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;
}
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 + " "));
}
}
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());
}
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);
}
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);
}
Aggregations