本文整理了Java中com.hazelcast.config.Config.findPNCounterConfig()
方法的一些代码示例,展示了Config.findPNCounterConfig()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.findPNCounterConfig()
方法的具体详情如下:
包路径:com.hazelcast.config.Config
类名称:Config
方法名:findPNCounterConfig
[英]Returns a read-only PNCounterConfigconfiguration for the given name.
The name is matched by pattern to the configuration and by stripping the partition ID qualifier from the given name. If there is no config found by the name, it will return the configuration with the name default.
[中]返回给定名称的只读PNCounterConfigconfiguration。
该名称通过模式与配置匹配,并从给定名称中剥离分区ID限定符。如果没有通过名称找到配置,它将返回名为default的配置。
代码示例来源:origin: hazelcast/hazelcast-jet
private int handlePNCounter(MemberStateImpl memberState, int count, Config config,
Map<String, LocalPNCounterStats> counters) {
for (Map.Entry<String, LocalPNCounterStats> entry : counters.entrySet()) {
String name = entry.getKey();
if (config.findPNCounterConfig(name).isStatisticsEnabled()) {
LocalPNCounterStats stats = entry.getValue();
memberState.putLocalPNCounterStats(name, stats);
++count;
}
}
return count;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
private int handlePNCounter(MemberStateImpl memberState, int count, Config config,
Map<String, LocalPNCounterStats> counters) {
for (Map.Entry<String, LocalPNCounterStats> entry : counters.entrySet()) {
String name = entry.getKey();
if (config.findPNCounterConfig(name).isStatisticsEnabled()) {
LocalPNCounterStats stats = entry.getValue();
memberState.putLocalPNCounterStats(name, stats);
++count;
}
}
return count;
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public Object createNew(String name) {
final PNCounterConfig counterConfig = nodeEngine.getConfig().findPNCounterConfig(name);
final String quorumName = counterConfig.getQuorumName();
return quorumName == null ? Memoizer.NULL_OBJECT : quorumName;
}
});
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
protected Object call() throws Exception {
return nodeEngine.getConfig().findPNCounterConfig(parameters.name).getReplicaCount();
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public Object createNew(String name) {
final PNCounterConfig counterConfig = nodeEngine.getConfig().findPNCounterConfig(name);
final String quorumName = counterConfig.getQuorumName();
return quorumName == null ? Memoizer.NULL_OBJECT : quorumName;
}
});
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
protected Object call() throws Exception {
return nodeEngine.getConfig().findPNCounterConfig(parameters.name).getReplicaCount();
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public CRDTReplicationContainer prepareMigrationOperation(int maxConfiguredReplicaCount) {
final HashMap<String, VectorClock> currentVectorClocks = new HashMap<String, VectorClock>();
final HashMap<String, PNCounterImpl> counters = new HashMap<String, PNCounterImpl>();
final Config config = nodeEngine.getConfig();
for (Entry<String, PNCounterImpl> counterEntry : this.counters.entrySet()) {
final String counterName = counterEntry.getKey();
final PNCounterImpl counter = counterEntry.getValue();
if (config.findPNCounterConfig(counterName).getReplicaCount() >= maxConfiguredReplicaCount) {
continue;
}
counters.put(counterName, counter);
currentVectorClocks.put(counterName, counter.getCurrentVectorClock());
}
return counters.isEmpty()
? null
: new CRDTReplicationContainer(new PNCounterReplicationOperation(counters), currentVectorClocks);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public CRDTReplicationContainer prepareMigrationOperation(int maxConfiguredReplicaCount) {
final HashMap<String, VectorClock> currentVectorClocks = new HashMap<String, VectorClock>();
final HashMap<String, PNCounterImpl> counters = new HashMap<String, PNCounterImpl>();
final Config config = nodeEngine.getConfig();
for (Entry<String, PNCounterImpl> counterEntry : this.counters.entrySet()) {
final String counterName = counterEntry.getKey();
final PNCounterImpl counter = counterEntry.getValue();
if (config.findPNCounterConfig(counterName).getReplicaCount() >= maxConfiguredReplicaCount) {
continue;
}
counters.put(counterName, counter);
currentVectorClocks.put(counterName, counter.getCurrentVectorClock());
}
return counters.isEmpty()
? null
: new CRDTReplicationContainer(new PNCounterReplicationOperation(counters), currentVectorClocks);
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
public CRDTReplicationContainer prepareReplicationOperation(
Map<String, VectorClock> previouslyReplicatedVectorClocks, int targetIndex) {
final HashMap<String, VectorClock> currentVectorClocks = new HashMap<String, VectorClock>();
final HashMap<String, PNCounterImpl> counters = new HashMap<String, PNCounterImpl>();
final Config config = nodeEngine.getConfig();
for (Entry<String, PNCounterImpl> counterEntry : this.counters.entrySet()) {
final String counterName = counterEntry.getKey();
final PNCounterImpl counter = counterEntry.getValue();
if (targetIndex >= config.findPNCounterConfig(counterName).getReplicaCount()) {
continue;
}
final VectorClock counterCurrentVectorClock = counter.getCurrentVectorClock();
final VectorClock counterPreviousVectorClock = previouslyReplicatedVectorClocks.get(counterName);
if (counterPreviousVectorClock == null || counterCurrentVectorClock.isAfter(counterPreviousVectorClock)) {
counters.put(counterName, counter);
}
currentVectorClocks.put(counterName, counterCurrentVectorClock);
}
return counters.isEmpty()
? null
: new CRDTReplicationContainer(new PNCounterReplicationOperation(counters), currentVectorClocks);
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
public CRDTReplicationContainer prepareReplicationOperation(
Map<String, VectorClock> previouslyReplicatedVectorClocks, int targetIndex) {
final HashMap<String, VectorClock> currentVectorClocks = new HashMap<String, VectorClock>();
final HashMap<String, PNCounterImpl> counters = new HashMap<String, PNCounterImpl>();
final Config config = nodeEngine.getConfig();
for (Entry<String, PNCounterImpl> counterEntry : this.counters.entrySet()) {
final String counterName = counterEntry.getKey();
final PNCounterImpl counter = counterEntry.getValue();
if (targetIndex >= config.findPNCounterConfig(counterName).getReplicaCount()) {
continue;
}
final VectorClock counterCurrentVectorClock = counter.getCurrentVectorClock();
final VectorClock counterPreviousVectorClock = previouslyReplicatedVectorClocks.get(counterName);
if (counterPreviousVectorClock == null || counterCurrentVectorClock.isAfter(counterPreviousVectorClock)) {
counters.put(counterName, counter);
}
currentVectorClocks.put(counterName, counterCurrentVectorClock);
}
return counters.isEmpty()
? null
: new CRDTReplicationContainer(new PNCounterReplicationOperation(counters), currentVectorClocks);
}
代码示例来源:origin: hazelcast/hazelcast-jet
/**
* Returns the addresses of the CRDT replicas from the current state of the
* local membership list. Addresses contained in the {@code excludedAddresses}
* collection are excluded.
*
* @param excludedAddresses the addresses to exclude
* @return list of possible CRDT replica addresses
*/
private List<Address> getReplicaAddresses(Collection<Address> excludedAddresses) {
final Collection<Member> dataMembers = getNodeEngine().getClusterService()
.getMembers(MemberSelectors.DATA_MEMBER_SELECTOR);
final int maxConfiguredReplicaCount = getNodeEngine().getConfig().findPNCounterConfig(name).getReplicaCount();
final int currentReplicaCount = Math.min(maxConfiguredReplicaCount, dataMembers.size());
final ArrayList<Address> replicaAddresses = new ArrayList<Address>(currentReplicaCount);
final Iterator<Member> dataMemberIterator = dataMembers.iterator();
for (int i = 0; i < currentReplicaCount; i++) {
final Address dataMemberAddress = dataMemberIterator.next().getAddress();
if (!excludedAddresses.contains(dataMemberAddress)) {
replicaAddresses.add(dataMemberAddress);
}
}
return replicaAddresses;
}
代码示例来源:origin: com.hazelcast/hazelcast-all
/**
* Returns the addresses of the CRDT replicas from the current state of the
* local membership list. Addresses contained in the {@code excludedAddresses}
* collection are excluded.
*
* @param excludedAddresses the addresses to exclude
* @return list of possible CRDT replica addresses
*/
private List<Address> getReplicaAddresses(Collection<Address> excludedAddresses) {
final Collection<Member> dataMembers = getNodeEngine().getClusterService()
.getMembers(MemberSelectors.DATA_MEMBER_SELECTOR);
final int maxConfiguredReplicaCount = getNodeEngine().getConfig().findPNCounterConfig(name).getReplicaCount();
final int currentReplicaCount = Math.min(maxConfiguredReplicaCount, dataMembers.size());
final ArrayList<Address> replicaAddresses = new ArrayList<Address>(currentReplicaCount);
final Iterator<Member> dataMemberIterator = dataMembers.iterator();
for (int i = 0; i < currentReplicaCount; i++) {
final Address dataMemberAddress = dataMemberIterator.next().getAddress();
if (!excludedAddresses.contains(dataMemberAddress)) {
replicaAddresses.add(dataMemberAddress);
}
}
return replicaAddresses;
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
protected ClientMessage encodeResponse(Object response) {
final CRDTTimestampedLong resp = (CRDTTimestampedLong) response;
final PNCounterConfig counterConfig = nodeEngine.getConfig().findPNCounterConfig(parameters.name);
return PNCounterAddCodec.encodeResponse(
resp.getValue(), resp.getVectorClock().entrySet(), counterConfig.getReplicaCount());
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
protected ClientMessage encodeResponse(Object response) {
final CRDTTimestampedLong resp = (CRDTTimestampedLong) response;
final PNCounterConfig counterConfig = nodeEngine.getConfig().findPNCounterConfig(parameters.name);
return PNCounterAddCodec.encodeResponse(
resp.getValue(), resp.getVectorClock().entrySet(), counterConfig.getReplicaCount());
}
代码示例来源:origin: com.hazelcast/hazelcast-all
@Override
protected ClientMessage encodeResponse(Object response) {
final CRDTTimestampedLong resp = (CRDTTimestampedLong) response;
final PNCounterConfig counterConfig = nodeEngine.getConfig().findPNCounterConfig(parameters.name);
return PNCounterGetCodec.encodeResponse(
resp.getValue(), resp.getVectorClock().entrySet(), counterConfig.getReplicaCount());
}
代码示例来源:origin: hazelcast/hazelcast-jet
@Override
protected ClientMessage encodeResponse(Object response) {
final CRDTTimestampedLong resp = (CRDTTimestampedLong) response;
final PNCounterConfig counterConfig = nodeEngine.getConfig().findPNCounterConfig(parameters.name);
return PNCounterGetCodec.encodeResponse(
resp.getValue(), resp.getVectorClock().entrySet(), counterConfig.getReplicaCount());
}
代码示例来源:origin: com.hazelcast/hazelcast-all
PNCounterImpl getPNCounter(VectorClock observedTimestamps) {
if (counter != null) {
return counter;
}
final PNCounterService service = getService();
if (observedTimestamps != null && !observedTimestamps.isEmpty() && !service.containsCounter(name)) {
throw new ConsistencyLostException("This replica cannot provide the session guarantees for "
+ "the PN counter since it's state is stale");
}
final int maxConfiguredReplicaCount = getNodeEngine().getConfig().findPNCounterConfig(name).getReplicaCount();
if (!isCRDTReplica(maxConfiguredReplicaCount)) {
throw new TargetNotReplicaException("This member is not a CRDT replica for the " + name + " + PN counter");
}
this.counter = service.getCounter(name);
return counter;
}
代码示例来源:origin: hazelcast/hazelcast-jet
PNCounterImpl getPNCounter(VectorClock observedTimestamps) {
if (counter != null) {
return counter;
}
final PNCounterService service = getService();
if (observedTimestamps != null && !observedTimestamps.isEmpty() && !service.containsCounter(name)) {
throw new ConsistencyLostException("This replica cannot provide the session guarantees for "
+ "the PN counter since it's state is stale");
}
final int maxConfiguredReplicaCount = getNodeEngine().getConfig().findPNCounterConfig(name).getReplicaCount();
if (!isCRDTReplica(maxConfiguredReplicaCount)) {
throw new TargetNotReplicaException("This member is not a CRDT replica for the " + name + " + PN counter");
}
this.counter = service.getCounter(name);
return counter;
}
内容来源于网络,如有侵权,请联系作者删除!