Hazelcast 是否支持这种 3 节点网络分区?
Does Hazelcast support this 3 node network partition?
我正在使用 hazelcast 3.11 并测试以下网络情况。
A
/ \
B C
其中A和B双向相连,A和C双向相连,B和C断开。通常所有节点都已连接,因此我使用 TcpIp 配置以编程方式为每个节点配置每个 IP。
当我介绍网络故障时,节点B怀疑节点C,因为它没有发送任何心跳,然后紧接着又怀疑节点A,原因"explicit suspicion"。
节点C怀疑节点B,因为它没有发送任何心跳。它与节点 A 位于同一集群中。
"explicit suspicion" Hazelcast 的方法是创建 2 个完全连接的分区而不是 1 个不完全连接的分区吗?有没有办法将 Hazelcast 配置为出现这种类型的网络故障并保持 A 连接到 A 和 C?
附带说明一下,我只对使用 ReplicatedMap 和分布式事件 API 感兴趣。
编辑:以下代码在名为 A、B 和 C 的 3 台服务器中的每台服务器上 运行 一次。它们每个都是 运行ning 一次 hazelcast 实例。
public HazelcastInstance getHazelcastInstance() {
Config config = new Config();
config
.getGroupConfig( )
.setName( localFacility.getName() )
.setPassword( clusterPassword );
NetworkConfig networkConfig = config.getNetworkConfig();
//Disable multicast
JoinConfig joinConfig = networkConfig.getJoin();
joinConfig
.getMulticastConfig()
.setEnabled( false );
// Interface config
InterfacesConfig interfaceConfig = networkConfig.getInterfaces();
IntraFacilityProperties intrafacilityProperties = facilityPropertiesUtil.getCurrentIntrafacilityProperties();
String primaryHostname = intrafacilityProperties.getHostname();
String secondaryHostname = intrafacilityProperties.getBackupHostname();
try {
InetAddress primaryIp = InetAddress.getByName( primaryHostname );
InetAddress secondaryIp = InetAddress.getByName( secondaryHostname );
// Specify which network interfaces to use based on the configured hostnames
interfaceConfig
.setEnabled( true )
.addInterface( primaryIp.getHostAddress() )
.addInterface( secondaryIp.getHostAddress() );
} catch ( UnknownHostException e ) {
if ( logger.isErrorEnabled() ) {
logger.error( "Caught UnknownHostException", e );
}
throw new HazelcastInstantiationException( e.getMessage() );
}
//Enable the tcp ip config.
TcpIpConfig ipConfig = joinConfig.getTcpIpConfig();
ipConfig.setEnabled( true );
try{
// Loops through all servers regardless of which server this is.
for( IntraFacilityProperties member : facilityPropertiesUtil.getIntraFacilityProperties() ) {
ipConfig.addMember( InetAddress.getByName( member.getHostname() ).getHostAddress() );
ipConfig.addMember( InetAddress.getByName( member.getBackupHostname() ).getHostAddress() );
}
} catch( UnknownHostException e ) {
if ( logger.isErrorEnabled() ) {
logger.error( "Caught UnknownHostException", e );
}
throw new HazelcastInstantiationException( e.getMessage() );
}
ReplicatedMapConfig repMapCfg = new ReplicatedMapConfig();
repMapCfg.setName( "default" )
.setMergePolicyConfig( new MergePolicyConfig()
.setPolicy( "LatestAccessMergePolicy" ) );
config.addReplicatedMapConfig( repMapCfg );
config.setProperty( "hazelcast.heartbeat.failuredetector.type", "deadline" );
config.setProperty( "hazelcast.heartbeat.interval.seconds", hzHeartbeatInterval );
config.setProperty( "hazelcast.max.no.heartbeat.seconds", hzHeartbeatTimeout );
config.setProperty( "hazelcast.merge.first.run.delay.seconds", hzMergeFirstDelay );
config.setProperty( "hazelcast.merge.next.run.delay.seconds", hzMergeNextDelay );
return Hazelcast.newHazelcastInstance( config );
}
由于您的混合网络分区与 node.一个节点要么是集群的成员,要么不是。您是在这里专门询问网络路由吗?请提供一些示例代码和配置。
这取决于哪个节点是主节点(集群中第一个出现的节点)。如果 A 是主节点,那么集群将继续正常运行,除了从 C 发起的针对节点 B 的操作将超时,反之亦然,对于 B 到 C。如果集群以客户端-服务器模式使用那么除了备份之外,对从客户端生成的数据操作没有影响,即如果一些数据主要存储在 B 但需要在 C 上备份,它将失败。因此,如果 B 或 C 发生故障,您最终将丢失数据。
如果 B 或 C 是主节点,则集群将拆分为 B-A 和 C 或 C-A 和 B。在这种情况下,标准的裂脑处理适用。
我正在使用 hazelcast 3.11 并测试以下网络情况。
A
/ \
B C
其中A和B双向相连,A和C双向相连,B和C断开。通常所有节点都已连接,因此我使用 TcpIp 配置以编程方式为每个节点配置每个 IP。
当我介绍网络故障时,节点B怀疑节点C,因为它没有发送任何心跳,然后紧接着又怀疑节点A,原因"explicit suspicion"。
节点C怀疑节点B,因为它没有发送任何心跳。它与节点 A 位于同一集群中。 "explicit suspicion" Hazelcast 的方法是创建 2 个完全连接的分区而不是 1 个不完全连接的分区吗?有没有办法将 Hazelcast 配置为出现这种类型的网络故障并保持 A 连接到 A 和 C?
附带说明一下,我只对使用 ReplicatedMap 和分布式事件 API 感兴趣。
编辑:以下代码在名为 A、B 和 C 的 3 台服务器中的每台服务器上 运行 一次。它们每个都是 运行ning 一次 hazelcast 实例。
public HazelcastInstance getHazelcastInstance() {
Config config = new Config();
config
.getGroupConfig( )
.setName( localFacility.getName() )
.setPassword( clusterPassword );
NetworkConfig networkConfig = config.getNetworkConfig();
//Disable multicast
JoinConfig joinConfig = networkConfig.getJoin();
joinConfig
.getMulticastConfig()
.setEnabled( false );
// Interface config
InterfacesConfig interfaceConfig = networkConfig.getInterfaces();
IntraFacilityProperties intrafacilityProperties = facilityPropertiesUtil.getCurrentIntrafacilityProperties();
String primaryHostname = intrafacilityProperties.getHostname();
String secondaryHostname = intrafacilityProperties.getBackupHostname();
try {
InetAddress primaryIp = InetAddress.getByName( primaryHostname );
InetAddress secondaryIp = InetAddress.getByName( secondaryHostname );
// Specify which network interfaces to use based on the configured hostnames
interfaceConfig
.setEnabled( true )
.addInterface( primaryIp.getHostAddress() )
.addInterface( secondaryIp.getHostAddress() );
} catch ( UnknownHostException e ) {
if ( logger.isErrorEnabled() ) {
logger.error( "Caught UnknownHostException", e );
}
throw new HazelcastInstantiationException( e.getMessage() );
}
//Enable the tcp ip config.
TcpIpConfig ipConfig = joinConfig.getTcpIpConfig();
ipConfig.setEnabled( true );
try{
// Loops through all servers regardless of which server this is.
for( IntraFacilityProperties member : facilityPropertiesUtil.getIntraFacilityProperties() ) {
ipConfig.addMember( InetAddress.getByName( member.getHostname() ).getHostAddress() );
ipConfig.addMember( InetAddress.getByName( member.getBackupHostname() ).getHostAddress() );
}
} catch( UnknownHostException e ) {
if ( logger.isErrorEnabled() ) {
logger.error( "Caught UnknownHostException", e );
}
throw new HazelcastInstantiationException( e.getMessage() );
}
ReplicatedMapConfig repMapCfg = new ReplicatedMapConfig();
repMapCfg.setName( "default" )
.setMergePolicyConfig( new MergePolicyConfig()
.setPolicy( "LatestAccessMergePolicy" ) );
config.addReplicatedMapConfig( repMapCfg );
config.setProperty( "hazelcast.heartbeat.failuredetector.type", "deadline" );
config.setProperty( "hazelcast.heartbeat.interval.seconds", hzHeartbeatInterval );
config.setProperty( "hazelcast.max.no.heartbeat.seconds", hzHeartbeatTimeout );
config.setProperty( "hazelcast.merge.first.run.delay.seconds", hzMergeFirstDelay );
config.setProperty( "hazelcast.merge.next.run.delay.seconds", hzMergeNextDelay );
return Hazelcast.newHazelcastInstance( config );
}
由于您的混合网络分区与 node.一个节点要么是集群的成员,要么不是。您是在这里专门询问网络路由吗?请提供一些示例代码和配置。
这取决于哪个节点是主节点(集群中第一个出现的节点)。如果 A 是主节点,那么集群将继续正常运行,除了从 C 发起的针对节点 B 的操作将超时,反之亦然,对于 B 到 C。如果集群以客户端-服务器模式使用那么除了备份之外,对从客户端生成的数据操作没有影响,即如果一些数据主要存储在 B 但需要在 C 上备份,它将失败。因此,如果 B 或 C 发生故障,您最终将丢失数据。
如果 B 或 C 是主节点,则集群将拆分为 B-A 和 C 或 C-A 和 B。在这种情况下,标准的裂脑处理适用。