@org.apache.reef.annotations.Unstable - java examples

Here are the examples of the java api @org.apache.reef.annotations.Unstable taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

84 Examples 7

19 View Complete Implementation : DistributedDataSetPartition.java
Copyright Apache License 2.0
Author : apache
/**
 * POJO that represents a distributed data set parreplacedion. Basically, it contains the path where
 * the data files are located for this parreplacedion, and the location where we want
 * this data to be loaded into.
 */
@Unstable
public final clreplaced DistributedDataSetParreplacedion {

    /**
     * The path of the distributed data set parreplacedion. If we use HDFS, it will be the
     * hdfs path.
     */
    private final String path;

    /**
     * The location (either a rackName or a nodeName) where we want the data in
     * this distributed parreplacedion to be loaded into. It can contain a wildcard at
     * the end, for example /datacenter1/*.
     */
    private final String location;

    /**
     * Number of desired splits for this parreplacedion.
     */
    private final int desiredSplits;

    DistributedDataSetParreplacedion(final String path, final String location, final int desiredSplits) {
        this.path = path;
        this.location = location;
        this.desiredSplits = desiredSplits;
    }

    /**
     * Returns the path to the distributed data parreplacedion.
     *
     * @return the path of the distributed data parreplacedion
     */
    String getPath() {
        return path;
    }

    /**
     * Returns the location where we want the data in this parreplacedion to be loaded
     * into.
     *
     * @return the location where to load this data into.
     */
    String getLocation() {
        return location;
    }

    /**
     * Returns the number of desired splits for this data parreplacedion.
     *
     * @return the number of desired splits
     */
    int getDesiredSplits() {
        return desiredSplits;
    }

    /**
     * @return a new DistributedDataSetParreplacedion Builder.
     */
    public static Builder newBuilder() {
        return new Builder();
    }

    @Override
    public boolean equals(final Object obj) {
        if (obj == this) {
            return true;
        }
        if (!(obj instanceof DistributedDataSetParreplacedion)) {
            return false;
        }
        final DistributedDataSetParreplacedion that = (DistributedDataSetParreplacedion) obj;
        return new EqualsBuilder().append(this.path, that.path).append(this.location, that.location).append(this.desiredSplits, that.desiredSplits).isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(this.path).append(this.location).append(this.desiredSplits).toHashCode();
    }

    @Override
    public String toString() {
        return "{" + this.path + "," + this.location + "," + this.desiredSplits + "}";
    }

    /**
     * {@link DistributedDataSetParreplacedion}s are build using this Builder.
     */
    public static final clreplaced Builder implements org.apache.reef.util.Builder<DistributedDataSetParreplacedion> {

        private String path;

        private String location;

        private int desiredSplits;

        private Builder() {
        }

        /**
         * Sets the path of the distributed data set parreplacedion.
         *
         * @param path
         *          the path to set
         * @return this
         */
        public Builder setPath(final String path) {
            this.path = path;
            return this;
        }

        /**
         * Sets the location where we want the data in this parreplacedion to be loaded
         * into.
         *
         * @param location
         *          the location to set
         * @return this
         */
        public Builder setLocation(final String location) {
            this.location = location;
            return this;
        }

        /**
         * Sets the desired number of splits for this parreplacedion.
         * @param desiredSplits
         *          the number of desired splits
         * @return this
         */
        public Builder setDesiredSplits(final int desiredSplits) {
            this.desiredSplits = desiredSplits;
            return this;
        }

        /**
         * Builds the {@link DistributedDataSetParreplacedion}.
         */
        @Override
        public DistributedDataSetParreplacedion build() {
            return new DistributedDataSetParreplacedion(this.path, this.location, this.desiredSplits);
        }
    }
}

19 View Complete Implementation : MultiRuntimeConfigurationBuilder.java
Copyright Apache License 2.0
Author : apache
/**
 * A builder for Multi Runtime Configuration.
 */
@Unstable
public final clreplaced MultiRuntimeConfigurationBuilder {

    private static final Set<String> SUPPORTED_RUNTIMES = new HashSet<>(Arrays.asList(org.apache.reef.runtime.yarn.driver.RuntimeIdentifier.RUNTIME_NAME, org.apache.reef.runtime.local.driver.RuntimeIdentifier.RUNTIME_NAME));

    private static final Set<String> SUPPORTED_SUBMISSION_RUNTIMES = new HashSet<>(Arrays.asList(org.apache.reef.runtime.yarn.driver.RuntimeIdentifier.RUNTIME_NAME));

    private final HashMap<Clreplaced, Object> namedParameters = new HashMap<>();

    private Set<String> runtimeNames = new HashSet<>();

    private Optional<String> defaultRuntime = Optional.empty();

    private String submissionRuntime;

    private void addNamedParameter(final Clreplaced namedParameter, final Object namedParameterValue) {
        Validate.notNull(namedParameterValue);
        this.namedParameters.put(namedParameter, namedParameterValue);
    }

    /**
     * Adds runtime name to the builder.
     * @param runtimeName The name to add
     * @return The builder instance
     */
    public MultiRuntimeConfigurationBuilder addRuntime(final String runtimeName) {
        Validate.isTrue(SUPPORTED_RUNTIMES.contains(runtimeName), "unsupported runtime " + runtimeName);
        this.runtimeNames.add(runtimeName);
        return this;
    }

    /**
     * Sets default runtime. Default runtime is used when no runtime was specified for evaluator
     * @param runtimeName the default runtime name
     * @return The builder instance
     */
    public MultiRuntimeConfigurationBuilder setDefaultRuntime(final String runtimeName) {
        Validate.isTrue(SUPPORTED_RUNTIMES.contains(runtimeName), "Unsupported runtime " + runtimeName);
        Validate.isTrue(!this.defaultRuntime.isPresent(), "Default runtime was already added");
        this.defaultRuntime = Optional.of(runtimeName);
        return this;
    }

    /**
     * Sets the submission runtime. Submission runtime is used for launching the job driver.
     * @param runtimeName the submission runtime name
     * @return The builder instance
     */
    public MultiRuntimeConfigurationBuilder setSubmissionRuntime(final String runtimeName) {
        Validate.isTrue(SUPPORTED_SUBMISSION_RUNTIMES.contains(runtimeName), "Unsupported submission runtime " + runtimeName);
        Validate.isTrue(this.submissionRuntime == null, "Submission runtime was already added");
        this.submissionRuntime = runtimeName;
        return this;
    }

    /**
     * Sets the max number of local evaluators for local runtime. This parameter is ignored when local runtime is not used
     * @param maxLocalEvaluators The max evaluators number
     * @return The builder instance
     */
    public MultiRuntimeConfigurationBuilder setMaxEvaluatorsNumberForLocalRuntime(final int maxLocalEvaluators) {
        Validate.isTrue(maxLocalEvaluators > 0, "Max evaluators number should be greater then 0");
        addNamedParameter(MaxNumberOfEvaluators.clreplaced, maxLocalEvaluators);
        return this;
    }

    /**
     * Builds the configuration.
     * @return The built configuration
     */
    public Configuration build() {
        Validate.notNull(this.submissionRuntime, "Default Runtime was not defined");
        if (!this.defaultRuntime.isPresent() || this.runtimeNames.size() == 1) {
            this.defaultRuntime = Optional.of(this.runtimeNames.toArray(new String[0])[0]);
        }
        Validate.isTrue(this.defaultRuntime.isPresent(), "Default runtime was not defined, and multiple runtimes were specified");
        if (!this.runtimeNames.contains(this.defaultRuntime.get())) {
            this.runtimeNames.add(this.defaultRuntime.get());
        }
        JavaConfigurationBuilder conf = Tang.Factory.getTang().newConfigurationBuilder();
        for (Map.Entry<Clreplaced, Object> entry : this.namedParameters.entrySet()) {
            conf = conf.bindNamedParameter(entry.getKey(), entry.getValue().toString());
        }
        conf = conf.bindNamedParameter(DefaultRuntimeName.clreplaced, this.defaultRuntime.get());
        for (final String runtimeName : this.runtimeNames) {
            conf = conf.bindSetEntry(RuntimeNames.clreplaced, runtimeName);
        }
        if (!this.submissionRuntime.equalsIgnoreCase(RuntimeIdentifier.RUNTIME_NAME)) {
            throw new RuntimeException("Unsupported submission runtime " + this.submissionRuntime);
        }
        conf = conf.bindImplementation(MultiRuntimeMainConfigurationGenerator.clreplaced, YarnMultiRuntimeMainConfigurationGeneratorImpl.clreplaced);
        // Currently only local runtime is supported as a secondary runtime
        return Configurations.merge(conf.build(), ExtensibleYarnClientConfiguration.CONF.set(ExtensibleYarnClientConfiguration.DRIVER_CONFIGURATION_PROVIDER, MultiRuntimeDriverConfigurationProvider.clreplaced).build());
    }
}

19 View Complete Implementation : WatcherConfiguration.java
Copyright Apache License 2.0
Author : apache
/**
 * ConfigurationModule for Watcher.
 */
@Unstable
public final clreplaced WatcherConfiguration extends ConfigurationModuleBuilder {

    /**
     * Types of EventStream where events subscribed by Watcher will be reported.
     */
    public static final OptionalImpl<EventStream> EVENT_STREAMS = new OptionalImpl<>();

    public static final ConfigurationModule CONF = new WatcherConfiguration().bindSetEntry(EventStreams.clreplaced, EVENT_STREAMS).bindSetEntry(Clock.RuntimeStartHandler.clreplaced, Watcher.DriverRuntimeStartHandler.clreplaced).bindSetEntry(Clock.StartHandler.clreplaced, Watcher.DriverStartHandler.clreplaced).bindSetEntry(Clock.StopHandler.clreplaced, Watcher.DriverStopHandler.clreplaced).bindSetEntry(Clock.RuntimeStopHandler.clreplaced, Watcher.DriverRuntimeStopHandler.clreplaced).bindSetEntry(ServiceContextActiveHandlers.clreplaced, Watcher.ContextActiveHandler.clreplaced).bindSetEntry(ServiceContextClosedHandlers.clreplaced, Watcher.ContextClosedHandler.clreplaced).bindSetEntry(ServiceContextFailedHandlers.clreplaced, Watcher.ContextFailedHandler.clreplaced).bindSetEntry(ServiceTaskFailedHandlers.clreplaced, Watcher.TaskFailedHandler.clreplaced).bindSetEntry(ServiceTaskCompletedHandlers.clreplaced, Watcher.TaskCompletedHandler.clreplaced).bindSetEntry(ServiceTaskMessageHandlers.clreplaced, Watcher.TaskMessageHandler.clreplaced).bindSetEntry(ServiceTaskRunningHandlers.clreplaced, Watcher.TaskRunningHandler.clreplaced).bindSetEntry(ServiceTaskSuspendedHandlers.clreplaced, Watcher.TaskSuspendedHandler.clreplaced).bindSetEntry(ServiceEvaluatorAllocatedHandlers.clreplaced, Watcher.EvaluatorAllocatedHandler.clreplaced).bindSetEntry(ServiceEvaluatorFailedHandlers.clreplaced, Watcher.EvaluatorFailedHandler.clreplaced).bindSetEntry(ServiceEvaluatorCompletedHandlers.clreplaced, Watcher.EvaluatorCompletedHandler.clreplaced).build();

    /**
     * Construct a WatcherConfiguration.
     */
    private WatcherConfiguration() {
    }
}

19 View Complete Implementation : DriverClientException.java
Copyright Apache License 2.0
Author : apache
/**
 * An exception thrown by the driver client.
 */
@Unstable
public final clreplaced DriverClientException extends Exception {

    public DriverClientException(final String message) {
        super(message);
    }
}

19 View Complete Implementation : VortexLauncher.java
Copyright Apache License 2.0
Author : apache
/**
 * Launches a Vortex Job.
 */
@Unstable
public final clreplaced VortexLauncher {

    private VortexLauncher() {
    }

    private static final int MAX_NUMBER_OF_EVALUATORS = 10;

    /**
     * Launch a Vortex job using the local runtime.
     */
    public static LauncherStatus launchLocal(final VortexJobConf vortexConf) {
        final Configuration runtimeConf = LocalRuntimeConfiguration.CONF.set(LocalRuntimeConfiguration.MAX_NUMBER_OF_EVALUATORS, MAX_NUMBER_OF_EVALUATORS).build();
        return launch(runtimeConf, vortexConf.getConfiguration());
    }

    private static LauncherStatus launch(final Configuration runtimeConf, final Configuration vortexConf) {
        try {
            return DriverLauncher.getLauncher(runtimeConf).run(vortexConf);
        } catch (InjectionException e) {
            throw new RuntimeException(e);
        }
    }
}

