Search in sources :

Example 11 with DelayedEntry

use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.

the class DefaultRecordStore method updateStoreStats.

private void updateStoreStats() {
    if (!(mapDataStore instanceof WriteBehindStore) || !mapContainer.getMapConfig().isStatisticsEnabled()) {
        return;
    }
    long now = Clock.currentTimeMillis();
    WriteBehindQueue<DelayedEntry> writeBehindQueue = ((WriteBehindStore) mapDataStore).getWriteBehindQueue();
    List<DelayedEntry> delayedEntries = writeBehindQueue.asList();
    for (DelayedEntry delayedEntry : delayedEntries) {
        Record record = getRecordOrNull(toData(delayedEntry.getKey()), now, false);
        onStore(record);
    }
}
Also used : Record(com.hazelcast.map.impl.record.Record) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) WriteBehindStore(com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)

Example 12 with DelayedEntry

use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.

the class WriteBehindQueueTest method testWBQ_counter_is_zero.

@Test
public void testWBQ_counter_is_zero() {
    final AtomicInteger counter = new AtomicInteger(0);
    final WriteBehindQueue<DelayedEntry> queue = createBoundedWBQ(counter);
    addEnd(1000, queue);
    queue.clear();
    assertEquals(0, counter.intValue());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 13 with DelayedEntry

use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.

the class WriteBehindQueueTest method createDelayedEntryList.

private List<DelayedEntry> createDelayedEntryList(int numberOfEntriesToCreate) {
    final List<DelayedEntry> list = new ArrayList<DelayedEntry>(numberOfEntriesToCreate);
    SerializationService ss1 = new DefaultSerializationServiceBuilder().build();
    final long storeTime = Clock.currentTimeMillis();
    for (int i = 0; i < numberOfEntriesToCreate; i++) {
        final DelayedEntry<Data, Object> e = DelayedEntries.createWithoutValue(ss1.toData(i), storeTime, i);
        list.add(e);
    }
    return list;
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) ArrayList(java.util.ArrayList) SerializationService(com.hazelcast.spi.serialization.SerializationService) Data(com.hazelcast.nio.serialization.Data) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)

Example 14 with DelayedEntry

use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.

the class WriteBehindQueueTest method testCounter_offer_thenRemove.

@Test
public void testCounter_offer_thenRemove() {
    final AtomicInteger counter = new AtomicInteger(0);
    final WriteBehindQueue<DelayedEntry> queue = createBoundedWBQ(counter);
    addEnd(1000, queue);
    queue.drainTo(new ArrayList<DelayedEntry>(1000));
    assertEquals(0, counter.intValue());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 15 with DelayedEntry

use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.

the class WriteBehindQueueTest method testWBQMaxSizeException_withMultipleWBQ.

@Test(expected = ReachedMaxSizeException.class)
public void testWBQMaxSizeException_withMultipleWBQ() {
    final AtomicInteger counter = new AtomicInteger(0);
    final WriteBehindQueue<DelayedEntry> queue1 = createBoundedWBQ(counter);
    final WriteBehindQueue<DelayedEntry> queue2 = createBoundedWBQ(counter);
    final WriteBehindQueue<DelayedEntry> queue3 = createBoundedWBQ(counter);
    final WriteBehindQueue<DelayedEntry> queue4 = createBoundedWBQ(counter);
    // put total 1001 items. Max allowed is 1000
    addEnd(10, queue1);
    addEnd(500, queue2);
    addEnd(400, queue3);
    addEnd(91, queue4);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) DelayedEntry(com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

DelayedEntry (com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry)28 ArrayList (java.util.ArrayList)9 Data (com.hazelcast.nio.serialization.Data)7 HashMap (java.util.HashMap)6 List (java.util.List)6 WriteBehindStore (com.hazelcast.map.impl.mapstore.writebehind.WriteBehindStore)5 Map (java.util.Map)5 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)4 WriteBehindQueue (com.hazelcast.map.impl.mapstore.writebehind.WriteBehindQueue)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 QuickTest (com.hazelcast.test.annotation.QuickTest)3 Queue (java.util.Queue)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Test (org.junit.Test)3 MapConfig (com.hazelcast.config.MapConfig)1 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 MapDataStore (com.hazelcast.map.impl.mapstore.MapDataStore)1