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 */ 019 020package org.apache.reef.io.network.naming; 021 022import org.apache.reef.io.naming.NameAssignment; 023import org.apache.reef.io.network.naming.serialization.*; 024import org.apache.reef.tang.annotations.DefaultImplementation; 025import org.apache.reef.tang.annotations.Parameter; 026import org.apache.reef.wake.EventHandler; 027import org.apache.reef.wake.Identifier; 028import org.apache.reef.wake.IdentifierFactory; 029import org.apache.reef.wake.Stage; 030import org.apache.reef.wake.impl.MultiEventHandler; 031import org.apache.reef.wake.impl.SyncStage; 032import org.apache.reef.wake.remote.Codec; 033import org.apache.reef.wake.remote.NetUtils; 034import org.apache.reef.wake.remote.impl.TransportEvent; 035import org.apache.reef.wake.remote.transport.Transport; 036import org.apache.reef.wake.remote.transport.netty.NettyMessagingTransport; 037import org.apache.reef.webserver.AvroReefServiceInfo; 038import org.apache.reef.webserver.ReefEventStateManager; 039 040import javax.inject.Inject; 041import java.io.IOException; 042import java.net.InetSocketAddress; 043import java.util.*; 044import java.util.logging.Level; 045import java.util.logging.Logger; 046 047/** 048 * Naming server interface 049 */ 050public interface NameServer extends Stage { 051 052 /** 053 * get port number 054 * @return 055 */ 056 public int getPort(); 057 058 /** 059 * Registers an (identifier, address) mapping locally 060 * 061 * @param id an identifier 062 * @param addr an Internet socket address 063 */ 064 public void register(final Identifier id, final InetSocketAddress addr); 065 066 /** 067 * Unregisters an identifier locally 068 * 069 * @param id an identifier 070 */ 071 public void unregister(final Identifier id); 072 073 /** 074 * Finds an address for an identifier locally 075 * 076 * @param id an identifier 077 * @return an Internet socket address 078 */ 079 public InetSocketAddress lookup(final Identifier id); 080 081 /** 082 * Finds addresses for identifiers locally 083 * 084 * @param identifiers an Iterable of identifiers 085 * @return a list of name assignments 086 */ 087 public List<NameAssignment> lookup(final Iterable<Identifier> identifiers); 088}