当前位置: 首页>>代码示例>>Java>>正文


Java MessagingException类代码示例

本文整理汇总了Java中org.onosproject.store.cluster.messaging.MessagingException的典型用法代码示例。如果您正苦于以下问题:Java MessagingException类的具体用法?Java MessagingException怎么用?Java MessagingException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MessagingException类属于org.onosproject.store.cluster.messaging包,在下文中一共展示了MessagingException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendAndReceive

import org.onosproject.store.cluster.messaging.MessagingException; //导入依赖的package包/类
protected <T, U> CompletableFuture<U> sendAndReceive(MessageSubject subject, T request, MemberId memberId) {
    CompletableFuture<U> future = new CompletableFuture<>();
    clusterCommunicator.<T, U>sendAndReceive(
            request, subject, serializer::encode, serializer::decode, NodeId.nodeId(memberId.id()))
            .whenComplete((result, error) -> {
                if (error == null) {
                    future.complete(result);
                } else {
                    if (error instanceof CompletionException) {
                        error = error.getCause();
                    }
                    if (error instanceof MessagingException.NoRemoteHandler) {
                        error = new ConnectException(error.getMessage());
                    } else if (error instanceof MessagingException.RemoteHandlerFailure
                            || error instanceof MessagingException.ProtocolException) {
                        error = new RaftException.ProtocolException(error.getMessage());
                    }
                    future.completeExceptionally(error);
                }
            });
    return future;
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:23,代码来源:RaftCommunicator.java

示例2: addSubscriber

import org.onosproject.store.cluster.messaging.MessagingException; //导入依赖的package包/类
@Override
public <M, R> void addSubscriber(
        MessageSubject subject,
        Function<byte[], M> decoder,
        Function<M, R> handler,
        Function<R, byte[]> encoder,
        Executor executor) {
    subscribers.put(subject, message -> {
        CompletableFuture<byte[]> future = new CompletableFuture<>();
        executor.execute(() -> {
            try {
                future.complete(encoder.apply(handler.apply(decoder.apply(message))));
            } catch (Exception e) {
                future.completeExceptionally(new MessagingException.RemoteHandlerFailure());
            }
        });
        return future;
    });
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:TestClusterCommunicationService.java

示例3: dispatch

import org.onosproject.store.cluster.messaging.MessagingException; //导入依赖的package包/类
/**
 * Dispatches a message to a local handler.
 *
 * @param message the message to dispatch
 */
private void dispatch(InternalReply message) {
    if (message.preamble() != preamble) {
        log.debug("Received {} with invalid preamble", message.type());
        return;
    }

    clockService.recordEventTime(message.time());

    Callback callback = completeCallback(message.id());
    if (callback != null) {
        if (message.status() == InternalReply.Status.OK) {
            callback.complete(message.payload());
        } else if (message.status() == InternalReply.Status.ERROR_NO_HANDLER) {
            callback.completeExceptionally(new MessagingException.NoRemoteHandler());
        } else if (message.status() == InternalReply.Status.ERROR_HANDLER_EXCEPTION) {
            callback.completeExceptionally(new MessagingException.RemoteHandlerFailure());
        } else if (message.status() == InternalReply.Status.PROTOCOL_EXCEPTION) {
            callback.completeExceptionally(new MessagingException.ProtocolException());
        }
    } else {
        log.debug("Received a reply for message id:[{}] "
                + "but was unable to locate the"
                + " request handle", message.id());
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:31,代码来源:NettyMessagingManager.java

示例4: sendAndReceive

import org.onosproject.store.cluster.messaging.MessagingException; //导入依赖的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);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:14,代码来源:TestClusterCommunicationService.java

示例5: handle

import org.onosproject.store.cluster.messaging.MessagingException; //导入依赖的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());
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:8,代码来源:TestClusterCommunicationService.java

示例6: reply

import org.onosproject.store.cluster.messaging.MessagingException; //导入依赖的package包/类
@Override
public void reply(InternalRequest message, InternalReply.Status status, Optional<byte[]> payload) {
    if (future != null) {
        if (status == InternalReply.Status.OK) {
            future.complete(payload.orElse(EMPTY_PAYLOAD));
        } else if (status == InternalReply.Status.ERROR_NO_HANDLER) {
            future.completeExceptionally(new MessagingException.NoRemoteHandler());
        } else if (status == InternalReply.Status.ERROR_HANDLER_EXCEPTION) {
            future.completeExceptionally(new MessagingException.RemoteHandlerFailure());
        } else if (status == InternalReply.Status.PROTOCOL_EXCEPTION) {
            future.completeExceptionally(new MessagingException.ProtocolException());
        }
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:15,代码来源:NettyMessagingManager.java


注:本文中的org.onosproject.store.cluster.messaging.MessagingException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。