org.jgroups.util.Util.close()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.3k)|赞(0)|评价(0)|浏览(237)

本文整理了Java中org.jgroups.util.Util.close()方法的一些代码示例,展示了Util.close()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.close()方法的具体详情如下:
包路径:org.jgroups.util.Util
类名称:Util
方法名:close

Util.close介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public static void close(Closeable... closeables) {
  if(closeables != null) {
    for(Closeable closeable : closeables)
      Util.close(closeable);
  }
}

代码示例来源:origin: wildfly/wildfly

public static void closeReverse(Closeable... closeables) {
  if(closeables != null) {
    for(int i=closeables.length-1; i >= 0; i--)
      Util.close(closeables[i]);
  }
}

代码示例来源:origin: wildfly/wildfly

protected void closeConnections() {
  Util.close(in);
  Util.close(out);
  Util.close(sock);
}

代码示例来源:origin: wildfly/wildfly

protected void stopEventThread() {
  Thread tmp=event_loop_thread;
  looping=false;
  if(tmp != null)
    tmp.interrupt();
  Util.close(channel);
}

代码示例来源:origin: wildfly/wildfly

public void getState(OutputStream output) throws Exception {
  DataOutputStream out=new DataOutputStream(new BufferedOutputStream(output, 1000));
  try {
    synchronized(nodes) {
      Util.objectToStream(nodes, out);
    }
  }
  finally {
    Util.close(out);
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public void stop() {
  if(running.compareAndSet(true, false)) {
    Util.close(conn);
    super.stop();
  }
}

代码示例来源:origin: wildfly/wildfly

protected void stop(boolean graceful) {
  if(acceptor != null && acceptor.isAlive())
    Util.close(srv_sock); // this will terminate thread, peer will receive SocketException (socket close)
  synchronized(clients) {
    clients.forEach(client -> client.stopThread(graceful));
    clients.clear();
  }
  acceptor=null;
}

代码示例来源:origin: wildfly/wildfly

public static XmlConfigurator getInstance(URL url, Boolean validate) throws java.io.IOException {
  InputStream is = url.openStream();
  try {
    return getInstance(is, validate);
  } finally {
    Util.close(is);
  }
}

代码示例来源:origin: wildfly/wildfly

public void stop() {
  Util.close(sock);
  sock=null;
  receiver=null;
  super.stop();
}

代码示例来源:origin: wildfly/wildfly

void stop() {
  if(disp != null)
    disp.stop();
  Util.close(channel);
}

代码示例来源:origin: wildfly/wildfly

@ManagedOperation
public void stop() throws IOException {
  Util.close(srv_sock);
  thread=null;
  if(thread_pool instanceof ExecutorService)
    ((ExecutorService)thread_pool).shutdown();
}

代码示例来源:origin: wildfly/wildfly

@Override
public void stop() {
  if(running.compareAndSet(true, false)) {
    Util.close(srv_sock);
    Util.interruptAndWaitToDie(acceptor);
    super.stop();
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
@ManagedOperation(description="Stops the server")
public synchronized void stop() {
  super.stop();
  if(running.compareAndSet(true, false))
    Util.close(selector, channel); // closing the selector also stops the acceptor thread
}

代码示例来源:origin: wildfly/wildfly

public void stop() {
  looping=false;
  try {
    JmxConfigurator.unregisterChannel(channel, Util.getMBeanServer(), "jgroups", "mperf");
  }
  catch(Exception e) {
    e.printStackTrace();
  }
  Util.close(channel);
}

代码示例来源:origin: wildfly/wildfly

public void destroy() {        
  stubManager.destroyStubs();
  Util.close(sock);
  super.destroy();
}

代码示例来源:origin: wildfly/wildfly

protected Tuple<InputStream,Object> createStreamToProvider(final Address provider, final StateHeader hdr) {
  Util.close(input_stream);
  input_stream=new BlockingInputStream(buffer_size);
  return new Tuple<>(input_stream, null);
}

代码示例来源:origin: wildfly/wildfly

public void stop() {
  super.stop();
  if(srv_sock_handler != null) {
    srv_sock_handler.stop(); // should also close srv_sock
    srv_sock_handler=null;
    Util.close(srv_sock);  // not needed, but second line of defense
    srv_sock=null;
  }
}

代码示例来源:origin: wildfly/wildfly

protected synchronized void stopKeyserver() {
  if(srv_sock_handler != null) {
    log.debug("%s: ceasing to be the keyserver; closing the server socket", local_addr);
    srv_sock_handler.stop();
    srv_sock_handler=null;
  }
  if(srv_sock != null) {
    Util.close(srv_sock); // should not be necessary (check)
    srv_sock=null;
  }
}

代码示例来源:origin: wildfly/wildfly

public void closeConnection(Connection conn, Throwable ex) {
  Util.close(conn);
  notifyConnectionClosed(conn, ex.toString());
  removeConnectionIfPresent(conn != null? conn.peerAddress() : null, conn);
}

代码示例来源:origin: wildfly/wildfly

protected synchronized void becomeKeyserver() throws Exception {
  if(srv_sock == null || srv_sock.isClosed()) {
    log.debug("%s: becoming keyserver; creating server socket", local_addr);
    srv_sock=createServerSocket();
    srv_sock_handler=new Runner(getThreadFactory(), SSL_KEY_EXCHANGE.class.getSimpleName() + "-runner",
                  this::accept, () -> Util.close(srv_sock));
    srv_sock_handler.start();
    log.debug("SSL server socket listening on %s", srv_sock.getLocalSocketAddress());
  }
}

相关文章

Util类方法