HDFS-12050. Ozone: StorageHandler: Implementation of close for releasing resources during shutdown. Contributed by Nandakumar.
This commit is contained in:
parent
8ef1163eca
commit
0a8c903d3f
@ -154,4 +154,13 @@ public XceiverClientSpi call() throws Exception {
|
||||
throw new IOException("Exception getting XceiverClient.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close and remove all the cached clients.
|
||||
*/
|
||||
public void close() {
|
||||
//closing is done through RemovalListener
|
||||
clientCache.invalidateAll();
|
||||
clientCache.cleanUp();
|
||||
}
|
||||
}
|
||||
|
@ -177,6 +177,7 @@ public StorageHandler getStorageHandler() {
|
||||
@Override
|
||||
public void close() {
|
||||
LOG.info("Closing ObjectStoreHandler.");
|
||||
storageHandler.close();
|
||||
if (this.storageContainerLocationClient != null) {
|
||||
this.storageContainerLocationClient.close();
|
||||
}
|
||||
|
@ -273,4 +273,9 @@ LengthInputStream newKeyReader(KeyArgs args)
|
||||
* @throws IOException
|
||||
*/
|
||||
ListKeys listKeys(ListArgs args) throws IOException, OzoneException;
|
||||
|
||||
/**
|
||||
* Closes all the opened resources.
|
||||
*/
|
||||
void close();
|
||||
}
|
||||
|
@ -353,4 +353,9 @@ public ListKeys listKeys(ListArgs args) throws IOException, OzoneException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
//No resource to close, do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -509,4 +509,14 @@ private static String dateToString(Date date) {
|
||||
sdf.setTimeZone(TimeZone.getTimeZone(OzoneConsts.OZONE_TIME_ZONE));
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes DistributedStorageHandler.
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
if(xceiverClientManager != null) {
|
||||
xceiverClientManager.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user