本文整理了Java中com.hazelcast.config.QuorumConfig
类的一些代码示例,展示了QuorumConfig
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QuorumConfig
类的具体详情如下:
包路径:com.hazelcast.config.QuorumConfig
类名称:QuorumConfig
[英]Configuration for cluster quorum, a means to protect consistency of data from network partitions. In this context, quorum does not refer to an implementation of a consensus protocol, it refers to the number of members in the cluster required for an operation to succeed.
Since Hazelcast 3.5, the default built-in quorum implementation keeps track of the number of members in the cluster, as determined by Hazelcast's cluster membership management.
Since Hazelcast 3.10, two additional built-in quorum implementations, decoupled from the existing cluster membership management, are provided:
To create a QuorumConfig for probabilistic quorum, use #newProbabilisticQuorumConfigBuilder(String,int) to configure and build the QuorumConfig.
To create a QuorumConfig for recently-active quorum, use #newRecentlyActiveQuorumConfigBuilder(String,int,int) to configure and build the QuorumConfig.
[中]群集仲裁的配置,一种保护网络分区数据一致性的方法。在这种情况下,quorum不是指共识协议的实现,而是指操作成功所需的集群中成员的数量。
自Hazelcast 3.5以来,默认的内置仲裁实现会根据Hazelcast的集群成员管理来跟踪集群中的成员数量。
自Hazelcast 3.10以来,提供了两个与现有集群成员管理分离的额外内置仲裁实现:
*概率仲裁:在这种模式下,跟踪成员心跳,自适应故障检测器为每个成员确定怀疑级别。此外,当Hazelcast成员配置启用ICMP ping故障检测器并以并行模式运行时,ping信息也用于早期检测成员故障。
要为概率仲裁创建QuorumConfig,请使用#newProbabilisticQuorumConfigBuilder(字符串,int)来配置和构建QuorumConfig。
*最近活动的仲裁:在这种模式下,如果要将成员视为出席仲裁,则必须在自现在起配置的时间窗口内接收到心跳信号。此外,当Hazelcast成员配置启用ICMP ping故障检测器并以并行模式运行时,ping信息也用于早期检测成员故障。
要为最近激活的仲裁创建QuorumConfig,请使用#NewRecentlyActivityQuorumConfigBuilder(String,int,int)来配置和构建QuorumConfig。
代码示例来源:origin: hazelcast/hazelcast-code-samples
private static QuorumConfig recentlyActiveQuorumConfig() {
QuorumConfig quorumConfig = QuorumConfig.newRecentlyActiveQuorumConfigBuilder(NAME, 2, 20000).build();
return quorumConfig;
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
private static QuorumConfig memberCountQuorumConfig() {
QuorumConfig quorumConfig = new QuorumConfig();
quorumConfig.setName(NAME).setEnabled(true).setSize(2);
return quorumConfig;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private void validateQuorumConfig(QuorumConfig quorumConfig) {
if (quorumConfig.getQuorumFunctionImplementation() == null) {
return;
}
QuorumFunction quorumFunction = quorumConfig.getQuorumFunctionImplementation();
if (quorumFunction instanceof ProbabilisticQuorumFunction) {
validateQuorumParameters(quorumConfig.getName(),
((ProbabilisticQuorumFunction) quorumFunction).getAcceptableHeartbeatPauseMillis(),
"acceptable heartbeat pause");
} else if (quorumFunction instanceof RecentlyActiveQuorumFunction) {
validateQuorumParameters(quorumConfig.getName(),
((RecentlyActiveQuorumFunction) quorumFunction).getHeartbeatToleranceMillis(),
"heartbeat tolerance");
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
public QuorumConfig build() {
RecentlyActiveQuorumFunction quorumFunction = new RecentlyActiveQuorumFunction(size, heartbeatToleranceMillis);
QuorumConfig quorumConfig = new QuorumConfig(name, enabled, size);
quorumConfig.setQuorumFunctionImplementation(quorumFunction);
return quorumConfig;
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
QuorumImpl(QuorumConfig config, NodeEngineImpl nodeEngine) {
this.nodeEngine = nodeEngine;
this.eventService = nodeEngine.getEventService();
this.config = config;
this.quorumName = config.getName();
this.size = config.getSize();
this.quorumFunction = initializeQuorumFunction();
this.heartbeatAwareQuorumFunction = (quorumFunction instanceof HeartbeatAware);
this.membershipListenerQuorumFunction = (quorumFunction instanceof MembershipListener);
this.pingAwareQuorumFunction = (quorumFunction instanceof PingAware);
}
代码示例来源:origin: hazelcast/hazelcast-jet
private void handleQuorum(Node node) {
QuorumConfig quorumConfig = new QuorumConfig();
String name = getAttribute(node, "name");
quorumConfig.setName(name);
Node attrEnabled = node.getAttributes().getNamedItem("enabled");
boolean enabled = attrEnabled != null && getBooleanValue(getTextContent(attrEnabled));
quorumConfig.setEnabled(enabled);
for (Node n : childElements(node)) {
String value = getTextContent(n).trim();
String nodeName = cleanNodeName(n);
if ("quorum-size".equals(nodeName)) {
quorumConfig.setSize(getIntegerValue("quorum-size", value));
} else if ("quorum-listeners".equals(nodeName)) {
for (Node listenerNode : childElements(n)) {
if ("quorum-listener".equals(cleanNodeName(listenerNode))) {
String listenerClass = getTextContent(listenerNode);
quorumConfig.addListenerConfig(new QuorumListenerConfig(listenerClass));
quorumConfig.setType(QuorumType.valueOf(upperCaseInternal(value)));
} else if ("quorum-function-class-name".equals(nodeName)) {
quorumConfig.setQuorumFunctionClassName(value);
} else if ("recently-active-quorum".equals(nodeName)) {
quorumConfigBuilder = handleRecentlyActiveQuorum(name, n, quorumConfig.getSize());
} else if ("probabilistic-quorum".equals(nodeName)) {
quorumConfigBuilder = handleProbabilisticQuorum(name, n, quorumConfig.getSize());
boolean quorumFunctionDefinedByClassName = !isNullOrEmpty(quorumConfig.getQuorumFunctionClassName());
if (quorumFunctionDefinedByClassName) {
throw new ConfigurationException("A quorum cannot simultaneously define probabilistic-quorum or "
代码示例来源:origin: hazelcast/hazelcast-jet
private static void quorumXmlGenerator(XmlGenerator gen, Config config) {
for (QuorumConfig quorumConfig : config.getQuorumConfigs().values()) {
gen.open("quorum", "name", quorumConfig.getName(),
"enabled", quorumConfig.isEnabled())
.node("quorum-size", quorumConfig.getSize())
.node("quorum-type", quorumConfig.getType());
if (!quorumConfig.getListenerConfigs().isEmpty()) {
gen.open("quorum-listeners");
for (QuorumListenerConfig listenerConfig : quorumConfig.getListenerConfigs()) {
gen.node("quorum-listener", classNameOrImplClass(listenerConfig.getClassName(),
listenerConfig.getImplementation()));
}
gen.close();
}
handleQuorumFunction(gen, quorumConfig);
gen.close();
}
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private QuorumFunction initializeQuorumFunction() {
QuorumFunction quorumFunction = config.getQuorumFunctionImplementation();
if (quorumFunction == null && config.getQuorumFunctionClassName() != null) {
try {
quorumFunction = newInstance(nodeEngine.getConfigClassLoader(), config.getQuorumFunctionClassName());
} catch (Exception e) {
throw rethrow(e);
}
}
if (quorumFunction == null) {
quorumFunction = new MemberCountQuorumFunction(size);
}
ManagedContext managedContext = nodeEngine.getSerializationService().getManagedContext();
quorumFunction = (QuorumFunction) managedContext.initialize(quorumFunction);
return quorumFunction;
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
private static QuorumConfig probabilisticQuorumConfig() {
QuorumConfig quorumConfig = QuorumConfig.newProbabilisticQuorumConfigBuilder(NAME, 2)
.withAcceptableHeartbeatPauseMillis(60000)
.withHeartbeatIntervalMillis(5000)
.withSuspicionThreshold(10)
.build();
return quorumConfig;
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
constructedConfig.getQuorumFunctionImplementation());
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public IdentifiedDataSerializable createNew(Integer arg) {
return new QuorumConfig();
}
};
代码示例来源:origin: com.hazelcast.simulator/tests-common
@Setup
@SuppressWarnings("unchecked")
public void setup() {
this.lastClusterSizeChange = new LastClusterSizeChange(0L,
getMemberCount());
this.map = targetInstance.getMap(name);
this.quorumCount = targetInstance.getConfig()
.getQuorumConfig("map-quorum-ref").getSize();
}
代码示例来源:origin: hazelcast/hazelcast-jet
/**
* Sets the map of split-brain protection configurations, mapped by config
* name. The config name may be a pattern with which the configuration
* will be obtained in the future.
*
* @param quorumConfigs the split-brain protection configuration map to set
* @return this config instance
*/
public Config setQuorumConfigs(Map<String, QuorumConfig> quorumConfigs) {
this.quorumConfigs.clear();
this.quorumConfigs.putAll(quorumConfigs);
for (final Entry<String, QuorumConfig> entry : this.quorumConfigs.entrySet()) {
entry.getValue().setName(entry.getKey());
}
return this;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private void handleQuorum(Node node) {
QuorumConfig quorumConfig = new QuorumConfig();
String name = getAttribute(node, "name");
quorumConfig.setName(name);
Node attrEnabled = node.getAttributes().getNamedItem("enabled");
boolean enabled = attrEnabled != null && getBooleanValue(getTextContent(attrEnabled));
quorumConfig.setEnabled(enabled);
for (Node n : childElements(node)) {
String value = getTextContent(n).trim();
String nodeName = cleanNodeName(n);
if ("quorum-size".equals(nodeName)) {
quorumConfig.setSize(getIntegerValue("quorum-size", value));
} else if ("quorum-listeners".equals(nodeName)) {
for (Node listenerNode : childElements(n)) {
if ("quorum-listener".equals(cleanNodeName(listenerNode))) {
String listenerClass = getTextContent(listenerNode);
quorumConfig.addListenerConfig(new QuorumListenerConfig(listenerClass));
quorumConfig.setType(QuorumType.valueOf(upperCaseInternal(value)));
} else if ("quorum-function-class-name".equals(nodeName)) {
quorumConfig.setQuorumFunctionClassName(value);
} else if ("recently-active-quorum".equals(nodeName)) {
quorumConfigBuilder = handleRecentlyActiveQuorum(name, n, quorumConfig.getSize());
} else if ("probabilistic-quorum".equals(nodeName)) {
quorumConfigBuilder = handleProbabilisticQuorum(name, n, quorumConfig.getSize());
boolean quorumFunctionDefinedByClassName = !isNullOrEmpty(quorumConfig.getQuorumFunctionClassName());
if (quorumFunctionDefinedByClassName) {
throw new ConfigurationException("A quorum cannot simultaneously define probabilistic-quorum or "
代码示例来源:origin: com.hazelcast/hazelcast-all
private static void quorumXmlGenerator(XmlGenerator gen, Config config) {
for (QuorumConfig quorumConfig : config.getQuorumConfigs().values()) {
gen.open("quorum", "name", quorumConfig.getName(),
"enabled", quorumConfig.isEnabled())
.node("quorum-size", quorumConfig.getSize())
.node("quorum-type", quorumConfig.getType());
if (!quorumConfig.getListenerConfigs().isEmpty()) {
gen.open("quorum-listeners");
for (QuorumListenerConfig listenerConfig : quorumConfig.getListenerConfigs()) {
gen.node("quorum-listener", classNameOrImplClass(listenerConfig.getClassName(),
listenerConfig.getImplementation()));
}
gen.close();
}
handleQuorumFunction(gen, quorumConfig);
gen.close();
}
}
代码示例来源:origin: hazelcast/hazelcast-jet
private QuorumFunction initializeQuorumFunction() {
QuorumFunction quorumFunction = config.getQuorumFunctionImplementation();
if (quorumFunction == null && config.getQuorumFunctionClassName() != null) {
try {
quorumFunction = newInstance(nodeEngine.getConfigClassLoader(), config.getQuorumFunctionClassName());
} catch (Exception e) {
throw rethrow(e);
}
}
if (quorumFunction == null) {
quorumFunction = new MemberCountQuorumFunction(size);
}
ManagedContext managedContext = nodeEngine.getSerializationService().getManagedContext();
quorumFunction = (QuorumFunction) managedContext.initialize(quorumFunction);
return quorumFunction;
}
代码示例来源:origin: hazelcast/hazelcast-jet
private QuorumConfigBuilder handleProbabilisticQuorum(String name, Node node, int quorumSize) {
QuorumConfigBuilder quorumConfigBuilder;
long acceptableHeartPause = getLongValue("acceptable-heartbeat-pause-millis",
getAttribute(node, "acceptable-heartbeat-pause-millis"),
ProbabilisticQuorumConfigBuilder.DEFAULT_HEARTBEAT_PAUSE_MILLIS);
double threshold = getDoubleValue("suspicion-threshold",
getAttribute(node, "suspicion-threshold"),
ProbabilisticQuorumConfigBuilder.DEFAULT_PHI_THRESHOLD);
int maxSampleSize = getIntegerValue("max-sample-size",
getAttribute(node, "max-sample-size"),
ProbabilisticQuorumConfigBuilder.DEFAULT_SAMPLE_SIZE);
long minStdDeviation = getLongValue("min-std-deviation-millis",
getAttribute(node, "min-std-deviation-millis"),
ProbabilisticQuorumConfigBuilder.DEFAULT_MIN_STD_DEVIATION);
long heartbeatIntervalMillis = getLongValue("heartbeat-interval-millis",
getAttribute(node, "heartbeat-interval-millis"),
ProbabilisticQuorumConfigBuilder.DEFAULT_HEARTBEAT_INTERVAL_MILLIS);
quorumConfigBuilder = QuorumConfig.newProbabilisticQuorumConfigBuilder(name, quorumSize)
.withAcceptableHeartbeatPauseMillis(acceptableHeartPause)
.withSuspicionThreshold(threshold)
.withHeartbeatIntervalMillis(heartbeatIntervalMillis)
.withMinStdDeviationMillis(minStdDeviation)
.withMaxSampleSize(maxSampleSize);
return quorumConfigBuilder;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
public QuorumConfig build() {
RecentlyActiveQuorumFunction quorumFunction = new RecentlyActiveQuorumFunction(size, heartbeatToleranceMillis);
QuorumConfig quorumConfig = new QuorumConfig(name, enabled, size);
quorumConfig.setQuorumFunctionImplementation(quorumFunction);
return quorumConfig;
}
}
代码示例来源:origin: com.hazelcast/hazelcast-all
QuorumImpl(QuorumConfig config, NodeEngineImpl nodeEngine) {
this.nodeEngine = nodeEngine;
this.eventService = nodeEngine.getEventService();
this.config = config;
this.quorumName = config.getName();
this.size = config.getSize();
this.quorumFunction = initializeQuorumFunction();
this.heartbeatAwareQuorumFunction = (quorumFunction instanceof HeartbeatAware);
this.membershipListenerQuorumFunction = (quorumFunction instanceof MembershipListener);
this.pingAwareQuorumFunction = (quorumFunction instanceof PingAware);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
constructedConfig.getQuorumFunctionImplementation());
内容来源于网络,如有侵权,请联系作者删除!