Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class OMDBUpdatesHandler extends ManagedWriteBatch.Handler {
private CodecRegistry codecRegistry;
private OMMetadataManager omMetadataManager;
private List<OMDBUpdateEvent> omdbUpdateEvents = new ArrayList<>();
private Map<String, OMDBUpdateEvent> omdbLatestUpdateEvents
private Map<Object, OMDBUpdateEvent> omdbLatestUpdateEvents
= new HashMap<>();
private OMDBDefinition omdbDefinition;

Expand Down Expand Up @@ -93,14 +93,23 @@ private void processEvent(int cfIndex, byte[] keyBytes, byte[]
valueBytes, OMDBUpdateEvent.OMDBUpdateAction action)
throws IOException {
String tableName = tablesNames.get(cfIndex);
// DTOKEN_TABLE is using OzoneTokenIdentifier as key instead of String
// and assuming to typecast as String while de-serializing will throw error.
// omdbLatestUpdateEvents defines map key as String type to store in its map
// and to change to Object as key will have larger impact considering all
// ReconOmTasks. Currently, this table is not needed to sync in Recon OM DB
// snapshot as this table data not being used currently in Recon.
// When this table data will be needed, all events for this table will be
// saved using Object as key and new task will also retrieve using Object
// as key.
Optional<Class> keyType = omdbDefinition.getKeyType(tableName);
Optional<Class> valueType = omdbDefinition.getValueType(tableName);
if (keyType.isPresent() && valueType.isPresent()) {
OMDBUpdateEvent.OMUpdateEventBuilder builder =
new OMDBUpdateEvent.OMUpdateEventBuilder<>();
builder.setTable(tableName);
builder.setAction(action);
String key = (String) codecRegistry.asObject(keyBytes, keyType.get());
Object key = codecRegistry.asObject(keyBytes, keyType.get());
builder.setKey(key);

// Put new
Expand All @@ -114,7 +123,7 @@ private void processEvent(int cfIndex, byte[] keyBytes, byte[]
if (latestEvent != null) {
oldValue = latestEvent.getValue();
} else {
// Recon does not add entries to cache and it is safer to always use
// Recon does not add entries to cache, and it is safer to always use
// getSkipCache in Recon.
oldValue = table.getSkipCache(key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.hadoop.hdds.server.ServerUtils;
import org.apache.hadoop.hdds.utils.db.RocksDatabase;
import org.apache.hadoop.hdds.utils.db.managed.ManagedTransactionLogIterator;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.ozone.om.OMMetadataManager;
import org.apache.hadoop.ozone.om.OmMetadataManagerImpl;
import org.apache.hadoop.ozone.om.codec.OMDBDefinition;
Expand Down Expand Up @@ -112,11 +113,20 @@ public void testPut() throws Exception {
reconOmMetadataManager.getKeyTable(getBucketLayout())
.put("/sampleVol/bucketOne/key_two", secondKey);


Text tester = new Text("tester");
OzoneTokenIdentifier identifier =
new OzoneTokenIdentifier(tester, tester, tester);
identifier.setOmCertSerialId("certID");
identifier.setOmServiceId("");

omMetadataManager.getDelegationTokenTable().put(identifier, 12345L);

List<byte[]> writeBatches = getBytesFromOmMetaManager(0);
OMDBUpdatesHandler omdbUpdatesHandler = captureEvents(writeBatches);

List<OMDBUpdateEvent> events = omdbUpdatesHandler.getEvents();
assertEquals(3, events.size());
assertEquals(4, events.size());

OMDBUpdateEvent volEvent = events.get(0);
assertEquals(PUT, volEvent.getAction());
Expand Down