Search in sources :

Example 1 with InvokerWrapper

use of com.hazelcast.map.impl.querycache.InvokerWrapper in project hazelcast by hazelcast.

the class ClientQueryCacheEndToEndConstructor method createPublishAccumulatorWithIncludeValue.

private void createPublishAccumulatorWithIncludeValue(AccumulatorInfo info) {
    Data data = context.getSerializationService().toData(info.getPredicate());
    ClientMessage request = ContinuousQueryPublisherCreateWithValueCodec.encodeRequest(info.getMapName(), info.getCacheName(), data, info.getBatchSize(), info.getBufferSize(), info.getDelaySeconds(), info.isPopulate(), info.isCoalesce());
    InvokerWrapper invokerWrapper = context.getInvokerWrapper();
    ClientMessage response = (ClientMessage) invokerWrapper.invoke(request);
    Collection<Map.Entry<Data, Data>> result = ContinuousQueryPublisherCreateWithValueCodec.decodeResponse(response).response;
    populateWithValues(queryCache, result);
}
Also used : InvokerWrapper(com.hazelcast.map.impl.querycache.InvokerWrapper) Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Example 2 with InvokerWrapper

use of com.hazelcast.map.impl.querycache.InvokerWrapper in project hazelcast by hazelcast.

the class DefaultQueryCache method isTryRecoverSucceeded.

/**
     * This tries to reset cursor position of the accumulator to the supplied sequence,
     * if that sequence is still there, it will be succeeded, otherwise query cache content stays inconsistent.
     */
private boolean isTryRecoverSucceeded(ConcurrentMap<Integer, Long> brokenSequences) {
    int numberOfBrokenSequences = brokenSequences.size();
    InvokerWrapper invokerWrapper = context.getInvokerWrapper();
    SubscriberContext subscriberContext = context.getSubscriberContext();
    SubscriberContextSupport subscriberContextSupport = subscriberContext.getSubscriberContextSupport();
    List<Future<Object>> futures = new ArrayList<Future<Object>>(numberOfBrokenSequences);
    for (Map.Entry<Integer, Long> entry : brokenSequences.entrySet()) {
        Integer partitionId = entry.getKey();
        Long sequence = entry.getValue();
        Object recoveryOperation = subscriberContextSupport.createRecoveryOperation(mapName, cacheName, sequence, partitionId);
        Future<Object> future = (Future<Object>) invokerWrapper.invokeOnPartitionOwner(recoveryOperation, partitionId);
        futures.add(future);
    }
    Collection<Object> results = FutureUtil.returnWithDeadline(futures, 1, MINUTES);
    int successCount = 0;
    for (Object object : results) {
        Boolean resolvedResponse = subscriberContextSupport.resolveResponseForRecoveryOperation(object);
        if (TRUE.equals(resolvedResponse)) {
            successCount++;
        }
    }
    return successCount == numberOfBrokenSequences;
}
Also used : ArrayList(java.util.ArrayList) NodeInvokerWrapper(com.hazelcast.map.impl.querycache.NodeInvokerWrapper) InvokerWrapper(com.hazelcast.map.impl.querycache.InvokerWrapper) Future(java.util.concurrent.Future) ConcurrentMap(java.util.concurrent.ConcurrentMap) Map(java.util.Map) IMap(com.hazelcast.core.IMap)

Example 3 with InvokerWrapper

use of com.hazelcast.map.impl.querycache.InvokerWrapper in project hazelcast by hazelcast.

the class NodeQueryCacheEndToEndConstructor method createPublishersAndGetQueryResults.

