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.io.data.loading.api; 020 021import org.apache.hadoop.mapred.InputSplit; 022import org.apache.reef.annotations.Unstable; 023import org.apache.reef.annotations.audience.DriverSide; 024import org.apache.reef.driver.catalog.NodeDescriptor; 025import org.apache.reef.io.data.loading.impl.NumberedSplit; 026 027/** 028 * Interface that tracks the mapping between evaluators and the data partitions 029 * assigned to those evaluators. Its part of the implementation of a 030 * {@link org.apache.reef.io.data.loading.api.DataLoadingService} that uses the 031 * Hadoop {@link org.apache.hadoop.mapred.InputFormat} to partition the data and 032 * request resources accordingly 033 * 034 * @param <V> 035 */ 036@DriverSide 037@Unstable 038public interface EvaluatorToPartitionStrategy<V extends InputSplit> { 039 040 /** 041 * Returns an input split for the given evaluator. 042 * @param nodeDescriptor 043 * the node descriptor where the evaluator is running on 044 * @param evalId 045 * the evaluator id 046 * @return 047 * the numberedSplit 048 * @throws RuntimeException if no split could be allocated 049 */ 050 NumberedSplit<V> getInputSplit(NodeDescriptor nodeDescriptor, String evalId); 051 052 /** 053 * Returns the total number of splits computed in this strategy. 054 * @return 055 * the number of splits 056 */ 057 int getNumberOfSplits(); 058 059}