19 View Complete Implementation : TaskletCancellationRequest.java
Copyright Apache License 2.0
Author : apache
/**
 * A {@link MasterToWorkerRequest} to cancel tasklets.
 */
@Unstable
public final clreplaced TaskletCancellationRequest implements MasterToWorkerRequest {

    private int taskletId;

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    TaskletCancellationRequest() {
    }

    public TaskletCancellationRequest(final int taskletId) {
        this.taskletId = taskletId;
    }

    /**
     * @return the ID of the VortexTasklet replacedociated with this MasterToWorkerRequest.
     */
    public int getTaskletId() {
        return taskletId;
    }

    @Override
    public Type getType() {
        return Type.CancelTasklet;
    }
}

19 View Complete Implementation : TaskletCancelledReport.java
Copyright Apache License 2.0
Author : apache
/**
 * The report of a cancelled Tasklet.
 */
@Unstable
public final clreplaced TaskletCancelledReport implements WorkerToMasterReport {

    private int taskletId;

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    TaskletCancelledReport() {
    }

    /**
     * @param taskletId of the cancelled tasklet.
     */
    public TaskletCancelledReport(final int taskletId) {
        this.taskletId = taskletId;
    }

    @Override
    public Type getType() {
        return Type.TaskletCancelled;
    }

    /**
     * @return the taskletId of this TaskletReport.
     */
    public int getTaskletId() {
        return taskletId;
    }
}

19 View Complete Implementation : Tuple.java
Copyright Apache License 2.0
Author : apache
/**
 * A key-value pair of elements.
 */
@Unstable
public final clreplaced Tuple<K, V> {

    private final K k;

    private final V v;

    public Tuple(final K k, final V v) {
        this.k = k;
        this.v = v;
    }

    public K getKey() {
        return k;
    }

    public V getValue() {
        return v;
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClreplaced() != o.getClreplaced()) {
            return false;
        }
        final Tuple tuple = (Tuple) o;
        if (!k.equals(tuple.k)) {
            return false;
        }
        if (!v.equals(tuple.v)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int result = k.hashCode();
        result = 31 * result + v.hashCode();
        return result;
    }

    @Override
    public String toString() {
        return "(" + getKey() + "," + getValue() + ")";
    }
}

19 View Complete Implementation : VortexMasterConf.java
Copyright Apache License 2.0
Author : apache
/**
 * Vortex Master configuration.
 */
@Unstable
@DriverSide
public final clreplaced VortexMasterConf extends ConfigurationModuleBuilder {

    /**
     * Number of Workers.
     */
    @NamedParameter(doc = "Number of Workers")
    final clreplaced WorkerNum implements Name<Integer> {
    }

    /**
     * Worker Memory.
     */
    @NamedParameter(doc = "Worker Memory")
    final clreplaced WorkerMem implements Name<Integer> {
    }

    /**
     * Worker Cores.
     */
    @NamedParameter(doc = "Worker Cores")
    final clreplaced WorkerCores implements Name<Integer> {
    }

    /**
     * Worker Capacity.
     */
    @NamedParameter(doc = "Worker Capacity")
    final clreplaced WorkerCapacity implements Name<Integer> {
    }

    /**
     * Number of Vortex Start Threads.
     */
    @NamedParameter(doc = "Number of Vortex Start Threads", default_value = "1")
    final clreplaced NumberOfVortexStartThreads implements Name<Integer> {
    }

    /**
     * Size of threadpool for callbacks on {@link org.apache.reef.vortex.api.VortexFuture}.
     */
    @NamedParameter(doc = "Size of threadpool for callbacks on VortexFuture.", default_value = "10")
    final clreplaced CallbackThreadPoolSize implements Name<Integer> {
    }

    /**
     * Number of Workers.
     */
    public static final RequiredParameter<Integer> WORKER_NUM = new RequiredParameter<>();

    /**
     * Worker Memory.
     */
    public static final RequiredParameter<Integer> WORKER_MEM = new RequiredParameter<>();

    /**
     * Worker Cores.
     */
    public static final RequiredParameter<Integer> WORKER_CORES = new RequiredParameter<>();

    /**
     * Worker Cores.
     */
    public static final OptionalParameter<Integer> WORKER_CAPACITY = new OptionalParameter<>();

    /**
     * Vortex Start.
     */
    public static final RequiredImpl<VortexStart> VORTEX_START = new RequiredImpl<>();

    /**
     * Number of Vortex Start threads.
     */
    public static final OptionalParameter<Integer> NUM_OF_VORTEX_START_THREAD = new OptionalParameter<>();

    /**
     * Size of threadpool for callbacks on VortexFuture.
     */
    public static final OptionalParameter<Integer> FUTURE_CALLBACK_THREAD_POOL_SIZE = new OptionalParameter<>();

    /**
     * Vortex Master configuration.
     */
    public static final ConfigurationModule CONF = new VortexMasterConf().bindNamedParameter(WorkerNum.clreplaced, WORKER_NUM).bindNamedParameter(WorkerMem.clreplaced, WORKER_MEM).bindNamedParameter(WorkerCores.clreplaced, WORKER_CORES).bindNamedParameter(WorkerCapacity.clreplaced, WORKER_CAPACITY).bindImplementation(VortexStart.clreplaced, VORTEX_START).bindNamedParameter(NumberOfVortexStartThreads.clreplaced, NUM_OF_VORTEX_START_THREAD).bindNamedParameter(CallbackThreadPoolSize.clreplaced, FUTURE_CALLBACK_THREAD_POOL_SIZE).build();
}

19 View Complete Implementation : VortexWorkerConf.java
Copyright Apache License 2.0
Author : apache
/**
 *  Vortex Worker configuration.
 */
@Unstable
@DriverSide
public final clreplaced VortexWorkerConf extends ConfigurationModuleBuilder {

    /**
     * Worker Threads.
     */
    @NamedParameter(doc = "Number of Worker Threads")
    public final clreplaced NumOfThreads implements Name<Integer> {
    }

    /**
     * Worker Threads.
     */
    public static final RequiredParameter<Integer> NUM_OF_THREADS = new RequiredParameter<>();

    /**
     * Vortex Worker configuration.
     */
    public static final ConfigurationModule CONF = new VortexWorkerConf().bindNamedParameter(NumOfThreads.clreplaced, NUM_OF_THREADS).build();
}

19 View Complete Implementation : PartitionSpec.java
Copyright Apache License 2.0
Author : apache
/**
 * This was another more type safe alternative to integer parreplacedions.
 */
@Unstable
public clreplaced ParreplacedionSpec {

    private final Type type;

    private final int id;

    public ParreplacedionSpec(final Type type, final int id) {
        this.type = type;
        this.id = id;
    }

    public Type getType() {
        return type;
    }

    public int getId() {
        return id;
    }

    /**
     * Parreplacedion type.
     */
    public enum Type {

        SINGLE, ALL, NONE
    }
}

18 View Complete Implementation : VortexJobConf.java
Copyright Apache License 2.0
Author : apache
/**
 * Helper clreplaced for building a configuration for Vortex.
 */
@Unstable
public final clreplaced VortexJobConf {

    private final Configuration conf;

    private VortexJobConf(final Configuration conf) {
        this.conf = conf;
    }

    /**
     * Create a Builder object for Vortex job configuration.
     */
    public static Builder newBuilder() {
        return new VortexJobConf.Builder();
    }

    /**
     * Convert to the Tang Configuration.
     */
    @Private
    public Configuration getConfiguration() {
        return conf;
    }

    /**
     * Builder object to create a {@link VortexJobConf}.
     */
    public static final clreplaced Builder implements org.apache.reef.util.Builder<VortexJobConf> {

        private String jobName;

        private Configuration vortexMasterConf;

        private Optional<Configuration> userConf = Optional.empty();

        private Builder() {
        }

        /**
         * @param vortexMasterConf Configuration for the Vortex Master, which can be built via {@link VortexMasterConf}.
         */
        public Builder setVortexMasterConf(final Configuration vortexMasterConf) {
            this.vortexMasterConf = vortexMasterConf;
            return this;
        }

        /**
         * @param userConf Configuration set by user (e.g., Parameters in {@link org.apache.reef.vortex.api.VortexStart}
         */
        public Builder setUserConf(final Configuration userConf) {
            this.userConf = Optional.of(userConf);
            return this;
        }

        /**
         * @param jobName Name of the job which is replacedigned to the Driver.
         */
        public Builder setJobName(final String jobName) {
            this.jobName = jobName;
            return this;
        }

        /**
         * Instantiate a {@link VortexJobConf} object, where a Configuration is built by Tang internally.
         *
         * {@link IllegalArgumentException} will be thrown if required parameters are not set
         * (See {@link #setJobName(String)} and {@link #setVortexMasterConf(Configuration)}).
         *
         * Also, {@link org.apache.reef.tang.exceptions.BindException} can be thrown while merging the configurations.
         *
         * @return An instance of VortexJobConf object.
         */
        @Override
        public VortexJobConf build() {
            BuilderUtils.notNull(jobName);
            BuilderUtils.notNull(vortexMasterConf);
            final Configuration vortexDriverConf = DriverConfiguration.CONF.set(DriverConfiguration.GLOBAL_LIBRARIES, EnvironmentUtils.getClreplacedLocation(VortexDriver.clreplaced)).set(DriverConfiguration.ON_DRIVER_STARTED, VortexDriver.StartHandler.clreplaced).set(DriverConfiguration.ON_EVALUATOR_ALLOCATED, VortexDriver.AllocatedEvaluatorHandler.clreplaced).set(DriverConfiguration.ON_TASK_RUNNING, VortexDriver.RunningTaskHandler.clreplaced).set(DriverConfiguration.ON_TASK_MESSAGE, VortexDriver.TaskMessageHandler.clreplaced).set(DriverConfiguration.ON_EVALUATOR_FAILED, VortexDriver.FailedEvaluatorHandler.clreplaced).set(DriverConfiguration.DRIVER_IDENTIFIER, jobName).build();
            final Configuration jobConf;
            if (userConf.isPresent()) {
                jobConf = Configurations.merge(vortexDriverConf, vortexMasterConf, userConf.get());
            } else {
                jobConf = Configurations.merge(vortexDriverConf, vortexMasterConf);
            }
            return new VortexJobConf(jobConf);
        }
    }
}

18 View Complete Implementation : MockEvaluatorDescriptor.java
Copyright Apache License 2.0
Author : apache
/**
 * mock evaluator descriptor.
 */
@Unstable
@Private
public final clreplaced MockEvaluatorDescriptor implements EvaluatorDescriptor {

    private final NodeDescriptor nodeDescriptor;

    MockEvaluatorDescriptor(final NodeDescriptor nodeDescriptor) {
        this.nodeDescriptor = nodeDescriptor;
    }

    @Override
    public NodeDescriptor getNodeDescriptor() {
        return this.nodeDescriptor;
    }

    @Override
    public EvaluatorProcess getProcess() {
        throw new UnsupportedOperationException();
    }

    @Override
    public int getMemory() {
        return 0;
    }

    @Override
    public int getNumberOfCores() {
        return 1;
    }

    @Override
    public String getRuntimeName() {
        return "mock";
    }
}

18 View Complete Implementation : MockNodeDescriptor.java
Copyright Apache License 2.0
Author : apache
/**
 * mock node descriptor.
 */
@Unstable
@Private
public final clreplaced MockNodeDescriptor implements NodeDescriptor {

    @Override
    public InetSocketAddress getInetSocketAddress() {
        throw new UnsupportedOperationException();
    }

    @Override
    public RackDescriptor getRackDescriptor() {
        return new RackDescriptor() {

            @Override
            public List<NodeDescriptor> getNodes() {
                final List<NodeDescriptor> nodes = new ArrayList<>();
                nodes.add(MockNodeDescriptor.this);
                return nodes;
            }

            @Override
            public String getName() {
                return "mock";
            }
        };
    }

    @Override
    public String getName() {
        return "mock";
    }

    @Override
    public String getId() {
        return "mock";
    }
}

18 View Complete Implementation : MockUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * mock utilities.
 */
@Unstable
@Private
final clreplaced MockUtils {

    private MockUtils() {
    }

    public static <U, T extends Name<U>> U getValue(final Configuration configuration, final Clreplaced<T> name) {
        try {
            final Injector injector = Tang.Factory.getTang().newInjector(configuration);
            return injector.getNamedInstance(name);
        } catch (InjectionException e) {
            throw new IllegalStateException(e);
        }
    }
}

18 View Complete Implementation : MultiRuntimeDefinitionBuilder.java
Copyright Apache License 2.0
Author : apache
/**
 * Builder for multi runtime definition.
 */
