From 9c3cfb92f93e5c5f2c54ac5509b87fd39d201f22 Mon Sep 17 00:00:00 2001 From: Mattias Andersson Date: Tue, 10 Mar 2020 01:33:13 +0100 Subject: [PATCH] Issue #4647 Hazelcast remote.xml configuration file do not configure hazelcast remote addresses (#4649) * Fix for #4647 Signed-off-by: Mattias Andersson Co-authored-by: Mattias Andersson --- .../config/etc/sessions/hazelcast/remote.xml | 3 ++- .../session-store-hazelcast-embedded.mod | 1 - .../session-store-hazelcast-remote.mod | 2 +- .../HazelcastSessionDataStoreFactory.java | 20 +++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/jetty-hazelcast/src/main/config/etc/sessions/hazelcast/remote.xml b/jetty-hazelcast/src/main/config/etc/sessions/hazelcast/remote.xml index 908130b4b0d..cf0b516e1e3 100644 --- a/jetty-hazelcast/src/main/config/etc/sessions/hazelcast/remote.xml +++ b/jetty-hazelcast/src/main/config/etc/sessions/hazelcast/remote.xml @@ -5,7 +5,7 @@ - + @@ -16,6 +16,7 @@ + diff --git a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod index 3d8ba5a1174..3b5970948a5 100644 --- a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod +++ b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod @@ -31,7 +31,6 @@ http://www.apache.org/licenses/LICENSE-2.0.html [ini-template] jetty.session.hazelcast.mapName=jetty-distributed-session-map jetty.session.hazelcast.hazelcastInstanceName=JETTY_DISTRIBUTED_SESSION_INSTANCE -#jetty.session.hazelcast.configurationLocation= jetty.session.hazelcast.scavengeZombies=false jetty.session.gracePeriod.seconds=3600 jetty.session.savePeriod.seconds=0 diff --git a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod index e3d67a3d387..9bf4db8f795 100644 --- a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod +++ b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod @@ -34,6 +34,6 @@ jetty.session.hazelcast.mapName=jetty-distributed-session-map jetty.session.hazelcast.hazelcastInstanceName=JETTY_DISTRIBUTED_SESSION_INSTANCE jetty.session.hazelcast.onlyClient=true jetty.session.hazelcast.scavengeZombies=false -#jetty.session.hazelcast.configurationLocation= jetty.session.gracePeriod.seconds=3600 jetty.session.savePeriod.seconds=0 +#jetty.session.hazelcast.addresses= diff --git a/jetty-hazelcast/src/main/java/org/eclipse/jetty/hazelcast/session/HazelcastSessionDataStoreFactory.java b/jetty-hazelcast/src/main/java/org/eclipse/jetty/hazelcast/session/HazelcastSessionDataStoreFactory.java index e8087e14b5d..6c9bed49ed7 100644 --- a/jetty-hazelcast/src/main/java/org/eclipse/jetty/hazelcast/session/HazelcastSessionDataStoreFactory.java +++ b/jetty-hazelcast/src/main/java/org/eclipse/jetty/hazelcast/session/HazelcastSessionDataStoreFactory.java @@ -19,6 +19,7 @@ package org.eclipse.jetty.hazelcast.session; import java.io.IOException; +import java.util.Arrays; import com.hazelcast.client.HazelcastClient; import com.hazelcast.client.config.ClientConfig; @@ -29,6 +30,7 @@ import com.hazelcast.config.SerializerConfig; import com.hazelcast.config.XmlConfigBuilder; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; + import org.eclipse.jetty.server.session.AbstractSessionDataStoreFactory; import org.eclipse.jetty.server.session.SessionData; import org.eclipse.jetty.server.session.SessionDataStore; @@ -57,6 +59,8 @@ public class HazelcastSessionDataStoreFactory private boolean scavengeZombies = false; + private String addresses; + public boolean isScavengeZombies() { return scavengeZombies; @@ -82,6 +86,12 @@ public class HazelcastSessionDataStoreFactory if (configurationLocation == null) { ClientConfig config = new ClientConfig(); + + if (addresses != null && !addresses.isEmpty()) + { + config.getNetworkConfig().setAddresses(Arrays.asList(addresses.split(","))); + } + SerializerConfig sc = new SerializerConfig() .setImplementation(new SessionDataSerializer()) .setTypeClass(SessionData.class); @@ -202,4 +212,14 @@ public class HazelcastSessionDataStoreFactory { this.hazelcastInstanceName = hazelcastInstanceName; } + + public String getAddresses() + { + return addresses; + } + + public void setAddresses(String addresses) + { + this.addresses = addresses; + } }