Example usage for java.net InetSocketAddress InetSocketAddress

List of usage examples for java.net InetSocketAddress InetSocketAddress

Introduction

In this page you can find the example usage for java.net InetSocketAddress InetSocketAddress.

Prototype

public InetSocketAddress(int port) 

Source Link

Document

Creates a socket address where the IP address is the wildcard address and the port number a specified value.

Usage

From source file:com.yahoo.storm.yarn.EmbeddedZKServer.java

void start() throws IOException, InterruptedException {
    LOG.info("Starting up embedded Zookeeper server");
    File localfile = new File("./target/zookeeper.data");
    ZooKeeperServer zkServer;/*w w  w  . ja  va2 s.c o  m*/
    zkServer = new ZooKeeperServer(localfile, localfile, 2000);
    for (zkport = 60000; true; zkport++)
        try {
            zkFactory = new Factory(new InetSocketAddress(zkport));
            break;
        } catch (BindException e) {
            if (zkport == 65535)
                throw new IOException("Fail to find a port for Zookeeper server to bind");
        }
    LOG.info("Zookeeper port allocated:" + zkport);
    zkFactory.startup(zkServer);
}

From source file:com.fusesource.test.http.HttpServerInterceptor.java

public HttpServerInterceptor(Class testClass) {
    Validate.notNull(testClass, "testClass is null");
    this.testClass = testClass;
    try {/*  w  w w  . ja v  a2s . c o m*/
        httpServer = HttpServer.create(new InetSocketAddress(0), 0); // automatically assigns a free port
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.ecarinfo.frame.httpserver.core.http.ECHttpServer.java

public void run() {
    ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
            Executors.newCachedThreadPool(), Executors.newCachedThreadPool()));

    bootstrap.setOption("child.tcpNoDelay", true);

    bootstrap.setPipelineFactory(new ECHttpServerPipelineFactory(spring));

    bootstrap.bind(new InetSocketAddress(port));
}

From source file:com.appdirect.sdk.support.FakeAppmarket.java

public static FakeAppmarket create(int port, String isvKey, String isvSecret) throws IOException {
    HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
    return new FakeAppmarket(server, isvKey, isvSecret);
}

From source file:com.linkedin.pinot.common.utils.FileUploadDownloadClientTest.java

@BeforeClass
public void setUp() throws Exception {
    TEST_SERVER = HttpServer.create(new InetSocketAddress(TEST_PORT), 0);
    TEST_SERVER.createContext("/segments", new testSegmentUploadHandler());
    TEST_SERVER.setExecutor(null); // creates a default executor
    TEST_SERVER.start();/*from  w w  w.j  a va  2 s  . com*/
}

From source file:edu.berkeley.sparrow.daemon.util.TestThriftClientPool.java

/** Test a very common scenario where we make two thrift function calls to the same
    node in rapid succession. This test ensures that a single client is created and 
    used for both calls. *///from   w w  w .  jav  a 2 s.c om
@Test
public void ensureConnectionReUsed() throws Exception {
    InetSocketAddress sock = new InetSocketAddress(12345);
    ThriftClientPool<TAsyncClient> pool = new ThriftClientPool<TAsyncClient>(new MockedMakerFactory());
    assertEquals(0, pool.getNumIdle(sock));
    assertEquals(0, pool.getNumActive(sock));

    TAsyncClient client1 = pool.borrowClient(sock);

    assertEquals(0, pool.getNumIdle(sock));
    assertEquals(1, pool.getNumActive(sock));

    pool.returnClient(sock, client1);

    assertEquals(1, pool.getNumIdle(sock));
    assertEquals(0, pool.getNumActive(sock));

    TAsyncClient client2 = pool.borrowClient(sock);

    assertEquals(0, pool.getNumIdle(sock));
    assertEquals(1, pool.getNumActive(sock));

    assertEquals(client1, client2);
}

From source file:code.google.nfs.rpc.mina.server.MinaServer.java

public void start(int listenPort, ExecutorService businessThreadPool) throws Exception {
    if (!startFlag.compareAndSet(false, true)) {
        return;/*from w w w. jav a2  s .c o  m*/
    }
    try {
        serverHandler = new MinaServerHandler(businessThreadPool);
        acceptor.bind(new InetSocketAddress(listenPort), serverHandler);
        LOGGER.warn("Server started,listen at: " + listenPort);
    } catch (Exception e) {
        startFlag.set(false);
        LOGGER.error("Server start failed", e);
        throw new Exception("start server error", e);
    }
}

From source file:me.xingrz.prox.udp.UdpProxySession.java

public UdpProxySession(UdpProxy udpProxy, Selector selector, int sourcePort, InetAddress remoteAddress,
        int remotePort) throws IOException {
    super(selector, sourcePort, remoteAddress, remotePort);
    this.udpProxy = udpProxy;
    this.serverChannel = DatagramChannel.open();
    this.serverChannel.configureBlocking(false);
    this.serverChannel.socket().bind(new InetSocketAddress(0));
}

From source file:com.linkedin.pinot.common.utils.FileUploadUtilsTest.java

@BeforeClass
public void setup() throws Exception {
    TEST_SERVER = HttpServer.create(new InetSocketAddress(Integer.parseInt(TEST_PORT)), 0);
    TEST_SERVER.createContext("/segments", new testSegmentUploadHandler());
    TEST_SERVER.setExecutor(null); // creates a default executor
    TEST_SERVER.start();//w ww.jav a  2 s.  c  o m
}

From source file:code.google.nfs.rpc.mina2.server.MinaServer.java

public void start(int listenPort, ExecutorService businessThreadPool) throws Exception {
    if (!startFlag.compareAndSet(false, true)) {
        return;/*from  w w w  .j av a 2s  .com*/
    }
    try {
        serverHandler = new MinaServerHandler(businessThreadPool);
        acceptor.setHandler(serverHandler);
        acceptor.bind(new InetSocketAddress(listenPort));
        LOGGER.warn("Server started,listen at: " + listenPort);
    } catch (Exception e) {
        startFlag.set(false);
        LOGGER.error("Server start failed", e);
        throw new Exception("start server error", e);
    }
}