HDDS-775. Batch updates to container db to minimize number of updates.
Contributed by Mukul Kumar Singh.
This commit is contained in:
parent
39d088bc2c
commit
73fbde31c6
|
@ -526,6 +526,7 @@ public class SCMContainerManager implements ContainerManager {
|
||||||
containerInfos = reports.getReportsList();
|
containerInfos = reports.getReportsList();
|
||||||
PendingDeleteStatusList pendingDeleteStatusList =
|
PendingDeleteStatusList pendingDeleteStatusList =
|
||||||
new PendingDeleteStatusList(datanodeDetails);
|
new PendingDeleteStatusList(datanodeDetails);
|
||||||
|
BatchOperation batch = new BatchOperation();
|
||||||
for (StorageContainerDatanodeProtocolProtos.ContainerInfo contInfo :
|
for (StorageContainerDatanodeProtocolProtos.ContainerInfo contInfo :
|
||||||
containerInfos) {
|
containerInfos) {
|
||||||
// Update replica info during registration process.
|
// Update replica info during registration process.
|
||||||
|
@ -575,7 +576,7 @@ public class SCMContainerManager implements ContainerManager {
|
||||||
//
|
//
|
||||||
// We need to write this to DB again since the closed only write
|
// We need to write this to DB again since the closed only write
|
||||||
// the updated State.
|
// the updated State.
|
||||||
containerStore.put(dbKey, newState.toByteArray());
|
batch.put(dbKey, newState.toByteArray());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Container not found in our container db.
|
// Container not found in our container db.
|
||||||
|
@ -588,6 +589,7 @@ public class SCMContainerManager implements ContainerManager {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
containerStore.writeBatch(batch);
|
||||||
if (pendingDeleteStatusList.getNumPendingDeletes() > 0) {
|
if (pendingDeleteStatusList.getNumPendingDeletes() > 0) {
|
||||||
eventPublisher.fireEvent(SCMEvents.PENDING_DELETE_STATUS,
|
eventPublisher.fireEvent(SCMEvents.PENDING_DELETE_STATUS,
|
||||||
pendingDeleteStatusList);
|
pendingDeleteStatusList);
|
||||||
|
|
Loading…
Reference in New Issue