All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.spi.OperationService Maven / Gradle / Ivy

There is a newer version: 5.4.0
Show newest version
/*
 * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.hazelcast.spi;

import com.hazelcast.nio.Address;
import com.hazelcast.spi.impl.Response;

import java.util.Collection;
import java.util.Map;

/**
 * The OperationService is responsible for executing operations.
 * 

* A single operation can be executed locally using {@link #runOperationOnCallingThread(Operation)} * and {@link #executeOperation(Operation)}. Or it can executed remotely using the one of the send methods. *

* It also is possible to execute multiple operation one multiple partitions using one of the invoke methods. * * @author mdogan 12/14/12 */ public interface OperationService { int getResponseQueueSize(); int getOperationExecutorQueueSize(); int getPriorityOperationExecutorQueueSize(); int getRunningOperationsCount(); int getRemoteOperationsCount(); int getPartitionOperationThreadCount(); int getGenericOperationThreadCount(); long getExecutedOperationCount(); /** * Runs operation in calling thread. * * @param op the operation to execute. */ void runOperationOnCallingThread(Operation op); /** * Executes operation in operation executor pool. * * @param op the operation to execute. */ void executeOperation(Operation op); InternalCompletableFuture invokeOnPartition(String serviceName, Operation op, int partitionId); InternalCompletableFuture invokeOnTarget(String serviceName, Operation op, Address target); InvocationBuilder createInvocationBuilder(String serviceName, Operation op, int partitionId); InvocationBuilder createInvocationBuilder(String serviceName, Operation op, Address target); /** * Invokes a set of operation on each partition. *

* This method blocks until the operation completes. * * @param serviceName the name of the service. * @param operationFactory the factory responsible creating operations * @return a Map with partitionId as key and outcome of the operation as value. * @throws Exception */ Map invokeOnAllPartitions(String serviceName, OperationFactory operationFactory) throws Exception; /** * Invokes an set of operation on selected set of partitions * *

* This method blocks until all operations complete. * * @param serviceName the name of the service * @param operationFactory the factory responsible creating operations * @param partitions the partitions the operation should be executed on. * @return a Map with partitionId as key and outcome of the operation as value. * @throws Exception */ Map invokeOnPartitions(String serviceName, OperationFactory operationFactory, Collection partitions) throws Exception; /** * Executes an operation remotely. *

* It isn't allowed * * @param op the operation to send and execute. * @param target the address of that target member. * @return true if send successfully, false otherwise. */ boolean send(Operation op, Address target); /** * Sends a response to a remote machine. * * @param response the response to send. * @param target the address of the target machine * @return true if send successfully, false otherwise. */ boolean send(Response response, Address target); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy