Package net.jxta.endpoint

Examples of net.jxta.endpoint.Message


            if(thePipe == null) {
                //no pipe to return to pool - just return
                return false;
            }

            Message theMsg = this.createMessage(state, isResponse);
            try {
                result = this.sendMessageOverPipe(theMsg, thePipe, thePipeWrapper);           
            } finally {
                try {
                    this.putPipeWrapper(thePipeWrapper);
View Full Code Here


        //System.out.println("federated query took " + (System.currentTimeMillis() - startTime) + " millis");
        return result;
    }   
   
    public void sendBroadcastQuery(ReplicationState state) {
        Message broadcastMsg = ReplicationState.createBroadcastMessage(state, false);
        //add up to date route advertisement to load call message
        JxtaUtil.addRoute(broadcastMsg);       
        sendOverPropagatedPipe(broadcastMsg);
    }
View Full Code Here

    //on the same pipe in the event of return of false but instead
    //tries another pipe
    private boolean sendState(ReplicationState state, boolean isResponse) {
        boolean result = true;
        state.setSendStartTime(System.currentTimeMillis());
        Message theMsg = this.createMessage(state, isResponse);
        boolean continueTrying = true;
        long waitTime = 5L;
        int counter = 0;
       
        while(continueTrying) {
View Full Code Here

            if(thePipe == null) {
                //no pipe to return to pool - just return
                return false;
            }

            Message theMsg = this.createMessage(state, isResponse);
            try {
                thePipe.sendMessage(theMsg);
                result = true;
            } catch (IOException ex) {
                // FIXME evaluate log level
                if (_pipelogger.isLoggable(Level.FINE)) {
                    _pipelogger.log(Level.FINE, "Exception sending message " + theMsg.toString(), ex);
                }
                result = false;
            } finally {
                try {
                    this.putPipeWrapper(thePipeWrapper, sourceInstanceName);
View Full Code Here

    public void pipeMsgEvent(PipeMsgEvent event, JxtaBiDiPipe thePipe) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("PipeWrapper>>pipeMsgEvent");
        }
        Message msg = null;
        try {
            // grab the message from the event
            msg = event.getMessage();
            if (_logger.isLoggable(Level.FINE)) {
                _logger.fine("PipeWrapper>>pipeMsgEvent:msg=" + msg);
            }
            if (msg == null) {
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("Received an empty message, returning");
                }
                return;
            }

            // get the message element named SenderMessage

            MessageElement instanceNameMsgElement =
                    msg.getMessageElement(ReplicationState.InstanceNameMessage, ReplicationState.InstanceNameMessage);
            //ignore broadcasts from yourself
            String returnInstance = null;
            if (instanceNameMsgElement != null) {
                returnInstance = instanceNameMsgElement.toString();
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("InputPipeWrapper:incoming propagated msg from: " + returnInstance);
                }
                if (ReplicationUtil.getInstanceName().equalsIgnoreCase(returnInstance)) {
                    return;
                }
            }

            MessageElement readyMsgElement = msg.getMessageElement(ReplicationState.ReadyMessage, ReplicationState.ReadyMessage);
            if (readyMsgElement != null) {
                try {
                    Thread.currentThread().sleep(2000L);
                } catch (InterruptedException ex) {
                }
                if (_pipelogger.isLoggable(Level.FINE)) {
                    _pipelogger.fine("readyMsgElement=" + readyMsgElement.toString() + " from: " + returnInstance);
                }
                JoinNotificationEventHandler.checkAndDoJoinFor(returnInstance);
                //TODO Can we return??
            }


            MessageElement bulkMsgElement = msg.getMessageElement(ReplicationState.BULK_MESSAGE_MODE, ReplicationState.BULK_MESSAGE_MODE);
            if (bulkMsgElement != null) {
                processBulkMessage(msg, bulkMsgElement, thePipe);
                return;
            }


            MessageElement idMsgElement = msg.getMessageElement(ReplicationState.MESSAGE_ID, ReplicationState.MESSAGE_ID);
            if (idMsgElement != null) {
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("idMsgElement=" + idMsgElement.toString());
                }
            }
            MessageElement commandMsgElement =
                    msg.getMessageElement(ReplicationState.MESSAGE_COMMAND, ReplicationState.MESSAGE_COMMAND);
            if (commandMsgElement != null) {
                String theCommand = commandMsgElement.toString();
                if (isBroadcastMethod(theCommand)) {
                    //processQueryMessage(msg, idMsgElement, returnInstance);
                    ReplicationMessageRouter receiver = getRouter();
View Full Code Here

                _logger.fine("Message  :" + msgElement.toString());
            }
            //put comment start back here
            //send back response if it isn't already a response
            if (!(msgElement.toString()).startsWith("RETURN_MSG_COMMAND")) {
                Message returnMsg = new Message();
                String returnData = "ReturnMessage  :" + msgElement.toString();
                returnMsg.addMessageElement(SenderMessage,
                        new StringMessageElement(SenderMessage,
                                returnData,
                                null));
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("SendingResponse :" + returnData);
View Full Code Here

            _logger.fine("<<checkSendImmediateBulkAck:isAckRequiredForMessage=" + ReplicationState.isAckRequiredForMessage(msg));
        }
        if (ReplicationState.isVoidMethodReturnMessage(msg)
                && ReplicationState.isAckRequiredForMessage(msg)) {
            //FIXME send immediate ack
            Message ackMsg = ReplicationState.createBulkAckMessageFrom(msg, states);

            MessageElement origMsgElement = msg.getMessageElement(ReplicationState.ORIGINATING_INSTANCE_NAME,
                    ReplicationState.ORIGINATING_INSTANCE_NAME);
            MessageElement idMsgElement = msg.getMessageElement(ReplicationState.MESSAGE_ID,
                    ReplicationState.MESSAGE_ID);
View Full Code Here

            return this.pipe;
        }

        public void pipeMsgEvent(PipeMsgEvent event) {

            Message msg = null;
            try {
                // grab the message from the event
                msg = event.getMessage();
                if (msg == null) {
                     if (_logger.isLoggable(Level.FINEST)) {
                        _logger.finest("Received an empty message, returning");
                     }                   
                    return;
                }
                 if (_logger.isLoggable(Level.FINEST)) {
                    _logger.finest("Received a response");
                 }                
                // get the message element named SenderMessage
                MessageElement msgElement = msg.getMessageElement(SenderMessage, SenderMessage);
                // Get message
                if (msgElement.toString() == null) {
                    if (_logger.isLoggable(Level.FINE)) {
                        _logger.fine("null msg received");
                    }
View Full Code Here

         */
        private void sendTestMessages(JxtaBiDiPipe pipe) {
            String instanceName = ReplicationUtil.getInstanceName();
            try {
                for (int i = 0; i < ITERATIONS; i++) {
                    Message msg = new Message();
                    String data = "Message #" + i + " From Instance " + instanceName;
                    msg.addMessageElement(MESSAGE_MODE,
                              new StringMessageElement(MESSAGE_MODE,
                                                       MODE_STARTUP,
                                                       null));
                    msg.addMessageElement(SenderMessage,
                                          new StringMessageElement(SenderMessage,
                                                                   data,
                                                                   null));                   
                    if (_pipelogger.isLoggable(Level.FINE)) {
                        _pipelogger.fine("Sending :" + data);
View Full Code Here

TOP

Related Classes of net.jxta.endpoint.Message

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.