@Unstable
public final clreplaced MultiRuntimeDefinitionBuilder {

    private Map<String, AvroRuntimeDefinition> runtimes = new HashMap<>();

    private String defaultRuntime;

    private static AvroRuntimeDefinition createRuntimeDefinition(final Configuration configModule, final String runtimeName) {
        final Configuration localDriverConfiguration = configModule;
        final AvroConfigurationSerializer serializer = new AvroConfigurationSerializer();
        final String serializedConfig = serializer.toString(localDriverConfiguration);
        return new AvroRuntimeDefinition(runtimeName, serializedConfig);
    }

    /**
     * Adds runtime configuration module to the builder.
     * @param config The configuration module
     * @param runtimeName The name of the runtime
     * @return The builder instance
     */
    public MultiRuntimeDefinitionBuilder addRuntime(final Configuration config, final String runtimeName) {
        Validate.notNull(config, "runtime configuration module should not be null");
        Validate.isTrue(StringUtils.isNotBlank(runtimeName), "runtimeName should be non empty and non blank string");
        final AvroRuntimeDefinition rd = createRuntimeDefinition(config, runtimeName);
        this.runtimes.put(runtimeName, rd);
        return this;
    }

    /**
     * Sets default runtime name.
     * @param runtimeName The name of the default runtime
     * @return The builder instance
     */
    public MultiRuntimeDefinitionBuilder setDefaultRuntimeName(final String runtimeName) {
        Validate.isTrue(StringUtils.isNotBlank(runtimeName), "runtimeName should be non empty and non blank string");
        this.defaultRuntime = runtimeName;
        return this;
    }

    /**
     * Builds multi runtime definition.
     * @return The populated definition object
     */
    public AvroMultiRuntimeDefinition build() {
        Validate.isTrue(this.runtimes.size() == 1 || !StringUtils.isEmpty(this.defaultRuntime), "Default runtime " + "should be set if more than a single runtime provided");
        if (StringUtils.isEmpty(this.defaultRuntime)) {
            // we have single runtime configured, take its name as a default
            this.defaultRuntime = this.runtimes.keySet().iterator().next();
        }
        Validate.isTrue(this.runtimes.containsKey(this.defaultRuntime), "Default runtime should be configured");
        return new AvroMultiRuntimeDefinition(defaultRuntime, new ArrayList<>(this.runtimes.values()));
    }
}

18 View Complete Implementation : TaskletAggregationFailureReport.java
Copyright Apache License 2.0
Author : apache
/**
 * Report of a tasklet exception on aggregation.
 */
@Unstable
public final clreplaced TaskletAggregationFailureReport implements WorkerToMasterReport {

    private List<Integer> taskletIds;

    private Exception exception;

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    TaskletAggregationFailureReport() {
    }

    /**
     * @param taskletIds of the failed tasklet(s).
     * @param exception that caused the tasklet failure.
     */
    public TaskletAggregationFailureReport(final List<Integer> taskletIds, final Exception exception) {
        this.taskletIds = Collections.unmodifiableList(new ArrayList<>(taskletIds));
        this.exception = exception;
    }

    /**
     * @return the type of this TaskletReport.
     */
    @Override
    public Type getType() {
        return Type.TaskletAggregationFailure;
    }

    /**
     * @return the taskletIds that failed on aggregation.
     */
    public List<Integer> getTaskletIds() {
        return taskletIds;
    }

    /**
     * @return the exception that caused the tasklet aggregation failure.
     */
    public Exception getException() {
        return exception;
    }
}

18 View Complete Implementation : TaskletFailureReport.java
Copyright Apache License 2.0
Author : apache
/**
 * Report of a Tasklet exception.
 */
@Unstable
@Private
@DriverSide
public final clreplaced TaskletFailureReport implements WorkerToMasterReport {

    private int taskletId;

    private Exception exception;

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    TaskletFailureReport() {
    }

    /**
     * @param taskletId of the failed Tasklet.
     * @param exception that caused the tasklet failure.
     */
    public TaskletFailureReport(final int taskletId, final Exception exception) {
        this.taskletId = taskletId;
        this.exception = exception;
    }

    /**
     * @return the type of this TaskletReport.
     */
    @Override
    public Type getType() {
        return Type.TaskletFailure;
    }

    /**
     * @return the taskletId of this TaskletReport.
     */
    public int getTaskletId() {
        return taskletId;
    }

    /**
     * @return the exception that caused the Tasklet failure.
     */
    public Exception getException() {
        return exception;
    }
}

18 View Complete Implementation : TaskletResultReport.java
Copyright Apache License 2.0
Author : apache
/**
 * Report of a tasklet execution result.
 */
@Unstable
@Private
@DriverSide
public final clreplaced TaskletResultReport implements WorkerToMasterReport {

    private int taskletId;

    private Object result;

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    TaskletResultReport() {
    }

    /**
     * @param taskletId of the Tasklet.
     * @param result of the tasklet execution.
     */
    public TaskletResultReport(final int taskletId, final Object result) {
        this.taskletId = taskletId;
        this.result = result;
    }

    /**
     * @return the type of this TaskletReport.
     */
    @Override
    public Type getType() {
        return Type.TaskletResult;
    }

    /**
     * @return the TaskletId of this TaskletReport
     */
    public int getTaskletId() {
        return taskletId;
    }

    /**
     * @return the result of the tasklet execution.
     */
    public Object getResult() {
        return result;
    }
}

18 View Complete Implementation : WorkerToMasterReports.java
Copyright Apache License 2.0
Author : apache
/**
 * Container for multiple WorkerToMasterReports.
 */
@Private
@Unstable
@DriverSide
public final clreplaced WorkerToMasterReports {

    private ArrayList<WorkerToMasterReport> workerToMasterReports;

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    WorkerToMasterReports() {
    }

    public WorkerToMasterReports(final Collection<WorkerToMasterReport> workerToMasterReports) {
        this.workerToMasterReports = new ArrayList<>(workerToMasterReports);
    }

    /**
     * @return the list of Tasklet reports.
     */
    public List<WorkerToMasterReport> getReports() {
        return Collections.unmodifiableList(workerToMasterReports);
    }
}

18 View Complete Implementation : MultiRuntimeYarnBootstrapREEFLauncher.java
Copyright Apache License 2.0
Author : apache
/**
 * This is a bootstrap launcher for YARN for submission of multiruntime jobs from C#. It allows for Java Driver
 * configuration generation directly on the Driver without need of Java dependency if REST
 * submission is used. Note that the name of the clreplaced must contain "REEFLauncher" for the time
 * being in order for the Interop code to discover the clreplaced.
 */
// TODO[JIRA REEF-1382]: This clreplaced does things both for client and driver need to split it
@Unstable
@Interop(CppFiles = "DriverLauncher.cpp")
public final clreplaced MultiRuntimeYarnBootstrapREEFLauncher {

    private static final Logger LOG = Logger.getLogger(MultiRuntimeYarnBootstrapREEFLauncher.clreplaced.getName());

    public static void main(final String[] args) throws IOException, InjectionException {
        LOG.log(Level.INFO, "Entering BootstrapLauncher.main().");
        if (args.length != 2) {
            final StringBuilder sb = new StringBuilder();
            sb.append("[ ");
            for (String arg : args) {
                sb.append(arg);
                sb.append(" ");
            }
            sb.append("]");
            final String message = "Bootstrap launcher should have two configuration file inputs, one specifying the" + " application submission parameters to be deserialized and the other specifying the job" + " submission parameters to be deserialized to create the YarnDriverConfiguration on the fly." + " Current args are " + sb.toString();
            throw fatal(message, new IllegalArgumentException(message));
        }
        try {
            final MultiRuntimeYarnBootstrapDriverConfigGenerator driverConfigurationGenerator = Tang.Factory.getTang().newInjector().getInstance(MultiRuntimeYarnBootstrapDriverConfigGenerator.clreplaced);
            REEFLauncher.main(new String[] { driverConfigurationGenerator.writeDriverConfigurationFile(args[0], args[1]) });
        } catch (final Exception exception) {
            if (!(exception instanceof RuntimeException)) {
                throw fatal("Failed to initialize configurations.", exception);
            }
            throw exception;
        }
    }

    private static RuntimeException fatal(final String msg, final Throwable t) {
        LOG.log(Level.SEVERE, msg, t);
        return new RuntimeException(msg, t);
    }

    private MultiRuntimeYarnBootstrapREEFLauncher() {
    }
}

18 View Complete Implementation : DriverClientGrpcConfiguration.java
Copyright Apache License 2.0
Author : apache
/**
 * Configuration module for Grpc runtime.
 */
@Unstable
public final clreplaced DriverClientGrpcConfiguration extends ConfigurationModuleBuilder {

    public static final RequiredParameter<Integer> DRIVER_SERVICE_PORT = new RequiredParameter<>();

    public static final OptionalParameter<Integer> DRIVER_CLIENT_REGISTRATION_TIMEOUT = new OptionalParameter<>();

    public static final ConfigurationModule CONF = new DriverClientGrpcConfiguration().bindImplementation(DriverClientService.clreplaced, GRPCDriverClientService.clreplaced).bindImplementation(DriverServiceClient.clreplaced, GRPCDriverServiceClient.clreplaced).bindNamedParameter(DriverServicePort.clreplaced, DRIVER_SERVICE_PORT).bindNamedParameter(DriverRegistrationTimeout.clreplaced, DRIVER_CLIENT_REGISTRATION_TIMEOUT).build();
}

18 View Complete Implementation : AggregateResultSynchronous.java
Copyright Apache License 2.0
Author : apache
/**
 * The synchronous result of an aggregate, returned by {@link VortexAggregateFuture#get()}.
 */
@Public
@ClientSide
@Unstable
public final clreplaced AggregateResultSynchronous<TInput, TOutput> {

    private final AggregateResult<TInput, TOutput> result;

    private final boolean hasNext;

    AggregateResultSynchronous(final AggregateResult<TInput, TOutput> result, final boolean hasNext) {
        this.result = result;
        this.hasNext = hasNext;
    }

    /**
     * @return the output of an aggregation, throws the Exception if a Tasklet or an aggregation fails.
     * If an aggregation fails, {@link VortexAggregateException} will be thrown, otherwise
     * the Exception that caused the Tasklet to fail will be thrown directly.
     * @throws VortexAggregateException the Exception that caused the Tasklet or aggregation failure.
     */
    public TOutput getAggregateResult() throws VortexAggregateException {
        return result.getAggregateResult();
    }

    /**
     * @return the replacedociated inputs of an aggregation
     */
    public List<TInput> getAggregatedInputs() {
        return result.getAggregatedInputs();
    }

    /**
     * If an aggregation fails, {@link VortexAggregateException} will be thrown, otherwise
     * the Exception that caused the Tasklet to fail will be thrown directly.
     * @return the Exception that caused the Tasklet or aggregation failure, if any.
     */
    public Optional<Exception> getException() {
        return result.getException();
    }

    /**
     * @return true if more results will be available, false otherwise.
     */
    public boolean hasNext() {
        return hasNext;
    }
}

18 View Complete Implementation : DriverRestartEvaluatorRecoverySeconds.java
Copyright Apache License 2.0
Author : apache
/**
 * Represents the amount of time in seconds that the driver restart waits for evaluators to report back.
 * Defaults to 3 minutes. If the value is set to Integer.MAX_VALUE, the driver will wait forever until all
 * expected evaluators report back or fail.
 */
@Unstable
@NamedParameter(doc = "The amount of time in seconds that the driver restart waits for" + " evaluators to report back. Defaults to 3 minutes. If the value is set to Integer.MAX_VALUE, " + "the driver will wait forever until all expected evaluators report back or fail.", default_value = DriverRestartEvaluatorRecoverySeconds.DEFAULT)
public final clreplaced DriverRestartEvaluatorRecoverySeconds implements Name<Integer> {

    /**
     * The driver waits forever until all expected evaluators report back or fail.
     */
    public static final String INFINITE = Long.toString(Integer.MAX_VALUE);

    /**
     * Default restart wait for the driver is 3 minutes.
     */
    public static final String DEFAULT = "180";

    private DriverRestartEvaluatorRecoverySeconds() {
    }
}

18 View Complete Implementation : DistributedDataSet.java
Copyright Apache License 2.0
Author : apache
/**
 * Represents a distributed data set that is split across data centers.
 * It contains a set of distributed data set parreplacedions {@link DistributedDataSetParreplacedion}
 * this data to be loaded into.
 */
