Github user jinossy commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/884#discussion_r47183366
  
    --- Diff: 
tajo-core/src/main/java/org/apache/tajo/worker/ExecutionBlockContext.java ---
    @@ -191,10 +197,59 @@ public void stop(){
         }
         tasks.clear();
         taskHistories.clear();
    +
    +    // Clear index cache in pull server
    +    clearIndexCache();
    +
         resource.release();
         RpcClientManager.cleanup(queryMasterClient);
       }
     
    +  private void clearIndexCache() {
    +    if (executionBlockId.getId() > 1) {
    +      Bootstrap bootstrap = new Bootstrap()
    +          
.group(NettyUtils.getSharedEventLoopGroup(NettyUtils.GROUP.FETCHER, 1))
    +          .channel(NioSocketChannel.class)
    +          .option(ChannelOption.ALLOCATOR, NettyUtils.ALLOCATOR)
    +          .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10 * 1000)
    +          .option(ChannelOption.TCP_NODELAY, true);
    +      ChannelInitializer<Channel> initializer = new 
ChannelInitializer<Channel>() {
    +        @Override
    +        protected void initChannel(Channel channel) throws Exception {
    +          ChannelPipeline pipeline = channel.pipeline();
    +          pipeline.addLast("codec", new HttpClientCodec());
    +        }
    +      };
    +      bootstrap.handler(initializer);
    +
    +      WorkerConnectionInfo connInfo = workerContext.getConnectionInfo();
    +      ChannelFuture future = bootstrap.connect(new 
InetSocketAddress(connInfo.getHost(), connInfo.getPullServerPort()))
    +          .addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
    +
    +      try {
    +        Channel channel = future.await().channel();
    +        if (!future.isSuccess()) {
    +          // Upon failure to connect to pull server, cache clear message 
is just ignored.
    +          LOG.warn(future.cause());
    +          return;
    +        }
    +
    +        ExecutionBlockId clearEbId = new 
ExecutionBlockId(executionBlockId.getQueryId(), executionBlockId.getId() - 1);
    +        HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, 
HttpMethod.DELETE, clearEbId.toString());
    +        request.headers().set(Names.HOST, connInfo.getHost());
    +        request.headers().set(Names.CONNECTION, Values.CLOSE);
    +        channel.writeAndFlush(request);
    +      } catch (InterruptedException e) {
    +        throw new RuntimeException(e);
    +      } finally {
    +        if (future != null && future.channel().isOpen()) {
    +          // Close the channel to exit.
    +          future.channel().closeFuture();
    --- End diff --
    
    It should be `future.channel().close()`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to