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.runtime.common.driver.context;
020
021import org.apache.reef.annotations.audience.DriverSide;
022import org.apache.reef.annotations.audience.Private;
023import org.apache.reef.driver.context.ActiveContext;
024import org.apache.reef.driver.context.ClosedContext;
025import org.apache.reef.driver.evaluator.EvaluatorDescriptor;
026import org.apache.reef.util.Optional;
027
028/**
029 * Driver side representation of a closed context.
030 */
031@DriverSide
032@Private
033public final class ClosedContextImpl implements ClosedContext {
034
035
036  private final ActiveContext parentContext;
037  private final String contextID;
038  private final String evaluatorId;
039  private final EvaluatorDescriptor evaluatorDescriptor;
040
041  /**
042   * @param parentContext       the parent context.
043   * @param contextID           the id of the closed context
044   * @param evaluatorId         the id of the evaluator on which the context was closed
045   * @param evaluatorDescriptor the descriptor of the evaluator on which the context was closed.
046   */
047  public ClosedContextImpl(final ActiveContext parentContext,
048                           final String contextID,
049                           final String evaluatorId,
050                           final EvaluatorDescriptor evaluatorDescriptor) {
051    this.parentContext = parentContext;
052    this.contextID = contextID;
053    this.evaluatorId = evaluatorId;
054    this.evaluatorDescriptor = evaluatorDescriptor;
055  }
056
057  @Override
058  public ActiveContext getParentContext() {
059    return parentContext;
060  }
061
062  @Override
063  public String getId() {
064    return this.contextID;
065  }
066
067  @Override
068  public String getEvaluatorId() {
069    return this.evaluatorId;
070  }
071
072  @Override
073  public Optional<String> getParentId() {
074    return Optional.of(this.parentContext.getId());
075  }
076
077  @Override
078  public EvaluatorDescriptor getEvaluatorDescriptor() {
079    return this.evaluatorDescriptor;
080  }
081
082  @Override
083  public String toString() {
084    return "ClosedContext{" +
085        "contextID='" + contextID + '\'' +
086        '}';
087  }
088}