/** * Extends its super class to read in database operation information. * * @see LNLogEntry#readEntry */ @Override public void readEntry(EnvironmentImpl envImpl, LogEntryHeader header, ByteBuffer entryBuffer) { readBaseLNEntry(envImpl, header, entryBuffer, false /*keyIsLastSerializedField*/); /* * The NameLNLogEntry was introduced in version 6. Before, a LNLogEntry * was used for NameLNs, and there is no extra information in the log * entry. */ int version = header.getVersion(); if (version >= 6) { operationType = DbOperationType.readTypeFromLog(entryBuffer, version); if (DbOperationType.isWriteConfigType(operationType)) { replicatedCreateConfig = new ReplicatedDatabaseConfig(); replicatedCreateConfig.readFromLog(entryBuffer, version); } if (operationType == DbOperationType.TRUNCATE) { truncateOldDbId = new DatabaseId(); truncateOldDbId.readFromLog(entryBuffer, version); } } else { operationType = DbOperationType.NONE; } }
/** * Extends its super class to add in database operation information. * * @see LNLogEntry#getSize */ @Override public int getSize() { int size = getBaseLNEntrySize(false /*keyIsLastSerializedField*/) + operationType.getLogSize(); if (DbOperationType.isWriteConfigType(operationType)) { size += replicatedCreateConfig.getLogSize(); } if (operationType == DbOperationType.TRUNCATE) { size += truncateOldDbId.getLogSize(); } return size; }
/** * Extends its super class to add in database operation information. * * @see LogEntry#writeToLog */ @Override public void writeEntry(LogEntryHeader header, ByteBuffer destBuffer) { writeBaseLNEntry(header, destBuffer, false /*keyIsLastSerializedField*/); operationType.writeToLog(destBuffer); if (DbOperationType.isWriteConfigType(operationType)) { replicatedCreateConfig.writeToLog(destBuffer); } if (operationType == DbOperationType.TRUNCATE) { truncateOldDbId.writeToLog(destBuffer); } }
/** * Extends its super class to dump database operation information. * * @see LNLogEntry#dumpEntry */ @Override public StringBuilder dumpEntry(StringBuilder sb, boolean verbose) { super.dumpEntry(sb, verbose); operationType.dumpLog(sb, verbose); if (replicatedCreateConfig != null) { replicatedCreateConfig.dumpLog(sb, verbose); } if (truncateOldDbId != null) { truncateOldDbId.dumpLog(sb, verbose); } return sb; }
/** @see LogEntry#logicalEquals */ @Override public boolean logicalEquals(LogEntry other) { if (!super.logicalEquals(other)) return false; NameLNLogEntry otherEntry = (NameLNLogEntry) other; if (!operationType.logicalEquals(otherEntry.operationType)) { return false; } if ((truncateOldDbId != null) && (!truncateOldDbId.logicalEquals(otherEntry.truncateOldDbId))) { return false; } if (replicatedCreateConfig != null) { if (!replicatedCreateConfig.logicalEquals(otherEntry.replicatedCreateConfig)) return false; } return true; }
/** Constructor to write this entry. */ public NameLNLogEntry( LogEntryType entryType, NameLN nameLN, DatabaseId dbId, byte[] key, long abortLsn, boolean abortKnownDeleted, Txn txn, ReplicationContext repContext) { super(entryType, nameLN, dbId, key, abortLsn, abortKnownDeleted, txn); ReplicationContext operationContext = repContext; operationType = repContext.getDbOperationType(); if (DbOperationType.isWriteConfigType(operationType)) { replicatedCreateConfig = ((DbOpReplicationContext) operationContext).getCreateConfig(); } if (operationType == DbOperationType.TRUNCATE) { truncateOldDbId = ((DbOpReplicationContext) operationContext).getTruncateOldDbId(); } }