java.net.BindException#getMessage ( )源码实例Demo

下面列出了java.net.BindException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase   文件: MasterRpcServices.java
@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);
  }
}
 
源代码2 项目: hbase   文件: RSRpcServices.java
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);
  }
}
 
@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);
}
 
源代码4 项目: cacheonix-core   文件: Receiver.java
/**
 * 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;
}
 
源代码5 项目: Tomcat7.0.67   文件: JIoEndpoint.java
@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;
        }
    }

}
 
源代码6 项目: tomcatsrc   文件: JIoEndpoint.java
@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;
        }
    }

}