* Added the option of using default port (5567) when debugging Mobius driver app. It is possible to provide a specific port number for CSharpBackend and also continue using the old debug behavior by specifying port 0
* Deleted App.Config from examples and updated projects to share App.Config
* Updated documentation
* Added/updated tests
This commit is contained in:
Kaarthik Sivashanmugam 2016-08-09 14:52:25 -07:00 коммит произвёл GitHub
Родитель 1ab980cb20
Коммит a2fe4f5dee
27 изменённых файлов: 108 добавлений и 605 удалений

Просмотреть файл

@ -24,6 +24,7 @@ namespace Microsoft.Spark.CSharp.Configuration
public const string SPARKCLR_HOME = "SPARKCLR_HOME";
public const string SPARK_MASTER = "spark.master";
public const string CSHARPBACKEND_PORT = "CSHARPBACKEND_PORT";
public const int CSHARPBACKEND_DEBUG_PORT = 5567;
private readonly ILoggerService logger = LoggerServiceFactory.GetLogger(typeof(ConfigurationService));
private readonly SparkCLRConfiguration configuration;
@ -178,13 +179,21 @@ namespace Microsoft.Spark.CSharp.Configuration
internal override int GetPortNumber()
{
int cSharpBackendPortNumber = CSHARPBACKEND_DEBUG_PORT;
KeyValueConfigurationElement portConfig = appSettings.Settings[CSharpBackendPortNumberSettingKey];
if (portConfig == null)
{
throw new ConfigurationErrorsException(string.Format("Need to set {0} value in App.config for running in DEBUG mode.", CSharpBackendPortNumberSettingKey));
logger.LogInfo(
string.Format(
"Port number not set using setting {0} in App.config. Using default port {1} to connect to CSharpBackend",
CSharpBackendPortNumberSettingKey, cSharpBackendPortNumber));
}
int cSharpBackendPortNumber = int.Parse(portConfig.Value);
logger.LogInfo(string.Format("CSharpBackend port number read from app config {0}", cSharpBackendPortNumber));
else
{
cSharpBackendPortNumber = int.Parse(portConfig.Value);
logger.LogInfo(string.Format("CSharpBackend port number read from app config {0}. Using it to connect to CSharpBackend", cSharpBackendPortNumber));
}
return cSharpBackendPortNumber;
}

Просмотреть файл

@ -39,7 +39,7 @@ namespace AdapterTest
try
{
ConfigurationService debugConfiguration = new ConfigurationService();
Assert.Throws<ConfigurationErrorsException>(() => Console.WriteLine(debugConfiguration.BackendPortNumber));
Assert.AreEqual(ConfigurationService.CSHARPBACKEND_DEBUG_PORT, debugConfiguration.BackendPortNumber);
Assert.Throws<Exception>(() => Console.WriteLine(debugConfiguration.GetCSharpWorkerExePath()));
}
finally

Просмотреть файл

@ -36,10 +36,15 @@
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** Instructions to update the following settings for debug mode are at ** -->
<!--** http://github.com/Microsoft/Mobius/blob/master/notes/running-mobius-app.md#debug-mode **-->
<!--** Uncomment the following setting to run Spark driver executable in **debug** mode ** -->
<!--** Setting the port number is optional and needed only to override the default debug port number (5567) -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug <port number - optional>" ** -->
<!--** If port number is not specified default debug port number will be used **-->
<!--********************************************************************************************************-->
<!--
@ -62,6 +67,7 @@
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--** For more instructions refer to https://github.com/Microsoft/Mobius/blob/master/notes/linux-instructions.md#instructions-1 **-->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->

Просмотреть файл

@ -20,10 +20,15 @@
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** Instructions to update the following settings for debug mode are at ** -->
<!--** http://github.com/Microsoft/Mobius/blob/master/notes/running-mobius-app.md#debug-mode **-->
<!--** Uncomment the following setting to run Spark driver executable in **debug** mode ** -->
<!--** Setting the port number is optional and needed only to override the default debug port number (5567) -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug <port number - optional>" ** -->
<!--** If port number is not specified default debug port number will be used **-->
<!--********************************************************************************************************-->
<!--
@ -46,6 +51,7 @@
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--** For more instructions refer to https://github.com/Microsoft/Mobius/blob/master/notes/linux-instructions.md#instructions-1 **-->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->

Просмотреть файл

