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

    https://github.com/apache/spark/pull/14080#discussion_r70171929
  
    --- Diff: 
common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ExternalShuffleBlockHandler.java
 ---
    @@ -79,32 +89,59 @@ protected void handleMessage(
           TransportClient client,
           RpcResponseCallback callback) {
         if (msgObj instanceof OpenBlocks) {
    -      OpenBlocks msg = (OpenBlocks) msgObj;
    -      checkAuth(client, msg.appId);
    -
    -      List<ManagedBuffer> blocks = Lists.newArrayList();
    -      for (String blockId : msg.blockIds) {
    -        blocks.add(blockManager.getBlockData(msg.appId, msg.execId, 
blockId));
    +      // Reset transferred block size metrics as zero
    +      final Timer.Context responseDelayContext = 
metrics.openBlockRequestLatencyMillis.time();
    +      try {
    +        OpenBlocks msg = (OpenBlocks) msgObj;
    +        checkAuth(client, msg.appId);
    +
    +        List<ManagedBuffer> blocks = Lists.newArrayList();
    +        long totalBlockSize = 0;
    +        for (String blockId : msg.blockIds) {
    +          final ManagedBuffer block = blockManager.getBlockData(msg.appId, 
msg.execId, blockId);
    +          totalBlockSize += block.size();
    +          blocks.add(block);
    +        }
    +        long streamId = streamManager.registerStream(client.getClientId(), 
blocks.iterator());
    +        logger.trace("Registered streamId {} with {} buffers for client {} 
from host {}",
    +                     streamId,
    +                     msg.blockIds.length,
    +                     client.getClientId(),
    +                     NettyUtils.getRemoteAddress(client.getChannel()));
    +        callback.onSuccess(new StreamHandle(streamId, 
msg.blockIds.length).toByteBuffer());
    +        metrics.blockTransferRateMBytes.mark(totalBlockSize / 1024 / 1024);
    +      } finally {
    +        responseDelayContext.stop();
           }
    -      long streamId = streamManager.registerStream(client.getClientId(), 
blocks.iterator());
    -      logger.trace("Registered streamId {} with {} buffers for client {} 
from host {}",
    -          streamId,
    -          msg.blockIds.length,
    -          client.getClientId(),
    -          NettyUtils.getRemoteAddress(client.getChannel()));
    -      callback.onSuccess(new StreamHandle(streamId, 
msg.blockIds.length).toByteBuffer());
     
         } else if (msgObj instanceof RegisterExecutor) {
    -      RegisterExecutor msg = (RegisterExecutor) msgObj;
    -      checkAuth(client, msg.appId);
    -      blockManager.registerExecutor(msg.appId, msg.execId, 
msg.executorInfo);
    -      callback.onSuccess(ByteBuffer.wrap(new byte[0]));
    +      final Timer.Context responseDelayContext = 
metrics.registerExecutorRequestLatencyMillis.time();
    +      try {
    +        RegisterExecutor msg = (RegisterExecutor) msgObj;
    +        checkAuth(client, msg.appId);
    +        blockManager.registerExecutor(msg.appId, msg.execId, 
msg.executorInfo);
    +        callback.onSuccess(ByteBuffer.wrap(new byte[0]));
    +      } finally {
    +        responseDelayContext.stop();
    +      }
     
         } else {
           throw new UnsupportedOperationException("Unexpected message: " + 
msgObj);
         }
       }
     
    +  public MetricSet getAllMetrics() {
    +    return metrics;
    +  }
    +
    +  public long getRegisteredExecutorsSize() {
    +    return blockManager.getRegisteredExecutorsSize();
    +  }
    +
    +  public long getTotalShuffleRequests() {
    --- End diff --
    
    Removed extra metrics.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to