예제 #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 PoolIoFileMessage(String pool, ProtocolInfo protocolInfo, FileAttributes fileAttributes) {
    super(pool);

    checkNotNull(fileAttributes);
    checkArgument(fileAttributes.isDefined(EnumSet.of(STORAGEINFO, PNFSID)));

    _fileAttributes = fileAttributes;
    _protocolInfo = protocolInfo;
  }
예제 #3
0
 public PoolAcceptFileMessage(
     String pool, ProtocolInfo protocolInfo, FileAttributes fileAttributes) {
   super(pool, protocolInfo, fileAttributes);
   checkArgument(fileAttributes.isDefined(EnumSet.of(ACCESS_LATENCY, RETENTION_POLICY)));
 }