fix MetadataStorage binding so that it is always Noop except for coordinator iff derby is configured (#3789)

This commit is contained in:
Himanshu 2016-12-19 18:24:09 -06:00 committed by Fangjin Yang
parent ebb4952f3f
commit fd14997b1d
3 changed files with 7 additions and 4 deletions

View File

@ -33,7 +33,6 @@ import io.druid.metadata.MetadataSegmentManager;
import io.druid.metadata.MetadataSegmentManagerProvider; import io.druid.metadata.MetadataSegmentManagerProvider;
import io.druid.metadata.MetadataSegmentPublisher; import io.druid.metadata.MetadataSegmentPublisher;
import io.druid.metadata.MetadataSegmentPublisherProvider; import io.druid.metadata.MetadataSegmentPublisherProvider;
import io.druid.metadata.MetadataStorage;
import io.druid.metadata.MetadataStorageActionHandlerFactory; import io.druid.metadata.MetadataStorageActionHandlerFactory;
import io.druid.metadata.MetadataStorageConnector; import io.druid.metadata.MetadataStorageConnector;
import io.druid.metadata.MetadataStorageProvider; import io.druid.metadata.MetadataStorageProvider;
@ -171,8 +170,6 @@ public class SQLMetadataStorageDruidModule implements Module
@Override @Override
public void configure(Binder binder) public void configure(Binder binder)
{ {
binder.bind(MetadataStorage.class).toProvider(NoopMetadataStorageProvider.class);
PolyBind.optionBinder(binder, Key.get(MetadataSegmentManager.class)) PolyBind.optionBinder(binder, Key.get(MetadataSegmentManager.class))
.addBinding(type) .addBinding(type)
.to(SQLMetadataSegmentManager.class) .to(SQLMetadataSegmentManager.class)

View File

@ -56,7 +56,7 @@ public class DerbyConnector extends SQLMetadataConnector
this.dbi = new DBI(datasource); this.dbi = new DBI(datasource);
this.storage = storage; this.storage = storage;
log.info("Configured Derby as metadata storage"); log.info("Derby connector instantiated with metadata storage [%s].", this.storage.getClass().getName());
} }
public DerbyConnector( public DerbyConnector(
@ -102,12 +102,14 @@ public class DerbyConnector extends SQLMetadataConnector
@LifecycleStart @LifecycleStart
public void start() public void start()
{ {
log.info("Starting DerbyConnector...");
storage.start(); storage.start();
} }
@LifecycleStop @LifecycleStop
public void stop() public void stop()
{ {
log.info("Stopping DerbyConnector...");
storage.stop(); storage.stop();
} }
} }

View File

@ -24,8 +24,10 @@ import com.google.inject.Key;
import io.druid.guice.LazySingleton; import io.druid.guice.LazySingleton;
import io.druid.guice.PolyBind; import io.druid.guice.PolyBind;
import io.druid.guice.SQLMetadataStorageDruidModule; import io.druid.guice.SQLMetadataStorageDruidModule;
import io.druid.metadata.MetadataStorage;
import io.druid.metadata.MetadataStorageConnector; import io.druid.metadata.MetadataStorageConnector;
import io.druid.metadata.MetadataStorageProvider; import io.druid.metadata.MetadataStorageProvider;
import io.druid.metadata.NoopMetadataStorageProvider;
import io.druid.metadata.SQLMetadataConnector; import io.druid.metadata.SQLMetadataConnector;
public class DerbyMetadataStorageDruidModule extends SQLMetadataStorageDruidModule public class DerbyMetadataStorageDruidModule extends SQLMetadataStorageDruidModule
@ -43,6 +45,8 @@ public class DerbyMetadataStorageDruidModule extends SQLMetadataStorageDruidModu
createBindingChoices(binder, TYPE); createBindingChoices(binder, TYPE);
super.configure(binder); super.configure(binder);
binder.bind(MetadataStorage.class).toProvider(NoopMetadataStorageProvider.class);
PolyBind.optionBinder(binder, Key.get(MetadataStorageProvider.class)) PolyBind.optionBinder(binder, Key.get(MetadataStorageProvider.class))
.addBinding(TYPE) .addBinding(TYPE)
.to(DerbyMetadataStorageProvider.class) .to(DerbyMetadataStorageProvider.class)