Package org.xmlBlaster.engine.msgstore

Examples of org.xmlBlaster.engine.msgstore.I_Map


   /**
    * Tests overflow of maxNumOfBytes() of a CACHE.
    */
   public void testByteOverflow() {
      I_Map i_map = this.currMap;
      ME = "I_MapTest.testByteOverflow(" + i_map.getStorageId() + ")[" + i_map.getClass().getName() + "]";
      System.out.println("***" + ME);
      try {
         StorageId storageId = new StorageId(glob, "msgUnitStore", "ByteOverflowMapId");
         QueuePropertyBase prop = new MsgUnitStoreProperty(glob, "/node/test");

         MsgUnitWrapper mu = new MsgUnitWrapper(glob, createMsgUnit(false, 0),  storageId);
         long sizeEmpty = mu.getSizeInBytes();

         MsgUnitWrapper[] queueEntries = {
            new MsgUnitWrapper(glob, createMsgUnit(false, 0),  storageId),
            new MsgUnitWrapper(glob, createMsgUnit(false, 0),  storageId),
            new MsgUnitWrapper(glob, createMsgUnit(false, 0),  storageId),
            // Each above entry has 3,311 bytes = 9,922, the next one has 9,932 bytes
            // so when it is entered two of the above need to be swapped away
            // as maxBytes=13,244
            new MsgUnitWrapper(glob, createMsgUnit(false, 2*sizeEmpty-1), storageId),
            new MsgUnitWrapper(glob, createMsgUnit(false, 0),  storageId)};

         final long maxBytesCache = 4*sizeEmpty;
         prop.setMaxBytes(1000000);
         prop.setMaxBytesCache(maxBytesCache);
         assertEquals(ME+": Wrong capacity", 1000000, prop.getMaxBytes());
         assertEquals(ME+": Wrong cache capacity", maxBytesCache, prop.getMaxBytesCache());
         i_map.initialize(storageId, prop);
         assertEquals(ME+": Wrong queue ID", storageId, i_map.getStorageId());

         long numOfBytes = 0;
         for(int i=0; i<queueEntries.length; i++) {
            i_map.put(queueEntries[i]);
            numOfBytes += queueEntries[i].getSizeInBytes();
         }

         assertEquals(ME+": Wrong size", queueEntries.length, i_map.getNumOfEntries());
         assertEquals(ME+": Wrong bytes", numOfBytes, i_map.getNumOfBytes());

         System.out.println("***" + ME + " [SUCCESS]");
         i_map.clear();
         i_map.shutdown();
      }
      catch(XmlBlasterException e) {
         log.severe("Exception thrown: " + e.getMessage());
         fail(ME + ": Exception thrown: " + e.getMessage());
      }
View Full Code Here


         loc = (setCache) ? "NumOfBytesCache" : "NumOfBytes";
      }
      else {
         loc = (setCache) ? "NumOfEntriesCache" : "NumOfEntries";
      }
      I_Map pm = this.persistentStore;
      if (pm == null)
         return getStorageId() + ": No persistence store found, setMax"+loc+"(" + max + ") ignored";

      Object obj = pm.getProperties();
      if (!(obj instanceof QueuePropertyBase))
         return getStorageId() + ": Configuration does not support setMax"+loc+"(" + max + "), ignored request";
      QueuePropertyBase property = (QueuePropertyBase)obj;
      long oldMax = 0;
      if (setBytes) {
View Full Code Here

   /**
    * @see I_Map#embeddedObjectsToXml(OutputStream, Properties)
    */
   public long embeddedObjectsToXml(OutputStream out, Properties props) throws Exception {
      I_Map ps = this.persistentStore;
      if (ps != null) {
         return ps.embeddedObjectsToXml(out, props);
      }
      log.warning("Sorry, dumping transient entries to '" + out + "' is not implemented");
      return 0;
   }
View Full Code Here

   //I_MapEntry changeMsgUnitEntry(I_MapEntry entry, I_ChangeCallback callback) throws XmlBlasterException {
   //   return this.msgUnitCache.change(entry, callback);
   //}
   void change(MsgUnitWrapper msgUnitWrapper) throws XmlBlasterException {
      if (isInMsgStore(msgUnitWrapper)) {
         I_Map msgUnitCache = this.msgUnitCache;
         if (msgUnitCache == null) { // on startup
            return;
         }
         // msgUnitCache.change(msgUnitWrapper, null);
         msgUnitCache.updateCounters(msgUnitWrapper);
      }
   }
View Full Code Here

      synchronized(this.msgUnitWrapperUnderConstructionMutex) {
         if (this.msgUnitWrapperUnderConstruction != null && this.msgUnitWrapperUnderConstruction.getUniqueId() == uniqueId)
            return this.msgUnitWrapperUnderConstruction;
      }

      I_Map msgUnitCache = this.msgUnitCache;
      if (msgUnitCache == null) { // on startup
         return null;
      }

      return (MsgUnitWrapper)msgUnitCache.get(uniqueId);
   }
View Full Code Here

      TopicProperty topicProperty = this.topicProperty;
      if (topicProperty != null)
         sb.append(topicProperty.toXml(extraOffset+Constants.INDENT));

      I_Map msgUnitCache = this.msgUnitCache;
      if (msgUnitCache != null) {
         sb.append(msgUnitCache.toXml(extraOffset+Constants.INDENT));
      }

      I_Queue historyQueue = this.historyQueue;
      if (historyQueue != null) {
         sb.append(historyQueue.toXml(extraOffset+Constants.INDENT));
View Full Code Here

            if (topicHandler == null)
               continue;
            //log.info("topicHandler " + i + ": " + topicHandler.getUniqueKey());
            try {
               out.write(("\n <TopicHandler id='"+topicHandler.getUniqueKey()+"'><topic>").getBytes("UTF-8"));
               I_Map m = topicHandler.getMsgUnitCache();
               if (m != null) {
                 PersistenceCachePlugin c = null;
                 if (m instanceof PersistenceCachePlugin) c = (PersistenceCachePlugin)m;
                 MsgUnitStoreProperty p = (MsgUnitStoreProperty)m.getProperties();
                 long bc = (c != null) ? c.getNumOfCachedBytes() : 0;
                 long ec = (c != null) ? c.getNumOfCachedEntries() : 0;
                 out.write(("\n   <persistence relating='msgUnitStore' entries='"+m.getNumOfEntries()
                       +"' entriesCache='"+ec+"' bytes='"+m.getNumOfBytes()+"' bytesCache='"+bc+"'/>").getBytes("UTF-8"));
                 out.write(p.toXml("  ").getBytes("UTF-8"));
                 out.write(("\n </topic></TopicHandler>").getBytes("UTF-8"));
                 currentBytes += m.getNumOfBytes();
                 currentBytesCache += bc;
                 currentEntries += m.getNumOfEntries();
                 currentEntriesCache += ec;
                 currentMaxBytes += p.getMaxBytes();
                 currentMaxBytesCache += p.getMaxBytesCache();
                 currentMaxEntries += p.getMaxEntries();
                 currentMaxEntriesCache += p.getMaxEntriesCache();
View Full Code Here

TOP

Related Classes of org.xmlBlaster.engine.msgstore.I_Map

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.