Пример #1
0
  private HLog.Entry createTestLogEntry(int i) {
    long seq = i;
    long now = i * 1000;

    WALEdit edit = new WALEdit();
    edit.add(KeyValueTestUtil.create("row", "fam", "qual", 1234, "val"));
    HLogKey key = new HLogKey(TEST_REGION, TEST_TABLE, seq, now, HConstants.DEFAULT_CLUSTER_ID);
    HLog.Entry entry = new HLog.Entry(key, edit);
    return entry;
  }
Пример #2
0
 private void addFamilyMapToWALEdit(Map<byte[], List<Cell>> familyMap, WALEdit walEdit) {
   for (List<Cell> edits : familyMap.values()) {
     for (Cell cell : edits) {
       KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
       walEdit.add(kv);
     }
   }
 }
Пример #3
0
 @Override
 public void run() {
   this.log.info(getName() + " started");
   final AtomicLong sequenceId = new AtomicLong(1);
   try {
     for (int i = 0; i < this.count; i++) {
       long now = System.currentTimeMillis();
       // Roll every ten edits
       if (i % 10 == 0) {
         this.wal.rollWriter();
       }
       WALEdit edit = new WALEdit();
       byte[] bytes = Bytes.toBytes(i);
       edit.add(new KeyValue(bytes, bytes, bytes, now, EMPTY_1K_ARRAY));
       final HRegionInfo hri = HRegionInfo.FIRST_META_REGIONINFO;
       final FSTableDescriptors fts = new FSTableDescriptors(TEST_UTIL.getConfiguration());
       final HTableDescriptor htd = fts.get(TableName.META_TABLE_NAME);
       final long txid =
           wal.append(
               htd,
               hri,
               new WALKey(hri.getEncodedNameAsBytes(), TableName.META_TABLE_NAME, now),
               edit,
               sequenceId,
               true,
               null);
       wal.sync(txid);
     }
     String msg = getName() + " finished";
     if (isException()) this.log.info(msg, getException());
     else this.log.info(msg);
   } catch (Exception e) {
     this.e = e;
     log.info("Caught exception from Appender:" + getName(), e);
   } finally {
     // Call sync on our log.else threads just hang out.
     try {
       this.wal.sync();
     } catch (IOException e) {
       throw new RuntimeException(e);
     }
   }
 }
 /**
  * Creates a WALEdit for the passed KeyValues and returns a HLog.Entry instance composed of the
  * WALEdit and passed HLogKey.
  *
  * @return HLog.Entry instance for the passed HLogKey and KeyValues
  */
 private HLog.Entry createAEntry(HLogKey hlogKey, List<KeyValue> kvs) {
   WALEdit edit = new WALEdit();
   for (KeyValue kv : kvs) edit.add(kv);
   return new HLog.Entry(hlogKey, edit);
 }