use of alluxio.exception.status.InternalException in project alluxio by Alluxio.
the class RegisterStreamer method registerInternal.
private void registerInternal() throws InterruptedException, DeadlineExceededException, CancelledException, InternalException {
int iter = 0;
while (hasNext()) {
// Send a request when the master ACKs the previous one
LOG.debug("Worker {} - Acquiring one token to send the next batch", mWorkerId);
Instant start = Instant.now();
if (!mBucket.tryAcquire(mResponseTimeoutMs, TimeUnit.MILLISECONDS)) {
throw new DeadlineExceededException(String.format("No response from master for more than %dms during the stream!", mResponseTimeoutMs));
}
Instant end = Instant.now();
LOG.debug("Worker {} - master ACK received in {}ms, sending the next batch {}", mWorkerId, Duration.between(start, end).toMillis(), iter);
// Send the request
RegisterWorkerPRequest request = next();
mWorkerRequestObserver.onNext(request);
if (mFinishLatch.getCount() == 0) {
abort();
}
iter++;
}
// If the master side is closed before the client side, there is a problem
if (mFinishLatch.getCount() == 0) {
abort();
}
// Wait for all batches have been ACK-ed by the master before completing the client side
if (!mAckLatch.await(mResponseTimeoutMs * MAX_BATCHES_IN_FLIGHT, TimeUnit.MILLISECONDS)) {
long receivedCount = mBlockMapIterator.getBatchCount() - mAckLatch.getCount();
throw new DeadlineExceededException(String.format("All batches have been sent to the master but only received %d ACKs!", receivedCount));
}
LOG.info("Worker {} - All requests have been sent. Completing the client side.", mWorkerId);
mWorkerRequestObserver.onCompleted();
LOG.info("Worker {} - Waiting on the master side to complete", mWorkerId);
if (!mFinishLatch.await(mCompleteTimeoutMs, TimeUnit.MILLISECONDS)) {
throw new DeadlineExceededException(String.format("All batches have been received by the master but the master failed" + " to complete the registration in %dms!", mCompleteTimeoutMs));
}
// If the master failed in completing the request, there will also be an error
if (mError.get() != null) {
Throwable t = mError.get();
LOG.error("Worker {} - Received an error from the master on completion", mWorkerId, t);
throw new InternalException(t);
}
LOG.info("Worker {} - Finished registration with a stream", mWorkerId);
}
Aggregations