Java Code Examples for java.net.BindException#getMessage()

The following examples show how to use java.net.BindException#getMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MasterRpcServices.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
protected RpcServerInterface createRpcServer(final Server server,
    final RpcSchedulerFactory rpcSchedulerFactory, final InetSocketAddress bindAddress,
    final String name) throws IOException {
  final Configuration conf = regionServer.getConfiguration();
  // RpcServer at HM by default enable ByteBufferPool iff HM having user table region in it
  boolean reservoirEnabled = conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY,
    LoadBalancer.isMasterCanHostUserRegions(conf));
  try {
    return RpcServerFactory.createRpcServer(server, name, getServices(),
        bindAddress, // use final bindAddress for this server.
        conf, rpcSchedulerFactory.create(conf, this, server), reservoirEnabled);
  } catch (BindException be) {
    throw new IOException(be.getMessage() + ". To switch ports use the '"
        + HConstants.MASTER_PORT + "' configuration property.",
        be.getCause() != null ? be.getCause() : be);
  }
}
 
Example 2
Source File: RSRpcServices.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected RpcServerInterface createRpcServer(
    final Server server,
    final RpcSchedulerFactory rpcSchedulerFactory,
    final InetSocketAddress bindAddress,
    final String name
) throws IOException {
  final Configuration conf = server.getConfiguration();
  boolean reservoirEnabled = conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, true);
  try {
    return RpcServerFactory.createRpcServer(server, name, getServices(),
        bindAddress, // use final bindAddress for this server.
        conf, rpcSchedulerFactory.create(conf, this, server), reservoirEnabled);
  } catch (BindException be) {
    throw new IOException(be.getMessage() + ". To switch ports use the '"
        + HConstants.REGIONSERVER_PORT + "' configuration property.",
        be.getCause() != null ? be.getCause() : be);
  }
}
 
Example 3
Source File: RestCtrlExceptionHandler.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
@ExceptionHandler(BindException.class)
@ResponseStatus(value = HttpStatus.OK)
@ResponseBody
public Result<Object> bindExceptionHandler(BindException e){
    String errorMsg="请求数据校验不合法: ";
    if(e!=null){
        errorMsg=e.getMessage();
        log.warn(errorMsg);
    }
    return new ResultUtil<>().setErrorMsg(errorMsg);
}
 
Example 4
Source File: Receiver.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a BindException with added information on the address for that the exception occurred. The stack trace of
 * the resulting exception is set to the stack trace of the original exception.
 *
 * @param originalException original exception.
 * @param endpoint          address
 * @return BindException with added information on the address for that the exception occurred.
 */
private static BindException createDetailedBindException(final BindException originalException,
        final InetSocketAddress endpoint) {

   final String newMessage = originalException.getMessage() + ". Address: " + endpoint;
   final BindException newBindException = new BindException(newMessage);
   newBindException.setStackTrace(originalException.getStackTrace());
   return newBindException;
}
 
Example 5
Source File: JIoEndpoint.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
@Override
public void bind() throws Exception {

    // Initialize thread count defaults for acceptor
    if (acceptorThreadCount == 0) {
        acceptorThreadCount = 1;
    }
    // Initialize maxConnections
    if (getMaxConnections() == 0) {
        // User hasn't set a value - use the default
        setMaxConnections(getMaxThreadsExecutor(true));
    }

    if (serverSocketFactory == null) {
        if (isSSLEnabled()) {
            serverSocketFactory =
                handler.getSslImplementation().getServerSocketFactory(this);
        } else {
            serverSocketFactory = new DefaultServerSocketFactory(this);
        }
    }

    if (serverSocket == null) {
        try {
            if (getAddress() == null) {
                serverSocket = serverSocketFactory.createSocket(getPort(),
                        getBacklog());
            } else {
                serverSocket = serverSocketFactory.createSocket(getPort(),
                        getBacklog(), getAddress());
            }
        } catch (BindException orig) {
            String msg;
            if (getAddress() == null)
                msg = orig.getMessage() + " <null>:" + getPort();
            else
                msg = orig.getMessage() + " " +
                        getAddress().toString() + ":" + getPort();
            BindException be = new BindException(msg);
            be.initCause(orig);
            throw be;
        }
    }

}
 
Example 6
Source File: JIoEndpoint.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
@Override
public void bind() throws Exception {

    // Initialize thread count defaults for acceptor
    if (acceptorThreadCount == 0) {
        acceptorThreadCount = 1;
    }
    // Initialize maxConnections
    if (getMaxConnections() == 0) {
        // User hasn't set a value - use the default
        setMaxConnections(getMaxThreadsInternal());
    }

    if (serverSocketFactory == null) {
        if (isSSLEnabled()) {
            serverSocketFactory =
                handler.getSslImplementation().getServerSocketFactory(this);
        } else {
            serverSocketFactory = new DefaultServerSocketFactory(this);
        }
    }

    if (serverSocket == null) {
        try {
            if (getAddress() == null) {
                serverSocket = serverSocketFactory.createSocket(getPort(),
                        getBacklog());
            } else {
                serverSocket = serverSocketFactory.createSocket(getPort(),
                        getBacklog(), getAddress());
            }
        } catch (BindException orig) {
            String msg;
            if (getAddress() == null)
                msg = orig.getMessage() + " <null>:" + getPort();
            else
                msg = orig.getMessage() + " " +
                        getAddress().toString() + ":" + getPort();
            BindException be = new BindException(msg);
            be.initCause(orig);
            throw be;
        }
    }

}