public void handleMessage(Message msg) { Trace trace = msg.getTrace(); if (trace.getLevel() == 0) { if (log.isLoggable(LogLevel.SPAM)) { trace.setLevel(9); logTrace = true; } else if (log.isLoggable(LogLevel.DEBUG)) { trace.setLevel(6); logTrace = true; } } this.msg = msg; RoutingNode root = new RoutingNode(mbus, net, resender, this, msg); root.send(); }
/** * A convenience method for assigning the internal trace level and route string to a message before sending it * through the internal mbus session object. * * @param msg the message to send. * @return the document api result object. */ public Result send(Message msg) { try { long reqId = requestId.incrementAndGet(); msg.setContext(reqId); msg.getTrace().setLevel(traceLevel); String toRoute = (msg.getType() == DocumentProtocol.MESSAGE_GETDOCUMENT ? routeForGet : route); if (toRoute != null) { return toResult(reqId, session.send(msg, toRoute, true)); } else { return toResult(reqId, session.send(msg)); } } catch (Exception e) { return new Result(Result.ResultType.FATAL_ERROR, new Error(e.getMessage(), e)); } }
/** * This is a convenience method to assign an {@link EmptyReply} containing a single error to this. This also fiddles * with the trace object so that the error gets written to it. * * @param err The error to set. * @see #setReply(Reply) */ public void setError(Error err) { Reply reply = new EmptyReply(); reply.getTrace().setLevel(trace.getLevel()); reply.addError(err); setReply(reply); }
/** * Deliver an error reply to the recipients of a {@link SendContext} in a way that avoids entanglement. * * @param ctx The send context that contains the recipient data. * @param errCode The error code to return. * @param errMsg The error string to return. */ private void replyError(SendContext ctx, int errCode, String errMsg) { for (RoutingNode recipient : ctx.recipients) { Reply reply = new EmptyReply(); reply.getTrace().setLevel(ctx.traceLevel); reply.addError(new Error(errCode, errMsg)); owner.deliverReply(reply, recipient); } }
public boolean sendMessage(Message msg) { msg.setRoute(Route.parse(server.connectionSpec())); msg.getTrace().setLevel(9); return client.sendMessage(msg).isAccepted(); }
public Request newClientRequest(Message msg) { msg.setRoute(Route.parse(server.connectionSpec())); if (msg.getTrace().getLevel() == 0) { msg.getTrace().setLevel(9); } final Request parent = newServerRequest(); try (final ResourceReference ref = References.fromResource(parent)) { return new MbusRequest(parent, URI.create("mbus://remotehost/"), msg); } }
/** * Send an error reply for a given request. * * @param request The JRT request to reply to. * @param version The version to serialize for. * @param traceLevel The trace level to set in the reply. * @param err The error to reply with. */ private void replyError(Request request, Version version, int traceLevel, Error err) { Reply reply = new EmptyReply(); reply.setContext(new ReplyContext(request, version)); reply.getTrace().setLevel(traceLevel); reply.addError(err); handleReply(reply); }
public DocumentMessage fromDocumentOperation(Processing processing, DocumentOperation documentOperation) { DocumentMessage msg = newMessage(documentOperation); msg.setLoadType(loadType); msg.setPriority(priority); msg.setRoute(requestMsg.getRoute()); msg.setTimeReceivedNow(); msg.setTimeRemaining(requestMsg.getTimeRemainingNow()); msg.getTrace().setLevel(requestMsg.getTrace().getLevel()); if (log.isLoggable(LogLevel.DEBUG)) { log.log(LogLevel.DEBUG, "Created '" + msg.getClass().getName() + "', route = '" + msg.getRoute() + "', priority = '" + msg.getPriority().name() + "', load type = '" + msg.getLoadType() + "', trace level = '" + msg.getTrace().getLevel() + "', time remaining = '" + msg.getTimeRemaining() + "'."); } return msg; }
private void setMessageParameters(DocumentOperationMessageV3 msg, FeederSettings settings) { msg.getMessage().setContext(new ReplyContext(msg.getOperationId(), feedReplies, DocumentOperationType.fromMessage(msg.getMessage()))); if (settings.traceLevel != null) { msg.getMessage().getTrace().setLevel(settings.traceLevel); } if (settings.priority != null) { try { DocumentProtocol.Priority priority = DocumentProtocol.Priority.valueOf(settings.priority); if (msg.getMessage() instanceof DocumentMessage) { ((DocumentMessage) msg.getMessage()).setPriority(priority); } } catch (IllegalArgumentException i) { log.severe(i.getMessage()); } } }
/** * Removes and returns the reply of the current child. This is the correct way of reusing a reply of a child node, * the {@link #getReplyRef()} should be used when just inspecting a child reply. * * @return The reply. */ public Reply removeReply() { Reply ret = entry.getReply(); ret.getTrace().setLevel(entry.getTrace().getLevel()); ret.getTrace().swap(entry.getTrace()); entry.setReply(null); return ret; }
@Override public void run() { Message msg = decode(envelope.msg.getProtocol(), payload, Message.class); msg.getTrace().setLevel(envelope.msg.getTrace().getLevel()); msg.setRoute(envelope.msg.getRoute()).getRoute().removeHop(0); msg.setRetryEnabled(envelope.msg.getRetryEnabled()); msg.setRetry(envelope.msg.getRetry()); msg.setTimeRemaining(envelope.msg.getTimeRemainingNow()); msg.pushHandler(new ReplyHandler() { @Override public void handleReply(Reply reply) { new ReplyEnvelope(LocalNetwork.this, envelope, reply).send(); } }); owner.deliverMessage(msg, LocalServiceAddress.class.cast(envelope.recipient.getServiceAddress()) .getSessionName()); } });
msg.setTimeReceivedNow(); msg.setTimeRemaining(p.timeRemaining); msg.getTrace().setLevel(p.traceLevel); if (msg.getTrace().shouldTrace(TraceLevel.SEND_RECEIVE)) { msg.getTrace().trace(TraceLevel.SEND_RECEIVE,
private CreateVisitorMessage createMessage(VisitorIterator.BucketProgress bucket) { CreateVisitorMessage msg = new CreateVisitorMessage( params.getVisitorLibrary(), getNextVisitorId(), receiver.getConnectionSpec(), dataDestination); msg.getTrace().setLevel(params.getTraceLevel()); msg.setTimeRemaining(messageTimeoutMs); msg.setBuckets(Arrays.asList(bucket.getSuperbucket(), bucket.getProgress())); msg.setDocumentSelection(params.getDocumentSelection()); msg.setBucketSpace(params.getBucketSpace()); msg.setFromTimestamp(params.getFromTimestamp()); msg.setToTimestamp(params.getToTimestamp()); msg.setMaxPendingReplyCount(params.getMaxPending()); msg.setFieldSet(params.fieldSet()); msg.setVisitInconsistentBuckets(params.visitInconsistentBuckets()); msg.setVisitRemoves(params.visitRemoves()); msg.setParameters(params.getLibraryParameters()); msg.setRoute(params.getRoute()); msg.setVisitorOrdering(params.getVisitorOrdering()); msg.setMaxBucketsPerVisitor(params.getMaxBucketsPerVisitor()); msg.setLoadType(params.getLoadType()); msg.setPriority(params.getPriority()); msg.setRetryEnabled(false); return msg; }