Skip to content

Commit 71c90f3

Browse files
committed
HPCC4J-680 DFSClient: FileUtility.ReadTest track individual file read times
- Added ability to have child operations to FileUtility TaskOperation - Created child operations for individual file parts during read tests Signed-off-by: James McMullan [email protected]
1 parent 4d096d6 commit 71c90f3

File tree

1 file changed

+74
-12
lines changed

1 file changed

+74
-12
lines changed

dfsclient/src/main/java/org/hpccsystems/dfs/client/FileUtility.java

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,14 @@ private static class TaskContext
8484
{
8585
private static class TaskOperation
8686
{
87-
public String currentOperationDesc = "";
87+
public String operationDesc = "";
8888
public long operationStartNS = 0;
89+
public long operationEndNS = 0;
8990

91+
public boolean isActive = true;
92+
public boolean success = false;
93+
94+
private List<TaskOperation> childOperations = new ArrayList<TaskOperation>();
9095

9196
public List<String> errorMessages = new ArrayList<String>();
9297
public List<String> warnMessages = new ArrayList<String>();
@@ -99,29 +104,61 @@ private static class TaskOperation
99104

100105
public Span operationSpan = null;
101106

102-
public JSONObject end(boolean success)
107+
public void addChildOperation(TaskOperation op)
103108
{
104-
if (success)
109+
synchronized(childOperations)
105110
{
106-
operationSpan.setStatus(StatusCode.OK);
111+
childOperations.add(op);
107112
}
108-
else
113+
}
114+
115+
public JSONObject end(boolean _success)
116+
{
117+
if (isActive)
109118
{
110-
operationSpan.setStatus(StatusCode.ERROR);
111-
}
119+
success = _success;
120+
if (operationSpan != null)
121+
{
122+
if (success)
123+
{
124+
operationSpan.setStatus(StatusCode.OK);
125+
}
126+
else
127+
{
128+
operationSpan.setStatus(StatusCode.ERROR);
129+
}
112130

113-
operationSpan.end();
131+
operationSpan.end();
132+
}
114133

115-
long totalOperationTime = System.nanoTime();
116-
totalOperationTime -= operationStartNS;
134+
operationEndNS = System.nanoTime();
117135

136+
isActive = false;
137+
}
138+
139+
long totalOperationTime = operationEndNS - operationStartNS;
118140
double timeInSeconds = (double) totalOperationTime / 1_000_000_000.0;
119141

120142
JSONObject results = new JSONObject();
121143

122-
results.put("operation", currentOperationDesc);
144+
results.put("operation", operationDesc);
123145
results.put("successful", success);
124146

147+
JSONArray childResults = new JSONArray();
148+
synchronized(childOperations)
149+
{
150+
for (TaskOperation childOp : childOperations)
151+
{
152+
if (childOp.isActive)
153+
{
154+
warnMessages.add("Child operation: " + childOp.operationDesc + " did not complete.");
155+
}
156+
157+
childResults.put(childOp.end(success));
158+
}
159+
}
160+
results.put("childOperations", childResults);
161+
125162
JSONArray errors = new JSONArray();
126163
for (String err : errorMessages)
127164
{
@@ -289,7 +326,7 @@ private void setCurrentOperation(TaskOperation op)
289326
public void startOperation(String operationName)
290327
{
291328
TaskOperation op = new TaskOperation();
292-
op.currentOperationDesc = operationName;
329+
op.operationDesc = operationName;
293330
op.operationStartNS = System.nanoTime();
294331

295332
Span parentSpan = null;
@@ -303,6 +340,23 @@ public void startOperation(String operationName)
303340
setCurrentOperation(op);
304341
}
305342

343+
public TaskOperation startChildOperation(String operationName)
344+
{
345+
if (!hasCurrentOperation())
346+
{
347+
return null;
348+
}
349+
350+
TaskOperation parentOp = getCurrentOperation();
351+
352+
TaskOperation childOp = new TaskOperation();
353+
childOp.operationDesc = operationName;
354+
childOp.operationStartNS = System.nanoTime();
355+
356+
parentOp.addChildOperation(childOp);
357+
return childOp;
358+
}
359+
306360
public void endOperation()
307361
{
308362
endOperation(true);
@@ -954,6 +1008,8 @@ public void run()
9541008
{
9551009
try
9561010
{
1011+
TaskContext.TaskOperation fileReadOperation = context.startChildOperation("File Part: " + filePart.getThisPart());
1012+
9571013
HpccRemoteFileReader.FileReadContext readContext = new HpccRemoteFileReader.FileReadContext();
9581014
readContext.parentSpan = context.getCurrentOperation().operationSpan;
9591015
readContext.originalRD = recordDef;
@@ -971,10 +1027,16 @@ public void run()
9711027
HPCCRecord record = fileReader.next();
9721028
recCount++;
9731029
}
1030+
1031+
fileReadOperation.recordsRead.addAndGet(recCount);
9741032
context.getCurrentOperation().recordsRead.addAndGet(recCount);
9751033

9761034
fileReader.close();
1035+
1036+
fileReadOperation.bytesRead.addAndGet(fileReader.getStreamPosition());
9771037
context.getCurrentOperation().bytesRead.addAndGet(fileReader.getStreamPosition());
1038+
1039+
fileReadOperation.end(true);
9781040
}
9791041
catch (Exception e)
9801042
{

0 commit comments

Comments
 (0)