@Unstable
public final clreplaced DistributedDataSet implements Iterable<DistributedDataSetParreplacedion> {

    /**
     * The set of distributed data set parreplacedions.
     */
    private final Set<DistributedDataSetParreplacedion> parreplacedions = new HashSet<>();

    /**
     * Adds the given parreplacedion to the set.
     *
     * @param parreplacedion
     *          the parreplacedion to add
     */
    public void addParreplacedion(final DistributedDataSetParreplacedion parreplacedion) {
        this.parreplacedions.add(parreplacedion);
    }

    /**
     * Adds the given parreplacedions to the set.
     *
     * @param parreplacedions
     *          the parreplacedions to add
     */
    @SuppressWarnings("checkstyle:hiddenfield")
    public void addParreplacedions(final Collection<DistributedDataSetParreplacedion> parreplacedions) {
        this.parreplacedions.addAll(parreplacedions);
    }

    /**
     * Returns true if it does not contain any parreplacedion.
     *
     * @return a boolean indicating whether it contains parreplacedions or not
     */
    public boolean isEmpty() {
        return this.parreplacedions.isEmpty();
    }

    @Override
    public Iterator<DistributedDataSetParreplacedion> iterator() {
        return new DistributedDataSereplacederator(parreplacedions);
    }

    static final clreplaced DistributedDataSereplacederator implements Iterator<DistributedDataSetParreplacedion> {

        private final List<DistributedDataSetParreplacedion> parreplacedions;

        private int position;

        DistributedDataSereplacederator(final Collection<DistributedDataSetParreplacedion> parreplacedions) {
            this.parreplacedions = new LinkedList<>(parreplacedions);
            position = 0;
        }

        @Override
        public boolean hasNext() {
            return position < parreplacedions.size();
        }

        @Override
        public DistributedDataSetParreplacedion next() {
            final DistributedDataSetParreplacedion parreplacedion = parreplacedions.get(position);
            position++;
            return parreplacedion;
        }

        @Override
        public void remove() {
            throw new UnsupportedOperationException("Remove method has not been implemented in this iterator");
        }
    }
}

18 View Complete Implementation : VortexAggregateException.java
Copyright Apache License 2.0
Author : apache
/**
 * Exception thrown when an aggregate function fails.
 * Call {@link Exception#getCause()} to find the cause of failure in aggregation.
 * Call {@link VortexAggregateException#getInputs()} to get the inputs that correlate
 * with the failure.
 */
@Unstable
public final clreplaced VortexAggregateException extends Exception {

    private final List<Object> inputList;

    @Private
    public VortexAggregateException(final Throwable cause, final List<?> inputList) {
        super(cause);
        this.inputList = new ArrayList<>(inputList);
    }

    @Private
    public VortexAggregateException(final String message, final Throwable cause, final List<?> inputList) {
        super(message, cause);
        this.inputList = new ArrayList<>(inputList);
    }

    /**
     * @return Inputs that correlate with the aggregation failure.
     */
    public List<Object> getInputs() {
        return Collections.unmodifiableList(inputList);
    }
}

18 View Complete Implementation : LogEventStream.java
Copyright Apache License 2.0
Author : apache
/**
 * Write events to driver.err using Logger.
 */
@Unstable
public final clreplaced LogEventStream implements EventStream {

    private static final Logger LOG = Logger.getLogger(LogEventStream.clreplaced.getName());

    @Inject
    private LogEventStream() {
    }

    @Override
    public void onEvent(final EventType type, final String jsonEncodedEvent) {
        LOG.log(Level.INFO, "[{0}] {1}", new Object[] { type, jsonEncodedEvent });
    }
}

18 View Complete Implementation : MockCompletedTask.java
Copyright Apache License 2.0
Author : apache
/**
 * mock completed task.
 */
@Unstable
@Private
public final clreplaced MockCompletedTask implements CompletedTask {

    private final MockRunningTask task;

    private final byte[] returnValue;

    public MockCompletedTask(final MockRunningTask task, final byte[] returnValue) {
        this.task = task;
        this.returnValue = returnValue;
    }

    @Override
    public ActiveContext getActiveContext() {
        return this.task.getActiveContext();
    }

    @Override
    public String getId() {
        return this.task.getId();
    }

    @Override
    public byte[] get() {
        return this.returnValue;
    }
}

18 View Complete Implementation : VortexThreadPool.java
Copyright Apache License 2.0
Author : apache
/**
 * Distributed thread pool.
 */
@Unstable
public final clreplaced VortexThreadPool {

    private final VortexMaster vortexMaster;

    @Inject
    private VortexThreadPool(final VortexMaster vortexMaster) {
        this.vortexMaster = vortexMaster;
    }

    /**
     * @param function to run on Vortex
     * @param input of the function
     * @param <TInput> input type
     * @param <TOutput> output type
     * @return VortexFuture for tracking execution progress
     */
    public <TInput, TOutput> VortexFuture<TOutput> submit(final VortexFunction<TInput, TOutput> function, final TInput input) {
        return vortexMaster.enqueueTasklet(function, input, Optional.<FutureCallback<TOutput>>empty());
    }

    /**
     * @param function to run on Vortex
     * @param input of the function
     * @param callback of the function
     * @param <TInput> input type
     * @param <TOutput> output type
     * @return VortexFuture for tracking execution progress
     */
    public <TInput, TOutput> VortexFuture<TOutput> submit(final VortexFunction<TInput, TOutput> function, final TInput input, final FutureCallback<TOutput> callback) {
        return vortexMaster.enqueueTasklet(function, input, Optional.of(callback));
    }

    /**
     * @param aggregateFunction to run on VortexFunction outputs
     * @param function to run on Vortex
     * @param policy on aggregation
     * @param inputs of the function
     * @param <TInput> input type
     * @param <TOutput> output type
     * @return VortexAggregationFuture for tracking execution progress of aggregate-able functions
     */
    public <TInput, TOutput> VortexAggregateFuture<TInput, TOutput> submit(final VortexAggregateFunction<TOutput> aggregateFunction, final VortexFunction<TInput, TOutput> function, final VortexAggregatePolicy policy, final List<TInput> inputs) {
        return vortexMaster.enqueueTasklets(aggregateFunction, function, policy, inputs, Optional.<FutureCallback<AggregateResult<TInput, TOutput>>>empty());
    }

    /**
     * @param aggregateFunction to run on VortexFunction outputs
     * @param function to run on Vortex
     * @param policy on aggregation
     * @param inputs of the function
     * @param callback of the aggregation
     * @param <TInput> input type
     * @param <TOutput> output type
     * @return VortexAggregationFuture for tracking execution progress of aggregate-able functions
     */
    public <TInput, TOutput> VortexAggregateFuture<TInput, TOutput> submit(final VortexAggregateFunction<TOutput> aggregateFunction, final VortexFunction<TInput, TOutput> function, final VortexAggregatePolicy policy, final List<TInput> inputs, final FutureCallback<AggregateResult<TInput, TOutput>> callback) {
        return vortexMaster.enqueueTasklets(aggregateFunction, function, policy, inputs, Optional.of(callback));
    }
}

18 View Complete Implementation : MockFailedContext.java
Copyright Apache License 2.0
Author : apache
/**
 * mock failed context.
 */
@Unstable
@Private
public final clreplaced MockFailedContext implements FailedContext {

    private final MockActiveContext context;

    public MockFailedContext(final MockActiveContext context) {
        this.context = context;
    }

    @Override
    public Optional<ActiveContext> getParentContext() {
        return this.context.getParentContext().isPresent() ? Optional.of((ActiveContext) this.context.getParentContext().get()) : Optional.<ActiveContext>empty();
    }

    @Override
    public String getMessage() {
        return "mock";
    }

    @Override
    public Optional<String> getDescription() {
        return Optional.empty();
    }

    @Override
    public Optional<Throwable> getReason() {
        return Optional.empty();
    }

    @Override
    public Optional<byte[]> getData() {
        return Optional.empty();
    }

    @Override
    public Throwable asError() {
        return new Exception("mock");
    }

    @Override
    public String getEvaluatorId() {
        return this.context.getEvaluatorId();
    }

    @Override
    public Optional<String> getParentId() {
        return this.context.getParentId();
    }

    @Override
    public EvaluatorDescriptor getEvaluatorDescriptor() {
        return this.context.getEvaluatorDescriptor();
    }

    @Override
    public String getId() {
        return this.context.getId();
    }
}

18 View Complete Implementation : MockSuspendedTask.java
Copyright Apache License 2.0
Author : apache
/**
 * mock suspended task.
 */
@Unstable
@Private
public final clreplaced MockSuspendedTask implements SuspendedTask {

    private final MockRunningTask task;

    public MockSuspendedTask(final MockRunningTask task) {
        this.task = task;
    }

    @Override
    public ActiveContext getActiveContext() {
        return this.task.getActiveContext();
    }

    @Override
    public byte[] get() {
        return new byte[0];
    }

    @Override
    public String getId() {
        return this.task.getId();
    }
}

18 View Complete Implementation : TaskletAggregateExecutionRequest.java
Copyright Apache License 2.0
Author : apache
/**
 * A request from the Vortex Driver to run an aggregate-able function.
 */
@Unstable
@Private
@DriverSide
public final clreplaced TaskletAggregateExecutionRequest<TInput> implements MasterToWorkerRequest {

    private TInput input;

    private int aggregateFunctionId;

    private int taskletId;

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    TaskletAggregateExecutionRequest() {
    }

    public TaskletAggregateExecutionRequest(final int taskletId, final int aggregateFunctionId, final TInput input) {
        this.taskletId = taskletId;
        this.input = input;
        this.aggregateFunctionId = aggregateFunctionId;
    }

    /**
     * @return input of the request.
     */
    public TInput getInput() {
        return input;
    }

    /**
     * @return tasklet ID corresponding to the tasklet request.
     */
    public int getTaskletId() {
        return taskletId;
    }

    /**
     * @return the AggregateFunctionID of the request.
     */
    public int getAggregateFunctionId() {
        return aggregateFunctionId;
    }

    @Override
    public Type getType() {
        return Type.ExecuteAggregateTasklet;
    }
}

18 View Complete Implementation : RunnableExecutingHandler.java
Copyright Apache License 2.0
Author : apache
/**
 * Handler that executes Runnable commands.
 */
@Unstable
public final clreplaced RunnableExecutingHandler implements EventHandler<Runnable> {

    private static final Logger LOG = Logger.getLogger(RunnableExecutingHandler.clreplaced.getName());

    @Override
    public void onNext(final Runnable runnable) {
        try {
            runnable.run();
        } catch (final Exception exception) {
            LOG.log(Level.INFO, "An exception occurred while writing event with Watcher. {0}", exception.getMessage());
        }
    }
}

18 View Complete Implementation : VortexAggregateFuture.java
Copyright Apache License 2.0
Author : apache
/**
 * The interface between user code and aggregation Tasklets.
 * Thread safety: This clreplaced is not meant to be used in a multi-threaded fashion.
 * TODO[JIRA REEF-1131]: Create and run tests once functional.
 */
