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
IMessageEndpoint
addNewMessageListener
in interface IMessageEndpoint
JobSchedulerException
public final void removeNewMessageListener(NewMessageListener listener) throws JobSchedulerException
JobSchedulerException
public 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()
IJobScheduler
getId
in interface IJobScheduler
getId
in interface IMessageEndpoint
public final boolean getIsConnected()
IJobScheduler
true
if this scheduler is connected; otherwise, false
.getIsConnected
in interface IJobScheduler
public 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
IJobScheduler
cancelJob
in interface IJobScheduler
jobId
- 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
IJobScheduler
cancelTask
in interface IJobScheduler
taskId
- 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
IJobScheduler
getMaximumHostCount
in interface IJobScheduler
JobSchedulerException
- If operation fails.public final java.util.List<AgentSnapshot> getAgentInfo() throws JobSchedulerException
IGetAgentInfo
getAgentInfo
in interface IGetAgentInfo
JobSchedulerException
- If there was a problem getting the agent info (e.g., the
connection was lost).public final AuthorizationType getUserAuthorization() throws JobSchedulerException
IGetAuthorizationInfo
getUserAuthorization
in interface IGetAuthorizationInfo
true
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
IGetVersionInfo
getVersionInfo
in interface IGetVersionInfo
JobSchedulerException
- 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
IMessageEndpoint
postMessage
in interface IMessageEndpoint
message
- 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
IMessageEndpoint
postMessage
in interface IMessageEndpoint
message
- 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
IMessageEndpoint
receiveMessage
in interface IMessageEndpoint
JobSchedulerException
- If target mailbox does not exist.public final java.lang.Object receiveMessage(int millisecondsTimeout) throws JobSchedulerException
IMessageEndpoint
receiveMessage
in interface IMessageEndpoint
millisecondsTimeout
- The number of milliseconds to wait, or -1 to wait indefinitely.null
if timeout is elapsed.JobSchedulerException
public final java.lang.Object receiveMessage(java.util.UUID[] sender) throws JobSchedulerException
IMessageEndpoint
receiveMessage
in interface IMessageEndpoint
sender
- The address of the sender of the message.JobSchedulerException
public final java.lang.Object receiveMessage(int millisecondsTimeout, java.util.UUID[] sender) throws JobSchedulerException
IMessageEndpoint
receiveMessage
in interface IMessageEndpoint
millisecondsTimeout
- 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.JobSchedulerException
public final LicenseInfo getLicenseInfo(LicenseParameters licenseParameters) throws JobSchedulerException
IGetLicenseInfo
getLicenseInfo
in interface IGetLicenseInfo
licenseParameters
- 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 IJobScheduler
java.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
IJobScheduler
submitJob
in interface IJobScheduler
job
- The job to be submitted.JobSchedulerException
- If a task or task environment cannot be serialized.public final Job createJob() throws JobSchedulerException
IJobScheduler
createJob
in interface IJobScheduler
JobSchedulerException
- Thrown if client is not connected to the job scheduler yet.public final void disconnect()
IJobScheduler
disconnect
in interface IJobScheduler
public final void onCoordinatorDisconnected() throws JobSchedulerException
JobSchedulerException
public final boolean waitUntilDone(java.util.UUID jobId, int millisecondsTimeout, java.lang.Runnable heartbeatCallback, int millisecondsHeartbeat) throws JobSchedulerException
IJobScheduler
millisecondsHeartbeat
argument.waitUntilDone
in interface IJobScheduler
jobId
- 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.Object
public void close()
IJobScheduler
close
in interface IJobScheduler
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
@Deprecated public final void dispose()
close()
dispose
in interface IJobScheduler