Package org.apache.hadoop.hbase.regionserver.wal.HLogSplitter

Examples of org.apache.hadoop.hbase.regionserver.wal.HLogSplitter.EntryBuffers


    Configuration conf = new Configuration();
    HLogSplitter splitter = HLogSplitter.createLogSplitter(
        conf, mock(Path.class), mock(Path.class), mock(Path.class),
        mock(FileSystem.class));

    EntryBuffers sink = splitter.new EntryBuffers(1*1024*1024);
    for (int i = 0; i < 1000; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }
   
    assertTrue(sink.totalBuffered > 0);
    long amountInChunk = sink.totalBuffered;
    // Get a chunk
    RegionEntryBuffer chunk = sink.getChunkToWrite();
    assertEquals(chunk.heapSize(), amountInChunk);
   
    // Make sure it got marked that a thread is "working on this"
    assertTrue(sink.isRegionCurrentlyWriting(TEST_REGION));

    // Insert some more entries
    for (int i = 0; i < 500; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }   
    // Asking for another chunk shouldn't work since the first one
    // is still writing
    assertNull(sink.getChunkToWrite());
   
    // If we say we're done writing the first chunk, then we should be able
    // to get the second
    sink.doneWriting(chunk);
   
    RegionEntryBuffer chunk2 = sink.getChunkToWrite();
    assertNotNull(chunk2);
    assertNotSame(chunk, chunk2);
    long amountInChunk2 = sink.totalBuffered;
    // The second chunk had fewer rows than the first
    assertTrue(amountInChunk2 < amountInChunk);
   
    sink.doneWriting(chunk2);
    assertEquals(0, sink.totalBuffered);
  }
View Full Code Here


    Configuration conf = new Configuration();
    HLogSplitter splitter = HLogSplitter.createLogSplitter(
        conf, mock(Path.class), mock(Path.class), mock(Path.class),
        mock(FileSystem.class));

    EntryBuffers sink = splitter.new EntryBuffers(1*1024*1024);
    for (int i = 0; i < 1000; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }
   
    assertTrue(sink.totalBuffered > 0);
    long amountInChunk = sink.totalBuffered;
    // Get a chunk
    RegionEntryBuffer chunk = sink.getChunkToWrite();
    assertEquals(chunk.heapSize(), amountInChunk);
   
    // Make sure it got marked that a thread is "working on this"
    assertTrue(sink.isRegionCurrentlyWriting(TEST_REGION));

    // Insert some more entries
    for (int i = 0; i < 500; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }   
    // Asking for another chunk shouldn't work since the first one
    // is still writing
    assertNull(sink.getChunkToWrite());
   
    // If we say we're done writing the first chunk, then we should be able
    // to get the second
    sink.doneWriting(chunk);
   
    RegionEntryBuffer chunk2 = sink.getChunkToWrite();
    assertNotNull(chunk2);
    assertNotSame(chunk, chunk2);
    long amountInChunk2 = sink.totalBuffered;
    // The second chunk had fewer rows than the first
    assertTrue(amountInChunk2 < amountInChunk);
   
    sink.doneWriting(chunk2);
    assertEquals(0, sink.totalBuffered);
  }
View Full Code Here

    Configuration conf = new Configuration();
    HLogSplitter splitter = HLogSplitter.createLogSplitter(
        conf, mock(Path.class), mock(Path.class), mock(Path.class),
        mock(FileSystem.class));

    EntryBuffers sink = splitter.new EntryBuffers(1*1024*1024);
    for (int i = 0; i < 1000; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }
   
    assertTrue(sink.totalBuffered > 0);
    long amountInChunk = sink.totalBuffered;
    // Get a chunk
    RegionEntryBuffer chunk = sink.getChunkToWrite();
    assertEquals(chunk.heapSize(), amountInChunk);
   
    // Make sure it got marked that a thread is "working on this"
    assertTrue(sink.isRegionCurrentlyWriting(TEST_REGION));

    // Insert some more entries
    for (int i = 0; i < 500; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }   
    // Asking for another chunk shouldn't work since the first one
    // is still writing
    assertNull(sink.getChunkToWrite());
   
    // If we say we're done writing the first chunk, then we should be able
    // to get the second
    sink.doneWriting(chunk);
   
    RegionEntryBuffer chunk2 = sink.getChunkToWrite();
    assertNotNull(chunk2);
    assertNotSame(chunk, chunk2);
    long amountInChunk2 = sink.totalBuffered;
    // The second chunk had fewer rows than the first
    assertTrue(amountInChunk2 < amountInChunk);
   
    sink.doneWriting(chunk2);
    assertEquals(0, sink.totalBuffered);
  }