@Public
@ClientSide
@NotThreadSafe
@Unstable
public final clreplaced VortexAggregateFuture<TInput, TOutput> implements VortexFutureDelegate<TOutput> {

    private final Executor executor;

    private final BlockingQueue<Pair<List<Integer>, AggregateResult>> resultQueue;

    private final ConcurrentMap<Integer, TInput> taskletIdInputMap;

    private final FutureCallback<AggregateResult<TInput, TOutput>> callbackHandler;

    @Private
    public VortexAggregateFuture(final Executor executor, final Map<Integer, TInput> taskletIdInputMap, final FutureCallback<AggregateResult<TInput, TOutput>> callbackHandler) {
        this.executor = executor;
        this.taskletIdInputMap = new ConcurrentHashMap<>(taskletIdInputMap);
        this.resultQueue = new ArrayBlockingQueue<>(taskletIdInputMap.size());
        this.callbackHandler = callbackHandler;
    }

    /**
     * @return the next aggregation result for the future, null if no more results.
     */
    public synchronized AggregateResultSynchronous<TInput, TOutput> get() throws InterruptedException {
        if (taskletIdInputMap.isEmpty()) {
            return null;
        }
        final Pair<List<Integer>, AggregateResult> resultPair = resultQueue.take();
        removeFromTaskletIdInputMap(resultPair.getLeft());
        return new AggregateResultSynchronous<>(resultPair.getRight(), !taskletIdInputMap.isEmpty());
    }

    /**
     * @param timeout the timeout for the operation.
     * @param timeUnit the time unit of the timeout.
     * @return the next aggregation result for the future, within the user specified timeout, null if no more results.
     * @throws TimeoutException if time out hits.
     */
    public synchronized AggregateResultSynchronous<TInput, TOutput> get(final long timeout, final TimeUnit timeUnit) throws InterruptedException, TimeoutException {
        if (taskletIdInputMap.isEmpty()) {
            return null;
        }
        final Pair<List<Integer>, AggregateResult> resultPair = resultQueue.poll(timeout, timeUnit);
        if (resultPair == null) {
            throw new TimeoutException("Synchronous aggregation of the next future result timed out. Timeout = " + timeout + " in time units: " + timeUnit);
        }
        removeFromTaskletIdInputMap(resultPair.getLeft());
        return new AggregateResultSynchronous<>(resultPair.getRight(), !taskletIdInputMap.isEmpty());
    }

    private void removeFromTaskletIdInputMap(final List<Integer> taskletIds) {
        for (final int taskletId : taskletIds) {
            taskletIdInputMap.remove(taskletId);
        }
    }

    /**
     * @return true if there are no more results to poll.
     */
    public boolean isDone() {
        return taskletIdInputMap.isEmpty();
    }

    /**
     * A Tasklet replacedociated with the aggregation has completed.
     */
    @Private
    @Override
    public void completed(final int taskletId, final TOutput result) {
        try {
            completedTasklets(result, Collections.singletonList(taskletId));
        } catch (final InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Aggregation has completed for a list of Tasklets, with an aggregated result.
     */
    @Private
    @Override
    public void aggregationCompleted(final List<Integer> taskletIds, final TOutput result) {
        try {
            completedTasklets(result, taskletIds);
        } catch (final InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * A Tasklet replacedociated with the aggregation has failed.
     */
    @Private
    @Override
    public void threwException(final int taskletId, final Exception exception) {
        try {
            failedTasklets(exception, Collections.singletonList(taskletId));
        } catch (final InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * A list of Tasklets has failed during aggregation phase.
     */
    @Private
    @Override
    public void aggregationThrewException(final List<Integer> taskletIds, final Exception exception) {
        try {
            failedTasklets(exception, taskletIds);
        } catch (final InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * Not implemented for local aggregation.
     */
    @Private
    @Override
    public void cancelled(final int taskletId) {
        throw new NotImplementedException("Tasklet cancellation not supported in aggregations.");
    }

    /**
     * Create and queue result for Tasklets that are expected and invoke callback.
     */
    private void completedTasklets(final TOutput output, final List<Integer> taskletIds) throws InterruptedException {
        final List<TInput> inputs = getInputs(taskletIds);
        final AggregateResult result = new AggregateResult(output, inputs);
        if (callbackHandler != null) {
            executor.execute(new Runnable() {

                @Override
                public void run() {
                    callbackHandler.onSuccess(result);
                }
            });
        }
        resultQueue.put(new ImmutablePair<>(taskletIds, result));
    }

    /**
     * Create and queue result for failed Tasklets that are expected and invokes callback.
     */
    private void failedTasklets(final Exception exception, final List<Integer> taskletIds) throws InterruptedException {
        final List<TInput> inputs = getInputs(taskletIds);
        final AggregateResult failure = new AggregateResult(exception, inputs);
        if (callbackHandler != null) {
            executor.execute(new Runnable() {

                @Override
                public void run() {
                    callbackHandler.onFailure(new VortexAggregateException(exception, inputs));
                }
            });
        }
        resultQueue.put(new ImmutablePair<>(taskletIds, failure));
    }

    /**
     * Gets the inputs on Tasklet aggregation completion.
     */
    private List<TInput> getInputs(final List<Integer> taskletIds) {
        final List<TInput> inputList = new ArrayList<>(taskletIds.size());
        for (final int taskletId : taskletIds) {
            inputList.add(taskletIdInputMap.get(taskletId));
        }
        return inputList;
    }
}

18 View Complete Implementation : WatcherAvroUtil.java
Copyright Apache License 2.0
Author : apache
@Private
@Unstable
public final clreplaced WatcherAvroUtil {

    public static AvroFailure toAvroFailure(final Failure failure) {
        final String reason;
        if (failure.getReason().isPresent()) {
            reason = convertThrowableToString(failure.getReason().get());
        } else {
            reason = null;
        }
        return AvroFailure.newBuilder().setAsError(convertThrowableToString(failure.asError())).setData(unwrapOptionalByteArray(failure.getData())).setDescription(failure.getDescription().orElse(null)).setId(failure.getId()).setMessage(failure.getMessage()).setReason(reason).build();
    }

    public static AvroNodeDescriptorInRackDescriptor toAvroNodeDescriptorInRackDescriptor(final String id, final String name, final InetSocketAddress inetSocketAddress) {
        return AvroNodeDescriptorInRackDescriptor.newBuilder().setInetSocketAddress(inetSocketAddress.toString()).setId(id).setName(name).build();
    }

    public static AvroRackDescriptor toAvroRackDescriptor(final RackDescriptor rackDescriptor) {
        final List<AvroNodeDescriptorInRackDescriptor> nodeDescriptorList = new ArrayList<>();
        for (final NodeDescriptor nodeDescriptor : rackDescriptor.getNodes()) {
            nodeDescriptorList.add(toAvroNodeDescriptorInRackDescriptor(nodeDescriptor.getId(), nodeDescriptor.getName(), nodeDescriptor.getInetSocketAddress()));
        }
        return AvroRackDescriptor.newBuilder().setNodes(nodeDescriptorList).setName(rackDescriptor.getName()).build();
    }

    public static AvroNodeDescriptor toAvroNodeDescriptor(final NodeDescriptor nodeDescriptor) {
        return AvroNodeDescriptor.newBuilder().setId(nodeDescriptor.getId()).setName(nodeDescriptor.getName()).setInetSocketAddress(nodeDescriptor.getInetSocketAddress().toString()).setRackDescriptor(toAvroRackDescriptor(nodeDescriptor.getRackDescriptor())).build();
    }

    public static AvroEvaluatorType toAvroEvaluatorType(final EvaluatorType evaluatorType) {
        switch(evaluatorType) {
            case JVM:
                return AvroEvaluatorType.JVM;
            case CLR:
                return AvroEvaluatorType.CLR;
            case UNDECIDED:
                return AvroEvaluatorType.UNDECIDED;
            default:
                throw new RuntimeException(evaluatorType + " is not defined for AvroEvaluatorType.");
        }
    }

    public static AvroEvaluatorProcess toAvroEvaluatorProcess(final EvaluatorProcess evaluatorProcess) {
        final List<CharSequence> commandLines = new ArrayList<>();
        for (final String commandLine : evaluatorProcess.getCommandLine()) {
            commandLines.add(commandLine);
        }
        return AvroEvaluatorProcess.newBuilder().setCommandLines(commandLines).setEvaluatorType(toAvroEvaluatorType(evaluatorProcess.getType())).setIsOptionSet(evaluatorProcess.isOptionSet()).build();
    }

    public static AvroEvaluatorDescriptor toAvroEvaluatorDescriptor(final EvaluatorDescriptor evaluatorDescriptor) {
        return AvroEvaluatorDescriptor.newBuilder().setMemory(evaluatorDescriptor.getMemory()).setNodeDescriptor(toAvroNodeDescriptor(evaluatorDescriptor.getNodeDescriptor())).setNumberOfCores(evaluatorDescriptor.getNumberOfCores()).setProcess(toAvroEvaluatorProcess(evaluatorDescriptor.getProcess())).build();
    }

    public static AvroRuntimeStart toAvroRuntimeStart(final RuntimeStart runtimeStart) {
        return AvroRuntimeStart.newBuilder().setTimestamp(runtimeStart.getTimestamp()).build();
    }

    public static AvroStartTime toAvroStartTime(final StartTime startTime) {
        return AvroStartTime.newBuilder().setTimestamp(startTime.getTimestamp()).build();
    }

    public static AvroStopTime toAvroStopTime(final StopTime stopTime) {
        return AvroStopTime.newBuilder().setTimestamp(stopTime.getTimestamp()).build();
    }

    public static AvroRuntimeStop toAvroRuntimeStop(final RuntimeStop runtimeStop) {
        return AvroRuntimeStop.newBuilder().setException(convertThrowableToString(runtimeStop.getException())).setTimestamp(runtimeStop.getTimestamp()).build();
    }

    public static AvroContextBase toAvroContextBase(final ContextBase contextBase) {
        return AvroContextBase.newBuilder().setEvaluatorDescriptor(null).setEvaluatorId(contextBase.getEvaluatorId()).setId(contextBase.getId()).setParentId(contextBase.getParentId().orElse(null)).build();
    }

    public static AvroActiveContext toAvroActiveContext(final ActiveContext activeContext) {
        return AvroActiveContext.newBuilder().setBase(toAvroContextBase(activeContext)).build();
    }

    public static AvroClosedContext toAvroClosedContext(final ClosedContext closedContext) {
        return AvroClosedContext.newBuilder().setBase(toAvroContextBase(closedContext)).setParentContext(toAvroActiveContext(closedContext.getParentContext())).build();
    }

    public static AvroFailedContext toAvroFailedContext(final FailedContext failedContext) {
        return AvroFailedContext.newBuilder().setBase(toAvroContextBase(failedContext)).setParentContext(unwrapOptionalActiveContext(failedContext.getParentContext())).setFailure(toAvroFailure(failedContext)).build();
    }

    public static AvroCompletedTask toAvroCompletedTask(final CompletedTask completedTask) {
        return AvroCompletedTask.newBuilder().setId(completedTask.getId()).setActiveContext(toAvroActiveContext(completedTask.getActiveContext())).setGet(wrapNullableByteArray(completedTask.get())).build();
    }

    public static AvroFailedTask toAvroFailedTask(final FailedTask failedTask) {
        return AvroFailedTask.newBuilder().setActiveContext(unwrapOptionalActiveContext(failedTask.getActiveContext())).setFailure(toAvroFailure(failedTask)).build();
    }

    public static AvroRunningTask toAvroRunningTask(final RunningTask runningTask) {
        return AvroRunningTask.newBuilder().setActiveContext(toAvroActiveContext(runningTask.getActiveContext())).setId(runningTask.getId()).build();
    }

    public static AvroTaskMessage toAvroTaskMessage(final TaskMessage taskMessage) {
        return AvroTaskMessage.newBuilder().setId(taskMessage.getId()).setContextId(taskMessage.getContextId()).setMessageSourceId(taskMessage.getMessageSourceID()).setGet(wrapNullableByteArray(taskMessage.get())).build();
    }

    public static AvroSuspendedTask toAvroSuspendedTask(final SuspendedTask suspendedTask) {
        return AvroSuspendedTask.newBuilder().setGet(wrapNullableByteArray(suspendedTask.get())).setId(suspendedTask.getId()).setActiveContext(toAvroActiveContext(suspendedTask.getActiveContext())).build();
    }

    public static AvroAllocatedEvaluator toAvroAllocatedEvaluator(final AllocatedEvaluator allocatedEvaluator) {
        return AvroAllocatedEvaluator.newBuilder().setId(allocatedEvaluator.getId()).setEvaluatorDescriptor(toAvroEvaluatorDescriptor(allocatedEvaluator.getEvaluatorDescriptor())).build();
    }

    public static AvroFailedEvaluator toAvroFailedEvaluator(final FailedEvaluator failedEvaluator) {
        final AvroFailedTask avroFailedTask;
        if (failedEvaluator.getFailedTask().isPresent()) {
            avroFailedTask = toAvroFailedTask(failedEvaluator.getFailedTask().get());
        } else {
            avroFailedTask = null;
        }
        final List<AvroFailedContext> avroFailedContextList = new ArrayList<>();
        for (final FailedContext failedContext : failedEvaluator.getFailedContextList()) {
            avroFailedContextList.add(toAvroFailedContext(failedContext));
        }
        return AvroFailedEvaluator.newBuilder().setId(failedEvaluator.getId()).setEvaluatorException(convertThrowableToString(failedEvaluator.getEvaluatorException())).setFailedContextList(avroFailedContextList).setFailedTask(avroFailedTask).build();
    }

    public static AvroCompletedEvaluator toAvroCompletedEvaluator(final CompletedEvaluator completedEvaluator) {
        return AvroCompletedEvaluator.newBuilder().setId(completedEvaluator.getId()).build();
    }

    public static String toString(final SpecificRecord record) {
        final String jsonEncodedRecord;
        try {
            final Schema schema = record.getSchema();
            final ByteArrayOutputStream bos = new ByteArrayOutputStream();
            final Encoder encoder = EncoderFactory.get().jsonEncoder(schema, bos);
            final SpecificDatumWriter datumWriter = new SpecificDatumWriter(record.getClreplaced());
            datumWriter.write(record, encoder);
            encoder.flush();
            jsonEncodedRecord = new String(bos.toByteArray(), Charset.forName("UTF-8"));
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
        return jsonEncodedRecord;
    }

    private static AvroActiveContext unwrapOptionalActiveContext(final Optional<ActiveContext> optionalActiveContext) {
        if (optionalActiveContext.isPresent()) {
            return toAvroActiveContext(optionalActiveContext.get());
        }
        return null;
    }

    private static String convertThrowableToString(final Throwable throwable) {
        if (throwable != null) {
            return throwable.toString();
        }
        return null;
    }

    private static ByteBuffer wrapNullableByteArray(final byte[] data) {
        if (data != null) {
            return ByteBuffer.wrap(data);
        }
        return null;
    }

    private static ByteBuffer unwrapOptionalByteArray(final Optional<byte[]> optionalByteArray) {
        if (optionalByteArray.isPresent()) {
            return ByteBuffer.wrap(optionalByteArray.get());
        }
        return null;
    }

    /**
     * Empty private constructor to prohibit instantiation of utility clreplaced.
     */
    private WatcherAvroUtil() {
    }
}

18 View Complete Implementation : MockActiveContext.java
Copyright Apache License 2.0
Author : apache
/**
 * mock active context.
 */
@Unstable
@Private
public final clreplaced MockActiveContext implements ActiveContext {

    private final MockRuntimeDriver mockRuntimeDriver;

    private final MockAllocatedEvaluator evaluator;

    private final Optional<MockActiveContext> parentContext;

    private final String contextID;

    MockActiveContext(final MockRuntimeDriver mockRuntimeDriver, final MockAllocatedEvaluator evaluator, final Optional<MockActiveContext> parentContext, final String contextID) {
        this.mockRuntimeDriver = mockRuntimeDriver;
        this.evaluator = evaluator;
        this.parentContext = parentContext;
        this.contextID = contextID;
    }

    @Override
    public int hashCode() {
        final String id = this.getEvaluatorId() + ":" + contextID;
        return id.hashCode();
    }

    public boolean equals(final Object that) {
        if (that instanceof MockActiveContext) {
            return this.getEvaluatorId().equals(((MockActiveContext) that).getEvaluatorId()) && this.contextID.equals(((MockActiveContext) that).contextID);
        }
        return false;
    }

    public MockAllocatedEvaluator getEvaluator() {
        return this.evaluator;
    }

    public Optional<MockActiveContext> getParentContext() {
        return this.parentContext;
    }

    @Override
    public void close() {
        this.mockRuntimeDriver.add(new CloseContext(this));
    }

    @Override
    public void submitTask(final Configuration taskConf) {
        final String taskID = MockUtils.getValue(taskConf, TaskConfigurationOptions.Identifier.clreplaced);
        final MockRunningTask task = new MockRunningTask(this.mockRuntimeDriver, taskID, this);
        this.mockRuntimeDriver.add(new CreateTask(task, this.mockRuntimeDriver.getTaskReturnValueProvider()));
    }

    @Override
    public void submitContext(final Configuration contextConfiguration) {
        final String childContextID = MockUtils.getValue(contextConfiguration, ContextIdentifier.clreplaced);
        final MockActiveContext context = new MockActiveContext(this.mockRuntimeDriver, this.evaluator, Optional.of(this), childContextID);
        this.mockRuntimeDriver.add(new CreateContext(context));
    }

    @Override
    public void submitContextAndService(final Configuration contextConfiguration, final Configuration serviceConfiguration) {
        submitContext(contextConfiguration);
    }

    @Override
    public void sendMessage(final byte[] message) {
        this.mockRuntimeDriver.add(new SendMessageDriverToContext(this, message));
    }

    @Override
    public String getEvaluatorId() {
        return this.evaluator.getId();
    }

    @Override
    public Optional<String> getParentId() {
        return this.parentContext.isPresent() ? Optional.of(this.parentContext.get().getId()) : Optional.<String>empty();
    }

    @Override
    public EvaluatorDescriptor getEvaluatorDescriptor() {
        return this.evaluator.getEvaluatorDescriptor();
    }

    @Override
    public String getId() {
        return this.contextID;
    }
}

18 View Complete Implementation : VortexAggregatePolicy.java
Copyright Apache License 2.0
Author : apache
/**
 * The policy for local aggregation on the {@link org.apache.reef.vortex.evaluator.VortexWorker}s.
 * The Aggregation function will be triggered on the individual {@link VortexFunction} results on
 * an "OR" basis of what is specified by the policy.
 */
@ClientSide
@Public
@Unstable
public final clreplaced VortexAggregatePolicy {

    private Optional<Integer> count;

    private int periodMilliseconds;

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    VortexAggregatePolicy() {
    }

    private VortexAggregatePolicy(final int periodMilliseconds, final Optional<Integer> count) {
        this.periodMilliseconds = periodMilliseconds;
        this.count = count;
    }

    /**
     * @return the aggregation period in milliseconds.
     */
    public int getPeriodMilliseconds() {
        return periodMilliseconds;
    }

    /**
     * @return the count trigger for the aggregation.
     */
    public Optional<Integer> getCount() {
        return count;
    }

    /**
     * @return a new {@link Builder} for {@link VortexAggregatePolicy}.
     */
    public static AggregatePolicyBuilder newBuilder() {
        return new AggregatePolicyBuilder();
    }

    /**
     * A Builder clreplaced for {@link VortexAggregatePolicy}.
     */
    public static final clreplaced AggregatePolicyBuilder implements Builder<VortexAggregatePolicy> {

        private Integer periodMilliseconds = null;

        private Optional<Integer> count = Optional.empty();

        private AggregatePolicyBuilder() {
        }

        /**
         * Sets the period to trigger aggregation in milliseconds. Required parameter to build.
         */
        public AggregatePolicyBuilder setTimerPeriodTrigger(final int pOffsetMilliseconds) {
            periodMilliseconds = pOffsetMilliseconds;
            return this;
        }

        /**
         * Sets the count trigger for aggregation. Not required.
         */
        public AggregatePolicyBuilder setCountTrigger(final int pCount) {
            count = Optional.of(pCount);
            return this;
        }

        /**
         * Builds and returns a new {@link VortexAggregatePolicy} based on user's specification.
         * The timer period is a required parameter for this to succeed.
         * @throws IllegalArgumentException if required parameters are not set or if parameters are invalid.
         */
        @Override
        public VortexAggregatePolicy build() throws IllegalArgumentException {
            if (periodMilliseconds == null) {
                throw new IllegalArgumentException("The aggregate period must be set.");
            }
            if (count.isPresent() && count.get() <= 0) {
                throw new IllegalArgumentException("The count trigger must be greater than zero.");
            }
            return new VortexAggregatePolicy(periodMilliseconds, count);
        }
    }
}

18 View Complete Implementation : MockClosedContext.java
Copyright Apache License 2.0
Author : apache
/**
 * mock closed context.
 */
@Unstable
@Private
public final clreplaced MockClosedContext implements ClosedContext {

    private final MockActiveContext mockActiveContext;

    public MockClosedContext(final MockActiveContext activeContext) {
        this.mockActiveContext = activeContext;
    }

    public MockActiveContext getMockActiveContext() {
        return this.mockActiveContext;
    }

    @Override
    public ActiveContext getParentContext() {
        return this.mockActiveContext.getParentContext().isPresent() ? this.mockActiveContext.getParentContext().get() : null;
    }

    @Override
    public String getId() {
        return this.mockActiveContext.getId();
    }

    @Override
    public String getEvaluatorId() {
        return this.mockActiveContext.getEvaluatorId();
    }

    @Override
    public Optional<String> getParentId() {
        return this.mockActiveContext.getParentId();
    }

    @Override
    public EvaluatorDescriptor getEvaluatorDescriptor() {
        return this.mockActiveContext.getEvaluatorDescriptor();
    }
}

17 View Complete Implementation : AggregateResult.java
Copyright Apache License 2.0
Author : apache
/**
 * The result of an aggregate. Registered to callbacks for {@link VortexAggregateFuture}.
 */
@Public
@ClientSide
@Unstable
public final clreplaced AggregateResult<TInput, TOutput> {

    private final Optional<TOutput> aggregatedOutput;

    private final List<TInput> inputList;

    private final Optional<Exception> exception;

    AggregateResult(final Exception exception, final List<TInput> inputList) {
        this(Optional.<TOutput>empty(), Optional.of(exception), inputList);
    }

    AggregateResult(final TOutput aggregatedOutput, final List<TInput> inputList) {
        this(Optional.of(aggregatedOutput), Optional.<Exception>empty(), inputList);
    }

    private AggregateResult(final Optional<TOutput> aggregatedOutput, final Optional<Exception> exception, final List<TInput> inputList) {
        this.aggregatedOutput = aggregatedOutput;
        this.inputList = Collections.unmodifiableList(inputList);
        this.exception = exception;
    }

    /**
     * @return the output of an aggregation, throws the Exception if a Tasklet or an aggregation fails.
     * If an aggregation fails, {@link VortexAggregateException} will be thrown, otherwise
     * the Exception that caused the Tasklet to fail will be thrown directly.
     * @throws Exception the Exception that caused the Tasklet or aggregation failure.
     */
    public TOutput getAggregateResult() throws VortexAggregateException {
        if (exception.isPresent()) {
            throw new VortexAggregateException(exception.get(), inputList);
        }
        return aggregatedOutput.get();
    }

    /**
     * @return the replacedociated inputs of an aggregation
     */
    public List<TInput> getAggregatedInputs() {
        return inputList;
    }

    /**
     * If an aggregation fails, {@link VortexAggregateException} will be thrown, otherwise
     * the Exception that caused the Tasklet to fail will be thrown directly.
     * @return the Exception that caused the Tasklet or aggregation failure, if any.
     */
    public Optional<Exception> getException() {
        return exception;
    }
}

17 View Complete Implementation : KryoUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * The one and only serializer for the Vortex protocol.
 */
@Private
@Unstable
public final clreplaced KryoUtils {

    /**
     * For reducing Kryo object instantiation cost.
     */
    private final KryoPool kryoPool;

    @Inject
    private KryoUtils() {
        final KryoFactory factory = new KryoFactory() {

            @Override
            public Kryo create() {
                final Kryo kryo = new Kryo();
                // Required to serialize/deserialize Throwable
                UnmodifiableCollectionsSerializer.registerSerializers(kryo);
                return kryo;
            }
        };
        kryoPool = new KryoPool.Builder(factory).softReferences().build();
    }

    public byte[] serialize(final Object object) {
        try (final Output out = new Output(new ByteArrayOutputStream())) {
            final Kryo kryo = kryoPool.borrow();
            kryo.writeClreplacedAndObject(out, object);
            kryoPool.release(kryo);
            return out.toBytes();
        }
    }

    public Object deserialize(final byte[] bytes) {
        try (final Input input = new Input(new ByteArrayInputStream(bytes))) {
            final Kryo kryo = kryoPool.borrow();
            final Object object = kryo.readClreplacedAndObject(input);
            kryoPool.release(kryo);
            return object;
        }
    }
}

17 View Complete Implementation : AggregateFunctionRepository.java
Copyright Apache License 2.0
Author : apache
/**
 * A repository for {@link VortexAggregateFunction} and its replacedociated {@link VortexAggregatePolicy}.
 */
@ThreadSafe
@Unstable
@Private
final clreplaced AggregateFunctionRepository {

    private final ConcurrentMap<Integer, Tuple<VortexAggregateFunction, VortexAggregatePolicy>> aggregateFunctionMap = new ConcurrentHashMap<>();

    @Inject
    private AggregateFunctionRepository() {
    }

    /**
     * replacedociates an aggregate function ID with a {@link VortexAggregateFunction} and a {@link VortexAggregatePolicy}.
     */
    public Tuple<VortexAggregateFunction, VortexAggregatePolicy> put(final int aggregateFunctionId, final VortexAggregateFunction aggregateFunction, final VortexAggregatePolicy policy) {
        return aggregateFunctionMap.put(aggregateFunctionId, new Tuple<>(aggregateFunction, policy));
    }

    /**
     * Gets the {@link VortexAggregateFunction} replacedociated with the aggregate function ID.
     */
    public VortexAggregateFunction getAggregateFunction(final int aggregateFunctionId) {
        return aggregateFunctionMap.get(aggregateFunctionId).getKey();
    }

    /**
     * Gets the {@link VortexAggregatePolicy} replacedociated with the aggregate function ID.
     */
    public VortexAggregatePolicy getPolicy(final int aggregateFunctionId) {
        return aggregateFunctionMap.get(aggregateFunctionId).getValue();
    }
}

17 View Complete Implementation : TaskletExecutionRequest.java
Copyright Apache License 2.0
Author : apache
/**
 * Request to execute a tasklet.
 */
@Unstable
@Private
public final clreplaced TaskletExecutionRequest<TInput, TOutput> implements MasterToWorkerRequest {

    private int taskletId;

    private VortexFunction<TInput, TOutput> userFunction;

    private TInput input;

    /**
     * @return the type of this MasterToWorkerRequest.
     */
    @Override
    public Type getType() {
        return Type.ExecuteTasklet;
    }

    /**
     * No-arg constructor required for Kryo to serialize/deserialize.
     */
    TaskletExecutionRequest() {
    }

    /**
     * Request from Vortex Master to Vortex Worker to execute a tasklet.
     */
    public TaskletExecutionRequest(final int taskletId, final VortexFunction<TInput, TOutput> userFunction, final TInput input) {
        this.taskletId = taskletId;
        this.userFunction = userFunction;
        this.input = input;
    }

    /**
     * Execute the function using the input.
     * @return Output of the function.
     */
    public TOutput execute() throws Exception {
        return userFunction.call(input);
    }

    /**
     * @return the ID of the VortexTasklet replacedociated with this MasterToWorkerRequest.
     */
    public int getTaskletId() {
        return taskletId;
    }

    /**
     * Get function of the tasklet.
     */
    public VortexFunction getFunction() {
        return userFunction;
    }

    /**
     * Get input of the tasklet.
     */
    public TInput getInput() {
        return input;
    }
}

17 View Complete Implementation : DriverClientConfiguration.java
Copyright Apache License 2.0
Author : apache
/**
 * Driver client configuration.
 */
@Unstable
public final clreplaced DriverClientConfiguration extends ConfigurationModuleBuilder {

    /**
     * The event handler invoked right after the driver boots up.
     */
    public static final RequiredImpl<EventHandler<StartTime>> ON_DRIVER_STARTED = new RequiredImpl<>();

    /**
     * The event handler invoked right before the driver shuts down. Defaults to ignore.
     */
    public static final OptionalImpl<EventHandler<StopTime>> ON_DRIVER_STOP = new OptionalImpl<>();

    // ***** EVALUATOR HANDLER BINDINGS:
    /**
     * Event handler for allocated evaluators. Defaults to returning the evaluator if not bound.
     */
    public static final OptionalImpl<EventHandler<AllocatedEvaluator>> ON_EVALUATOR_ALLOCATED = new OptionalImpl<>();

    /**
     * Event handler for completed evaluators. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<CompletedEvaluator>> ON_EVALUATOR_COMPLETED = new OptionalImpl<>();

    /**
     * Event handler for failed evaluators. Defaults to job failure if not bound.
     */
    public static final OptionalImpl<EventHandler<FailedEvaluator>> ON_EVALUATOR_FAILED = new OptionalImpl<>();

    // ***** TASK HANDLER BINDINGS:
    /**
     * Event handler for task messages. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<TaskMessage>> ON_TASK_MESSAGE = new OptionalImpl<>();

    /**
     * Event handler for completed tasks. Defaults to closing the context the task ran on if not bound.
     */
    public static final OptionalImpl<EventHandler<CompletedTask>> ON_TASK_COMPLETED = new OptionalImpl<>();

    /**
     * Event handler for failed tasks. Defaults to job failure if not bound.
     */
    public static final OptionalImpl<EventHandler<FailedTask>> ON_TASK_FAILED = new OptionalImpl<>();

    /**
     * Event handler for running tasks. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<RunningTask>> ON_TASK_RUNNING = new OptionalImpl<>();

    /**
     * Event handler for suspended tasks. Defaults to job failure if not bound. Rationale: many jobs don't support
     * task suspension. Hence, this parameter should be optional. The only sane default is to crash the job, then.
     */
    public static final OptionalImpl<EventHandler<SuspendedTask>> ON_TASK_SUSPENDED = new OptionalImpl<>();

    // ***** CLIENT HANDLER BINDINGS:
    /**
     * Event handler for client messages. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<byte[]>> ON_CLIENT_MESSAGE = new OptionalImpl<>();

    /**
     * Event handler for close messages sent by the client. Defaults to job failure if not bound.
     */
    public static final OptionalImpl<EventHandler<Void>> ON_CLIENT_CLOSED = new OptionalImpl<>();

    /**
     * Event handler for close messages sent by the client. Defaults to job failure if not bound.
     */
    public static final OptionalImpl<EventHandler<byte[]>> ON_CLIENT_CLOSED_MESSAGE = new OptionalImpl<>();

    // ***** CONTEXT HANDLER BINDINGS:
    /**
     * Event handler for active context. Defaults to closing the context if not bound.
     */
    public static final OptionalImpl<EventHandler<ActiveContext>> ON_CONTEXT_ACTIVE = new OptionalImpl<>();

    /**
     * Event handler for closed context. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<ClosedContext>> ON_CONTEXT_CLOSED = new OptionalImpl<>();

    /**
     * Event handler for closed context. Defaults to job failure if not bound.
     */
    public static final OptionalImpl<EventHandler<FailedContext>> ON_CONTEXT_FAILED = new OptionalImpl<>();

    /**
     * Event handler for context messages. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<ContextMessage>> ON_CONTEXT_MESSAGE = new OptionalImpl<>();

    /**
     * Number of dispatch threads to use.
     */
    public static final OptionalImpl<Integer> CLIENT_DRIVER_DISPATCH_THREAD_COUNT = new OptionalImpl<>();

    /**
     * Alarm dispatch handler.
     */
    public static final OptionalImpl<AlarmDispatchHandler> ALARM_DISPATCH_HANDLER = new OptionalImpl<>();

    /**
     * Default to gRPC Driver Client Service.
     */
    public static final OptionalImpl<DriverClientService> DRIVER_CLIENT_SERVICE = new OptionalImpl<>();

    /**
     * Default to gRPC Driver Service Client.
     */
    public static final OptionalImpl<DriverServiceClient> DRIVER_SERVICE_CLIENT = new OptionalImpl<>();

    /**
     * ConfigurationModule to fill out to get a legal Driver Configuration.
     */
    public static final ConfigurationModule CONF = new DriverClientConfiguration().bindImplementation(Clock.clreplaced, DriverClientClock.clreplaced).bindImplementation(EvaluatorRequestor.clreplaced, DriverClientEvaluatorRequestor.clreplaced).bindImplementation(AlarmDispatchHandler.clreplaced, ALARM_DISPATCH_HANDLER).bindImplementation(DriverClientService.clreplaced, DRIVER_CLIENT_SERVICE).bindImplementation(DriverServiceClient.clreplaced, DRIVER_SERVICE_CLIENT).bindNamedParameter(DriverClientDispatchThreadCount.clreplaced, CLIENT_DRIVER_DISPATCH_THREAD_COUNT).bindSetEntry(DriverStartHandler.clreplaced, ON_DRIVER_STARTED).bindSetEntry(ClientDriverStopHandler.clreplaced, ON_DRIVER_STOP).bindSetEntry(EvaluatorAllocatedHandlers.clreplaced, ON_EVALUATOR_ALLOCATED).bindSetEntry(EvaluatorCompletedHandlers.clreplaced, ON_EVALUATOR_COMPLETED).bindSetEntry(EvaluatorFailedHandlers.clreplaced, ON_EVALUATOR_FAILED).bindSetEntry(TaskRunningHandlers.clreplaced, ON_TASK_RUNNING).bindSetEntry(TaskFailedHandlers.clreplaced, ON_TASK_FAILED).bindSetEntry(TaskMessageHandlers.clreplaced, ON_TASK_MESSAGE).bindSetEntry(TaskCompletedHandlers.clreplaced, ON_TASK_COMPLETED).bindSetEntry(TaskSuspendedHandlers.clreplaced, ON_TASK_SUSPENDED).bindSetEntry(ContextActiveHandlers.clreplaced, ON_CONTEXT_ACTIVE).bindSetEntry(ContextClosedHandlers.clreplaced, ON_CONTEXT_CLOSED).bindSetEntry(ContextMessageHandlers.clreplaced, ON_CONTEXT_MESSAGE).bindSetEntry(ContextFailedHandlers.clreplaced, ON_CONTEXT_FAILED).bindSetEntry(ClientMessageHandlers.clreplaced, ON_CLIENT_MESSAGE).bindSetEntry(ClientCloseHandlers.clreplaced, ON_CLIENT_CLOSED).bindSetEntry(ClientCloseWithMessageHandlers.clreplaced, ON_CLIENT_CLOSED_MESSAGE).build();
}

17 View Complete Implementation : DefaultDriverRuntimeRestartMangerImpl.java
Copyright Apache License 2.0
Author : apache
/**
 * The default driver runtime restart manager that is not able to perform any restart actions.
 * Thus, when performing actions pertaining to restart, it is recommended to call
 * {@link DriverRuntimeRestartManager#getResubmissionAttempts()} first and check for > 0.
 */
@Private
@DriverSide
@Unstable
final clreplaced DefaultDriverRuntimeRestartMangerImpl implements DriverRuntimeRestartManager {

    @Inject
    private DefaultDriverRuntimeRestartMangerImpl() {
    }

    @Override
    public int getResubmissionAttempts() {
        return 0;
    }

    @Override
    public void recordAllocatedEvaluator(final String id) {
        throw new DriverFatalRuntimeException("Restart is not enabled. recordAllocatedEvaluator should not have been called.");
    }

    @Override
    public void recordRemovedEvaluator(final String id) {
        throw new DriverFatalRuntimeException("Restart is not enabled. recordRemovedEvaluator should not have been called.");
    }

    @Override
    public RestartEvaluators getPreviousEvaluators() {
        throw new DriverFatalRuntimeException("Restart is not enabled. getPreviousEvaluators should not have been called.");
    }

    @Override
    public void informAboutEvaluatorFailures(final Set<String> failedEvaluatorIds) {
        throw new DriverFatalRuntimeException("Restart is not enabled. informAboutEvaluatorFailures should not have been called.");
    }
}

17 View Complete Implementation : EventStreams.java
Copyright Apache License 2.0
Author : apache
/**
 * Set of EventStreams.
 */
@Private
@Unstable
@NamedParameter(default_clreplacedes = { LogEventStream.clreplaced })
public final clreplaced EventStreams implements Name<Set<EventStream>> {

    /**
     * This clreplaced should not be instantiated.
     */
    private EventStreams() {
    }
}

17 View Complete Implementation : Watcher.java
Copyright Apache License 2.0
Author : apache
/**
 * Subscribe events and transfer them as wrapping with corresponding avro clreplacedes.
 */
@Unstable
@Unit
public final clreplaced Watcher {

    private final Set<EventStream> eventStreamSet;

    @Inject
    private Watcher(@Parameter(EventStreams.clreplaced) final Set<EventStream> eventStreamSet) {
        this.eventStreamSet = eventStreamSet;
    }

    private void onEvent(final EventType eventType, final String jsonEncodedEvent) {
        for (final EventStream eventStream : eventStreamSet) {
            eventStream.onEvent(eventType, jsonEncodedEvent);
        }
    }

    public final clreplaced DriverRuntimeStartHandler implements EventHandler<RuntimeStart> {

        @Override
        public void onNext(final RuntimeStart runtimeStart) {
            onEvent(EventType.RuntimeStart, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroRuntimeStart(runtimeStart)));
        }
    }

    public final clreplaced DriverStartHandler implements EventHandler<StartTime> {

        @Override
        public void onNext(final StartTime startTime) {
            onEvent(EventType.StartTime, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroStartTime(startTime)));
        }
    }

    public final clreplaced DriverStopHandler implements EventHandler<StopTime> {

        @Override
        public void onNext(final StopTime stopTime) {
            onEvent(EventType.StopTime, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroStopTime(stopTime)));
        }
    }

    public final clreplaced DriverRuntimeStopHandler implements EventHandler<RuntimeStop> {

        @Override
        public void onNext(final RuntimeStop runtimeStop) {
            onEvent(EventType.RuntimeStop, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroRuntimeStop(runtimeStop)));
        }
    }

    public final clreplaced ContextActiveHandler implements EventHandler<ActiveContext> {

        @Override
        public void onNext(final ActiveContext activeContext) {
            onEvent(EventType.ActiveContext, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroActiveContext(activeContext)));
        }
    }

    public final clreplaced ContextClosedHandler implements EventHandler<ClosedContext> {

        @Override
        public void onNext(final ClosedContext closedContext) {
            onEvent(EventType.ClosedContext, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroClosedContext(closedContext)));
        }
    }

    public final clreplaced ContextFailedHandler implements EventHandler<FailedContext> {

        @Override
        public void onNext(final FailedContext failedContext) {
            onEvent(EventType.FailedContext, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroFailedContext(failedContext)));
        }
    }

    public final clreplaced TaskCompletedHandler implements EventHandler<CompletedTask> {

        @Override
        public void onNext(final CompletedTask completedTask) {
            onEvent(EventType.CompletedTask, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroCompletedTask(completedTask)));
        }
    }

    public final clreplaced TaskFailedHandler implements EventHandler<FailedTask> {

        @Override
        public void onNext(final FailedTask failedTask) {
            onEvent(EventType.FailedTask, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroFailedTask(failedTask)));
        }
    }

    public final clreplaced TaskRunningHandler implements EventHandler<RunningTask> {

        @Override
        public void onNext(final RunningTask runningTask) {
            onEvent(EventType.RunningTask, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroRunningTask(runningTask)));
        }
    }

    public final clreplaced TaskMessageHandler implements EventHandler<TaskMessage> {

        @Override
        public void onNext(final TaskMessage taskMessage) {
            onEvent(EventType.TaskMessage, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroTaskMessage(taskMessage)));
        }
    }

    public final clreplaced TaskSuspendedHandler implements EventHandler<SuspendedTask> {

        @Override
        public void onNext(final SuspendedTask suspendedTask) {
            onEvent(EventType.SuspendedTask, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroSuspendedTask(suspendedTask)));
        }
    }

    public final clreplaced EvaluatorAllocatedHandler implements EventHandler<AllocatedEvaluator> {

        @Override
        public void onNext(final AllocatedEvaluator allocatedEvaluator) {
            onEvent(EventType.AllocatedEvaluator, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroAllocatedEvaluator(allocatedEvaluator)));
        }
    }

    public final clreplaced EvaluatorFailedHandler implements EventHandler<FailedEvaluator> {

        @Override
        public void onNext(final FailedEvaluator failedEvaluator) {
            onEvent(EventType.FailedEvaluator, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroFailedEvaluator(failedEvaluator)));
        }
    }

    public final clreplaced EvaluatorCompletedHandler implements EventHandler<CompletedEvaluator> {

        @Override
        public void onNext(final CompletedEvaluator completedEvaluator) {
            onEvent(EventType.CompletedEvaluator, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroCompletedEvaluator(completedEvaluator)));
        }
    }
}

