Examples of MsgQosData


Examples of org.xmlBlaster.util.qos.MsgQosData

         "  <isPublish/>\n" +
         "  <clientProperty name='StringKey' type=''><BlaBla attr1='val1' attr2=' val2 '> Something </BlaBla></clientProperty>\n" +
         "</qos>";     
     
      MsgQosSaxFactory parser = new MsgQosSaxFactory(this.glob);
      MsgQosData data = parser.readObject(xml);
      ClientProperty prop = data.getClientProperty("StringKey");
      System.out.println(prop.toXml());
      // assertEquals("", true, prop.isBase64());
     
     
      String val = "<BlaBla attr1='val1' attr2=' val2 '> Something </BlaBla>";
      prop = new ClientProperty("StringKey", null, Constants.ENCODING_FORCE_PLAIN, val);
      System.out.println(prop.toXml());

      xml =  "<qos>\n" +
      "  <isPublish/>\n" +
      "  <clientProperty name='StringKey' type='' encoding='forcePlain'><qos attr1='val1' attr2=' val2 '> Something </qos></clientProperty>\n" +
      "</qos>";     
     
      parser = new MsgQosSaxFactory(this.glob);
      data = parser.readObject(xml);
      prop = data.getClientProperty("StringKey");
      System.out.println(prop.toXml());
     
      xml =  "<qos>\n" +
      "  <isPublish/>\n" +
      "  <clientProperty name='StringKey' type='' encoding='forcePlain'><clientProperty name='aaa' type='' encoding=''>Something</clientProperty></clientProperty>\n" +
      "</qos>";     
     
      parser = new MsgQosSaxFactory(this.glob);
      data = parser.readObject(xml);
      prop = data.getClientProperty("StringKey");
      System.out.println(prop.toXml());
     
      System.out.println("END");
   }
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

         // TODO: REQ engine.qos.update.queue states that the queue size is passed and not the curr msgArr.length
         ReferenceEntry entry = (ReferenceEntry)entries[i];
         MsgUnit mu = entry.getMsgUnitOrNull();
         if (mu == null)
            continue;
         MsgQosData msgQosData = (MsgQosData)mu.getQosData().clone();
         msgQosData.setTopicProperty(null);
         if (entry instanceof MsgQueueUpdateEntry) {
            MsgQueueUpdateEntry updateEntry = (MsgQueueUpdateEntry)entry;
            msgQosData.setState(updateEntry.getState());
            msgQosData.setSubscriptionId(updateEntry.getSubscriptionId());
         }
         msgQosData.setQueueIndex(i);
         msgQosData.setQueueSize(entries.length);
         if (msgQosData.getNumRouteNodes() == 1) {
            msgQosData.clearRoutes();
         }
        
         ret.add(new MsgUnit(mu, null, null, msgQosData));
         // ret[i] = new MsgUnitRaw(mu, mu.getKeyData().toXml(), mu.getContent(), mu.getQosData().toXml());
      }
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

   public NodeMasterInfo getMasterId(NodeMasterInfo nodeMasterInfo, MsgUnit msgUnit) throws XmlBlasterException {

      QueryKeyData[] keyMappings = nodeMasterInfo.getKeyMappings()// These are the key based queries

      if (msgUnit.getQosData() instanceof MsgQosData) {
         MsgQosData qos = (MsgQosData)msgUnit.getQosData();
         if (qos.isPtp()) {
            // We check the domain of each MsgUnit entry (PtP messages may use a static topic just for communication channel)
            for (int ii=0; ii<keyMappings.length; ii++) {
               if (keyMappings[ii].getDomain().equals("*") || keyMappings[ii].getDomain().equals(msgUnit.getKeyData().getDomain())) {
                  if (log.isLoggable(Level.FINE)) log.fine("Found master='" + nodeMasterInfo.getNodeId().getId() +
                           "' stratum=" + nodeMasterInfo.getStratum() + " for PtP message '" + msgUnit.getLogId() +
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

    * @param messageWrapper The container with all necessary message info.
    */
   public final void store(MsgUnitWrapper messageWrapper) throws XmlBlasterException
   {
      MsgKeyData xmlKey = messageWrapper.getMsgKeyData();
      MsgQosData qos = messageWrapper.getMsgQosData();
      //String mime = messageWrapper.getContentMime();
      byte[] content = messageWrapper.getMsgUnit().getContent();

      String oid = xmlKey.getOid(); // The file name

      FileLocator.writeFile(path, oid + XMLKEY_TOKEN, xmlKey.toXml().getBytes());
      FileLocator.writeFile(path, oid, content);
      FileLocator.writeFile(path, oid + XMLQOS_TOKEN, qos.toXml().getBytes());

      if (log.isLoggable(Level.FINE)) log.fine("Successfully stored " + oid);
   }
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

            if (log.isLoggable(Level.FINE)) log.fine(ME+": Creating TopicEntry to make topic persistent");
            if (this.topicProperty==null || this.msgKeyData==null) {
               log.severe(ME+": Can't create useful TopicEntry in state=" + getStateStr() + " no QoS is available");
               return null;
            }
            MsgQosData msgQosData = new MsgQosData(serverScope, MethodName.PUBLISH);
            msgQosData.setTopicProperty(this.topicProperty);
            msgQosData.setAdministrative(true);
            msgQosData.touchRcvTimestamp();
            msgQosData.setPersistent(true);
            msgQosData.setSender(creatorSessionName);
            MsgUnit msgUnit = new MsgUnit(this.msgKeyData, null, msgQosData);
            this.topicEntry = new TopicEntry(serverScope, msgUnit, null);
            isNew = true;
            if (log.isLoggable(Level.FINE)) log.fine(ME+": Created persistent topicEntry '" + this.topicEntry.getUniqueId() + "'"); //: " + this.topicEntry.toXml());
         }
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

   public PublishReturnQos publish(SessionInfo publisherSessionInfo, MsgUnit msgUnit, PublishQosServer publishQosServer) throws XmlBlasterException
   {
      if (log.isLoggable(Level.FINE)) log.fine(ME+": publish() publisherSessionInfo '" + publisherSessionInfo.getId() + "', message '" + msgUnit.getLogId() + "' ...");

      PublishReturnQos publishReturnQos = null;
      MsgQosData msgQosData = null;

      StatusQosData qos = new StatusQosData(serverScope, MethodName.PUBLISH);
      qos.setKeyOid(this.uniqueKey);
      qos.setState(Constants.STATE_OK);
      qos.setRcvTimestamp(publishQosServer.getRcvTimestamp());
      publishReturnQos = new PublishReturnQos(serverScope, qos);

      MsgKeyData msgKeyData = (MsgKeyData)msgUnit.getKeyData();
      msgQosData = (MsgQosData)msgUnit.getQosData();
      /* Happens in RequestBroker already
      if (msgQosData.getSender() == null) {
         msgQosData.setSender(publisherSessionInfo.getSessionName());
      }
      */

      // Do a log.warning if topic meta XML is different
      if (!clientTagLog) {
         try {
            XmlKey xmlKey = this.xmlKey;
            if (xmlKey != null) {
               String newTags = msgKeyData.getClientTags();
               if (newTags != null && newTags.length() > 0) {
                  String oldTags = ((MsgKeyData)xmlKey.getKeyData()).getClientTags();
                  if (!newTags.equals(oldTags)) {
                     log.warning(ME+": Changing topic meta information from '" + oldTags + "' to '" + newTags + "' is not supported and this change is ignored, please check your publisher.");
                     clientTagLog = true;
                  }
               }
            }
         }
         catch (Throwable e) {
            e.printStackTrace();
            log.severe(ME+": Ignoring unexpected exception during meta info check:" + e.toString());
         }
      }

      if (msgQosData.isAdministrative()) {
         if ( isUnconfigured() || isSoftErased() || allowedToReconfigureTopicAndFixWrongLimits(msgQosData)) {
            administrativeInitialize(msgKeyData, msgQosData, publishQosServer);
            if (!msgQosData.isFromPersistenceStore()) {
               msgQosData.setAdministrative(true);
               msgQosData.setRcvTimestamp(this.topicEntry.getMsgQosData().getRcvTimestamp());
               msgQosData.setPersistent(true);
               this.topicEntry.setMsgUnit(msgUnit);
               this.requestBroker.changePersistentTopicHandler(this.topicEntry);
            }
         }
         else {
            log.warning(ME+": Sorry we are in state '" + getStateStr() + "', reconfiguring TopicHandler is not yet supported, we ignore the reconfiguration request");
         }
         if (this.handlerIsNewCreated) {
            this.handlerIsNewCreated = false;
            // Check all known query subscriptions if the new message fits as well (does it only if TopicHandler is new)
            serverScope.getRequestBroker().checkExistingSubscriptions(publisherSessionInfo, this, publishQosServer);
         }
         if (msgQosData.isFromPersistenceStore()) {
            log.info(ME+": Topic is successfully recovered from persistency to state " + getStateStr() +
                     //((requestBroker.getTopicStore()!=null) ? (" '" + requestBroker.getTopicStore().getStorageId() + "'") : "") +
                     " with " + getNumOfHistoryEntries() + " history entries (" + getNumOfCacheEntries() + " currently referenced msgUnits are loaded).");
         }
         else {
            log.info(ME+": Topic is successfully configured by administrative message.");
         }
         publishReturnQos.getData().setStateInfo("Administrative configuration request handled");
         return publishReturnQos;
      }

      if (!this.administrativeInitialize) {
         administrativeInitialize(msgKeyData, msgQosData, publishQosServer);
      }

      if (!isAlive()) {
         toAlive();
      }
      if (this.handlerIsNewCreated) {
         // Check all known query subscriptions if the new message fits as well (does it only if TopicHandler is new)
         serverScope.getRequestBroker().checkExistingSubscriptions(publisherSessionInfo, this, publishQosServer);
         this.handlerIsNewCreated = false;
      }

      int initialCounter = 1; // Force referenceCount until update queues are filled (volatile messages)
      MsgUnitWrapper msgUnitWrapper = null;

      try { // finally
         boolean changed = true;

         final boolean isInvisiblePtp = publishQosServer.isPtp() && !publishQosServer.isSubscribable();
         final boolean addToHistoryQueue = this.historyQueue != null && !isInvisiblePtp;

         if (!isInvisiblePtp) {  // readonly is only checked for Pub/Sub?
            if (this.topicProperty.isReadonly() && hasHistoryEntries()) {
               log.warning(ME+": Sorry, published message '" + msgKeyData.getOid() + "' rejected, topic is readonly.");
               throw new XmlBlasterException(serverScope, ErrorCode.USER_PUBLISH_READONLY, ME, "Sorry, published message '" + msgKeyData.getOid() + "' rejected, topic is readonly.");
            }
         }

         msgUnitWrapper = new MsgUnitWrapper(serverScope, msgUnit, this.msgUnitCache, initialCounter, 0, -1);

         if (!isAlive()) {
             toAlive();
         }

         // Forcing RAM entry temporary (reset in finally below) to avoid performance critical harddisk IO during initialization, every callback/subject/history queue put()/take() is changing the reference counter of MsgUnitWrapper. For persistent messages this needs to be written to harddisk
         // If the server crashed during this RAM operation it is not critical as the publisher didn't get an ACK yet
         synchronized(this.msgUnitWrapperUnderConstructionMutex) {
            // A queue (e.g. callback queue) could swap its entry and reload it during this initialization phase,
            // in this case we need to assure that it receives our RAM based MsgUnitWrapper (with all current settings)
            // in case it changes the referenceCounter
            this.msgUnitWrapperUnderConstruction = msgUnitWrapper;
         }

         try {
            // marker if we are working on the history queue
            // A historyQueue.take() could trigger entry.remove() -> topicHandler.entryDestroyed() -> toUnreferenced() ==> The topic would be invalid for the current publish
            this.isHistoryHandling = true;

            if (addToHistoryQueue && msgUnitWrapper.hasRemainingLife()) { // no sense to remember
               if (msgQosData.isForceUpdate() == false && hasHistoryEntries()) {
                  MsgQueueHistoryEntry entry = (MsgQueueHistoryEntry)this.historyQueue.peek();
                  if (entry != null) {
                     MsgUnitWrapper old = entry.getMsgUnitWrapper();
                     if (old != null) {
                        changed = !old.getMsgUnit().sameContent(msgUnit.getContent());
                     }
                  }
               }

               try { // Cleanup if persistent queue was temporary unavailable
                  long numHist = getNumOfHistoryEntries();
                  if (numHist > 1L && numHist > this.historyQueue.getMaxNumOfEntries()) {
                     long count = numHist-this.historyQueue.getMaxNumOfEntries();
                     // TODO: Implement count>1 in takeLowest():
                     List<I_Entry> entryList = this.historyQueue.takeLowest((int) count, -1L, null, false);
                     if (entryList.size() != count) {
                        log.severe(ME+": Can't remove expected entry, entryList.size()=" + entryList.size() + ": " + this.historyQueue.toXml(""));
                     }
                  }
               }
               catch (XmlBlasterException e) {
                  log.severe(ME+": History queue take() problem: " + e.getMessage());
               }

               try { // increments reference counter += 1
                  this.historyQueue.put(new MsgQueueHistoryEntry(serverScope, msgUnitWrapper, this.historyQueue.getStorageId()), I_Queue.USE_PUT_INTERCEPTOR);
               }
               catch (XmlBlasterException e) {
                  log.severe(ME+": History queue put() problem: " + e.getMessage());
               }

               try {
                  long numHist = getNumOfHistoryEntries();
                  if (numHist > 1L && numHist > this.historyQueue.getMaxNumOfEntries()) {
                     List<I_Entry> entryList = this.historyQueue.takeLowest(1, -1L, null, false);
                     if (entryList.size() != 1) {
                        throw new XmlBlasterException(serverScope, ErrorCode.INTERNAL_UNKNOWN, ME,
                              "Can't remove expected entry, entryList.size()=" + entryList.size() + ": " + this.historyQueue.toXml(""));
                     }
                     MsgQueueHistoryEntry entry = (MsgQueueHistoryEntry)entryList.get(0);
                     if (log.isLoggable(Level.FINE)) { if (!entry.isInternal()) log.fine(ME+": Removed oldest entry in history queue."); }
                  }
               }
               catch (XmlBlasterException e) {
                  log.severe(ME+": History queue take() problem: " + e.getMessage());
               }
            }
         }
         finally {
            this.isHistoryHandling = false;
         }

         // NOTE: Putting entries into callback queues must be outside of a synchronized(topicHandler) to avoid deadlock
         //       The DispatchWorker removes a MsgUnitWrapper entry from the msgstore (see entryDestroyed()) and would deadlock
         //       This is currently addressed as the MsgUnitWrapper.lookup is a dirty read on the topicHandler

         //----- 2a. now we can send updates to all destination clients:
         if (publishQosServer.isPtp()) {
            /*publishReturnQos =*/ forwardToDestinations(publisherSessionInfo, msgUnitWrapper, publishQosServer);
            if (!publishQosServer.isSubscribable()) {
               publishReturnQos.getData().setStateInfo("PtP request handled");
               return publishReturnQos;
            }
         }

         //----- 2b. now we can send updates to all subscribed clients:
         if (log.isLoggable(Level.FINE)) log.fine(ME+": Message " + msgUnit.getLogId() + " handled, now we can send updates to all interested clients.");
         if (changed || msgQosData.isForceUpdate()) { // if the content changed of the publisher forces updates ...
            invokeCallbackAndHandleFailure(publisherSessionInfo, msgUnitWrapper);
         }
         msgUnitWrapper.startExpiryTimer();
      }
      catch (XmlBlasterException e) {
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

    * @param msgQosData
    * @return true if dirtyRead is set, false otherwise.
    */
   public static boolean isDirtyRead(SubscriptionInfo sub, MsgUnitWrapper msgUnitWrapper)
      throws XmlBlasterException {
      MsgQosData msgQosData = msgUnitWrapper.getMsgQosData();
      if (sub.getSessionInfo().getSubjectInfo().isCluster()) {
         if (log.isLoggable(Level.FINEST)) log.finest("TopicHandler: Slave node '" + sub.getSessionInfo() + "' has dirty read message '" + msgUnitWrapper.toXml());
         if (msgQosData.dirtyRead(sub.getSessionInfo().getSubjectInfo().getNodeId())) {
            if (log.isLoggable(Level.FINE)) log.fine("TopicHandler: Slave node '" + sub.getSessionInfo() + "' has dirty read message '" + sub.getSubscriptionId() + "', '" + sub.getKeyData().getOid() + "' we don't need to send it back");
            return true;
         }
      }
      return false;
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

  
   private String preparePubQos(String origQos) throws XmlBlasterException {
      if (replSourceEngine == null || origQos == null)
         return origQos;
     
      MsgQosData msgQosData = global.getMsgQosFactory().readObject(origQos);
      MsgQosData preparedMsgQosData = replSourceEngine.preparePubQos(msgQosData);
      return preparedMsgQosData.toXml();
   }
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

            if (infos[i].getSize() > maximumChunkSize) {
               // log.warning("Not implemented yet: the size '" + infos[i].getSize() + "' is bigger than the maximum chunk size (" + maximumChunkSize + ")");
               InputStream is = directoryManager.getContentStream(infos[i]);
               Global glob = access.getGlobal();
               MsgKeyData keyData = glob.getMsgKeyFactory().readObject(publishKey);
               MsgQosData qosData = glob.getMsgQosFactory().readObject(publishQos);
               qosData.addClientProperty(ContribConstants.FILENAME_ATTR, infos[i].getRelativeName());
               qosData.addClientProperty(ContribConstants.FILE_DATE, infos[i].getTimestamp());
               qosData.addClientProperty(Constants.addJmsPrefix(XBConnectionMetaData.JMSX_MAX_CHUNK_SIZE, log), maximumChunkSize);
               String subDir = directoryManager.getSubDir();
               if (subDir != null)
                  qosData.addClientProperty(ContribConstants.SUBDIR_ATTR, subDir);
               access.publishStream(is, keyData, qosData, maximumChunkSize, replSourceEngine);
               if (log.isLoggable(Level.FINE))
                  log.fine(ME+": Successfully published file " + infos[i].getRelativeName() + " with size=" +infos[i].getSize());
            }
            else if (infos[i].getSize() > Integer.MAX_VALUE) {
View Full Code Here

Examples of org.xmlBlaster.util.qos.MsgQosData

   private final Global glob;
   private final MsgQosData msgQosData;

   public PublishQos(Global glob, String serialData) {
      this.glob = (glob==null) ? Global.instance() : glob;
      this.msgQosData = new MsgQosData(this.glob, this.glob.getMsgQosFactory(), serialData, MethodName.PUBLISH);
      this.msgQosData.setMethod(MethodName.PUBLISH);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.