Skip to content

Commit

Permalink
Update for Bootstrap and LifeCycleManager changes
Browse files Browse the repository at this point in the history
  • Loading branch information
electrum committed Sep 17, 2019
1 parent 2eda92a commit 38c4326
Show file tree
Hide file tree
Showing 64 changed files with 269 additions and 592 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,6 @@ public List<PropertyMetadata<?>> getSessionProperties()
@Override
public final void shutdown()
{
try {
lifeCycleManager.stop();
}
catch (Exception e) {
LOG.error(e, "Error shutting down connector");
}
lifeCycleManager.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import java.util.Map;

import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.util.Objects.requireNonNull;

public class AccumuloConnectorFactory
Expand All @@ -44,19 +43,17 @@ public Connector create(String catalogName, Map<String, String> config, Connecto
requireNonNull(config, "requiredConfig is null");
requireNonNull(context, "context is null");

try {
Bootstrap app = new Bootstrap(new JsonModule(), new AccumuloModule(context.getTypeManager()));
Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.initialize();
return injector.getInstance(AccumuloConnector.class);
}
catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
Bootstrap app = new Bootstrap(
new JsonModule(),
new AccumuloModule(context.getTypeManager()));

Injector injector = app
.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.initialize();

return injector.getInstance(AccumuloConnector.class);
}

@Override
Expand Down
5 changes: 0 additions & 5 deletions presto-atop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@
<artifactId>bootstrap</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>log</artifactId>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.prestosql.plugin.atop;

import io.airlift.bootstrap.LifeCycleManager;
import io.airlift.log.Logger;
import io.prestosql.spi.connector.Connector;
import io.prestosql.spi.connector.ConnectorAccessControl;
import io.prestosql.spi.connector.ConnectorMetadata;
Expand All @@ -30,8 +29,6 @@
public class AtopConnector
implements Connector
{
private static final Logger log = Logger.get(AtopConnector.class);

private final LifeCycleManager lifeCycleManager;
private final AtopMetadata metadata;
private final AtopSplitManager splitManager;
Expand Down Expand Up @@ -86,11 +83,6 @@ public ConnectorAccessControl getAccessControl()
@Override
public final void shutdown()
{
try {
lifeCycleManager.stop();
}
catch (Exception e) {
log.error(e, "Error shutting down connector");
}
lifeCycleManager.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import java.util.Map;

import static com.google.common.base.Throwables.throwIfUnchecked;
import static io.airlift.configuration.ConditionalModule.installModuleIf;
import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -88,9 +87,5 @@ public Connector create(String catalogName, Map<String, String> requiredConfig,

return injector.getInstance(AtopConnector.class);
}
catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import com.google.common.collect.ImmutableSet;
import io.airlift.bootstrap.LifeCycleManager;
import io.airlift.log.Logger;
import io.prestosql.spi.connector.Connector;
import io.prestosql.spi.connector.ConnectorAccessControl;
import io.prestosql.spi.connector.ConnectorCapabilities;
Expand Down Expand Up @@ -47,8 +46,6 @@
public class JdbcConnector
implements Connector
{
private static final Logger log = Logger.get(JdbcConnector.class);

private final LifeCycleManager lifeCycleManager;
private final JdbcMetadataFactory jdbcMetadataFactory;
private final JdbcSplitManager jdbcSplitManager;
Expand Down Expand Up @@ -159,12 +156,7 @@ public List<PropertyMetadata<?>> getSessionProperties()
@Override
public final void shutdown()
{
try {
lifeCycleManager.stop();
}
catch (Exception e) {
log.error(e, "Error shutting down connector");
}
lifeCycleManager.stop();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.util.Objects.requireNonNull;

public class JdbcConnectorFactory
Expand Down Expand Up @@ -82,9 +81,5 @@ public Connector create(String catalogName, Map<String, String> requiredConfig,

return injector.getInstance(JdbcConnector.class);
}
catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public class TestCredentialProvider
{
@Test
public void testInlineCredentialProvider()
throws Exception
{
Map<String, String> properties = ImmutableMap.of(
"connection-url", "jdbc:h2:mem:config",
Expand All @@ -41,7 +40,6 @@ public void testInlineCredentialProvider()

@Test
public void testFileCredentialProvider()
throws Exception
{
Map<String, String> properties = ImmutableMap.of(
"connection-url", "jdbc:h2:mem:config",
Expand All @@ -53,8 +51,7 @@ public void testFileCredentialProvider()
assertEquals(credentialProvider.getConnectionPassword(Optional.empty()).get(), "password_for_user_from_file");
}

private CredentialProvider getCredentialProvider(Map<String, String> properties)
throws Exception
private static CredentialProvider getCredentialProvider(Map<String, String> properties)
{
return new Bootstrap(ImmutableList.of(new CredentialProviderModule()))
.setOptionalConfigurationProperties(properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class TestExtraCredentialProvider
{
@Test
public void testUserNameOverwritten()
throws Exception
{
Map<String, String> properties = ImmutableMap.of(
"connection-url", "jdbc:h2:mem:config",
Expand All @@ -44,7 +43,6 @@ public void testUserNameOverwritten()

@Test
public void testPasswordOverwritten()
throws Exception
{
Map<String, String> properties = ImmutableMap.of(
"connection-url", "jdbc:h2:mem:config",
Expand All @@ -60,7 +58,6 @@ public void testPasswordOverwritten()

@Test
public void testCredentialsOverwritten()
throws Exception
{
Map<String, String> properties = ImmutableMap.of(
"connection-url", "jdbc:h2:mem:config",
Expand All @@ -77,7 +74,6 @@ public void testCredentialsOverwritten()

@Test
public void testCredentialsNotOverwritten()
throws Exception
{
Map<String, String> properties = ImmutableMap.of(
"connection-url", "jdbc:h2:mem:config",
Expand All @@ -96,8 +92,7 @@ public void testCredentialsNotOverwritten()
assertEquals(credentialProvider.getConnectionPassword(jdbcIdentity).get(), "default_password");
}

private CredentialProvider getCredentialProvider(Map<String, String> properties)
throws Exception
private static CredentialProvider getCredentialProvider(Map<String, String> properties)
{
return new Bootstrap(ImmutableList.of(new CredentialProviderModule()))
.setRequiredConfigurationProperties(properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.prestosql.plugin.cassandra;

import io.airlift.bootstrap.LifeCycleManager;
import io.airlift.log.Logger;
import io.prestosql.spi.connector.Connector;
import io.prestosql.spi.connector.ConnectorMetadata;
import io.prestosql.spi.connector.ConnectorPageSinkProvider;
Expand All @@ -35,8 +34,6 @@
public class CassandraConnector
implements Connector
{
private static final Logger log = Logger.get(CassandraConnector.class);

private final LifeCycleManager lifeCycleManager;
private final CassandraMetadata metadata;
private final CassandraSplitManager splitManager;
Expand Down Expand Up @@ -107,11 +104,6 @@ public List<PropertyMetadata<?>> getSessionProperties()
@Override
public final void shutdown()
{
try {
lifeCycleManager.stop();
}
catch (Exception e) {
log.error(e, "Error shutting down connector");
}
lifeCycleManager.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import java.util.Map;

import static com.google.common.base.Throwables.throwIfUnchecked;
import static java.util.Objects.requireNonNull;

public class CassandraConnectorFactory
Expand All @@ -48,22 +47,16 @@ public Connector create(String catalogName, Map<String, String> config, Connecto
{
requireNonNull(config, "config is null");

try {
Bootstrap app = new Bootstrap(
new MBeanModule(),
new JsonModule(),
new CassandraClientModule(),
new MBeanServerModule());
Bootstrap app = new Bootstrap(
new MBeanModule(),
new JsonModule(),
new CassandraClientModule(),
new MBeanServerModule());

Injector injector = app.strictConfig().doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.initialize();
Injector injector = app.strictConfig().doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.initialize();

return injector.getInstance(CassandraConnector.class);
}
catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
return injector.getInstance(CassandraConnector.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package io.prestosql.elasticsearch;

import io.airlift.bootstrap.LifeCycleManager;
import io.airlift.log.Logger;
import io.prestosql.spi.connector.Connector;
import io.prestosql.spi.connector.ConnectorMetadata;
import io.prestosql.spi.connector.ConnectorRecordSetProvider;
Expand All @@ -31,8 +30,6 @@
public class ElasticsearchConnector
implements Connector
{
private static final Logger LOG = Logger.get(ElasticsearchConnector.class);

private final LifeCycleManager lifeCycleManager;
private final ElasticsearchMetadata metadata;
private final ElasticsearchSplitManager splitManager;
Expand Down Expand Up @@ -79,11 +76,6 @@ public ConnectorRecordSetProvider getRecordSetProvider()
@Override
public final void shutdown()
{
try {
lifeCycleManager.stop();
}
catch (Exception e) {
LOG.error(e, "Error shutting down connector");
}
lifeCycleManager.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,20 @@ public Connector create(String catalogName, Map<String, String> config, Connecto
requireNonNull(catalogName, "catalogName is null");
requireNonNull(config, "config is null");

try {
Bootstrap app = new Bootstrap(
new JsonModule(),
new ElasticsearchConnectorModule(),
binder -> {
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
binder.bind(NodeManager.class).toInstance(context.getNodeManager());
binder.bind(ElasticsearchTableDescriptionProvider.class).in(Scopes.SINGLETON);
});
Bootstrap app = new Bootstrap(
new JsonModule(),
new ElasticsearchConnectorModule(),
binder -> {
binder.bind(TypeManager.class).toInstance(context.getTypeManager());
binder.bind(NodeManager.class).toInstance(context.getNodeManager());
binder.bind(ElasticsearchTableDescriptionProvider.class).in(Scopes.SINGLETON);
});

Injector injector = app.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.initialize();
Injector injector = app.strictConfig()
.doNotInitializeLogging()
.setRequiredConfigurationProperties(config)
.initialize();

return injector.getInstance(ElasticsearchConnector.class);
}
catch (Exception e) {
throw new RuntimeException(e);
}
return injector.getInstance(ElasticsearchConnector.class);
}
}
Loading

0 comments on commit 38c4326

Please sign in to comment.