Repository: incubator-reef Updated Branches: refs/heads/master 2a1565ff3 -> 85bf1da4d
[REEF-198] Updated namespace for the Bridge classes Currently, bridge classes still use Microsoft.reef. as name space. This PR is to change the interfaces in Driver project to use Org.Apache.REEF.Driver.Interop. For rest of the clr class in Bridge project, replace Microsoft.Reef to Org.Apache.REEF JIRA: [REEF-198](https://issues.apache.org/jira/browse/REEF-198) Pull Requests: This closes #102 (the old PR that became obsolete by other changes) This closes #136 (current PR) Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/85bf1da4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/85bf1da4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/85bf1da4 Branch: refs/heads/master Commit: 85bf1da4d573135962385b60da66c06ded27aea5 Parents: 2a1565f Author: Julia Wang <[email protected]> Authored: Sun Apr 5 22:26:41 2015 -0700 Committer: Markus Weimer <[email protected]> Committed: Tue Apr 7 09:44:42 2015 -0700 ---------------------------------------------------------------------- .../cs/Org.Apache.REEF.Bridge/InteropLogger.cpp | 58 ++++----- lang/cs/Org.Apache.REEF.Bridge/InteropLogger.h | 32 ++--- .../InteropReturnInfo.cpp | 124 ++++++++++--------- .../Org.Apache.REEF.Bridge/InteropReturnInfo.h | 48 +++---- .../Bridge/IInteropReturnInfo.cs | 30 +++++ .../cs/Org.Apache.REEF.Driver/Bridge/ILogger.cs | 37 ++++++ .../InteropInterface/IInteropReturnInfo.cs | 30 ----- .../InteropInterface/ILogger.cs | 37 ------ .../Org.Apache.REEF.Driver.csproj | 4 +- 9 files changed, 204 insertions(+), 196 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.cpp ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.cpp b/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.cpp index 418bd55..26c0cff 100644 --- a/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.cpp +++ b/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.cpp @@ -18,33 +18,35 @@ */ #include "InteropLogger.h" -namespace Microsoft { - namespace Reef { - namespace Interop { - /// currently not being used - InteropLogger::InteropLogger (JNIEnv* env, jobject jobjectInteropLogger) { - _env = env; - _jobjectInteropLogger = jobjectInteropLogger; - _jclassInteropLogger = env->GetObjectClass(jobjectInteropLogger); - wchar_t formatBuf[1024]; - if (NULL == _jclassInteropLogger) { - swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jclassInteropLogger %p\n", _jclassInteropLogger); - fwprintf (stdout, formatBuf); - fflush (stdout); - } - _jmidLog = env->GetMethodID(_jclassInteropLogger, "Log", "(ILjava/lang/String;)V"); - if (NULL == _jmidLog) { - swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidLog %p\n", _jmidLog); - fwprintf (stdout, formatBuf); - fflush (stdout); - } +namespace Org { + namespace Apache { + namespace REEF { + namespace Bridge { + /// currently not being used + InteropLogger::InteropLogger(JNIEnv* env, jobject jobjectInteropLogger) { + _env = env; + _jobjectInteropLogger = jobjectInteropLogger; + _jclassInteropLogger = env->GetObjectClass(jobjectInteropLogger); + wchar_t formatBuf[1024]; + if (NULL == _jclassInteropLogger) { + swprintf_s(formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jclassInteropLogger %p\n", _jclassInteropLogger); + fwprintf(stdout, formatBuf); + fflush(stdout); + } + _jmidLog = env->GetMethodID(_jclassInteropLogger, "Log", "(ILjava/lang/String;)V"); + if (NULL == _jmidLog) { + swprintf_s(formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidLog %p\n", _jmidLog); + fwprintf(stdout, formatBuf); + fflush(stdout); + } - } - void InteropLogger::Log(TraceLevel traceLevel, String^ message) { - pin_ptr<const wchar_t> wch = PtrToStringChars(message); - jstring msg = _env->NewString((const jchar*)wch, message->Length); - _env->CallObjectMethod(_jobjectInteropLogger, _jmidLog, (int)traceLevel, msg); - } - } - } + } + void InteropLogger::Log(TraceLevel traceLevel, String^ message) { + pin_ptr<const wchar_t> wch = PtrToStringChars(message); + jstring msg = _env->NewString((const jchar*)wch, message->Length); + _env->CallObjectMethod(_jobjectInteropLogger, _jmidLog, (int)traceLevel, msg); + } + } + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.h ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.h b/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.h index 0c0d162..711c8cf 100644 --- a/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.h +++ b/lang/cs/Org.Apache.REEF.Bridge/InteropLogger.h @@ -27,21 +27,23 @@ using namespace System::IO; using namespace System::Collections::Generic; using namespace System::Runtime::InteropServices; using namespace System::Reflection; -using namespace Microsoft::Reef::Interop; +using namespace Org::Apache::REEF::Driver::Bridge; -namespace Microsoft { - namespace Reef { - namespace Interop { - public ref class InteropLogger : public ILogger { - jobject _jobjectInteropLogger; - jclass _jclassInteropLogger; - jmethodID _jmidLog; - JNIEnv* _env; +namespace Org { + namespace Apache { + namespace REEF { + namespace Bridge { + public ref class InteropLogger : public ILogger { + jobject _jobjectInteropLogger; + jclass _jclassInteropLogger; + jmethodID _jmidLog; + JNIEnv* _env; - public: - InteropLogger (JNIEnv* env, jobject jobjectInteropLogger); - virtual void Log(TraceLevel traceLevel, String^ message ); - }; - } - } + public: + InteropLogger(JNIEnv* env, jobject jobjectInteropLogger); + virtual void Log(TraceLevel traceLevel, String^ message); + }; + } + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.cpp ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.cpp b/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.cpp index 821c0d1..8f1048e 100644 --- a/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.cpp +++ b/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.cpp @@ -18,71 +18,73 @@ */ #include "InteropReturnInfo.h" -namespace Microsoft { - namespace Reef { - namespace Interop { - // currently not being used - InteropReturnInfo::InteropReturnInfo ( - JNIEnv* env, - jobject jobjectInteropReturnInfo, - ILogger^ logger - ) { - _env = env; - _jobjectInteropReturnInfo = jobjectInteropReturnInfo; - jclass thisClass = env->GetObjectClass(jobjectInteropReturnInfo); - wchar_t formatBuf[1024]; +namespace Org { + namespace Apache { + namespace REEF { + namespace Bridge { + // currently not being used + InteropReturnInfo::InteropReturnInfo( + JNIEnv* env, + jobject jobjectInteropReturnInfo, + ILogger^ logger + ) { + _env = env; + _jobjectInteropReturnInfo = jobjectInteropReturnInfo; + jclass thisClass = env->GetObjectClass(jobjectInteropReturnInfo); + wchar_t formatBuf[1024]; - swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"zzzzzzz this should be printed by java jmid 00 %p\n", thisClass); - logger->Log(TraceLevel::Error, gcnew String(formatBuf)); - _jmidAddExceptionString = env->GetMethodID(thisClass, "addExceptionString", "(Ljava/lang/String;)V"); - if (NULL == _jmidAddExceptionString) { - swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidAddExceptionString %p\n", _jmidAddExceptionString); - fwprintf (stdout, formatBuf); - fflush (stdout); - } + swprintf_s(formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"zzzzzzz this should be printed by java jmid 00 %p\n", thisClass); + logger->Log(TraceLevel::Error, gcnew String(formatBuf)); + _jmidAddExceptionString = env->GetMethodID(thisClass, "addExceptionString", "(Ljava/lang/String;)V"); + if (NULL == _jmidAddExceptionString) { + swprintf_s(formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidAddExceptionString %p\n", _jmidAddExceptionString); + fwprintf(stdout, formatBuf); + fflush(stdout); + } - _jmidHasExceptions = env->GetMethodID(thisClass, "hasExceptions", "()Z"); - if (NULL == _jmidHasExceptions) { - swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidHasExceptions %p\n", _jmidHasExceptions); - fwprintf (stdout, formatBuf); - fflush (stdout); - } + _jmidHasExceptions = env->GetMethodID(thisClass, "hasExceptions", "()Z"); + if (NULL == _jmidHasExceptions) { + swprintf_s(formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidHasExceptions %p\n", _jmidHasExceptions); + fwprintf(stdout, formatBuf); + fflush(stdout); + } - _jmidsetReturnCode = env->GetMethodID(thisClass, "setReturnCode", "(I)V"); - if (NULL == _jmidsetReturnCode) { - swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidsetReturnCode %p\n", _jmidsetReturnCode); - fwprintf (stdout, formatBuf); - fflush (stdout); - } + _jmidsetReturnCode = env->GetMethodID(thisClass, "setReturnCode", "(I)V"); + if (NULL == _jmidsetReturnCode) { + swprintf_s(formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidsetReturnCode %p\n", _jmidsetReturnCode); + fwprintf(stdout, formatBuf); + fflush(stdout); + } - _jmidgetReturnCode = env->GetMethodID(thisClass, "getReturnCode", "()I"); - if (NULL == _jmidgetReturnCode) { - swprintf_s (formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidgetReturnCode %p\n", _jmidgetReturnCode); - fwprintf (stdout, formatBuf); - fflush (stdout); - } - } + _jmidgetReturnCode = env->GetMethodID(thisClass, "getReturnCode", "()I"); + if (NULL == _jmidgetReturnCode) { + swprintf_s(formatBuf, sizeof(formatBuf) / sizeof(wchar_t), L"_jmidgetReturnCode %p\n", _jmidgetReturnCode); + fwprintf(stdout, formatBuf); + fflush(stdout); + } + } - void InteropReturnInfo::AddExceptionString(String^ exceptionString) { - HasExceptions(); - pin_ptr<const wchar_t> wch = PtrToStringChars(exceptionString); - jstring ret = _env->NewString((const jchar*)wch, exceptionString->Length); - _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidAddExceptionString, ret); - HasExceptions(); - } + void InteropReturnInfo::AddExceptionString(String^ exceptionString) { + HasExceptions(); + pin_ptr<const wchar_t> wch = PtrToStringChars(exceptionString); + jstring ret = _env->NewString((const jchar*)wch, exceptionString->Length); + _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidAddExceptionString, ret); + HasExceptions(); + } - Boolean InteropReturnInfo::HasExceptions() { - jobject obj = _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidHasExceptions); - return ((int)obj) != 0; - } - void InteropReturnInfo::SetReturnCode(int rc) { - _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidsetReturnCode, rc); - GetReturnCode(); - } - int InteropReturnInfo::GetReturnCode() { - jobject obj = _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidgetReturnCode); - return (int)obj; - } - } - } + Boolean InteropReturnInfo::HasExceptions() { + jobject obj = _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidHasExceptions); + return ((int)obj) != 0; + } + void InteropReturnInfo::SetReturnCode(int rc) { + _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidsetReturnCode, rc); + GetReturnCode(); + } + int InteropReturnInfo::GetReturnCode() { + jobject obj = _env->CallObjectMethod(_jobjectInteropReturnInfo, _jmidgetReturnCode); + return (int)obj; + } + } + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.h ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.h b/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.h index a79e85e..93cc504 100644 --- a/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.h +++ b/lang/cs/Org.Apache.REEF.Bridge/InteropReturnInfo.h @@ -27,31 +27,33 @@ using namespace System::IO; using namespace System::Collections::Generic; using namespace System::Runtime::InteropServices; using namespace System::Reflection; -using namespace Microsoft::Reef::Interop; +using namespace Org::Apache::REEF::Driver::Bridge; -namespace Microsoft { - namespace Reef { - namespace Interop { - public ref class InteropReturnInfo : public IInteropReturnInfo { - JNIEnv* _env; - jobject _jobjectInteropReturnInfo; +namespace Org { + namespace Apache { + namespace REEF { + namespace Bridge { + public ref class InteropReturnInfo : public IInteropReturnInfo { + JNIEnv* _env; + jobject _jobjectInteropReturnInfo; - jmethodID _jmidAddExceptionString; - jmethodID _jmidHasExceptions; - jmethodID _jmidsetReturnCode; - jmethodID _jmidgetReturnCode; + jmethodID _jmidAddExceptionString; + jmethodID _jmidHasExceptions; + jmethodID _jmidsetReturnCode; + jmethodID _jmidgetReturnCode; - public: - InteropReturnInfo ( - JNIEnv* env, - jobject jobjectInteropReturnInfo, - ILogger^ logger - ); - virtual void AddExceptionString(String^ exceptionString); - virtual Boolean HasExceptions(); - virtual void SetReturnCode(int rc); - virtual int GetReturnCode(); - }; - } + public: + InteropReturnInfo( + JNIEnv* env, + jobject jobjectInteropReturnInfo, + ILogger^ logger + ); + virtual void AddExceptionString(String^ exceptionString); + virtual Boolean HasExceptions(); + virtual void SetReturnCode(int rc); + virtual int GetReturnCode(); + }; + } + } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Driver/Bridge/IInteropReturnInfo.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/IInteropReturnInfo.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/IInteropReturnInfo.cs new file mode 100644 index 0000000..a479158 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/IInteropReturnInfo.cs @@ -0,0 +1,30 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +using System; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public interface IInteropReturnInfo + { + void AddExceptionString(String exceptionString); + Boolean HasExceptions(); + void SetReturnCode(int rc); + int GetReturnCode(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Driver/Bridge/ILogger.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/ILogger.cs b/lang/cs/Org.Apache.REEF.Driver/Bridge/ILogger.cs new file mode 100644 index 0000000..4ec822b --- /dev/null +++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/ILogger.cs @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +using System; + +namespace Org.Apache.REEF.Driver.Bridge +{ + public enum TraceLevel : int + { + NoTrace = Int32.MaxValue, + + Error = 1000, + Warning = 900, + Info = 800, + Verbose = 300, + } + + public interface ILogger + { + void Log(TraceLevel traceLevel, String message); + } +} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Driver/InteropInterface/IInteropReturnInfo.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/InteropInterface/IInteropReturnInfo.cs b/lang/cs/Org.Apache.REEF.Driver/InteropInterface/IInteropReturnInfo.cs deleted file mode 100644 index b3b930a..0000000 --- a/lang/cs/Org.Apache.REEF.Driver/InteropInterface/IInteropReturnInfo.cs +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -using System; - -namespace Microsoft.Reef.Interop -{ - public interface IInteropReturnInfo - { - void AddExceptionString(String exceptionString); - Boolean HasExceptions(); - void SetReturnCode(int rc); - int GetReturnCode(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Driver/InteropInterface/ILogger.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/InteropInterface/ILogger.cs b/lang/cs/Org.Apache.REEF.Driver/InteropInterface/ILogger.cs deleted file mode 100644 index 4a7f9b2..0000000 --- a/lang/cs/Org.Apache.REEF.Driver/InteropInterface/ILogger.cs +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -using System; - -namespace Microsoft.Reef.Interop -{ - public enum TraceLevel : int - { - NoTrace = Int32.MaxValue, - - Error = 1000, - Warning = 900, - Info = 800, - Verbose = 300, - } - - public interface ILogger - { - void Log(TraceLevel traceLevel, String message); - } -} http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/85bf1da4/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj b/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj index 7185cec..359b956 100644 --- a/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj +++ b/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj @@ -79,6 +79,8 @@ under the License. <Compile Include="Bridge\HttpServerPort.cs" /> <Compile Include="Bridge\IHttpHandler.cs" /> <Compile Include="Bridge\IHttpMessage.cs" /> + <Compile Include="Bridge\IInteropReturnInfo.cs" /> + <Compile Include="Bridge\ILogger.cs" /> <Compile Include="Bridge\ReefHttpRequest.cs" /> <Compile Include="Bridge\ReefHttpResponse.cs" /> <Compile Include="ClientManager.cs" /> @@ -133,8 +135,6 @@ under the License. <Compile Include="Evaluator\IFailedEvaluator.cs" /> <Compile Include="FailedJob.cs" /> <Compile Include="IDriver.cs" /> - <Compile Include="InteropInterface\IInteropReturnInfo.cs" /> - <Compile Include="InteropInterface\ILogger.cs" /> <Compile Include="IStartHandler.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Task\ICompletedTask.cs" />
