Skip to content

Instantly share code, notes, and snippets.

@xymor
Created December 18, 2018 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xymor/db65c57132992da3e5d1463b2847af72 to your computer and use it in GitHub Desktop.
Save xymor/db65c57132992da3e5d1463b2847af72 to your computer and use it in GitHub Desktop.
connect to aws hazelcast cluster
@Grab('com.hazelcast:hazelcast:3.7.4')
@Grab('com.hazelcast:hazelcast-aws:2.1.0')
import com.hazelcast.config.*
import com.hazelcast.core.Hazelcast
import com.hazelcast.spi.discovery.impl.*
import com.hazelcast.aws.*
import com.hazelcast.core.ILock
Config config = new Config();
config.getGroupConfig().setName("name").setPassword("pwd")
JoinConfig joinConfig = config.getNetworkConfig().getJoin();
joinConfig.getTcpIpConfig().setEnabled(false);
joinConfig.getMulticastConfig().setEnabled(false);
def aws = joinConfig.getAwsConfig()
aws.setEnabled(true)
aws.setRegion("sa-east-1")
aws.setSecretKey("secret")
aws.setAccessKey("access")
aws.setSecurityGroupName()
aws.setTagKey("hazelcast")
aws.setTagValue("value")
def instance = Hazelcast.newHazelcastInstance(config);
println instance.getDistributedObjects()
instance.getDistributedObjects().forEach{
println it.name
}
//instance.lifecycleService.shutdown()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment