Skip to content

Commit

Permalink
Rename ElasticSearchConnectorConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
martint committed Oct 2, 2019
1 parent c5b6d85 commit af89181
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ public class ElasticsearchClient
private final Duration maxRetryTime;

@Inject
public ElasticsearchClient(ElasticsearchTableDescriptionProvider descriptions, ElasticsearchConnectorConfig config)
public ElasticsearchClient(ElasticsearchTableDescriptionProvider descriptions, ElasticsearchConfig config)
throws IOException
{
tableDescriptions = requireNonNull(descriptions, "description is null");
ElasticsearchConnectorConfig configuration = requireNonNull(config, "config is null");
ElasticsearchConfig configuration = requireNonNull(config, "config is null");
requestTimeout = configuration.getRequestTimeout();
maxAttempts = configuration.getMaxRequestRetries();
maxRetryTime = configuration.getMaxRetryTime();
Expand Down Expand Up @@ -464,12 +464,12 @@ public int compare(String left, String right)
}
}

static TransportClient createTransportClient(ElasticsearchConnectorConfig config, TransportAddress address)
static TransportClient createTransportClient(ElasticsearchConfig config, TransportAddress address)
{
return createTransportClient(config, address, Optional.empty());
}

static TransportClient createTransportClient(ElasticsearchConnectorConfig config, TransportAddress address, Optional<String> clusterName)
static TransportClient createTransportClient(ElasticsearchConfig config, TransportAddress address, Optional<String> clusterName)
{
Settings settings;
Settings.Builder builder = Settings.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import static java.util.concurrent.TimeUnit.SECONDS;

@DefunctConfig("elasticsearch.max-hits")
public class ElasticsearchConnectorConfig
public class ElasticsearchConfig
{
private String defaultSchema = "default";
private File tableDescriptionDirectory = new File("etc/elasticsearch/");
Expand All @@ -57,7 +57,7 @@ public File getTableDescriptionDirectory()

@Config("elasticsearch.table-description-directory")
@ConfigDescription("Directory that contains JSON table description files")
public ElasticsearchConnectorConfig setTableDescriptionDirectory(File tableDescriptionDirectory)
public ElasticsearchConfig setTableDescriptionDirectory(File tableDescriptionDirectory)
{
this.tableDescriptionDirectory = tableDescriptionDirectory;
return this;
Expand All @@ -71,7 +71,7 @@ public String getDefaultSchema()

@Config("elasticsearch.default-schema-name")
@ConfigDescription("Default schema name to use")
public ElasticsearchConnectorConfig setDefaultSchema(String defaultSchema)
public ElasticsearchConfig setDefaultSchema(String defaultSchema)
{
this.defaultSchema = defaultSchema;
return this;
Expand All @@ -86,7 +86,7 @@ public int getScrollSize()

@Config("elasticsearch.scroll-size")
@ConfigDescription("Scroll batch size")
public ElasticsearchConnectorConfig setScrollSize(int scrollSize)
public ElasticsearchConfig setScrollSize(int scrollSize)
{
this.scrollSize = scrollSize;
return this;
Expand All @@ -100,7 +100,7 @@ public Duration getScrollTimeout()

@Config("elasticsearch.scroll-timeout")
@ConfigDescription("Scroll timeout")
public ElasticsearchConnectorConfig setScrollTimeout(Duration scrollTimeout)
public ElasticsearchConfig setScrollTimeout(Duration scrollTimeout)
{
this.scrollTimeout = scrollTimeout;
return this;
Expand All @@ -114,7 +114,7 @@ public Duration getRequestTimeout()

@Config("elasticsearch.request-timeout")
@ConfigDescription("Elasticsearch request timeout")
public ElasticsearchConnectorConfig setRequestTimeout(Duration requestTimeout)
public ElasticsearchConfig setRequestTimeout(Duration requestTimeout)
{
this.requestTimeout = requestTimeout;
return this;
Expand All @@ -128,7 +128,7 @@ public int getMaxRequestRetries()

@Config("elasticsearch.max-request-retries")
@ConfigDescription("Maximum number of Elasticsearch request retries")
public ElasticsearchConnectorConfig setMaxRequestRetries(int maxRequestRetries)
public ElasticsearchConfig setMaxRequestRetries(int maxRequestRetries)
{
this.maxRequestRetries = maxRequestRetries;
return this;
Expand All @@ -142,7 +142,7 @@ public Duration getMaxRetryTime()

@Config("elasticsearch.max-request-retry-time")
@ConfigDescription("Use exponential backoff starting at 1s up to the value specified by this configuration when retrying failed requests")
public ElasticsearchConnectorConfig setMaxRetryTime(Duration maxRetryTime)
public ElasticsearchConfig setMaxRetryTime(Duration maxRetryTime)
{
this.maxRetryTime = maxRetryTime;
return this;
Expand All @@ -156,7 +156,7 @@ public SearchGuardCertificateFormat getCertificateFormat()

@Config("searchguard.ssl.certificate-format")
@ConfigDescription("Certificate format")
public ElasticsearchConnectorConfig setCertificateFormat(SearchGuardCertificateFormat certificateFormat)
public ElasticsearchConfig setCertificateFormat(SearchGuardCertificateFormat certificateFormat)
{
this.certificateFormat = certificateFormat;
return this;
Expand All @@ -170,7 +170,7 @@ public File getPemcertFilepath()

@Config("searchguard.ssl.pemcert-filepath")
@ConfigDescription("Path to the X.509 node certificate chain")
public ElasticsearchConnectorConfig setPemcertFilepath(File pemcertFilepath)
public ElasticsearchConfig setPemcertFilepath(File pemcertFilepath)
{
this.pemcertFilepath = pemcertFilepath;
return this;
Expand All @@ -184,7 +184,7 @@ public File getPemkeyFilepath()

@Config("searchguard.ssl.pemkey-filepath")
@ConfigDescription("Path to the certificates key file")
public ElasticsearchConnectorConfig setPemkeyFilepath(File pemkeyFilepath)
public ElasticsearchConfig setPemkeyFilepath(File pemkeyFilepath)
{
this.pemkeyFilepath = pemkeyFilepath;
return this;
Expand All @@ -198,7 +198,7 @@ public Optional<String> getPemkeyPassword()
@Config("searchguard.ssl.pemkey-password")
@ConfigDescription("Key password. Omit this setting if the key has no password.")
@ConfigSecuritySensitive
public ElasticsearchConnectorConfig setPemkeyPassword(String pemkeyPassword)
public ElasticsearchConfig setPemkeyPassword(String pemkeyPassword)
{
this.pemkeyPassword = pemkeyPassword;
return this;
Expand All @@ -212,7 +212,7 @@ public File getPemtrustedcasFilepath()

@Config("searchguard.ssl.pemtrustedcas-filepath")
@ConfigDescription("Path to the root CA(s) (PEM format)")
public ElasticsearchConnectorConfig setPemtrustedcasFilepath(File pemtrustedcasFilepath)
public ElasticsearchConfig setPemtrustedcasFilepath(File pemtrustedcasFilepath)
{
this.pemtrustedcasFilepath = pemtrustedcasFilepath;
return this;
Expand All @@ -226,7 +226,7 @@ public File getKeystoreFilepath()

@Config("searchguard.ssl.keystore-filepath")
@ConfigDescription("Path to the keystore file")
public ElasticsearchConnectorConfig setKeystoreFilepath(File keystoreFilepath)
public ElasticsearchConfig setKeystoreFilepath(File keystoreFilepath)
{
this.keystoreFilepath = keystoreFilepath;
return this;
Expand All @@ -240,7 +240,7 @@ public Optional<String> getKeystorePassword()
@Config("searchguard.ssl.keystore-password")
@ConfigDescription("Keystore password")
@ConfigSecuritySensitive
public ElasticsearchConnectorConfig setKeystorePassword(String keystorePassword)
public ElasticsearchConfig setKeystorePassword(String keystorePassword)
{
this.keystorePassword = keystorePassword;
return this;
Expand All @@ -254,7 +254,7 @@ public File getTruststoreFilepath()

@Config("searchguard.ssl.truststore-filepath")
@ConfigDescription("Path to the truststore file")
public ElasticsearchConnectorConfig setTruststoreFilepath(File truststoreFilepath)
public ElasticsearchConfig setTruststoreFilepath(File truststoreFilepath)
{
this.truststoreFilepath = truststoreFilepath;
return this;
Expand All @@ -268,7 +268,7 @@ public Optional<String> getTruststorePassword()
@Config("searchguard.ssl.truststore-password")
@ConfigDescription("Truststore password")
@ConfigSecuritySensitive
public ElasticsearchConnectorConfig setTruststorePassword(String truststorePassword)
public ElasticsearchConfig setTruststorePassword(String truststorePassword)
{
this.truststorePassword = truststorePassword;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void configure(Binder binder)
binder.bind(ElasticsearchSplitManager.class).in(Scopes.SINGLETON);
binder.bind(ElasticsearchRecordSetProvider.class).in(Scopes.SINGLETON);

configBinder(binder).bindConfig(ElasticsearchConnectorConfig.class);
configBinder(binder).bindConfig(ElasticsearchConfig.class);

jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
jsonCodecBinder(binder).bindJsonCodec(ElasticsearchTableDescription.class);
Expand All @@ -55,7 +55,7 @@ public void configure(Binder binder)

@Singleton
@Provides
public static ElasticsearchClient createElasticsearchClient(ElasticsearchConnectorConfig config, ElasticsearchTableDescriptionProvider elasticsearchTableDescriptionProvider)
public static ElasticsearchClient createElasticsearchClient(ElasticsearchConfig config, ElasticsearchTableDescriptionProvider elasticsearchTableDescriptionProvider)
throws IOException
{
return new ElasticsearchClient(elasticsearchTableDescriptionProvider, config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class ElasticsearchQueryBuilder
private final String index;
private final String type;

public ElasticsearchQueryBuilder(List<ElasticsearchColumnHandle> columnHandles, ElasticsearchConnectorConfig config, ElasticsearchSplit split, ElasticsearchTableHandle table)
public ElasticsearchQueryBuilder(List<ElasticsearchColumnHandle> columnHandles, ElasticsearchConfig config, ElasticsearchSplit split, ElasticsearchTableHandle table)
{
requireNonNull(columnHandles, "columnHandles is null");
requireNonNull(config, "config is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public class ElasticsearchRecordCursor
private long totalBytes;
private List<Object> fields;

public ElasticsearchRecordCursor(List<ElasticsearchColumnHandle> columnHandles, ElasticsearchConnectorConfig config, ElasticsearchSplit split, ElasticsearchTableHandle table)
public ElasticsearchRecordCursor(List<ElasticsearchColumnHandle> columnHandles, ElasticsearchConfig config, ElasticsearchSplit split, ElasticsearchTableHandle table)
{
requireNonNull(columnHandles, "columnHandle is null");
requireNonNull(config, "config is null");
Expand Down Expand Up @@ -286,7 +286,7 @@ private static class SearchHitsIterator
private Iterator<SearchHit> searchHits;
private String scrollId;

SearchHitsIterator(ElasticsearchQueryBuilder queryBuilder, ElasticsearchConnectorConfig config)
SearchHitsIterator(ElasticsearchQueryBuilder queryBuilder, ElasticsearchConfig config)
{
this.queryBuilder = queryBuilder;
this.requestTimeout = config.getRequestTimeout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class ElasticsearchRecordSet
private final List<Type> columnTypes;
private final ElasticsearchSplit split;
private final ElasticsearchTableHandle table;
private final ElasticsearchConnectorConfig config;
private final ElasticsearchConfig config;

public ElasticsearchRecordSet(ElasticsearchSplit split, ElasticsearchTableHandle table, ElasticsearchConnectorConfig config, List<ElasticsearchColumnHandle> columnHandles)
public ElasticsearchRecordSet(ElasticsearchSplit split, ElasticsearchTableHandle table, ElasticsearchConfig config, List<ElasticsearchColumnHandle> columnHandles)
{
this.split = requireNonNull(split, "split is null");
this.table = requireNonNull(table, "table is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
public class ElasticsearchRecordSetProvider
implements ConnectorRecordSetProvider
{
private final ElasticsearchConnectorConfig config;
private final ElasticsearchConfig config;

@Inject
public ElasticsearchRecordSetProvider(ElasticsearchConnectorConfig config)
public ElasticsearchRecordSetProvider(ElasticsearchConfig config)
{
this.config = requireNonNull(config, "config is null");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ public class ElasticsearchTableDescriptionProvider
private final Map<SchemaTableName, ElasticsearchTableDescription> tableDefinitions;

@Inject
ElasticsearchTableDescriptionProvider(ElasticsearchConnectorConfig config, JsonCodec<ElasticsearchTableDescription> codec)
ElasticsearchTableDescriptionProvider(ElasticsearchConfig config, JsonCodec<ElasticsearchTableDescription> codec)
{
requireNonNull(config, "config is null");
requireNonNull(codec, "codec is null");
tableDefinitions = createTableDescriptions(config, codec);
}

private Map<SchemaTableName, ElasticsearchTableDescription> createTableDescriptions(ElasticsearchConnectorConfig config, JsonCodec<ElasticsearchTableDescription> codec)
private Map<SchemaTableName, ElasticsearchTableDescription> createTableDescriptions(ElasticsearchConfig config, JsonCodec<ElasticsearchTableDescription> codec)
{
Optional<File[]> files = listFiles(config.getTableDescriptionDirectory());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private static ElasticsearchTableDescriptionProvider createTableDescriptions(Met
JsonCodec<ElasticsearchTableDescription> codec = new CodecSupplier<>(ElasticsearchTableDescription.class, metadata).get();

URL metadataUrl = getResource(ElasticsearchQueryRunner.class, "/queryrunner");
ElasticsearchConnectorConfig config = new ElasticsearchConnectorConfig()
ElasticsearchConfig config = new ElasticsearchConfig()
.setTableDescriptionDirectory(new File(metadataUrl.toURI()))
.setDefaultSchema(TPCH_SCHEMA);
return new ElasticsearchTableDescriptionProvider(config, codec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;

public class TestElasticsearchConnectorConfig
public class TestElasticsearchConfig
{
@Test
public void testDefaults()
{
assertRecordedDefaults(recordDefaults(ElasticsearchConnectorConfig.class)
assertRecordedDefaults(recordDefaults(ElasticsearchConfig.class)
.setTableDescriptionDirectory(new File("etc/elasticsearch/"))
.setDefaultSchema("default")
.setScrollSize(1000)
Expand Down Expand Up @@ -74,7 +74,7 @@ public void testExplicitPropertyMappings()
.put("searchguard.ssl.truststore-password", "333333")
.build();

ElasticsearchConnectorConfig expected = new ElasticsearchConnectorConfig()
ElasticsearchConfig expected = new ElasticsearchConfig()
.setTableDescriptionDirectory(new File("/etc/elasticsearch/"))
.setDefaultSchema("test")
.setScrollSize(4000)
Expand Down

0 comments on commit af89181

Please sign in to comment.