Java Code Examples for org.apache.hadoop.util.GSet#put()

The following examples show how to use org.apache.hadoop.util.GSet#put() . 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: GSetGenerator.java    From NNAnalytics with Apache License 2.0 5 votes vote down vote up
public void generateGSet(
    GSet<INode, INodeWithAdditionalFields> newGSet,
    INodeDirectory parent,
    int filesPerDir,
    int numOfDirsPerDepth,
    short depth)
    throws IOException {
  if (depth == 0) {
    return;
  }
  List<INodeDirectory> childrenDirs = new ArrayList<>();
  for (int j = 1; j <= numOfDirsPerDepth; j++) {
    long mAndAtime = now - rand.nextLong(TimeUnit.DAYS.toMillis(365)); // 1 year
    int dirId = ID++;
    INodeDirectory dir =
        new INodeDirectory(dirId, ("dir" + j).getBytes(CHARSET), status, mAndAtime);
    boolean childAdded = parent.addChild(dir);
    if (rand.nextBoolean()) {
      dir.setQuota(BlockStoragePolicySuite.createDefaultSuite(), 9000L, 9999999999L, null);
      dir.getDirectoryWithQuotaFeature()
          .setSpaceConsumed(rand.nextLong(5000L), rand.nextLong(9999999991L), null);
    }
    if (childAdded) {
      generateFilesForDirectory(gset, dir, filesPerDir);
      dir.setParent(parent);
      INodeWithAdditionalFields booted = newGSet.put(dir);
      if (booted == null) {
        DIRS_MADE++;
      }
    }
    childrenDirs.add(dir);
  }
  for (INodeDirectory childrenDir : childrenDirs) {
    generateGSet(newGSet, childrenDir, filesPerDir, numOfDirsPerDepth, (short) (depth - 1));
  }
}
 
Example 2
Source File: GSetGenerator.java    From NNAnalytics with Apache License 2.0 5 votes vote down vote up
public void generateGSet(
    GSet<INode, INodeWithAdditionalFields> newGSet,
    INodeDirectory parent,
    int filesPerDir,
    int numOfDirsPerDepth,
    short depth)
    throws IOException {
  if (depth == 0) {
    return;
  }
  List<INodeDirectory> childrenDirs = new ArrayList<>();
  for (int j = 1; j <= numOfDirsPerDepth; j++) {
    long mAndAtime = now - rand.nextLong(TimeUnit.DAYS.toMillis(365)); // 1 year
    int dirId = ID++;
    INodeDirectory dir =
        new INodeDirectory(dirId, ("dir" + j).getBytes(CHARSET), status, mAndAtime);
    boolean childAdded = parent.addChild(dir);
    if (rand.nextBoolean()) {
      dir.setQuota(BlockStoragePolicySuite.createDefaultSuite(), 9000L, 9999999999L, null);
      dir.getDirectoryWithQuotaFeature()
          .setSpaceConsumed(rand.nextLong(5000L), rand.nextLong(9999999991L), null);
    }
    if (childAdded) {
      generateFilesForDirectory(gset, dir, filesPerDir);
      dir.setParent(parent);
      INodeWithAdditionalFields booted = newGSet.put(dir);
      if (booted == null) {
        DIRS_MADE++;
      }
    }
    childrenDirs.add(dir);
  }
  for (INodeDirectory childrenDir : childrenDirs) {
    generateGSet(newGSet, childrenDir, filesPerDir, numOfDirsPerDepth, (short) (depth - 1));
  }
}
 
Example 3
Source File: GSetGenerator.java    From NNAnalytics with Apache License 2.0 5 votes vote down vote up
public void generateGSet(
    GSet<INode, INodeWithAdditionalFields> newGSet,
    INodeDirectory parent,
    int filesPerDir,
    int numOfDirsPerDepth,
    short depth)
    throws IOException {
  if (depth == 0) {
    return;
  }
  List<INodeDirectory> childrenDirs = new ArrayList<>();
  for (int j = 1; j <= numOfDirsPerDepth; j++) {
    long mAndAtime = now - rand.nextLong(TimeUnit.DAYS.toMillis(365)); // 1 year
    int dirId = ID++;
    INodeDirectory dir =
        new INodeDirectory(dirId, ("dir" + j).getBytes(CHARSET), status, mAndAtime);
    boolean childAdded = parent.addChild(dir);
    if (rand.nextBoolean()) {
      dir.setQuota(BlockStoragePolicySuite.createDefaultSuite(), 9000L, 9999999999L, null);
      dir.getDirectoryWithQuotaFeature()
          .setSpaceConsumed(rand.nextLong(5000L), rand.nextLong(9999999991L), null);
    }
    if (childAdded) {
      generateFilesForDirectory(gset, dir, filesPerDir);
      dir.setParent(parent);
      INodeWithAdditionalFields booted = newGSet.put(dir);
      if (booted == null) {
        DIRS_MADE++;
      }
    }
    childrenDirs.add(dir);
  }
  for (INodeDirectory childrenDir : childrenDirs) {
    generateGSet(newGSet, childrenDir, filesPerDir, numOfDirsPerDepth, (short) (depth - 1));
  }
}
 
