@Override public void append(List<TransactionEdit> edits) throws IOException { long startTime = System.nanoTime(); synchronized (this) { ensureAvailable(); for (TransactionEdit edit : edits) { Entry entry = new Entry(new LongWritable(logSequence.getAndIncrement()), edit); // add to pending edits append(entry); } } // wait for sync to complete sync(); long durationMillis = (System.nanoTime() - startTime) / 1000000L; if (durationMillis > SLOW_APPEND_THRESHOLD) { LOG.info("Slow append to log " + getName() + ", took " + durationMillis + " msec."); } }
private void sync() throws IOException { // writes out pending entries to the HLog TransactionLogWriter tmpWriter = null; long latestSeq = 0; int entryCount = 0; synchronized (this) { if (closed) { return; } // prevent writer being dereferenced tmpWriter = writer; List<Entry> currentPending = getPendingWrites(); if (!currentPending.isEmpty()) { tmpWriter.commitMarker(currentPending.size()); } // write out all accumulated entries to log. for (Entry e : currentPending) { tmpWriter.append(e); entryCount++; latestSeq = Math.max(latestSeq, e.getKey().get()); } } long lastSynced = syncedUpTo.get(); // someone else might have already synced our edits, avoid double syncing if (lastSynced < latestSeq) { tmpWriter.sync(); metricsCollector.histogram("wal.sync.size", entryCount); syncedUpTo.compareAndSet(lastSynced, latestSeq); } }
entry = new AbstractTransactionLog.Entry(new LongWritable(logSequence.getAndIncrement()), edits.get(j)); writer.append(entry.getKey(), entry.getEdit()); entry = new AbstractTransactionLog.Entry(new LongWritable(logSequence.getAndIncrement()), edits.get(i)); writer.append(entry.getKey(), entry.getEdit()); entry = new AbstractTransactionLog.Entry(new LongWritable(logSequence.getAndIncrement()), edits.get(totalCount - 1)); if (isComplete) { writer.append(entry.getKey(), entry.getEdit()); } else { byte[] bytes = Longs.toByteArray(entry.getKey().get()); writer.appendRaw(bytes, 0, bytes.length, new SequenceFile.ValueBytes() { @Override
private void sync() throws IOException { // writes out pending entries to the HLog TransactionLogWriter tmpWriter = null; long latestSeq = 0; int entryCount = 0; synchronized (this) { if (closed) { return; } // prevent writer being dereferenced tmpWriter = writer; List<Entry> currentPending = getPendingWrites(); if (!currentPending.isEmpty()) { tmpWriter.commitMarker(currentPending.size()); } // write out all accumulated entries to log. for (Entry e : currentPending) { tmpWriter.append(e); entryCount++; latestSeq = Math.max(latestSeq, e.getKey().get()); } } long lastSynced = syncedUpTo.get(); // someone else might have already synced our edits, avoid double syncing if (lastSynced < latestSeq) { tmpWriter.sync(); metricsCollector.histogram("wal.sync.size", entryCount); syncedUpTo.compareAndSet(lastSynced, latestSeq); } }
@Override public void append(List<TransactionEdit> edits) throws IOException { long startTime = System.nanoTime(); synchronized (this) { ensureAvailable(); for (TransactionEdit edit : edits) { Entry entry = new Entry(new LongWritable(logSequence.getAndIncrement()), edit); // add to pending edits append(entry); } } // wait for sync to complete sync(); long durationMillis = (System.nanoTime() - startTime) / 1000000L; if (durationMillis > SLOW_APPEND_THRESHOLD) { LOG.info("Slow append to log " + getName() + ", took " + durationMillis + " msec."); } }
@Override public void append(TransactionEdit edit) throws IOException { long startTime = System.nanoTime(); synchronized (this) { ensureAvailable(); Entry entry = new Entry(new LongWritable(logSequence.getAndIncrement()), edit); // add to pending edits append(entry); } // wait for sync to complete sync(); long durationMillis = (System.nanoTime() - startTime) / 1000000L; if (durationMillis > SLOW_APPEND_THRESHOLD) { LOG.info("Slow append to log " + getName() + ", took " + durationMillis + " msec."); } }
@Override public void append(TransactionEdit edit) throws IOException { long startTime = System.nanoTime(); synchronized (this) { ensureAvailable(); Entry entry = new Entry(new LongWritable(logSequence.getAndIncrement()), edit); // add to pending edits append(entry); } // wait for sync to complete sync(); long durationMillis = (System.nanoTime() - startTime) / 1000000L; if (durationMillis > SLOW_APPEND_THRESHOLD) { LOG.info("Slow append to log " + getName() + ", took " + durationMillis + " msec."); } }
@Override public void append(Entry entry) throws IOException { entry.write(out); }
@Override public void append(Entry entry) throws IOException { entry.write(out); }
@Override public TransactionEdit next(TransactionEdit reuse) throws IOException { try { reuseEntry.getKey().readFields(in); reuse.readFields(in); } catch (EOFException eofe) { // signal end of file by returning null return null; } return reuse; }
@Override public TransactionEdit next() throws IOException { Entry entry = new Entry(); try { entry.readFields(in); } catch (EOFException eofe) { // signal end of file by returning null return null; } return entry.getEdit(); }
@Override public TransactionEdit next() throws IOException { Entry entry = new Entry(); try { entry.readFields(in); } catch (EOFException eofe) { // signal end of file by returning null return null; } return entry.getEdit(); }
@Override public TransactionEdit next(TransactionEdit reuse) throws IOException { try { reuseEntry.getKey().readFields(in); reuse.readFields(in); } catch (EOFException eofe) { // signal end of file by returning null return null; } return reuse; }