View Full Code Here

    RecoveryMode mode = (conf.getBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, false) ?
      RecoveryMode.LOG_REPLAY : RecoveryMode.LOG_SPLITTING);
    HLogSplitter splitter = new HLogSplitter(
      conf, mock(Path.class), mock(FileSystem.class), null, null, mode);

    EntryBuffers sink = splitter.new EntryBuffers(1*1024*1024);
    for (int i = 0; i < 1000; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }

    assertTrue(sink.totalBuffered > 0);
    long amountInChunk = sink.totalBuffered;
    // Get a chunk
    RegionEntryBuffer chunk = sink.getChunkToWrite();
    assertEquals(chunk.heapSize(), amountInChunk);

    // Make sure it got marked that a thread is "working on this"
    assertTrue(sink.isRegionCurrentlyWriting(TEST_REGION));

    // Insert some more entries
    for (int i = 0; i < 500; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }
    // Asking for another chunk shouldn't work since the first one
    // is still writing
    assertNull(sink.getChunkToWrite());

    // If we say we're done writing the first chunk, then we should be able
    // to get the second
    sink.doneWriting(chunk);

    RegionEntryBuffer chunk2 = sink.getChunkToWrite();
    assertNotNull(chunk2);
    assertNotSame(chunk, chunk2);
    long amountInChunk2 = sink.totalBuffered;
    // The second chunk had fewer rows than the first
    assertTrue(amountInChunk2 < amountInChunk);

    sink.doneWriting(chunk2);
    assertEquals(0, sink.totalBuffered);
  }
View Full Code Here

    conf.set(HConstants.RPC_CODEC_CONF_KEY, codecClassName);

    this.numWriterThreads = this.conf.getInt(
      "hbase.region.replica.replication.writer.threads", 3);
    controller = new PipelineController();
    entryBuffers = new EntryBuffers(controller,
      this.conf.getInt("hbase.region.replica.replication.buffersize",
          128*1024*1024));

    // use the regular RPC timeout for replica replication RPC's
    this.operationTimeout = conf.getInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT,
View Full Code Here

    Configuration conf = new Configuration();
    HLogSplitter splitter = HLogSplitter.createLogSplitter(
        conf, mock(Path.class), mock(Path.class), mock(Path.class),
        mock(FileSystem.class));

    EntryBuffers sink = splitter.new EntryBuffers(1*1024*1024);
    for (int i = 0; i < 1000; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }
   
    assertTrue(sink.totalBuffered > 0);
    long amountInChunk = sink.totalBuffered;
    // Get a chunk
    RegionEntryBuffer chunk = sink.getChunkToWrite();
    assertEquals(chunk.heapSize(), amountInChunk);
   
    // Make sure it got marked that a thread is "working on this"
    assertTrue(sink.isRegionCurrentlyWriting(TEST_REGION));

    // Insert some more entries
    for (int i = 0; i < 500; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }   
    // Asking for another chunk shouldn't work since the first one
    // is still writing
    assertNull(sink.getChunkToWrite());
   
    // If we say we're done writing the first chunk, then we should be able
    // to get the second
    sink.doneWriting(chunk);
   
    RegionEntryBuffer chunk2 = sink.getChunkToWrite();
    assertNotNull(chunk2);
    assertNotSame(chunk, chunk2);
    long amountInChunk2 = sink.totalBuffered;
    // The second chunk had fewer rows than the first
    assertTrue(amountInChunk2 < amountInChunk);
   
    sink.doneWriting(chunk2);
    assertEquals(0, sink.totalBuffered);
  }
