本文整理匯總了Java中io.atomix.utils.concurrent.Futures.exceptionalFuture方法的典型用法代碼示例。如果您正苦於以下問題:Java Futures.exceptionalFuture方法的具體用法?Java Futures.exceptionalFuture怎麽用?Java Futures.exceptionalFuture使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.atomix.utils.concurrent.Futures
的用法示例。
在下文中一共展示了Futures.exceptionalFuture方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isEmpty
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public CompletableFuture<Boolean> isEmpty() {
try {
return backingMap.isEmpty();
} catch (Exception e) {
return Futures.exceptionalFuture(e);
}
}
示例2: reconfigure
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
CompletableFuture<ReconfigureResponse> reconfigure(ReconfigureRequest request) {
if (reconfigureHandler != null) {
return reconfigureHandler.apply(request);
} else {
return Futures.exceptionalFuture(new ConnectException());
}
}
示例3: putAndGet
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public CompletableFuture<Versioned<V1>> putAndGet(K1 key, V1 value, Duration ttl) {
try {
return backingMap.putAndGet(keyEncoder.apply(key), valueEncoder.apply(value), ttl)
.thenApply(versionedValueTransform);
} catch (Exception e) {
return Futures.exceptionalFuture(e);
}
}
示例4: remove
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public CompletableFuture<Boolean> remove(K1 key, long version) {
try {
return backingMap.remove(keyEncoder.apply(key), version);
} catch (Exception e) {
return Futures.exceptionalFuture(e);
}
}
示例5: sendAndReceive
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public <M, R> CompletableFuture<R> sendAndReceive(
M message,
MessageSubject subject,
Function<M, byte[]> encoder,
Function<byte[], R> decoder,
NodeId toNodeId) {
TestClusterCommunicationService node = nodes.get(toNodeId);
if (node == null) {
return Futures.exceptionalFuture(new MessagingException.NoRemoteHandler());
}
return node.handle(subject, encoder.apply(message)).thenApply(decoder);
}
示例6: leave
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
CompletableFuture<byte[]> leave(byte[] request) {
if (leaveHandler != null) {
return leaveHandler.apply(decode(request)).thenApply(this::encode);
} else {
return Futures.exceptionalFuture(new ConnectException());
}
}
示例7: keepAlive
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
CompletableFuture<KeepAliveResponse> keepAlive(KeepAliveRequest request) {
if (keepAliveHandler != null) {
return keepAliveHandler.apply(request);
} else {
return Futures.exceptionalFuture(new ConnectException());
}
}
示例8: put
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public CompletableFuture<Boolean> put(K1 key, V1 value) {
try {
return backingMap.put(keyEncoder.apply(key),
valueEncoder.apply(value));
} catch (Exception e) {
return Futures.exceptionalFuture(e);
}
}
示例9: handle
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
private CompletableFuture<byte[]> handle(MessageSubject subject, byte[] message) {
Function<byte[], CompletableFuture<byte[]>> subscriber = subscribers.get(subject);
if (subscriber != null) {
return subscriber.apply(message);
}
return Futures.exceptionalFuture(new MessagingException.NoRemoteHandler());
}
示例10: rollback
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public CompletableFuture<Void> rollback(TransactionId transactionId) {
try {
return backingMap.rollback(transactionId);
} catch (Exception e) {
return Futures.exceptionalFuture(e);
}
}
示例11: prepare
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public CompletableFuture<Boolean> prepare(TransactionLog<MapUpdate<K1, V1>> transactionLog) {
try {
return backingMap.prepare(transactionLog.map(record -> record.map(keyEncoder, valueEncoder)));
} catch (Exception e) {
return Futures.exceptionalFuture(e);
}
}
示例12: replace
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public CompletableFuture<Boolean> replace(K1 key, long expectedOldValue, long newValue) {
try {
return backingMap.replace(keyEncoder.apply(key), expectedOldValue, newValue);
} catch (Exception e) {
return Futures.exceptionalFuture(e);
}
}
示例13: listen
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public synchronized CompletableFuture<Void> listen(Collection<NodeId> cluster) {
if (joinFuture != null)
return joinFuture;
// If no configuration was loaded from disk, create a new configuration.
if (configuration == null) {
member.setType(RaftMember.Type.PASSIVE);
// Create a set of cluster members, excluding the local member which is joining a cluster.
Set<RaftMember> activeMembers = cluster.stream()
.filter(m -> !m.equals(member.nodeId()))
.map(m -> new DefaultRaftMember(m, RaftMember.Type.ACTIVE, member.getLastUpdated()))
.collect(Collectors.toSet());
// If the set of members in the cluster is empty when the local member is excluded,
// fail the join.
if (activeMembers.isEmpty()) {
return Futures.exceptionalFuture(new IllegalStateException("cannot join empty cluster"));
}
// Create a new configuration and configure the cluster. Once the cluster is configured, the configuration
// will be stored on disk to ensure the cluster can fall back to the provided configuration if necessary.
configure(new Configuration(0, 0, member.getLastUpdated().toEpochMilli(), activeMembers));
}
return join();
}
示例14: putIfAbsent
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
@Override
public CompletableFuture<Versioned<V1>> putIfAbsent(K1 key, V1 value, Duration ttl) {
try {
return backingMap.putIfAbsent(keyEncoder.apply(key), valueEncoder.apply(value), ttl)
.thenApply(versionedValueTransform);
} catch (Exception e) {
return Futures.exceptionalFuture(e);
}
}
示例15: appendAndCompact
import io.atomix.utils.concurrent.Futures; //導入方法依賴的package包/類
/**
* Appends an entry to the Raft log and compacts logs if necessary.
*
* @param entry the entry to append
* @param attempt the append attempt count
* @param <E> the entry type
* @return a completable future to be completed once the entry has been appended
*/
protected <E extends RaftLogEntry> CompletableFuture<Indexed<E>> appendAndCompact(E entry, int attempt) {
if (attempt == MAX_APPEND_ATTEMPTS) {
return Futures.exceptionalFuture(new StorageException.OutOfDiskSpace("Not enough space to append entry"));
} else {
try {
return CompletableFuture.completedFuture(raft.getLogWriter().append(entry));
} catch (StorageException.OutOfDiskSpace e) {
return raft.getLogCompactor().compact().thenCompose(v -> appendAndCompact(entry, attempt + 1));
}
}
}