17 View Complete Implementation : MockConfiguration.java
Copyright Apache License 2.0
Author : apache
/**
 * Configure a mock runtime.
 */
@Unstable
public clreplaced MockConfiguration extends ConfigurationModuleBuilder {

    /**
     * The event handler invoked right after the driver boots up.
     */
    public static final RequiredImpl<EventHandler<StartTime>> ON_DRIVER_STARTED = new RequiredImpl<>();

    /**
     * The event handler invoked right before the driver shuts down. Defaults to ignore.
     */
    public static final OptionalImpl<EventHandler<StopTime>> ON_DRIVER_STOP = new OptionalImpl<>();

    // ***** EVALUATOR HANDLER BINDINGS:
    /**
     * Event handler for allocated evaluators. Defaults to returning the evaluator if not bound.
     */
    public static final OptionalImpl<EventHandler<AllocatedEvaluator>> ON_EVALUATOR_ALLOCATED = new OptionalImpl<>();

    /**
     * Event handler for completed evaluators. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<CompletedEvaluator>> ON_EVALUATOR_COMPLETED = new OptionalImpl<>();

    /**
     * Event handler for failed evaluators. Defaults to job failure if not bound.
     */
    public static final OptionalImpl<EventHandler<FailedEvaluator>> ON_EVALUATOR_FAILED = new OptionalImpl<>();

    // ***** TASK HANDLER BINDINGS:
    /**
     * Event handler for task messages. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<TaskMessage>> ON_TASK_MESSAGE = new OptionalImpl<>();

    /**
     * Event handler for completed tasks. Defaults to closing the context the task ran on if not bound.
     */
    public static final OptionalImpl<EventHandler<CompletedTask>> ON_TASK_COMPLETED = new OptionalImpl<>();

    /**
     * Event handler for failed tasks. Defaults to job failure if not bound.
     */
    public static final OptionalImpl<EventHandler<FailedTask>> ON_TASK_FAILED = new OptionalImpl<>();

    /**
     * Event handler for running tasks. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<RunningTask>> ON_TASK_RUNNING = new OptionalImpl<>();

    /**
     * Event handler for suspended tasks. Defaults to job failure if not bound. Rationale: many jobs don't support
     * task suspension. Hence, this parameter should be optional. The only sane default is to crash the job, then.
     */
    public static final OptionalImpl<EventHandler<SuspendedTask>> ON_TASK_SUSPENDED = new OptionalImpl<>();

    // ***** CONTEXT HANDLER BINDINGS:
    /**
     * Event handler for active context. Defaults to closing the context if not bound.
     */
    public static final OptionalImpl<EventHandler<ActiveContext>> ON_CONTEXT_ACTIVE = new OptionalImpl<>();

    /**
     * Event handler for closed context. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<ClosedContext>> ON_CONTEXT_CLOSED = new OptionalImpl<>();

    /**
     * Event handler for closed context. Defaults to job failure if not bound.
     */
    public static final OptionalImpl<EventHandler<FailedContext>> ON_CONTEXT_FAILED = new OptionalImpl<>();

    /**
     * Event handler for context messages. Defaults to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<ContextMessage>> ON_CONTEXT_MESSAGE = new OptionalImpl<>();

    /**
     * This event is fired in place of the ON_DRIVER_STARTED when the Driver is in fact restarted after failure.
     */
    public static final OptionalImpl<EventHandler<DriverRestarted>> ON_DRIVER_RESTARTED = new OptionalImpl<>();

    /**
     * Event handler for running tasks in previous evaluator, when driver restarted. Defaults to crash if not bound.
     */
    public static final OptionalImpl<EventHandler<RunningTask>> ON_DRIVER_RESTART_TASK_RUNNING = new OptionalImpl<>();

    /**
     * Event handler for active context when driver restart. Defaults to closing the context if not bound.
     */
    public static final OptionalImpl<EventHandler<ActiveContext>> ON_DRIVER_RESTART_CONTEXT_ACTIVE = new OptionalImpl<>();

    /**
     * Event handler for the event of driver restart completion, default to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<DriverRestartCompleted>> ON_DRIVER_RESTART_COMPLETED = new OptionalImpl<>();

    /**
     * Event handler for the event of driver restart completion, default to logging if not bound.
     */
    public static final OptionalImpl<EventHandler<FailedEvaluator>> ON_DRIVER_RESTART_EVALUATOR_FAILED = new OptionalImpl<>();

    /**
     * Receiver of messages sent by the Driver to the client.
     */
    public static final OptionalImpl<JobMessageObserver> ON_JOB_MESSAGE = new OptionalImpl<>();

    /**
     *  An implementation of a task return value provider.
     */
    public static final OptionalImpl<MockTaskReturnValueProvider> TASK_RETURN_VALUE_PROVIDER = new OptionalImpl<>();

    public static final ConfigurationModule CONF = new MockConfiguration().bindImplementation(EvaluatorRequestor.clreplaced, // requesting evaluators
    MockEvaluatorRequestor.clreplaced).bindImplementation(MockRuntime.clreplaced, MockRuntimeDriver.clreplaced).bindImplementation(MockFailure.clreplaced, MockRuntimeDriver.clreplaced).bindImplementation(Clock.clreplaced, MockClock.clreplaced).bindImplementation(MockTaskReturnValueProvider.clreplaced, TASK_RETURN_VALUE_PROVIDER).bindSetEntry(DriverRestartFailedEvaluatorHandlers.clreplaced, ON_DRIVER_RESTART_EVALUATOR_FAILED).bindSetEntry(DriverRestartCompletedHandlers.clreplaced, ON_DRIVER_RESTART_COMPLETED).bindSetEntry(DriverRestartContextActiveHandlers.clreplaced, ON_DRIVER_RESTART_CONTEXT_ACTIVE).bindSetEntry(DriverRestartTaskRunningHandlers.clreplaced, ON_DRIVER_RESTART_TASK_RUNNING).bindSetEntry(DriverRestartHandler.clreplaced, ON_DRIVER_RESTARTED).bindImplementation(JobMessageObserver.clreplaced, // sending message to job client
    ON_JOB_MESSAGE).bindSetEntry(DriverStartHandler.clreplaced, ON_DRIVER_STARTED).bindSetEntry(Clock.StopHandler.clreplaced, ON_DRIVER_STOP).bindSetEntry(EvaluatorAllocatedHandlers.clreplaced, ON_EVALUATOR_ALLOCATED).bindSetEntry(EvaluatorCompletedHandlers.clreplaced, ON_EVALUATOR_COMPLETED).bindSetEntry(EvaluatorFailedHandlers.clreplaced, ON_EVALUATOR_FAILED).bindSetEntry(TaskRunningHandlers.clreplaced, ON_TASK_RUNNING).bindSetEntry(TaskFailedHandlers.clreplaced, ON_TASK_FAILED).bindSetEntry(TaskMessageHandlers.clreplaced, ON_TASK_MESSAGE).bindSetEntry(TaskCompletedHandlers.clreplaced, ON_TASK_COMPLETED).bindSetEntry(TaskSuspendedHandlers.clreplaced, ON_TASK_SUSPENDED).bindSetEntry(ContextActiveHandlers.clreplaced, ON_CONTEXT_ACTIVE).bindSetEntry(ContextClosedHandlers.clreplaced, ON_CONTEXT_CLOSED).bindSetEntry(ContextMessageHandlers.clreplaced, ON_CONTEXT_MESSAGE).bindSetEntry(ContextFailedHandlers.clreplaced, ON_CONTEXT_FAILED).build();
}

