當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericFutureListener類代碼示例

本文整理匯總了Java中io.netty.util.concurrent.GenericFutureListener的典型用法代碼示例。如果您正苦於以下問題:Java GenericFutureListener類的具體用法?Java GenericFutureListener怎麽用?Java GenericFutureListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GenericFutureListener類屬於io.netty.util.concurrent包,在下文中一共展示了GenericFutureListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connect

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
public synchronized ListenableFuture<Void> connect ()
{
    if ( this.connectFuture != null )
    {
        return this.connectFuture;
    }

    final ChannelFuture channelFuture = this.bootstrap.connect ( this.address );
    this.connectFuture = SettableFuture.create ();

    channelFuture.addListener ( new GenericFutureListener<ChannelFuture> () {

        @Override
        public void operationComplete ( final ChannelFuture future ) throws Exception
        {
            handleOperationComplete ( Client.this.connectFuture, future );
        }
    } );

    return this.connectFuture;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:22,代碼來源:Client.java

示例2: setupWithTest

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
/**
 * Establishes a new socket connection with connection test
 */
protected void setupWithTest() {
  ChannelFuture future = boot.connect(uri.host(), port);
  future.addListener(
      new GenericFutureListener<ChannelFuture>() {

        public void operationComplete(ChannelFuture f) {
          if (f.isSuccess()) {
            channel = (HTTPChannel) f.channel();
            testConnection();
            onTestBell.promise(onConnectBell);
          } else {
            onConnectBell.ring(f.cause());
          }
        }
      });
}
 
開發者ID:didclab,項目名稱:onedatashare,代碼行數:20,代碼來源:HTTPBuilder.java

示例3: kickPlayerFromServer

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
/**
 * Kick a player from the server with a reason
 */
public void kickPlayerFromServer(String reason)
{
    final ChatComponentText chatcomponenttext = new ChatComponentText(reason);
    this.netManager.sendPacket(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener < Future <? super Void >> ()
    {
        public void operationComplete(Future <? super Void > p_operationComplete_1_) throws Exception
        {
            NetHandlerPlayServer.this.netManager.closeChannel(chatcomponenttext);
        }
    }, new GenericFutureListener[0]);
    this.netManager.disableAutoRead();
    Futures.getUnchecked(this.serverController.addScheduledTask(new Runnable()
    {
        public void run()
        {
            NetHandlerPlayServer.this.netManager.checkDisconnected();
        }
    }));
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:23,代碼來源:NetHandlerPlayServer.java

示例4: sendPacket

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
public void sendPacket(Packet packetIn)
{
    if (this.isChannelOpen())
    {
        this.flushOutboundQueue();
        this.dispatchPacket(packetIn, (GenericFutureListener <? extends Future <? super Void >> [])null);
    }
    else
    {
        this.field_181680_j.writeLock().lock();

        try
        {
            this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(packetIn, (GenericFutureListener[])null));
        }
        finally
        {
            this.field_181680_j.writeLock().unlock();
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:22,代碼來源:NetworkManager.java

示例5: RemoteConnection

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
public RemoteConnection(SocketChannel channel, String name) {
  super();
  this.channel = channel;
  this.clientName = name;
  this.writeManager = new WriteManager();
  channel.pipeline().addLast(new BackPressureHandler());
  channel.closeFuture().addListener(new GenericFutureListener<Future<? super Void>>() {
    public void operationComplete(Future<? super Void> future) throws Exception {
      // this could possibly overrelease but it doesn't matter since we're only going to do this to ensure that we
      // fail out any pending messages
      writeManager.disable();
      writeManager.setWritable(true);
    }
  });

}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:17,代碼來源:RemoteConnection.java

示例6: kickPlayerFromServer

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
/**
 * Kick a player from the server with a reason
 */
public void kickPlayerFromServer(String reason)
{
    final TextComponentString textcomponentstring = new TextComponentString(reason);
    this.netManager.sendPacket(new SPacketDisconnect(textcomponentstring), new GenericFutureListener < Future <? super Void >> ()
    {
        public void operationComplete(Future <? super Void > p_operationComplete_1_) throws Exception
        {
            NetHandlerPlayServer.this.netManager.closeChannel(textcomponentstring);
        }
    }, new GenericFutureListener[0]);
    this.netManager.disableAutoRead();
    Futures.getUnchecked(this.serverController.addScheduledTask(new Runnable()
    {
        public void run()
        {
            NetHandlerPlayServer.this.netManager.checkDisconnected();
        }
    }));
}
 
開發者ID:NSExceptional,項目名稱:Zombe-Modpack,代碼行數:23,代碼來源:NetHandlerPlayServer.java

示例7: connectionSucceeded

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
@Override
public void connectionSucceeded(final ServerConnection connection) {
  connection.getChannel().closeFuture().addListener(
      new GenericFutureListener<Future<? super Void>>() {
        @Override
        public void operationComplete(Future<? super Void> future)
            throws Exception {
          for (final UserResultsListener listener : queryIdToResultsListenersMap.values()) {
            listener.submissionFailed(UserException.connectionError()
                .message("Connection %s closed unexpectedly. SabotNode down?",
                    connection.getName())
                .build(logger));
            if (listener instanceof BufferingResultsListener) {
              // the appropriate listener will be failed by SubmissionListener#failed
              logger.warn("Buffering listener failed before results were transferred to the actual listener.");
            }
          }
        }
      });
  parentHandler.connectionSucceeded(connection);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:22,代碼來源:QueryResultHandler.java

示例8: kickWithMessage

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
private void kickWithMessage(String message)
{
    final TextComponentString TextComponentString = new TextComponentString(message);
    if (side == Side.CLIENT)
    {
        manager.closeChannel(TextComponentString);
    }
    else
    {
        manager.sendPacket(new SPacketDisconnect(TextComponentString), new GenericFutureListener<Future<? super Void>>()
        {
            @Override
            public void operationComplete(Future<? super Void> result)
            {
                manager.closeChannel(TextComponentString);
            }
        }, (GenericFutureListener<? extends Future<? super Void>>[])null);
    }
    manager.channel().config().setAutoRead(false);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:NetworkDispatcher.java

示例9: sendPacket

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
public void sendPacket(Packet<?> packetIn)
{
    if (this.isChannelOpen())
    {
        this.flushOutboundQueue();
        this.dispatchPacket(packetIn, (GenericFutureListener <? extends Future <? super Void >> [])null);
    }
    else
    {
        this.readWriteLock.writeLock().lock();

        try
        {
            this.outboundPacketsQueue.add(new NetworkManager.InboundHandlerTuplePacketListener(packetIn, (GenericFutureListener[])null));
        }
        finally
        {
            this.readWriteLock.writeLock().unlock();
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:22,代碼來源:NetworkManager.java

示例10: kickWithMessage

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
private void kickWithMessage(String message)
{
    final ChatComponentText chatcomponenttext = new ChatComponentText(message);
    if (side == Side.CLIENT)
    {
        manager.func_150718_a(chatcomponenttext);
    }
    else
    {
        manager.func_150725_a(new S40PacketDisconnect(chatcomponenttext), new GenericFutureListener<Future<?>>()
        {
            @Override
            public void operationComplete(Future<?> result)
            {
                manager.func_150718_a(chatcomponenttext);
            }
        });
    }
    manager.channel().config().setAutoRead(false);
}
 
開發者ID:SchrodingersSpy,項目名稱:TRHS_Club_Mod_2016,代碼行數:21,代碼來源:NetworkDispatcher.java

示例11: sendOneWayMessage

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
@Override
public void sendOneWayMessage(Message message, SendResultCallback callback) {
    if (message.getMessageId() == null) {
        message.assignMessageId();
    }
    io.netty.channel.Channel _socket = this.socket;
    if (_socket == null || !_socket.isOpen()) {
        callback.messageSent(message, new Exception(this + " connection is closed"));
        return;
    }
    _socket.writeAndFlush(message).addListener(new GenericFutureListener() {

        @Override
        public void operationComplete(Future future) throws Exception {
            if (future.isSuccess()) {
                callback.messageSent(message, null);
            } else {
                LOGGER.log(Level.SEVERE, this + ": error " + future.cause(), future.cause());
                callback.messageSent(message, future.cause());
                close();
            }
        }

    });
}
 
開發者ID:diennea,項目名稱:herddb,代碼行數:26,代碼來源:NettyChannel.java

示例12: mock

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
@Test
public void finalizeChannelPipeline_should_send_event_to_metricsListener_for_successful_response_and_flush_context() throws Exception {
    // given
    ChannelFuture responseWriterChannelFuture = mock(ChannelFuture.class);
    state.setResponseWriterFinalChunkChannelFuture(responseWriterChannelFuture);
    HttpProcessingState stateSpy = spy(state);
    doReturn(stateSpy).when(stateAttributeMock).get();
    ChannelFuture responseWriteFutureResult = mock(ChannelFuture.class);
    doReturn(true).when(responseWriteFutureResult).isSuccess();
    Assertions.assertThat(stateSpy.isRequestMetricsRecordedOrScheduled()).isFalse();

    // when
    handler.finalizeChannelPipeline(ctxMock, null, stateSpy, null);

    // then
    ArgumentCaptor<GenericFutureListener> channelFutureListenerArgumentCaptor = ArgumentCaptor.forClass(GenericFutureListener.class);
    verify(responseWriterChannelFuture).addListener(channelFutureListenerArgumentCaptor.capture());
    GenericFutureListener futureListener = channelFutureListenerArgumentCaptor.getValue();
    assertThat(futureListener, notNullValue());
    futureListener.operationComplete(responseWriteFutureResult);

    verify(metricsListenerMock).onEvent(eq(ServerMetricsEvent.RESPONSE_SENT), any(HttpProcessingState.class));
    verify(ctxMock).flush();
    Assertions.assertThat(stateSpy.isRequestMetricsRecordedOrScheduled()).isTrue();
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:26,代碼來源:ChannelPipelineFinalizerHandlerTest.java

示例13: finalizeChannelPipeline_should_send_event_to_metricsListener_for_failure_response_and_flush_context

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
@Test
public void finalizeChannelPipeline_should_send_event_to_metricsListener_for_failure_response_and_flush_context() throws Exception {
    // given
    ChannelFuture responseWriterChannelFuture = mock(ChannelFuture.class);
    state.setResponseWriterFinalChunkChannelFuture(responseWriterChannelFuture);
    HttpProcessingState stateSpy = spy(state);
    doReturn(stateSpy).when(stateAttributeMock).get();
    ChannelFuture responseWriteFutureResult = mock(ChannelFuture.class);
    doReturn(false).when(responseWriteFutureResult).isSuccess();
    Assertions.assertThat(stateSpy.isRequestMetricsRecordedOrScheduled()).isFalse();

    // when
    handler.finalizeChannelPipeline(ctxMock, null, stateSpy, null);

    // then
    ArgumentCaptor<GenericFutureListener> channelFutureListenerArgumentCaptor = ArgumentCaptor.forClass(GenericFutureListener.class);
    verify(responseWriterChannelFuture).addListener(channelFutureListenerArgumentCaptor.capture());
    GenericFutureListener futureListener = channelFutureListenerArgumentCaptor.getValue();
    assertThat(futureListener, notNullValue());
    futureListener.operationComplete(responseWriteFutureResult);

    verify(metricsListenerMock).onEvent(ServerMetricsEvent.RESPONSE_WRITE_FAILED, null);
    verify(ctxMock).flush();
    Assertions.assertThat(stateSpy.isRequestMetricsRecordedOrScheduled()).isTrue();
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:26,代碼來源:ChannelPipelineFinalizerHandlerTest.java

示例14: verifyCloseFutureListener

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
private void verifyCloseFutureListener(GenericFutureListener closeFutureListener) throws Exception {
    // If the double-check ScheduledFuture is not done then it cancels it.
    reset(doubleCheckScheduledFutureMock);
    doReturn(false).when(doubleCheckScheduledFutureMock).isDone();
    closeFutureListener.operationComplete(null);
    verify(doubleCheckScheduledFutureMock).isDone();
    verify(doubleCheckScheduledFutureMock).cancel(false);
    verifyNoMoreInteractions(doubleCheckScheduledFutureMock);

    // And when the double-check ScheduledFuture is done, then nothing happens.
    reset(doubleCheckScheduledFutureMock);
    doReturn(true).when(doubleCheckScheduledFutureMock).isDone();
    closeFutureListener.operationComplete(null);
    verify(doubleCheckScheduledFutureMock).isDone();
    verifyNoMoreInteractions(doubleCheckScheduledFutureMock);
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:17,代碼來源:OpenChannelLimitHandlerTest.java

示例15: doChannelActive_marks_and_schedules_double_check_timeout_if_too_many_open_channels

import io.netty.util.concurrent.GenericFutureListener; //導入依賴的package包/類
@DataProvider(value = {
    "0",
    "1"
})
@Test
public void doChannelActive_marks_and_schedules_double_check_timeout_if_too_many_open_channels(
    int numOpenChannelsGreaterThanMax
) throws Exception {
    // given
    int actualOpenChannels = maxOpenChannelsThreshold + numOpenChannelsGreaterThanMax;
    setActualOpenChannels(actualOpenChannels);

    // when
    PipelineContinuationBehavior result = handler.doChannelActive(ctxMock);

    // then
    assertThat(result).isEqualTo(CONTINUE);
    Pair<Runnable, GenericFutureListener> futureInfoPair = extractDoubleCheckRunnableAndCloseFutureListener();
    verify(tooManyOpenConnectionsAttributeMock).set(actualOpenChannels);
    verifyDoubleCheckFuture(futureInfoPair.getLeft());
    verifyCloseFutureListener(futureInfoPair.getRight());
    verify(channelGroupMock, never()).add(channelMock);
}
 
開發者ID:Nike-Inc,項目名稱:riposte,代碼行數:24,代碼來源:OpenChannelLimitHandlerTest.java


注:本文中的io.netty.util.concurrent.GenericFutureListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。