use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class StoreWorker method hasEntryInWriteBehindQueue.
private boolean hasEntryInWriteBehindQueue(RecordStore recordStore) {
if (recordStore == null) {
return false;
}
MapDataStore mapDataStore = recordStore.getMapDataStore();
WriteBehindStore dataStore = (WriteBehindStore) mapDataStore;
WriteBehindQueue<DelayedEntry> writeBehindQueue = dataStore.getWriteBehindQueue();
return writeBehindQueue.size() != 0;
}
use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class StoreWorker method runInternal.
private void runInternal() {
final long now = Clock.currentTimeMillis();
// if this node is the owner of a partition, we use this criteria time.
final long ownerHighestStoreTime = calculateHighestStoreTime(lastHighestStoreTime, now);
// if this node is the backup of a partition, we use this criteria time because backups are processed after delay.
final long backupHighestStoreTime = ownerHighestStoreTime - backupDelayMillis;
lastHighestStoreTime = ownerHighestStoreTime;
List<DelayedEntry> ownersList = null;
List<DelayedEntry> backupsList = null;
for (int partitionId = 0; partitionId < partitionCount; partitionId++) {
if (currentThread().isInterrupted()) {
break;
}
RecordStore recordStore = getRecordStoreOrNull(mapName, partitionId);
if (!hasEntryInWriteBehindQueue(recordStore)) {
continue;
}
boolean localPartition = isPartitionLocal(partitionId);
if (!localPartition) {
backupsList = initListIfNull(backupsList, partitionCount);
selectEntriesToStore(recordStore, backupsList, backupHighestStoreTime);
} else {
ownersList = initListIfNull(ownersList, partitionCount);
selectEntriesToStore(recordStore, ownersList, ownerHighestStoreTime);
}
}
if (!isEmpty(ownersList)) {
Map<Integer, List<DelayedEntry>> failuresPerPartition = writeBehindProcessor.process(ownersList);
removeFinishedStoreOperationsFromQueues(mapName, ownersList);
reAddFailedStoreOperationsToQueues(mapName, failuresPerPartition);
}
if (!isEmpty(backupsList)) {
doInBackup(backupsList);
}
notifyFlush();
}
use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class WriteBehindManager method newWriteBehindProcessor.
private WriteBehindProcessor newWriteBehindProcessor(final MapStoreContext mapStoreContext) {
WriteBehindProcessor writeBehindProcessor = createWriteBehindProcessor(mapStoreContext);
StoreListener<DelayedEntry> storeListener = new InternalStoreListener(mapStoreContext);
writeBehindProcessor.addStoreListener(storeListener);
return writeBehindProcessor;
}
use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class WriteBehindStore method notifyFlush.
public void notifyFlush() {
long nextSequenceNumber = sequence.get() + 1;
DelayedEntry firstEntry = writeBehindQueue.peek();
if (firstEntry == null) {
if (!flushSequences.isEmpty()) {
findAwaitingFlushesAndSendNotification(nextSequenceNumber);
}
} else {
findAwaitingFlushesAndSendNotification(firstEntry.getSequence());
}
}
use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class CoalescedWriteBehindQueue method calculateStoreTime.
/**
* If this is an existing key in this queue, use previously set store time;
* since we do not want to shift store time of an existing key on every update.
*/
private void calculateStoreTime(DelayedEntry delayedEntry) {
Data key = (Data) delayedEntry.getKey();
DelayedEntry currentEntry = map.get(key);
if (currentEntry != null) {
long currentStoreTime = currentEntry.getStoreTime();
delayedEntry.setStoreTime(currentStoreTime);
}
}
Aggregations