Skip to content

Commit ad85725

Browse files
committed
reorder initialization of CompletionTimeService and WorkloadRunner - correctness depends on the order of their creation... because I'm an idiot
1 parent 41491e2 commit ad85725

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

src/main/java/com/ldbc/driver/Client.java

+26-22
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,32 @@ private void doInit(boolean warmup) throws ClientException {
373373
String.format("Error while instantiating Completion Time Service with peer IDs %s", controlService.configuration().peerIds().toString()), e);
374374
}
375375

376+
// ========================
377+
// === Workload Runner ==
378+
// ========================
379+
logger.info(String.format("Instantiating %s", WorkloadRunner.class.getSimpleName()));
380+
try {
381+
int operationHandlerExecutorsBoundedQueueSize = DefaultQueues.DEFAULT_BOUND_1000;
382+
workloadRunner = new WorkloadRunner(
383+
timeSource,
384+
database,
385+
timeMappedWorkloadStreams,
386+
metricsService,
387+
errorReporter,
388+
completionTimeService,
389+
controlService.configuration().threadCount(),
390+
controlService.configuration().statusDisplayIntervalAsSeconds(),
391+
controlService.configuration().spinnerSleepDurationAsMilli(),
392+
controlService.configuration().ignoreScheduledStartTimes(),
393+
operationHandlerExecutorsBoundedQueueSize);
394+
} catch (Exception e) {
395+
throw new ClientException(String.format("Error instantiating %s", WorkloadRunner.class.getSimpleName()), e);
396+
}
397+
398+
// ===========================================
399+
// === Initialize Completion Time Service ==
400+
// ===========================================
401+
// TODO note, this MUST be done after creation of Workload Runner because Workload Runner creates the "writers" for completion time service (refactor this mess at some stage)
376402
try {
377403
if (completionTimeService.getAllWriters().isEmpty()) {
378404
// There are no local completion time writers, GCT would never advance or be non-null, set to max so nothing ever waits on it
@@ -409,28 +435,6 @@ private void doInit(boolean warmup) throws ClientException {
409435
} catch (CompletionTimeException e) {
410436
throw new ClientException("Error while writing initial initiated and completed times to Completion Time Service", e);
411437
}
412-
413-
// ========================
414-
// === Workload Runner ==
415-
// ========================
416-
logger.info(String.format("Instantiating %s", WorkloadRunner.class.getSimpleName()));
417-
try {
418-
int operationHandlerExecutorsBoundedQueueSize = DefaultQueues.DEFAULT_BOUND_1000;
419-
workloadRunner = new WorkloadRunner(
420-
timeSource,
421-
database,
422-
timeMappedWorkloadStreams,
423-
metricsService,
424-
errorReporter,
425-
completionTimeService,
426-
controlService.configuration().threadCount(),
427-
controlService.configuration().statusDisplayIntervalAsSeconds(),
428-
controlService.configuration().spinnerSleepDurationAsMilli(),
429-
controlService.configuration().ignoreScheduledStartTimes(),
430-
operationHandlerExecutorsBoundedQueueSize);
431-
} catch (Exception e) {
432-
throw new ClientException(String.format("Error instantiating %s", WorkloadRunner.class.getSimpleName()), e);
433-
}
434438
}
435439

436440
private void doExecute(boolean warmup) throws ClientException {

0 commit comments

Comments
 (0)