本文整理了Java中java.nio.channels.Selector.close()
方法的一些代码示例,展示了Selector.close()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Selector.close()
方法的具体详情如下:
包路径:java.nio.channels.Selector
类名称:Selector
方法名:close
[英]Closes this selector. Ongoing calls to the select methods of this selector will get interrupted. This interruption behaves as if the #wakeup() method of this selector is called. After this, all keys that are still valid are invalidated and their channels are unregistered. All resources held by this selector are released.
Any further attempt of using this selector after this method has been called (except calling #close() or #wakeup()) results in a ClosedSelectorException being thrown.
[中]
代码示例来源:origin: netty/netty
@Override
public void close() throws IOException {
delegate.close();
}
}
代码示例来源:origin: redisson/redisson
@Override
public void close() throws IOException {
delegate.close();
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public void close() throws IOException {
delegate.close();
}
}
代码示例来源:origin: iluwatar/java-design-patterns
/**
* Stops the reactor and related resources such as dispatcher.
*
* @throws InterruptedException
* if interrupted while stopping the reactor.
* @throws IOException
* if any I/O error occurs.
*/
public void stop() throws InterruptedException, IOException {
reactorMain.shutdownNow();
selector.wakeup();
reactorMain.awaitTermination(4, TimeUnit.SECONDS);
selector.close();
LOGGER.info("Reactor stopped");
}
代码示例来源:origin: apache/zookeeper
/**
* Close the selector. This should be called when the thread is about to
* exit and no operation is going to be performed on the Selector or
* SelectionKey
*/
protected void closeSelector() {
try {
selector.close();
} catch (IOException e) {
LOG.warn("ignored exception during selector close "
+ e.getMessage());
}
}
代码示例来源:origin: netty/netty
@Override
protected void cleanup() {
try {
selector.close();
} catch (IOException e) {
logger.warn("Failed to close a selector.", e);
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
void close() {
if (selector != null) {
try {
selector.close();
} catch (IOException e) {
LOG.warn("Unexpected exception while closing selector : ", e);
}
}
}
}
代码示例来源:origin: apache/zookeeper
@Override
void close() {
try {
if (LOG.isTraceEnabled()) {
LOG.trace("Doing client selector close");
}
selector.close();
if (LOG.isTraceEnabled()) {
LOG.trace("Closed client selector");
}
} catch (IOException e) {
LOG.warn("Ignoring exception during selector close", e);
}
}
代码示例来源:origin: redisson/redisson
@Override
protected void cleanup() {
try {
selector.close();
} catch (IOException e) {
logger.warn("Failed to close a selector.", e);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void cleanup() {
try {
selector.close();
} catch (IOException e) {
logger.warn("Failed to close a selector.", e);
}
}
代码示例来源:origin: EsotericSoftware/kryonet
/** Releases the resources used by this client, which may no longer be used. */
public void dispose () throws IOException {
close();
selector.close();
}
代码示例来源:origin: apache/activemq
public void close() throws IOException {
if (rs.isOpen()) {
rs.close();
if (sc.isOpen()) {
sc.socket().shutdownInput();
sc.socket().close();
}
bb = null;
sc = null;
}
}
代码示例来源:origin: EsotericSoftware/kryonet
/** Releases the resources used by this server, which may no longer be used. */
public void dispose () throws IOException {
close();
selector.close();
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
@Override
public void run() {
LOG.info("Starting " + Thread.currentThread().getName());
try {
doRunLoop();
} finally {
try {
readSelector.close();
} catch (IOException ioe) {
LOG.error("Error closing read selector in " + Thread.currentThread().getName(), ioe);
}
}
}
代码示例来源:origin: apache/rocketmq
/**
* {@inheritDoc}
*/
@Override
public void shutdown(final boolean interrupt) {
super.shutdown(interrupt);
try {
this.serverSocketChannel.close();
this.selector.close();
} catch (IOException e) {
log.error("AcceptSocketService shutdown exception", e);
}
}
代码示例来源:origin: apache/kafka
/**
* Close this selector and all associated connections
*/
@Override
public void close() {
List<String> connections = new ArrayList<>(channels.keySet());
for (String id : connections)
close(id);
try {
this.nioSelector.close();
} catch (IOException | SecurityException e) {
log.error("Exception closing nioSelector:", e);
}
sensors.close();
channelBuilder.close();
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void doClose() throws Exception {
try {
selector.close();
} catch (IOException e) {
logger.warn("Failed to close a selector.", e);
}
sch.close();
}
代码示例来源:origin: wildfly/wildfly
private static void closeSelector(String selectorName, Selector selector) {
try {
selector.close();
} catch (IOException e) {
if (logger.isWarnEnabled()) {
logger.warn("Failed to close a " + selectorName + " selector.", e);
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void run() {
try {
doRunLoop();
} finally {
try {
readSelector.close();
} catch (IOException ioe) {
LOG.error(getName() + ": error closing read selector in " + getName(), ioe);
}
}
}
代码示例来源:origin: apache/hbase
@Override
public void run() {
SimpleRpcServer.LOG.debug(getName() + ": starting");
try {
doRunLoop();
} finally {
SimpleRpcServer.LOG.info(getName() + ": stopping");
try {
writeSelector.close();
} catch (IOException ioe) {
SimpleRpcServer.LOG.error(getName() + ": couldn't close write selector", ioe);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!