diff options
author | 2016-07-15 14:13:58 +0000 | |
---|---|---|
committer | 2016-07-18 10:42:18 +0000 | |
commit | 2c12327885113878ce63afef2f15e8c2b075c0c3 (patch) | |
tree | 43b24dadebe7f993bd1d6a16ca3ebf7bdc94987e /src/main/java/com/google/devtools/build/lib | |
parent | 74cb8c7d6ae2462006e983b8baafd50c884d1d8d (diff) |
Add support for Hazelcast configuration file
--
Change-Id: I3255a14a60b7ae7749c49d5a885d92f4f19ec84f
Reviewed-on: https://bazel-review.git.corp.google.com/#/c/3980/
MOS_MIGRATED_REVID=127537367
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib')
3 files changed, 20 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java b/src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java index af7da29be6..b135f67b6b 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java +++ b/src/main/java/com/google/devtools/build/lib/remote/HazelcastCacheFactory.java @@ -17,10 +17,12 @@ package com.google.devtools.build.lib.remote; import com.hazelcast.client.HazelcastClient; import com.hazelcast.client.config.ClientConfig; import com.hazelcast.client.config.ClientNetworkConfig; +import com.hazelcast.client.config.XmlClientConfigBuilder; import com.hazelcast.config.Config; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; +import java.io.IOException; import java.util.concurrent.ConcurrentMap; /** @@ -33,7 +35,14 @@ public final class HazelcastCacheFactory { public static ConcurrentMap<String, byte[]> create(RemoteOptions options) { HazelcastInstance instance; - if (options.hazelcastNode != null) { + if (options.hazelcastClientConfig != null) { + try { + ClientConfig config = new XmlClientConfigBuilder(options.hazelcastClientConfig).build(); + instance = HazelcastClient.newHazelcastClient(config); + } catch (IOException e) { + throw new RuntimeException(e); + } + } else if (options.hazelcastNode != null) { // If --hazelcast_node is then create a client instance. ClientConfig config = new ClientConfig(); ClientNetworkConfig net = config.getNetworkConfig(); diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java index ff772217b4..32e08615b9 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java @@ -63,7 +63,8 @@ public final class RemoteModule extends BlazeModule { RemoteOptions options = buildRequest.getOptions(RemoteOptions.class); // Don't provide the remote spawn unless at least action cache is initialized. - if (actionCache == null && options.hazelcastNode != null) { + if (actionCache == null + && (options.hazelcastNode != null || options.hazelcastClientConfig != null)) { MemcacheActionCache cache = new MemcacheActionCache( this.env.getDirectories().getExecRoot(), diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java index 4116a931b0..da8c3b935d 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteOptions.java @@ -30,6 +30,14 @@ public final class RemoteOptions extends OptionsBase { public String hazelcastNode; @Option( + name = "hazelcast_client_config", + defaultValue = "null", + category = "remote", + help = "A file path to a hazelcast client config XML file. For client mode only." + ) + public String hazelcastClientConfig; + + @Option( name = "hazelcast_standalone_listen_port", defaultValue = "0", category = "build_worker", |