@Override protected void initAfterCompression(String cellCodecClsName) throws IOException { WALCellCodec codec = getCodec(this.conf, cellCodecClsName, this.compressionContext); this.cellDecoder = codec.getDecoder(this.inputStream); if (this.hasCompression) { this.byteStringUncompressor = codec.getByteStringUncompressor(); } else { this.byteStringUncompressor = WALCellCodec.getNoneUncompressor(); } }
private void initAfterHeader0(boolean doCompress) throws IOException { WALCellCodec codec = getCodec(conf, this.compressionContext); this.cellEncoder = codec.getEncoder(getOutputStreamForCellEncoder()); if (doCompress) { this.compressor = codec.getByteStringCompressor(); } else { this.compressor = WALCellCodec.getNoneCompressor(); } }
private void checkIfSyncFailed(SyncFuture syncFuture) throws FailedSyncBeforeLogCloseException { if (syncFuture.isThrowable()) { throw new FailedSyncBeforeLogCloseException(syncFuture.getThrowable()); } }
protected final void secureInitAfterHeader(boolean doCompress, Encryptor encryptor) throws IOException { if (conf.getBoolean(HConstants.ENABLE_WAL_ENCRYPTION, false) && encryptor != null) { WALCellCodec codec = SecureWALCellCodec.getCodec(this.conf, encryptor); this.cellEncoder = codec.getEncoder(getOutputStreamForCellEncoder()); // We do not support compression this.compressionContext = null; this.compressor = WALCellCodec.getNoneCompressor(); } else { initAfterHeader0(doCompress); } }
@Override public void logRollRequested(boolean underReplicated) { source.incrementLogRollRequested(); if (underReplicated) { source.incrementLowReplicationLogRoll(); } } }
/** * Tell listeners about pre log roll. */ private void tellListenersAboutPreLogRoll(final Path oldPath, final Path newPath) throws IOException { coprocessorHost.preWALRoll(oldPath, newPath); if (!this.listeners.isEmpty()) { for (WALActionsListener i : this.listeners) { i.preLogRoll(oldPath, newPath); } } }
/** * Tell listeners about post log roll. */ private void tellListenersAboutPostLogRoll(final Path oldPath, final Path newPath) throws IOException { if (!this.listeners.isEmpty()) { for (WALActionsListener i : this.listeners) { i.postLogRoll(oldPath, newPath); } } coprocessorHost.postWALRoll(oldPath, newPath); }
@Override public Encoder getEncoder(OutputStream os) { os = (os instanceof ByteBufferWriter) ? os : new ByteBufferWriterOutputStream(os); if (compression == null) { return new EnsureKvEncoder(os); } return new CompressedKvEncoder(os, compression); }
@Override public long getEarliestMemStoreSeqNum(byte[] encodedRegionName, byte[] familyName) { // This method is used by tests and for figuring if we should flush or not because our // sequenceids are too old. It is also used reporting the master our oldest sequenceid for use // figuring what edits can be skipped during log recovery. getEarliestMemStoreSequenceId // from this.sequenceIdAccounting is looking first in flushingOldestStoreSequenceIds, the // currently flushing sequence ids, and if anything found there, it is returning these. This is // the right thing to do for the reporting oldest sequenceids to master; we won't skip edits if // we crash during the flush. For figuring what to flush, we might get requeued if our sequence // id is old even though we are currently flushing. This may mean we do too much flushing. return this.sequenceIdAccounting.getLowestSequenceId(encodedRegionName, familyName); }
@Override public void onStart() { for (SyncRunner syncRunner : this.syncRunners) { syncRunner.start(); } }
private boolean isOutstandingSyncsFromRunners() { // Look at SyncFutures in the SyncRunners for (SyncRunner syncRunner: syncRunners) { if(syncRunner.isAlive() && !syncRunner.areSyncFuturesReleased()) { return true; } } return false; }
@Override public void onShutdown() { for (SyncRunner syncRunner : this.syncRunners) { syncRunner.interrupt(); } } }
/** * Used to initialize the WAL. Usually just call rollWriter to create the first log writer. */ public void init() throws IOException { rollWriter(); }
/** @return the number of log files in use */ public int getNumLogFiles() { // +1 for current use log return getNumRolledLogFiles() + 1; }
@Override public void close() throws IOException { FSHLog log = this.log; if (log != null) { log.close(); } }
/** * iff the given WALFactory is using the DefaultWALProvider for meta and/or non-meta, count the * number of files (rolled and active). if either of them aren't, count 0 for that provider. */ @Override public long getNumLogFiles() { T log = this.wal; return log == null ? 0 : log.getNumLogFiles(); }
@Override public void shutdown() throws IOException { T log = this.wal; if (log != null) { log.shutdown(); } }
@Override protected WALHeader buildWALHeader(Configuration conf, WALHeader.Builder builder) throws IOException { return super.buildSecureWALHeader(conf, builder); }
@Override public void write(int b) throws IOException { oneByteBuf[0] = (byte) b; write(oneByteBuf); }
/** * @return Call when the thread is done. */ boolean isException() { return !isAlive() && this.e != null; }