configuration continues
Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/1d550403 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/1d550403 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/1d550403 Branch: refs/heads/curator-rpc Commit: 1d550403b759901d782ec98b4e25daf850d2f672 Parents: 8fd1bc8 Author: randgalt <randg...@apache.org> Authored: Wed May 28 08:34:22 2014 -0500 Committer: randgalt <randg...@apache.org> Committed: Wed May 28 08:34:22 2014 -0500 ---------------------------------------------------------------------- .../org/apache/curator/x/rpc/Configuration.java | 37 ------------ .../curator/x/rpc/CuratorProjectionServer.java | 1 + .../x/rpc/configuration/Configuration.java | 53 +++++++++++++++++ .../configuration/ConnectionConfiguration.java | 61 ++++++++++++++++++++ .../ExponentialBackoffRetryConfiguration.java | 44 ++++++++++++++ .../curator/x/rpc/configuration/RetryType.java | 6 ++ 6 files changed, 165 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/1d550403/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/Configuration.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/Configuration.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/Configuration.java deleted file mode 100644 index ea361b3..0000000 --- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/Configuration.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.apache.curator.x.rpc; - -import com.facebook.swift.service.ThriftServerConfig; -import io.airlift.configuration.Config; -import io.airlift.configuration.ConfigDescription; -import io.airlift.units.Duration; -import java.util.concurrent.TimeUnit; - -public class Configuration extends ThriftServerConfig -{ - private Duration projectionExpiration = new Duration(3, TimeUnit.MINUTES); - private Duration pingTime = new Duration(5, TimeUnit.SECONDS); - - public Duration getProjectionExpiration() - { - return projectionExpiration; - } - - @Config("curator.projection-expiration") - @ConfigDescription("Curator projection instances will be expired after this amount of inactivity - default is 3 minutes") - public void setProjectionExpiration(Duration projectionExpiration) - { - this.projectionExpiration = projectionExpiration; - } - - public Duration getPingTime() - { - return pingTime; - } - - @Config("curator.ping-time") - @ConfigDescription("Calls to getNextEvent() will return PING after this duration - default is 5 seconds") - public void setPingTime(Duration pingTime) - { - this.pingTime = pingTime; - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/1d550403/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java index 6083339..bf92cde 100644 --- a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java +++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/CuratorProjectionServer.java @@ -32,6 +32,7 @@ import io.airlift.log.Logging; import io.airlift.log.LoggingConfiguration; import io.airlift.units.DataSize; import io.airlift.units.Duration; +import org.apache.curator.x.rpc.configuration.Configuration; import org.apache.curator.x.rpc.idl.event.EventService; import org.apache.curator.x.rpc.idl.projection.CuratorProjectionService; import org.slf4j.Logger; http://git-wip-us.apache.org/repos/asf/curator/blob/1d550403/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/Configuration.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/Configuration.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/Configuration.java new file mode 100644 index 0000000..799ab9b --- /dev/null +++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/Configuration.java @@ -0,0 +1,53 @@ +package org.apache.curator.x.rpc.configuration; + +import com.facebook.swift.service.ThriftServerConfig; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; +import io.airlift.configuration.Config; +import io.airlift.configuration.ConfigDescription; +import io.airlift.units.Duration; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public class Configuration extends ThriftServerConfig +{ + private Duration projectionExpiration = new Duration(3, TimeUnit.MINUTES); + private Duration pingTime = new Duration(5, TimeUnit.SECONDS); + private List<String> connectionNames = ImmutableList.of(); + + public Duration getProjectionExpiration() + { + return projectionExpiration; + } + + @Config("curator.projection-expiration") + @ConfigDescription("Curator projection instances will be expired after this amount of inactivity - default is 3 minutes") + public void setProjectionExpiration(Duration projectionExpiration) + { + this.projectionExpiration = projectionExpiration; + } + + public Duration getPingTime() + { + return pingTime; + } + + @Config("curator.ping-time") + @ConfigDescription("Calls to getNextEvent() will return PING after this duration - default is 5 seconds") + public void setPingTime(Duration pingTime) + { + this.pingTime = pingTime; + } + + public List<String> getConnectionNames() + { + return connectionNames; + } + + @Config("curator.connection.names") + public void setConnectionNames(String connectionNames) + { + this.connectionNames = Splitter.on(",").trimResults().splitToList(connectionNames); + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/1d550403/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/ConnectionConfiguration.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/ConnectionConfiguration.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/ConnectionConfiguration.java new file mode 100644 index 0000000..8209c6a --- /dev/null +++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/ConnectionConfiguration.java @@ -0,0 +1,61 @@ +package org.apache.curator.x.rpc.configuration; + +import io.airlift.configuration.Config; +import io.airlift.configuration.ConfigDescription; +import io.airlift.units.Duration; +import java.util.concurrent.TimeUnit; + +public class ConnectionConfiguration +{ + private String connectionString = "localhost:2181"; + private Duration sessionLength = new Duration(1, TimeUnit.MINUTES); + private Duration connectionTimeout = new Duration(15, TimeUnit.SECONDS); + private RetryType retryType; + + public String getConnectionString() + { + return connectionString; + } + + @Config("curator.connection.$CONNECTION-NAME$.connection-string") + @ConfigDescription("Default ZooKeeper connection string. E.g. \"foo.com:2181,bar.com:2181\"") + public void setConnectionString(String connectionString) + { + this.connectionString = connectionString; + } + + public Duration getSessionLength() + { + return sessionLength; + } + + @Config("curator.connection.$CONNECTION-NAME$.session-length") + @ConfigDescription("Session length. Default is 1 minute") + public void setSessionLength(Duration sessionLength) + { + this.sessionLength = sessionLength; + } + + public Duration getConnectionTimeout() + { + return connectionTimeout; + } + + @Config("curator.connection.$CONNECTION-NAME$.connection-timeout") + @ConfigDescription("Connection timeout. Default is 15 seconds") + public void setConnectionTimeout(Duration connectionTimeout) + { + this.connectionTimeout = connectionTimeout; + } + + public RetryType getRetryType() + { + return retryType; + } + + @Config("curator.connection.$CONNECTION-NAME$.retry.type") + public void setRetryType(RetryType retryType) + { + this.retryType = retryType; + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/1d550403/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/ExponentialBackoffRetryConfiguration.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/ExponentialBackoffRetryConfiguration.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/ExponentialBackoffRetryConfiguration.java new file mode 100644 index 0000000..41b8db8 --- /dev/null +++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/ExponentialBackoffRetryConfiguration.java @@ -0,0 +1,44 @@ +package org.apache.curator.x.rpc.configuration; + +import io.airlift.configuration.Config; +import io.airlift.units.Duration; + +public class ExponentialBackoffRetryConfiguration +{ + private Duration baseSleepTime; + private int maxRetries; + private Duration maxSleep; + + public Duration getBaseSleepTime() + { + return baseSleepTime; + } + + @Config("curator.retry.exponential.base-sleep-time") + public void setBaseSleepTime(Duration baseSleepTime) + { + this.baseSleepTime = baseSleepTime; + } + + public int getMaxRetries() + { + return maxRetries; + } + + @Config("curator.retry.exponential.max-retries") + public void setMaxRetries(int maxRetries) + { + this.maxRetries = maxRetries; + } + + public Duration getMaxSleep() + { + return maxSleep; + } + + @Config("curator.retry.exponential.max-sleep") + public void setMaxSleep(Duration maxSleep) + { + this.maxSleep = maxSleep; + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/1d550403/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/RetryType.java ---------------------------------------------------------------------- diff --git a/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/RetryType.java b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/RetryType.java new file mode 100644 index 0000000..7e4761a --- /dev/null +++ b/curator-x-rpc/src/main/java/org/apache/curator/x/rpc/configuration/RetryType.java @@ -0,0 +1,6 @@ +package org.apache.curator.x.rpc.configuration; + +public enum RetryType +{ + ExponentialBackoffRetry, +}