Custom Discriminator and Affinity Conditions
In addition to Conditions based on Engine Properties, you can implement your own custom Conditions. For example, you might have a number of Services that require a connection to a database and might have more Engines working on those Services than available connections. You could write a Server Hook that keeps track of how many tasks are currently running, and write a Custom Discriminator to prevent all Engines from taking a Task if all connections are in use by other Tasks.
To write a Custom Condition:
-
Implement the
CustomDiscriminatororCustomAffinityinterface inSchedulingConditionFactory. -
Package your classes into a JAR file, and for each Broker on which this is used, place that file in
DS_MANAGER/webapps/livecluster/WEB-INF/lib. -
At Service creation time, create it using the
SchedulingConditionFactory.createCustom[Affinity/Discriminator]call. Note that it is not necessary to have the JAR in a Java Driver classpath; likewise, this is also available for C++ and .NET Services, since the class is only used on Brokers.