cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dineshjoshi <...@git.apache.org>
Subject [GitHub] cassandra pull request #253: 13630
Date Fri, 07 Sep 2018 23:09:52 GMT
Github user dineshjoshi commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/253#discussion_r216105848
  
    --- Diff: src/java/org/apache/cassandra/net/MessageOut.java ---
    @@ -180,6 +199,73 @@ public String toString()
             return sbuf.toString();
         }
     
    +    /**
    +     * The main entry point for sending an internode message to a peer node in the cluster.
    +     */
    +    public void serialize(DataOutputPlus out, int messagingVersion, OutboundConnectionIdentifier
destinationId, int id, long timestampNanos) throws IOException
    +    {
    +        captureTracingInfo(destinationId);
    +
    +        out.writeInt(MessagingService.PROTOCOL_MAGIC);
    +        out.writeInt(id);
    +
    +        // int cast cuts off the high-order half of the timestamp, which we can assume
remains
    +        // the same between now and when the recipient reconstructs it.
    +        out.writeInt((int) NanoTimeToCurrentTimeMillis.convert(timestampNanos));
    +        serialize(out, messagingVersion);
    +    }
    +
    +    /**
    +     * Record any tracing data, if enabled on this message.
    +     */
    +    @VisibleForTesting
    +    void captureTracingInfo(OutboundConnectionIdentifier destinationId)
    +    {
    +        try
    +        {
    +            UUID sessionId =  (UUID)getParameter(ParameterType.TRACE_SESSION);
    +            if (sessionId != null)
    +            {
    +                TraceState state = Tracing.instance.get(sessionId);
    +                String logMessage = String.format("Sending %s message to %s", verb, destinationId.connectionAddress());
    +                // session may have already finished; see CASSANDRA-5668
    +                if (state == null)
    +                {
    +                    Tracing.TraceType traceType = (Tracing.TraceType)getParameter(ParameterType.TRACE_TYPE);
    +                    traceType = traceType == null ? Tracing.TraceType.QUERY : traceType;
    +                    Tracing.instance.trace(ByteBuffer.wrap(UUIDGen.decompose(sessionId)),
logMessage, traceType.getTTL());
    +                }
    +                else
    +                {
    +                    state.trace(logMessage);
    +                    if (verb == MessagingService.Verb.REQUEST_RESPONSE)
    +                        Tracing.instance.doneWithNonLocalSession(state);
    +                }
    +            }
    +        }
    +        catch (Exception e)
    +        {
    +            logger.warn("failed to capture the tracing info for an outbound message to
{}, ignoring", destinationId, e);
    +        }
    +    }
    +
    +    private Object getParameter(ParameterType type)
    +    {
    +        for (int ii = 0; ii < parameters.size(); ii += PARAMETER_TUPLE_SIZE)
    +        {
    +            if (((ParameterType)parameters.get(ii + PARAMETER_TUPLE_TYPE_OFFSET)).equals(type))
    --- End diff --
    
    Don't need the typecast to `ParameterType`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message