@Override public FSEditLogOp decodeOp() throws IOException { limiter.setLimit(maxOpSize); in.mark(maxOpSize); byte opCodeByte; try { opCodeByte = in.readByte(); } catch (EOFException eof) { // EOF at an opcode boundary is expected. return null; } FSEditLogOpCodes opCode = FSEditLogOpCodes.fromByte(opCodeByte); if (opCode == OP_INVALID) { verifyTerminator(); return null; } FSEditLogOp op = cache.get(opCode); if (op == null) { throw new IOException("Read invalid opcode " + opCode); } if (NameNodeLayoutVersion.supports( LayoutVersion.Feature.STORED_TXIDS, logVersion)) { op.setTransactionId(in.readLong()); } else { op.setTransactionId(HdfsServerConstants.INVALID_TXID); } op.readFields(in, logVersion); return op; }
synchronized boolean doEditTransaction(final FSEditLogOp op) { long start = beginTransaction(); op.setTransactionId(txid); try { editLogStream.write(op); } catch (IOException ex) { // All journals failed, it is handled in logSync. } finally { op.reset(); } endTransaction(start); return shouldForceSync(); }
throw new IOException("Read invalid opcode " + opCode); op.setTransactionId(in.readLong()); op.readFields(in, logVersion);
@Override public FSEditLogOp decodeOp() throws IOException { long txid = decodeOpFrame(); if (txid == HdfsServerConstants.INVALID_TXID) { return null; } in.reset(); in.mark(maxOpSize); FSEditLogOpCodes opCode = FSEditLogOpCodes.fromByte(in.readByte()); FSEditLogOp op = cache.get(opCode); if (op == null) { throw new IOException("Read invalid opcode " + opCode); } op.setTransactionId(txid); IOUtils.skipFully(in, 4 + 8); // skip length and txid op.readFields(in, logVersion); // skip over the checksum, which we validated above. IOUtils.skipFully(in, CHECKSUM_LENGTH); return op; }
op.setTransactionId(nextTxId); nextTxId++;
op.setTransactionId(nextTxId); nextTxId++;
op.setTransactionId(in.readLong());
LayoutVersion.Feature.STORED_TXIDS, logVersion)) { op.setTransactionId(in.readLong()); } else { op.setTransactionId(HdfsConstants.INVALID_TXID);
public static void writeOp(EditLogOutputStream stm, long txid) throws IOException { FSEditLogOp op = NameNodeAdapter.createMkdirOp("tx " + txid); op.setTransactionId(txid); stm.write(op); }
LayoutVersion.Feature.STORED_TXIDS, logVersion)) { op.setTransactionId(in.readLong()); } else { op.setTransactionId(HdfsConstants.INVALID_TXID);
op.setTransactionId(txid); assert this.getNumEditStreams() > 0 : "no editlog streams"; long start = FSNamesystem.now();
op.setTransactionId(nextTxId); nextTxId++;
op.setTransactionId(nextTxId); nextTxId++;
op.setTransactionId(nextTxId); nextTxId++;
public static byte[] createTxnData(int startTxn, int numTxns) throws Exception { DataOutputBuffer buf = new DataOutputBuffer(); FSEditLogOp.Writer writer = new FSEditLogOp.Writer(buf); for (long txid = startTxn; txid < startTxn + numTxns; txid++) { FSEditLogOp op = NameNodeAdapter.createMkdirOp("tx " + txid); op.setTransactionId(txid); writer.writeOp(op); } return Arrays.copyOf(buf.getData(), buf.getLength()); }
/** * Generate byte array representing a set of GarbageMkdirOp */ public static byte[] createGabageTxns(long startTxId, int numTxns) throws IOException { DataOutputBuffer buf = new DataOutputBuffer(); FSEditLogOp.Writer writer = new FSEditLogOp.Writer(buf); for (long txid = startTxId; txid < startTxId + numTxns; txid++) { FSEditLogOp op = new TestEditLog.GarbageMkdirOp(); op.setTransactionId(txid); writer.writeOp(op); } return Arrays.copyOf(buf.getData(), buf.getLength()); }
op.setTransactionId(nextTxId); nextTxId++;