本文整理了Java中io.netty.util.concurrent.Future.sync()
方法的一些代码示例,展示了Future.sync()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Future.sync()
方法的具体详情如下:
包路径:io.netty.util.concurrent.Future
类名称:Future
方法名:sync
[英]Waits for this future until it is done, and rethrows the cause of the failure if this future failed.
[中]等待此未来直到完成,如果此未来失败,则重新选择失败的原因。
代码示例来源:origin: spring-projects/spring-framework
@Override
public void destroy() throws InterruptedException {
if (this.defaultEventLoopGroup) {
// Clean up the EventLoopGroup if we created it in the constructor
this.eventLoopGroup.shutdownGracefully().sync();
}
}
代码示例来源:origin: line/armeria
@Override
public Future<T> sync() throws InterruptedException {
return delegate.sync();
}
代码示例来源:origin: org.springframework/spring-web
@Override
public void destroy() throws InterruptedException {
if (this.defaultEventLoopGroup) {
// Clean up the EventLoopGroup if we created it in the constructor
this.eventLoopGroup.shutdownGracefully().sync();
}
}
代码示例来源:origin: alipay/sofa-rpc
@Override
public void stop() {
try {
eventLoopGroup.shutdownGracefully().sync();
eventExecutor.shutdownGracefully().sync();
} catch (Exception ignore) { // NOPMD
}
bootstrap = null;
}
}
代码示例来源:origin: alipay/sofa-rpc
@Override
public void stop() {
try {
eventLoopGroup.shutdownGracefully().sync();
eventExecutor.shutdownGracefully().sync();
} catch (Exception ignore) { // NOPMD
}
bootstrap = null;
}
}
代码示例来源:origin: apache/hive
public void stop() throws IOException, InterruptedException {
LOG.info("Stopping LlapOutputFormatService");
if (listeningChannelFuture != null) {
listeningChannelFuture.channel().close().sync();
listeningChannelFuture = null;
} else {
LOG.warn("LlapOutputFormatService does not appear to have a listening port to close.");
}
eventLoopGroup.shutdownGracefully(1, WAIT_TIME, TimeUnit.SECONDS).sync();
}
代码示例来源:origin: apache/drill
public void stop() throws IOException, InterruptedException {
LOG.info("Stopping LlapOutputFormatService");
if (listeningChannelFuture != null) {
listeningChannelFuture.channel().close().sync();
listeningChannelFuture = null;
} else {
LOG.warn("LlapOutputFormatService does not appear to have a listening port to close.");
}
eventLoopGroup.shutdownGracefully(1, WAIT_TIME, TimeUnit.SECONDS).sync();
}
代码示例来源:origin: lets-blade/blade
@Override
public void stopAndWait() {
if (isStop) {
return;
}
isStop = true;
System.out.println();
log.info("{}Blade shutdown ...", getStartedSymbol());
try {
if (this.bossGroup != null) {
this.bossGroup.shutdownGracefully().sync();
}
if (this.workerGroup != null) {
this.workerGroup.shutdownGracefully().sync();
}
log.info("{}Blade shutdown successful", getStartedSymbol());
} catch (Exception e) {
log.error("Blade shutdown error", e);
}
}
代码示例来源:origin: lets-blade/blade
@Override
public void stopAndWait() {
if (isStop) {
return;
}
isStop = true;
System.out.println();
log.info("{}Blade shutdown ...", getStartedSymbol());
try {
if (this.bossGroup != null) {
this.bossGroup.shutdownGracefully().sync();
}
if (this.workerGroup != null) {
this.workerGroup.shutdownGracefully().sync();
}
log.info("{}Blade shutdown successful", getStartedSymbol());
} catch (Exception e) {
log.error("Blade shutdown error", e);
}
}
代码示例来源:origin: spring-projects/spring-framework
@AfterClass
public static void shutdownEventLoopGroup() throws InterruptedException {
eventLoopGroup.shutdownGracefully().sync();
}
代码示例来源:origin: spring-projects/spring-framework
@AfterClass
public static void shutdownEventLoopGroup() throws InterruptedException {
eventLoopGroup.shutdownGracefully().sync();
}
代码示例来源:origin: netty/netty
register0(ch, interestOps, task);
}).sync();
} catch (InterruptedException ignore) {
代码示例来源:origin: Graylog2/graylog2-server
private List<ADnsAnswer> resolveIpAddresses(String hostName, DnsRecordType dnsRecordType, boolean includeIpVersion)
throws InterruptedException, ExecutionException {
LOG.debug("Attempting to resolve [{}] records for [{}]", dnsRecordType, hostName);
if (isShutdown()) {
throw new DnsClientNotRunningException();
}
validateHostName(hostName);
final DefaultDnsQuestion aRecordDnsQuestion = new DefaultDnsQuestion(hostName, dnsRecordType);
/* The DnsNameResolver.resolveAll(DnsQuestion) method handles all redirects through CNAME records to
* ultimately resolve a list of IP addresses with TTL values. */
return resolver.resolveAll(aRecordDnsQuestion).sync().get().stream()
.map(dnsRecord -> decodeDnsRecord(dnsRecord, includeIpVersion))
.filter(Objects::nonNull) // Removes any entries which the IP address could not be extracted for.
.collect(Collectors.toList());
}
代码示例来源:origin: redisson/redisson
register0(ch, interestOps, task);
}).sync();
} catch (InterruptedException ignore) {
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void shutdown() {
bootstrap.config().group().shutdownGracefully();
try {
bootstrap.config().group().terminationFuture().sync();
} catch (InterruptedException e) {
GlowServer.logger.log(Level.SEVERE,
"Datagram server shutdown process interrupted!",
e);
}
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public void shutdown() {
channel.close();
bootstrap.config().group().shutdownGracefully();
bootstrap.config().childGroup().shutdownGracefully();
try {
bootstrap.config().group().terminationFuture().sync();
bootstrap.config().childGroup().terminationFuture().sync();
} catch (InterruptedException e) {
GlowServer.logger.log(Level.SEVERE, "Socket server shutdown process interrupted!",
e);
}
}
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldLogOnlyTheFirstCaughtException() throws Exception
{
AssertableLogProvider logProvider = new AssertableLogProvider();
BoltConnection connection = mock( BoltConnection.class );
HouseKeeper houseKeeper = new HouseKeeper( connection, logProvider.getLog( HouseKeeper.class ) );
Bootstrap bootstrap = newBootstrap( houseKeeper );
RuntimeException error1 = new RuntimeException( "error #1" );
RuntimeException error2 = new RuntimeException( "error #2" );
RuntimeException error3 = new RuntimeException( "error #3" );
try ( ServerSocket serverSocket = new ServerSocket( 0 ) )
{
ChannelFuture future = bootstrap.connect( "localhost", serverSocket.getLocalPort() ).sync();
Channel channel = future.channel();
// fire multiple errors
channel.pipeline().fireExceptionCaught( error1 );
channel.pipeline().fireExceptionCaught( error2 );
channel.pipeline().fireExceptionCaught( error3 );
// await for the channel to be closed by the HouseKeeper
channel.closeFuture().sync();
}
finally
{
// make sure event loop group is always terminated
bootstrap.config().group().shutdownGracefully().sync();
}
logProvider.assertExactly(
inLog( HouseKeeper.class ).error( startsWith( "Fatal error occurred when handling a client connection" ), equalTo( error1 ) ) );
}
代码示例来源:origin: Graylog2/graylog2-server
content = resolver.query(new DefaultDnsQuestion(hostName, DnsRecordType.TXT)).sync().get().content();
int count = content.count(DnsSection.ANSWER);
final ArrayList<TxtDnsAnswer> txtRecords = new ArrayList<>(count);
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldNotLogExceptionsWhenEvenLoopIsShuttingDown() throws Exception
{
AssertableLogProvider logProvider = new AssertableLogProvider();
BoltConnection connection = mock( BoltConnection.class );
HouseKeeper houseKeeper = new HouseKeeper( connection, logProvider.getLog( HouseKeeper.class ) );
Bootstrap bootstrap = newBootstrap( houseKeeper );
try ( ServerSocket serverSocket = new ServerSocket( 0 ) )
{
ChannelFuture future = bootstrap.connect( "localhost", serverSocket.getLocalPort() ).sync();
Channel channel = future.channel();
// write some messages without flushing
for ( int i = 0; i < 100; i++ )
{
// use void promise which should redirect all write errors back to the pipeline and the HouseKeeper
channel.write( writeUtf8( channel.alloc(), "Hello" ), channel.voidPromise() );
}
// stop the even loop to make all pending writes fail
bootstrap.config().group().shutdownGracefully();
// await for the channel to be closed by the HouseKeeper
channel.closeFuture().sync();
}
finally
{
// make sure event loop group is always terminated
bootstrap.config().group().shutdownGracefully().sync();
}
logProvider.assertNoLoggingOccurred();
}
代码示例来源:origin: Graylog2/graylog2-server
content = resolver.query(new DefaultDnsQuestion(inverseAddressFormat, DnsRecordType.PTR)).sync().get().content();
for (int i = 0; i < content.count(DnsSection.ANSWER); i++) {
内容来源于网络,如有侵权,请联系作者删除!