Package net.jxta.endpoint

Examples of net.jxta.endpoint.MessageElement


    public synchronized void pipeMsgEvent(PipeMsgEvent event) {
        // Extract the message.
        Message message = event.getMessage();
        MessageElementEnumeration msgEnum = message.getElements();
        MessageElement elm = null;
        JXTAClassLoader classLoader = new JXTAClassLoader();

        while (msgEnum.hasMoreElements()) {
            elm = (MessageElement) msgEnum.nextElement();

            String tag = elm.getName();

            if (tag.equals(_TAG)) {
                System.out.println("get an actor class from remote peer ");

                InputStream inputStream = null;
                try {
                    inputStream = elm.getStream();
                    int length = elm.getLength();
                    byte[] buffer = new byte[length];
                    int bytesRead;
                    if ((bytesRead = inputStream.read(buffer)) != length) {
                        throw new IOException("While reading " + elm
                                + ", read only " + bytesRead
View Full Code Here


        //byte[] buff = new byte[MAXBUFF];
        //int size = actStream.read(buff);
        //actStream.close();
        //if (size < MAXBUFF) {
        try {
            MessageElement msgelm = msg
                    .newMessageElement(_TAG, null, actStream);
            msg.addElement(msgelm);
        } catch (java.io.IOException e) {
            // go try again;
        }
View Full Code Here

                }               
                return;
            }

            // get the message element named SenderMessage
            MessageElement msgElement = msg.getMessageElement(SenderMessage, SenderMessage);
            MessageElement idMsgElement = msg.getMessageElement(MESSAGE_ID, MESSAGE_ID);
            MessageElement bulkMsgElement = msg.getMessageElement(BULK_MESSAGE_MODE, BULK_MESSAGE_MODE);
//            if (_logger.isLoggable(Level.FINE)) {
//                _logger.fine("msgElement=" + msgElement +
//                             " idMsgElement=" + idMsgElement +
//                             " bulkMsgElement=" + bulkMsgElement);
//            }            
View Full Code Here

        String ackRequiredString = (String)sentMessage.getMessageProperty(MESSAGE_ACK_REQUIRED);       
        printFastAckStats(sentMessage, true);           
        if(ackRequiredString.equalsIgnoreCase("Y")) {
            //_logger.fine("doing fast ack...");
            //for bulk case
            MessageElement bulkMsgElement = sentMessage.getMessageElement(BULK_MESSAGE_MODE, BULK_MESSAGE_MODE);
            if(bulkMsgElement != null) {
                doFastBulkAcksFor(sentMessage, bulkMsgElement);
            } else {
                //for non bulk case
                MessageElement idMsgElement = sentMessage.getMessageElement(MESSAGE_ID, MESSAGE_ID);
                if(idMsgElement != null) {
                    doFastAckFor(sentMessage, idMsgElement);
                }
            }
        }
View Full Code Here

        String ackRequiredString = (String)sentMessage.getMessageProperty(MESSAGE_ACK_REQUIRED);       
        printFastAckStats(sentMessage, true);           
        if(ackRequiredString.equalsIgnoreCase("Y")) {
            //System.out.println("doing fast ack...");
            //for bulk case
            MessageElement bulkMsgElement = sentMessage.getMessageElement(BULK_MESSAGE_MODE, BULK_MESSAGE_MODE);
            if(bulkMsgElement != null) {
                doFastBulkAcksFor(sentMessage, bulkMsgElement);
            } else {
                //for non bulk case
                MessageElement idMsgElement = sentMessage.getMessageElement(MESSAGE_ID, MESSAGE_ID);
                if(idMsgElement != null) {
                    doFastAckFor(sentMessage, idMsgElement);
                }
            }
        }
View Full Code Here

        }
        boolean useLong = true;
        int measurementInterval = this.getReplicationMeasurementInterval();
        long id = -1L;
        String stringId = "";
        MessageElement idMsgElement =
            sentMessage.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        if(idMsgElement != null) {
            try {
                id = (Long.decode(idMsgElement.toString())).longValue();
            } catch (NumberFormatException ex) {
                useLong = false;
                stringId = idMsgElement.toString();
            }           
            //System.out.println("messageSendSucceeded: bulkId = " + id);
        }
        if(useLong) {
            stringId = ""+id;
View Full Code Here

    }   
   
    static List<ReplicationState> extractBulkReplicationStatesFromMessage(Message msg) {
        List<ReplicationState> states = null;
        byte[] data = null;
        MessageElement dataMsgElement =
            msg.getMessageElement(MESSAGE_DATA, MESSAGE_DATA);
        MessageElement totalStatesElement =
            msg.getMessageElement(MESSAGE_TOTAL_STATES, MESSAGE_TOTAL_STATES);
        if(dataMsgElement != null) {
            data = dataMsgElement.getBytes(false);
            ObjectInputStream ois = null;
            ByteArrayInputStream bis = null;
View Full Code Here

        byte[] trunkData = null;
        byte[] containerExtraParamsData = null;
        byte[] propertiesState = null;
        HashMap properties = null;
       
        MessageElement modeMsgElement =
            msg.getMessageElement(MESSAGE_MODE, MESSAGE_MODE);
        if(modeMsgElement != null) {
            mode = modeMsgElement.toString();
        }
        MessageElement idMsgElement =
            msg.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        if(idMsgElement != null) {
            id = idMsgElement.toString();
        }
       
        //added for bulk messages
        MessageElement bulkModeMsgElement =
            msg.getMessageElement(BULK_MESSAGE_MODE, BULK_MESSAGE_MODE);
        if(bulkModeMsgElement != null) {
            bulkMode = bulkModeMsgElement.toString();
        }
        MessageElement bulkIdMsgElement =
            msg.getMessageElement(BULK_MESSAGE_ID, BULK_MESSAGE_ID);
        if(bulkIdMsgElement != null) {
            bulkId = bulkIdMsgElement.toString();
        }
        //end added for bulk messages
       
        MessageElement appidMsgElement =
            msg.getMessageElement(MESSAGE_APPID, MESSAGE_APPID);
        if(appidMsgElement != null) {
            appid = appidMsgElement.toString();
        }
        MessageElement versionMsgElement =
            msg.getMessageElement(MESSAGE_VERSION, MESSAGE_VERSION);
        if(versionMsgElement != null) {
            version =
                (Long.decode(versionMsgElement.toString())).longValue();
        }       
        MessageElement commandMsgElement =
            msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);
        String command = commandMsgElement.toString();               
        MessageElement lastAccessMsgElement =
            msg.getMessageElement(MESSAGE_LAST_ACCESS, MESSAGE_LAST_ACCESS);
        if(lastAccessMsgElement != null) {
            lastAccess =
                (Long.decode(lastAccessMsgElement.toString())).longValue();
        }
        MessageElement maxInactiveMsgElement =
            msg.getMessageElement(MESSAGE_MAX_INACTIVE, MESSAGE_MAX_INACTIVE);
        if(maxInactiveMsgElement != null) {
            maxInactive =
                (Long.decode(maxInactiveMsgElement.toString())).longValue();
        }
        MessageElement instanceNameMsgElement =
            msg.getMessageElement(MESSAGE_INSTANCE_NAME, MESSAGE_INSTANCE_NAME);
        if(_logger.isLoggable(Level.FINE)) {
            _logger.fine("ReplicationState>>createReplicationState:instanceNameMsgElement: " + instanceNameMsgElement);
        }       
        if(instanceNameMsgElement != null) {
            instanceName = instanceNameMsgElement.toString();
            if(_logger.isLoggable(Level.FINE)) {
                _logger.fine("ReplicationState>>createReplicationState:instanceNameString: " + instanceName);
            }           
        }
        MessageElement extraParamMsgElement =
            msg.getMessageElement(MESSAGE_EXTRA_PARAM, MESSAGE_EXTRA_PARAM);
        if(extraParamMsgElement != null) {
            extraParam = extraParamMsgElement.toString();
        }
        //FIXME assuming queryResult is a string encoding an Integer
        MessageElement queryResultMsgElement =
            msg.getMessageElement(MESSAGE_QUERY_RESULT, MESSAGE_QUERY_RESULT);
        if(queryResultMsgElement != null) {
            queryResult =
                Integer.decode(maxInactiveMsgElement.toString());
        }              
        MessageElement dataMsgElement =
            msg.getMessageElement(MESSAGE_DATA, MESSAGE_DATA);
        if(dataMsgElement != null) {
            data = dataMsgElement.getBytes(false);
        }
        MessageElement trunkDataMsgElement =
            msg.getMessageElement(MESSAGE_TRUNK_DATA, MESSAGE_TRUNK_DATA);
        if(trunkDataMsgElement != null) {
            trunkData = trunkDataMsgElement.getBytes(false);
        }
        MessageElement containerExtraParamsDataMsgElement =
            msg.getMessageElement(MESSAGE_CONTAINER_EXTRA_PARAMS_DATA, MESSAGE_CONTAINER_EXTRA_PARAMS_DATA);
        if(containerExtraParamsDataMsgElement != null) {
            containerExtraParamsData = containerExtraParamsDataMsgElement.getBytes(false);
        }
        MessageElement propertiesMsgElement =
            msg.getMessageElement(MESSAGE_PROPERTIES_DATA, MESSAGE_PROPERTIES_DATA);
        if(propertiesMsgElement != null) {
            propertiesState = propertiesMsgElement.getBytes(false);
            if(propertiesState != null) {
                try {
                    properties = (HashMap)getObjectValue(propertiesState);
                } catch (Exception ex) {
                    ;
View Full Code Here

        String queryResult = null;
        String instanceName = null;
        byte[] propertiesState = null;
        HashMap properties = null;
        boolean isNack = false;
        MessageElement modeMsgElement =
            msg.getMessageElement(MESSAGE_MODE, MESSAGE_MODE);
        if(modeMsgElement != null) {
            mode = modeMsgElement.toString();
        }
        MessageElement idMsgElement =
            msg.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        String id = idMsgElement.toString();
        MessageElement appidMsgElement =
            msg.getMessageElement(MESSAGE_APPID, MESSAGE_APPID);
        String appid = appidMsgElement.toString();       
        MessageElement versionMsgElement =
            msg.getMessageElement(MESSAGE_VERSION, MESSAGE_VERSION);
        if(_logger.isLoggable(Level.FINE)) {
            _logger.fine("ReplicationState:createBroadcastReplicationState:versMsgElem=" + versionMsgElement);
        }        
        if(versionMsgElement != null) {
            version =
                (Long.decode(versionMsgElement.toString())).longValue();
        }
        MessageElement extraParamMsgElement =
            msg.getMessageElement(MESSAGE_EXTRA_PARAM, MESSAGE_EXTRA_PARAM);
        if(extraParamMsgElement != null) {
            extraParam = extraParamMsgElement.toString();
        }
        MessageElement queryResultMsgElement =
            msg.getMessageElement(MESSAGE_QUERY_RESULT, MESSAGE_QUERY_RESULT);
        if(queryResultMsgElement != null) {
            queryResult = queryResultMsgElement.toString();
        }       
        MessageElement commandMsgElement =
            msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);
        String command = commandMsgElement.toString();
        MessageElement instanceNameMsgElement =
            msg.getMessageElement(MESSAGE_INSTANCE_NAME, MESSAGE_INSTANCE_NAME);
        if(instanceNameMsgElement != null) {
            instanceName = instanceNameMsgElement.toString();
        }
        MessageElement nackMsgElement =
            msg.getMessageElement(MESSAGE_IS_NACK, MESSAGE_IS_NACK);
        if(nackMsgElement != null) {
            String isNackString = nackMsgElement.toString();
            if("Y".equalsIgnoreCase(isNackString)) {
                isNack = true;
            }
        }       
        /* don't need these message element - remove after testing
        //FIXME will need to add more later
        MessageElement lastAccessMsgElement =
            msg.getMessageElement(MESSAGE_LAST_ACCESS, MESSAGE_LAST_ACCESS);
        long lastAccess =
            (Long.decode(lastAccessMsgElement.toString())).longValue();
        MessageElement maxInactiveMsgElement =
            msg.getMessageElement(MESSAGE_MAX_INACTIVE, MESSAGE_MAX_INACTIVE);
        long maxInactive =
            (Long.decode(maxInactiveMsgElement.toString())).longValue();
        MessageElement instanceNameMsgElement =
            msg.getMessageElement(MESSAGE_INSTANCE_NAME, MESSAGE_INSTANCE_NAME);
        String instanceName = instanceNameMsgElement.toString();
        MessageElement extraParamMsgElement =
            msg.getMessageElement(MESSAGE_EXTRA_PARAM, MESSAGE_EXTRA_PARAM);
        String extraParam = extraParamMsgElement.toString();
         */
        byte[] data = null;
        MessageElement dataMsgElement =
            msg.getMessageElement(MESSAGE_DATA, MESSAGE_DATA);
        if(dataMsgElement != null) {
            data = dataMsgElement.getBytes(false);
        }
        byte[] trunkData = null;
        MessageElement trunkDataMsgElement =
            msg.getMessageElement(MESSAGE_TRUNK_DATA, MESSAGE_TRUNK_DATA);
        if(trunkDataMsgElement != null) {
            trunkData = trunkDataMsgElement.getBytes(false);
        }
       
        byte[] containerExtraParamsData = null;
        MessageElement containerExtraParamsMsgElement =
            msg.getMessageElement(MESSAGE_CONTAINER_EXTRA_PARAMS_DATA, MESSAGE_CONTAINER_EXTRA_PARAMS_DATA);
        if(containerExtraParamsMsgElement != null) {
            containerExtraParamsData = containerExtraParamsMsgElement.getBytes(false);
        }
        MessageElement propertiesMsgElement =
            msg.getMessageElement(MESSAGE_PROPERTIES_DATA, MESSAGE_PROPERTIES_DATA);
        if(propertiesMsgElement != null) {
            propertiesState = propertiesMsgElement.getBytes(false);
            if(propertiesState != null) {
                try {
                    properties = (HashMap)getObjectValue(propertiesState);
                } catch (Exception ex) {
                    ;
View Full Code Here

    public static Message createAckMessageFrom(Message msg) {
        Message ackMsg = new Message();
       
        //echo the mode
        String mode = MODE_WEB;
        MessageElement modeMsgElement =
            msg.getMessageElement(MESSAGE_MODE, MESSAGE_MODE);
        if(modeMsgElement != null) {
            mode = modeMsgElement.toString();
        }       
        ackMsg.addMessageElement(MESSAGE_MODE,
                              new StringMessageElement(MESSAGE_MODE,
                                                       mode,
                                                       null));        
        //echo the id
        MessageElement idMsgElement =
        msg.getMessageElement(MESSAGE_ID, MESSAGE_ID);
        String id = idMsgElement.toString();
        ackMsg.addMessageElement(MESSAGE_ID,
                              new StringMessageElement(MESSAGE_ID,
                                                       id,
                                                       null));
        //echo the appid
        MessageElement appidMsgElement =
            msg.getMessageElement(MESSAGE_APPID, MESSAGE_APPID);
        String appid = appidMsgElement.toString();
        ackMsg.addMessageElement(MESSAGE_APPID,
                              new StringMessageElement(MESSAGE_APPID,
                                                       appid,
                                                       null));
        //********** test begin**********************
        //get the current command
        MessageElement commandMsgElement =
            msg.getMessageElement(MESSAGE_COMMAND, MESSAGE_COMMAND);
        String previousCommand = commandMsgElement.toString();
        String theCommand = RETURN_MSG_COMMAND;
        if(previousCommand.equals(ReplicationState.HC_COMMAND)) {
            theCommand = RETURN_HC_MSG_COMMAND;
        }
        //this is a return command
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.