Search in sources :

Example 1 with Monitor

use of mondrian.server.monitor.Monitor in project mondrian by pentaho.

the class SqlStatementTest method setUp.

public void setUp() {
    monitor = mock(Monitor.class);
    srv = mock(MondrianServer.class);
    when(srv.getMonitor()).thenReturn(monitor);
    rolapConnection = mock(RolapConnection.class);
    when(rolapConnection.getServer()).thenReturn(srv);
    statMock = mock(StatementImpl.class);
    when(statMock.getMondrianConnection()).thenReturn(rolapConnection);
    execution = new Execution(statMock, 0);
    execution = spy(execution);
    doThrow(MondrianResource.instance().QueryCanceled.ex()).when(execution).checkCancelOrTimeout();
    locus = new Locus(execution, "component", "message");
    statement = new SqlStatement(null, "sql", null, 0, 0, locus, 0, 0, null);
    statement = spy(statement);
}
Also used : Monitor(mondrian.server.monitor.Monitor) MondrianServer(mondrian.olap.MondrianServer) Execution(mondrian.server.Execution) StatementImpl(mondrian.server.StatementImpl) Locus(mondrian.server.Locus)

Example 2 with Monitor

use of mondrian.server.monitor.Monitor 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);
}
Also used : ServerInfo(mondrian.server.monitor.ServerInfo) ArrayList(java.util.ArrayList) Monitor(mondrian.server.monitor.Monitor)

Aggregations

Monitor (mondrian.server.monitor.Monitor)2 ArrayList (java.util.ArrayList)1 MondrianServer (mondrian.olap.MondrianServer)1 Execution (mondrian.server.Execution)1 Locus (mondrian.server.Locus)1 StatementImpl (mondrian.server.StatementImpl)1 ServerInfo (mondrian.server.monitor.ServerInfo)1