use of io.cdap.cdap.spi.metadata.MetadataStorage in project cdap by caskdata.
the class MetadataServiceMain method addServices.
@Override
protected void addServices(Injector injector, List<? super Service> services, List<? super AutoCloseable> closeableResources, MasterEnvironment masterEnv, MasterEnvironmentContext masterEnvContext, EnvironmentOptions options) {
services.add(injector.getInstance(MetadataService.class));
services.add(injector.getInstance(MetadataSubscriberService.class));
Binding<ZKClientService> zkBinding = injector.getExistingBinding(Key.get(ZKClientService.class));
if (zkBinding != null) {
services.add(zkBinding.getProvider().get());
}
CConfiguration cConf = injector.getInstance(CConfiguration.class);
if (SecurityUtil.isInternalAuthEnabled(cConf)) {
services.add(injector.getInstance(TokenManager.class));
}
// Add a service just for closing MetadataStorage to release resource.
// MetadataStorage is binded as Singleton, so ok to get the instance and close it.
MetadataStorage metadataStorage = injector.getInstance(MetadataStorage.class);
services.add(new AbstractService() {
@Override
protected void doStart() {
notifyStarted();
}
@Override
protected void doStop() {
Closeables.closeQuietly(metadataStorage);
notifyStopped();
}
});
}
Aggregations