This project has retired. For details please refer to its Attic page.
Source code
001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.vortex.driver;
020
021import org.apache.reef.annotations.Unstable;
022import org.apache.reef.annotations.audience.DriverSide;
023import org.apache.reef.tang.annotations.DefaultImplementation;
024import org.apache.reef.util.Optional;
025import org.apache.reef.vortex.api.*;
026import org.apache.reef.vortex.protocol.workertomaster.WorkerToMasterReports;
027
028import java.util.List;
029
030/**
031 * The heart of Vortex.
032 * Processes various tasklet related events/requests coming from different components of the system.
033 */
034@Unstable
035@DriverSide
036@DefaultImplementation(DefaultVortexMaster.class)
037public interface VortexMaster {
038  /**
039   * Submit a new Tasklet to be run sometime in the future, with an optional callback function on the result.
040   */
041  <TInput, TOutput> VortexFuture<TOutput>
042      enqueueTasklet(final VortexFunction<TInput, TOutput> vortexFunction, final TInput input,
043                     final Optional<FutureCallback<TOutput>> callback);
044
045  /**
046   * Submits aggregate-able Tasklets to be run sometime in the future, with an optional callback function on
047   * the aggregation progress.
048   */
049  <TInput, TOutput> VortexAggregateFuture<TInput, TOutput>
050      enqueueTasklets(final VortexAggregateFunction<TOutput> aggregateFunction,
051                      final VortexFunction<TInput, TOutput> vortexFunction,
052                      final VortexAggregatePolicy policy,
053                      final List<TInput> inputs,
054                      final Optional<FutureCallback<AggregateResult<TInput, TOutput>>> callback);
055
056  /**
057   * Call this when a Tasklet is to be cancelled.
058   * @param mayInterruptIfRunning if true, will attempt to cancel running Tasklets; otherwise will only
059   *                              prevent a pending Tasklet from running.
060   * @param taskletId the ID of the Tasklet.
061   */
062  void cancelTasklet(final boolean mayInterruptIfRunning, final int taskletId);
063
064  /**
065   * Call this when a new worker is up and running.
066   */
067  void workerAllocated(final VortexWorkerManager vortexWorkerManager);
068
069  /**
070   * Call this when a worker is preempted.
071   */
072  void workerPreempted(final String id);
073
074  /**
075   * Call this when a worker has reported back.
076   */
077  void workerReported(final String workerId, final WorkerToMasterReports workerToMasterReports);
078
079  /**
080   * Release all resources and shut down.
081   */
082  void terminate();
083}