This is an automated email from the ASF dual-hosted git repository.
shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new c4cbcad HDDS-5710. initialize sequenceIdToLastIdMap when
SequenceIdGenerator#StateManager reinitializes (#2611)
c4cbcad is described below
commit c4cbcadb26596cbf38c65a1e776c7d35ba3f1b79
Author: Jackson Yao <[email protected]>
AuthorDate: Fri Oct 1 20:01:55 2021 +0800
HDDS-5710. initialize sequenceIdToLastIdMap when
SequenceIdGenerator#StateManager reinitializes (#2611)
---
.../hadoop/hdds/scm/ha/SequenceIdGenerator.java | 26 +++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java
index b874bfb..2333ba8 100644
---
a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java
+++
b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java
@@ -159,7 +159,8 @@ public class SequenceIdGenerator {
* Reinitialize the SequenceIdGenerator with the latest sequenceIdTable
* during SCM reload.
*/
- public void reinitialize(Table<String, Long> sequenceIdTable) {
+ public void reinitialize(Table<String, Long> sequenceIdTable)
+ throws IOException {
lock.lock();
try {
LOG.info("reinitialize SequenceIdGenerator.");
@@ -197,7 +198,7 @@ public class SequenceIdGenerator {
* Reinitialize the SequenceIdGenerator with the latest sequenceIdTable
* during SCM reload.
*/
- void reinitialize(Table<String, Long> sequenceIdTable);
+ void reinitialize(Table<String, Long> sequenceIdTable) throws IOException;
}
/**
@@ -253,9 +254,28 @@ public class SequenceIdGenerator {
}
@Override
- public void reinitialize(Table<String, Long> seqIdTable) {
+ public void reinitialize(Table<String, Long> seqIdTable)
+ throws IOException {
this.sequenceIdTable = seqIdTable;
this.sequenceIdToLastIdMap.clear();
+ initialize();
+ }
+
+ private void initialize() throws IOException {
+ TableIterator<String,
+ ? extends Table.KeyValue<String, Long>>
+ iterator = sequenceIdTable.iterator();
+
+ while (iterator.hasNext()) {
+ Table.KeyValue<String, Long> kv = iterator.next();
+ final String sequenceIdName = kv.getKey();
+ final Long lastId = kv.getValue();
+ Preconditions.checkNotNull(sequenceIdName,
+ "sequenceIdName should not be null");
+ Preconditions.checkNotNull(lastId,
+ "lastId should not be null");
+ sequenceIdToLastIdMap.put(sequenceIdName, lastId);
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]