/** * Registers a request for the block location. * If the location is already known, reply the location instantly. * * @param requestId the ID of the block location request. * @param messageContext the message context to reply. */ void registerRequest(final long requestId, final MessageContext messageContext) { final ControlMessage.BlockLocationInfoMsg.Builder infoMsgBuilder = ControlMessage.BlockLocationInfoMsg.newBuilder() .setRequestId(requestId) .setBlockId(blockIdOrWildcard); locationFuture.whenComplete((location, throwable) -> { if (throwable == null) { infoMsgBuilder.setOwnerExecutorId(location); } else { infoMsgBuilder.setState( convertBlockState(((AbsentBlockException) throwable).getState())); } messageContext.reply( ControlMessage.Message.newBuilder() .setId(RuntimeIdManager.generateMessageId()) .setListenerId(MessageEnvironment.EXECUTOR_MESSAGE_LISTENER_ID) .setType(ControlMessage.MessageType.BlockLocationInfo) .setBlockLocationInfoMsg(infoMsgBuilder.build()) .build()); }); }
/** * Registers a request for the block location. * If the location is already known, reply the location instantly. * * @param requestId the ID of the block location request. * @param messageContext the message context to reply. */ void registerRequest(final long requestId, final MessageContext messageContext) { final ControlMessage.BlockLocationInfoMsg.Builder infoMsgBuilder = ControlMessage.BlockLocationInfoMsg.newBuilder() .setRequestId(requestId) .setBlockId(blockIdOrWildcard); locationFuture.whenComplete((location, throwable) -> { if (throwable == null) { infoMsgBuilder.setOwnerExecutorId(location); } else { infoMsgBuilder.setState( convertBlockState(((AbsentBlockException) throwable).getState())); } messageContext.reply( ControlMessage.Message.newBuilder() .setId(RuntimeIdManager.generateMessageId()) .setListenerId(MessageEnvironment.EXECUTOR_MESSAGE_LISTENER_ID) .setType(ControlMessage.MessageType.BlockLocationInfo) .setBlockLocationInfoMsg(infoMsgBuilder.build()) .build()); }); }