Java Code Examples for org.apache.hadoop.hdfs.server.common.GenerationStamp#GRANDFATHER_GENERATION_STAMP

The following examples show how to use org.apache.hadoop.hdfs.server.common.GenerationStamp#GRANDFATHER_GENERATION_STAMP . 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: FsDatasetUtil.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Find the meta-file for the specified block file
 * and then return the generation stamp from the name of the meta-file.
 */
static long getGenerationStampFromFile(File[] listdir, File blockFile) {
  String blockName = blockFile.getName();
  for (int j = 0; j < listdir.length; j++) {
    String path = listdir[j].getName();
    if (!path.startsWith(blockName)) {
      continue;
    }
    if (blockFile == listdir[j]) {
      continue;
    }
    return Block.getGenerationStamp(listdir[j].getName());
  }
  FsDatasetImpl.LOG.warn("Block " + blockFile + " does not have a metafile!");
  return GenerationStamp.GRANDFATHER_GENERATION_STAMP;
}
 
Example 2
Source File: TestGetBlocks.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testBlockKey() {
  Map<Block, Long> map = new HashMap<Block, Long>();
  final Random RAN = new Random();
  final long seed = RAN.nextLong();
  System.out.println("seed=" + seed);
  RAN.setSeed(seed);

  long[] blkids = new long[10];
  for (int i = 0; i < blkids.length; i++) {
    blkids[i] = 1000L + RAN.nextInt(100000);
    map.put(new Block(blkids[i], 0, blkids[i]), blkids[i]);
  }
  System.out.println("map=" + map.toString().replace(",", "\n  "));

  for (int i = 0; i < blkids.length; i++) {
    Block b = new Block(blkids[i], 0,
        GenerationStamp.GRANDFATHER_GENERATION_STAMP);
    Long v = map.get(b);
    System.out.println(b + " => " + v);
    assertEquals(blkids[i], v.longValue());
  }
}
 
Example 3
Source File: FsDatasetUtil.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Find the meta-file for the specified block file
 * and then return the generation stamp from the name of the meta-file.
 */
static long getGenerationStampFromFile(File[] listdir, File blockFile) {
  String blockName = blockFile.getName();
  for (int j = 0; j < listdir.length; j++) {
    String path = listdir[j].getName();
    if (!path.startsWith(blockName)) {
      continue;
    }
    if (blockFile == listdir[j]) {
      continue;
    }
    return Block.getGenerationStamp(listdir[j].getName());
  }
  FsDatasetImpl.LOG.warn("Block " + blockFile + " does not have a metafile!");
  return GenerationStamp.GRANDFATHER_GENERATION_STAMP;
}
 
Example 4
Source File: TestGetBlocks.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testBlockKey() {
  Map<Block, Long> map = new HashMap<Block, Long>();
  final Random RAN = new Random();
  final long seed = RAN.nextLong();
  System.out.println("seed=" + seed);
  RAN.setSeed(seed);

  long[] blkids = new long[10];
  for (int i = 0; i < blkids.length; i++) {
    blkids[i] = 1000L + RAN.nextInt(100000);
    map.put(new Block(blkids[i], 0, blkids[i]), blkids[i]);
  }
  System.out.println("map=" + map.toString().replace(",", "\n  "));

  for (int i = 0; i < blkids.length; i++) {
    Block b = new Block(blkids[i], 0,
        GenerationStamp.GRANDFATHER_GENERATION_STAMP);
    Long v = map.get(b);
    System.out.println(b + " => " + v);
    assertEquals(blkids[i], v.longValue());
  }
}
 
Example 5
Source File: BlockIdManager.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public void clear() {
  generationStampV1.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP);
  generationStampV2.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP);
  getBlockIdGenerator().setCurrentValue(SequentialBlockIdGenerator
    .LAST_RESERVED_BLOCK_ID);
  generationStampV1Limit = GenerationStamp.GRANDFATHER_GENERATION_STAMP;
}
 
Example 6
Source File: BlockIdManager.java    From big-c with Apache License 2.0 5 votes vote down vote up
public void clear() {
  generationStampV1.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP);
  generationStampV2.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP);
  getBlockIdGenerator().setCurrentValue(SequentialBlockIdGenerator
    .LAST_RESERVED_BLOCK_ID);
  generationStampV1Limit = GenerationStamp.GRANDFATHER_GENERATION_STAMP;
}
 
Example 7
Source File: Block.java    From hadoop with Apache License 2.0 4 votes vote down vote up
/**
 * Get generation stamp from the name of the metafile name
 */
public static long getGenerationStamp(String metaFile) {
  Matcher m = metaFilePattern.matcher(metaFile);
  return m.matches() ? Long.parseLong(m.group(2))
      : GenerationStamp.GRANDFATHER_GENERATION_STAMP;
}
 
Example 8
Source File: Block.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public Block(final long blkid) {
  this(blkid, 0, GenerationStamp.GRANDFATHER_GENERATION_STAMP);
}
 
Example 9
Source File: BlockIdManager.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public BlockIdManager(BlockManager blockManager) {
  this.generationStampV1Limit = GenerationStamp.GRANDFATHER_GENERATION_STAMP;
  this.blockIdGenerator = new SequentialBlockIdGenerator(blockManager);
}
 
Example 10
Source File: DirectoryScanner.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public long getGenStamp() {
  return metaSuffix != null ? Block.getGenerationStamp(
      getMetaFile().getName()) : 
        GenerationStamp.GRANDFATHER_GENERATION_STAMP;
}
 
Example 11
Source File: Block.java    From big-c with Apache License 2.0 4 votes vote down vote up
/**
 * Get generation stamp from the name of the metafile name
 */
public static long getGenerationStamp(String metaFile) {
  Matcher m = metaFilePattern.matcher(metaFile);
  return m.matches() ? Long.parseLong(m.group(2))
      : GenerationStamp.GRANDFATHER_GENERATION_STAMP;
}
 
Example 12
Source File: Block.java    From big-c with Apache License 2.0 4 votes vote down vote up
public Block(final long blkid) {
  this(blkid, 0, GenerationStamp.GRANDFATHER_GENERATION_STAMP);
}
 
Example 13
Source File: BlockIdManager.java    From big-c with Apache License 2.0 4 votes vote down vote up
public BlockIdManager(BlockManager blockManager) {
  this.generationStampV1Limit = GenerationStamp.GRANDFATHER_GENERATION_STAMP;
  this.blockIdGenerator = new SequentialBlockIdGenerator(blockManager);
}
 
Example 14
Source File: DirectoryScanner.java    From big-c with Apache License 2.0 4 votes vote down vote up
public long getGenStamp() {
  return metaSuffix != null ? Block.getGenerationStamp(
      getMetaFile().getName()) : 
        GenerationStamp.GRANDFATHER_GENERATION_STAMP;
}