carbondata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jackylk <...@git.apache.org>
Subject [GitHub] incubator-carbondata pull request #605: [CARBONDATA-715] Optimize Single-Pas...
Date Wed, 22 Feb 2017 01:11:28 GMT
Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/incubator-carbondata/pull/605#discussion_r102361729
  
    --- Diff: core/src/main/java/org/apache/carbondata/core/dictionary/client/DictionaryClientHandler.java
---
    @@ -77,20 +79,13 @@ public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent
e) throws
        */
       public DictionaryKey getDictionary(DictionaryKey key) {
         DictionaryKey dictionaryKey;
    -    BlockingQueue<DictionaryKey> dictKeyQueue = null;
         try {
    -      synchronized (lock) {
    -        dictKeyQueue = dictKeyQueueMap.get(key.getThreadNo());
    -        if (dictKeyQueue == null) {
    -          dictKeyQueue = new LinkedBlockingQueue<DictionaryKey>();
    -          dictKeyQueueMap.put(key.getThreadNo(), dictKeyQueue);
    -        }
    -      }
    -      byte[] serialize = KryoRegister.serialize(key);
    -      ctx.getChannel().write(serialize);
    +      ByteBuf buffer = ctx.alloc().buffer();
    +      key.writeData(buffer);
    +      ctx.writeAndFlush(buffer);
         } catch (Exception e) {
    -      LOGGER.error("Error while send request to server " + e.getMessage());
    -      ctx.getChannel().close();
    +      LOGGER.error(e, "Error while send request to server " + e.getMessage());
    +      ctx.close();
         }
         boolean interrupted = false;
         try {
    --- End diff --
    
    There is no timeout control here. How about using SettingFuture from Guava libary, like
    ```
    final SettableFuture<Integer> dictionaryKey = SettableFuture.create();
        ResponseCallback callback = new ResponseCallback() {
          @Override
          public void invoke(NettyMessage response) {
            if (response instanceof DictGenResponseMessage) {
              DictGenResponseMessage resp = (DictGenResponseMessage) response;
              dictionaryKey.set(resp.getDictionaryKey());
            }
          }
        };
        clientHandler.addRequest(request.id(), callback);
        ChannelFuture f = channel.writeAndFlush(request);
        try {
          return dictionaryKey.get(10, TimeUnit.SECONDS);
        } catch (InterruptedException | TimeoutException | ExecutionException e) {
          LOGGER.error("exception while generating dictionary key from Dictionary Service:
" +
              e.getMessage());
          throw e;
        }
    ```
    This needs to set a callback in the handler and invoke the callback in `channelRead0`
in the handler. Then the blockingQueue is not needed



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message