use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class CoalescedWriteBehindQueue method removeFirstOccurrence.
/**
* Removes the first occurrence of the specified element in this queue
* when searching it by starting from the head of this queue.
*
* @param incoming element to be removed.
* @return <code>true</code> if removed successfully, <code>false</code> otherwise
*/
@Override
public boolean removeFirstOccurrence(DelayedEntry incoming) {
Data incomingKey = (Data) incoming.getKey();
Object incomingValue = incoming.getValue();
DelayedEntry current = map.get(incomingKey);
if (current == null) {
return false;
}
Object currentValue = current.getValue();
if (incomingValue == null && currentValue == null || incomingValue != null && currentValue != null && incomingValue.equals(currentValue)) {
map.remove(incomingKey);
return true;
}
return false;
}
use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class CoalescedWriteBehindQueue method drainTo.
@Override
public int drainTo(Collection<DelayedEntry> collection) {
checkNotNull(collection, "collection can not be null");
Collection<DelayedEntry> delayedEntries = map.values();
for (DelayedEntry delayedEntry : delayedEntries) {
collection.add(delayedEntry);
}
map.clear();
return collection.size();
}
use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class CyclicWriteBehindQueue method drainTo.
/**
* Removes all available elements from this queue and adds them
* to the given collection.
*
* @param collection all elements to be added to this collection.
* @return number of removed items from this queue.
*/
@Override
public int drainTo(Collection<DelayedEntry> collection) {
checkNotNull(collection, "collection can not be null");
Iterator<DelayedEntry> iterator = deque.iterator();
while (iterator.hasNext()) {
DelayedEntry e = iterator.next();
collection.add(e);
iterator.remove();
}
resetCountIndex();
return collection.size();
}
use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class DefaultWriteBehindProcessor method addToFails.
private void addToFails(List<DelayedEntry> fails, Map<Integer, List<DelayedEntry>> failsPerPartition) {
if (fails == null || fails.isEmpty()) {
return;
}
for (DelayedEntry entry : fails) {
final int partitionId = entry.getPartitionId();
List<DelayedEntry> delayedEntriesPerPartition = failsPerPartition.get(partitionId);
if (delayedEntriesPerPartition == null) {
delayedEntriesPerPartition = new ArrayList<DelayedEntry>();
failsPerPartition.put(partitionId, delayedEntriesPerPartition);
}
delayedEntriesPerPartition.add(entry);
}
}
use of com.hazelcast.map.impl.mapstore.writebehind.entry.DelayedEntry in project hazelcast by hazelcast.
the class DefaultWriteBehindProcessor method convertToObject.
private Map convertToObject(Map<Object, DelayedEntry> batchMap) {
final Map map = new HashMap();
for (DelayedEntry entry : batchMap.values()) {
final Object key = toObject(entry.getKey());
final Object value = toObject(entry.getValue());
map.put(key, value);
}
return map;
}
Aggregations