Search in sources :

Example 11 with ChannelException

use of org.jboss.netty.channel.ChannelException in project neo4j by neo4j.

the class ArbiterBootstrapper method start.

@SafeVarargs
@Override
public final int start(File homeDir, Optional<File> configFile, Pair<String, String>... configOverrides) {
    Config config = getConfig(configFile, configOverrides);
    try {
        DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
        life.add(new FileSystemLifecycleAdapter(fileSystem));
        life.add(new Neo4jJobScheduler());
        new ClusterClientModule(life, new Dependencies(), new Monitors(), config, logService(fileSystem, config), new NotElectableElectionCredentialsProvider());
    } catch (LifecycleException e) {
        @SuppressWarnings({ "ThrowableResultOfMethodCallIgnored", "unchecked" }) Throwable cause = peel(e, Predicates.<Throwable>instanceOf(LifecycleException.class));
        if (cause instanceof ChannelException) {
            System.err.println("ERROR: " + cause.getMessage() + (cause.getCause() != null ? ", caused by:" + cause.getCause().getMessage() : ""));
        } else {
            System.err.println("ERROR: Unknown error");
            throw e;
        }
    }
    addShutdownHook();
    life.start();
    return 0;
}
Also used : FileSystemLifecycleAdapter(org.neo4j.io.fs.FileSystemLifecycleAdapter) Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) LifecycleException(org.neo4j.kernel.lifecycle.LifecycleException) DefaultFileSystemAbstraction(org.neo4j.io.fs.DefaultFileSystemAbstraction) Config(org.neo4j.kernel.configuration.Config) NotElectableElectionCredentialsProvider(org.neo4j.cluster.protocol.election.NotElectableElectionCredentialsProvider) Monitors(org.neo4j.kernel.monitoring.Monitors) Dependencies(org.neo4j.kernel.impl.util.Dependencies) ClusterClientModule(org.neo4j.cluster.client.ClusterClientModule) ChannelException(org.jboss.netty.channel.ChannelException)

Example 12 with ChannelException

use of org.jboss.netty.channel.ChannelException in project hadoop by apache.

the class TestFrameDecoder method startRpcServer.

private static int startRpcServer(boolean allowInsecurePorts) {
    Random rand = new Random();
    int serverPort = 30000 + rand.nextInt(10000);
    // A few retries in case initial choice is in use.
    int retries = 10;
    while (true) {
        try {
            RpcProgram program = new TestFrameDecoder.TestRpcProgram("TestRpcProgram", "localhost", serverPort, 100000, 1, 2, allowInsecurePorts);
            SimpleTcpServer tcpServer = new SimpleTcpServer(serverPort, program, 1);
            tcpServer.run();
            // Successfully bound a port, break out.
            break;
        } catch (ChannelException ce) {
            if (retries-- > 0) {
                // Port in use? Try another.
                serverPort += rand.nextInt(20);
            } else {
                // Out of retries.
                throw ce;
            }
        }
    }
    return serverPort;
}
Also used : Random(java.util.Random) ChannelException(org.jboss.netty.channel.ChannelException)

Aggregations

ChannelException (org.jboss.netty.channel.ChannelException)12 InetSocketAddress (java.net.InetSocketAddress)6 ServerBootstrap (org.jboss.netty.bootstrap.ServerBootstrap)4 Channel (org.jboss.netty.channel.Channel)4 IOException (java.io.IOException)3 Request (com.metamx.http.client.Request)2 RetryPolicy (io.druid.indexing.common.RetryPolicy)2 URI (java.net.URI)2 Map (java.util.Map)2 Test (org.junit.Test)2 HostnamePort (org.neo4j.helpers.HostnamePort)2 ActorSystem (akka.actor.ActorSystem)1 ServiceBindException (co.cask.cdap.common.ServiceBindException)1 HttpRequestHandler (co.cask.cdap.gateway.router.handlers.HttpRequestHandler)1 HttpStatusRequestHandler (co.cask.cdap.gateway.router.handlers.HttpStatusRequestHandler)1 SecurityAuthenticationHttpHandler (co.cask.cdap.gateway.router.handlers.SecurityAuthenticationHttpHandler)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 FullResponseHandler (com.metamx.http.client.response.FullResponseHandler)1 FullResponseHolder (com.metamx.http.client.response.FullResponseHolder)1 StatusResponseHandler (com.metamx.http.client.response.StatusResponseHandler)1