Skip to content
Permalink
Browse files

0003865: Improve logging readability and appropriate levels

  • Loading branch information...
erilong committed Jan 28, 2019
1 parent 17f380a commit 38f67a7273adca9f0a5fc761f0099e32f03ff09d
@@ -251,37 +251,31 @@ protected void sendAck(Node remote, Node local, NodeSecurity localSecurity,

Exception exception = null;
int statusCode = -1;
int numberOfStatusSendRetries = parameterService
.getInt(ParameterConstants.DATA_LOADER_NUM_OF_ACK_RETRIES);
int numberOfStatusSendRetries = parameterService.getInt(ParameterConstants.DATA_LOADER_NUM_OF_ACK_RETRIES);

for (int i = 0; i < numberOfStatusSendRetries && statusCode != HttpURLConnection.HTTP_OK; i++) {
try {
statusCode = transportManager.sendAcknowledgement(remote, list, local,
localSecurity.getNodePassword(), parameterService.getRegistrationUrl());
} catch (IOException ex) {
exception = ex;
} catch (RuntimeException ex) {
exception = ex;
exception = null;
} catch (Exception e) {
exception = e;
}
if (statusCode != HttpURLConnection.HTTP_OK) {
String message = String.format("Ack was not sent successfully on try number %s of %s.", i+1, numberOfStatusSendRetries);
if (statusCode > 0) {
message += String.format(" statusCode=%s", statusCode);
}
if (exception != null) {
log.warn(message, exception);
log.info(message + ": " + exception.getClass().getName() + ": " + exception.getMessage());
} else {
log.warn(message);
log.info(message);
}

if (i < numberOfStatusSendRetries - 1) {
AppUtils.sleep(parameterService
.getLong(ParameterConstants.DATA_LOADER_TIME_BETWEEN_ACK_RETRIES));
} else if (exception instanceof RuntimeException) {
throw (RuntimeException) exception;
} else if (exception instanceof IOException) {
throw (IOException) exception;
AppUtils.sleep(parameterService.getLong(ParameterConstants.DATA_LOADER_TIME_BETWEEN_ACK_RETRIES));
} else {
throw new IOException("Ack was not sent successfully. statusCode=" + statusCode);
log.warn("Ack was not sent successfully.");
}
}
}
@@ -2018,10 +2018,8 @@ public void execute(NodeCommunication nodeCommunication, RemoteNodeStatus status
}
Node identity = nodeService.findIdentity();
Node targetNode = nodeService.findNode(nodeCommunication.getNodeId(), true);
log.info(
"Extracting batches for request {}. Starting at batch {}. Ending at batch {}",
new Object[] { request.getRequestId(), request.getStartBatchId(),
request.getEndBatchId() });
log.info("Begin extracting table {} request {} batches {} through {}.",
new Object[] { request.getTableName(), request.getRequestId(), request.getStartBatchId(), request.getEndBatchId() });
List<OutgoingBatch> batches = outgoingBatchService.getOutgoingBatchRange(
request.getStartBatchId(), request.getEndBatchId()).getBatches();

@@ -2075,8 +2073,8 @@ public void execute(NodeCommunication nodeCommunication, RemoteNodeStatus status

checkSendDeferredConstraints(request, targetNode, firstBatch);
} else {
log.info("Batches already had an OK status for request {}, batches {} to {}. Not extracting", new Object[] { request.getRequestId(), request.getStartBatchId(),
request.getEndBatchId() });
log.info("Batches already had an OK status for table {} request {} batches {} through {}. Not extracting",
new Object[] { request.getTableName(), request.getRequestId(), request.getStartBatchId(), request.getEndBatchId() });
}

/*
@@ -2109,7 +2107,8 @@ public void execute(NodeCommunication nodeCommunication, RemoteNodeStatus status
}
}
transaction.commit();
log.info("Done extracting {} batches for request {}", (request.getEndBatchId() - request.getStartBatchId()) + 1, request.getRequestId());
log.info("Done extracting table {} request {} batches {} through {}",
request.getTableName(), request.getRequestId(), request.getStartBatchId(), request.getEndBatchId());
} catch (Error ex) {
if (transaction != null) {
transaction.rollback();
@@ -2128,15 +2127,12 @@ public void execute(NodeCommunication nodeCommunication, RemoteNodeStatus status
processInfo.setStatus(ProcessInfo.ProcessStatus.OK);

} catch (CancellationException ex) {
log.info("Interrupted extract request {} for table {} batches {} through {}",
new Object[] { request.getRequestId(), request.getTableName(), request.getStartBatchId(),
request.getEndBatchId() });
log.info("Interrupted extract for table {} request {} batches {} through {}",
new Object[] { request.getTableName(), request.getRequestId(), request.getStartBatchId(), request.getEndBatchId() });
processInfo.setStatus(ProcessInfo.ProcessStatus.OK);
} catch (RuntimeException ex) {
log.warn(
"Failed to extract batches for request {}. Starting at batch {}. Ending at batch {}",
new Object[] { request.getRequestId(), request.getStartBatchId(),
request.getEndBatchId() });
log.warn("Failed to extract batches for table {} request {} batches {} through {}",
new Object[] { request.getTableName(), request.getRequestId(), request.getStartBatchId(), request.getEndBatchId() });
processInfo.setStatus(ProcessInfo.ProcessStatus.ERROR);
List<OutgoingBatch> checkBatches = outgoingBatchService.getOutgoingBatchRange(
request.getStartBatchId(), request.getEndBatchId()).getBatches();
@@ -226,7 +226,7 @@ public boolean acquireIncomingBatch(IncomingBatch batch) {
batch.setLoadRowCount(existingBatch.getLoadRowCount());

existingBatch.setSkipCount(existingBatch.getSkipCount() + 1);
log.info("Skipping batch {}", batch.getNodeBatchId());
log.info("Skipping batch {} that was already loaded", batch.getNodeBatchId());
}
updateIncomingBatch(existingBatch);
}
@@ -197,9 +197,9 @@ public void write(CsvData data) {
}
if (System.currentTimeMillis() - ts > 60000) {
this.dataExtractorService.log.info(
"Request {} has been processing for {} seconds. BATCHES={}, ROWS={}, BYTES={}, RANGE={}-{}, CURRENT={}",
request.getRequestId(), (System.currentTimeMillis() - startTime) / 1000, finishedBatches.size(), rowCount, byteCount,
request.getStartBatchId(), request.getEndBatchId(), batch.getBatchId());
"Extracting table {} request {} for {} seconds, {} batches, {} rows, and {} bytes. Current batch {} of batches {} through {}.",
request.getTableName(), request.getRequestId(), (System.currentTimeMillis() - startTime) / 1000, finishedBatches.size(), rowCount, byteCount,
batch.getBatchId(), request.getStartBatchId(), request.getEndBatchId());
ts = System.currentTimeMillis();
}
}

0 comments on commit 38f67a7

Please sign in to comment.
You can’t perform that action at this time.