use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class CompareAndRemoveOperation method afterRun.
@Override
public void afterRun() throws Exception {
LocalQueueStatsImpl stats = getQueueService().getLocalQueueStatsImpl(name);
stats.incrementOtherOperations();
if (hasListener()) {
for (Data data : dataMap.values()) {
publishEvent(ItemEventType.REMOVED, data);
}
}
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class TransactionalQueueProxy method offer.
@Override
public boolean offer(E e, long timeout, TimeUnit unit) throws InterruptedException {
checkNotNull(e, "Offered item should not be null.");
checkNotNull(unit, "TimeUnit should not be null.");
checkTransactionState();
Data data = getNodeEngine().toData(e);
return offerInternal(data, unit.toMillis(timeout));
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class ClientQueueProxy method removeAll.
@Override
public boolean removeAll(Collection<?> c) {
Preconditions.checkNotNull(c);
Collection<Data> dataCollection = CollectionUtil.objectToDataCollection(c, getSerializationService());
ClientMessage request = QueueCompareAndRemoveAllCodec.encodeRequest(name, dataCollection);
ClientMessage response = invokeOnPartition(request);
QueueCompareAndRemoveAllCodec.ResponseParameters resultParameters = QueueCompareAndRemoveAllCodec.decodeResponse(response);
return resultParameters.response;
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class ClientQueueProxy method put.
@Override
public void put(E e) throws InterruptedException {
Data data = toData(e);
ClientMessage request = QueuePutCodec.encodeRequest(name, data);
invokeOnPartitionInterruptibly(request);
}
use of com.hazelcast.nio.serialization.Data in project hazelcast by hazelcast.
the class ClientReliableTopicProxy method publish.
@Override
public void publish(E payload) {
try {
Data data = serializationService.toData(payload);
ReliableTopicMessage message = new ReliableTopicMessage(data, null);
switch(overloadPolicy) {
case ERROR:
addOrFail(message);
break;
case DISCARD_OLDEST:
addOrOverwrite(message);
break;
case DISCARD_NEWEST:
ringbuffer.addAsync(message, OverflowPolicy.FAIL).get();
break;
case BLOCK:
addWithBackoff(message);
break;
default:
throw new IllegalArgumentException("Unknown overloadPolicy:" + overloadPolicy);
}
} catch (Exception e) {
throw (RuntimeException) peel(e, null, "Failed to publish message: " + payload + " to topic:" + getName());
}
}
Aggregations