Search in sources :

Example 81 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class AbstractReplicatedMapAddEntryListenerMessageTask method call.

@Override
protected Object call() {
    ReplicatedMapService service = getService(ReplicatedMapService.SERVICE_NAME);
    ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
    String registrationId;
    Predicate predicate = getPredicate();
    if (predicate == null) {
        registrationId = eventPublishingService.addEventListener(this, new ReplicatedEntryEventFilter(getKey()), getDistributedObjectName());
    } else {
        registrationId = eventPublishingService.addEventListener(this, new ReplicatedQueryEventFilter(getKey(), predicate), getDistributedObjectName());
    }
    endpoint.addListenerDestroyAction(ReplicatedMapService.SERVICE_NAME, getDistributedObjectName(), registrationId);
    return registrationId;
}
Also used : ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) ReplicatedEntryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService) Predicate(com.hazelcast.query.Predicate)

Example 82 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class MapPublisherCreateMessageTask method createInvocations.

private void createInvocations(Collection<MemberImpl> members, List<Future> futures) {
    final InternalOperationService operationService = nodeEngine.getOperationService();
    final ClientEndpoint endpoint = getEndpoint();
    for (MemberImpl member : members) {
        Predicate predicate = serializationService.toObject(parameters.predicate);
        AccumulatorInfo accumulatorInfo = AccumulatorInfo.createAccumulatorInfo(parameters.mapName, parameters.cacheName, predicate, parameters.batchSize, parameters.bufferSize, parameters.delaySeconds, false, parameters.populate, parameters.coalesce);
        PublisherCreateOperation operation = new PublisherCreateOperation(accumulatorInfo);
        operation.setCallerUuid(endpoint.getUuid());
        Address address = member.getAddress();
        InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(SERVICE_NAME, operation, address);
        Future future = invocationBuilder.invoke();
        futures.add(future);
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) Future(java.util.concurrent.Future) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) InvocationBuilder(com.hazelcast.spi.InvocationBuilder) ClientEndpoint(com.hazelcast.client.ClientEndpoint) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) Predicate(com.hazelcast.query.Predicate)

Example 83 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class MapPublisherCreateWithValueMessageTask method createInvocations.

private void createInvocations(Collection<MemberImpl> members, List<Future> futures) {
    final InternalOperationService operationService = nodeEngine.getOperationService();
    final ClientEndpoint endpoint = getEndpoint();
    for (MemberImpl member : members) {
        Predicate predicate = serializationService.toObject(parameters.predicate);
        AccumulatorInfo accumulatorInfo = AccumulatorInfo.createAccumulatorInfo(parameters.mapName, parameters.cacheName, predicate, parameters.batchSize, parameters.bufferSize, parameters.delaySeconds, true, parameters.populate, parameters.coalesce);
        PublisherCreateOperation operation = new PublisherCreateOperation(accumulatorInfo);
        operation.setCallerUuid(endpoint.getUuid());
        Address address = member.getAddress();
        InvocationBuilder invocationBuilder = operationService.createInvocationBuilder(SERVICE_NAME, operation, address);
        Future future = invocationBuilder.invoke();
        futures.add(future);
    }
}
Also used : Address(com.hazelcast.nio.Address) MemberImpl(com.hazelcast.instance.MemberImpl) Future(java.util.concurrent.Future) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService) InvocationBuilder(com.hazelcast.spi.InvocationBuilder) ClientEndpoint(com.hazelcast.client.ClientEndpoint) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) Predicate(com.hazelcast.query.Predicate)

Example 84 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddEntryListenerWithEntryListenerAndPredicate_NullListener.

@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithEntryListenerAndPredicate_NullListener() throws Exception {
    EntryListener entryListener = null;
    Predicate predicate = new TruePredicate();
    map.addEntryListener(entryListener, predicate, false);
}
Also used : TruePredicate(com.hazelcast.query.TruePredicate) EntryListener(com.hazelcast.core.EntryListener) Predicate(com.hazelcast.query.Predicate) TruePredicate(com.hazelcast.query.TruePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 85 with Predicate

use of com.hazelcast.query.Predicate in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddEntryListenerWithMapListenerAndPredicateAndKey_NullPredicate.

@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithMapListenerAndPredicateAndKey_NullPredicate() throws Exception {
    MapListener mapListener = new MapListenerAdapter() {

        public void onEntryEvent(EntryEvent event) {
            System.out.println("-");
        }
    };
    Predicate predicate = null;
    map.addEntryListener(mapListener, predicate, null, true);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) MapListenerAdapter(com.hazelcast.map.impl.MapListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) Predicate(com.hazelcast.query.Predicate) TruePredicate(com.hazelcast.query.TruePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

Predicate (com.hazelcast.query.Predicate)160 Test (org.junit.Test)125 QuickTest (com.hazelcast.test.annotation.QuickTest)124 ParallelTest (com.hazelcast.test.annotation.ParallelTest)107 TruePredicate (com.hazelcast.query.TruePredicate)41 SqlPredicate (com.hazelcast.query.SqlPredicate)33 HazelcastInstance (com.hazelcast.core.HazelcastInstance)26 FalsePredicate (com.hazelcast.query.impl.FalsePredicate)23 PredicateBuilder (com.hazelcast.query.PredicateBuilder)19 EntryListener (com.hazelcast.core.EntryListener)16 MapListener (com.hazelcast.map.listener.MapListener)16 EntryObject (com.hazelcast.query.EntryObject)14 IndexAwarePredicate (com.hazelcast.query.IndexAwarePredicate)12 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)10 Value (com.hazelcast.query.SampleObjects.Value)9 PredicateTestUtils.createMockVisitablePredicate (com.hazelcast.query.impl.predicates.PredicateTestUtils.createMockVisitablePredicate)9 ArrayList (java.util.ArrayList)9 EntryEvent (com.hazelcast.core.EntryEvent)8 MapListenerAdapter (com.hazelcast.map.impl.MapListenerAdapter)8 ValueType (com.hazelcast.query.SampleObjects.ValueType)7