org.apache.reef.wake.Identifier Java Examples
The following examples show how to use
org.apache.reef.wake.Identifier.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestUtils.java From reef with Apache License 2.0 | 6 votes |
public static ReefNetworkGroupCommProtos.GroupCommMessage bldGCM( final ReefNetworkGroupCommProtos.GroupCommMessage.Type msgType, final Identifier from, final Identifier to, final byte[]... elements) { final ReefNetworkGroupCommProtos.GroupCommMessage.Builder gcmBuilder = ReefNetworkGroupCommProtos.GroupCommMessage.newBuilder(); gcmBuilder.setType(msgType); gcmBuilder.setSrcid(from.toString()); gcmBuilder.setDestid(to.toString()); final ReefNetworkGroupCommProtos.GroupMessageBody.Builder bodyBuilder = ReefNetworkGroupCommProtos.GroupMessageBody.newBuilder(); for (final byte[] element : elements) { bodyBuilder.setData(ByteString.copyFrom(element)); gcmBuilder.addMsgs(bodyBuilder.build()); } final ReefNetworkGroupCommProtos.GroupCommMessage msg = gcmBuilder.build(); return msg; }
Example #2
Source File: RemoteIdentifierFactoryTest.java From reef with Apache License 2.0 | 6 votes |
@Test public void testRemoteManagerIdentifier() throws Exception { final RemoteManagerFactory remoteManagerFactory = Tang.Factory.getTang().newInjector() .getInstance(RemoteManagerFactory.class); final Map<Class<?>, Codec<?>> clazzToCodecMap = new HashMap<>(); clazzToCodecMap.put(TestEvent.class, new TestEventCodec()); final Codec<?> codec = new MultiCodec<Object>(clazzToCodecMap); try (RemoteManager rm = remoteManagerFactory.getInstance("TestRemoteManager", 0, codec, new LoggingEventHandler<Throwable>())) { final RemoteIdentifier id = rm.getMyIdentifier(); final IdentifierFactory factory = new DefaultIdentifierFactory(); final Identifier newId = factory.getNewInstance(id.toString()); Assert.assertEquals(id, newId); } }
Example #3
Source File: NetworkConnectionServiceImpl.java From reef with Apache License 2.0 | 6 votes |
@Override public <T> ConnectionFactory<T> registerConnectionFactory( final Identifier connectionFactoryId, final Codec<T> codec, final EventHandler<Message<T>> eventHandler, final LinkListener<Message<T>> linkListener, final Identifier localEndPointId) { final String id = connectionFactoryId.toString(); checkBeforeRegistration(id); final NetworkConnectionFactory<T> connectionFactory = new NetworkConnectionFactory<>( this, connectionFactoryId, codec, eventHandler, linkListener, localEndPointId); final Identifier localId = getEndPointIdWithConnectionFactoryId(connectionFactoryId, localEndPointId); nameServiceRegisteringStage.onNext(new Tuple<>(localId, (InetSocketAddress) transport.getLocalAddress())); if (connFactoryMap.putIfAbsent(id, connectionFactory) != null) { throw new NetworkRuntimeException("ConnectionFactory " + connectionFactoryId + " was already registered."); } LOG.log(Level.INFO, "ConnectionFactory {0} was registered", id); return connectionFactory; }
Example #4
Source File: ScatterSender.java From reef with Apache License 2.0 | 6 votes |
@Inject public ScatterSender(@Parameter(CommunicationGroupName.class) final String groupName, @Parameter(OperatorName.class) final String operName, @Parameter(TaskConfigurationOptions.Identifier.class) final String selfId, @Parameter(DataCodec.class) final Codec<T> dataCodec, @Parameter(DriverIdentifierGroupComm.class) final String driverId, @Parameter(TaskVersion.class) final int version, final CommGroupNetworkHandler commGroupNetworkHandler, final NetworkService<GroupCommunicationMessage> netService, final CommunicationGroupServiceClient commGroupClient, final ScatterEncoder scatterEncoder) { LOG.finest(operName + "has CommGroupHandler-" + commGroupNetworkHandler.toString()); this.version = version; this.groupName = Utils.getClass(groupName); this.operName = Utils.getClass(operName); this.dataCodec = dataCodec; this.scatterEncoder = scatterEncoder; this.topology = new OperatorTopologyImpl(this.groupName, this.operName, selfId, driverId, new Sender(netService), version); this.commGroupClient = commGroupClient; commGroupNetworkHandler.register(this.operName, this); }
Example #5
Source File: Utils.java From reef with Apache License 2.0 | 6 votes |
public static ReefNetworkGroupCommProtos.GroupCommMessage bldGCM( final ReefNetworkGroupCommProtos.GroupCommMessage.Type msgType, final Identifier from, final Identifier to, final byte[]... elements) { final ReefNetworkGroupCommProtos.GroupCommMessage.Builder gcmBuilder = ReefNetworkGroupCommProtos.GroupCommMessage.newBuilder() .setType(msgType) .setSrcid(from.toString()) .setDestid(to.toString()); final ReefNetworkGroupCommProtos.GroupMessageBody.Builder bodyBuilder = ReefNetworkGroupCommProtos.GroupMessageBody.newBuilder(); for (final byte[] element : elements) { bodyBuilder.setData(ByteString.copyFrom(element)); gcmBuilder.addMsgs(bodyBuilder.build()); } return gcmBuilder.build(); }
Example #6
Source File: ReduceReceiver.java From reef with Apache License 2.0 | 6 votes |
@Inject public ReduceReceiver(@Parameter(CommunicationGroupName.class) final String groupName, @Parameter(OperatorName.class) final String operName, @Parameter(TaskConfigurationOptions.Identifier.class) final String selfId, @Parameter(DataCodec.class) final Codec<T> dataCodec, @Parameter(ReduceFunctionParam.class) final ReduceFunction<T> reduceFunction, @Parameter(DriverIdentifierGroupComm.class) final String driverId, @Parameter(TaskVersion.class) final int version, final CommGroupNetworkHandler commGroupNetworkHandler, final NetworkService<GroupCommunicationMessage> netService, final CommunicationGroupServiceClient commGroupClient) { super(); this.version = version; LOG.finest(operName + " has CommGroupHandler-" + commGroupNetworkHandler.toString()); this.groupName = Utils.getClass(groupName); this.operName = Utils.getClass(operName); this.dataCodec = dataCodec; this.reduceFunction = reduceFunction; this.commGroupNetworkHandler = commGroupNetworkHandler; this.netService = netService; this.sender = new Sender(this.netService); this.topology = new OperatorTopologyImpl(this.groupName, this.operName, selfId, driverId, sender, version); this.commGroupNetworkHandler.register(this.operName, this); this.commGroupClient = commGroupClient; }
Example #7
Source File: GatherReceiver.java From reef with Apache License 2.0 | 6 votes |
@Inject public GatherReceiver(@Parameter(CommunicationGroupName.class) final String groupName, @Parameter(OperatorName.class) final String operName, @Parameter(TaskConfigurationOptions.Identifier.class) final String selfId, @Parameter(DataCodec.class) final Codec<T> dataCodec, @Parameter(DriverIdentifierGroupComm.class) final String driverId, @Parameter(TaskVersion.class) final int version, final CommGroupNetworkHandler commGroupNetworkHandler, final NetworkService<GroupCommunicationMessage> netService, final CommunicationGroupServiceClient commGroupClient) { LOG.finest(operName + " has CommGroupHandler-" + commGroupNetworkHandler.toString()); this.version = version; this.groupName = Utils.getClass(groupName); this.operName = Utils.getClass(operName); this.dataCodec = dataCodec; this.topology = new OperatorTopologyImpl(this.groupName, this.operName, selfId, driverId, new Sender(netService), version); this.commGroupClient = commGroupClient; commGroupNetworkHandler.register(this.operName, this); }
Example #8
Source File: GatherReceiver.java From reef with Apache License 2.0 | 6 votes |
@Override public List<T> receive(final List<? extends Identifier> order) throws NetworkException, InterruptedException { LOG.entering("GatherReceiver", "receive"); final Map<String, T> mapOfTaskIdToData = receiveMapOfTaskIdToData(); LOG.log(Level.FINE, "{0} Sorting data according to specified order of task identifiers.", this); final List<T> retList = new LinkedList<>(); for (final Identifier key : order) { final String keyString = key.toString(); if (mapOfTaskIdToData.containsKey(keyString)) { retList.add(mapOfTaskIdToData.get(key.toString())); } else { LOG.warning(this + " Received no data from " + keyString + ". Adding null."); retList.add(null); } } LOG.exiting("GatherReceiver", "receive"); return retList; }
Example #9
Source File: CommunicationGroupClientImpl.java From reef with Apache License 2.0 | 6 votes |
private void updateActiveTasks(final GroupCommunicationMessage msg) { LOG.entering("CommunicationGroupClientImpl", "updateActiveTasks", new Object[]{getQualifiedName(), msg}); final Pair<TopologySimpleNode, List<Identifier>> pair = TopologySerializer.decode(msg.getData()[0], identifierFactory); topologySimpleNodeRoot = pair.getFirst(); activeSlaveTasks = pair.getSecond(); // remove myself activeSlaveTasks.remove(identifierFactory.getNewInstance(taskId)); // sort the tasks in lexicographical order on task ids Collections.sort(activeSlaveTasks, new Comparator<Identifier>() { @Override public int compare(final Identifier o1, final Identifier o2) { return o1.toString().compareTo(o2.toString()); } }); LOG.exiting("CommunicationGroupClientImpl", "updateActiveTasks", new Object[]{getQualifiedName(), msg}); }
Example #10
Source File: TopologySerializer.java From reef with Apache License 2.0 | 5 votes |
/** * Recursively translate a byte array into a TopologySimpleNode and a list of task Identifiers. * * @param data encoded byte array * @param ifac IdentifierFactory needed to generate Identifiers from String Ids * @return decoded TopologySimpleNode and a lexicographically sorted list of task Identifiers */ public static Pair<TopologySimpleNode, List<Identifier>> decode( final byte[] data, final IdentifierFactory ifac) { try (DataInputStream dstream = new DataInputStream(new ByteArrayInputStream(data))) { final List<Identifier> activeSlaveTasks = new LinkedList<>(); final TopologySimpleNode retNode = decodeHelper(dstream, activeSlaveTasks, ifac); return new Pair<>(retNode, activeSlaveTasks); } catch (final IOException e) { throw new RuntimeException("Exception while decoding message", e); } }
Example #11
Source File: ScatterEncoder.java From reef with Apache License 2.0 | 5 votes |
/** * Encode elements into byte arrays, and distribute them across Tasks indicated by Identifiers. * Note that elements are distributed in the exact order specified in * {@code elements} and not in a round-robin fashion. * For example, (1, 2, 3, 4) uniformly distributed to (task1, task2, task3) would be * {task1: (1, 2), task2: (3), task3: (4)}. * * @param elements list of data elements to encode * @param counts list of numbers specifying how many elements each Task should receive * @param taskOrder list of Identifiers indicating Task Ids * @param codec class for encoding data * @param <T> type of data * @return byte representation of a map of identifiers to encoded data */ private <T> Map<String, byte[]> encodeAndDistributeElements(final List<T> elements, final List<Integer> counts, final List<? extends Identifier> taskOrder, final Codec<T> codec) { final Map<String, byte[]> taskIdToBytes = new HashMap<>(); int elementsIndex = 0; for (int taskOrderIndex = 0; taskOrderIndex < taskOrder.size(); taskOrderIndex++) { final int elementCount = counts.get(taskOrderIndex); try (ByteArrayOutputStream bstream = new ByteArrayOutputStream(); DataOutputStream dstream = new DataOutputStream(bstream)) { dstream.writeInt(elementCount); for (final T element : elements.subList(elementsIndex, elementsIndex + elementCount)) { final byte[] encodedElement = codec.encode(element); dstream.writeInt(encodedElement.length); dstream.write(encodedElement); } taskIdToBytes.put(taskOrder.get(taskOrderIndex).toString(), bstream.toByteArray()); } catch (final IOException e) { throw new RuntimeException("IOException", e); } elementsIndex += elementCount; } return taskIdToBytes; }
Example #12
Source File: ScatterEncoder.java From reef with Apache License 2.0 | 5 votes |
public <T> Map<String, byte[]> encode(final List<T> elements, final List<Integer> counts, final List<? extends Identifier> taskOrder, final Codec<T> dataCodec) { // first assign data to all tasks final Map<String, byte[]> taskIdToBytes = encodeAndDistributeElements(elements, counts, taskOrder, dataCodec); // then organize the data so that a node keeps its own data as well as its descendants' data final Map<String, byte[]> childIdToBytes = new HashMap<>(); for (final TopologySimpleNode node : commGroupClient.getTopologySimpleNodeRoot().getChildren()) { childIdToBytes.put(node.getTaskId(), encodeScatterMsgForNode(node, taskIdToBytes)); } return childIdToBytes; }
Example #13
Source File: NetworkConnection.java From reef with Apache License 2.0 | 5 votes |
/** * Constructs a connection for destination identifier of NetworkConnectionService. * @param connFactory a connection factory of this connection. * @param destId a destination identifier of NetworkConnectionService. */ NetworkConnection( final NetworkConnectionFactory<T> connFactory, final Identifier destId) { this.connFactory = connFactory; this.destId = destId; this.closed = new AtomicBoolean(); }
Example #14
Source File: NetworkMessagingTestService.java From reef with Apache License 2.0 | 5 votes |
public MessageHandler(final Monitor monitor, final int expected, final Identifier expectedSrcId, final Identifier expectedDestId) { this.monitor = monitor; this.expected = expected; this.expectedSrcId = expectedSrcId; this.expectedDestId = expectedDestId; }
Example #15
Source File: NameRegistryClient.java From reef with Apache License 2.0 | 5 votes |
/** * Unregisters an identifier. * * @param id an identifier */ @Override public void unregister(final Identifier id) throws IOException { final Link<NamingMessage> link = transport.open(serverSocketAddr, codec, new LoggingLinkListener<NamingMessage>()); link.write(new NamingUnregisterRequest(id)); }
Example #16
Source File: NetworkConnectionServiceImpl.java From reef with Apache License 2.0 | 5 votes |
/** * Open a channel for destination identifier of NetworkConnectionService. * @param connectionFactoryId * @param remoteEndPointId * @throws NetworkException */ <T> Link<NetworkConnectionServiceMessage<T>> openLink( final Identifier connectionFactoryId, final Identifier remoteEndPointId) throws NetworkException { final Identifier remoteId = getEndPointIdWithConnectionFactoryId(connectionFactoryId, remoteEndPointId); try { final SocketAddress address = nameResolver.lookup(remoteId); if (address == null) { throw new NetworkException("Lookup " + remoteId + " is null"); } return transport.open(address, nsCodec, nsLinkListener); } catch(final Exception e) { throw new NetworkException(e); } }
Example #17
Source File: CtrlMsgSender.java From reef with Apache License 2.0 | 5 votes |
@Override public void onNext(final GroupCommunicationMessage srcCtrlMsg) { LOG.entering("CtrlMsgSender", "onNext", srcCtrlMsg); final Identifier id = idFac.getNewInstance(srcCtrlMsg.getDestid()); final Connection<GroupCommunicationMessage> link = netService.newConnection(id); try { link.open(); link.write(srcCtrlMsg); } catch (final NetworkException e) { throw new RuntimeException("Unable to send ctrl task msg to parent " + id, e); } LOG.exiting("CtrlMsgSender", "onNext", srcCtrlMsg); }
Example #18
Source File: NameServerImpl.java From reef with Apache License 2.0 | 5 votes |
/** * @param port a listening port number * @param factory an identifier factory * @param localAddressProvider a local address provider * Constructs a name server */ @Inject private NameServerImpl( @Parameter(RemoteConfiguration.HostAddress.class) final String hostAddress, @Parameter(NameServerParameters.NameServerPort.class) final int port, @Parameter(NameServerParameters.NameServerIdentifierFactory.class) final IdentifierFactory factory, final TcpPortProvider portProvider, final LocalAddressProvider localAddressProvider) { final Injector injector = Tang.Factory.getTang().newInjector(); this.localAddressProvider = localAddressProvider; this.reefEventStateManager = null; final Codec<NamingMessage> codec = NamingCodecFactory.createFullCodec(factory); final EventHandler<NamingMessage> handler = createEventHandler(codec); String host = UNKNOWN_HOST_NAME.equals(hostAddress) ? localAddressProvider.getLocalAddress() : hostAddress; injector.bindVolatileParameter(RemoteConfiguration.HostAddress.class, host); injector.bindVolatileParameter(RemoteConfiguration.Port.class, port); injector.bindVolatileInstance(TcpPortProvider.class, portProvider); injector.bindVolatileParameter(RemoteConfiguration.RemoteServerStage.class, new SyncStage<>(new NamingServerHandler(handler, codec))); try { this.transport = injector.getInstance(NettyMessagingTransport.class); } catch (final InjectionException e) { throw new RuntimeException(e); } this.port = transport.getListeningPort(); this.idToAddrMap = Collections.synchronizedMap(new HashMap<Identifier, InetSocketAddress>()); LOG.log(Level.FINE, "NameServer starting, listening at port {0}", this.port); }
Example #19
Source File: NameLookupClient.java From reef with Apache License 2.0 | 5 votes |
/** * Retrieves an address for an identifier remotely. * * @param id an identifier * @return an Internet socket address * @throws Exception */ public InetSocketAddress remoteLookup(final Identifier id) throws Exception { // the lookup is not thread-safe, because concurrent replies may // be read by the wrong thread. // TODO: better fix uses a map of id's after REEF-198 synchronized (this) { LOG.log(Level.INFO, "Looking up {0} on NameServer {1}", new Object[]{id, serverSocketAddr}); final List<Identifier> ids = Arrays.asList(id); final Link<NamingMessage> link = transport.open(serverSocketAddr, codec, new LoggingLinkListener<NamingMessage>()); link.write(new NamingLookupRequest(ids)); final NamingLookupResponse resp; for (;;) { try { resp = replyQueue.poll(timeout, TimeUnit.MILLISECONDS); break; } catch (final InterruptedException e) { LOG.log(Level.INFO, "Lookup interrupted", e); throw new NamingException(e); } } final List<NameAssignment> list = resp == null ? Collections.<NameAssignment>emptyList() : resp.getNameAssignments(); if (list.isEmpty()) { throw new NamingException("Cannot find " + id + " from the name server"); } else { return list.get(0).getAddress(); } } }
Example #20
Source File: ScatterSender.java From reef with Apache License 2.0 | 5 votes |
@Override public void send(final List<T> elements, final List<Integer> counts, final List<? extends Identifier> order) throws NetworkException, InterruptedException { LOG.entering("ScatterSender", "send"); if (counts.size() != order.size()) { throw new RuntimeException("Parameter 'counts' has size " + counts.size() + ", but parameter 'order' has size " + order.size() + "."); } initializeGroup(); // I am root. LOG.fine("I am " + this); LOG.fine(this + " Encoding data and determining which Tasks receive which elements."); final Map<String, byte[]> mapOfChildIdToBytes = scatterEncoder.encode(elements, counts, order, dataCodec); try { LOG.fine(this + " Sending " + elements.size() + " elements."); topology.sendToChildren(mapOfChildIdToBytes, ReefNetworkGroupCommProtos.GroupCommMessage.Type.Scatter); } catch (final ParentDeadException e) { throw new RuntimeException("ParentDeadException during OperatorTopology.sendToChildren()", e); } LOG.exiting("ScatterSender", "send"); }
Example #21
Source File: NetworkConnectionServiceImpl.java From reef with Apache License 2.0 | 5 votes |
/** * Gets a ConnectionFactory. * @param connFactoryId the identifier of the ConnectionFactory */ @Override public <T> ConnectionFactory<T> getConnectionFactory(final Identifier connFactoryId) { final ConnectionFactory<T> connFactory = connFactoryMap.get(connFactoryId.toString()); if (connFactory == null) { throw new RuntimeException("Cannot find ConnectionFactory of " + connFactoryId + "."); } return connFactory; }
Example #22
Source File: NetworkMessagingTestService.java From reef with Apache License 2.0 | 5 votes |
public <T> void registerTestConnectionFactory(final Identifier connFactoryId, final int numMessages, final Monitor monitor, final Codec<T> codec) throws NetworkException { final Identifier receiverEndPointId = factory.getNewInstance("receiver"); final Identifier senderEndPointId = factory.getNewInstance("sender"); receiverNetworkConnService.registerConnectionFactory(connFactoryId, codec, new MessageHandler<T>(monitor, numMessages, senderEndPointId, receiverEndPointId), new TestListener<T>(), receiverEndPointId); senderNetworkConnService.registerConnectionFactory(connFactoryId, codec, new MessageHandler<T>(monitor, numMessages, receiverEndPointId, senderEndPointId), new TestListener<T>(), senderEndPointId); }
Example #23
Source File: LocalNameResolverImpl.java From reef with Apache License 2.0 | 5 votes |
@Override public InetSocketAddress lookup(final Identifier id) throws Exception { return cache.get(id, new Callable<InetSocketAddress>() { @Override public InetSocketAddress call() throws Exception { final int origRetryCount = LocalNameResolverImpl.this.retryCount; int retriesLeft = origRetryCount; while (true) { try { final InetSocketAddress addr = nameServer.lookup(id); if (addr == null) { throw new NullPointerException("The lookup of the address in the nameServer returned null for id " + id); } else { return addr; } } catch (final NullPointerException e) { if (retriesLeft <= 0) { throw new NamingException("Cannot find " + id + " from the name server", e); } else { final int retTimeout = LocalNameResolverImpl.this.retryTimeout * (origRetryCount - retriesLeft + 1); LOG.log(Level.WARNING, "Caught Naming Exception while looking up " + id + " with Name Server. Will retry " + retriesLeft + " time(s) after waiting for " + retTimeout + " msec."); Thread.sleep(retTimeout); --retriesLeft; } } } } }); }
Example #24
Source File: NSConnection.java From reef with Apache License 2.0 | 5 votes |
/** * Constructs a connection. * * @param srcId a source identifier * @param destId a destination identifier * @param listener a link listener * @param service a network service */ NSConnection(final Identifier srcId, final Identifier destId, final LinkListener<T> listener, final NetworkService<T> service) { this.srcId = srcId; this.destId = destId; this.listener = new NSMessageLinkListener<>(listener); this.service = service; this.codec = new NSMessageCodec<>(service.getCodec(), service.getIdentifierFactory()); }
Example #25
Source File: NameServerImpl.java From reef with Apache License 2.0 | 5 votes |
/** * Finds addresses for identifiers locally. * * @param identifiers an iterable of identifiers * @return a list of name assignments */ @Override public List<NameAssignment> lookup(final Iterable<Identifier> identifiers) { LOG.log(Level.FINE, "identifiers"); final List<NameAssignment> nas = new ArrayList<>(); for (final Identifier id : identifiers) { final InetSocketAddress addr = idToAddrMap.get(id); LOG.log(Level.FINEST, "id : {0} addr: {1}", new Object[]{id, addr}); if (addr != null) { nas.add(new NameAssignmentTuple(id, addr)); } } return nas; }
Example #26
Source File: NamingLookupRequestCodec.java From reef with Apache License 2.0 | 5 votes |
/** * Encodes the identifiers to bytes. * * @param obj the naming lookup request * @return a byte array */ @Override public byte[] encode(final NamingLookupRequest obj) { final List<CharSequence> ids = new ArrayList<>(); for (final Identifier id : obj.getIdentifiers()) { ids.add(id.toString()); } return AvroUtils.toBytes(AvroNamingLookupRequest.newBuilder().setIds(ids).build(), AvroNamingLookupRequest.class); }
Example #27
Source File: NamingLookupRequestCodec.java From reef with Apache License 2.0 | 5 votes |
/** * Decodes the bytes to a naming lookup request. * * @param buf the byte array * @return a naming lookup request */ @Override public NamingLookupRequest decode(final byte[] buf) { final AvroNamingLookupRequest req = AvroUtils.fromBytes(buf, AvroNamingLookupRequest.class); final List<Identifier> ids = new ArrayList<>(req.getIds().size()); for (final CharSequence s : req.getIds()) { ids.add(factory.getNewInstance(s.toString())); } return new NamingLookupRequest(ids); }
Example #28
Source File: UtilsTest.java From reef with Apache License 2.0 | 5 votes |
/** * Generic parseList test. */ @Test public void testParseList() { final IdentifierFactory factory = new StringIdentifierFactory(); final List<Identifier> list1 = Utils.parseList("1,2,3", factory); final List<ComparableIdentifier> list2 = Utils.parseList("1,2,3", factory); }
Example #29
Source File: GrpcMessageClient.java From incubator-nemo with Apache License 2.0 | 5 votes |
/** * Find receiver's ip address using receiverId and the name server, and try to connect to the receiver. * * @throws Exception if it fails to resolve receiver's ip from the name server, or to establish connection using grpc */ void connect() throws Exception { // 1. Look-up destination ip address using receiver id final Identifier identifier = idFactory.getNewInstance(receiverId); final InetSocketAddress ipAddress = nameResolver.lookup(identifier); // 2. Connect to the address setupChannel(ipAddress); }
Example #30
Source File: NetworkConnectionFactory.java From reef with Apache License 2.0 | 5 votes |
NetworkConnectionFactory( final NetworkConnectionServiceImpl networkService, final Identifier connectionFactoryId, final Codec<T> eventCodec, final EventHandler<Message<T>> eventHandler, final LinkListener<Message<T>> eventListener, final Identifier localEndPointId) { this.networkService = networkService; this.connectionMap = new ConcurrentHashMap<>(); this.connectionFactoryId = connectionFactoryId; this.eventCodec = eventCodec; this.eventHandler = eventHandler; this.eventListener = eventListener; this.localEndPointId = localEndPointId; }