Hello,
I have created an Hazelcast cluster using EC2-auto-discovery mechanism in AWS.
But when I try to write something in a distributed map using Hazelcast client it gives exception.
I haven't came across such error in past. I don't know what's going wrong this time.
I have configured appropriate security rules to allow tcp requests on port 5701.
For brevity, I am mentioning below client code only.
================
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.client.config.ClientNetworkConfig;
import com.hazelcast.core.HazelcastInstance;
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Level;
import java.util.logging.Logger;
public class TestSimpleWriteReadOperartion {
public static void main(String[] args) {
Logger logger = Logger.getLogger("TestSimpleWriteReadOperartion");
ClientNetworkConfig clientNetworkConfig = new ClientNetworkConfig();
ClientConfig clientConfig = new ClientConfig();
clientConfig.setNetworkConfig(clientNetworkConfig);
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
try {
logger.log(Level.INFO, "client created {0}", client);
ConcurrentMap<Integer, String> testHzMap = client.getMap("testmap");
int testKey = 1;
String testValue = Integer.toString(testKey);
testHzMap.put(testKey, testValue);
logger.log(Level.INFO, "done with put");
String readValue = testHzMap.get(testKey);
logger.log(Level.INFO, "done with get");
if (readValue.equals(testValue)) {
logger.log(Level.INFO, "success");
} else {
logger.log(Level.INFO, "fail");
}
} finally {
client.shutdown();
}
}
}
================
The logs are:
================
Apr 11, 2016 4:21:15 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is STARTING
Apr 11, 2016 4:21:15 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is STARTED
Apr 11, 2016 4:21:16 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is CLIENT_CONNECTED
Apr 11, 2016 4:21:16 PM com.hazelcast.client.spi.impl.ClientMembershipListener
INFO:
Members [3] {
Member [172.31.18.123]:5701
Member [172.31.29.238]:5701
Member [172.31.29.239]:5701
}
Apr 11, 2016 4:21:16 PM TestSimpleWriteReadOperartion main
INFO: client created com.hazelcast.client.impl.HazelcastClientInstanceImpl@7c0c77c7
Apr 11, 2016 4:23:18 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is SHUTTING_DOWN
Apr 11, 2016 4:23:23 PM com.hazelcast.core.LifecycleService
INFO: HazelcastClient[hz.client_0_dev][3.6] is SHUTDOWN
Exception in thread "main" com.hazelcast.core.HazelcastException: java.io.IOException: No available connection to address Address[172.31.29.238]:5701
at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:73)
at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:63)
at com.hazelcast.util.ExceptionUtil.peel(ExceptionUtil.java:52)
at com.hazelcast.util.ExceptionUtil.rethrow(ExceptionUtil.java:83)
at com.hazelcast.client.spi.ClientProxy.invokeOnPartition(ClientProxy.java:128)
at com.hazelcast.client.spi.ClientProxy.invoke(ClientProxy.java:120)
at com.hazelcast.client.proxy.ClientMapProxy.putInternal(ClientMapProxy.java:411)
at com.hazelcast.client.proxy.ClientMapProxy.put(ClientMapProxy.java:405)
at com.hazelcast.client.proxy.ClientMapProxy.put(ClientMapProxy.java:233)
at TestSimpleWriteReadOperartion.main(TestSimpleWriteReadOperartion.java:28)
================
If it can form a client successfully, then why should it refuse connection during map put operation?
Best Regards,
Manoj