Skip to content

Commit

Permalink
Added configuration parameters for solr connect timeout, solr socket …
Browse files Browse the repository at this point in the history
…timeout Fixes #40 (#41)

Co-authored-by: rameshbx <rameshbx@science.regn.net>
  • Loading branch information
ramyogi and rameshbx authored Jun 10, 2020
1 parent 143bcd7 commit 02fca29
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.iml
target
.okhttpcache
.idea
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>com.github.jcustenborder.kafka.connect</groupId>
<artifactId>kafka-connect-parent</artifactId>
<version>2.2.1-cp1</version>
<version>2.4.0</version>
</parent>
<artifactId>kafka-connect-solr</artifactId>
<version>0.1-SNAPSHOT</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class CloudSolrSinkConnectorConfig extends SolrSinkConnectorConfig {
public static final String ZOOKEEPER_CONNECT_TIMEOUT_CONFIG = "solr.zookeeper.connect.timeout.ms";
public static final String ZOOKEEPER_CLIENT_TIMEOUT_CONFIG = "solr.zookeeper.client.timeout.ms";
public static final String ZOOKEEPER_RETRY_EXPIRY_TIME_CONFIG = "solr.zookeeper.retry.expiry.time.ms";
public static final String SOLR_CONNECT_TIMEOUT_CONFIG = "solr.connect.timeout.ms";
public static final String SOLR_SOCKET_TIMEOUT_CONFIG = "solr.socket.timeout.ms";


private static final String ZOOKEEPER_HOSTS_DOC = "Zookeeper hosts that are used to store solr configuration.";
Expand All @@ -36,12 +38,16 @@ class CloudSolrSinkConnectorConfig extends SolrSinkConnectorConfig {
private static final String ZOOKEEPER_CLIENT_TIMEOUT_DOC = "Set the timeout to the zookeeper ensemble in ms.";
private static final String ZOOKEEPER_RETRY_EXPIRY_TIME_DOC = "This is the time to wait to refetch the " +
"state after getting the same state version from ZK in ms.";
private static final String SOLR_CONNECT_TIMEOUT_DOC = "Set the connect timeout to the solr in ms.";
private static final String SOLR_SOCKET_TIMEOUT_DOC = "Set the solr read timeout on all sockets in ms.";

public final List<String> zookeeperHosts;
public final String zookeeperChroot;
public final int zookeeperConnectTimeoutMs;
public final int zookeeperClientTimeoutMs;
public final int zookeeperRetryExpiryTimeMs;
public final int solrConnectTimeoutMs;
public final int solrSocketTimeoutMs;

protected CloudSolrSinkConnectorConfig(Map<String, String> props) {
super(config(), props);
Expand All @@ -50,6 +56,8 @@ protected CloudSolrSinkConnectorConfig(Map<String, String> props) {
this.zookeeperConnectTimeoutMs = getInt(ZOOKEEPER_CONNECT_TIMEOUT_CONFIG);
this.zookeeperClientTimeoutMs = getInt(ZOOKEEPER_CLIENT_TIMEOUT_CONFIG);
this.zookeeperRetryExpiryTimeMs = getInt(ZOOKEEPER_RETRY_EXPIRY_TIME_CONFIG);
this.solrConnectTimeoutMs = getInt(SOLR_CONNECT_TIMEOUT_CONFIG);
this.solrSocketTimeoutMs = getInt(SOLR_SOCKET_TIMEOUT_CONFIG);
}


Expand Down Expand Up @@ -89,6 +97,20 @@ public static ConfigDef config() {
.group(CONNECTION_GROUP)
.defaultValue(3000)
.build()
).define(
ConfigKeyBuilder.of(SOLR_CONNECT_TIMEOUT_CONFIG, ConfigDef.Type.INT)
.importance(ConfigDef.Importance.LOW)
.documentation(SOLR_CONNECT_TIMEOUT_DOC)
.group(CONNECTION_GROUP)
.defaultValue(15000)
.build()
).define(
ConfigKeyBuilder.of(SOLR_SOCKET_TIMEOUT_CONFIG, ConfigDef.Type.INT)
.importance(ConfigDef.Importance.LOW)
.documentation(SOLR_SOCKET_TIMEOUT_DOC)
.group(CONNECTION_GROUP)
.defaultValue(120000)
.build()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public void start(Map<String, String> settings) {
CloudSolrClient.Builder builder = new CloudSolrClient.Builder();
builder.withZkHost(this.config.zookeeperHosts);
builder.withZkChroot(this.config.zookeeperChroot);
builder.withConnectionTimeout(this.config.solrConnectTimeoutMs);
builder.withSocketTimeout(this.config.solrSocketTimeoutMs);
this.client = builder.build();
this.client.setZkConnectTimeout(this.config.zookeeperConnectTimeoutMs);
this.client.setZkClientTimeout(this.config.zookeeperClientTimeoutMs);
Expand Down

0 comments on commit 02fca29

Please sign in to comment.