Examples of StorableLastModIterationCallback


Examples of com.fasterxml.storemate.store.backend.StorableLastModIterationCallback

       
        final ArrayList<E> result = new ArrayList<E>(Math.min(100, maxCount));
        final AtomicInteger totalCounter = new AtomicInteger(0);

        IterationResult r = _stores.getEntryStore().iterateEntriesByModifiedTime(
            new StorableLastModIterationCallback() {
                int total = 0;
                K key = null;
                // to ensure List advances timestamp:
                boolean timestampHasAdvanced = false;
View Full Code Here

Examples of com.fasterxml.storemate.store.backend.StorableLastModIterationCallback

            }
            return stats;
        }
       
        final long tombstoneThreshold = _timeMaster.currentTimeMillis() - _tombstoneTTLMsecs;
        _entryStore.iterateEntriesByModifiedTime(new StorableLastModIterationCallback() {
            @Override
            public IterationAction verifyTimestamp(long timestamp) {
                return IterationAction.PROCESS_ENTRY;
            }
View Full Code Here

Examples of com.fasterxml.storemate.store.backend.StorableLastModIterationCallback

       _verifyCounts(1L, store);

       // then verify we can see it via iteration
       final AtomicInteger count = new AtomicInteger(0);
       store.iterateEntriesByModifiedTime(StoreOperationSource.REQUEST, null, 1L,
               new StorableLastModIterationCallback() {
           @Override
           public IterationAction verifyTimestamp(long timestamp) {
            if (timestamp != startTime) {
                throw new IllegalStateException("Wrong timestamp, "+timestamp+", expected "+startTime);
            }
            return IterationAction.PROCESS_ENTRY;
           }

           @Override
           public IterationAction verifyKey(StorableKey key) {
            if (!key.equals(KEY1)) {
                throw new IllegalStateException("Wrong key: "+key);
            }
            return IterationAction.PROCESS_ENTRY;
           }

           @Override
           public IterationAction processEntry(Storable entry) {
            count.addAndGet(1);
            return IterationAction.PROCESS_ENTRY;
           }
       });
       assertEquals(1, count.get());

       // then add another entry; but in "wrong order"
       final long time2 = timeMaster.forceCurrentTimeMillis(startTime - 200L).currentTimeMillis();
       final StorableKey KEY2 = storableKey("data/entry/2");
       final byte[] SMALL_DATA2 = "Foo".getBytes("UTF-8");
       metadata = new StorableCreationMetadata(
               /*existing compression*/ null,
               calcChecksum32(SMALL_DATA2), HashConstants.NO_CHECKSUM);
       resp = store.insert(StoreOperationSource.REQUEST, null,
               KEY2, new ByteArrayInputStream(SMALL_DATA2),
               metadata, ByteContainer.simple(CUSTOM_METADATA_IN));
        assertTrue(resp.succeeded());
        assertNull(resp.getPreviousEntry());
        _verifyCounts(2L, store);

        // and verify order
        final ArrayList<Long> timestamps = new ArrayList<Long>();
        final ArrayList<StorableKey> keys = new ArrayList<StorableKey>();
        store.iterateEntriesByModifiedTime(StoreOperationSource.REQUEST, null,
                0L, new StorableLastModIterationCallback() {
            long lastTimestamp;

            @Override
            public IterationAction verifyTimestamp(long timestamp) {
                timestamps.add(timestamp);
                lastTimestamp = timestamp;
                return IterationAction.PROCESS_ENTRY;
            }

            @Override
            public IterationAction verifyKey(StorableKey key) {
                keys.add(key);
                return IterationAction.PROCESS_ENTRY;
            }

            @Override
            public IterationAction processEntry(Storable entry) {
                assertEquals(lastTimestamp, entry.getLastModified());
                return IterationAction.PROCESS_ENTRY;
            }
        });
        assertEquals(2, timestamps.size());
        assertEquals(2, keys.size());
        assertEquals(Long.valueOf(time2), timestamps.get(0));
        assertEquals(Long.valueOf(startTime), timestamps.get(1));
        assertEquals(KEY2, keys.get(0));
        assertEquals(KEY1, keys.get(1));

        // finally, traverse partial:
        count.set(0);
        store.iterateEntriesByModifiedTime(StoreOperationSource.REQUEST, null,
                startTime-50L,
                new StorableLastModIterationCallback() {
            @Override
            public IterationAction verifyTimestamp(long timestamp) {
                if (timestamp != startTime) {
                    throw new IllegalStateException("Wrong timestamp, "+timestamp+", expected "+startTime);
                }
                return IterationAction.PROCESS_ENTRY;
            }

            @Override
            public IterationAction verifyKey(StorableKey key) {
                if (!key.equals(KEY1)) {
                    throw new IllegalStateException("Wrong key: "+key);
                }
                return IterationAction.PROCESS_ENTRY;
            }

            @Override
            public IterationAction processEntry(Storable entry) {
                count.addAndGet(1);
                return IterationAction.PROCESS_ENTRY;
            }
        });
        assertEquals(1, count.get());

        // and once more, using exact start value
        count.set(0);
        store.iterateEntriesByModifiedTime(StoreOperationSource.REQUEST, null,
                startTime-200L,
                new StorableLastModIterationCallback() {
            @Override
            public IterationAction verifyTimestamp(long timestamp) {
                if ((timestamp != (startTime-200L)) && (timestamp != startTime)) {
                    throw new IllegalStateException("Wrong timestamp: "+timestamp+" (startTime "+startTime+")");
                }
View Full Code Here

Examples of com.fasterxml.storemate.store.backend.StorableLastModIterationCallback

           _verifyCounts(i+1, store);
       }

       // And then verify traversal order
       store.iterateEntriesByModifiedTime(StoreOperationSource.REQUEST, null,
               startTime-50L, new StorableLastModIterationCallback() {
           int index = 0;
          
           @Override
           public IterationAction verifyTimestamp(long timestamp) {
               assertEquals(startTime + index * 5000, timestamp);
View Full Code Here

Examples of com.fasterxml.storemate.store.backend.StorableLastModIterationCallback

       _verifyCounts(1L, store);
      
       // then verify we can see it via iteration
       final AtomicInteger count = new AtomicInteger(0);
       store.iterateEntriesByModifiedTime(StoreOperationSource.REQUEST, null, secondTime,
               new StorableLastModIterationCallback() {
           @Override
           public IterationAction verifyTimestamp(long timestamp) {
               if (timestamp != secondTime) {
                   throw new IllegalStateException("Wrong timestamp, "+timestamp+", expected "+secondTime);
               }
View Full Code Here

Examples of com.fasterxml.storemate.store.backend.StorableLastModIterationCallback

            final long fromTime, final boolean includeDeleted)
        throws StoreException
    {
        final ArrayList<Storable> result = new ArrayList<Storable>();
        if (maxCount > 0) {
            _backend.iterateEntriesByModifiedTime(new StorableLastModIterationCallback() {
                // we are fine with all timestamps
                @Override
                public IterationAction verifyTimestamp(long timestamp) {
                    return IterationAction.PROCESS_ENTRY;
                }
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.