3.8.1을 사용하고 있는데, 멤버가 반송 된 후 클라이언트 주변의 재 연결 동작에 대해 약간의 문제가 나타났습니다. 재 연결 시도를 설정 했음에도 불구하고 클라이언트는 클러스터 연결을 얻을 수 없다는 반복적 인 경고를 로깅 한 후 어쨌든 연결을 끊습니다. 이는 항상 최소한 하나의 살아남은 구성원이 항상 있음에도 불구하고 있습니다.Hazelcast는 멤버가 다시 시작된 후 클라이언트 연결을 종료합니다.
그러면 연결이 끊어지는 이유는 무엇입니까? 나는 살아있는 회원이 적어도 한 명이라면 어떤 클라이언트도 연결을 끊어야한다고 믿습니다. 회원이 반송 한 후 클라이언트가 반복적으로 기록하고 경고하는 이유는 무엇입니까?
테스트 : 2 명의 회원이 가입했습니다. tcp를 통해 두 멤버에 연결하는 클라이언트가 3 대 있습니다. 클라이언트가 1000 회 다시 연결하도록 구성되었습니다. 클라이언트 1이 반복되고 단순히 임의의 값을 동일한 키에 넣습니다. 클라이언트 2 & 3이 맵의 리스너이며 업데이트를 로깅합니다.
단계 : 시작 멤버 1, 멤버 2 클라이언트 2, 3 (청취자)을 모두 시작하십시오. 클라이언트 1 (작성자)을 시작하십시오. 이 시점에서 모든 것이 정상입니다. 로그에 경고가 없습니다.
반송 멤버 1이 시작될 때까지 기다립니다.
Put 29: d16b0acd-d0d6-4722-b511-7fd975774f8c
May 10, 2017 11:41:10 AM com.hazelcast.client.spi.impl.ClusterListenerSupport
WARNING: hz.client_0 [dev] [3.8.1] Unable to get alive cluster connection, try in 0 ms later, attempt 4 of 1000.
May 10, 2017 11:41:10 AM com.hazelcast.client.spi.impl.ClusterListenerSupport
INFO: hz.client_0 [dev] [3.8.1] Trying to connect to [127.0.0.1]:5701 as owner member
Put 30: f91ec949-19bd-4039-95d3-28c7abd0f241
May 10, 2017 11:41:15 AM com.hazelcast.client.spi.impl.ClusterListenerSupport
INFO: hz.client_0 [dev] [3.8.1] Trying to connect to [127.0.0.1]:5702 as owner member
Put 31: 2af9fb36-d501-4b0b-9fc8-6b36d467a929
May 10, 2017 11:41:20 AM com.hazelcast.client.spi.impl.ClusterListenerSupport
INFO: hz.client_0 [dev] [3.8.1] Trying to connect to [127.0.0.1]:5701 as owner member
Put 32: f08bd6ca-a79f-44f4-9064-42e47953c37a
클라이언트가 여전히 작동하고 이벤트에 BUT 기간 후에 청취 할 수있다, 그들은 종종 분리 : 반송 부재 (2) 반송 부재 (1)
는 아니 항상,하지만 종종, 고객이보고 :
May 10, 2017 11:25:04 AM com.hazelcast.core.LifecycleService
INFO: hz.client_0 [dev] [3.8.1] HazelcastClient 3.8.1 (20170411 - f1e9264) is SHUTTING_DOWN
May 10, 2017 11:25:04 AM com.hazelcast.client.connection.ClientConnectionManager
INFO: hz.client_0 [dev] [3.8.1] Removed connection to endpoint: [localhost]:5701, connection: ClientConnection{alive=false, connectionId=5, socketChannel=DefaultSocketChannelWrapper{socketChannel=java.nio.channels.SocketChannel[closed]}, remoteEndpoint=[localhost]:5701, lastReadTime=2017-05-10 11:25:04.021, lastWriteTime=2017-05-10 11:25:04.084, closedTime=2017-05-10 11:25:04.084, lastHeartbeatRequested=2017-05-10 11:25:03.834, lastHeartbeatReceived=2017-05-10 11:25:03.834, connected server version=3.8.1}
May 10, 2017 11:25:04 AM com.hazelcast.client.connection.ClientConnectionManager
INFO: hz.client_0 [dev] [3.8.1] Removed connection to endpoint: [localhost]:5702, connection: ClientConnection{alive=false, connectionId=6, socketChannel=DefaultSocketChannelWrapper{socketChannel=java.nio.channels.SocketChannel[closed]}, remoteEndpoint=[localhost]:5702, lastReadTime=2017-05-10 11:24:59.513, lastWriteTime=2017-05-10 11:25:04.084, closedTime=2017-05-10 11:25:04.084, lastHeartbeatRequested=2017-05-10 11:17:43.840, lastHeartbeatReceived=2017-05-10 11:17:43.840, connected server version=3.8.1}
May 10, 2017 11:25:04 AM com.hazelcast.core.LifecycleService
INFO: hz.client_0 [dev] [3.8.1] HazelcastClient 3.8.1 (20170411 - f1e9264) is SHUTDOWN
클라이언트 차단 :
INFO: hz.client_0 [dev] [3.8.1] Removed connection to endpoint: [localhost]:5701, connection: ClientConnection{alive=false, connectionId=8, socketChannel=DefaultSocketChannelWrapper{socketChannel=java.nio.channels.SocketChannel[closed]}, remoteEndpoint=[localhost]:5701, lastReadTime=2017-05-10 11:45:31.791, lastWriteTime=2017-05-10 11:45:31.791, closedTime=2017-05-10 11:45:31.791, lastHeartbeatRequested=2017-05-10 11:45:23.604, lastHeartbeatReceived=2017-05-10 11:45:23.605, connected server version=3.8.1}
May 10, 2017 11:45:31 AM com.hazelcast.core.LifecycleService
INFO: hz.client_0 [dev] [3.8.1] HazelcastClient 3.8.1 (20170411 - f1e9264) is CLIENT_DISCONNECTED
,개
회원 보고서 :
May 10, 2017 11:47:32 AM com.hazelcast.client.impl.protocol.task.AuthenticationMessageTask
WARNING: [localhost]:5701 [dev] [3.8.1] Member having uuid 8847c2e3-2fcb-428f-a827-d0e24f5624a1 is not part of the cluster. Client Authentication rejected.
May 10, 2017 11:47:32 AM com.hazelcast.client.impl.protocol.task.AuthenticationMessageTask
WARNING: [localhost]:5701 [dev] [3.8.1] Received auth from Connection[id=222, /127.0.0.1:5701->/127.0.0.1:53883, endpoint=null, alive=true, type=NONE] with principal ClientPrincipal{uuid='f1e5d928-23b2-4fdf-bd3f-9db1778a5a8c', ownerUuid='8847c2e3-2fcb-428f-a827-d0e24f5624a1'} , authentication failed
차 회원 :
public class HzNodeTest {
private HazelcastInstance service;
@Before
public void setUp() throws Exception {
Config config = new Config();
JoinConfig join = config.getNetworkConfig().setPort(5701).getJoin();
join.getMulticastConfig().setEnabled(false);
join.getAwsConfig().setEnabled(false);
join.getTcpIpConfig().addMember("localhost:5701").addMember("localhost:5702").setEnabled(true);
service = Hazelcast.newHazelcastInstance(config);
}
@After
public void tearDown() throws Exception {
service.shutdown();
}
@Test
public void testStart() throws InterruptedException {
Thread.sleep(1000000000);
}
}
Secondary member:
public class HzNodeSecondaryTest {
private HazelcastInstance service;
@Before
public void setUp() throws Exception {
Config config = new Config();
JoinConfig join = config.getNetworkConfig().setPort(5702).getJoin();
join.getMulticastConfig().setEnabled(false);
join.getAwsConfig().setEnabled(false);
join.getTcpIpConfig().addMember("localhost:5701").addMember("localhost:5702").setEnabled(true);
service = Hazelcast.newHazelcastInstance(config);
}
@After
public void tearDown() throws Exception {
service.shutdown();
}
@Test
public void testStart() throws InterruptedException {
Thread.sleep(1000000000);
}
}
Listener:
public class HzListenerTest {
private HazelcastInstance service;
private AtomicLong counter = new AtomicLong();
@Before
public void setUp() throws Exception {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().addAddress("localhost:5701").addAddress("localhost:5702").setConnectionAttemptLimit(1000);
service = HazelcastClient.newHazelcastClient(clientConfig);
}
@After
public void tearDown() throws Exception {
service.shutdown();
}
@Test
public void testListen() throws InterruptedException {
service.getMap("TEST").addEntryListener(new Listener(), true);
Thread.sleep(1000000);
}
private class Listener implements EntryAddedListener, EntryUpdatedListener, EntryRemovedListener,
EntryEvictedListener {
@Override
public void entryAdded(EntryEvent event) {
System.out.println("onAdded " + counter.getAndIncrement() + ": " + event);
}
@Override
public void entryEvicted(EntryEvent event) {
System.out.println("onEvicted " + counter.getAndIncrement() + ": " + event);
}
@Override
public void entryRemoved(EntryEvent event) {
System.out.println("onRemoved " + counter.getAndIncrement() + ": " + event);
}
@Override
public void entryUpdated(EntryEvent event) {
System.out.println("onUpdated " + counter.getAndIncrement() + ": "+ event);
}
}
}
Updater:
public class HzUpdaterTest {
private HazelcastInstance service;
@Before
public void setUp() throws Exception {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().addAddress("localhost:5701").addAddress("localhost:5702").setConnectionAttemptLimit(1000);
service = HazelcastClient.newHazelcastClient(clientConfig);
service.getMap("TEST").put("1", UUID.randomUUID().toString());
}
@After
public void tearDown() throws Exception {
service.shutdown();
}
@Test
public void testSpin() {
for (int i = 0; i < 10000; i++) {
try {
String value = UUID.randomUUID().toString();
service.getMap("TEST").put("1", value);
System.out.println("Put " + i + ": " + value);
Thread.sleep(5000);
} catch (Exception ex) {
System.out.println(ex);
}
}
}
}