Java Code Examples for org.apache.hadoop.hbase.HConstants#DEFAULT_CLUSTER_ID

The following examples show how to use org.apache.hadoop.hbase.HConstants#DEFAULT_CLUSTER_ID . 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: TestWALSplit.java    From hbase with Apache License 2.0 6 votes vote down vote up
private static void appendCompactionEvent(Writer w, RegionInfo hri, String[] inputs,
    String output) throws IOException {
  WALProtos.CompactionDescriptor.Builder desc = WALProtos.CompactionDescriptor.newBuilder();
  desc.setTableName(ByteString.copyFrom(hri.getTable().toBytes()))
      .setEncodedRegionName(ByteString.copyFrom(hri.getEncodedNameAsBytes()))
      .setRegionName(ByteString.copyFrom(hri.getRegionName()))
      .setFamilyName(ByteString.copyFrom(FAMILY))
      .setStoreHomeDir(hri.getEncodedName() + "/" + Bytes.toString(FAMILY))
      .addAllCompactionInput(Arrays.asList(inputs))
      .addCompactionOutput(output);

  WALEdit edit = WALEdit.createCompaction(hri, desc.build());
  WALKeyImpl key = new WALKeyImpl(hri.getEncodedNameAsBytes(), TABLE_NAME, 1,
      EnvironmentEdgeManager.currentTime(), HConstants.DEFAULT_CLUSTER_ID);
  w.append(new Entry(key, edit));
  w.sync(false);
}
 
Example 2
Source File: TestReplicationSource.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Sanity check that we can move logs around while we are reading
 * from them. Should this test fail, ReplicationSource would have a hard
 * time reading logs that are being archived.
 */
@Test
public void testLogMoving() throws Exception{
  Path logPath = new Path(logDir, "log");
  if (!FS.exists(logDir)) FS.mkdirs(logDir);
  if (!FS.exists(oldLogDir)) FS.mkdirs(oldLogDir);
  WALProvider.Writer writer = WALFactory.createWALWriter(FS, logPath,
      TEST_UTIL.getConfiguration());
  for(int i = 0; i < 3; i++) {
    byte[] b = Bytes.toBytes(Integer.toString(i));
    KeyValue kv = new KeyValue(b,b,b);
    WALEdit edit = new WALEdit();
    edit.add(kv);
    WALKeyImpl key = new WALKeyImpl(b, TableName.valueOf(b), 0, 0,
        HConstants.DEFAULT_CLUSTER_ID);
    writer.append(new WAL.Entry(key, edit));
    writer.sync(false);
  }
  writer.close();

  WAL.Reader reader = WALFactory.createReader(FS, logPath, TEST_UTIL.getConfiguration());
  WAL.Entry entry = reader.next();
  assertNotNull(entry);

  Path oldLogPath = new Path(oldLogDir, "log");
  FS.rename(logPath, oldLogPath);

  entry = reader.next();
  assertNotNull(entry);

  entry = reader.next();
  entry = reader.next();

  assertNull(entry);
  reader.close();
}
 
Example 3
Source File: TestWALMethods.java    From hbase with Apache License 2.0 5 votes vote down vote up
private WAL.Entry createTestLogEntry(int i) {
  long seq = i;
  long now = i * 1000;

  WALEdit edit = new WALEdit();
  edit.add(KeyValueTestUtil.create("row", "fam", "qual", 1234, "val"));
  WALKeyImpl key = new WALKeyImpl(TEST_REGION, TEST_TABLE, seq, now,
      HConstants.DEFAULT_CLUSTER_ID);
  WAL.Entry entry = new WAL.Entry(key, edit);
  return entry;
}
 
Example 4
Source File: TestWALSplit.java    From hbase with Apache License 2.0 5 votes vote down vote up
private Path createRecoveredEditsPathForRegion() throws IOException {
  byte[] encoded = RegionInfoBuilder.FIRST_META_REGIONINFO.getEncodedNameAsBytes();
  long now = System.currentTimeMillis();
  Entry entry = new Entry(
      new WALKeyImpl(encoded, TableName.META_TABLE_NAME, 1, now, HConstants.DEFAULT_CLUSTER_ID),
      new WALEdit());
  Path p = WALSplitUtil
      .getRegionSplitEditsPath(TableName.META_TABLE_NAME, encoded, 1, FILENAME_BEING_SPLIT,
          TMPDIRNAME, conf);
  return p;
}
 
Example 5
Source File: TestWALSplit.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static void appendRegionEvent(Writer w, String region) throws IOException {
  WALProtos.RegionEventDescriptor regionOpenDesc = ProtobufUtil.toRegionEventDescriptor(
      WALProtos.RegionEventDescriptor.EventType.REGION_OPEN,
      TABLE_NAME.toBytes(),
      Bytes.toBytes(region),
      Bytes.toBytes(String.valueOf(region.hashCode())),
      1,
      ServerName.parseServerName("ServerName:9099"), ImmutableMap.<byte[], List<Path>>of());
  final long time = EnvironmentEdgeManager.currentTime();
  final WALKeyImpl walKey = new WALKeyImpl(Bytes.toBytes(region), TABLE_NAME, 1, time,
      HConstants.DEFAULT_CLUSTER_ID);
  WALEdit we = WALEdit.createRegionEventWALEdit(Bytes.toBytes(region), regionOpenDesc);
  w.append(new Entry(walKey, we));
  w.sync(false);
}
 
Example 6
Source File: TestWALSplit.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static Entry createTestEntry(
    TableName table, byte[] region,
    byte[] row, byte[] family, byte[] qualifier,
    byte[] value, long seq) {
  long time = System.nanoTime();

  seq++;
  final KeyValue cell = new KeyValue(row, family, qualifier, time, KeyValue.Type.Put, value);
  WALEdit edit = new WALEdit();
  edit.add(cell);
  return new Entry(new WALKeyImpl(region, table, seq, time,
      HConstants.DEFAULT_CLUSTER_ID), edit);
}
 
Example 7
Source File: ProtobufLogTestHelper.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static WAL.Entry generateEdit(int i, RegionInfo hri, TableName tableName, byte[] row,
    int columnCount, long timestamp, MultiVersionConcurrencyControl mvcc) {
  WALKeyImpl key = new WALKeyImpl(hri.getEncodedNameAsBytes(), tableName, i, timestamp,
      HConstants.DEFAULT_CLUSTER_ID, mvcc);
  WALEdit edit = new WALEdit();
  int prefix = i;
  IntStream.range(0, columnCount).mapToObj(j -> toValue(prefix, j))
      .map(value -> new KeyValue(row, row, row, timestamp, value)).forEachOrdered(edit::add);
  return new WAL.Entry(key, edit);
}
 
Example 8
Source File: WALKeyImpl.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * @return the cluster id on which the change has originated. It there is no such cluster, it
 *         returns DEFAULT_CLUSTER_ID (cases where replication is not enabled)
 */
@Override
public UUID getOriginatingClusterId(){
  return clusterIds.isEmpty()? HConstants.DEFAULT_CLUSTER_ID: clusterIds.get(0);
}
 
Example 9
Source File: THLogKey.java    From hbase-secondary-index with GNU General Public License v3.0 4 votes vote down vote up
public THLogKey(final byte[] regionName, final byte[] tablename, final long logSeqNum, final long now,
        final TrxOp op, final long transactionId) {
    super(regionName, tablename, logSeqNum, now, HConstants.DEFAULT_CLUSTER_ID);
    this.transactionOp = op.opCode;
    this.transactionId = transactionId;
}