HDFS-12050. Ozone: StorageHandler: Implementation of close for releasing resources during shutdown. Contributed by Nandakumar.

This commit is contained in:
Chen Liang 2017-06-29 14:43:30 -07:00 committed by Owen O'Malley
parent 8ef1163eca
commit 0a8c903d3f
5 changed files with 30 additions and 0 deletions

View File

@ -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();
}
}

View File

@ -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();
}

View File

@ -273,4 +273,9 @@ public interface StorageHandler {
* @throws IOException
*/
ListKeys listKeys(ListArgs args) throws IOException, OzoneException;
/**
* Closes all the opened resources.
*/
void close();
}

View File

@ -353,4 +353,9 @@ public class LocalStorageHandler implements StorageHandler {
}
@Override
public void close() {
//No resource to close, do nothing.
}
}

View File

@ -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();
}
}
}