diff options
Diffstat (limited to 'messagebus/src')
4 files changed, 18 insertions, 33 deletions
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/Routable.java b/messagebus/src/main/java/com/yahoo/messagebus/Routable.java index b797c103e67..e761a874ac1 100755 --- a/messagebus/src/main/java/com/yahoo/messagebus/Routable.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/Routable.java @@ -69,41 +69,27 @@ public abstract class Routable { return callStack.pop(this); } - /** - * Return the context of this routable. - * - * @return The context. - */ + /** Returns the context of this routable. */ public Object getContext() { return context; } /** - * Set a new context for this routable. Please note that the context is <u>not</u> something that is passed along a + * Sets a new context for this routable. Please note that the context is <u>not</u> something that is passed along a * message, it is simply a user context for the handler currently manipulating a message. When the corresponding * reply reaches the registered reply handler, its content will be the same as that of the outgoing message. More * technically, this context is contained in the callstack of a routable. - * - * @param context The new context. */ public void setContext(Object context) { this.context = context; } - /** - * Return the callstack of this routable. - * - * @return The callstack. - */ + /** Returns the callstack of this routable. */ public CallStack getCallStack() { return callStack; } - /** - * Returns the trace object of this routable. - * - * @return The trace object. - */ + /** Returns the trace object of this routable. */ public Trace getTrace() { return trace; } @@ -112,15 +98,14 @@ public abstract class Routable { * Return the name of the protocol that defines this routable. This must be implemented by all inheriting classes, * and should then return the result of {@link com.yahoo.messagebus.Protocol#getName} of its protocol. * - * @return The name of the protocol defining this message. + * @return the name of the protocol defining this message. */ public abstract Utf8String getProtocol(); /** - * Obtain the type of this routable. The id '0' is reserved for the EmptyReply class. Other ids must be defined by + * Returns the type of this routable. The id '0' is reserved for the EmptyReply class. Other ids must be defined by * the application protocol. - * - * @return The message type. */ public abstract int getType(); + } diff --git a/messagebus/src/main/java/com/yahoo/messagebus/SendProxy.java b/messagebus/src/main/java/com/yahoo/messagebus/SendProxy.java index ecc6bfebc41..df60fc5bdbf 100644 --- a/messagebus/src/main/java/com/yahoo/messagebus/SendProxy.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/SendProxy.java @@ -90,4 +90,5 @@ public class SendProxy implements MessageHandler, ReplyHandler { handler.handleReply(reply); } } + } diff --git a/messagebus/src/main/java/com/yahoo/messagebus/Sequencer.java b/messagebus/src/main/java/com/yahoo/messagebus/Sequencer.java index b804c776969..35218364c8f 100644 --- a/messagebus/src/main/java/com/yahoo/messagebus/Sequencer.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/Sequencer.java @@ -103,7 +103,7 @@ public class Sequencer implements MessageHandler, ReplyHandler { * sequencing-id, it is simply passed through to the next handler in the chain. Sequenced messages are sent only if * there is no queue for their id, otherwise they are queued. * - * @param msg The message to send. + * @param msg the message to send. */ @Override public void handleMessage(Message msg) { diff --git a/messagebus/src/main/java/com/yahoo/messagebus/SourceSession.java b/messagebus/src/main/java/com/yahoo/messagebus/SourceSession.java index 3bfdfaa1f4a..4fdfa341e3b 100644 --- a/messagebus/src/main/java/com/yahoo/messagebus/SourceSession.java +++ b/messagebus/src/main/java/com/yahoo/messagebus/SourceSession.java @@ -1,25 +1,22 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.messagebus; -import com.yahoo.log.LogLevel; import com.yahoo.messagebus.routing.Route; import com.yahoo.messagebus.routing.RoutingTable; -import com.yahoo.text.Utf8String; -import java.util.*; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.Queue; import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Logger; /** - * <p>A session supporting sending new messages.</p> + * A session supporting sending new messages. * * @author Simon Thoresen Hult */ public final class SourceSession implements ReplyHandler, MessageBus.SendBlockedMessages { - private static Logger log = Logger.getLogger(SourceSession.class.getName()); private final AtomicBoolean destroyed = new AtomicBoolean(false); private final CountDownLatch done = new CountDownLatch(1); private final Object lock = new Object(); @@ -116,11 +113,12 @@ public final class SourceSession implements ReplyHandler, MessageBus.SendBlocked * </code> * * @param msg the message to send - * @return The result of <i>initiating</i> sending of this message. + * @return the result of <i>initiating</i> sending of this message */ public Result send(Message msg) { return sendInternal(updateTiming(msg)); } + private Message updateTiming(Message msg) { msg.setTimeReceivedNow(); if (msg.getTimeRemaining() <= 0) { @@ -128,13 +126,14 @@ public final class SourceSession implements ReplyHandler, MessageBus.SendBlocked } return msg; } + private Result sendInternal(Message msg) { synchronized (lock) { if (closed) { return new Result(ErrorCode.SEND_QUEUE_CLOSED, "Source session is closed."); } - if (throttlePolicy != null && !throttlePolicy.canSend(msg, pendingCount)) { + if (throttlePolicy != null && ! throttlePolicy.canSend(msg, pendingCount)) { return new Result(ErrorCode.SEND_QUEUE_FULL, "Too much pending data (" + pendingCount + " messages)."); } @@ -247,7 +246,7 @@ public final class SourceSession implements ReplyHandler, MessageBus.SendBlocked private void expireStalledBlockedMessages() { synchronized (lock) { - final Iterator<BlockedMessage> each = blockedQ.iterator(); + Iterator<BlockedMessage> each = blockedQ.iterator(); while (each.hasNext()) { if (each.next().notifyIfExpired()) { each.remove(); |