Search in sources :

Example 26 with Data

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);
        }
    }
}
Also used : LocalQueueStatsImpl(com.hazelcast.monitor.impl.LocalQueueStatsImpl) Data(com.hazelcast.nio.serialization.Data)

Example 27 with 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));
}
Also used : Data(com.hazelcast.nio.serialization.Data)

Example 28 with Data

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;
}
Also used : Data(com.hazelcast.nio.serialization.Data) QueueCompareAndRemoveAllCodec(com.hazelcast.client.impl.protocol.codec.QueueCompareAndRemoveAllCodec) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Example 29 with Data

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);
}
Also used : Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Example 30 with Data

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());
    }
}
Also used : ReliableTopicMessage(com.hazelcast.topic.impl.reliable.ReliableTopicMessage) Data(com.hazelcast.nio.serialization.Data) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TopicOverloadException(com.hazelcast.topic.TopicOverloadException) DistributedObjectDestroyedException(com.hazelcast.spi.exception.DistributedObjectDestroyedException) StaleSequenceException(com.hazelcast.ringbuffer.StaleSequenceException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

Data (com.hazelcast.nio.serialization.Data)773 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)140 Test (org.junit.Test)121 QuickTest (com.hazelcast.test.annotation.QuickTest)118 ParallelTest (com.hazelcast.test.annotation.ParallelTest)108 ArrayList (java.util.ArrayList)81 Map (java.util.Map)64 SerializationService (com.hazelcast.spi.serialization.SerializationService)54 HashMap (java.util.HashMap)54 NodeEngine (com.hazelcast.spi.NodeEngine)50 HashSet (java.util.HashSet)39 Address (com.hazelcast.nio.Address)28 AbstractMap (java.util.AbstractMap)28 Record (com.hazelcast.map.impl.record.Record)27 HazelcastInstance (com.hazelcast.core.HazelcastInstance)26 HeapData (com.hazelcast.internal.serialization.impl.HeapData)26 List (java.util.List)20 Future (java.util.concurrent.Future)20 CacheEventData (com.hazelcast.cache.impl.CacheEventData)19 Operation (com.hazelcast.spi.Operation)18