use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class NearCachedClientMapProxy method submitToKeyInternal.
@Override
public <R> InternalCompletableFuture<R> submitToKeyInternal(Object key, EntryProcessor<K, V, R> entryProcessor) {
key = toNearCacheKey(key);
InternalCompletableFuture future;
try {
future = super.submitToKeyInternal(key, entryProcessor);
} finally {
invalidateNearCache(key);
}
return future;
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class RaftInvocationManager method invokeGetMembersToCreateRaftGroup.
private void invokeGetMembersToCreateRaftGroup(String groupName, int groupSize, InternalCompletableFuture<RaftGroupId> resultFuture) {
RaftGroupId metadataGroupId = raftService.getMetadataGroupId();
InternalCompletableFuture<List<CPMemberInfo>> f1 = query(metadataGroupId, new GetActiveCPMembersOp(), LINEARIZABLE);
InternalCompletableFuture<Collection<RaftGroupId>> f2 = query(metadataGroupId, new GetRaftGroupIdsOp(), LINEARIZABLE);
f1.thenCombineAsync(f2, (cpMembers, groupIds) -> {
if (cpMembers.size() < groupSize) {
Exception e = new IllegalArgumentException("There are not enough active CP members to create CP group " + groupName + ". Active CP members: " + cpMembers.size() + ", Requested CP group size: " + groupSize);
resultFuture.completeExceptionally(e);
return null;
}
long groupIndex = generateRandomGroupIndex(groupIds);
List<RaftEndpoint> groupEndpoints = generateRandomGroupMembers(cpMembers, groupSize);
invokeCreateRaftGroup(groupName, groupSize, groupIndex, groupEndpoints, resultFuture);
return null;
}).exceptionally(t -> {
resultFuture.completeExceptionally(t);
return null;
});
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class AtomicLongProxy method localGetAsync.
public InternalCompletableFuture<Long> localGetAsync(QueryPolicy queryPolicy) {
InternalCompletableFuture<Long> resultFuture = new InternalCompletableFuture<>();
InternalCompletableFuture<Long> localFuture = invocationManager.queryLocally(groupId, new LocalGetOp(objectName), queryPolicy);
localFuture.whenCompleteAsync((response, throwable) -> {
if (throwable == null) {
resultFuture.complete(response);
} else {
InternalCompletableFuture<Long> future = invocationManager.query(groupId, new LocalGetOp(objectName), queryPolicy);
future.whenCompleteAsync(completingCallback(resultFuture));
}
});
return resultFuture;
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class RaftNodeImpl method replicateMembershipChange.
@Override
public InternalCompletableFuture replicateMembershipChange(RaftEndpoint member, MembershipChangeMode mode, long groupMembersCommitIndex) {
InternalCompletableFuture resultFuture = raftIntegration.newCompletableFuture();
raftIntegration.execute(new MembershipChangeTask(this, resultFuture, member, mode, groupMembersCommitIndex));
return resultFuture;
}
use of com.hazelcast.spi.impl.InternalCompletableFuture in project hazelcast by hazelcast.
the class RaftNodeImpl method tryRunQueries.
public boolean tryRunQueries() {
QueryState queryState = state.leaderState().queryState();
if (queryState.queryCount() == 0) {
return false;
}
long commitIndex = state.commitIndex();
if (!queryState.isMajorityAcked(commitIndex, state.majority())) {
return true;
}
Collection<BiTuple<Object, InternalCompletableFuture>> operations = queryState.operations();
if (logger.isFineEnabled()) {
logger.fine("Running " + operations.size() + " queries at commit index: " + commitIndex + ", query round: " + queryState.queryRound());
}
for (BiTuple<Object, InternalCompletableFuture> t : operations) {
runQuery(t.element1, t.element2);
}
queryState.reset();
return false;
}
Aggregations