Repository: incubator-reef Updated Branches: refs/heads/master cfa149a6e -> a9919be4a
[REEF-640]:Create CLI CPP project Org.Apache.REEF.ClrDriver. Phase I This addressed the issue by adding a managed cpp project to start clr driver JIRA: [REEF-640](https://issues.apache.org/jira/browse/REEF-640) This closes #413 Author: Beysim Sezgin <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/a9919be4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/a9919be4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/a9919be4 Branch: refs/heads/master Commit: a9919be4a6ee81c5a68c11b714bbd7945c386b1b Parents: cfa149a Author: Beysim Sezgin <[email protected]> Authored: Tue Aug 25 10:23:47 2015 -0700 Committer: Julia Wang <[email protected]> Committed: Thu Aug 27 17:31:23 2015 -0700 ---------------------------------------------------------------------- .../Common/DriverFolderPreparationHelper.cs | 22 +- .../Org.Apache.REEF.Client.csproj | 11 + .../Properties/Resources.xml | 6 + .../Org.Apache.REEF.ClrDriver/AssemblyInfo.cpp | 56 +++ .../Org.Apache.REEF.ClrDriver.cpp | 341 +++++++++++++++++++ .../Org.Apache.REEF.ClrDriver.h | 29 ++ .../Org.Apache.REEF.ClrDriver.vcxproj | 109 ++++++ lang/cs/Org.Apache.REEF.ClrDriver/ReadMe.txt | 53 +++ lang/cs/Org.Apache.REEF.ClrDriver/app.ico | Bin 0 -> 11001 bytes lang/cs/Org.Apache.REEF.ClrDriver/app.rc | Bin 0 -> 2558 bytes lang/cs/Org.Apache.REEF.ClrDriver/resource.h | 21 ++ lang/cs/Org.Apache.REEF.sln | Bin 31052 -> 32048 bytes 12 files changed, 637 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.Client/Common/DriverFolderPreparationHelper.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client/Common/DriverFolderPreparationHelper.cs b/lang/cs/Org.Apache.REEF.Client/Common/DriverFolderPreparationHelper.cs index 0f1598b..7c9a37f 100644 --- a/lang/cs/Org.Apache.REEF.Client/Common/DriverFolderPreparationHelper.cs +++ b/lang/cs/Org.Apache.REEF.Client/Common/DriverFolderPreparationHelper.cs @@ -38,11 +38,14 @@ namespace Org.Apache.REEF.Client.Common { private const string DLLFileNameExtension = ".dll"; private const string EXEFileNameExtension = ".exe"; - private const string ClientJarResourceName = "reef_bridge_client"; - private const string ClientJarFileNameResourceName = "ClientJarFullName"; - private const string DriverJarResourceName = "reef_bridge_driver"; - private const string DriveJarFileNameResourceName = "DriverJarFullName"; + private readonly static Tuple<string, string>[] clientFileResources = new Tuple<string, string>[] + { + new Tuple<string, string>("ClientJarFullName", "reef_bridge_client"), + new Tuple<string, string>("DriverJarFullName", "reef_bridge_driver"), + // enable with next pull request + // new Tuple<string, string>("ClrDriverFullName", "reef_clrdriver"), + }; private static readonly Logger Logger = Logger.GetLogger(typeof(DriverFolderPreparationHelper)); private readonly AvroConfigurationSerializer _configurationSerializer; @@ -123,13 +126,10 @@ namespace Org.Apache.REEF.Client.Common private void AddAssemblies() { var resourceHelper = new ResourceHelper(typeof(DriverFolderPreparationHelper).Assembly); - var clientJarBytes = resourceHelper.GetBytes(ClientJarResourceName); - var clientJarFileName = resourceHelper.GetString(ClientJarFileNameResourceName); - var driverJarBytes = resourceHelper.GetBytes(DriverJarResourceName); - var driverJarFileName = resourceHelper.GetString(DriveJarFileNameResourceName); - - File.WriteAllBytes(clientJarFileName, clientJarBytes); - File.WriteAllBytes(driverJarFileName, driverJarBytes); + foreach (var fileResources in clientFileResources) + { + File.WriteAllBytes(resourceHelper.GetString(fileResources.Item1), resourceHelper.GetBytes(fileResources.Item2)); + } // TODO: Be more precise, e.g. copy the JAR only to the driver. var assemblies = Directory.GetFiles(@".\").Where(IsAssemblyToCopy); http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.Client/Org.Apache.REEF.Client.csproj ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client/Org.Apache.REEF.Client.csproj b/lang/cs/Org.Apache.REEF.Client/Org.Apache.REEF.Client.csproj index 0a1becd..de1b045 100644 --- a/lang/cs/Org.Apache.REEF.Client/Org.Apache.REEF.Client.csproj +++ b/lang/cs/Org.Apache.REEF.Client/Org.Apache.REEF.Client.csproj @@ -109,6 +109,14 @@ under the License. <Project>{75503f90-7b82-4762-9997-94b5c68f15db}</Project> <Name>Org.Apache.REEF.Examples</Name> </ProjectReference> + <ProjectReference Include="$(SolutionDir)\Org.Apache.REEF.ClrDriver\Org.Apache.REEF.ClrDriver.vcxproj"> + <Project>{0097e4ac-0cc9-450c-bc22-acd5b2d55e70}</Project> + <Name>Org.Apache.REEF.ClrDriver</Name> + <ReferenceOutputAssembly>false</ReferenceOutputAssembly> + <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies> + <LinkLibraryDependencies>false</LinkLibraryDependencies> + <UseLibraryDependencyInputs>false</UseLibraryDependencyInputs> + </ProjectReference> </ItemGroup> <ItemGroup> <EmbeddedResource Include="$(TempResxFile)"> @@ -164,6 +172,7 @@ under the License. var binDir = @"lang\cs\bin\x64"; var resxInputPath = Path.Combine(ProjectFolder, srcDir, "Resources.xml"); var resourceDir = Path.Combine(ProjectFolder, binDir, DebugOrRelease, "Org.Apache.REEF.Bridge.JAR"); + var clrDriverDir = Path.Combine(ProjectFolder, binDir, DebugOrRelease, "Org.Apache.REEF.ClrDriver"); var byteArrayType = ";System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"; var jarRest = reefVersion + "-shaded.jar" + byteArrayType; @@ -171,8 +180,10 @@ under the License. dllResources.Add("reef_bridge_client", resourceDir + @"\reef-bridge-client-" + jarRest); dllResources.Add("reef_bridge_driver", resourceDir + @"\reef-bridge-java-" + jarRest); dllResources.Add("evaluator", resourceDir + "Org.Apache.REEF.Evaluator.exe" + byteArrayType); + dllResources.Add("reef_clrdriver", clrDriverDir + @"\Org.Apache.REEF.ClrDriver.exe" + byteArrayType); dllResources.Add("ClientJarFullName", "reef-bridge-client-" + reefVersion + "-shaded.jar"); dllResources.Add("DriverJarFullName", "reef-bridge-java-" + reefVersion + "-shaded.jar"); + dllResources.Add("ClrDriverFullName", "Org.Apache.REEF.ClrDriver.exe"); XElement root = XElement.Load(resxInputPath); var resources = root.Descendants().Where(x => x.Name.LocalName == "data").ToList(); http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.Client/Properties/Resources.xml ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Client/Properties/Resources.xml b/lang/cs/Org.Apache.REEF.Client/Properties/Resources.xml index d0c8554..64e6cf4 100644 --- a/lang/cs/Org.Apache.REEF.Client/Properties/Resources.xml +++ b/lang/cs/Org.Apache.REEF.Client/Properties/Resources.xml @@ -85,6 +85,9 @@ This file is used to embed JAR files to client dll <data name="DriverJarFullName" xml:space="preserve"> <value>reef-bridge-java-0.13.0-incubating-SNAPSHOT-shaded.jar</value> </data> + <data name="ClrDriverFullName" xml:space="preserve"> + <value>Org.Apache.REEF.ClrDriver.exe</value> + </data> <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> <data name="reef_bridge_client" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>E:\src\reef\lang\cs\bin\x64\Debug\Org.Apache.REEF.Bridge.JAR\reef-bridge-client-0.13.0-incubating-SNAPSHOT-shaded.jar;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> @@ -92,4 +95,7 @@ This file is used to embed JAR files to client dll <data name="reef_bridge_driver" type="System.Resources.ResXFileRef, System.Windows.Forms"> <value>E:\src\reef\lang\cs\bin\x64\Debug\Org.Apache.REEF.Bridge.JAR\reef-bridge-java-0.13.0-incubating-SNAPSHOT-shaded.jar;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </data> + <data name="reef_clrdriver" type="System.Resources.ResXFileRef, System.Windows.Forms"> + <value>E:\src\reef\lang\cs\bin\x64\Debug\Org.Apache.REEF.ClrDriver\Org.Apache.REEF.ClrDriver.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </data> </root> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.ClrDriver/AssemblyInfo.cpp ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.ClrDriver/AssemblyInfo.cpp b/lang/cs/Org.Apache.REEF.ClrDriver/AssemblyInfo.cpp new file mode 100644 index 0000000..6197c5b --- /dev/null +++ b/lang/cs/Org.Apache.REEF.ClrDriver/AssemblyInfo.cpp @@ -0,0 +1,56 @@ +/** +* 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 namespace System; +using namespace System::Reflection; +using namespace System::Runtime::CompilerServices; +using namespace System::Runtime::InteropServices; +using namespace System::Security::Permissions; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly:AssemblyTitle("Org.Apache.REEF.ClrDriver")] +[assembly:AssemblyDescription("")] +[assembly:AssemblyConfiguration("")] +[assembly:AssemblyCompany("")] +[assembly:AssemblyProduct("Org.Apache.REEF.ClrDriver")] +[assembly:AssemblyCopyright("Copyright � 2015")] +[assembly:AssemblyTrademark("")] +[assembly:AssemblyCulture("")] + + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the value or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly:AssemblyVersion("0.13.0.0")] +[assembly:AssemblyFileVersion("0.13.0.0")] + +[assembly:ComVisible(false)]; + +[assembly:CLSCompliantAttribute(true)]; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.cpp ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.cpp b/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.cpp new file mode 100644 index 0000000..6142b42 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.cpp @@ -0,0 +1,341 @@ +/** +* 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. +*/ +#include "Org.Apache.REEF.ClrDriver.h" +using namespace std;; + +typedef jint(JNICALL *JNI_CreateJavaVM_FN)(JavaVM **pvm, void **penv, void *args); +LPCTSTR JAVA_HOME = L"JAVA_HOME"; +LPCTSTR JVM_DLL1 = L"\\jre\\bin\\server\\jvm.dll"; +LPCTSTR JVM_DLL2 = L"\\jre\\bin\\client\\jvm.dll"; +const char* JNI_CreateJavaVM_Func_Name = "JNI_CreateJavaVM"; +const char* JavaOptionClassPath = "-classpath"; +const char* JavaMainMethodSignature = "([Ljava/lang/String;)V"; +const char* JavaStringClassPath = "java/lang/String"; +const int maxPathBufSize = 16 * 1024; +const char ClassPathSeparatorCharForWindows = ';'; + +const char* launcherClass = "org.apache.reef.runtime.common.REEFLauncher"; +const char* JavaMainMethodName = "main"; +const char* JavaClassPath = "-Djava.class.path="; + + +typedef enum { + ErrSuccess = 0, + ErrGetEnvironmentVariable = 1, + ErrLoadLibraryJVM = 2, + ErrGetProcAddress = 3, + ErrCreateJavaVM = 4, + ErrFindClassEntry = 5, + ErrGetStaticMethodID = 6, + ErrFindClassString = 7, + ErrNewObjectArray = 8, +} ErrorEnum; + +// +// figure out where jvm options end, entry class method and its parameters begin +// +void GetCounts( + int cArgs, + char*argv[], + int& optionCount, + int& firstOptionOrdinal, + int& argCount, + int& firstArgOrdinal) +{ + bool option = true; + optionCount = 0; + firstOptionOrdinal = 2; + argCount = 0; + firstArgOrdinal = -1; + + for (int i = firstOptionOrdinal; i < cArgs; i++) { + if (option && 0 == strcmp(argv[i], launcherClass)) { + option = false; + firstArgOrdinal = i; + } + if (option) { + ++optionCount; + } + else { + ++argCount; + } + } +} + +// +// Set JVM option. JNI does not support unicode +// +void SetOption(JavaVMOption *option, char *src) +{ + size_t len = strlen(src) + 1; + char* pszOption = new char[len]; + strcpy_s(pszOption, len, src); + option->optionString = pszOption; + option->extraInfo = nullptr; +} + +// +// Jni does not expand * and *.jar +// We need to do it ourselves. +// +char *ExpandJarPaths(char *jarPaths) +{ + String^ ClassPathSeparatorStringForWindows = ";"; + const int StringBuilderInitalSize = 1024 * 16; + System::Text::StringBuilder^ sb = gcnew System::Text::StringBuilder(StringBuilderInitalSize); + sb->Append(gcnew String(JavaClassPath)); + String^ pathString = gcnew String(jarPaths); + array<String^>^ rawPaths = pathString->Split(';'); + for (int i = 0; i < rawPaths->Length; i++) + { + String^ oldPath = rawPaths[i]; + int oldPathLength = oldPath->Length; + String^ path; + bool shouldExpand = false; + if (oldPath->EndsWith("*")) + { + path = oldPath + ".jar"; + shouldExpand = true; + } + else if (oldPath->EndsWith("*.jar")) + { + path = oldPath; + shouldExpand = true; + } + else + { + sb->Append(ClassPathSeparatorStringForWindows); + sb->Append(oldPath); + } + if (shouldExpand) + { + try + { + auto filesDir = System::IO::Path::GetDirectoryName(path); + auto fileName = System::IO::Path::GetFileName(path); + auto directoryInfo = gcnew System::IO::DirectoryInfo(filesDir); + auto files = directoryInfo->GetFiles(fileName); + for (int i = 0; i < files->Length; i++) + { + auto fullName = System::IO::Path::Combine(files[i]->Directory->ToString(), files[i]->ToString()); + sb->Append(ClassPathSeparatorStringForWindows); + sb->Append(fullName); + } + } + catch (System::IO::DirectoryNotFoundException^) + { + //Ignore invalid paths. + } + } + } + auto newPaths = sb->ToString(); + int len = newPaths->Length; + char* finalPath = new char[len + 1]; + auto hglobal = System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(newPaths); + memcpy(finalPath, (void*)hglobal, len + 1); + System::Runtime::InteropServices::Marshal::FreeHGlobal(hglobal); + return finalPath; +} + +JavaVMOption* GetJavaOptions(char *argv[], int& optionCount, int firstOptionOrdinal) +{ + JavaVMOption* options = new JavaVMOption[optionCount + 1]; + char classPathBuf[maxPathBufSize]; + int sourceOrdinal = firstOptionOrdinal; + + for (int i = 0; i < optionCount; i++) { + SetOption(options + i, argv[sourceOrdinal]); + if (0 == strcmp(argv[i + firstOptionOrdinal], JavaOptionClassPath) && ((i + 1) < optionCount)) { + strcpy_s(classPathBuf, argv[++sourceOrdinal]); + for (char* ptr = classPathBuf; *ptr; ptr++) { + if (*ptr == '/') { + *ptr = '\\'; + } + } + strcat_s(classPathBuf, ";local\\*;global\\*"); + auto expandedPath = ExpandJarPaths(classPathBuf); + SetOption(options + i, expandedPath); + --optionCount; + } + ++sourceOrdinal; + } + + SetOption(options + optionCount++, "-verbose:jni"); + SetOption(options + optionCount++, "-verbose:class"); + + return options; +} + +int Get_CreateJavaVM_Function(JNI_CreateJavaVM_FN& fn_JNI_CreateJavaVM) +{ + wchar_t jvmDllPath1[maxPathBufSize]; + wchar_t jvmDllPath2[maxPathBufSize]; + DWORD rc = GetEnvironmentVariable(JAVA_HOME, jvmDllPath1, maxPathBufSize); + if (0 == rc) { + wprintf(L"Could not GetEnvironmentVariable %ls\n", JAVA_HOME); + return ErrGetEnvironmentVariable; + } + + wcscat_s(jvmDllPath1, maxPathBufSize, JVM_DLL1); + + HMODULE jvm_dll = LoadLibrary(jvmDllPath1); + if (jvm_dll == NULL) { + wprintf(L"Could not load dll %ls\n", jvmDllPath1); + GetEnvironmentVariable(JAVA_HOME, jvmDllPath2, maxPathBufSize); + wcscat_s(jvmDllPath2, maxPathBufSize, JVM_DLL2); + jvm_dll = LoadLibrary(jvmDllPath2); + if (jvm_dll == NULL) { + wprintf(L"Could not load dll %ls\n", jvmDllPath2); + return ErrLoadLibraryJVM; + } + } + + fn_JNI_CreateJavaVM = (JNI_CreateJavaVM_FN)GetProcAddress(jvm_dll, JNI_CreateJavaVM_Func_Name); + if (fn_JNI_CreateJavaVM == NULL) { + printf("Could not GetProcAddress %s\n", JNI_CreateJavaVM_Func_Name); + return ErrGetProcAddress; + } + + return ErrSuccess; +} + +// +// Creates Java vm with the given options +// +int CreateJVM(JNIEnv*& env, JavaVM*& jvm, JavaVMOption* options, int optionCount) { + JNI_CreateJavaVM_FN fn_JNI_CreateJavaVM; + int failureCode = 0; + if ((failureCode = Get_CreateJavaVM_Function(fn_JNI_CreateJavaVM)) != ErrSuccess) { + return failureCode; + } + + for (int i = 0; i < optionCount; i++) { + printf("Option %d [%s]\n", i, options[i].optionString); + } + fflush(stdout); + JavaVMInitArgs vm_args; + memset(&vm_args, 0, sizeof(vm_args)); + vm_args.version = JNI_VERSION_1_6; + vm_args.nOptions = optionCount; + vm_args.options = options; + vm_args.ignoreUnrecognized = JNI_FALSE; + long status = fn_JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args); + if (status) { + printf("Could not fn_JNI_CreateJavaVM\n"); + return ErrCreateJavaVM; + } + return ErrSuccess; +} + +// +// Invokes main method of entry class. +// I.E. org/apache/reef/runtime/common/REEFLauncher +// +int CallMainMethodOfEntryClass( + JNIEnv* env, + char* argv[], + int firstArgOrdinal, + int argCount) +{ + // int the entry class name, Replace '.' with '/' + char classBuf[maxPathBufSize]; + strcpy_s(classBuf, argv[firstArgOrdinal]); + for (char* ptr = classBuf; *ptr; ptr++) { + if (*ptr == '.') { + *ptr = '/'; + } + } + + // Find the entry class + jclass mainClass = env->FindClass(classBuf); + if (!mainClass) { + printf("Failed to find class '%s'", classBuf); + fflush(stdout); + if (env->ExceptionOccurred()) { + env->ExceptionDescribe(); + } + fflush(stdout); + return ErrFindClassEntry; + } + + // find method 'static void main (String[] args)' + jmethodID mainMethod = env->GetStaticMethodID(mainClass, JavaMainMethodName, JavaMainMethodSignature); + if (!mainMethod) { + printf("Failed to find jmethodID of 'main'"); + return ErrGetStaticMethodID; + } + + // Find string class + jclass stringClass = env->FindClass("java/lang/String"); + if (!stringClass) { + printf("Failed to find java/lang/String"); + return ErrFindClassString; + } + + // Allocate string[] for main method parameter + jobjectArray args = env->NewObjectArray(argCount - 1, stringClass, 0); + if (!args) { + printf("Failed to create args array"); + return ErrNewObjectArray; + } + + // Copy parameters for main method + for (int i = 0; i < argCount - 1; ++i) { + env->SetObjectArrayElement(args, i, env->NewStringUTF(argv[firstArgOrdinal + 1 + i])); + } + + // call main method with parameters + env->CallStaticVoidMethod(mainClass, mainMethod, args); + + return ErrSuccess; +} + +int main(int cArgs, char *argv[]) +{ + int optionCount; + int firstOptionOrdinal; + int argCount; + int firstArgOrdinal; + + GetCounts(cArgs, argv, optionCount, firstOptionOrdinal, argCount, firstArgOrdinal); + JavaVMOption* options = GetJavaOptions(argv, optionCount, firstOptionOrdinal); + + JNIEnv *env; + JavaVM *jvm; + int failureCode = 0; + if ((failureCode = CreateJVM(env, jvm, options, optionCount)) != ErrSuccess) { + fflush(stdout); + return failureCode; + } + + if ((failureCode = CallMainMethodOfEntryClass(env, argv, firstArgOrdinal, argCount)) != ErrSuccess) { + fflush(stdout); + return failureCode; + } + + // Check for errors. + if (env->ExceptionOccurred()) { + env->ExceptionDescribe(); + } + + // Finally, destroy the JavaVM + jvm->DestroyJavaVM(); + + return 0; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.h ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.h b/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.h new file mode 100644 index 0000000..da99482 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.h @@ -0,0 +1,29 @@ +/** +* 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. +*/#pragma once +#define _USING_V110_SDK71_ + +#pragma warning( push ) +#pragma warning( disable : 4793 ) +#include <jni.h> +#pragma warning( pop ) +#include "mscoree.h" +#include "vcclr.h" +#include <string> + +using namespace System; http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.vcxproj ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.vcxproj b/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.vcxproj new file mode 100644 index 0000000..2d05399 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.ClrDriver/Org.Apache.REEF.ClrDriver.vcxproj @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{0097E4AC-0CC9-450C-BC22-ACD5B2D55E70}</ProjectGuid> + <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> + <Keyword>ManagedCProj</Keyword> + <RootNamespace>OrgApacheREEFClrDriver</RootNamespace> + </PropertyGroup> + <Import Project="$(SolutionDir)\build.props" /> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <CLRSupport>true</CLRSupport> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v120</PlatformToolset> + <CLRSupport>true</CLRSupport> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <LinkIncremental>true</LinkIncremental> + <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath> + <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <LinkIncremental>false</LinkIncremental> + <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;$(IncludePath)</IncludePath> + <OutDir>$(SolutionDir)bin\$(Platform)\$(Configuration)\$(ProjectName)\</OutDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalDependencies> + </AdditionalDependencies> + <SubSystem>Console</SubSystem> + <AdditionalOptions>/ignore:4248 %(AdditionalOptions)</AdditionalOptions> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + </ClCompile> + <Link> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalDependencies> + </AdditionalDependencies> + <SubSystem>Console</SubSystem> + <AdditionalOptions>/ignore:4248 %(AdditionalOptions)</AdditionalOptions> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Text Include="ReadMe.txt" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="Org.Apache.REEF.ClrDriver.h" /> + <ClInclude Include="resource.h" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="app.rc" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="AssemblyInfo.cpp" /> + <ClCompile Include="Org.Apache.REEF.ClrDriver.cpp" /> + </ItemGroup> + <ItemGroup> + <Image Include="app.ico" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.ClrDriver/ReadMe.txt ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.ClrDriver/ReadMe.txt b/lang/cs/Org.Apache.REEF.ClrDriver/ReadMe.txt new file mode 100644 index 0000000..3f4c7b3 --- /dev/null +++ b/lang/cs/Org.Apache.REEF.ClrDriver/ReadMe.txt @@ -0,0 +1,53 @@ +/** +* 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. +*/ +======================================================================== + APPLICATION : Org.Apache.REEF.ClrDriver Project Overview +======================================================================== + +AppWizard has created this Org.Apache.REEF.ClrDriver Application for you. + +This file contains a summary of what you will find in each of the files that +make up your Org.Apache.REEF.ClrDriver application. + +Org.Apache.REEF.ClrDriver.vcxproj + This is the main project file for VC++ projects generated using an Application Wizard. + It contains information about the version of Visual C++ that generated the file, and + information about the platforms, configurations, and project features selected with the + Application Wizard. + +Org.Apache.REEF.ClrDriver.vcxproj.filters + This is the filters file for VC++ projects generated using an Application Wizard. + It contains information about the association between the files in your project + and the filters. This association is used in the IDE to show grouping of files with + similar extensions under a specific node (for e.g. ".cpp" files are associated with the + "Source Files" filter). + +Org.Apache.REEF.ClrDriver.cpp + This is the main application source file. + +AssemblyInfo.cpp + Contains custom attributes for modifying assembly metadata. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +///////////////////////////////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.ClrDriver/app.ico ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.ClrDriver/app.ico b/lang/cs/Org.Apache.REEF.ClrDriver/app.ico new file mode 100644 index 0000000..d06d92b Binary files /dev/null and b/lang/cs/Org.Apache.REEF.ClrDriver/app.ico differ http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.ClrDriver/app.rc ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.ClrDriver/app.rc b/lang/cs/Org.Apache.REEF.ClrDriver/app.rc new file mode 100644 index 0000000..eab4306 Binary files /dev/null and b/lang/cs/Org.Apache.REEF.ClrDriver/app.rc differ http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.ClrDriver/resource.h ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.ClrDriver/resource.h b/lang/cs/Org.Apache.REEF.ClrDriver/resource.h new file mode 100644 index 0000000..3978b8f --- /dev/null +++ b/lang/cs/Org.Apache.REEF.ClrDriver/resource.h @@ -0,0 +1,21 @@ +/** +* 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. +*/ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by app.rc http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/a9919be4/lang/cs/Org.Apache.REEF.sln ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.sln b/lang/cs/Org.Apache.REEF.sln index ebc28a4..bbbf938 100644 Binary files a/lang/cs/Org.Apache.REEF.sln and b/lang/cs/Org.Apache.REEF.sln differ
