ChenSammi commented on code in PR #5089:
URL: https://github.com/apache/ozone/pull/5089#discussion_r1282627826
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMCertStore.java:
##########
@@ -220,6 +222,37 @@ public void removeExpiredCertificate(BigInteger serialID)
// TODO: Later this allows removal of expired certificates from the system.
}
+ @Override
+ public void removeAllExpiredCertificates() {
+ lock.lock();
+ try (BatchOperation batchOperation =
+ scmMetadataStore.getBatchHandler().initBatchOperation()) {
+ addExpiredCertsToBeRemoved(batchOperation,
+ scmMetadataStore.getValidCertsTable());
+ addExpiredCertsToBeRemoved(batchOperation,
+ scmMetadataStore.getValidSCMCertsTable());
+ scmMetadataStore.getStore().commitBatchOperation(batchOperation);
+ } catch (IOException e) {
+ LOG.error("Error while trying to remove expired certificate.", e);
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ private void addExpiredCertsToBeRemoved(BatchOperation batchOperation,
+ Table<BigInteger, X509Certificate> certTable) throws IOException {
+ TableIterator<BigInteger, ? extends Table.KeyValue<BigInteger,
+ X509Certificate>> certsIterator = certTable.iterator();
Review Comment:
Please use try() with this iterator to make sure it will be closed in any
cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]