Package org.apache.cassandra.net

Examples of org.apache.cassandra.net.EndPoint


{
    private static Logger logger_ = Logger.getLogger( GossipDigestSynVerbHandler.class);

    public void doVerb(Message message)
    {
        EndPoint from = message.getFrom();
        if (logger_.isTraceEnabled())
            logger_.trace("Received a GossipDigestSynMessage from " + from);

        byte[] bytes = message.getMessageBody();
        DataInputStream dis = new DataInputStream( new ByteArrayInputStream(bytes) );
View Full Code Here


         * of the local EndPointState and the version found in the GossipDigest.
        */
        List<GossipDigest> diffDigests = new ArrayList<GossipDigest>();
        for ( GossipDigest gDigest : gDigestList )
        {
            EndPoint ep = gDigest.getEndPoint();
            EndPointState epState = Gossiper.instance().getEndPointStateForEndPoint(ep);
            int version = (epState != null) ? Gossiper.instance().getMaxEndPointStateVersion( epState ) : 0;
            int diffVersion = Math.abs(version - gDigest.getMaxVersion() );
            diffDigests.add( new GossipDigest(ep, gDigest.getGeneration(), diffVersion) );
        }
View Full Code Here

{
    private static Logger logger_ = Logger.getLogger(GossipDigestAckVerbHandler.class);

    public void doVerb(Message message)
    {
        EndPoint from = message.getFrom();
        if (logger_.isTraceEnabled())
            logger_.trace("Received a GossipDigestAckMessage from " + from);

        byte[] bytes = message.getMessageBody();
        DataInputStream dis = new DataInputStream( new ByteArrayInputStream(bytes) );

        try
        {
            GossipDigestAckMessage gDigestAckMessage = GossipDigestAckMessage.serializer().deserialize(dis);
            List<GossipDigest> gDigestList = gDigestAckMessage.getGossipDigestList();
            Map<EndPoint, EndPointState> epStateMap = gDigestAckMessage.getEndPointStateMap();

            if ( epStateMap.size() > 0 )
            {
                /* Notify the Failure Detector */
                Gossiper.instance().notifyFailureDetector(epStateMap);
                Gossiper.instance().applyStateLocally(epStateMap);
            }

            /* Get the state required to send to this gossipee - construct GossipDigestAck2Message */
            Map<EndPoint, EndPointState> deltaEpStateMap = new HashMap<EndPoint, EndPointState>();
            for( GossipDigest gDigest : gDigestList )
            {
                EndPoint addr = gDigest.getEndPoint();
                EndPointState localEpStatePtr = Gossiper.instance().getStateForVersionBiggerThan(addr, gDigest.getMaxVersion());
                if ( localEpStatePtr != null )
                    deltaEpStateMap.put(addr, localEpStatePtr);
            }

View Full Code Here

{
    private static Logger logger_ = Logger.getLogger(GossipDigestAck2VerbHandler.class);

    public void doVerb(Message message)
    {
        EndPoint from = message.getFrom();
        if (logger_.isTraceEnabled())
            logger_.trace("Received a GossipDigestAck2Message from " + from);

        byte[] bytes = message.getMessageBody();
        DataInputStream dis = new DataInputStream( new ByteArrayInputStream(bytes) );
View Full Code Here

    Map<EndPoint, Message> messageMap = new HashMap<EndPoint, Message>();
    Message message = rm.makeRowMutationMessage();

    for (Map.Entry<EndPoint, EndPoint> entry : endpointMap.entrySet())
    {
            EndPoint target = entry.getKey();
            EndPoint hint = entry.getValue();
            if ( !target.equals(hint) )
      {
        Message hintedMessage = rm.makeRowMutationMessage();
        hintedMessage.addHeader(RowMutation.HINT, EndPoint.toBytes(hint) );
        if (logger.isDebugEnabled())
            logger.debug("Sending the hint of " + hint.getHost() + " to " + target.getHost());
        messageMap.put(target, hintedMessage);
      }
      else
      {
        messageMap.put(target, message);
View Full Code Here

      // TODO: throw a thrift exception if we do not have N nodes
      Map<EndPoint, Message> messageMap = createWriteMessages(rm, endpointMap);
      for (Map.Entry<EndPoint, Message> entry : messageMap.entrySet())
      {
                Message message = entry.getValue();
                EndPoint endpoint = entry.getKey();
                // Check if local and not hinted
                byte[] hintedBytes = message.getHeader(RowMutation.HINT);
                if (endpoint.equals(StorageService.getLocalStorageEndPoint())
                        && !(hintedBytes!= null && hintedBytes.length>0))
                {
                    if (logger.isDebugEnabled())
                        logger.debug("locally writing writing key " + rm.key()
                                + " to " + endpoint);
View Full Code Here

     * @return the row associated with command.key
     * @throws Exception
     */
    private static Row weakReadRemote(ReadCommand command) throws IOException
    {
        EndPoint endPoint = StorageService.instance().findSuitableEndPoint(command.key);
        assert endPoint != null;
        Message message = command.makeReadMessage();
        if (logger.isDebugEnabled())
            logger.debug("weakreadremote reading " + command + " from " + message.getMessageId() + "@" + endPoint);
        message.addHeader(ReadCommand.DO_REPAIR, ReadCommand.DO_REPAIR.getBytes());
View Full Code Here

        IResponseResolver<Row> readResponseResolver = new ReadResponseResolver();
        QuorumResponseHandler<Row> quorumResponseHandler = new QuorumResponseHandler<Row>(
                DatabaseDescriptor.getQuorum(),
                readResponseResolver);
        EndPoint dataPoint = StorageService.instance().findSuitableEndPoint(command.key);
        List<EndPoint> endpointList = new ArrayList<EndPoint>(Arrays.asList(StorageService.instance().getNStorageEndPoint(command.key)));
        /* Remove the local storage endpoint from the list. */
        endpointList.remove(dataPoint);
        EndPoint[] endPoints = new EndPoint[endpointList.size() + 1];
        Message messages[] = new Message[endpointList.size() + 1];

        /*
         * First message is sent to the node that will actually get
         * the data for us. The other two replicas are only sent a
         * digest query.
        */
        endPoints[0] = dataPoint;
        messages[0] = message;
        if (logger.isDebugEnabled())
            logger.debug("strongread reading data for " + command + " from " + message.getMessageId() + "@" + dataPoint);
        for (int i = 1; i < endPoints.length; i++)
        {
            EndPoint digestPoint = endpointList.get(i - 1);
            endPoints[i] = digestPoint;
            messages[i] = messageDigestOnly;
            if (logger.isDebugEnabled())
                logger.debug("strongread reading digest for " + command + " from " + messageDigestOnly.getMessageId() + "@" + digestPoint);
        }
View Full Code Here

       
        int i = 0;
        for ( String key : keys )
        {
            /* This is the primary */
            EndPoint dataPoint = StorageService.instance().findSuitableEndPoint(key);
            List<EndPoint> replicas = new ArrayList<EndPoint>( StorageService.instance().getNLiveStorageEndPoint(key) );
            replicas.remove(dataPoint);
            /* Get the messages to be sent index 0 is the data messages and index 1 is the digest message */
            Message[] message = messages.get(key);          
            msgList[i][0] = message[0];
View Full Code Here

        Comparator<String> comparator = StorageService.getPartitioner().getDecoratedKeyComparator();
        TokenMetadata tokenMetadata = StorageService.instance().getTokenMetadata();
        List<String> allKeys = new ArrayList<String>();
        RangeCommand command = rawCommand;

        EndPoint endPoint = StorageService.instance().findSuitableEndPoint(command.startWith);
        EndPoint startEndpoint = endPoint;
        EndPoint wrapEndpoint = tokenMetadata.getFirstEndpoint();

        do
        {
            Message message = command.getMessage();
            if (logger.isDebugEnabled())
View Full Code Here

TOP

Related Classes of org.apache.cassandra.net.EndPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.