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;
}
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;
}
Aggregations