Package org.apache.cassandra.net

Examples of org.apache.cassandra.net.EndPoint


        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


        return instance_;
    }

    private static boolean sendMessage(String endpointAddress, String key) throws DigestMismatchException, TimeoutException, IOException
    {
        EndPoint endPoint = new EndPoint(endpointAddress, DatabaseDescriptor.getStoragePort());
        if (!FailureDetector.instance().isAlive(endPoint))
        {
            return false;
        }
View Full Code Here

    public Message makeRowMutationMessage(String verbHandlerName) throws IOException
    {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream( bos );
        RowMutationMessage.serializer().serialize(this, dos);
        EndPoint local = StorageService.getLocalStorageEndPoint();
        EndPoint from = ( local != null ) ? local : new EndPoint(FBUtilities.getHostAddress(), 7000);
        return new Message(from, StorageService.mutationStage_, verbHandlerName, bos.toByteArray());        
    }
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) );
        logger.debug("Sending the hint of " + target.getHost() + " to " + hint.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();
                logger.debug("insert writing key " + rm.key() + " to " + message.getMessageId() + "@" + endpoint);
                MessagingService.getMessagingInstance().sendOneWay(message, endpoint);
      }
    }
        catch (IOException e)
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();
        logger.debug("weakreadremote reading " + command + " from " + message.getMessageId() + "@" + endPoint);
        message.addHeader(ReadCommand.DO_REPAIR, ReadCommand.DO_REPAIR.getBytes());
        IAsyncResult iar = MessagingService.getMessagingInstance().sendRR(message, endPoint);
View Full Code Here

        IResponseResolver<Row> readResponseResolver = new ReadResponseResolver();
        QuorumResponseHandler<Row> quorumResponseHandler = new QuorumResponseHandler<Row>(
                DatabaseDescriptor.getReplicationFactor(),
                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;
        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;
            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

    static List<String> getKeyRange(RangeCommand command)
    {
        long startTime = System.currentTimeMillis();
        try
        {
            EndPoint endPoint = StorageService.instance().findSuitableEndPoint(command.startWith);
            IAsyncResult iar = MessagingService.getMessagingInstance().sendRR(command.getMessage(), endPoint);

            // read response
            // TODO send more requests if we need to span multiple nodes
            byte[] responseBody = iar.get(DatabaseDescriptor.getRpcTimeout(), TimeUnit.MILLISECONDS);
View Full Code Here

    public Message makeRowMutationMessage(String verbHandlerName) throws IOException
    {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(bos);
        serializer().serialize(this, dos);
        EndPoint local = StorageService.getLocalStorageEndPoint();
        EndPoint from = (local != null) ? local : new EndPoint(FBUtilities.getHostAddress(), 7000);
        return new Message(from, StorageService.mutationStage_, verbHandlerName, bos.toByteArray());
    }
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.