Package org.xmlBlaster.engine.msgstore

Examples of org.xmlBlaster.engine.msgstore.I_MapEntry


      if (log.isLoggable(Level.FINER)) log.finer("remove(" + mapEntry.getLogId() + ")");
      try {
         synchronized (this.storage) {
            if (mapEntry.getSortTimestamp() != null)
               this.lruSet.remove(mapEntry);
            I_MapEntry entry = (I_MapEntry)this.storage.remove(mapEntry.getUniqueIdStr());
            if (entry == null)
               return 0;

            if (entry.isPersistent()) {
               this.numOfPersistentEntries--;
               this.persistentSizeInBytes -= entry.getSizeInBytes();
            }
            entry.setStored(false);
            this.sizeInBytes -= entry.getSizeInBytes();
            return 1;
         }
      }
      finally { // since it should be outside the sync
         this.storageSizeListenerHelper.invokeStorageSizeListener();
View Full Code Here


    */
   public int remove(final long uniqueId) throws XmlBlasterException {
      if (log.isLoggable(Level.FINER)) log.finer("remove(" + uniqueId + ")");
      int ret = 0;
      synchronized (this.storage) {
         I_MapEntry mapEntry = get(uniqueId);
         if (mapEntry != null)
            ret = remove(mapEntry);
      }
      this.storageSizeListenerHelper.invokeStorageSizeListener();
      return ret;
View Full Code Here

    * @see I_Map#removeOldest()
    */
   public I_MapEntry removeOldest() throws XmlBlasterException {
      try {
         synchronized (this.storage) {
            I_MapEntry oldest = null;
            Iterator it = this.lruSet.iterator();
            if (it.hasNext()) {
               oldest = (I_MapEntry)it.next();
            }
            if (oldest != null) {
               remove(oldest);
               return oldest;
            }

            if (this.storage.size() > 0) {
               log.severe("LRU set has no entries, we remove an arbitrary entry from RAM map");
               it = this.storage.values().iterator();
               if (it.hasNext()) {
                  I_MapEntry entry = (I_MapEntry)it.next();
                  remove(entry);
                  return entry;
               }
            }

View Full Code Here

    * @see I_Map#change(I_MapEntry, I_ChangeCallback)
    */
   public I_MapEntry change(I_MapEntry entry, I_ChangeCallback callback) throws XmlBlasterException {
      synchronized(this.storage) {
         entry.getSizeInBytes(); // must be here since newEntry could reference same obj.
         I_MapEntry newEntry = entry;
         if (callback != null) newEntry = callback.changeEntry(entry);
         if (newEntry == null) return entry;
         if (newEntry.isPersistent() != entry.isPersistent()) {
            throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".change",
                  "changing  oldEntry.isPersistent=" + entry.isPersistent() + " to newEntry.isPersistent=" + newEntry.isPersistent() + "differs. This is not allowed");
         }
         if (entry != newEntry) { // then they are not the same reference ...
            int tmp = remove(entry);
            if (tmp < 1) throw new XmlBlasterException(this.glob,  ErrorCode.INTERNAL_UNKNOWN, ME + ".change", "the size of the entry '" + entry.getUniqueId() + "' has not been found on this map");
            put(newEntry);
View Full Code Here

   /**
    * @see I_Map#change(long, I_ChangeCallback)
    */
   public I_MapEntry change(long uniqueId, I_ChangeCallback callback) throws XmlBlasterException {
      synchronized(this.storage) {
         I_MapEntry oldEntry = get(uniqueId);
         return change(oldEntry, callback);
      }
   }
View Full Code Here

   {
      private static final long serialVersionUID = -8286998211709086682L;

      // We compare the MsgUnitWrapper by its cache entry timestamp
      public final int compare(Object o1, Object o2) {
         I_MapEntry id1 = (I_MapEntry)o1;
         I_MapEntry id2 = (I_MapEntry)o2;

         if (id1.getSortTimestamp() == null) id1.setSortTimestamp(new Timestamp()); // assert != null
         if (id2.getSortTimestamp() == null) id2.setSortTimestamp(new Timestamp()); // assert != null
        
         if (id1.getSortTimestamp().getTimestamp() > id2.getSortTimestamp().getTimestamp()) {
            return 1;
         }
         else if (id1.getSortTimestamp().getTimestamp() < id2.getSortTimestamp().getTimestamp()) {
            return -1;
         }
         return 0;
      }
View Full Code Here

    * @see I_Map#change(I_MapEntry, I_ChangeCallback)
    */
   public I_MapEntry change(I_MapEntry entry, I_ChangeCallback callback) throws XmlBlasterException {
      synchronized(this) { // is this the correct synchronization ??
         entry.getSizeInBytes(); // must be here since newEntry could reference same obj.
         I_MapEntry newEntry = entry;
         if (callback != null)
            newEntry = callback.changeEntry(entry);
         if (newEntry == null)
            return entry;
         if (newEntry.isPersistent() != entry.isPersistent()) {
            throw new XmlBlasterException(this.glob, ErrorCode.INTERNAL_UNKNOWN, ME + ".change",
                  "changing  oldEntry.isPersistent=" + entry.isPersistent() + " to newEntry.isPersistent=" + newEntry.isPersistent() + "differs. This is not allowed");
         }

         final boolean onlyRefCounter = false; // TODO Check if this can be optimized if only used for reference counting
        
         XBMeat newMeat = newEntry.getMeat();
         XBMeat oldMeat = entry.getMeat();
         long diffSize = databaseAccessor.modifyEntry(xbStore, newMeat, oldMeat, onlyRefCounter);
         this.numOfBytes += diffSize;
         if (entry.isPersistent())
            this.numOfPersistentBytes += diffSize;
View Full Code Here

   /**
    * @see I_Map#change(long, I_ChangeCallback)
    */
   public I_MapEntry change(long uniqueId, I_ChangeCallback callback) throws XmlBlasterException {
      synchronized (this) {
         I_MapEntry oldEntry = get(uniqueId);
         return change(oldEntry, callback);
      }
   }
View Full Code Here

                  } else if (ent instanceof ReferenceEntry) {
                     ReferenceEntry refEntry = (ReferenceEntry) ent;
                     XBStore xbStore = getXBStore(dbAccessorServerThree, serverScopeThree, refEntry.getStorageId());
                     dbAccessorServerThree.addEntry(xbStore, refEntry);
                  } else {
                     I_MapEntry entry = (I_MapEntry) ent;
                     if (relating.equals(Constants.RELATING_MSGUNITSTORE)) {
                        if (!entry.getStorageId().getPostfix1().startsWith(
                              relating + "_" + clusterNodeIdToTransfer)) {
                           logToFile(relating + ": Ignoring wrong cluster node "
                                 + entry.getStorageId().getPostfix1()
                                 + ": " + entry.getStorageId().getId());
                           return null;
                        }
                        MsgUnitWrapper msgUnitWrapper = (MsgUnitWrapper) entry;
                        entry.getStorageId().getXBStore().setPostfix(msgUnitWrapper.getKeyOid());
                     } else if (relating.equals(Constants.RELATING_SESSION)
                           || relating.equals(Constants.RELATING_SUBSCRIBE)) {
                        // "subPersistence,1_0" to "subPersistence,1.0"
                        // "topicStore_heron"
                        if (!entry.getStorageId().getPostfix1().startsWith(
                              relating + "_" + clusterNodeIdToTransfer)) {
                           logToFile(relating + ": Ignoring wrong cluster node "
                                 + entry.getStorageId().getPostfix1()
                                 + ": " + entry.getStorageId().getId());
                           return null;
                        }
                        entry.getStorageId().getXBStore().setPostfix(
                              ReplaceVariable.replaceAll(entry.getStorageId().getXBStore().getPostfix(), "1_0", "1.0"));
                     }
                     //else if (relating.equals(Constants.RELATING_TOPICSTORE)) {
                     //   TopicEntry topicEntry = (TopicEntry)entry;
                     // logToFile(queueNamePattern + " [processed=" + counter +
                     // "] processing topicStore " + entry.getLogId());
                     //}
                     XBStore xbStore = getXBStore(dbAccessorServerThree, serverScopeThree, entry.getStorageId());
                     dbAccessorServerThree.addEntry(xbStore, entry);
                  }
                  processed++;
                  if ((processed % 1000) == 0)
                     logToFile(queueNamePattern + " [processed=" + processed + "] processing ...");
View Full Code Here

                     entries = ((org.xmlBlaster.util.queue.I_Queue)this.persistentStore).peek((int)maxEntries, maxBytes);
                     int n = entries.size();
                     log.info(this.storageId.getId() + " Prefilling cache with " + n + " entries");
                     synchronized(this) {
                        for(int i=0; i<n; i++) {
                           I_MapEntry cleanEntry = (I_MapEntry)entries.get(i);
                           this.transientStore.put(cleanEntry);
                        }
                     }
                  }
                  catch (XmlBlasterException ex) {
View Full Code Here

TOP

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

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.