This project has retired. For details please refer to its Attic page.
Source code
001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.reef.poison;
020
021import org.apache.reef.driver.task.TaskConfigurationOptions;
022import org.apache.reef.evaluator.context.parameters.ContextStartHandlers;
023import org.apache.reef.poison.context.PoisonedContextStartHandler;
024import org.apache.reef.poison.params.CrashProbability;
025import org.apache.reef.poison.params.CrashTimeout;
026import org.apache.reef.poison.task.PoisonedTaskStartHandler;
027import org.apache.reef.tang.formats.ConfigurationModule;
028import org.apache.reef.tang.formats.ConfigurationModuleBuilder;
029import org.apache.reef.tang.formats.OptionalParameter;
030
031/**
032 * Configure a Context with a lethal injection.
033 */
034public final class PoisonedConfiguration extends ConfigurationModuleBuilder {
035
036  /**
037   * The time window in seconds beginning at ContextStart during which the crash is to occur.
038   */
039  public static final OptionalParameter<Integer> CRASH_TIMEOUT = new OptionalParameter<>();
040
041  /**
042   * The probability with which a crash is to occur.
043   */
044  public static final OptionalParameter<Double> CRASH_PROBABILITY = new OptionalParameter<>();
045
046  public static final ConfigurationModule CONTEXT_CONF = new PoisonedConfiguration()
047      .bindNamedParameter(CrashTimeout.class, CRASH_TIMEOUT)
048      .bindNamedParameter(CrashProbability.class, CRASH_PROBABILITY)
049      .bindSetEntry(ContextStartHandlers.class, PoisonedContextStartHandler.class)
050      .build();
051
052  public static final ConfigurationModule TASK_CONF = new PoisonedConfiguration()
053      .bindNamedParameter(CrashTimeout.class, CRASH_TIMEOUT)
054      .bindNamedParameter(CrashProbability.class, CRASH_PROBABILITY)
055      .bindSetEntry(TaskConfigurationOptions.StartHandlers.class, PoisonedTaskStartHandler.class)
056      .build();
057}