/** * 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); } }
/** 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(); } }