Search in sources :

Example 1 with InetSocketAddress

use of java.net.InetSocketAddress in project camel by apache.

the class AvroNettyConsumerTest method initializeTranceiver.

@Override
protected void initializeTranceiver() throws IOException {
    transceiver = new NettyTransceiver(new InetSocketAddress("localhost", avroPort));
    requestor = new SpecificRequestor(KeyValueProtocol.class, transceiver);
    transceiverMessageInRoute = new NettyTransceiver(new InetSocketAddress("localhost", avroPortMessageInRoute));
    requestorMessageInRoute = new SpecificRequestor(KeyValueProtocol.class, transceiverMessageInRoute);
    transceiverForWrongMessages = new NettyTransceiver(new InetSocketAddress("localhost", avroPortForWrongMessages));
    requestorForWrongMessages = new SpecificRequestor(KeyValueProtocol.class, transceiverForWrongMessages);
    reflectTransceiver = new NettyTransceiver(new InetSocketAddress("localhost", avroPortReflection));
    reflectRequestor = new ReflectRequestor(TestReflection.class, reflectTransceiver);
}
Also used : NettyTransceiver(org.apache.avro.ipc.NettyTransceiver) SpecificRequestor(org.apache.avro.ipc.specific.SpecificRequestor) InetSocketAddress(java.net.InetSocketAddress) ReflectRequestor(org.apache.avro.ipc.reflect.ReflectRequestor) TestReflection(org.apache.camel.avro.test.TestReflection) KeyValueProtocol(org.apache.camel.avro.generated.KeyValueProtocol)

Example 2 with InetSocketAddress

use of java.net.InetSocketAddress in project camel by apache.

the class AvroNettyProducerTest method initializeServer.

@Override
protected void initializeServer() {
    if (server == null) {
        server = new NettyServer(new SpecificResponder(KeyValueProtocol.PROTOCOL, keyValue), new InetSocketAddress("localhost", avroPort));
        server.start();
    }
    if (serverReflection == null) {
        serverReflection = new NettyServer(new ReflectResponder(TestReflection.class, testReflection), new InetSocketAddress("localhost", avroPortReflection));
        serverReflection.start();
    }
}
Also used : SpecificResponder(org.apache.avro.ipc.specific.SpecificResponder) InetSocketAddress(java.net.InetSocketAddress) NettyServer(org.apache.avro.ipc.NettyServer) ReflectResponder(org.apache.avro.ipc.reflect.ReflectResponder)

Example 3 with InetSocketAddress

use of java.net.InetSocketAddress in project camel by apache.

the class HazelcastInstanceConsumerTest method testRemoveInstance.

@Test
public void testRemoveInstance() throws InterruptedException {
    MockEndpoint removed = getMockEndpoint("mock:removed");
    removed.setExpectedMessageCount(1);
    when(member.getSocketAddress()).thenReturn(new InetSocketAddress("foo.bar", 12345));
    MembershipEvent event = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_REMOVED, null);
    argument.getValue().memberRemoved(event);
    assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
    // check headers
    Exchange ex = removed.getExchanges().get(0);
    Map<String, Object> headers = ex.getIn().getHeaders();
    this.checkHeaders(headers, HazelcastConstants.REMOVED);
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) InetSocketAddress(java.net.InetSocketAddress) MembershipEvent(com.hazelcast.core.MembershipEvent) Test(org.junit.Test)

Example 4 with InetSocketAddress

use of java.net.InetSocketAddress in project camel by apache.

the class HazelcastInstanceConsumerTest method testAddInstance.

@Test
public void testAddInstance() throws InterruptedException {
    MockEndpoint added = getMockEndpoint("mock:added");
    added.setExpectedMessageCount(1);
    when(member.getSocketAddress()).thenReturn(new InetSocketAddress("foo.bar", 12345));
    MembershipEvent event = new MembershipEvent(cluster, member, MembershipEvent.MEMBER_ADDED, null);
    argument.getValue().memberAdded(event);
    assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
    // check headers
    Exchange ex = added.getExchanges().get(0);
    Map<String, Object> headers = ex.getIn().getHeaders();
    this.checkHeaders(headers, HazelcastConstants.ADDED);
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) InetSocketAddress(java.net.InetSocketAddress) MembershipEvent(com.hazelcast.core.MembershipEvent) Test(org.junit.Test)

Example 5 with InetSocketAddress

use of java.net.InetSocketAddress in project camel by apache.

the class KestrelConfiguration method getInetSocketAddresses.

public List<InetSocketAddress> getInetSocketAddresses() {
    List<InetSocketAddress> list = new ArrayList<InetSocketAddress>();
    for (String address : addresses) {
        String[] tok = address.split(":");
        String host;
        int port;
        if (tok.length == 2) {
            host = tok[0];
            port = Integer.parseInt(tok[1]);
        } else if (tok.length == 1) {
            host = tok[0];
            port = DEFAULT_KESTREL_PORT;
        } else {
            throw new IllegalArgumentException("Invalid address: " + address);
        }
        list.add(new InetSocketAddress(host, port));
    }
    return list;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList)

Aggregations

InetSocketAddress (java.net.InetSocketAddress)2586 Test (org.junit.Test)595 IOException (java.io.IOException)592 Socket (java.net.Socket)345 InetAddress (java.net.InetAddress)242 SocketAddress (java.net.SocketAddress)176 ServerSocket (java.net.ServerSocket)170 ArrayList (java.util.ArrayList)168 Configuration (org.apache.hadoop.conf.Configuration)140 ByteBuffer (java.nio.ByteBuffer)129 UnknownHostException (java.net.UnknownHostException)122 InputStream (java.io.InputStream)102 OutputStream (java.io.OutputStream)101 SocketChannel (java.nio.channels.SocketChannel)101 SocketException (java.net.SocketException)89 File (java.io.File)88 HashMap (java.util.HashMap)78 URI (java.net.URI)72 Proxy (java.net.Proxy)65 SocketTimeoutException (java.net.SocketTimeoutException)65