Search in sources :

Example 1 with PartitionAwareOperation

use of com.hazelcast.spi.impl.operationservice.PartitionAwareOperation in project hazelcast by hazelcast.

the class NodeEngineImpl method getPostJoinOperations.

/**
 * Collects all post-join operations from {@link PostJoinAwareService}s.
 * <p>
 * Post join operations should return response, at least a {@code null} response.
 * <p>
 * <b>Note</b>: Post join operations must be lock free, meaning no locks at all:
 * no partition locks, no key-based locks, no service level locks, no database interaction!
 * The {@link Operation#getPartitionId()} method should return a negative value.
 * This means that the operations should not implement {@link PartitionAwareOperation}.
 *
 * @return the operations to be executed at the end of a finalized join
 */
public Collection<Operation> getPostJoinOperations() {
    Collection<Operation> postJoinOps = new LinkedList<>();
    Collection<PostJoinAwareService> services = getServices(PostJoinAwareService.class);
    for (PostJoinAwareService service : services) {
        Operation postJoinOperation = service.getPostJoinOperation();
        if (postJoinOperation != null) {
            if (postJoinOperation.getPartitionId() >= 0) {
                logger.severe("Post-join operations should not have partition ID set! Service: " + service + ", Operation: " + postJoinOperation);
                continue;
            }
            postJoinOps.add(postJoinOperation);
        }
    }
    return postJoinOps;
}
Also used : PostJoinAwareService(com.hazelcast.internal.services.PostJoinAwareService) PartitionAwareOperation(com.hazelcast.spi.impl.operationservice.PartitionAwareOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) LinkedList(java.util.LinkedList)

Aggregations

PostJoinAwareService (com.hazelcast.internal.services.PostJoinAwareService)1 Operation (com.hazelcast.spi.impl.operationservice.Operation)1 PartitionAwareOperation (com.hazelcast.spi.impl.operationservice.PartitionAwareOperation)1 LinkedList (java.util.LinkedList)1