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.task; 020 021import org.apache.reef.io.network.group.api.operators.Reduce.ReduceFunction; 022import org.apache.reef.io.network.group.impl.GroupCommunicationMessage; 023import org.apache.reef.io.network.group.impl.operators.Sender; 024import org.apache.reef.io.network.proto.ReefNetworkGroupCommProtos; 025import org.apache.reef.io.serialization.Codec; 026import org.apache.reef.tang.annotations.Name; 027 028import java.util.Collection; 029import java.util.Map; 030import java.util.Set; 031 032/** 033 * The actual local topology maintaining the 034 * children and parent that reacts to update 035 * and data msgs. The actual nodes are represented 036 * by NodeStruct and it handles receiving and 037 * providing data 038 */ 039public interface OperatorTopologyStruct { 040 041 Class<? extends Name<String>> getGroupName(); 042 043 Class<? extends Name<String>> getOperName(); 044 045 String getSelfId(); 046 047 int getVersion(); 048 049 NodeStruct getParent(); 050 051 Collection<? extends NodeStruct> getChildren(); 052 053 String getDriverId(); 054 055 Sender getSender(); 056 057 boolean hasChanges(); 058 059 void setChanges(boolean b); 060 061 void addAsData(GroupCommunicationMessage msg); 062 063 void update(Set<GroupCommunicationMessage> deletionDeltas); 064 065 void update(GroupCommunicationMessage msg); 066 067 void sendToParent(byte[] data, ReefNetworkGroupCommProtos.GroupCommMessage.Type msgType); 068 069 byte[] recvFromParent(ReefNetworkGroupCommProtos.GroupCommMessage.Type msgType); 070 071 void sendToChildren(byte[] data, ReefNetworkGroupCommProtos.GroupCommMessage.Type msgType); 072 073 void sendToChildren(Map<String, byte[]> dataMap, ReefNetworkGroupCommProtos.GroupCommMessage.Type msgType); 074 075 <T> T recvFromChildren(ReduceFunction<T> redFunc, Codec<T> dataCodec); 076 077 byte[] recvFromChildren(); 078}