Search in sources :

Example 1 with CopyRequest

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);
}
Also used : CopyRequest(org.dcache.srm.request.CopyRequest)

Example 2 with CopyRequest

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());
}
Also used : CopyRequest(org.dcache.srm.request.CopyRequest)

Example 3 with CopyRequest

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);
}
Also used : TFileStorageType(org.dcache.srm.v2_2.TFileStorageType) CopyRequest(org.dcache.srm.request.CopyRequest) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency)

Example 4 with CopyRequest

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));
}
Also used : CopyRequest(org.dcache.srm.request.CopyRequest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with CopyRequest

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);
    }
}
Also used : CopyRequest(org.dcache.srm.request.CopyRequest) JDC(org.dcache.srm.util.JDC) URI(org.apache.axis.types.URI) SRMInvalidRequestException(org.dcache.srm.SRMInvalidRequestException)

Aggregations

CopyRequest (org.dcache.srm.request.CopyRequest)7 JDC (org.dcache.srm.util.JDC)2 TAccessLatency (org.dcache.srm.v2_2.TAccessLatency)2 TRetentionPolicy (org.dcache.srm.v2_2.TRetentionPolicy)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 URI (java.net.URI)1 URI (org.apache.axis.types.URI)1 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)1 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)1 IllegalStateTransition (org.dcache.srm.scheduler.IllegalStateTransition)1 SrmCopyRequest (org.dcache.srm.v2_2.SrmCopyRequest)1 TCopyFileRequest (org.dcache.srm.v2_2.TCopyFileRequest)1 TFileStorageType (org.dcache.srm.v2_2.TFileStorageType)1 TOverwriteMode (org.dcache.srm.v2_2.TOverwriteMode)1