コード例 #1
0
 /**
  * Extracts the StorageInfo stored in the FileAttributes.
  *
  * <p>Initializes legacy fields that used to be stored in StorageInfo, but are now stored in
  * FileAttributes.
  *
  * <p>Should only be used when backwards compatibility must be maintained.
  */
 public static StorageInfo extractFrom(FileAttributes attributes) {
   StorageInfo info = attributes.getStorageInfo();
   if (attributes.isDefined(FileAttribute.SIZE)) {
     info.setLegacySize(attributes.getSize());
   }
   if (attributes.isDefined(FileAttribute.ACCESS_LATENCY)) {
     info.setLegacyAccessLatency(attributes.getAccessLatency());
   }
   if (attributes.isDefined(FileAttribute.RETENTION_POLICY)) {
     info.setLegacyRetentionPolicy(attributes.getRetentionPolicy());
   }
   if (attributes.isDefined(FileAttribute.FLAGS)) {
     for (Map.Entry<String, String> entry : attributes.getFlags().entrySet()) {
       info.setKey(entry.getKey(), entry.getValue());
     }
   }
   if (attributes.isDefined(FileAttribute.CHECKSUM)) {
     info.setKey("flag-c", Joiner.on(',').join(attributes.getChecksums()));
   }
   if (attributes.isDefined(FileAttribute.OWNER)) {
     info.setKey("uid", Integer.toString(attributes.getOwner()));
   }
   if (attributes.isDefined(FileAttribute.OWNER_GROUP)) {
     info.setKey("gid", Integer.toString(attributes.getGroup()));
   }
   return info;
 }
コード例 #2
0
 public StageRequestImpl(NearlineStorage storage, FileAttributes fileAttributes)
     throws CacheException {
   super(storage);
   PnfsId pnfsId = fileAttributes.getPnfsId();
   infoMsg = new StorageInfoMessage(cellAddress.toString(), pnfsId, true);
   infoMsg.setStorageInfo(fileAttributes.getStorageInfo());
   infoMsg.setFileSize(fileAttributes.getSize());
   descriptor =
       repository.createEntry(
           fileAttributes,
           ReplicaState.FROM_STORE,
           ReplicaState.CACHED,
           Collections.emptyList(),
           EnumSet.noneOf(Repository.OpenFlags.class));
   LOGGER.debug("Stage request created for {}.", pnfsId);
 }
コード例 #3
0
 private FileAttributes getFileAttributesForNotification(Set<URI> uris) throws CacheException {
   FileAttributes fileAttributes = descriptor.getFileAttributes();
   StorageInfo storageInfo = fileAttributes.getStorageInfo().clone();
   for (URI uri : uris) {
     try {
       HsmLocationExtractorFactory.validate(uri);
       storageInfo.addLocation(uri);
       storageInfo.isSetAddLocation(true);
     } catch (IllegalArgumentException e) {
       throw new CacheException(2, e.getMessage(), e);
     }
   }
   FileAttributes fileAttributesForNotification = new FileAttributes();
   fileAttributesForNotification.setAccessLatency(fileAttributes.getAccessLatency());
   fileAttributesForNotification.setRetentionPolicy(fileAttributes.getRetentionPolicy());
   fileAttributesForNotification.setStorageInfo(storageInfo);
   fileAttributesForNotification.setSize(fileAttributes.getSize());
   return fileAttributesForNotification;
 }