Package net.jxta.endpoint

Examples of net.jxta.endpoint.MessageElement


                MessageProcessor.getInstance().pipeMsgEvent(event, null);
                return;
            }
            // get the message element named InstanceNameMessage

            MessageElement instanceNameMsgElement =
                msg.getMessageElement(InstanceNameMessage, 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(returnInstance.equalsIgnoreCase(getInstanceName())) {
                return;
            }
           
            MessageElement readyMsgElement = msg.getMessageElement(ReadyMessage, 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);
            }
           
            MessageElement bulkMsgElement = msg.getMessageElement(BULK_MESSAGE_MODE, BULK_MESSAGE_MODE);
            if (bulkMsgElement != null) {
                processBulkMessage(msg, bulkMsgElement);
                return;
            }           
                  
            MessageElement idMsgElement = msg.getMessageElement(MESSAGE_ID, MESSAGE_ID);
            if(idMsgElement != null) {
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("idMsgElement=" + idMsgElement.toString());
                }
            }
            MessageElement commandMsgElement =
                msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);            
            if(commandMsgElement != null) {
                String theCommand = commandMsgElement.toString();
                if(isBroadcastMethod(theCommand)) {
                    //processQueryMessage(msg, idMsgElement, returnInstance);
                    ReplicationMessageRouter receiver = getRouter();
                    ReplicationState state = createReplicationState(msg);
                    processQueryState(state, receiver);
View Full Code Here


   
    private void displayKeyMessageElements(Message msg) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.fine("PropagatedPipeWrapper>>pipeMsgEvent:msg=" + msg);
        }
        MessageElement instanceNameMsgElement =
            msg.getMessageElement(InstanceNameMessage, InstanceNameMessage);
        String returnInstance = null;
        if(instanceNameMsgElement != null) {
            returnInstance = instanceNameMsgElement.toString();
            if (_logger.isLoggable(Level.FINE) && !isMessageFromYourself(returnInstance)) {
                _logger.fine("PropagatedPipeWrapper>>pipeMsgEvent:fromInstance=" + returnInstance);
            }
        }
       
        MessageElement idMsgElement = msg.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        if(idMsgElement != null  && _logger.isLoggable(Level.FINE)) {
            _logger.fine("idMsgElement=" + idMsgElement.toString());
        }
       
        MessageElement commandMsgElement =
            msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);            
        if(commandMsgElement != null) {
            String theCommand = commandMsgElement.toString();
            if (_logger.isLoggable(Level.FINE)) {
                _logger.fine("incoming msg to broadcast pipe:command=" + theCommand);
             }
        }        
    }
