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

org.apache.cassandra.distributed.api.IInvokableInstance Maven / Gradle / Ivy

There is a newer version: 0.0.17
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.cassandra.distributed.api;

import java.io.Serializable;
import java.util.concurrent.Future;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * This version is only supported for a Cluster running the same code as the test environment, and permits
 * ergonomic cross-node behaviours, without editing the cross-version API.
 * 

* A lambda can be written tto be invoked on any or all of the nodes. *

* The reason this cannot (easily) be made cross-version is that the lambda is tied to the declaring class, which will * not be the same in the alternate version. Even were it not, there would likely be a runtime linkage error given * any code divergence. */ public interface IInvokableInstance extends IInstance { default CallableNoExcept> asyncCallsOnInstance(SerializableCallable call) { return async(transfer(call)); } default CallableNoExcept callsOnInstance(SerializableCallable call) { return sync(transfer(call)); } default O callOnInstance(SerializableCallable call) { return callsOnInstance(call).call(); } default CallableNoExcept> asyncRunsOnInstance(SerializableRunnable run) { return async(transfer(run)); } default Runnable runsOnInstance(SerializableRunnable run) { return sync(transfer(run)); } default void runOnInstance(SerializableRunnable run) { runsOnInstance(run).run(); } default Function> asyncAcceptsOnInstance(SerializableConsumer consumer) { return async(transfer(consumer)); } default Consumer acceptsOnInstance(SerializableConsumer consumer) { return sync(transfer(consumer)); } default BiFunction> asyncAcceptsOnInstance(SerializableBiConsumer consumer) { return async(transfer(consumer)); } default BiConsumer acceptsOnInstance(SerializableBiConsumer consumer) { return sync(transfer(consumer)); } default Function> asyncAppliesOnInstance(SerializableFunction f) { return async(transfer(f)); } default Function appliesOnInstance(SerializableFunction f) { return sync(transfer(f)); } default BiFunction> asyncAppliesOnInstance(SerializableBiFunction f) { return async(transfer(f)); } default BiFunction appliesOnInstance(SerializableBiFunction f) { return sync(transfer(f)); } default TriFunction> asyncAppliesOnInstance(SerializableTriFunction f) { return async(transfer(f)); } default TriFunction appliesOnInstance(SerializableTriFunction f) { return sync(transfer(f)); } E transfer(E object); }