BatchProcessorAPI 1.0.2
See the version list below for details.
dotnet add package BatchProcessorAPI --version 1.0.2
NuGet\Install-Package BatchProcessorAPI -Version 1.0.2
<PackageReference Include="BatchProcessorAPI" Version="1.0.2" />
<PackageVersion Include="BatchProcessorAPI" Version="1.0.2" />
<PackageReference Include="BatchProcessorAPI" />
paket add BatchProcessorAPI --version 1.0.2
#r "nuget: BatchProcessorAPI, 1.0.2"
#:package BatchProcessorAPI@1.0.2
#addin nuget:?package=BatchProcessorAPI&version=1.0.2
#tool nuget:?package=BatchProcessorAPI&version=1.0.2
BatchProcessor
The goal of this project is to allow applications that are computationally expensive a simple way to distribute the workload amongst a group of local computers.
The user's code will use the BatchProcessorAPI to execute "jobs" through a job scheduler. This calls out to a remote server, which is running the BatchProcessor service. The BatchProcessorUI is a way to configure, test, and launch the BatchProcessor service.
Jobs are defined as an executable command with optional arguments. The job needs to contain a zipped payload of the executable and all necessary files. There is a utility class in the API to pull the entire working directory of the application.
Batch Processor API
The API is on Nuget under BatchProcessorAPI, or include the API project directly if not using Nuget.
This API currently targets .NET Standard 2.0, which is compatable with .NET Core 2.0 and later, .NET Framework 4.6.1 and later, and Mono 5.4 and later.
The API requires Newtonsoft.Json and Newtonsoft.Json.Bson.
Code Sample
Please check out the TestApp for sample code.
A JobScheduler is the main point of entry for the API. Initialize it with the Server IP and port.
JobScheduler scheduler = new JobScheduler(SERVER_IP, SERVER_PORT);
The scheduler allows jobs to execute remotely. A Job contains a name, executable name, executable arguments, binary payload, and output file to return. The executable can be the same as the calling executable if the arguments are handled properly.
List<Job> jobs = new List<Job>();
for (int i = 0; i < 100; i++)
jobs.Add(new Job($"Job-{i}", "TestApp.exe", i.ToString(), payload, "output.txt"));
There is a utility to get the payload of the current working directory.
byte[] payload = PayloadUtil.CreatePayloadWithWorkingDirectory();
To execute jobs, call the JobScheduler with a list of Job elements. There is an Action<JobResponse> that is called on job completion or failure.
scheduler.ScheduleAll(jobs, response =>
{
//Add lock statement to cleanup console writing
Console.WriteLine($"Job Response {response.Completed}: {response.Name}");
//Output from the file
string returnFile = "Empty";
if (response.ReturnFile != null)
returnFile = System.Text.Encoding.Default.GetString(response.ReturnFile);
Console.WriteLine($"File: [{returnFile}]);
//Output from the executable
Console.WriteLine($"Output: [{response.ConsoleOutput}] Error: [{response.ConsoleError}]");
if (response.Completed)
//Increment a counter if you want
});
Server Application
The server installer can be found in the Downloads folder. The installer will install the BatchProcessor service, the BatchProcessorUI configuration tool, and add Windows Firewall exceptions.
Please make sure .NET Framework 4.7.1 is installed on the server.
Controls
- Start Local - Start a local instance of the BatchProcessor, make sure the service is not active, they will interfere. The Console will show incoming jobs and loaded configuration.
- Stop Local - Stops the local instance of the BatchProcessor.
- Install Service - Installs the BatchProcessor as a Windows Service. As a service, this will run always.
- Uninstall Service - Uninstalls the BatchProcessor as a Windows Service, but does not remove the application from the computer.
- Start Service - Starts the Windows Service version of the BatchProcessor.
- Stop Service - Stops the Windows Service version of the BatchProcessor.
Configuration
Mode
- Server Mode - there should only be one server on the network, this is the master node that controls job flow.
- Worker Mode - a worker adds more computing power to an existing server. You must put an address in the Server Address field. Make sure the Worker Port matches the configuration on the server.
Job Port
- A single integer port, 1200 by default. This port is used by applications using the API to send jobs. If in Worker Mode, this port is used by the server to send jobs.
Worker Port
- A single integer port, 1201 by default. This port is specified by both workers and server to establish communication. Make sure when adding workers that this port matches the server.
Server Address
- Only used in Worker Mode - set this as the address of the server. Make sure the server is on a static IP in the network.
Max Local Slots
- Number of simultaneous jobs that can occur on the local machine. Default value is (Number of Cores - 1). Make sure this number is at least 1.
Buttons
- Save - Save the configuration. The BatchProcessor must be restarted in order for the settings to load.
- Load - Load the current configuration, this will undo any local changes.
Change log
- Version 1.0.1 - Updated Nuget package to include proper dependencies. Server install in now more reliable, minor bug fixes.
- Version 1.0.0 - Initial public release! Downloadable installer created. Nuget package available.
- Version 0.0.1 - This is not released yet. Still a work in progress.
If you feel generous, and wish to support my projects:
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 12.0.1)
- Newtonsoft.Json.Bson (>= 1.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.