@ -1,75 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--*************************************************************************************-->
<!-- Log4Net is used by the example -->
<!--**************************************************************************************-->
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
<!--<appender-ref ref="LogFileAppender" />-->
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString">
<conversionPattern value="%env{TEMP}\\SparkCLRLogs\\SparkCLR-WordCount_%env{COMPUTERNAME}[%processid].log" />
</file>
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="2000" />
<param name="MaxFileSize" value="51200000" />
<param name="StaticLogFileName" value="false" />
<param name="DatePattern" value=".yyyy_MM_dd_hh" />
<param name="RollingStyle" value="Composite" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpBackendPortNumber" value="0"/>
-->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to override the location of CSharpWorker.exe to use ** -->
<!--** when running Spark in **local** or ** YARN ** modes ** -->
<!--** If this setting is not used, CSharpWorker.exe will be used from default location - location of driver exe ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\path\to\mobius\driver\application\CSharpWorker.exe"/>
-->
<!-- *** Settings for Mobius in Linux *** -->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->
<!--
<add key="CSharpWorkerPath" value="/path/to/mobius/driver/application/CSharpWorker.sh.exe"/>
-->
<!-- for Spark in ** YARN ** mode -->
<!--
<add key="CSharpWorkerPath" value="CSharpWorker.sh.exe"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -70,7 +70,9 @@
<None Include="..\..\packages\Microsoft.SparkCLR.1.6.100\lib\net45\CSharpWorker.exe.config">
<Link>CSharpWorker.exe.config</Link>
</None>
<None Include="App.config" />
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Просмотреть файл

@ -1,75 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--*************************************************************************************-->
<!-- Log4Net is used by the example -->
<!--**************************************************************************************-->
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
<!--<appender-ref ref="LogFileAppender" />-->
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString">
<conversionPattern value="%env{TEMP}\\SparkCLRLogs\\SparkCLR-WordCount_%env{COMPUTERNAME}[%processid].log" />
</file>
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="2000" />
<param name="MaxFileSize" value="51200000" />
<param name="StaticLogFileName" value="false" />
<param name="DatePattern" value=".yyyy_MM_dd_hh" />
<param name="RollingStyle" value="Composite" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpBackendPortNumber" value="0"/>
-->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to override the location of CSharpWorker.exe to use ** -->
<!--** when running Spark in **local** or ** YARN ** modes ** -->
<!--** If this setting is not used, CSharpWorker.exe will be used from default location - location of driver exe ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\path\to\mobius\driver\application\CSharpWorker.exe"/>
-->
<!-- *** Settings for Mobius in Linux *** -->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->
<!--
<add key="CSharpWorkerPath" value="/path/to/mobius/driver/application/CSharpWorker.sh.exe"/>
-->
<!-- for Spark in ** YARN ** mode -->
<!--
<add key="CSharpWorkerPath" value="CSharpWorker.sh.exe"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -64,8 +64,10 @@
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="WordCountExample.fs" />
<Content Include="App.config" />
<Content Include="packages.config" />
<Content Include="..\..\App.config">
<Link>App.config</Link>
</Content>
</ItemGroup>
<ItemGroup>
<Reference Include="CSharpWorker">

Просмотреть файл

@ -1,81 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--*************************************************************************************-->
<!-- Log4Net is used by the example -->
<!--**************************************************************************************-->
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
<!--<appender-ref ref="LogFileAppender" />-->
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString">
<conversionPattern value="%env{TEMP}\\SparkCLRLogs\\SparkCLR-Pi_%env{COMPUTERNAME}[%processid].log" />
</file>
<param name="AppendToFile" value="true" />
<param name="MaxSizeRollBackups" value="2000" />
<param name="MaxFileSize" value="51200000" />
<param name="StaticLogFileName" value="false" />
<param name="DatePattern" value=".yyyy_MM_dd_hh" />
<param name="RollingStyle" value="Composite" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpBackendPortNumber" value="0"/>
-->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to override the location of CSharpWorker.exe to use ** -->
<!--** when running Spark in **local** or ** YARN ** modes ** -->
<!--** If this setting is not used, CSharpWorker.exe will be used from default location - location of driver exe ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\path\to\mobius\driver\application\CSharpWorker.exe"/>
-->
<!-- *** Settings for Mobius in Linux *** -->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->
<!--
<add key="CSharpWorkerPath" value="/path/to/mobius/driver/application/CSharpWorker.sh.exe"/>
-->
<!-- for Spark in ** YARN ** mode -->
<!--
<add key="CSharpWorkerPath" value="CSharpWorker.sh.exe"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -69,8 +69,8 @@
<None Include="..\..\packages\Microsoft.SparkCLR.1.6.100\lib\net45\CSharpWorker.exe.config">
<Link>CSharpWorker.exe.config</Link>
</None>
<None Include="App.config">
<SubType>Designer</SubType>
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>

