Search in sources :

Example 1 with PutFileRequest

use of org.dcache.srm.request.PutFileRequest in project dcache by dCache.

the class PutFileRequestStorage method getStatement.

private PreparedStatement getStatement(Connection connection, String query, Job job) throws SQLException {
    PutFileRequest request = (PutFileRequest) job;
    TRetentionPolicy retentionPolicy = request.getRetentionPolicy();
    TAccessLatency accessLatency = request.getAccessLatency();
    return getPreparedStatement(connection, query, request.getNextJobId(), request.getCreationTime(), request.getLifetime(), request.getState().getStateId(), request.latestHistoryEvent(), request.getSchedulerId(), request.getSchedulerTimeStamp(), // num of retries
    0, request.getLastStateTransitionTime(), request.getRequestId(), request.getStatusCodeString(), request.getSurlString(), request.getTurlString(), request.getFileId(), // parentFileId (unused)
    null, request.getSpaceReservationId(), request.getSize(), (retentionPolicy != null ? retentionPolicy.getValue() : null), (accessLatency != null ? accessLatency.getValue() : null), request.getId());
}
Also used : PutFileRequest(org.dcache.srm.request.PutFileRequest) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency)

Example 2 with PutFileRequest

use of org.dcache.srm.request.PutFileRequest in project dcache by dCache.

the class PutFileRequestStorage method getFileRequest.

@Override
protected PutFileRequest getFileRequest(Connection _con, long ID, Long NEXTJOBID, long CREATIONTIME, long LIFETIME, int STATE, String SCHEDULERID, long SCHEDULER_TIMESTAMP, int NUMOFRETR, long LASTSTATETRANSITIONTIME, long REQUESTID, Long CREDENTIALID, String STATUSCODE, ResultSet set, int next_index) throws SQLException {
    String SURL = set.getString(next_index++);
    String TURL = set.getString(next_index++);
    String FILEID = set.getString(next_index++);
    String PARENTFILEID = set.getString(next_index++);
    String SPACERESERVATIONID = set.getString(next_index++);
    Long SIZE = set.getLong(next_index++);
    if (set.wasNull()) {
        SIZE = null;
    }
    String RETENTIONPOLICY = set.getString(next_index++);
    String ACCESSLATENCY = set.getString(next_index++);
    TRetentionPolicy retentionPolicy = RETENTIONPOLICY == null || RETENTIONPOLICY.equalsIgnoreCase("null") ? null : TRetentionPolicy.fromString(RETENTIONPOLICY);
    TAccessLatency accessLatency = ACCESSLATENCY == null || ACCESSLATENCY.equalsIgnoreCase("null") ? null : TAccessLatency.fromString(ACCESSLATENCY);
    Job.JobHistory[] jobHistoryArray = getJobHistory(ID, _con);
    return new PutFileRequest(ID, NEXTJOBID, CREATIONTIME, LIFETIME, STATE, SCHEDULERID, SCHEDULER_TIMESTAMP, NUMOFRETR, LASTSTATETRANSITIONTIME, jobHistoryArray, REQUESTID, STATUSCODE, SURL, TURL, FILEID, SPACERESERVATIONID, SIZE, retentionPolicy, accessLatency);
}
Also used : PutFileRequest(org.dcache.srm.request.PutFileRequest) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency)

Example 3 with PutFileRequest

use of org.dcache.srm.request.PutFileRequest in project dcache by dCache.

the class SchedulerContainerTests method shouldSchedulePutFileRequest.

@Test
public void shouldSchedulePutFileRequest() throws Exception {
    PutFileRequest job = mockJob(PutFileRequest.class);
    ArgumentCaptor<Scheduler> schedCapture = ArgumentCaptor.forClass(Scheduler.class);
    container.schedule(job);
    verify(job, times(1)).scheduleWith(schedCapture.capture());
    assertThat(schedCapture.getValue(), is(putScheduler));
}
Also used : PutFileRequest(org.dcache.srm.request.PutFileRequest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with PutFileRequest

use of org.dcache.srm.request.PutFileRequest in project dcache by dCache.

the class PutFileRequestStorage method getCreateStatement.

@Override
public PreparedStatement getCreateStatement(Connection connection, Job job) throws SQLException {
    if (job == null || !(job instanceof PutFileRequest)) {
        throw new IllegalArgumentException("fr is not PutFileRequest");
    }
    PutFileRequest request = (PutFileRequest) job;
    TRetentionPolicy retentionPolicy = request.getRetentionPolicy();
    TAccessLatency accessLatency = request.getAccessLatency();
    return getPreparedStatement(connection, INSERT_SQL, request.getId(), request.getNextJobId(), request.getCreationTime(), request.getLifetime(), request.getState().getStateId(), request.latestHistoryEvent(), request.getSchedulerId(), request.getSchedulerTimeStamp(), // num of retries
    0, request.getLastStateTransitionTime(), request.getRequestId(), request.getStatusCodeString(), request.getSurlString(), request.getTurlString(), request.getFileId(), // parentFileId (unused)
    null, request.getSpaceReservationId(), request.getSize(), (retentionPolicy != null ? retentionPolicy.getValue() : null), (accessLatency != null ? accessLatency.getValue() : null));
}
Also used : PutFileRequest(org.dcache.srm.request.PutFileRequest) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency)

Example 5 with PutFileRequest

use of org.dcache.srm.request.PutFileRequest in project dcache by dCache.

the class SchedulerContainerTests method shouldScheduleRestoredPutFileRequests.

@Test
public void shouldScheduleRestoredPutFileRequests() throws Exception {
    PutFileRequest job = mockJob(PutFileRequest.class, INPROGRESS, "put_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(putScheduler));
}
Also used : PutFileRequest(org.dcache.srm.request.PutFileRequest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

PutFileRequest (org.dcache.srm.request.PutFileRequest)7 TAccessLatency (org.dcache.srm.v2_2.TAccessLatency)3 TRetentionPolicy (org.dcache.srm.v2_2.TRetentionPolicy)3 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 URI (org.apache.axis.types.URI)1 SRMAbortedException (org.dcache.srm.SRMAbortedException)1 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)1 SRMFileRequestNotFoundException (org.dcache.srm.SRMFileRequestNotFoundException)1 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)1 SRMRequestTimedOutException (org.dcache.srm.SRMRequestTimedOutException)1 GetFileRequest (org.dcache.srm.request.GetFileRequest)1 PutRequest (org.dcache.srm.request.PutRequest)1 IllegalStateTransition (org.dcache.srm.scheduler.IllegalStateTransition)1 JDC (org.dcache.srm.util.JDC)1 ArrayOfAnyURI (org.dcache.srm.v2_2.ArrayOfAnyURI)1 ArrayOfTSURLReturnStatus (org.dcache.srm.v2_2.ArrayOfTSURLReturnStatus)1 SrmPutDoneResponse (org.dcache.srm.v2_2.SrmPutDoneResponse)1 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)1 TSURLReturnStatus (org.dcache.srm.v2_2.TSURLReturnStatus)1