Java Code Examples for org.apache.hadoop.fs.permission.FsPermission#write()

The following examples show how to use org.apache.hadoop.fs.permission.FsPermission#write() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FSImageSerialization.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static void writeCachePoolInfo(DataOutputStream out, CachePoolInfo info)
    throws IOException {
  writeString(info.getPoolName(), out);

  final String ownerName = info.getOwnerName();
  final String groupName = info.getGroupName();
  final Long limit = info.getLimit();
  final FsPermission mode = info.getMode();
  final Long maxRelativeExpiry = info.getMaxRelativeExpiryMs();

  boolean hasOwner, hasGroup, hasMode, hasLimit, hasMaxRelativeExpiry;
  hasOwner = ownerName != null;
  hasGroup = groupName != null;
  hasMode = mode != null;
  hasLimit = limit != null;
  hasMaxRelativeExpiry = maxRelativeExpiry != null;

  int flags =
      (hasOwner ? 0x1 : 0) |
      (hasGroup ? 0x2 : 0) |
      (hasMode  ? 0x4 : 0) |
      (hasLimit ? 0x8 : 0) |
      (hasMaxRelativeExpiry ? 0x10 : 0);

  writeInt(flags, out);

  if (hasOwner) {
    writeString(ownerName, out);
  }
  if (hasGroup) {
    writeString(groupName, out);
  }
  if (hasMode) {
    mode.write(out);
  }
  if (hasLimit) {
    writeLong(limit, out);
  }
  if (hasMaxRelativeExpiry) {
    writeLong(maxRelativeExpiry, out);
  }
}
 
Example 2
Source File: FSImageSerialization.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static void writeCachePoolInfo(DataOutputStream out, CachePoolInfo info)
    throws IOException {
  writeString(info.getPoolName(), out);

  final String ownerName = info.getOwnerName();
  final String groupName = info.getGroupName();
  final Long limit = info.getLimit();
  final FsPermission mode = info.getMode();
  final Long maxRelativeExpiry = info.getMaxRelativeExpiryMs();

  boolean hasOwner, hasGroup, hasMode, hasLimit, hasMaxRelativeExpiry;
  hasOwner = ownerName != null;
  hasGroup = groupName != null;
  hasMode = mode != null;
  hasLimit = limit != null;
  hasMaxRelativeExpiry = maxRelativeExpiry != null;

  int flags =
      (hasOwner ? 0x1 : 0) |
      (hasGroup ? 0x2 : 0) |
      (hasMode  ? 0x4 : 0) |
      (hasLimit ? 0x8 : 0) |
      (hasMaxRelativeExpiry ? 0x10 : 0);

  writeInt(flags, out);

  if (hasOwner) {
    writeString(ownerName, out);
  }
  if (hasGroup) {
    writeString(groupName, out);
  }
  if (hasMode) {
    mode.write(out);
  }
  if (hasLimit) {
    writeLong(limit, out);
  }
  if (hasMaxRelativeExpiry) {
    writeLong(maxRelativeExpiry, out);
  }
}