Server Settings
Workers.xml
The LEADTOOLS Distributed Computing (Job Processor) SDK allows most job processor worker settings to be configured in the Workers.XML file. The Workers.XML file is required by the WorkerService WCF Service and must exist in the App_Data directory of the WorkerService WCF Service on the server. The Workers.XML configuration file allows you to control many settings, including the following settings:
The schema of the Workers.XML configuration file, along with the usage of each setting, is shown below.
<Workers>
<Worker Name="*" NewJobCheckPeriod="2">
<JobTypes>
<JobType Name="XYZ" MaxNumberOfJobs="5" CpuThreshold="80" UseCpuThreshold="false" ProgressRate="10" AssumeHangAfter="60" Attempts="3"/>
</JobTypes>
</Worker>
<Worker Name="Worker1" NewJobCheckPeriod="2">
<JobTypes>
<JobType Name="Ocr" MaxNumberOfJobs="5" CpuThreshold="80" UseCpuThreshold="false" ProgressRate="10" AssumeHangAfter="60" Attempts="3"/>
<JobType Name="Multimedia" MaxNumberOfJobs="5" CpuThreshold="80" UseCpuThreshold="false" ProgressRate="10" AssumeHangAfter="60" Attempts="3"/>
</JobTypes>
</Worker>
</Workers>
Worker: Node representing a worker machine.
Name (Worker Node): Attribute representing the name of the worker. Use "*" to specify settings which should be used for those machines whose names are not located in the configuration.
NewJobCheckPeriod: Attribute representing the frequency in seconds the worker should poll the central server for new jobs of this type.
JobTypes: Node representing which types of jobs this machine will process.
JobType: Node representing the settings for a specific type of job for a worker.
Name (JobType Node): Attribute representing the name of this job type.
MaxNumberOfJobs: Attribute representing the maximum number of concurrent jobs this machine can accept for this job type.
CpuThreshold: Attribute representing the maximum CPU percentage threshold for this machine. New jobs cannot be accepted until the CPU usage drops below this figure. For example, if the CpuThreshold is set to 80, new jobs of this type will not be accepted unless the current CPU usage drops below 80%.
UseCpuThreshold: Attribute representing whether the worker should use the value specified by CpuThreshold. If this value is true, the value set by CpuThreshold will be used to control when new jobs are accepted. If this value is false, the value set by MaxNumberOfJobs will be used to control when jobs are accepted.
ProgressRate: Attribute representing the rate in seconds at which the worker process should post progress via the UpdatePercentage Method.
AssumeHangAfter: Attribute representing the maximum amount of time in seconds a job process can go without a change in progress before it is assumed hung and therefore killed. The AssumeHangAfter value should be larger than the ProgressRate value to prevent jobs from being mistakenly considered hung and killed. In cases where large periods of time can go by without a change in progress, you will want this value to be larger. For example, if your process could go 5 minutes without a change in progress, this value should be greater than 300 (5 x 60 seconds per minute).
Attempts: Attribute representing the maximum number of times to attempt jobs of this type if they do not complete successfully.
Web.config
The WCF Service web.config file should contain the following settings:
Connection String: The connecting string to the Job Processor database. The name of the connection string should be "LeadtoolsJobProcessorDB". See the following fexample.
<connectionStrings>
<add name="LeadtoolsJobProcessorDB" connectionString="data source=localhost\SQLEXPRESS;initial catalog =LeadtoolsJobProcessorDB;Trusted_Connection=true;" providerName="System.Data.SqlClient" />
</connectionStrings>
License Information: The LEADTOOLS Distributed Computing (Job Processor) SDK must be unlocked before its properties, methods, and events can be used. For more information on unlocking LEAD features, refer to Unlocking Special LEAD Features. To add your license information and unlock the Distributed Computing (Job Processor) SDK, specify the 'DeveloperKey' and 'LicenseFile' in the appSettings section. The 'LicenseFile' must be located in the WCF Service App_Data directory. See below for an example.
<appSettings>
<add key="DeveloperKey" value="" />
<add key="LicenseFile" value="" />
</appSettings>
Logging Information: Logging for the WCF service can be configured in the WCF Service web.config file (see below for example). WCF Service information that will be logged includes database interactions, calls made to the service, and other service related events. Logging is implemented using the LEADTOOLS Logging Framework. For more information on the Leadtools.Logging logging framework, refer to Programming with LEADTOOLS Logging.
<configSections> <section name="leadLogging" type="Leadtools.Logging.Configuration.ConfigSectionHandler, Leadtools.Logging"/> </configSections>
<logging>
<channels>
<channel name="EventLog" type="Leadtools.Logging.LoggingChannel.EventLogLoggingChannel, Leadtools.Logging" Enabled="false" Source="Leadtools.JobProcessor"/>
</channels>
</logging>
WCF Service | Name | Service Contract |
---|---|---|
JobService | Leadtools.Services.JobProcessor.ServiceImplementations.JobService | Leadtools.Services.JobProcessor.ServiceContracts.IJobService |
WorkerService | Leadtools.Services.JobProcessor.ServiceImplementations.WorkerService | Leadtools.Services.JobProcessor.ServiceContracts.IWorkerService |
<services>
<!-- JobService -->
<service name="Leadtools.Services.JobProcessor.ServiceImplementations.JobService" behaviorConfiguration="LeadtoolsServiceBehavior"> <endpoint
contract="Leadtools.Services.JobProcessor.ServiceContracts.IJobService" binding="basicHttpBinding" bindingConfiguration="HttpTextStreaming"
bindingNamespace="http://Leadtools.JobProcessor.ServiceContracts/2009/01"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service> <!-- WorkerService --> <service name="Leadtools.Services.JobProcessor.ServiceImplementations.WorkerService"
behaviorConfiguration="LeadtoolsServiceBehavior"> <endpoint contract="Leadtools.Services.JobProcessor.ServiceContracts.IWorkerService"
binding="basicHttpBinding" bindingConfiguration="HttpTextStreaming" bindingNamespace="http://Leadtools.JobProcessor.ServiceContracts/2009/01"/> <endpoint
address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service>
Windows Service Worker Settings
App.config
Logging for the windows service and user worker assembly can be configured in the application app.config file (see below for example). Windows service information that will be logged includes database interactions, WorkerService WCF service interactions, current job information, and other events related to the worker. Logging is implemented using the LEADTOOLS Logging Framework. For more information on the Leadtools.Logging logging framework, refer to Programming with LEADTOOLS Logging.
<configSections> <section
name="leadLogging" type="Leadtools.Logging.Configuration.ConfigSectionHandler, Leadtools.Logging"/> </configSections> <logging> <channels>
<channel name="EventLog" type="Leadtools.Logging.LoggingChannel.EventLogLoggingChannel, Leadtools.Logging" Enabled="false" Source="Leadtools.JobProcessor"/>
</channels> </logging>
Each Windows Service can be set up to process any number of job types. There are no limitations on the number of Windows Services from the LEADTOOLS Distributed Computing Framework which can be installed on a single machine. For more information on using multiple job types, refer to Understanding the LEADTOOLS Job Processor Database.
The Windows Service application configuration file (app.config) allows you to specify which type of jobs this service will process. It also contains the endpoint information for the WorkerService WCF Service. The following settings can be found in the 'appSettings' section of the app.config file.
UserClassTypeName: The namespace and class (Specified as 'Namespace.Class') of the class which will override the OnJobReceived Method and process new jobs.
JobType: The type of jobs this service will process. If a job type is specified here, a matching job type should be defined in Workers.xml under the same machine, or the default machine settings (*) if the machine is not defined. If no job type is specified here, the worker will process all job types defined for that worker in Workers.xml, as well as jobs which were added with no job type specified. This is useful if you have a single worker assembly which can process multiple job types.
WorkerLayerPath: The path to Leadtools.JobProcessor.Workerlayer.exe.
UserDllPath: The path to your custom worker assembly. The custom worker assembly will be loaded by Leadtools.JobProcessor.Workerlayer.exe to process jobs.
The Windows Service will use the settings specified in the application's configuration file to connect to the WorkerService WCF Service (contract="IWorkerService"). For more information on how to specify WCF binding, behavior, and endpoint information in the application configuration file, refer to Configuring Services Using Configuration Files.
Programming with the LEADTOOLS Distributed Computing (Job Processor) SDK
Creating Job Processor Worker Assemblies
Understanding The LEADTOOLS Job Processor Database
Deploying LEADTOOLS Distributed Computing (JobProcessor) Applications
Unlocking Special LEAD Features