public class SmartProxyImpl extends AbstractSmartProxy<JobTrackerImpl> implements org.objectweb.proactive.InitActive, org.objectweb.proactive.EndActive, Serializable
This implementation assumes that:
In order to use this object, a reference to it should be obtained via the
getActiveInstance()
method. One of the init methods should be called
afterwards.
The client could add a Listener to this object in order to receive
notifications from the Scheduler. The listener is of type
SchedulerEventListenerExtended
which, in addition to the
notifications declared by its super type
SchedulerEventListener
, can be
notified with events related to data transfer.
Remember this is an active object. The listener object needs to be an active or remote object (in order to avoid passing the listener through deep copy). You could use, for instance:
SchedulerEventListenerExtended myListenerRemoteReference = PARemoteObject.turnRemote( new MyEventListener());
schedProxy.addEventListener(myListenerRemoteReference);
When a listener is added by the client, no new connection will be established with the scheduler. This Proxy object broadcasts events received from the Scheduler to its own listeners. In addition, it adds events related to data transfer.
When a new job is submitted, these operations will be performed:
Modifier and Type | Field and Description |
---|---|
protected Scheduler |
schedulerProxy |
configuredEvents, connectionInfo, eventListeners, GENERIC_INFO_INPUT_FOLDER_PROPERTY_NAME, GENERIC_INFO_OUTPUT_FOLDER_PROPERTY_NAME, GENERIC_INFO_PULL_URL_PROPERTY_NAME, GENERIC_INFO_PUSH_URL_PROPERTY_NAME, jobTracker, MAX_NB_OF_DATA_TRANSFER_THREADS, PROXY_SCHED_EVENTS, terminated, terminating, threadPool
Constructor and Description |
---|
SmartProxyImpl()
Deprecated.
Use
getActiveInstance() or getInstance() |
Modifier and Type | Method and Description |
---|---|
protected Scheduler |
_getScheduler()
Returns a proxy instance to the Scheduler.
|
void |
addEventListener(SchedulerEventListenerExtended listener,
boolean myEventsOnly,
SchedulerEvent[] events) |
boolean |
changeStartAt(JobId jobId,
String startAt)
Change the START_AT generic information at job level and reset the
scheduledAt at task level
|
boolean |
checkJobPermissionMethod(String sessionId,
String jobId,
String method)
Check if the user has the permission to execute the method passed as argument
|
protected void |
createFolder(String fUri) |
void |
disconnect()
Disconnect from the scheduler
|
protected void |
downloadTaskOutputFiles(AwaitedJob awaitedjob,
String jobId,
String t_name,
String localFolder)
Pull the output files of the given task from the pull_url either to the localFolder defined for the job or to the localFolder specified as argument, if it is not null.
|
void |
endActivity(org.objectweb.proactive.Body body) |
boolean |
finishInErrorTask(String jobId,
String taskName) |
static SmartProxyImpl |
getActiveInstance()
Returns a stub to the only active instance of the proxy (proactive
singleton pattern)
|
String |
getCurrentPolicy()
Return the name of the current Policy
|
String |
getCurrentUser()
Returns the user currently connected
|
UserData |
getCurrentUserData()
Returns the user data object associated with the user currently connected
|
List<String> |
getGlobalSpaceURIs()
Returns the GLOBAL DataSpace URI available to all users
|
static SmartProxyImpl |
getInstance()
Returns the real singleton instance of the proxy
|
String |
getJobContent(JobId jobId) |
JobInfo |
getJobInfo(String jobId)
Retrieve a job info by it id.
|
JobState |
getJobState(String jobId)
Return the state of the given job.
The state contains informations about the job, every tasks and informations about the tasks. The jobId is given as a string. |
Map |
getJobsToSchedule()
get job Descriptor Map with eligible jobs (running and pending)
|
Map<Object,Object> |
getPortalConfiguration() |
Map<String,Object> |
getSchedulerProperties()
Returns the scheduler properties associated with the user currently connected
|
Page<TaskId> |
getTaskIds(String taskTag,
long from,
long to,
boolean mytasks,
boolean running,
boolean pending,
boolean finished,
int offset,
int limit)
Retrieve a tasks names list from the scheduler.
|
TaskStatesPage |
getTaskPaginated(String jobId,
int offset,
int limit)
Return the page of tasks of the given job.
|
TaskResult |
getTaskResult(JobId jobId,
String taskName)
Get the result for the given task name in the given jobId.
|
TaskResult |
getTaskResult(String jobId,
String taskName)
Get the result for the given task name in the given jobId.
|
List<TaskResult> |
getTaskResultAllIncarnations(JobId jobId,
String taskName)
Get the result for the given task name and all result incarnations in the
given jobId.
|
List<TaskResult> |
getTaskResultAllIncarnations(String jobId,
String taskName)
Get the result for the given task name and all result incarnations in the
given jobId.
|
TaskResult |
getTaskResultFromIncarnation(JobId jobId,
String taskName,
int inc)
Get the result for the given task name and the given incarnation in the
given jobId.
|
TaskResult |
getTaskResultFromIncarnation(String jobId,
String taskName,
int inc)
Get the result for the given task name and the given incarnation in the
given jobId.
|
Page<TaskState> |
getTaskStates(String taskTag,
long from,
long to,
boolean mytasks,
boolean running,
boolean pending,
boolean finished,
int offset,
int limit,
SortSpecifierContainer sortParams)
Retrieve a taskstates list from the scheduler.
|
List<String> |
getUserSpaceURIs()
Returns the USER DataSpace URIs associated with the current user
|
void |
init(ConnectionInfo connectionInfo)
Connects to the scheduler
|
void |
init(String url,
CredData credData) |
void |
init(String url,
Credentials credentials) |
void |
initActivity(org.objectweb.proactive.Body body) |
void |
reconnect()
Reconnects this smart proxy to the scheduler
|
void |
registerAsListener() |
protected void |
removeJobIO(Job job,
String pushURL,
String pullURL,
String newFolderName) |
boolean |
restartAllInErrorTasks(String jobId)
Restart all in error tasks in the job represented by jobId.
This method will restart every in error tasks of this job. The jobId is given as a string. |
boolean |
restartInErrorTask(String jobId,
String taskName) |
JobId |
submit(Job job)
Submit a new job to the scheduler.
|
void |
terminateFast()
This method forcefully terminates the activity of the proxy This method
should not be called via a proactive stub
|
boolean |
uploadInputfiles(TaskFlowJob job,
String localInputFolderPath)
Push the input files of the given job from the local input folder to the
location specified by PUSH_URL.
|
addEventListener, addEventListener, addEventListener, changeJobPriority, changeJobPriority, changePolicy, checkInitialized, cleanDatabase, configureEvents, createNewFolderName, freeze, getAccountUsage, getJobResult, getJobResult, getJobs, getJobServerLogs, getJobsInfoList, getJobState, getMyAccountUsage, getState, getState, getStatus, getTaskResultsByTag, getTaskResultsByTag, getTaskServerLogs, getTaskServerLogsByTag, getTasksToSchedule, getUsers, getUsersWithJobs, isConnected, jobStateUpdatedEvent, jobSubmittedEvent, jobUpdatedFullDataEvent, kill, killJob, killJob, killTask, killTask, linkResourceManager, listenJobLogs, listenJobLogs, pause, pauseJob, pauseJob, preemptTask, preemptTask, prepareJobInput, prepareJobOutput, pullData, putThirdPartyCredential, reinitializeState, reloadPolicyConfiguration, removeAwaitedTask, removeEventListener, removeEventListener, removeJob, removeJob, removeThirdPartyCredential, renewSession, restartTask, restartTask, resume, resumeJob, resumeJob, schedulerStateUpdatedEvent, setInitialized, setSessionName, shutdown, start, stop, submit, submit, syncAwaitedJobs, taskStateUpdatedEvent, terminate, thirdPartyCredentialsKeySet, updateJob, updateTask, usersUpdatedEvent
protected transient Scheduler schedulerProxy
public SmartProxyImpl()
getActiveInstance()
or getInstance()
public static SmartProxyImpl getActiveInstance() throws org.objectweb.proactive.ActiveObjectCreationException, org.objectweb.proactive.core.node.NodeException
org.objectweb.proactive.ActiveObjectCreationException
org.objectweb.proactive.core.node.NodeException
public static SmartProxyImpl getInstance()
public void init(ConnectionInfo connectionInfo) throws SchedulerException, LoginException
AbstractSmartProxy
init
in class AbstractSmartProxy<JobTrackerImpl>
LoginException
SchedulerException
public void init(String url, Credentials credentials) throws SchedulerException, LoginException
SchedulerException
LoginException
public void init(String url, CredData credData) throws SchedulerException, LoginException
SchedulerException
LoginException
public void disconnect() throws NotConnectedException, PermissionException
AbstractSmartProxy
disconnect
in interface Scheduler
disconnect
in class AbstractSmartProxy<JobTrackerImpl>
NotConnectedException
- if you are not authenticated.PermissionException
- if you can't access to this particular method.public String getCurrentPolicy() throws NotConnectedException, PermissionException
Scheduler
getCurrentPolicy
in interface Scheduler
getCurrentPolicy
in class AbstractSmartProxy<JobTrackerImpl>
NotConnectedException
PermissionException
public Map getJobsToSchedule() throws NotConnectedException, PermissionException
Scheduler
getJobsToSchedule
in interface Scheduler
getJobsToSchedule
in class AbstractSmartProxy<JobTrackerImpl>
NotConnectedException
PermissionException
protected Scheduler _getScheduler()
AbstractSmartProxy
/!\ This method must not be exposed remotely since remote calls to the proxy that is returned will fail with permission failures.
_getScheduler
in class AbstractSmartProxy<JobTrackerImpl>
public void reconnect() throws SchedulerException, LoginException
AbstractSmartProxy
reconnect
in class AbstractSmartProxy<JobTrackerImpl>
SchedulerException
LoginException
public void registerAsListener() throws NotConnectedException, PermissionException
registerAsListener
in class AbstractSmartProxy<JobTrackerImpl>
NotConnectedException
PermissionException
public boolean uploadInputfiles(TaskFlowJob job, String localInputFolderPath) throws Exception
AbstractSmartProxy
uploadInputfiles
in class AbstractSmartProxy<JobTrackerImpl>
job
- job to push data forlocalInputFolderPath
- utFolderPath local input folderNotConnectedException
PermissionException
Exception
protected void downloadTaskOutputFiles(AwaitedJob awaitedjob, String jobId, String t_name, String localFolder) throws Exception
AbstractSmartProxy
downloadTaskOutputFiles
in class AbstractSmartProxy<JobTrackerImpl>
jobId
- job to pull data fort_name
- name of the tasklocalFolder
- local output folder, if not null, it overrides the folder specified as output folder for the jobException
public JobId submit(Job job) throws NotConnectedException, PermissionException, SubmissionClosedException, JobCreationException
Scheduler
It will execute the tasks of the jobs as soon as resources are available. The job will be considered as finished once every tasks have finished (error or success). Thus, user could get the job result according to the precious result.
It is possible to get a listener on the scheduler. (see
Scheduler.addEventListener(SchedulerEventListener, boolean, SchedulerEvent...)
for more details)
submit
in interface Scheduler
submit
in class AbstractSmartProxy<JobTrackerImpl>
job
- the new job to submit.NotConnectedException
- if you are not authenticated.PermissionException
- if you can't access to this particular method.SubmissionClosedException
- if the submit action could not be performed.JobCreationException
- if Their was a problem while creation the jobpublic JobState getJobState(String jobId) throws NotConnectedException, UnknownJobException, PermissionException
Scheduler
JobId.value()
method.getJobState
in interface Scheduler
getJobState
in class AbstractSmartProxy<JobTrackerImpl>
jobId
- the job on which to get the state.NotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.PermissionException
- if you can't access to this particular job.public TaskResult getTaskResult(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException
Scheduler
JobId.value()
method.getTaskResult
in interface Scheduler
getTaskResult
in class AbstractSmartProxy<JobTrackerImpl>
jobId
- the job in which the task result is.taskName
- the name of the task in which the result is.NotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.UnknownTaskException
- if this task does not exist in the job.PermissionException
- if you can't access to this particular job.public TaskResult getTaskResult(JobId jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException
Scheduler
getTaskResult
in interface Scheduler
getTaskResult
in class AbstractSmartProxy<JobTrackerImpl>
jobId
- the job in which the task result is.taskName
- the name of the task in which the result is.NotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.UnknownTaskException
- if this task does not exist in the job.PermissionException
- if you can't access to this particular job.public TaskResult getTaskResultFromIncarnation(JobId jobId, String taskName, int inc) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException
Scheduler
A user can only get HIS result back.
The incarnation argument represents the task result to get. If the task has failed 3 times and then has worked, then 0 represents the last result, 1 the previous, ..., and 3 represents the result of the first execution.
If the job does not exist, a schedulerException is sent with the proper message.
So, if you have the right to get the task result that is in the job represented by the given jobId and if the job and task name exist, so you will receive the result. In any other cases a schedulerException will be thrown.
getTaskResultFromIncarnation
in interface Scheduler
getTaskResultFromIncarnation
in class AbstractSmartProxy<JobTrackerImpl>
jobId
- the job in which the task result is.taskName
- the name of the task in which the result is.inc
- id of incarnation (0 is the last one, 1 the previous, and so
on...)NotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.UnknownTaskException
- if this task does not exist in the job.PermissionException
- if you can't access to this particular job.public List<TaskResult> getTaskResultAllIncarnations(JobId jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException
Scheduler
This method returns a list of task result attempts. If the task has failed 3 times and then has worked, then the list will contain a list of 4 task results. 0 represents the first failed result attempt, 1 the next one, ..., and 3 represents the result of the last execution. In that sense the id order is reversed comparing to individual calls to getTaskResultFromIncarnation
getTaskResultAllIncarnations
in interface Scheduler
getTaskResultAllIncarnations
in class AbstractSmartProxy<JobTrackerImpl>
jobId
- the job in which the task result is.taskName
- the name of the task in which the result is.NotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.UnknownTaskException
- if this task does not exist in the job.PermissionException
- if you can't access to this particular job.public List<TaskResult> getTaskResultAllIncarnations(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException
Scheduler
This method returns a list of task result attempts. If the task has failed 3 times and then has worked, then the list will contain a list of 4 task results. 0 represents the first failed result attempt, 1 the next one, ..., and 3 represents the result of the last execution. In that sense the id order is reversed comparing to individual calls to
getTaskResultAllIncarnations
in interface Scheduler
getTaskResultAllIncarnations
in class AbstractSmartProxy<JobTrackerImpl>
jobId
- the job in which the task result is.taskName
- the name of the task in which the result is.NotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.UnknownTaskException
- if this task does not exist in the job.PermissionException
- if you can't access to this particular job.public TaskResult getTaskResultFromIncarnation(String jobId, String taskName, int inc) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException
Scheduler
JobId.value()
method. A user can only get HIS
result back. The incarnation argument represents the task result to get.
If the task has failed 3 times and then has worked, then 0 represents the
last result, 1 the previous, ..., and 3 represents the result of the
first execution.
If the job does not exist, a schedulerException is sent with the proper message. So, if you have the right to get the task result that is in the job represented by the given jobId and if the job and task name exist, so you will receive the result. In any other cases a schedulerException will be thrown.
getTaskResultFromIncarnation
in interface Scheduler
getTaskResultFromIncarnation
in class AbstractSmartProxy<JobTrackerImpl>
jobId
- the job in which the task result is.taskName
- the name of the task in which the result is.inc
- id of incarnation (0 is the last one, 1 the previous, and so
on...)NotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.UnknownTaskException
- if this task does not exist in the job.PermissionException
- if you can't access to this particular job.public boolean finishInErrorTask(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException
finishInErrorTask
in interface Scheduler
NotConnectedException
UnknownJobException
UnknownTaskException
PermissionException
public boolean restartInErrorTask(String jobId, String taskName) throws NotConnectedException, UnknownJobException, UnknownTaskException, PermissionException
restartInErrorTask
in interface Scheduler
NotConnectedException
UnknownJobException
UnknownTaskException
PermissionException
public boolean restartAllInErrorTasks(String jobId) throws NotConnectedException, UnknownJobException, PermissionException
Scheduler
JobId.value()
method.restartAllInErrorTasks
in interface Scheduler
jobId
- the job to resume.NotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.PermissionException
- if you can't access to this particular job.public List<String> getGlobalSpaceURIs() throws NotConnectedException, PermissionException
Scheduler
getGlobalSpaceURIs
in interface Scheduler
getGlobalSpaceURIs
in class AbstractSmartProxy<JobTrackerImpl>
NotConnectedException
- if you are not authenticated.PermissionException
public List<String> getUserSpaceURIs() throws NotConnectedException, PermissionException
Scheduler
getUserSpaceURIs
in interface Scheduler
getUserSpaceURIs
in class AbstractSmartProxy<JobTrackerImpl>
NotConnectedException
- if you are not authenticated.PermissionException
public void addEventListener(SchedulerEventListenerExtended listener, boolean myEventsOnly, SchedulerEvent[] events) throws NotConnectedException, PermissionException
addEventListener
in class AbstractSmartProxy<JobTrackerImpl>
NotConnectedException
PermissionException
protected void removeJobIO(Job job, String pushURL, String pullURL, String newFolderName)
removeJobIO
in class AbstractSmartProxy<JobTrackerImpl>
protected void createFolder(String fUri) throws NotConnectedException, PermissionException
createFolder
in class AbstractSmartProxy<JobTrackerImpl>
NotConnectedException
PermissionException
public void initActivity(org.objectweb.proactive.Body body)
initActivity
in interface org.objectweb.proactive.InitActive
public void endActivity(org.objectweb.proactive.Body body)
endActivity
in interface org.objectweb.proactive.EndActive
public void terminateFast()
public Page<TaskId> getTaskIds(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit) throws NotConnectedException, PermissionException
Scheduler
getTaskIds
in interface Scheduler
taskTag
- a complete tag to use to filter tasksfrom
- the starting date to fetch tasks from. The format is in Epoch
time.to
- the end date to stop fetching tasks. The format is in Epoch
time.mytasks
- True
will only fetch the user tasks,
False
will fetch everyones.running
- fetch the running tasks.pending
- fetch the pending tasks.finished
- fetch the finished tasks.offset
- the starting task to include in the paginated list.limit
- the last task (not included) before stopping fetching tasks in
the paginated list.NotConnectedException
PermissionException
public Page<TaskState> getTaskStates(String taskTag, long from, long to, boolean mytasks, boolean running, boolean pending, boolean finished, int offset, int limit, SortSpecifierContainer sortParams) throws NotConnectedException, PermissionException
Scheduler
getTaskStates
in interface Scheduler
taskTag
- a complete tag to use to filter tasksfrom
- the starting date to fetch tasks from. The format is in Epoch
time.to
- the end date to stop fetching tasks. The format is in Epoch
time.mytasks
- True
will only fetch the user tasks,
False
will fetch everyones.running
- fetch the running tasks.pending
- fetch the pending tasks.finished
- fetch the finished tasks.offset
- the starting task to include in the paginated list.limit
- the last task (not included) before stopping fetching tasks in
the paginated list.NotConnectedException
PermissionException
public JobInfo getJobInfo(String jobId) throws UnknownJobException, NotConnectedException, PermissionException
Scheduler
getJobInfo
in interface Scheduler
jobId
- the id of the job we want to fetch info.JobInfo
associated to the given idUnknownJobException
NotConnectedException
PermissionException
public boolean changeStartAt(JobId jobId, String startAt) throws NotConnectedException, UnknownJobException, PermissionException
Scheduler
changeStartAt
in interface Scheduler
jobId
- id of the job that needs to be updatedstartAt
- its value should be ISO 8601 compliantNotConnectedException
UnknownJobException
PermissionException
public String getJobContent(JobId jobId) throws UnknownJobException, SubmissionClosedException, JobCreationException, NotConnectedException, PermissionException
getJobContent
in interface Scheduler
jobId
- job id of existing jobUnknownJobException
SubmissionClosedException
JobCreationException
NotConnectedException
PermissionException
public Map<Object,Object> getPortalConfiguration() throws NotConnectedException, PermissionException
getPortalConfiguration
in interface Scheduler
NotConnectedException
PermissionException
public String getCurrentUser() throws NotConnectedException
Scheduler
getCurrentUser
in interface Scheduler
NotConnectedException
public UserData getCurrentUserData() throws NotConnectedException
Scheduler
getCurrentUserData
in interface Scheduler
NotConnectedException
public Map<String,Object> getSchedulerProperties() throws NotConnectedException, PermissionException
Scheduler
getSchedulerProperties
in interface Scheduler
NotConnectedException
PermissionException
public TaskStatesPage getTaskPaginated(String jobId, int offset, int limit) throws NotConnectedException, UnknownJobException, PermissionException
Scheduler
getTaskPaginated
in interface Scheduler
jobId
- the job on which to get the state.offset
- the starting index of the sublist of tasks to getlimit
- the last index (non inclusive) of the sublist of tasks to getNotConnectedException
- if you are not authenticated.UnknownJobException
- if the job does not exist.PermissionException
- if you can't access to this particular job.public boolean checkJobPermissionMethod(String sessionId, String jobId, String method) throws NotConnectedException, UnknownJobException
Scheduler
checkJobPermissionMethod
in interface Scheduler
NotConnectedException
UnknownJobException