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.driver.evaluator; 020 021import org.apache.reef.annotations.Provided; 022import org.apache.reef.annotations.audience.DriverSide; 023import org.apache.reef.annotations.audience.Public; 024import org.apache.reef.driver.ContextAndTaskSubmittable; 025import org.apache.reef.driver.ContextSubmittable; 026import org.apache.reef.driver.TaskSubmittable; 027import org.apache.reef.io.naming.Identifiable; 028import org.apache.reef.tang.Configuration; 029 030import java.io.File; 031import java.io.IOException; 032 033/** 034 * Represents an Evaluator that is allocated, but is not running yet. 035 */ 036@Public 037@DriverSide 038@Provided 039public interface AllocatedEvaluator 040 extends AutoCloseable, Identifiable, ContextSubmittable, ContextAndTaskSubmittable, TaskSubmittable { 041 042 /** 043 * Puts the given file into the working directory of the Evaluator. 044 * 045 * @param file the file to be copied 046 * @throws IOException if the copy fails. 047 */ 048 void addFile(final File file); 049 050 /** 051 * Puts the given file into the working directory of the Evaluator and adds it to its classpath. 052 * 053 * @param file the file to be copied 054 * @throws IOException if the copy fails. 055 */ 056 void addLibrary(final File file); 057 058 /** 059 * @return the evaluator descriptor of this evaluator. 060 */ 061 EvaluatorDescriptor getEvaluatorDescriptor(); 062 063 /** 064 * Set the type of Evaluator to be instantiated. Defaults to EvaluatorType.JVM. 065 * 066 * @param type 067 */ 068 void setType(final EvaluatorType type); 069 070 /** 071 * Releases the allocated evaluator back to the resource manager. 072 */ 073 @Override 074 void close(); 075 076 /** 077 * Submits the given Task for execution. 078 * <p/> 079 * This generates a ContextConfiguration for the root context with a generated ID derived from the EvaluatorId. 080 * 081 * @param taskConfiguration the Configuration. See TaskConfiguration for details. 082 */ 083 @Override 084 void submitTask(final Configuration taskConfiguration); 085 086 @Override 087 void submitContext(final Configuration contextConfiguration); 088 089 @Override 090 void submitContextAndService(final Configuration contextConfiguration, 091 final Configuration serviceConfiguration); 092 093 @Override 094 void submitContextAndTask(final Configuration contextConfiguration, 095 final Configuration taskConfiguration); 096 097 @Override 098 void submitContextAndServiceAndTask(final Configuration contextConfiguration, 099 final Configuration serviceConfiguration, 100 final Configuration taskConfiguration); 101}