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.network.group.api.driver; 020 021import org.apache.reef.annotations.Provided; 022import org.apache.reef.annotations.audience.DriverSide; 023import org.apache.reef.driver.context.ActiveContext; 024import org.apache.reef.io.network.group.impl.driver.GroupCommDriverImpl; 025import org.apache.reef.tang.Configuration; 026import org.apache.reef.tang.annotations.DefaultImplementation; 027import org.apache.reef.tang.annotations.Name; 028 029/** 030 * The driver side interface of Group Communication. 031 * which is the entry point for the service 032 */ 033@DriverSide 034@Provided 035@DefaultImplementation(value = GroupCommDriverImpl.class) 036public interface GroupCommDriver { 037 038 /** 039 * Create a new communication group with the specified name. 040 * and the minimum number of tasks needed in this group before 041 * communication can start 042 * 043 * @param groupName 044 * @param numberOfTasks 045 * @return 046 */ 047 CommunicationGroupDriver newCommunicationGroup(Class<? extends Name<String>> groupName, int numberOfTasks); 048 049 /** 050 * Create a new communication group with the specified name, 051 * the minimum number of tasks needed in this group before 052 * communication can start, and a custom fanOut. 053 * 054 * @param groupName 055 * @param numberOfTasks 056 * @param customFanOut 057 * @return 058 */ 059 CommunicationGroupDriver newCommunicationGroup(Class<? extends Name<String>> groupName, int numberOfTasks, 060 int customFanOut); 061 062 /** 063 * Create a new communication group with the specified name, topology implementation, 064 * the minimum number of tasks needed in this group before 065 * communication can start, and a custom fanOut. 066 * 067 * @param groupName 068 * @param topologyClass 069 * @param numberOfTasks 070 * @param customFanOut 071 * @return 072 */ 073 CommunicationGroupDriver newCommunicationGroup(Class<? extends Name<String>> groupName, 074 Class<? extends Topology> topologyClass, 075 int numberOfTasks, 076 int customFanOut); 077 078 /** 079 * Tests whether the activeContext is a context configured. 080 * using the Group Communication Service 081 * 082 * @param activeContext 083 * @return 084 */ 085 boolean isConfigured(ActiveContext activeContext); 086 087 /** 088 * @return Configuration needed for a Context that should have 089 * Group Communication Service enabled 090 */ 091 Configuration getContextConfiguration(); 092 093 /** 094 * @return Configuration needed to enable 095 * Group Communication as a Service 096 */ 097 Configuration getServiceConfiguration(); 098 099 /** 100 * @return Configuration needed for a Task that should have 101 * Group Communication Service enabled 102 */ 103 Configuration getTaskConfiguration(Configuration partialTaskConf); 104 105}