Просмотреть файл

@ -67,7 +67,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Просмотреть файл

@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpBackendPortNumber" value="0"/>
-->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to override the location of CSharpWorker.exe to use ** -->
<!--** when running Spark in **local** or ** YARN ** modes ** -->
<!--** If this setting is not used, CSharpWorker.exe will be used from default location - location of driver exe ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\path\to\mobius\driver\application\CSharpWorker.exe"/>
-->
<!-- *** Settings for Mobius in Linux *** -->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->
<!--
<add key="CSharpWorkerPath" value="/path/to/mobius/driver/application/CSharpWorker.sh.exe"/>
-->
<!-- for Spark in ** YARN ** mode -->
<!--
<add key="CSharpWorkerPath" value="CSharpWorker.sh.exe"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -59,7 +59,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="data\people.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

Просмотреть файл

@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpBackendPortNumber" value="0"/>
-->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to override the location of CSharpWorker.exe to use ** -->
<!--** when running Spark in **local** or ** YARN ** modes ** -->
<!--** If this setting is not used, CSharpWorker.exe will be used from default location - location of driver exe ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\path\to\mobius\driver\application\CSharpWorker.exe"/>
-->
<!-- *** Settings for Mobius in Linux *** -->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->
<!--
<add key="CSharpWorkerPath" value="/path/to/mobius/driver/application/CSharpWorker.sh.exe"/>
-->
<!-- for Spark in ** YARN ** mode -->
<!--
<add key="CSharpWorkerPath" value="CSharpWorker.sh.exe"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -68,7 +68,9 @@
<None Include="..\..\packages\Microsoft.SparkCLR.1.6.100\lib\net45\CSharpWorker.exe.config">
<Link>CSharpWorker.exe.config</Link>
</None>
<None Include="App.config" />
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Просмотреть файл

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!--*************************************************************************************-->
<!-- Log4Net configuration sections below are needed only if Log4NetLoggerService is used -->
<!--**************************************************************************************-->
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpBackendPortNumber" value="0"/>
-->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to override the location of CSharpWorker.exe to use ** -->
<!--** when running Spark in **local** or ** YARN ** modes ** -->
<!--** If this setting is not used, CSharpWorker.exe will be used from default location - location of driver exe ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\path\to\mobius\driver\application\CSharpWorker.exe"/>
-->
<!-- *** Settings for Mobius in Linux *** -->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->
<!--
<add key="CSharpWorkerPath" value="/path/to/mobius/driver/application/CSharpWorker.sh.exe"/>
-->
<!-- for Spark in ** YARN ** mode -->
<!--
<add key="CSharpWorkerPath" value="CSharpWorker.sh.exe"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -68,7 +68,9 @@
<None Include="..\..\packages\Microsoft.SparkCLR.1.6.100\lib\net45\CSharpWorker.exe.config">
<Link>CSharpWorker.exe.config</Link>
</None>
<None Include="App.config" />
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Просмотреть файл

@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpBackendPortNumber" value="0"/>
-->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to override the location of CSharpWorker.exe to use ** -->
<!--** when running Spark in **local** or ** YARN ** modes ** -->
<!--** If this setting is not used, CSharpWorker.exe will be used from default location - location of driver exe ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\path\to\mobius\driver\application\CSharpWorker.exe"/>
-->
<!-- *** Settings for Mobius in Linux *** -->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->
<!--
<add key="CSharpWorkerPath" value="/path/to/mobius/driver/application/CSharpWorker.sh.exe"/>
-->
<!-- for Spark in ** YARN ** mode -->
<!--
<add key="CSharpWorkerPath" value="CSharpWorker.sh.exe"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -71,8 +71,8 @@
<None Include="..\..\packages\Microsoft.SparkCLR.1.6.100\lib\net45\CSharpWorker.exe.config">
<Link>CSharpWorker.exe.config</Link>
</None>
<None Include="App.config">
<SubType>Designer</SubType>
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>