private Collection<QueryResult> createPublishersAndGetQueryResults(AccumulatorInfo info) {
    InvokerWrapper invokerWrapper = context.getInvokerWrapper();
    Collection<Member> members = context.getMemberList();
    List<Future<QueryResult>> futures = new ArrayList<Future<QueryResult>>(members.size());
    for (Member member : members) {
        Address address = member.getAddress();
        Future future = invokerWrapper.invokeOnTarget(new PublisherCreateOperation(info), address);
        futures.add(future);
    }
    return returnWithDeadline(futures, OPERATION_WAIT_TIMEOUT_MINUTES, MINUTES);
}
Also used : QueryResult(com.hazelcast.map.impl.query.QueryResult) Address(com.hazelcast.nio.Address) InvokerWrapper(com.hazelcast.map.impl.querycache.InvokerWrapper) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Member(com.hazelcast.core.Member) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation)

Example 4 with InvokerWrapper

use of com.hazelcast.map.impl.querycache.InvokerWrapper in project hazelcast by hazelcast.

the class NodeQueryCacheEndToEndConstructor method madePublishable.

private void madePublishable(String mapName, String cacheName) throws Exception {
    InvokerWrapper invokerWrapper = context.getInvokerWrapper();
    Collection<Member> memberList = context.getMemberList();
    List<Future> futures = new ArrayList<Future>(memberList.size());
    for (Member member : memberList) {
        Operation operation = new MadePublishableOperation(mapName, cacheName);
        Future future = invokerWrapper.invokeOnTarget(operation, member.getAddress());
        futures.add(future);
    }
    waitWithDeadline(futures, OPERATION_WAIT_TIMEOUT_MINUTES, MINUTES);
}
Also used : MadePublishableOperation(com.hazelcast.map.impl.querycache.subscriber.operation.MadePublishableOperation) InvokerWrapper(com.hazelcast.map.impl.querycache.InvokerWrapper) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) PublisherCreateOperation(com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation) Operation(com.hazelcast.spi.Operation) MadePublishableOperation(com.hazelcast.map.impl.querycache.subscriber.operation.MadePublishableOperation) Member(com.hazelcast.core.Member)

Example 5 with InvokerWrapper

use of com.hazelcast.map.impl.querycache.InvokerWrapper in project hazelcast by hazelcast.

the class ClientQueryCacheEndToEndConstructor method createPublishAccumulatorWithoutIncludeValue.

private void createPublishAccumulatorWithoutIncludeValue(AccumulatorInfo info) {
    Data data = context.getSerializationService().toData(info.getPredicate());
    ClientMessage request = ContinuousQueryPublisherCreateCodec.encodeRequest(info.getMapName(), info.getCacheName(), data, info.getBatchSize(), info.getBufferSize(), info.getDelaySeconds(), info.isPopulate(), info.isCoalesce());
    InvokerWrapper invokerWrapper = context.getInvokerWrapper();
    ClientMessage response = (ClientMessage) invokerWrapper.invoke(request);
    Collection<Data> result = ContinuousQueryPublisherCreateCodec.decodeResponse(response).response;
    populateWithoutValues(queryCache, result);
}
Also used : InvokerWrapper(com.hazelcast.map.impl.querycache.InvokerWrapper) Data(com.hazelcast.nio.serialization.Data) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage)

Aggregations

InvokerWrapper (com.hazelcast.map.impl.querycache.InvokerWrapper)6 Member (com.hazelcast.core.Member)3 ArrayList (java.util.ArrayList)3 Future (java.util.concurrent.Future)3 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)2 NodeInvokerWrapper (com.hazelcast.map.impl.querycache.NodeInvokerWrapper)2 PublisherCreateOperation (com.hazelcast.map.impl.querycache.subscriber.operation.PublisherCreateOperation)2 Address (com.hazelcast.nio.Address)2 Data (com.hazelcast.nio.serialization.Data)2 IMap (com.hazelcast.core.IMap)1 QueryResult (com.hazelcast.map.impl.query.QueryResult)1 MadePublishableOperation (com.hazelcast.map.impl.querycache.subscriber.operation.MadePublishableOperation)1 Operation (com.hazelcast.spi.Operation)1 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1