/**
* The 3DOrchestrate job database requires that each activity DB record
* identify the DRM job, if any, which is managing that activity.
* The activity DB table records the DRM system's job ID in a
* string column; therefore DRM job IDs must be strings, or at
* least must be interconvertible with a string format. This
* method converts string from the activity record to a job ID.
* @param jobID String
* @return DRMJobID
*/
@Override
public DRMJobID makeDRMJobIDFromString(String jobID) {
//sample implementation
return new DemoDrmJObID(jobID);}
/**
* This method is called periodically by the 3DOrchestrate server
* to maintain the health of the DRM system.
* @param timerInterval long
* @throws PSEException
*/
@Override
public void audit(long timerInterval) throws PSEException {
//write DRM audit operation operation
}
/**
* This method is called by the 3DOrchestrate server to
* cancel a set of DRM jobs currently managed by this DRM
* system. ALL of the DRM ID objects in the given list must
* be ID objects created by the 'submit()' method of this
* DRM system.
* @param drmJobIDList List<DRMJobID>
* @param commandRunner DRMCommandRunner
* @throws PSEException
*/
@Override
public void cancel(List<DRMJobID> arg0, DRMCommandRunner arg1)
throws PSEException {
//write cancel operation for each drm job ID from drmJobIDList
}
/**
* This method is called by the 3DOrchestrate server to
* create a new DRM job, providing it with all data needed
* to evaluate a given 3DOrchestrate workitem [by launching a 3DOrchestrate
* Station and telling it to claim that particular workitem].
* @param IDRMDataWrapper wraps DRM data
* @interface IDRMDataWrapper interface have following methods -
* @method getDrmType() - this method return current drm name
* @method getJobID() - this method will return 3DOrchestrate JOB ID
* @method getCosimGroupID() - this method return cosimulation group ID
* @method getWorkitemID() - this method return the workitem ID
* @method getWorkItemIDList() - this method returns list of workitem IDs which could be used for co-simulatoin
* @method getUserName() - this method returns userName
* @method getTenantID() - this method returns tenant ID
* @method getDrmAffinityResourceData() - this method returns DRMResourceRequest class
* @method getDrmResReqSet() -this method returns List<String> contains drm resource list
* @method getDrmCommandPropertiesList() this method returns List<DRMCommandProperties> which contains list of command line properties that needs to be passed to DRM
* @method getSubmitHost() this method returns the submit host
* @method getCommandRunner() this method returns command runner object. This object will be used to get credentials
* @method getJobLog() this method used to get 3DOrchestrate job log
* @method getJobMgr() this method used to get 3DOrchestrate job manager
* @method isContainSteps() this method returns true if job contains step
* @method isCosimulation() this method checks if is cosimulation
* @method getJobLogMgr() this method returns job log manager
* @return DRMJobID - return job id created by DRM
* @throws PSEException the PSE exception
*/
@Override
public DRMJobID submit(IDRMDataWrapper drmDataWrapper) throws PSEException {
//sample implementation
//Way to access OS run-as credentials
Map<String, byte[]> credMap;
try {
credMap = drmDataWrapper.getCommandRunner().getDRMResourceCredentialForOS(drmDataWrapper.getJobID(),this.getClass().getCanonicalName(), this);
// get individual credentials from the map
byte[] user = credMap.get("user");
String decryptedUser = new String(user);
byte[] password = credMap.get("password");
String decryptedPasswrod = new String(password);
} catch (Exception e) { e.printStackTrace();}
// build DRM command
StringBuilder commandBuilder = new StringBuilder();
List<DRMCommandProperties> drmCommandPropertiesList = drmDataWrapper.getDrmCommandPropertiesList();
for (DRMCommandProperties drmCommand : drmCommandPropertiesList) {
String name = drmCommand.getName();
String type = drmCommand.getType();
String value = drmCommand.getValve();
commandBuilder.append(name + " " + value + " ");
}
String[] command = commandBuilder.toString().split(" ");
//built transtation command and run
String drmjobID = drmDataWrapper.getCommandRunner().customDRMSubmit(command, drmDataWrapper);
//return drm job ID to 3DOrchestrate server
return new DemoDrmJObID(drmjobID);
}
/**
* This method is called by the 3DOrchestrate server to
* create a new job in this DRM system, providing it with
* all data needed to 'co-evaluate' a given set of
* workitems [by launching a transtation and telling
* it to claim that particular set of workitem]. It has
* been declared separately from 'submit' specifically to
* allow DRM Enablers to support the 3DOrchestrate’s 'cosimulation'
* feature.
* @param IDRMDataWrapper wraps DRM data
* @interface IDRMDataWrapper interface have following methods -
* @method getDrmType() - this method return current drm name
* @method getJobID() - this method will return 3DOrchestrate JOB ID
* @method getCosimGroupID() - this method return cosimulation group ID
* @method getWorkitemID() - this method return the workitem ID
* @method getWorkItemIDList() - this method returns list of workitem IDs which could be used for co-simulatoin
* @method getUserName() - this method returns userName
* @method getTenantID() - this method returns tenant ID
* @method getDrmAffinityResourceData() - this method returns DRMResourceRequest class
* @method getDrmResReqSet() -this method returns List<String> contains drm resource list
* @method getDrmCommandPropertiesList() this method returns List<DRMCommandProperties> which contains list of command line properties that needs to be passed to DRM
* @method getSubmitHost() this method returns the submit host
* @method getCommandRunner() this method returns command runner object. This object will be used to get credentials
* @method getJobLog() this method used to get 3DOrchestrate job log
* @method getJobMgr() this method used to get 3DOrchestrate job manager
* @method isContainSteps() this method returns true if job contains step
* @method isCosimulation() this mehod checks if is cosimulation
* @method getJobLogMgr() this method returns job log manager
* @return DRMJobID - return job id created by DRM
* @throws PSEException the PSE exception
*/
@Override
public DRMJobID cosubmit(IDRMDataWrapper drmDataWrapper) throws PSEException {}
/**
* This method is called by the 3DOrchestrate server to
* obtain the list of available host groups.
* @param commandRunner DRMCommandRunner
* @return Map<String, List<String>>
* @throws PSEException
*/
@Override
public Map<String, List<String>> getGroupsMap(DRMCommandRunner arg0)
throws PSEException {
//sample implementation
return new HashMap<String, List<String>>();/
}
/**
* This method is called by the 3DOrchestrate server to
* obtain the list of available queues.
* @param commandRunner DRMCommandRunner
* @return List<String>
* @throws PSEException
*/
@Override
public List<String> getQueuesList(DRMCommandRunner drmCommandRunner)
throws PSEException {
//sample implementation
return new ArrayList<String>();
}
/**
* This method is called by the 3DOrchestrate server to
* release resources for a set of DRM jobs currently managed by this DRM system.
* ALL of the DRM ID objects in the given list must
* be ID objects created by the 'submit()' method of this
* DRM system. This is used in DRMs where the resource needs to be "freed"
* after the activity is complete.
* @param drmJobIDList List<DRMJobID>
* @param commandRunner DRMCommandRunner
* @throws PSEException
*/
@Override
public void release(List<DRMJobID> arg0, DRMCommandRunner arg1)
throws PSEException {}
/**
* This method is called by the 3DOrchestrate server to
* check the statuses of a set of DRM jobs currently managed
* by this DRM system. ALL of the DRM ID objects in the
* given list must be ID objects created by the 'submit()'
* method of this DRM system.
* @param drmJobIDList List<DRMJobID>`
* @param commandRunner DRMCommandRunner
* @return List<DRMJobValue>
* @throws PSEException
*/
@Override
public List<DRMJobValue> query(List<DRMJobID> arg0, DRMCommandRunner arg1)
throws PSEException {
//Sample Implementation
//Step 1 - To know the status of each each job query to the DRM system for each drm job ID
//Write code to query drm system to know job status for each drm job ID
//Step 2 - Iterate each DRM job ID and construct DRMJobValue object with its status returned by DRM system
List<DRMJobValue> jobStats = new ArrayList<DRMJobValue>();
// query to DRM to know status for each job and send back status to 3DOrchestrate server
//Map each job DRM job ID status with 3Dorchestrate job status
//refer these mapping
//DRM JOB Status 3DOrchestrate JOB Status
//1.DRM job staus undefined DRMJobStatus.DRM_JOBSTATUS_UNDEFINED
//2.DRM job staus pending DRMJobStatus.DRM_JOBSTATUS_PENDING
//3.DRM job staus running DRMJobStatus.DRM_JOBSTATUS_RUNNING
//4.DRM job staus paused DRMJobStatus.DRM_JOBSTATUS_PAUSED
//5.DRM job staus done DRMJobStatus.DRM_JOBSTATUS_DONE
//6.DRM job staus suspended DRMJobStatus.DRM_JOBSTATUS_SUSPENDED
//7.DRM job staus aborted DRMJobStatus.DRM_JOBSTATUS_ABORTED
//8.DRM job staus unknown DRMJobStatus.DRM_JOBSTATUS_UNKNOWN
//9.DRM job staus cancelled DRMJobStatus.DRM_JOBSTATUS_CANCELLED
for (DRMJobID drmjobID : drmJobIDList) {
jobStats.add(new DRMJobValue(drmjobID,DRMJobStatus.DRM_JOBSTATUS_DONE, "CustomDRM"));
}
return jobStats;
}