Просмотреть файл

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following settings to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\Git\Mobius\examples\HdfsWordCount\bin\Debug\CSharpWorker.exe"/>
<add key="CSharpBackendPortNumber" value="0"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -67,7 +67,9 @@
<None Include="..\..\packages\Microsoft.SparkCLR.1.6.100\lib\net45\CSharpWorker.exe.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="App.config" />
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Просмотреть файл

@ -1,61 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="ConsoleAppender" />
</root>
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date] [%thread] [%-5level] [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<appSettings>
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to run Spark driver executable in **local** or **debug** modes ** -->
<!--** In debug mode, the driver is not launched by CSharpRunner but launched from VS or command prompt not configured for SparkCLR ** -->
<!--** CSharpBackend should be launched in debug mode as well and the port number from that should be used below ** -->
<!--** Command to launch CSharpBackend in debug mode is "sparkclr-submit.cmd debug" ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpBackendPortNumber" value="0"/>
-->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to override the location of CSharpWorker.exe to use ** -->
<!--** when running Spark in **local** or ** YARN ** modes ** -->
<!--** If this setting is not used, CSharpWorker.exe will be used from default location - location of driver exe ** -->
<!--********************************************************************************************************-->
<!--
<add key="CSharpWorkerPath" value="C:\path\to\mobius\driver\application\CSharpWorker.exe"/>
-->
<!-- *** Settings for Mobius in Linux *** -->
<!--********************************************************************************************************-->
<!--** Uncomment the following setting to use Mobius in Linux - ** CentOS, Fedora or OS X or similiar distros ** ** -->
<!--** This setting uses the application layout settings recommended at http://www.mono-project.com/docs/getting-started/application-deployment/#layout-recommendation ** -->
<!--** Make sure CSharpWorker.sh.exe is available in the same location as your Mobius driver application ** -->
<!--********************************************************************************************************-->
<!-- for Spark in ** local ** mode -->
<!--
<add key="CSharpWorkerPath" value="/path/to/mobius/driver/application/CSharpWorker.sh.exe"/>
-->
<!-- for Spark in ** YARN ** mode -->
<!--
<add key="CSharpWorkerPath" value="CSharpWorker.sh.exe"/>
-->
</appSettings>
</configuration>

Просмотреть файл

@ -66,7 +66,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="..\..\App.config">
<Link>App.config</Link>
</None>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Просмотреть файл

@ -40,15 +40,22 @@ To use Mobius with Spark available locally in a machine, navigate to `%SPARKCLR_
### Debug Mode
Debug mode is used to step through the C# code in Visual Studio during a debugging session. With this mode, driver-side operations can be debugged.
1. Navigate to `%SPARKCLR_HOME%\scripts` directory and run `sparkclr-submit.cmd debug`
The steps to debug a Mobius driver program are:
1. Navigate to `%SPARKCLR_HOME%\scripts` directory and run `sparkclr-submit.cmd debug` (**Note**: refer to [additional instructions](https://github.com/Microsoft/Mobius/blob/master/notes/running-mobius-app.md#instructions-for-mobius-versions-16200-or-later) for Mobius versions 1.6.200 or later)
2. Look for the message in the console output that looks like "Port number used by CSharpBackend is <portnumber>". Note down the port number and use it in the next step
3. Add the following XML snippet to App.Config in the Visual Studio project for Mobius application that you want to debug and start debugging
```
<appSettings>
<add key="CSharpWorkerPath" value="/path/to/CSharpWorker.exe"/>
<add key="CSharpWorkerPath" value="/path/to/driverprogram/CSharpWorker.exe"/>
<add key="CSharpBackendPortNumber" value="port_number_from_previous_step"/>
</appSettings>
```
#### Instructions for Mobius versions 1.6.200 or later
* Syntax to launch CSharpBackend in debug mode is `sparkclr-submit.cmd debug <port number>`. Port number is optional.
* If the port number is not specified, default port number (5567) will be used and there is no need to set that in App.Config using the key `CSharpBackendPortNumber`.
* If the port number is specified, it will be used when launching the CSharpBackend. This port number should be set in App.Config using the key `CSharpBackendPortNumber`
* If the port number specified is 0, a random port number will be used in CSharpBackend. This behavior is same as in Mobius releases prior to 1.6.200. This port number should be set in App.Config using the key `CSharpBackendPortNumber`
**Notes**
* `CSharpWorkerPath` - the folder containing CSharpWorker.exe should also contain Microsoft.Spark.CSharp.Adapter.dll, executable that has the Mobius driver application and any dependent binaries. Typically, the path to CSharpWorker.exe in the build output directory of Mobius application is used for this configuration value

Просмотреть файл

@ -31,7 +31,7 @@ class CSharpBackend { self => // for accessing the this reference in inner class
private[this] var bootstrap: ServerBootstrap = null
private[this] var bossGroup: EventLoopGroup = null
def init(): Int = {
def init(portNumber: Int): Int = {
// need at least 3 threads, use 10 here for safety
bossGroup = new NioEventLoopGroup(10)
val workerGroup = bossGroup
@ -58,7 +58,7 @@ class CSharpBackend { self => // for accessing the this reference in inner class
}
})
channelFuture = bootstrap.bind(new InetSocketAddress("localhost", 0))
channelFuture = bootstrap.bind(new InetSocketAddress("localhost", portNumber))
channelFuture.syncUninterruptibly()
channelFuture.channel().localAddress().asInstanceOf[InetSocketAddress].getPort()
}

Просмотреть файл

@ -24,21 +24,20 @@ import org.apache.spark.util.csharp.{Utils => CSharpSparkUtils}
*/
// scalastyle:off println
object CSharpRunner {
val MOBIUS_DEBUG_PORT = 5567
def main(args: Array[String]): Unit = {
// determines if CSharpBackend need to be run in debug mode
// in debug mode this runner will not launch C# process
var runInDebugMode = false
if (args.length == 0) {
throw new IllegalArgumentException("At least one argument is expected for CSharpRunner")
}
if (args.length == 1 && args(0).equalsIgnoreCase("debug")) {
runInDebugMode = true
println("[CSharpRunner.main] Debug mode is set. " +
"CSharp executable will not be launched as a sub-process.")
}
val runnerSettings = initializeCSharpRunnerSettings(args)
// determines if CSharpBackend need to be run in debug mode
// in debug mode this runner will not launch C# process
var runInDebugMode = runnerSettings._1
@volatile var csharpBackendPortNumber = runnerSettings._2
var csharpExecutable = ""
var otherArgs: Array[String] = null
@ -83,11 +82,12 @@ object CSharpRunner {
// Launch a SparkCLR backend server for the C# process to connect to; this will let it see our
// Java system properties etc.
val csharpBackend = new CSharpBackend()
@volatile var csharpBackendPortNumber = 0
val initialized = new Semaphore(0)
val csharpBackendThread = new Thread("CSharpBackend") {
override def run() {
csharpBackendPortNumber = csharpBackend.init()
// need to get back csharpBackendPortNumber because if the value passed to init is 0
// the port number is dynamically assigned in the backend
csharpBackendPortNumber = csharpBackend.init(csharpBackendPortNumber)
println("[CSharpRunner.main] Port number used by CSharpBackend is "
+ csharpBackendPortNumber) // TODO - send to logger also
initialized.release()
@ -190,5 +190,19 @@ object CSharpRunner {
println("[CSharpRunner.main] closing CSharpBackend")
csharpBackend.close()
}
def initializeCSharpRunnerSettings(args: Array[String]): (Boolean, Int) = {
val runInDebugMode = (args.length == 1 || args.length == 2) && args(0).equalsIgnoreCase("debug")
var portNumber = 0
if (runInDebugMode) {
if (args.length == 1) {
portNumber = MOBIUS_DEBUG_PORT
} else if (args.length == 2 ) {
portNumber = Integer.parseInt(args(1))
}
}
(runInDebugMode, portNumber)
}
}
// scalastyle:on println

Просмотреть файл

@ -26,4 +26,20 @@ class CSharpRunnerSuite extends SparkCLRFunSuite {
assert(CSharpRunner.formatPath(path3).startsWith("."))
assert(CSharpRunner.formatPath(path3).endsWith(path3))
}
test("debug mode test without port number") {
val args = Array("debug")
val settings = CSharpRunner.initializeCSharpRunnerSettings(args)
assert(settings._1)
assert(CSharpRunner.MOBIUS_DEBUG_PORT == settings._2)
}
test("debug mode test with port number") {
val args = Array("debug", "1234")
val settings = CSharpRunner.initializeCSharpRunnerSettings(args)
assert(settings._1)
assert(1234 == settings._2)
}
}