Search in sources :

Example 1 with TRetentionPolicy

use of org.dcache.srm.v2_2.TRetentionPolicy in project dcache by dCache.

the class LsFileRequest method convertFileMetaDataToTMetaDataPathDetail.

private TMetaDataPathDetail convertFileMetaDataToTMetaDataPathDetail(final URI path, final FileMetaData fmd, final boolean verbose) throws SRMException {
    TMetaDataPathDetail metaDataPathDetail = new TMetaDataPathDetail();
    metaDataPathDetail.setPath(getPath(path));
    metaDataPathDetail.setLifetimeAssigned(-1);
    metaDataPathDetail.setLifetimeLeft(-1);
    metaDataPathDetail.setSize(new UnsignedLong(fmd.size));
    if (fmd.isDirectory) {
        metaDataPathDetail.setType(TFileType.DIRECTORY);
    } else if (fmd.isLink) {
        metaDataPathDetail.setType(TFileType.LINK);
    } else if (fmd.isRegular) {
        metaDataPathDetail.setType(TFileType.FILE);
    } else {
        LOGGER.debug("file type is Unknown");
    }
    if (verbose) {
        // TODO: this needs to be rewritten to
        // take the ACLs into account.
        TUserPermission userPermission = new TUserPermission();
        userPermission.setUserID(fmd.owner);
        int userPerm = (fmd.permMode >> 6) & 7;
        userPermission.setMode(maskToTPermissionMode(userPerm));
        metaDataPathDetail.setOwnerPermission(userPermission);
        TGroupPermission groupPermission = new TGroupPermission();
        groupPermission.setGroupID(fmd.group);
        int groupPerm = (fmd.permMode >> 3) & 7;
        groupPermission.setMode(maskToTPermissionMode(groupPerm));
        metaDataPathDetail.setGroupPermission(groupPermission);
        metaDataPathDetail.setOtherPermission(maskToTPermissionMode(fmd.permMode & 7));
        GregorianCalendar td = new GregorianCalendar();
        td.setTimeInMillis(fmd.creationTime);
        metaDataPathDetail.setCreatedAtTime(td);
        td = new GregorianCalendar();
        td.setTimeInMillis(fmd.lastModificationTime);
        metaDataPathDetail.setLastModificationTime(td);
        if (fmd.checksumType != null && fmd.checksumValue != null) {
            metaDataPathDetail.setCheckSumType(fmd.checksumType);
            metaDataPathDetail.setCheckSumValue(fmd.checksumValue);
        }
        metaDataPathDetail.setFileStorageType(TFileStorageType.PERMANENT);
        if (!fmd.isPermanent) {
            if (fmd.isPinned) {
                metaDataPathDetail.setFileStorageType(TFileStorageType.DURABLE);
            } else {
                metaDataPathDetail.setFileStorageType(TFileStorageType.VOLATILE);
            }
        }
        metaDataPathDetail.setFileLocality(fmd.locality);
        if (fmd.retentionPolicyInfo != null) {
            TAccessLatency al = fmd.retentionPolicyInfo.getAccessLatency();
            TRetentionPolicy rp = fmd.retentionPolicyInfo.getRetentionPolicy();
            metaDataPathDetail.setRetentionPolicyInfo(new TRetentionPolicyInfo(rp, al));
        }
        if (fmd.spaceTokens != null) {
            if (fmd.spaceTokens.length > 0) {
                ArrayOfString arrayOfSpaceTokens = new ArrayOfString(new String[fmd.spaceTokens.length]);
                for (int st = 0; st < fmd.spaceTokens.length; st++) {
                    arrayOfSpaceTokens.setStringArray(st, String.valueOf(fmd.spaceTokens[st]));
                }
                metaDataPathDetail.setArrayOfSpaceTokens(arrayOfSpaceTokens);
            }
        }
    }
    metaDataPathDetail.setStatus(new TReturnStatus(TStatusCode.SRM_SUCCESS, null));
    return metaDataPathDetail;
}
Also used : TRetentionPolicyInfo(org.dcache.srm.v2_2.TRetentionPolicyInfo) UnsignedLong(org.apache.axis.types.UnsignedLong) TReturnStatus(org.dcache.srm.v2_2.TReturnStatus) ArrayOfTMetaDataPathDetail(org.dcache.srm.v2_2.ArrayOfTMetaDataPathDetail) TMetaDataPathDetail(org.dcache.srm.v2_2.TMetaDataPathDetail) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) GregorianCalendar(java.util.GregorianCalendar) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency) TUserPermission(org.dcache.srm.v2_2.TUserPermission) TGroupPermission(org.dcache.srm.v2_2.TGroupPermission)