Example 4
Source File: GSetGenerator.java    From NNAnalytics with Apache License 2.0 5 votes vote down vote up
public void generateGSet(
    GSet<INode, INodeWithAdditionalFields> newGSet,
    INodeDirectory parent,
    int filesPerDir,
    int numOfDirsPerDepth,
    short depth)
    throws IOException {
  if (depth == 0) {
    return;
  }
  List<INodeDirectory> childrenDirs = new ArrayList<>();
  for (int j = 1; j <= numOfDirsPerDepth; j++) {
    long mAndAtime = now - rand.nextLong(TimeUnit.DAYS.toMillis(365)); // 1 year
    int dirId = ID++;
    INodeDirectory dir =
        new INodeDirectory(dirId, ("dir" + j).getBytes(CHARSET), status, mAndAtime);
    boolean childAdded = parent.addChild(dir);
    if (rand.nextBoolean()) {
      dir.setQuota(BlockStoragePolicySuite.createDefaultSuite(), 9000L, 9999999999L, null);
      dir.getDirectoryWithQuotaFeature()
          .setSpaceConsumed(rand.nextLong(5000L), rand.nextLong(9999999991L), null);
    }
    if (childAdded) {
      generateFilesForDirectory(gset, dir, filesPerDir);
      dir.setParent(parent);
      INodeWithAdditionalFields booted = newGSet.put(dir);
      if (booted == null) {
        DIRS_MADE++;
      }
    }
    childrenDirs.add(dir);
  }
  for (INodeDirectory childrenDir : childrenDirs) {
    generateGSet(newGSet, childrenDir, filesPerDir, numOfDirsPerDepth, (short) (depth - 1));
  }
}
 
Example 5
Source File: GSetGenerator.java    From NNAnalytics with Apache License 2.0 5 votes vote down vote up
public void generateGSet(
    GSet<INode, INodeWithAdditionalFields> newGSet,
    INodeDirectory parent,
    int filesPerDir,
    int numOfDirsPerDepth,
    short depth)
    throws IOException {
  if (depth == 0) {
    return;
  }
  List<INodeDirectory> childrenDirs = new ArrayList<>();
  for (int j = 1; j <= numOfDirsPerDepth; j++) {
    long mAndAtime = now - rand.nextLong(TimeUnit.DAYS.toMillis(365)); // 1 year
    int dirId = ID++;
    INodeDirectory dir =
        new INodeDirectory(dirId, ("dir" + j).getBytes(CHARSET), status, mAndAtime);
    if (rand.nextBoolean()) {
      dir.setQuota(BlockStoragePolicySuite.createDefaultSuite(), 9000L, 9999999999L, null);
      dir.getDirectoryWithQuotaFeature()
          .setSpaceConsumed(rand.nextLong(5000L), rand.nextLong(9999999991L), null);
    }
    boolean childAdded = parent.addChild(dir);
    if (childAdded) {
      generateFilesForDirectory(gset, dir, filesPerDir);
      dir.setParent(parent);
      INodeWithAdditionalFields booted = newGSet.put(dir);
      if (booted == null) {
        DIRS_MADE++;
      }
    }
    childrenDirs.add(dir);
  }
  for (INodeDirectory childrenDir : childrenDirs) {
    generateGSet(newGSet, childrenDir, filesPerDir, numOfDirsPerDepth, (short) (depth - 1));
  }
}
 
Example 6
Source File: INodeMap.java    From hadoop with Apache License 2.0 5 votes vote down vote up
static INodeMap newInstance(INodeDirectory rootDir) {
  // Compute the map capacity by allocating 1% of total memory
  int capacity = LightWeightGSet.computeCapacity(1, "INodeMap");
  GSet<INode, INodeWithAdditionalFields> map
      = new LightWeightGSet<INode, INodeWithAdditionalFields>(capacity);
  map.put(rootDir);
  return new INodeMap(map);
}
 
Example 7
Source File: INodeMap.java    From big-c with Apache License 2.0 5 votes vote down vote up
static INodeMap newInstance(INodeDirectory rootDir) {
  // Compute the map capacity by allocating 1% of total memory
  int capacity = LightWeightGSet.computeCapacity(1, "INodeMap");
  GSet<INode, INodeWithAdditionalFields> map
      = new LightWeightGSet<INode, INodeWithAdditionalFields>(capacity);
  map.put(rootDir);
  return new INodeMap(map);
}