Examples of DummyEntry


Examples of org.xmlBlaster.util.queuemsg.DummyEntry

            DummyEntry[] entries = new DummyEntry[imax];
            List<I_Entry> list = new ArrayList<I_Entry>();

            for (int i=0; i < imax; i++) {
               entries[i] = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), true);
               list.add(entries[i]);
            }

            queue.put(entries, false);
            this.checkSizeAndEntries("sizesCheck test 1: ", list, queue);
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

            long msgSize = 202010L;
            DummyEntry[] entries = new DummyEntry[imax];
            List<I_Entry> list = new ArrayList<I_Entry>();

            for (int i=0; i < imax; i++) {
               entries[i] = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), msgSize, true);
               list.add(entries[i]);
            }

            queue.put(entries, false);
            this.checkSizeAndEntries("sizesCheck test 1: ", list, queue);
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

         long msgSize = 100L;
         boolean isPersistent = true;
         DummyEntry[] entries = new DummyEntry[imax];

         for (int i=0; i < imax; i++) {
            entries[i] = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), msgSize, isPersistent);
         }

         queue.put(entries[0], false); // <-- OK
         queue.put(entries[1], false); // <-- OK
         try {
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

     
      public void run() {
         try {
            for (int i=0; i < this.numOfEntries; i++) {
               Thread.sleep(this.delay);
               DummyEntry queueEntry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), true);
               this.queue.put(queueEntry, this.ignoreInterceptor);
            }
         }
         catch (Exception ex) {
            ex.printStackTrace();
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

      int num = 30;
      boolean success = false;
      for (int i=0; i < num; i++) {
         try {
            log.info("put with break entry " + i + "/" + num + " please kill the DB manually to test reconnect");
            DummyEntry entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), sizeOfMsg, true);
            queue.put(entry, false);
            try {
               Thread.sleep(5000L);
            }
            catch (Exception ex) {
            }
         }
         catch (XmlBlasterException ex) {
            if (log.isLoggable(Level.FINE))  log.fine(ex.getMessage());
            if ("resource.db.unavailable".equalsIgnoreCase(ex.getErrorCodeStr())) {
               log.info("the communication to the db has been lost");
               success = true;
               break;
            }
            else throw ex;
         }
      }
     
      assertTrue(me + ": Timed out when waiting to loose the connection to the DB", success);
      success = false; // reset the flag
      log.info("preparing to reconnect again ...");

      for (int i=0; i < num; i++) {
         try {
            log.info("put with break entry " + i + "/" + num + " please restart the the DB to test reconnect");
            DummyEntry entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), sizeOfMsg, true);
            queue.put(entry, false);
            log.info("the communication to the db has been reestablished");
            success = true;
            break;
         }
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

         prop.put("tableNamePrefix", "TEST");
         prop.put("entriesTableName", "_entries");
         I_Queue tmpQueue = pluginManager.getPlugin(pluginInfo, queueId, cbProp);
         tmpQueue.clear();
         // add some persistent entries and then shutdown ...
         DummyEntry entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), 100, true);
         tmpQueue.put(entry, false);
         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), 100, true);
         tmpQueue.put(entry, false);
         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), 100, true);
         tmpQueue.put(entry, false);
         tmpQueue.shutdown(); // to allow to initialize again
         I_Queue tmpQueue2 = pluginManager.getPlugin(pluginInfo, queueId, cbProp);
         long numOfEntries = tmpQueue2.getNumOfEntries();
         assertEquals("Wrong number of entries in queue", 3L, numOfEntries);
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

         int size = 100;

         for (int j=0; j < 4; j++) {
            DummyEntry[] entries = new DummyEntry[nmax];
            for (int i=0; i < nmax; i++) {
               entries[i] = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queue.getStorageId(), size, true);
            }
            long time1 = System.currentTimeMillis();
            tmpQueue.put(entries, false);
            long delta = System.currentTimeMillis() - time1;
            log.info("multiple put '" + nmax + "' entries took '" + 0.001 * delta + "' seconds which is '" + 1.0 * delta / nmax + "' ms per entry");
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

      ArrayList entryList = new ArrayList(numOfMsg*numOfQueues);
      t0 = System.currentTimeMillis();
      for (int j=0; j < numOfMsg; j++) {
         for (int i=0; i < numOfQueues; i++) {
            DummyEntry entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queues[i].getStorageId(), sizeOfMsg, true);
            entryList.add(entry);
            queues[i].put(entry, false);
         }
      }
      t1 = System.currentTimeMillis() - t0;
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

      ArrayList entryList = new ArrayList(numOfQueues*numOfMsg);
      t0 = System.currentTimeMillis();
      for (int i=0; i < numOfQueues; i++) {
         DummyEntry[] entries = new DummyEntry[numOfMsg];
         for (int j=0; j < numOfMsg; j++) {
            entries[j] = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, queues[i].getStorageId(), sizeOfMsg, true);
            entryList.add(entries[j]);
         }
         queues[i].put(entries, false);

      }
View Full Code Here

