Search in sources :

Example 1 with TcpAddress

use of net.dempsy.transport.tcp.TcpAddress in project Dempsy by Dempsy.

the class NioSenderFactory method getSender.

@Override
public NioSender getSender(final NodeAddress destination) throws MessageTransportException {
    final TcpAddress tcpaddr = (TcpAddress) destination;
    final NioSender ret;
    if (isRunning.get()) {
        ret = senders.computeIfAbsent(tcpaddr, a -> new NioSender(a, this));
    } else
        throw new MessageTransportException(nodeId + " sender had getSender called while stopped.");
    try {
        ret.connect(false);
    } catch (final IOException e) {
        throw new MessageTransportException(nodeId + " sender failed to connect to " + destination, e);
    }
    return ret;
}
Also used : TcpAddress(net.dempsy.transport.tcp.TcpAddress) Arrays(java.util.Arrays) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) NioUtils.dontInterrupt(net.dempsy.transport.tcp.nio.internal.NioUtils.dontInterrupt) SelectionKey(java.nio.channels.SelectionKey) NodeAddress(net.dempsy.transport.NodeAddress) Selector(java.nio.channels.Selector) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LoggerFactory(org.slf4j.LoggerFactory) SenderFactory(net.dempsy.transport.SenderFactory) Set(java.util.Set) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IOException(java.io.IOException) ArrayList(java.util.ArrayList) Serializer(net.dempsy.serialization.Serializer) NodeStatsCollector(net.dempsy.monitoring.NodeStatsCollector) List(java.util.List) Infrastructure(net.dempsy.Infrastructure) Functional.chain(net.dempsy.util.Functional.chain) Map(java.util.Map) Manager(net.dempsy.Manager) NioUtils(net.dempsy.transport.tcp.nio.internal.NioUtils) MessageTransportException(net.dempsy.transport.MessageTransportException) TcpAddress(net.dempsy.transport.tcp.TcpAddress) MessageTransportException(net.dempsy.transport.MessageTransportException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 SelectionKey (java.nio.channels.SelectionKey)1 Selector (java.nio.channels.Selector)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Infrastructure (net.dempsy.Infrastructure)1 Manager (net.dempsy.Manager)1 NodeStatsCollector (net.dempsy.monitoring.NodeStatsCollector)1 Serializer (net.dempsy.serialization.Serializer)1 MessageTransportException (net.dempsy.transport.MessageTransportException)1 NodeAddress (net.dempsy.transport.NodeAddress)1 SenderFactory (net.dempsy.transport.SenderFactory)1 TcpAddress (net.dempsy.transport.tcp.TcpAddress)1 NioUtils (net.dempsy.transport.tcp.nio.internal.NioUtils)1