View Full Code Here

  public void testEntrySink() throws Exception {
    Configuration conf = new Configuration();
    HLogSplitter splitter = new HLogSplitter(
      conf, mock(Path.class), mock(FileSystem.class), null, null);

    EntryBuffers sink = splitter.new EntryBuffers(1*1024*1024);
    for (int i = 0; i < 1000; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }
   
    assertTrue(sink.totalBuffered > 0);
    long amountInChunk = sink.totalBuffered;
    // Get a chunk
    RegionEntryBuffer chunk = sink.getChunkToWrite();
    assertEquals(chunk.heapSize(), amountInChunk);
   
    // Make sure it got marked that a thread is "working on this"
    assertTrue(sink.isRegionCurrentlyWriting(TEST_REGION));

    // Insert some more entries
    for (int i = 0; i < 500; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }   
    // Asking for another chunk shouldn't work since the first one
    // is still writing
    assertNull(sink.getChunkToWrite());
   
    // If we say we're done writing the first chunk, then we should be able
    // to get the second
    sink.doneWriting(chunk);
   
    RegionEntryBuffer chunk2 = sink.getChunkToWrite();
    assertNotNull(chunk2);
    assertNotSame(chunk, chunk2);
    long amountInChunk2 = sink.totalBuffered;
    // The second chunk had fewer rows than the first
    assertTrue(amountInChunk2 < amountInChunk);
   
    sink.doneWriting(chunk2);
    assertEquals(0, sink.totalBuffered);
  }
View Full Code Here

    RecoveryMode mode = (conf.getBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, false) ?
      RecoveryMode.LOG_REPLAY : RecoveryMode.LOG_SPLITTING);
    HLogSplitter splitter = new HLogSplitter(
      conf, mock(Path.class), mock(FileSystem.class), null, null, mode);

    EntryBuffers sink = splitter.new EntryBuffers(1*1024*1024);
    for (int i = 0; i < 1000; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }
   
    assertTrue(sink.totalBuffered > 0);
    long amountInChunk = sink.totalBuffered;
    // Get a chunk
    RegionEntryBuffer chunk = sink.getChunkToWrite();
    assertEquals(chunk.heapSize(), amountInChunk);
   
    // Make sure it got marked that a thread is "working on this"
    assertTrue(sink.isRegionCurrentlyWriting(TEST_REGION));

    // Insert some more entries
    for (int i = 0; i < 500; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }   
    // Asking for another chunk shouldn't work since the first one
    // is still writing
    assertNull(sink.getChunkToWrite());
   
    // If we say we're done writing the first chunk, then we should be able
    // to get the second
    sink.doneWriting(chunk);
   
    RegionEntryBuffer chunk2 = sink.getChunkToWrite();
    assertNotNull(chunk2);
    assertNotSame(chunk, chunk2);
    long amountInChunk2 = sink.totalBuffered;
    // The second chunk had fewer rows than the first
    assertTrue(amountInChunk2 < amountInChunk);
   
    sink.doneWriting(chunk2);
    assertEquals(0, sink.totalBuffered);
  }
View Full Code Here

  public void testEntrySink() throws Exception {
    Configuration conf = new Configuration();
    RecoveryMode mode = (conf.getBoolean(HConstants.DISTRIBUTED_LOG_REPLAY_KEY, false) ?
      RecoveryMode.LOG_REPLAY : RecoveryMode.LOG_SPLITTING);

    EntryBuffers sink = new EntryBuffers(new PipelineController(), 1*1024*1024);
    for (int i = 0; i < 1000; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }

    assertTrue(sink.totalBuffered > 0);
    long amountInChunk = sink.totalBuffered;
    // Get a chunk
    RegionEntryBuffer chunk = sink.getChunkToWrite();
    assertEquals(chunk.heapSize(), amountInChunk);

    // Make sure it got marked that a thread is "working on this"
    assertTrue(sink.isRegionCurrentlyWriting(TEST_REGION));

    // Insert some more entries
    for (int i = 0; i < 500; i++) {
      HLog.Entry entry = createTestLogEntry(i);
      sink.appendEntry(entry);
    }
    // Asking for another chunk shouldn't work since the first one
    // is still writing
    assertNull(sink.getChunkToWrite());

    // If we say we're done writing the first chunk, then we should be able
    // to get the second
    sink.doneWriting(chunk);

    RegionEntryBuffer chunk2 = sink.getChunkToWrite();
    assertNotNull(chunk2);
    assertNotSame(chunk, chunk2);
    long amountInChunk2 = sink.totalBuffered;
    // The second chunk had fewer rows than the first
    assertTrue(amountInChunk2 < amountInChunk);

    sink.doneWriting(chunk2);
    assertEquals(0, sink.totalBuffered);
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.wal.HLogSplitter.EntryBuffers

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.