Search in sources :

Example 56 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueProxyImpl method toArray.

@Nonnull
@Override
public <T> T[] toArray(@Nonnull T[] ts) {
    checkNotNull(ts, "Null array parameter is not allowed!");
    T[] tsParam = ts;
    final NodeEngine nodeEngine = getNodeEngine();
    List<Data> list = listInternal();
    int size = list.size();
    if (tsParam.length < size) {
        tsParam = (T[]) java.lang.reflect.Array.newInstance(tsParam.getClass().getComponentType(), size);
    }
    for (int i = 0; i < size; i++) {
        tsParam[i] = nodeEngine.toObject(list.get(i));
    }
    return tsParam;
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data) Nonnull(javax.annotation.Nonnull)

Example 57 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueProxyImpl method poll.

@Override
public E poll(long timeout, @Nonnull TimeUnit timeUnit) throws InterruptedException {
    checkNotNull(timeUnit, "Null timeUnit is not allowed!");
    final NodeEngine nodeEngine = getNodeEngine();
    final Object data = pollInternal(timeUnit.toMillis(timeout));
    return nodeEngine.toObject(data);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) InitializingObject(com.hazelcast.spi.impl.InitializingObject)

Example 58 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueProxyImpl method drainTo.

@Override
public int drainTo(@Nonnull Collection<? super E> objects, int i) {
    checkNotNull(objects, "Null objects parameter is not allowed!");
    checkFalse(this.equals(objects), "Can not drain to same Queue");
    final NodeEngine nodeEngine = getNodeEngine();
    Collection<Data> dataList = drainInternal(i);
    for (Data data : dataList) {
        E e = nodeEngine.toObject(data);
        objects.add(e);
    }
    return dataList.size();
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data)

Example 59 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueProxyImpl method offer.

@Override
public boolean offer(@Nonnull E e, long timeout, @Nonnull TimeUnit timeUnit) throws InterruptedException {
    checkNotNull(e, "Null item is not allowed!");
    checkNotNull(timeUnit, "Null timeUnit is not allowed!");
    final NodeEngine nodeEngine = getNodeEngine();
    final Data data = nodeEngine.toData(e);
    return offerInternal(data, timeUnit.toMillis(timeout));
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data)

Example 60 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class QueueProxyImpl method remove.

@Override
public boolean remove(@Nonnull Object o) {
    checkNotNull(o, "Null item is not allowed!");
    final NodeEngine nodeEngine = getNodeEngine();
    final Data data = nodeEngine.toData(o);
    return removeInternal(data);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Data(com.hazelcast.internal.serialization.Data)

Aggregations

NodeEngine (com.hazelcast.spi.impl.NodeEngine)165 Data (com.hazelcast.internal.serialization.Data)48 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)30 Address (com.hazelcast.cluster.Address)22 Test (org.junit.Test)21 ILogger (com.hazelcast.logging.ILogger)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)18 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Config (com.hazelcast.config.Config)17 Operation (com.hazelcast.spi.impl.operationservice.Operation)16 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)15 IPartitionService (com.hazelcast.internal.partition.IPartitionService)12 Nonnull (javax.annotation.Nonnull)12 ArrayList (java.util.ArrayList)11 Future (java.util.concurrent.Future)11 Member (com.hazelcast.cluster.Member)10 UUID (java.util.UUID)10 InitializingObject (com.hazelcast.spi.impl.InitializingObject)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9