use of org.dcache.srm.request.CopyRequest in project dcache by dCache.
the class CopyRequestStorage method getCreateStatement.
@Override
public PreparedStatement getCreateStatement(Connection connection, Job job) throws SQLException {
CopyRequest cr = (CopyRequest) job;
String storageTypeValue = null;
if (cr.getStorageType() != null) {
storageTypeValue = cr.getStorageType().getValue();
}
String retentionPolicyValue = null;
if (cr.getTargetRetentionPolicy() != null) {
retentionPolicyValue = cr.getTargetRetentionPolicy().getValue();
}
String accessLatencyValue = null;
if (cr.getTargetAccessLatency() != null) {
accessLatencyValue = cr.getTargetAccessLatency().getValue();
}
return getPreparedStatement(connection, INSERT_SQL, cr.getId(), cr.getNextJobId(), cr.getCreationTime(), cr.getLifetime(), // 5
cr.getState().getStateId(), cr.latestHistoryEvent(), cr.getSchedulerId(), cr.getSchedulerTimeStamp(), // num of retries
0, // 10
cr.getLastStateTransitionTime(), // Database Request Storage
cr.getCredentialId(), cr.getRetryDeltaTime(), cr.isShould_updateretryDeltaTime() ? 0 : 1, cr.getDescription(), cr.getClient_host(), cr.getStatusCodeString(), cr.getUser().getId(), storageTypeValue, retentionPolicyValue, accessLatencyValue);
}
use of org.dcache.srm.request.CopyRequest in project dcache by dCache.
the class CopyRequestStorage method getUpdateStatement.
@Override
public PreparedStatement getUpdateStatement(Connection connection, Job job) throws SQLException {
CopyRequest cr = (CopyRequest) job;
String storageTypeValue = null;
if (cr.getStorageType() != null) {
storageTypeValue = cr.getStorageType().getValue();
}
String retentionPolicyValue = null;
if (cr.getTargetRetentionPolicy() != null) {
retentionPolicyValue = cr.getTargetRetentionPolicy().getValue();
}
String accessLatencyValue = null;
if (cr.getTargetAccessLatency() != null) {
accessLatencyValue = cr.getTargetAccessLatency().getValue();
}
return getPreparedStatement(connection, UPDATE_REQUEST_SQL, cr.getNextJobId(), cr.getCreationTime(), cr.getLifetime(), cr.getState().getStateId(), // 5
cr.latestHistoryEvent(), cr.getSchedulerId(), cr.getSchedulerTimeStamp(), // num of retries
0, cr.getLastStateTransitionTime(), // 10
cr.getCredentialId(), cr.getRetryDeltaTime(), cr.isShould_updateretryDeltaTime() ? 0 : 1, cr.getDescription(), cr.getClient_host(), cr.getStatusCodeString(), cr.getUser().getId(), storageTypeValue, retentionPolicyValue, accessLatencyValue, cr.getId());
}
use of org.dcache.srm.request.CopyRequest in project dcache by dCache.
the class CopyRequestStorage method getContainerRequest.
@Override
protected CopyRequest getContainerRequest(Connection _con, long ID, Long NEXTJOBID, long CREATIONTIME, long LIFETIME, int STATE, SRMUser user, String SCHEDULERID, long SCHEDULER_TIMESTAMP, int NUMOFRETR, long LASTSTATETRANSITIONTIME, Long CREDENTIALID, int RETRYDELTATIME, boolean SHOULDUPDATERETRYDELTATIME, String DESCRIPTION, String CLIENTHOST, String STATUSCODE, ImmutableList<CopyFileRequest> fileRequests, ResultSet set, int next_index) throws SQLException {
Job.JobHistory[] jobHistoryArray = getJobHistory(ID, _con);
String STORAGETYPE = set.getString(next_index++);
String RETENTIONPOLICY = set.getString(next_index++);
String ACCESSLATENCY = set.getString(next_index++);
TFileStorageType storageType = STORAGETYPE == null || STORAGETYPE.equalsIgnoreCase("null") ? null : TFileStorageType.fromString(STORAGETYPE);
TRetentionPolicy retentionPolicy = RETENTIONPOLICY == null || RETENTIONPOLICY.equalsIgnoreCase("null") ? null : TRetentionPolicy.fromString(RETENTIONPOLICY);
TAccessLatency accessLatency = ACCESSLATENCY == null || ACCESSLATENCY.equalsIgnoreCase("null") ? null : TAccessLatency.fromString(ACCESSLATENCY);
return new CopyRequest(srmId, ID, NEXTJOBID, CREATIONTIME, LIFETIME, STATE, user, SCHEDULERID, SCHEDULER_TIMESTAMP, NUMOFRETR, LASTSTATETRANSITIONTIME, jobHistoryArray, CREDENTIALID, fileRequests, RETRYDELTATIME, SHOULDUPDATERETRYDELTATIME, DESCRIPTION, CLIENTHOST, STATUSCODE, storageType, retentionPolicy, accessLatency);
}
use of org.dcache.srm.request.CopyRequest in project dcache by dCache.
the class SchedulerContainerTests method shouldScheduleRestoredCopyRequests.
@Test
public void shouldScheduleRestoredCopyRequests() throws Exception {
CopyRequest job = mockJob(CopyRequest.class, INPROGRESS, "copy_localhost");
container.restoreJobsOnSrmStart(Lists.newArrayList(job), false);
ArgumentCaptor<Scheduler> schedCapture = ArgumentCaptor.forClass(Scheduler.class);
verify(job, times(1)).onSrmRestart(schedCapture.capture(), eq(false));
assertThat(schedCapture.getValue(), is(genericScheduler));
}
use of org.dcache.srm.request.CopyRequest in project dcache by dCache.
the class SrmStatusOfCopyRequest method srmStatusOfCopyRequest.
private SrmStatusOfCopyRequestResponse srmStatusOfCopyRequest() throws SRMInvalidRequestException {
CopyRequest copyRequest = Request.getRequest(request.getRequestToken(), CopyRequest.class);
try (JDC ignored = copyRequest.applyJdc()) {
if (request.getArrayOfSourceSURLs() == null || request.getArrayOfTargetSURLs() == null) {
return copyRequest.getSrmStatusOfCopyRequest();
}
URI[] fromsurls = request.getArrayOfSourceSURLs().getUrlArray();
URI[] tosurls = request.getArrayOfTargetSURLs().getUrlArray();
if (fromsurls.length == 0 || tosurls.length == 0) {
return copyRequest.getSrmStatusOfCopyRequest();
}
if (tosurls.length != fromsurls.length) {
throw new SRMInvalidRequestException("Length of arrayOfSourceSURLs and arrayOfTargetSURLs differ.");
}
return copyRequest.getSrmStatusOfCopyRequest(fromsurls, tosurls);
}
}
Aggregations