public final class ClusterJobScheduler extends java.lang.Object implements IJobScheduler, IEnforceTaskPrecondition, IGetLicenseInfo, IGetAgentInfo, IGetAuthorizationInfo, IGetVersionInfo, IMessageEndpoint
connect() method to connect to the cluster scheduler.
You can then submit and monitor jobs.
We recommend that instead of using this class you instead use the IJobScheduler interface if possible.| Constructor and Description |
|---|
ClusterJobScheduler()
Initializes a new instance of the
ClusterJobScheduler class. |
ClusterJobScheduler(java.lang.String coordinatorMachineName)
Initializes a new instance of the
ClusterJobScheduler class with the specified coordinator hostname. |
ClusterJobScheduler(java.lang.String coordinatorMachineName,
int coordinatorPort)
Initializes a new instance of the
ClusterJobScheduler class with the specified coordinator hostname and coordinator port. |
ClusterJobScheduler(java.lang.String coordinatorMachineName,
int coordinatorPort,
boolean useSsl,
boolean allowSelfSignedCertificates)
Initializes a new instance of the
ClusterJobScheduler class with the specified coordinator host name, port, and security options. |
| Modifier and Type | Method and Description |
|---|---|
void |
addNewMessageListener(NewMessageListener listener)
Adds a handler for an event that occurs when a new message arrives.
|
void |
cancelJob(java.util.UUID jobId,
boolean listenForCancellationEvent)
Cancels the job with the specified id.
|
void |
cancelTask(java.util.UUID taskId)
Cancels the task with the specified id.
|
void |
close()
Closes this JobScheduler and releases any system resources associated with it.
|
void |
connect()
Connects client to specified cluster scheduler.
|
Job |
createJob()
Returns a new job that can later be used to submit to the job scheduler.
|
void |
disconnect()
Disconnects client from specified job scheduler.
|
void |
dispose()
Deprecated.
Please use
close() |
java.util.List<AgentSnapshot> |
getAgentInfo()
Returns the list of agents and their current states.
|
boolean |
getAllowSelfSignedCertificates()
Gets a value indicating whether to allow self-signed certificates when communicating with the coordinator.
|
java.lang.String |
getCoordinatorMachineName()
Gets the name of the coordinator.
|
int |
getCoordinatorPort()
Gets port number of the coordinator.
|
int |
getCoordinatorReconnectionDelay()
Retrieves the amount of time, in milliseconds, the scheduler should wait before attempting to reconnect to the coordinator.
|
int |
getCoordinatorReconnectionInterval()
Gets the amount of time, in milliseconds, the scheduler should wait in between each reconnection attempt.
|
java.lang.String |
getCoordinatorThumbprint()
Returns the expected thumbprint of the coordinator's certificate.
|
int |
getCoordinatorTimeout()
Gets the timeout wait time in milliseconds
This value is readonly after you have already connected to the coordinator.
|
java.util.UUID |
getId()
Gets the id of this job scheduler.
|
boolean |
getIsConnected()
Gets a value indicating whether the job scheduler is connected.
|
LicenseInfo |
getLicenseInfo(LicenseParameters licenseParameters)
Gets the license info that matches the provided license parameters.
|
int |
getMaximumHostCount()
Returns the maximum number of hosts that is available to the job scheduler.
|
int |
getMaximumReconnectionAttempts()
Gets the maximum number of times the job scheduler should try to reconnect to the coordinator before aborting.
|
boolean |
getProvideClientCertificate()
Gets a value indicating whether or not to provide a client certificate to the coordinator.
|
AuthorizationType |
getUserAuthorization()
Determines whether the user is authorized for the job submission protocol.
|
boolean |
getUseSsl()
Gets a value indicating whether or not to use SSL when communicating with the coordinator.
|
VersionInfo |
getVersionInfo()
Gets the version info of the job scheduler.
|
void |
onCoordinatorDisconnected()
Called when the job scheduler connection with the coordinator is interrupted.
|
void |
postMessage(java.lang.Object message,
java.util.UUID target)
Posts a message to the specified target mailbox.
|
void |
postMessage(java.lang.Object message,
java.util.UUID target,
boolean quietlyFail)
Posts a message to the specified target mailbox.
|
java.lang.Object |
receiveMessage()
Receives a message from the participant's mailbox.
|
java.lang.Object |
receiveMessage(int millisecondsTimeout)
Receives a message from the participant's mailbox.
|
java.lang.Object |
receiveMessage(int millisecondsTimeout,
java.util.UUID[] sender)
Receives a message from the participant's mailbox.
|
java.lang.Object |
receiveMessage(java.util.UUID[] sender)
Receives a message from the participant's mailbox.
|
void |
removeNewMessageListener(NewMessageListener listener) |
void |
setAllowSelfSignedCertificates(boolean value)
Sets a value indicating whether to allow self-signed certificates when communicating with the coordinator.
|
void |
setCoordinatorMachineName(java.lang.String value)
Sets the name of the coordinator.
|
void |
setCoordinatorPort(int value)
Sets port number of the coordinator.
|
void |
setCoordinatorReconnectionDelay(int delay)
Sets the amount of time, in milliseconds, the scheduler should wait before attempting to reconnect to the coordinator.
|
void |
setCoordinatorReconnectionInterval(int interval)
Sets the amount of time, in milliseconds, the scheduler should wait in between each reconnection attempt.
|
void |
setCoordinatorThumbprint(java.lang.String thumbprint)
Sets the expected thumbprint of the coordinator's certificate.
|
void |
setCoordinatorTimeout(int timeout)
Sets the timeout wait time in milliseconds.
|
void |
setMaximumReconnectionAttempts(int maximum)
Sets the maximum number of times the job scheduler should try to reconnect to the coordinator before aborting.
|
void |
setProvideClientCertificate(boolean provide)
Sets a value indicating whether to provide a client certificate to the coordinator.
|
void |
setUseSsl(boolean value)
Sets a value indicating whether or not to use SSL when communicating with the coordinator.
|
void |
submitJob(Job job,
JobSubmitListener listener)
Submits job to the job scheduler so that the job scheduler can add the job to it's queue.
|
java.lang.String |
toString() |
boolean |
waitUntilDone(java.util.UUID jobId,
int millisecondsTimeout,
java.lang.Runnable heartbeatCallback,
int millisecondsHeartbeat)
Blocks until all tasks in this job complete or the operation times out.
|
public ClusterJobScheduler()
ClusterJobScheduler class.public ClusterJobScheduler(java.lang.String coordinatorMachineName)
ClusterJobScheduler class with the specified coordinator hostname.coordinatorMachineName - The DNS name of the coordinator you intend to connect.public ClusterJobScheduler(java.lang.String coordinatorMachineName,
int coordinatorPort)
ClusterJobScheduler class with the specified coordinator hostname and coordinator port.coordinatorMachineName - The DNS name of the coordinator you intend to connect.coordinatorPort - The port number of the coordinator you intend to connect.public ClusterJobScheduler(java.lang.String coordinatorMachineName,
int coordinatorPort,
boolean useSsl,
boolean allowSelfSignedCertificates)
ClusterJobScheduler class with the specified coordinator host name, port, and security options.coordinatorMachineName - The DNS name of the coordinator you intend to connect.coordinatorPort - The port number of the coordinator you intend to connect.useSsl - If set to true, use SSL to communicate with the coordinator.allowSelfSignedCertificates - If set to true, allow self-signed certificates.public final void addNewMessageListener(NewMessageListener listener) throws JobSchedulerException
IMessageEndpointaddNewMessageListener in interface IMessageEndpointJobSchedulerExceptionpublic final void removeNewMessageListener(NewMessageListener listener) throws JobSchedulerException
JobSchedulerExceptionpublic final java.lang.String getCoordinatorMachineName()
java.lang.IllegalStateException - Thrown if CoordinatorMachineName is read-only.public final void setCoordinatorMachineName(java.lang.String value)
java.lang.IllegalStateException - Thrown if CoordinatorMachineName is read-only.public final int getCoordinatorPort()
java.lang.IllegalStateException - Thrown if CoordinatorPort is read-only.public final void setCoordinatorPort(int value)
java.lang.IllegalStateException - Thrown if CoordinatorPort is read-only.public final boolean getUseSsl()
public final void setUseSsl(boolean value)
java.lang.IllegalStateException - Thrown if CoordinatorPort is read-only.public final boolean getAllowSelfSignedCertificates()
public final void setAllowSelfSignedCertificates(boolean value)
java.lang.IllegalStateException - Thrown if CoordinatorPort is read-only.public final int getCoordinatorTimeout()
public void setCoordinatorTimeout(int timeout)
timeout - Coordinator timeout (in milliseconds).java.lang.IllegalStateException - If CoordinatorTimeout is readonly.public boolean getProvideClientCertificate()
public void setProvideClientCertificate(boolean provide)
java.lang.IllegalStateException - Thrown if CoordinatorPort is read-only.public final java.util.UUID getId()
IJobSchedulergetId in interface IJobSchedulergetId in interface IMessageEndpointpublic final boolean getIsConnected()
IJobSchedulertrue if this scheduler is connected; otherwise, false.getIsConnected in interface IJobSchedulerpublic int getCoordinatorReconnectionDelay()
public void setCoordinatorReconnectionDelay(int delay)
public int getCoordinatorReconnectionInterval()
public void setCoordinatorReconnectionInterval(int interval)
public int getMaximumReconnectionAttempts()
public void setMaximumReconnectionAttempts(int maximum)
public java.lang.String getCoordinatorThumbprint()
public void setCoordinatorThumbprint(java.lang.String thumbprint)
thumbprint - Expected coordinator certificate thumbprint.public final void cancelJob(java.util.UUID jobId,
boolean listenForCancellationEvent)
throws JobSchedulerException
IJobSchedulercancelJob in interface IJobSchedulerjobId - The id of the job to cancel.listenForCancellationEvent - if set to true, client will listen for the cancellation event. Otherwise, cancellation events can be ignored.JobSchedulerException - Thrown if client is not connected to the job scheduler yet.public final void cancelTask(java.util.UUID taskId)
throws JobSchedulerException
IJobSchedulercancelTask in interface IJobSchedulertaskId - The id of the task to cancel.JobSchedulerException - Thrown if client is not connected to the job scheduler yet.public final int getMaximumHostCount()
throws JobSchedulerException
IJobSchedulergetMaximumHostCount in interface IJobSchedulerJobSchedulerException - If operation fails.public final java.util.List<AgentSnapshot> getAgentInfo() throws JobSchedulerException
IGetAgentInfogetAgentInfo in interface IGetAgentInfoJobSchedulerException - If there was a problem getting the agent info (e.g., the
connection was lost).public final AuthorizationType getUserAuthorization() throws JobSchedulerException
IGetAuthorizationInfogetUserAuthorization in interface IGetAuthorizationInfotrue if this user is authorized; else false.JobSchedulerException - If there was a problem getting the authorization info (e.g., the
connection was lost)public final VersionInfo getVersionInfo() throws JobSchedulerException
IGetVersionInfogetVersionInfo in interface IGetVersionInfoJobSchedulerException - If there was a problem getting the version info (e.g., the
connection was lost).public final void postMessage(java.lang.Object message,
java.util.UUID target)
throws JobSchedulerException
IMessageEndpointpostMessage in interface IMessageEndpointmessage - The message.target - The target.JobSchedulerException - If target mailbox does not exist.public final void postMessage(java.lang.Object message,
java.util.UUID target,
boolean quietlyFail)
throws JobSchedulerException
IMessageEndpointpostMessage in interface IMessageEndpointmessage - The message.target - The target.quietlyFail - If true will not throw an exception if target does
not exist.JobSchedulerException - If target mailbox does not exist.public final java.lang.Object receiveMessage()
throws JobSchedulerException
IMessageEndpointreceiveMessage in interface IMessageEndpointJobSchedulerException - If target mailbox does not exist.public final java.lang.Object receiveMessage(int millisecondsTimeout)
throws JobSchedulerException
IMessageEndpointreceiveMessage in interface IMessageEndpointmillisecondsTimeout - The number of milliseconds to wait, or -1 to wait indefinitely.null if timeout is elapsed.JobSchedulerExceptionpublic final java.lang.Object receiveMessage(java.util.UUID[] sender)
throws JobSchedulerException
IMessageEndpointreceiveMessage in interface IMessageEndpointsender - The address of the sender of the message.JobSchedulerExceptionpublic final java.lang.Object receiveMessage(int millisecondsTimeout,
java.util.UUID[] sender)
throws JobSchedulerException
IMessageEndpointreceiveMessage in interface IMessageEndpointmillisecondsTimeout - The number of milliseconds to wait, or -1 to wait indefinitely.sender - The address of the sender of the message.null if timeout is elapsed.JobSchedulerExceptionpublic final LicenseInfo getLicenseInfo(LicenseParameters licenseParameters)
throws JobSchedulerException
IGetLicenseInfogetLicenseInfo in interface IGetLicenseInfolicenseParameters - The license parameters.JobSchedulerException - If there was a problem getting the license info (e.g., the
connection was lost).public final void connect()
throws JobSchedulerException
Call this method to establish a synchronous remote connection the coordinator specified at the
host name (CoordinatorMachineName (get / set)), and port (CoordinatorPort (get / set)).
connect in interface IJobSchedulerjava.lang.IllegalStateException - The client is already connected.JobSchedulerException - coordinator CoordinatorMachineName (get / set) is not specified,
or coordinator could not be reached at hostname and port.public final void submitJob(Job job, JobSubmitListener listener) throws JobSchedulerException
IJobSchedulersubmitJob in interface IJobSchedulerjob - The job to be submitted.JobSchedulerException - If a task or task environment cannot be serialized.public final Job createJob() throws JobSchedulerException
IJobSchedulercreateJob in interface IJobSchedulerJobSchedulerException - Thrown if client is not connected to the job scheduler yet.public final void disconnect()
IJobSchedulerdisconnect in interface IJobSchedulerpublic final void onCoordinatorDisconnected()
throws JobSchedulerException
JobSchedulerExceptionpublic final boolean waitUntilDone(java.util.UUID jobId,
int millisecondsTimeout,
java.lang.Runnable heartbeatCallback,
int millisecondsHeartbeat)
throws JobSchedulerException
IJobSchedulermillisecondsHeartbeat argument.waitUntilDone in interface IJobSchedulerjobId - The job id for the job to be submitted.millisecondsTimeout - The timeout (in milliseconds).heartbeatCallback - The heartbeat callback.millisecondsHeartbeat - The heartbeat period (in milliseconds).true if job completed, false if timed-out.JobSchedulerException - Thrown if client disconnects from the job scheduler.public java.lang.String toString()
toString in class java.lang.Objectpublic void close()
IJobSchedulerclose in interface IJobSchedulerclose in interface java.io.Closeableclose in interface java.lang.AutoCloseable@Deprecated public final void dispose()
close()dispose in interface IJobScheduler