use of mondrian.server.monitor.ServerInfo in project mondrian by pentaho.
the class CacheTest method checkNQueriesWaitingForSameSegment.
private void checkNQueriesWaitingForSameSegment(ThreadPoolExecutor executor, int parallel, String iteration) throws InterruptedException, ExecutionException {
final MondrianServer server = MondrianServer.forConnection(getConnection());
final CacheControl cacheControl = getConnection().getCacheControl(null);
cacheControl.flush(cacheControl.createMeasuresRegion(getCubeWithName("Sales", getConnection().getSchema().getCubes())));
// wait for flush to propagate
Thread.sleep(2000);
final Monitor monitor = server.getMonitor();
final ServerInfo serverBefore = monitor.getServer();
final List<Future<Boolean>> futures = new ArrayList<Future<Boolean>>();
for (int i = 0; i < parallel; i++) {
Callable<Boolean> runnable = new Callable<Boolean>() {
public Boolean call() {
assertQueryReturns("select [Gender].Children * [Product].Children on 0\n" + "from [Sales]", "Axis #0:\n" + "{}\n" + "Axis #1:\n" + "{[Gender].[F], [Product].[Drink]}\n" + "{[Gender].[F], [Product].[Food]}\n" + "{[Gender].[F], [Product].[Non-Consumable]}\n" + "{[Gender].[M], [Product].[Drink]}\n" + "{[Gender].[M], [Product].[Food]}\n" + "{[Gender].[M], [Product].[Non-Consumable]}\n" + "Row #0: 12,202\n" + "Row #0: 94,814\n" + "Row #0: 24,542\n" + "Row #0: 12,395\n" + "Row #0: 97,126\n" + "Row #0: 25,694\n");
return true;
}
};
futures.add(executor.submit(runnable));
}
for (Future<Boolean> future : futures) {
assertTrue(future.get() == Boolean.TRUE);
}
final ServerInfo serverAfter = monitor.getServer();
final String beforeAfter = "before: " + serverBefore + "\n" + "after: " + serverAfter + "\n" + iteration;
assertTrue(beforeAfter, serverAfter.segmentCreateCount == serverBefore.segmentCreateCount + 1 && serverAfter.segmentCreateViaSqlCount == serverBefore.segmentCreateViaSqlCount + 1);
}
Aggregations