Examples of MsgKeyData


Examples of org.xmlBlaster.util.key.MsgKeyData

    * The other store() method is called for following messages, to store only message-content.
    * @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.key.MsgKeyData

      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);

View Full Code Here

Examples of org.xmlBlaster.util.key.MsgKeyData

                  pq.setState(Constants.STATE_ERASED);
                  pq.setVolatile(true);
                  pq.setSender(sessionName);
                  pq.addDestination(new Destination(sub.getSessionInfo().getSessionName()));
                  pq.addClientProperty("__oid", getUniqueKey());
                  MsgKeyData k = this.msgKeyData;
                  if (k != null && k.getDomain() != null)
                     pq.addClientProperty("__domain", k.getDomain());
                  pq.addClientProperty("__subscriptionId", sub.getSubSourceSubscriptionId());
                  if (eraseKey != null) // To have all attributes for cluster slaves getting forwarded the erase
                     pq.addClientProperty("__eraseKey", eraseKey.toXml());
                  if (eraseQos != null) // To have all attributes for cluster slaves getting forwarded the erase
                     pq.addClientProperty("__eraseQos", eraseQos.toXml());
View Full Code Here

Examples of org.xmlBlaster.util.key.MsgKeyData

            String key = (String)obj[1];
            byte[] content = (byte[])obj[2];
            Integer referenceCounter = (Integer)obj[3];
            Integer historyReferenceCounter = (Integer)obj[4];
            PublishQosServer publishQosServer = new PublishQosServer(glob, qos, true); // true marks from persistent store (prevents new timestamp)
            MsgKeyData msgKeyData = glob.getMsgKeyFactory().readObject(key);
            MsgUnit msgUnit = new MsgUnit(msgKeyData, content, publishQosServer.getData());
            MsgUnitWrapper msgUnitWrapper = new MsgUnitWrapper(glob, msgUnit, storageId,
                                      referenceCounter.intValue(), historyReferenceCounter.intValue(), sizeInBytes);
            msgUnitWrapper.startExpiryTimer();
            return msgUnitWrapper;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgUnitWrapper", ex);
         }
      }
      else if (ENTRY_TYPE_MSG_SERIAL.equalsIgnoreCase(type)) {  // probably unused (not found in my tests)
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 3) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                         "Expected 3 entries in serialized object stream but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp);
            }
            MsgUnit msgUnit = (MsgUnit)obj[0];
            Integer referenceCounter = (Integer)obj[1];
            Integer historyReferenceCounter = (Integer)obj[2];
            msgUnit.setGlobal(glob);
            MsgUnitWrapper msgUnitWrapper = new MsgUnitWrapper(glob, msgUnit, storageId,
                             referenceCounter.intValue(), historyReferenceCounter.intValue(), sizeInBytes);
            msgUnitWrapper.startExpiryTimer();
            return msgUnitWrapper;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgUnitWrapper", ex);
         }
      }

      else if (ENTRY_TYPE_TOPIC_XML.equalsIgnoreCase(type)) { // still used
         try {
            ObjectInputStream objStream = new ObjectInputStream(is);
            Object[] obj = (Object[])objStream.readObject();
            if (obj.length < 2) {
               throw new XmlBlasterException(glob, ErrorCode.INTERNAL_ILLEGALARGUMENT, ME,
                         "Expected 2 entries in serialized object stream but got " + obj.length + " for priority=" + priority + " timestamp=" + timestamp);
            }
            String qos = (String)obj[0];
            String key = (String)obj[1];
            byte[] content = null;
            PublishQosServer publishQosServer = new PublishQosServer(glob, qos, true); // true marks from persistent store (prevents new timestamp)
            MsgKeyData msgKeyData = glob.getMsgKeyFactory().readObject(key);
            MsgUnit msgUnit = new MsgUnit(msgKeyData, content, publishQosServer.getData());
            TopicEntry topicEntry = new TopicEntry(glob, msgUnit, storageId, type, sizeInBytes);
            return topicEntry;
         }
         catch (Exception ex) {
View Full Code Here

Examples of org.xmlBlaster.util.key.MsgKeyData

            String key = meat.getKey();
            byte[] content = meat.getContent();
            long referenceCounter = meat.getRefCount();
            long historyReferenceCounter = meat.getRefCount2();
            PublishQosServer publishQosServer = new PublishQosServer(glob, qos, true); // true marks from persistent store (prevents new timestamp)
            MsgKeyData msgKeyData = glob.getMsgKeyFactory().readObject(key);
            MsgUnit msgUnit = new MsgUnit(msgKeyData, content, publishQosServer.getData());
            MsgUnitWrapper msgUnitWrapper = new MsgUnitWrapper(glob, msgUnit, storageId,
                                      (int)referenceCounter, (int)historyReferenceCounter, meat.getByteSize());
            msgUnitWrapper.startExpiryTimer();
            return msgUnitWrapper;
         }
         catch (Exception ex) {
            throw new XmlBlasterException(glob, ErrorCode.INTERNAL_UNKNOWN, ME, "createEntry-MsgUnitWrapper", ex);
         }
      }
      else if (ENTRY_TYPE_TOPIC_XML.equalsIgnoreCase(type)) { // still used
         try {
            String qos = meat.getQos();
            String key = meat.getKey();
            byte[] content = null;
            PublishQosServer publishQosServer = new PublishQosServer(glob, qos, true); // true marks from persistent store (prevents new timestamp)
            MsgKeyData msgKeyData = glob.getMsgKeyFactory().readObject(key);
            MsgUnit msgUnit = new MsgUnit(msgKeyData, content, publishQosServer.getData());
            TopicEntry topicEntry = new TopicEntry(glob, msgUnit, storageId, type, meat.getByteSize());
            return topicEntry;
         }
         catch (Exception ex) {
View Full Code Here

Examples of org.xmlBlaster.util.key.MsgKeyData

            info_.put(ReplicationConstants.REPLICATION_VERSION, "1.0");
         String tmpKey = "replication.countSingleMsg";
         String tmpVal = info_.get(tmpKey, null);
         if (tmpVal == null)
            info_.put(tmpKey, "true");
         MsgKeyData key = global.getMsgKeyFactory().readObject(publishKey);
         String oid = key.getOid();
         info.put("mom.topicName", oid); // this must ALWAYS be set if using replication
         prepareReplSource(replPrefix != null);
      }
      this.recursive = info_.getBoolean("filewatcher.recursive", false);
      createDirectoryManagers();
View Full Code Here

Examples of org.xmlBlaster.util.key.MsgKeyData

      for (int i=0; i < keys.length; i++)
         connectQos.addClientProperty(keys[i], info_.get(keys[i], null));
      publisher = new XmlBlasterPublisher();
      String oid = null;
      if (publishKey != null) {
         MsgKeyData key = global.getMsgKeyFactory().readObject(publishKey);
         oid = key.getOid();
      }
      publisher.initWithExistingGlob(global, publishKey, publishQos, 0);
      replSource = new ReplSource(info_, oid);
      replSourceEngine = new ReplSourceEngine(replPrefix, publisher, replSource);
      replSource.setEngine(replSourceEngine);
View Full Code Here

Examples of org.xmlBlaster.util.key.MsgKeyData

           
            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();
View Full Code Here

Examples of org.xmlBlaster.util.key.MsgKeyData

     
      xmlKey_literal = xmlKey_literal.trim();
      if (!xmlKey_literal.startsWith("<")) {
         keyType = ASCII_TYPE;  // eg "Airport/Runway1/WindVeloc3"
         this.keyData = new MsgKeyData(glob);
         this.keyData.setOid(xmlKey_literal);

         // Works well with ASCII, but is switched off for the moment
         // perhaps we should make it configurable through a property file !!!
         // Example: xmlKey_literal="Airport.*" as a regular expression
View Full Code Here

Examples of org.xmlBlaster.util.key.MsgKeyData

      try {
         String xml =
           "<key oid='HELLO' contentMime='image/gif' contentMimeExtended='2.0' domain='RUGBY'>\n" +
           "   <filter><subtag></subtag></filter>\n" +
           "</key>\n";
         MsgKeyData key = factory.readObject(xml);

         assertEquals("", "HELLO", key.getOid());
         assertEquals("", "image/gif", key.getContentMime());
         assertEquals("", "2.0", key.getContentMimeExtended());
         assertEquals("", "RUGBY", key.getDomain());
         assertEquals("", "<filter><subtag></subtag></filter>", key.getClientTags());
         assertEquals("", false, key.isInternal());
         assertEquals("", false, key.isPluginInternal());
         assertEquals("", false, key.isDeadMessage());
      }
      catch (XmlBlasterException e) {
         fail("testParse failed: " + e.toString());
      }

      try {
         String xml = "<key oid='__HELLO'/>";
         MsgKeyData key = factory.readObject(xml);

         assertEquals("", "__HELLO", key.getOid());
         assertEquals("", true, key.isInternal());
         assertEquals("", false, key.isPluginInternal());
         assertEquals("", false, key.isDeadMessage());
      }
      catch (XmlBlasterException e) {
         fail("testParse failed: " + e.toString());
      }


      try {
         String xml = "<key oid='_HELLO'/>";
         MsgKeyData key = factory.readObject(xml);

         assertEquals("", "_HELLO", key.getOid());
         assertEquals("", false, key.isInternal());
         assertEquals("", true, key.isPluginInternal());
         assertEquals("", false, key.isDeadMessage());
      }
      catch (XmlBlasterException e) {
         fail("testParse failed: " + e.toString());
      }

      try {
         String xml = "<key oid='" + Constants.OID_DEAD_LETTER + "'/>";
         MsgKeyData key = factory.readObject(xml);

         assertEquals("", Constants.OID_DEAD_LETTER, key.getOid());
         assertEquals("", true, key.isInternal());
         assertEquals("", false, key.isPluginInternal());
         assertEquals("", true, key.isDeadMessage());
      }
      catch (XmlBlasterException e) {
         fail("testParse failed: " + e.toString());
      }

      try {
         String xml = "<key/>";
         MsgKeyData key = factory.readObject(xml);

         assertTrue("", (String)null != key.getOid());
         assertEquals("", false, key.isInternal());
         assertEquals("", false, key.isPluginInternal());
         assertEquals("", false, key.isDeadMessage());
      }
      catch (XmlBlasterException e) {
         fail("testParse failed: " + e.toString());
      }
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.