@Override public void addTransactionsToLog(EditLogOutputStream elos, OpInstanceCache cache) throws IOException { for (long txid = 1; txid <= MAX_TXID; txid++) { if (txid == BAD_TXID) { byte garbage[] = { 0x1, 0x2, 0x3 }; elos.writeRaw(garbage, 0, garbage.length); } else { DeleteOp op; op = DeleteOp.getInstance(cache); op.setTransactionId(txid); op.setPath("/foo." + txid); op.setTimestamp(txid); elos.write(op); } } }
/** * Converts a Transaction Log operation into a NamespaceNotification * object. * @param op the Transaction Log operation. * @return the NamespaceNotification object or null if the type of * the operation isn't supported to be transformed into a * NamespaceNotification. */ static NamespaceNotification createNotification(FSEditLogOp op) { switch (op.opCode) { case OP_ADD: return new NamespaceNotification(((AddOp)op).path, EventType.FILE_ADDED.getByteValue(), op.getTransactionId()); case OP_CLOSE: return new NamespaceNotification(((CloseOp)op).path, EventType.FILE_CLOSED.getByteValue(), op.getTransactionId()); case OP_DELETE: return new NamespaceNotification(((DeleteOp)op).path, EventType.NODE_DELETED.getByteValue(), op.getTransactionId()); case OP_MKDIR: return new NamespaceNotification(((MkdirOp)op).path, EventType.DIR_ADDED.getByteValue(), op.getTransactionId()); default: return null; } }
/** * Add delete file record to edit log */ void logDelete(String src, long timestamp, boolean toLogRpcIds) { DeleteOp op = DeleteOp.getInstance(cache.get()) .setPath(src) .setTimestamp(timestamp); logRpcIds(op, toLogRpcIds); logEdit(op); }
static void addDeleteOpcode(EditLogOutputStream elos, OpInstanceCache cache, long txId, String path) throws IOException { DeleteOp op = DeleteOp.getInstance(cache); op.setTransactionId(txId); op.setPath(path); op.setTimestamp(0); elos.write(op); }