Skip to content

Commit

Permalink
Issue #4647 Hazelcast remote.xml configuration file do not configure …
Browse files Browse the repository at this point in the history
…hazelcast remote addresses (#4649)

* Fix for #4647

Signed-off-by: Mattias Andersson <andermaj@gmail.com>

Co-authored-by: Mattias Andersson <andermaj@gmail.com>
  • Loading branch information
2 people authored and olamy committed Mar 10, 2020
1 parent 67eb9b3 commit 82247f2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<!-- ===================================================================== -->
<!-- Configure a factory for HazelcastSessionDataStore using -->
<!-- an embedded Hazelcast Instance -->
<!-- an remote Hazelcast Instance -->
<!-- ===================================================================== -->
<Call name="addBean">
<Arg>
Expand All @@ -15,6 +15,7 @@
<Set name="gracePeriodSec"><Property name="jetty.session.gracePeriod.seconds" default="3600" /></Set>
<Set name="savePeriodSec"><Property name="jetty.session.savePeriod.seconds" default="0" /></Set>
<Set name="onlyClient"><Property name="jetty.session.hazelcast.onlyClient" default="true" /></Set>
<Set name="addresses"><Property name="jetty.session.hazelcast.addresses" default="" /></Set>
</New>
</Arg>
</Call>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +30,7 @@
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;
Expand Down Expand Up @@ -57,6 +59,8 @@ public class HazelcastSessionDataStoreFactory

private boolean scavengeZombies = false;

private String addresses;

public boolean isScavengeZombies()
{
return scavengeZombies;
Expand All @@ -81,6 +85,12 @@ public SessionDataStore getSessionDataStore(SessionHandler handler)
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);
Expand Down Expand Up @@ -201,4 +211,14 @@ public void setHazelcastInstanceName(String hazelcastInstanceName)
{
this.hazelcastInstanceName = hazelcastInstanceName;
}

public String getAddresses()
{
return addresses;
}

public void setAddresses(String addresses)
{
this.addresses = addresses;
}
}

0 comments on commit 82247f2

Please sign in to comment.