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 class XceiverClientManager {
|
|||
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 final class ObjectStoreHandler implements Closeable {
|
|||
@Override
|
||||
public void close() {
|
||||
LOG.info("Closing ObjectStoreHandler.");
|
||||
storageHandler.close();
|
||||
if (this.storageContainerLocationClient != null) {
|
||||
this.storageContainerLocationClient.close();
|
||||
}
|
||||
|
|
|
@ -273,4 +273,9 @@ public interface StorageHandler {
|
|||
* @throws IOException
|
||||
*/
|
||||
ListKeys listKeys(ListArgs args) throws IOException, OzoneException;
|
||||
|
||||
/**
|
||||
* Closes all the opened resources.
|
||||
*/
|
||||
void close();
|
||||
}
|
||||
|
|
|
@ -353,4 +353,9 @@ public class LocalStorageHandler implements StorageHandler {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
//No resource to close, do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -509,4 +509,14 @@ public final class DistributedStorageHandler implements StorageHandler {
|
|||
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