Examples of org.xmlBlaster.util.queuemsg.DummyEntry

         StorageId storageId = new StorageId(this.glob, "cb:queue1");
         String queueName = storageId.getStrippedId();

         long size = 100; // entry.getSizeInBytes();
         DummyEntry entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, storageId, size, true);

         try {
            this.manager.addEntry(queueName, entry);
            assertTrue(me + " adding an entry with no queue nor node associated should fail", false);        
         }
         catch (XmlBlasterException ex) {
            log.info("the previous exception is expected and is OK in this context");
         }
         try {
            this.manager.addEntry(queueName, entry);
            assertTrue(me + " adding an entry with no queue associated should fail", false);
         }
         catch (XmlBlasterException ex) {
            log.info("the previous exception is expected and is OK in this context");
         }
         boolean ret = this.manager.addEntry(queueName, entry);
         assertEquals(me + " adding an entry should give back true", true, ret);

         long totalSize = size;
         ret = this.manager.addEntry(queueName, entry);
         assertEquals(me + " adding an entry the second time should give back 'false'", false, ret);
         // add some more entries
         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, storageId, size, true);
         this.manager.addEntry(queueName, entry);
         totalSize += size;

         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, storageId, size, false);
         this.manager.addEntry(queueName, entry);
         totalSize += size;

         // check here a modification of an entry:
         long oldNumOfEntries = this.manager.getNumOfEntries(queueName);
         long oldNumOfBytes = this.manager.getNumOfBytes(queueName);

         entry.setPersistent(true);
         this.manager.modifyEntry(queueName, entry, entry);
         long[] dataIds = new long[1];
         dataIds[0] = entry.getUniqueId();
         ArrayList tmp = this.manager.getEntries(storageId, dataIds);
         assertEquals(me + " modified entry is not correct ", true, ((DummyEntry)(tmp.get(0))).isPersistent());

         entry.setPersistent(false);
         this.manager.modifyEntry(queueName, entry, entry);
         dataIds = new long[1];
         dataIds[0] = entry.getUniqueId();
         tmp = this.manager.getEntries(storageId, dataIds);
         assertEquals(me + " modified entry is not correct ", false, ((DummyEntry)(tmp.get(0))).isPersistent());

         // did the modification change the number or the size of the entries ?
         assertEquals(me + " modification did change the number of entries", oldNumOfEntries, this.manager.getNumOfEntries(queueName));
         assertEquals(me + " modification did change the number of bytes", oldNumOfBytes, this.manager.getNumOfBytes(queueName));

         long numOfBytes = this.manager.getNumOfBytes(queueName);
         assertEquals(me + " num of bytes in queue 'queue1'", totalSize, numOfBytes);

         // count the number of entries here: they should be 4
         this.manager.deleteAllTransient(queueName);
         numOfBytes = this.manager.getNumOfBytes(queueName);
         totalSize -= size;
         assertEquals(me + " num of bytes in queue 'queue1' after deleting transients", totalSize, numOfBytes);

         ReturnDataHolder retHolder = this.manager.getAndDeleteLowest(storageId, 2, -1, 10, -1, false, true);
         assertEquals(me + " getAndDeleteLowest check", 2, retHolder.countEntries);

         long entriesToDelete[] = new long[2];
         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, storageId, size, true);
         entriesToDelete[0] = entry.getUniqueId();
         this.manager.addEntry(queueName, entry);
         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, storageId, size, true);
         this.manager.addEntry(queueName, entry);
         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, storageId, size, true);
         entriesToDelete[1] = entry.getUniqueId();
         this.manager.addEntry(queueName, entry);
         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, storageId, size, true);
         this.manager.addEntry(queueName, entry);

         boolean[] tmpArr = this.manager.deleteEntries(queueName, entriesToDelete);
         int numOfDel = 0;
         for (int i=0; i < tmpArr.length; i++) {
            if ( tmpArr[i] ) numOfDel++;
         }

         assertEquals(me + " deleteEntries check", 2, numOfDel);

         retHolder = this.manager.deleteFirstEntries(queueName, 1L, 10000L);
         assertEquals(me + " deleteFirstEntries check", 1, retHolder.countEntries);

         ArrayList arrayList = this.manager.getEntriesByPriority(storageId, -1, -1, 0, 9, null);
         assertEquals(me + " getEntriesByPriority check", 1, arrayList.size());


         long[] entriesToGet = new long[2];
         entry = new DummyEntry(glob, PriorityEnum.MAX_PRIORITY, storageId, size, true);
         entriesToGet[0] = entry.getUniqueId();
         this.manager.addEntry(queueName, entry);

         arrayList = this.manager.getEntriesBySamePriority(storageId, -1, -1);
         assertEquals(me + " getEntriesBySamePriority check", 1, arrayList.size());

         arrayList = this.manager.getEntries(storageId, -1, -1, null);
         assertEquals(me + " getEntries check", 2, arrayList.size());

         entry = new DummyEntry(glob, PriorityEnum.NORM_PRIORITY, storageId, size, true);
         entriesToGet[1] = entry.getUniqueId();

         this.manager.addEntry(queueName, entry);
         arrayList = this.manager.getEntriesWithLimit(storageId, entry);
         assertEquals(me + " getEntriesWithLimit check", 2, arrayList.size());
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.