public void run(UniqueId viewDefId,
List<MarketDataSpecification> marketDataSpecs,
boolean batchMode,
ViewResultListener listener,
ViewProcessor viewProcessor) {
ViewClient viewClient = viewProcessor.createViewClient(UserPrincipal.getTestUser());
try {
Set<DistinctMarketDataSelector> allSelectors = allSelectors();
ViewCycleExecutionOptions baseOptions =
ViewCycleExecutionOptions
.builder()
.setMarketDataSpecifications(marketDataSpecs)
.setMarketDataSelector(CompositeMarketDataSelector.of(allSelectors))
.create();
List<ViewCycleExecutionOptions> cycleOptions = cycleExecutionOptions(baseOptions, allSelectors);
ViewCycleExecutionSequence sequence = new ArbitraryViewCycleExecutionSequence(cycleOptions);
EnumSet<ViewExecutionFlags> executionFlags = ExecutionFlags.none().awaitMarketData().runAsFastAsPossible().get();
ViewExecutionOptions executionOptions;
if (listener != null) {
viewClient.setResultListener(listener);
}
if (batchMode) {
executionOptions = ExecutionOptions.batch(sequence, baseOptions);
} else if (listener != null) {
executionOptions = ExecutionOptions.of(sequence, executionFlags);
} else {
s_logger.warn("Not running in batch mode and no listener specified, the results would be ignored. Exiting.");
return;
}
s_logger.info("Attaching to view process, view def ID {}, execution options {}", viewDefId, executionOptions);
viewClient.attachToViewProcess(viewDefId, executionOptions, true);
try {
viewClient.waitForCompletion();
} catch (InterruptedException e) {
s_logger.warn("Interrupted waiting for ViewClient to complete", e);
}
} finally {
viewClient.shutdown();
}
}