View Full Code Here

    private static final String NAMESPACE = ReplicationState.NAMESPACE;
    private static final String ROUTEADV = ReplicationState.ROUTEADV;
   
    RouteAdvertisement getRouteAdvertisement(Message msg) {
        RouteAdvertisement routeAdv = null;
        MessageElement routeElement = msg.getMessageElement(NAMESPACE, ROUTEADV);
        if(routeElement != null) {
            try {
                XMLDocument asDoc = (XMLDocument) StructuredDocumentFactory.newStructuredDocument(
                        routeElement.getMimeType(), routeElement.getStream());
                routeAdv = (RouteAdvertisement)
                        AdvertisementFactory.newAdvertisement(asDoc);
            } catch (IOException io) {
                io.printStackTrace();
            }
View Full Code Here

        if(!this.getReplicationMeasurementEnabled()) {
            return;
        }
        int measurementInterval = this.getReplicationMeasurementInterval();
        long id = -1L;
        MessageElement idMsgElement =
            receivedMessage.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        if(idMsgElement != null) {
            id = (Long.decode(idMsgElement.toString())).longValue();
            //System.out.println("messageReceived: bulkId = " + id);
        }
        if(id % measurementInterval != 0) {
            return;
        }
        //get send start time for measurements
        long sendStartTime = -1L;
        MessageElement sendStartMsgElement =
            receivedMessage.getMessageElement(MESSAGE_SEND_START_TIME, MESSAGE_SEND_START_TIME);
        if(sendStartMsgElement != null) {
            sendStartTime =
                (Long.decode(sendStartMsgElement.toString())).longValue();
            if(sendStartTime > 0L) {
                //System.out.println("message receipt time: " + (System.currentTimeMillis() - sendStartTime));
            }
        }
        _logger.log(Level.INFO, "messageReceiptSucceeded: bulkId = " + id + " receiptTime = "
View Full Code Here

                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();
                    ReplicationState state = createReplicationState(msg);
                    processQueryState(state, receiver);
View Full Code Here

        }
    }

    //This method is assumed to be called only for broadcast method
    private ReplicationState createReplicationState(Message msg) {
        MessageElement bidiMsgElement =
                msg.getMessageElement(ReplicationState.MESSAGE_BIDI_STYLE,
                        ReplicationState.MESSAGE_BIDI_STYLE);
        boolean isBiDiStyle = (bidiMsgElement == null)
            ? false : Boolean.valueOf(bidiMsgElement.toString());
       
        ReplicationState result
                = isBiDiStyle ? ReplicationState.createReplicationState(msg)
                : ReplicationState.createBroadcastReplicationState(msg);
        result.setBiDiStyle(isBiDiStyle);
View Full Code Here

        return receiver.isExpensiveMethod(theCommand);
    }

    private RouteAdvertisement getRouteAdvertisement(Message msg) {
        RouteAdvertisement routeAdv = null;
        MessageElement routeElement = msg.getMessageElement(ReplicationState.NAMESPACE, ReplicationState.ROUTEADV);
        if (routeElement != null) {
            try {
                XMLDocument asDoc = (XMLDocument) StructuredDocumentFactory.newStructuredDocument(
                        routeElement.getMimeType(), routeElement.getStream());
                routeAdv = (RouteAdvertisement)
                        AdvertisementFactory.newAdvertisement(asDoc);
            } catch (IOException io) {
                io.printStackTrace();
            }
View Full Code Here

        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);
            MessageElement commandMsgElement = msg.getMessageElement(ReplicationState.MESSAGE_COMMAND,
                    ReplicationState.MESSAGE_COMMAND);
            if (origMsgElement != null && idMsgElement != null && commandMsgElement != null) {
                String originatingInstanceName = origMsgElement.toString();
                JxtaUnicastPipeUtil.sendOverUnicastPipe(null, originatingInstanceName, idMsgElement.toString(),
                            commandMsgElement.toString(), ackMsg);
            }
        }
    }
View Full Code Here

        if (!this.getReplicationMeasurementEnabled()) {
            return;
        }
        int measurementInterval = this.getReplicationMeasurementInterval();
        long id = -1L;
        MessageElement idMsgElement =
                receivedMessage.getMessageElement(ReplicationState.MESSAGE_ID, ReplicationState.MESSAGE_ID);
        if (idMsgElement != null) {
            id = (Long.decode(idMsgElement.toString())).longValue();
            //System.out.println("messageReceived: bulkId = " + id);
        }
        if (id % measurementInterval != 0) {
            return;
        }
        //get send start time for measurements
        long sendStartTime = -1L;
        MessageElement originatingMsgElement =
                receivedMessage.getMessageElement(ReplicationState.ORIGINATING_INSTANCE_NAME,
                        ReplicationState.ORIGINATING_INSTANCE_NAME);
        MessageElement sendStartMsgElement =
                receivedMessage.getMessageElement(ReplicationState.MESSAGE_SEND_START_TIME, ReplicationState.MESSAGE_SEND_START_TIME);
        if (sendStartMsgElement != null) {
            sendStartTime =
                    (Long.decode(sendStartMsgElement.toString())).longValue();
            if (sendStartTime > 0L) {
                //System.out.println("message receipt time: " + (System.currentTimeMillis() - sendStartTime));
            }
        }
        _logger.log(Level.INFO, "messageReceiptSucceeded: bulkId = " + id + " receiptTime = "
View Full Code Here

                }
                 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");
                    }
                } else {
                    if (_logger.isLoggable(Level.FINE)) {
                        _logger.fine("Message  :"+ msgElement.toString());
                    }
                }
            } catch (Exception e) {
                 if (_logger.isLoggable(Level.FINEST)) {
                    _logger.log(Level.FINEST, "exception occurred in pipeMsgEvent", e);
View Full Code Here

TOP

Related Classes of net.jxta.endpoint.MessageElement

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.