Example 2 with TRetentionPolicy

use of org.dcache.srm.v2_2.TRetentionPolicy in project dcache by dCache.

the class PutFileRequest method toString.

@Override
public void toString(StringBuilder sb, String padding, boolean longformat) {
    sb.append(padding);
    if (padding.isEmpty()) {
        sb.append("Put ");
    }
    sb.append("file id:").append(getId());
    State state = getState();
    sb.append(" state:").append(state);
    if (longformat) {
        sb.append('\n');
        sb.append(padding).append("   SURL: ").append(getSurlString()).append('\n');
        sb.append(padding).append("   TURL: ").append(getTurlString()).append('\n');
        if (getSize() != null) {
            sb.append(padding).append("   Size: ").append(getSize()).append('\n');
        }
        TAccessLatency al = getAccessLatency();
        if (al != null) {
            sb.append(padding).append("   Access latency: ").append(al).append('\n');
        }
        TRetentionPolicy rp = getRetentionPolicy();
        if (rp != null) {
            sb.append(padding).append("   Retention policy: ").append(rp).append('\n');
        }
        String space = getSpaceReservationId();
        if (space != null) {
            sb.append(padding).append("   Space reservation: ").append(space).append('\n');
        }
        TStatusCode status = getStatusCode();
        if (status != null) {
            sb.append(padding).append("   Status:").append(status).append('\n');
        }
        sb.append(padding).append("   History:\n");
        sb.append(getHistory(padding + "   "));
    }
}
Also used : State(org.dcache.srm.scheduler.State) TRetentionPolicy(org.dcache.srm.v2_2.TRetentionPolicy) TAccessLatency(org.dcache.srm.v2_2.TAccessLatency) TStatusCode(org.dcache.srm.v2_2.TStatusCode)

Example 3 with TRetentionPolicy

use of org.dcache.srm.v2_2.TRetentionPolicy 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 4 with TRetentionPolicy

use of org.dcache.srm.v2_2.TRetentionPolicy 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 5 with TRetentionPolicy

use of org.dcache.srm.v2_2.TRetentionPolicy 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)

Aggregations

TAccessLatency (org.dcache.srm.v2_2.TAccessLatency)17 TRetentionPolicy (org.dcache.srm.v2_2.TRetentionPolicy)17 TRetentionPolicyInfo (org.dcache.srm.v2_2.TRetentionPolicyInfo)11 UnsignedLong (org.apache.axis.types.UnsignedLong)9 TReturnStatus (org.dcache.srm.v2_2.TReturnStatus)7 IOException (java.io.IOException)5 ArrayOfString (org.dcache.srm.v2_2.ArrayOfString)5 TStatusCode (org.dcache.srm.v2_2.TStatusCode)5 URI (org.apache.axis.types.URI)4 ArrayOfAnyURI (org.dcache.srm.v2_2.ArrayOfAnyURI)4 PutFileRequest (org.dcache.srm.request.PutFileRequest)3 TAccessPattern (org.dcache.srm.v2_2.TAccessPattern)3 TConnectionType (org.dcache.srm.v2_2.TConnectionType)3 TTransferParameters (org.dcache.srm.v2_2.TTransferParameters)3 URI (java.net.URI)2 SRMException (org.dcache.srm.SRMException)2 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)2 SRMInvalidRequestException (org.dcache.srm.SRMInvalidRequestException)2 SRMNotSupportedException (org.dcache.srm.SRMNotSupportedException)2 CopyRequest (org.dcache.srm.request.CopyRequest)2