Skip to content

feat(exporter): define remote connection timeout #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,30 @@ The values can be overridden by environment variables with the same name and a `

By default, the exporter creates an in-memory Hazelcast instance and publishes the records to it. But it can also be configured to export the records to a remote/external Hazecast instance by setting the argument `remoteAddress` or the environment variable `ZEEBE_HAZELCAST_REMOTE_ADDRESS` to the address of the remote Hazelcast instance.

* the remote Hazelcast address
* the remote Hazelcast cluster name
* the connection timeout

Default values:

```
zeebe:
broker:
exporters:
hazelcast:
className: io.zeebe.hazelcast.exporter.HazelcastExporter
jarPath: exporters/zeebe-hazelcast-exporter.jar
args:
# remote Hazelcast address
remoteAddress = 127.0.0.1:5702

# Hazelcast cluster name
clusterName = "dev"

# connection timeout
remoteConnectionTimeout = "PT30S"
```

<details>
<summary>Full docker-compose.yml with external Hazelcast</summary>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ public class ExporterConfiguration {

private int port = 5701;

private String remoteAddress;

private String clusterName = "dev";

private String name = "zeebe";
Expand All @@ -22,6 +20,9 @@ public class ExporterConfiguration {
private String enabledValueTypes = "";
private String enabledRecordTypes = "";

private String remoteAddress;
private String remoteConnectionTimeout = "PT30S";

public int getPort() {
return getEnv("PORT").map(Integer::parseInt).orElse(port);
}
Expand Down Expand Up @@ -60,6 +61,10 @@ public String getClusterName() {
return getEnv("CLUSTER_NAME").orElse(clusterName);
}

public String getRemoteConnectionTimeout() {
return getEnv("REMOTE_CONNECTION_TIMEOUT").orElse(remoteConnectionTimeout);
}

private Optional<String> getEnv(String name) {
return Optional.ofNullable(System.getenv(ENV_PREFIX + name));
}
Expand All @@ -84,6 +89,8 @@ public String toString() {
+ timeToLiveInSeconds
+ ", format="
+ format
+ ", remoteConnectionTimeout="
+ remoteConnectionTimeout
+ "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.zeebe.exporter.proto.Schema;
import org.slf4j.Logger;

import java.time.Duration;
import java.util.function.Function;

public class HazelcastExporter implements Exporter {
Expand Down Expand Up @@ -116,11 +117,15 @@ private HazelcastInstance connectToHazelcast(String remoteAddress) {

final var clientConfig = new ClientConfig();
clientConfig.setProperty("hazelcast.logging.type", "slf4j");
clientConfig.setClusterName(clusterName);

final var networkConfig = clientConfig.getNetworkConfig();
networkConfig.addAddress(remoteAddress);

clientConfig.setClusterName(clusterName);
final var connectionRetryConfig =
clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig();
final var connectionTimeout = Duration.parse(this.config.getRemoteConnectionTimeout());
connectionRetryConfig.setClusterConnectTimeoutMillis(connectionTimeout.toMillis());

logger.info(
"Connecting to remote Hazelcast instance [address: {}, cluster-name: {}]",
Expand Down