diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /messagebus/src/main/java/com/yahoo/messagebus/network/NetworkOwner.java |
Publish
Diffstat (limited to 'messagebus/src/main/java/com/yahoo/messagebus/network/NetworkOwner.java')
-rw-r--r-- | messagebus/src/main/java/com/yahoo/messagebus/network/NetworkOwner.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/network/NetworkOwner.java b/messagebus/src/main/java/com/yahoo/messagebus/network/NetworkOwner.java new file mode 100644 index 00000000000..42197e086b7 --- /dev/null +++ b/messagebus/src/main/java/com/yahoo/messagebus/network/NetworkOwner.java @@ -0,0 +1,44 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.messagebus.network; + +import com.yahoo.messagebus.Message; +import com.yahoo.messagebus.Protocol; +import com.yahoo.messagebus.Reply; +import com.yahoo.messagebus.ReplyHandler; +import com.yahoo.text.Utf8Array; +import com.yahoo.text.Utf8String; + +/** + * A network owner is the object that instantiates and uses a network. The API to send messages + * across the network is part of the Network interface, whereas this interface exposes the required + * functionality of a network owner to be able to decode and deliver incoming messages. + * + * @author <a href="mailto:havardpe@yahoo-inc.com">Haavard Pettersen</a> + */ +public interface NetworkOwner { + + /** + * All messages are sent across the network with its accompanying protocol name so that it can be decoded at the + * receiving end. The network queries its owner through this function to resolve the protocol from its name. + * + * @param name The name of the protocol to return. + * @return The named protocol. + */ + public Protocol getProtocol(Utf8Array name); + + /** + * All messages that arrive in the network layer is passed to its owner through this function. + * + * @param message The message that just arrived from the network. + * @param session The name of the session that is the recipient of the request. + */ + public void deliverMessage(Message message, String session); + + /** + * All replies that arrive in the network layer is passed through this to unentangle it from the network thread. + * + * @param reply The reply that just arrived from the network. + * @param handler The handler that is to receive the reply. + */ + public void deliverReply(Reply reply, ReplyHandler handler); +} |