private void dumpRemainingEditLogs() { byte[] buf = this.getData(); byte[] remainingRawEdits = Arrays.copyOfRange(buf, 0, this.size()); ByteArrayInputStream bis = new ByteArrayInputStream(remainingRawEdits); DataInputStream dis = new DataInputStream(bis); FSEditLogLoader.PositionTrackingInputStream tracker = new FSEditLogLoader.PositionTrackingInputStream(bis); FSEditLogOp.Reader reader = FSEditLogOp.Reader.create(dis, tracker, NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION); FSEditLogOp op; LOG.warn("The edits buffer is " + size() + " bytes long with " + numTxns + " unflushed transactions. " + "Below is the list of unflushed transactions:"); int numTransactions = 0; try { while ((op = reader.readOp(false)) != null) { LOG.warn("Unflushed op [" + numTransactions + "]: " + op); numTransactions++; } } catch (IOException ioe) { // If any exceptions, print raw bytes and stop. LOG.warn("Unable to dump remaining ops. Remaining raw bytes: " + Hex.encodeHexString(remainingRawEdits), ioe); } } }
void setBytes(byte[] newBytes, int version) throws IOException { inner.setData(newBytes); tracker = new FSEditLogLoader.PositionTrackingInputStream(inner); in = new DataInputStream(tracker); this.version = version; reader = FSEditLogOp.Reader.create(in, tracker, version); }
reader = FSEditLogOp.Reader.create(dataIn, tracker, logVersion); reader.setMaxOpSize(maxOpSize); state = State.OPEN;