17 View Complete Implementation : AllocateEvaluator.java
Copyright Apache License 2.0
Author : apache
/**
 * Allocate Evaluator process request.
 */
@Unstable
@Private
public final clreplaced AllocateEvaluator implements ProcessRequestInternal<MockAllocatedEvaluator, FailedEvaluator> {

    private final MockAllocatedEvaluator evaluator;

    public AllocateEvaluator(final MockAllocatedEvaluator evaluator) {
        this.evaluator = evaluator;
    }

    @Override
    public Type getType() {
        return Type.ALLOCATE_EVALUATOR;
    }

    @Override
    public MockAllocatedEvaluator getSuccessEvent() {
        return this.evaluator;
    }

    @Override
    public FailedEvaluator getFailureEvent() {
        return new MockFailedEvaluator(evaluator.getId());
    }

    @Override
    public boolean doAutoComplete() {
        return false;
    }

    @Override
    public void setAutoComplete(final boolean value) {
        throw new UnsupportedOperationException();
    }

    @Override
    public ProcessRequest getCompletionProcessRequest() {
        throw new UnsupportedOperationException();
    }
}

17 View Complete Implementation : CloseContext.java
Copyright Apache License 2.0
Author : apache
/**
 * close context process request.
 */
@Unstable
@Private
public final clreplaced CloseContext implements ProcessRequestInternal<ClosedContext, FailedContext>, AutoCompletable {

    private final MockActiveContext context;

    public CloseContext(final MockActiveContext context) {
        this.context = context;
    }

    @Override
    public Type getType() {
        return Type.CLOSE_CONTEXT;
    }

    @Override
    public MockClosedContext getSuccessEvent() {
        return new MockClosedContext(this.context);
    }

    @Override
    public FailedContext getFailureEvent() {
        return new MockFailedContext(this.context);
    }

    @Override
    public boolean doAutoComplete() {
        return !this.context.getParentContext().isPresent();
    }

    @Override
    public void setAutoComplete(final boolean value) {
        throw new UnsupportedOperationException();
    }

    @Override
    public ProcessRequest getCompletionProcessRequest() {
        return new CloseEvaluator(this.context.getEvaluator());
    }
}

17 View Complete Implementation : CloseEvaluator.java
Copyright Apache License 2.0
Author : apache
/**
 * close evaluator request.
 */
@Unstable
@Private
public final clreplaced CloseEvaluator implements ProcessRequestInternal<CompletedEvaluator, FailedEvaluator> {

    private final MockAllocatedEvaluator evaluator;

    public CloseEvaluator(final MockAllocatedEvaluator evaluator) {
        this.evaluator = evaluator;
    }

    @Override
    public Type getType() {
        return Type.CLOSE_EVALUATOR;
    }

    @Override
    public CompletedEvaluator getSuccessEvent() {
        return new CompletedEvaluator() {

            @Override
            public String getId() {
                return evaluator.getId();
            }
        };
    }

    @Override
    public FailedEvaluator getFailureEvent() {
        // TODO[initialize remaining failed contstructer fields]
        return new MockFailedEvaluator(evaluator.getId());
    }

    @Override
    public boolean doAutoComplete() {
        return false;
    }

    @Override
    public void setAutoComplete(final boolean value) {
        throw new UnsupportedOperationException();
    }

    @Override
    public ProcessRequest getCompletionProcessRequest() {
        throw new UnsupportedOperationException();
    }
}