Search in sources :

Example 16 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class SegmentLoader method load.

/**
 * Loads data for all the segments of the GroupingSets. If the grouping sets
 * list contains more than one Grouping Set then data is loaded using the
 * GROUP BY GROUPING SETS sql. Else if only one grouping set is passed in
 * the list data is loaded without using GROUP BY GROUPING SETS sql. If the
 * database does not support grouping sets
 * {@link mondrian.spi.Dialect#supportsGroupingSets()} then
 * grouping sets list should always have only one element in it.
 *
 * <p>For example, if list has 2 grouping sets with columns A, B, C and B, C
 * respectively, then the SQL will be
 * "GROUP BY GROUPING SETS ((A, B, C), (B, C))".
 *
 * <p>Else if the list has only one grouping set then sql would be without
 * grouping sets.
 *
 * <p>The <code>groupingSets</code> list should be topological order, with
 * more detailed higher-level grouping sets occurring first. In other words,
 * the first element of the list should always be the detailed grouping
 * set (default grouping set), followed by grouping sets which can be
 * rolled-up on this detailed grouping set.
 * In the example (A, B, C) is the detailed grouping set and (B, C) is
 * rolled-up using the detailed.
 *
 * <p>Grouping sets are removed from the {@code groupingSets} list as they
 * are loaded.</p>
 *
 * @param cellRequestCount Number of missed cells that led to this request
 * @param groupingSets   List of grouping sets whose segments are loaded
 * @param compoundPredicateList Compound predicates
 * @param segmentFutures List of futures wherein each statement will place
 *                       a list of the segments it has loaded, when it
 *                       completes
 */
public void load(int cellRequestCount, List<GroupingSet> groupingSets, List<StarPredicate> compoundPredicateList, List<Future<Map<Segment, SegmentWithData>>> segmentFutures) {
    if (!MondrianProperties.instance().DisableCaching.get()) {
        for (GroupingSet groupingSet : groupingSets) {
            for (Segment segment : groupingSet.getSegments()) {
                final SegmentCacheIndex index = cacheMgr.getIndexRegistry().getIndex(segment.star);
                index.add(segment.getHeader(), new SegmentBuilder.StarSegmentConverter(segment.measure, compoundPredicateList), true);
                // Make sure that we are registered as a client of
                // the segment by invoking getFuture.
                Util.discard(index.getFuture(Locus.peek().execution, segment.getHeader()));
            }
        }
    }
    try {
        segmentFutures.add(cacheMgr.sqlExecutor.submit(new SegmentLoadCommand(Locus.peek(), this, cellRequestCount, groupingSets, compoundPredicateList)));
    } catch (Exception e) {
        throw new MondrianException(e);
    }
}
Also used : SegmentCacheIndex(mondrian.rolap.cache.SegmentCacheIndex) MondrianException(mondrian.olap.MondrianException) AbortException(mondrian.rolap.agg.SegmentCacheManager.AbortException) SQLException(java.sql.SQLException) MondrianException(mondrian.olap.MondrianException)

Example 17 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class CodeSetTest method testSucces_CodeSetContainsCodeForBothPostgresAndPostgresqlDialects.

/**
 * ISSUE MONDRIAN-2335 If SqlQuery.CodeSet contains sql code
 * for both dialect="postgres" and dialect="postgresql",
 * the code for dialect="postgres"should be chosen. No error should be thrown
 *
 * @throws Exception
 */
public void testSucces_CodeSetContainsCodeForBothPostgresAndPostgresqlDialects() throws Exception {
    PostgreSqlDialect postgreSqlDialect = new PostgreSqlDialect(mockConnection(POSTGRESQL_PRODUCT_NAME, POSTGRESQL_PRODUCT_VERSION));
    codeSet = new SqlQuery.CodeSet();
    codeSet.put(POSTGRES_DIALECT, SQL_CODE_FOR_POSTGRES_DIALECT);
    codeSet.put(POSTGRESQL_DIALECT, SQL_CODE_FOR_POSTGRESQL_DIALECT);
    try {
        String chooseQuery = codeSet.chooseQuery(postgreSqlDialect);
        assertEquals(SQL_CODE_FOR_POSTGRES_DIALECT, chooseQuery);
    } catch (MondrianException mExc) {
        fail("Not expected any MondrianException but it occured: " + mExc.getLocalizedMessage());
    }
}
Also used : PostgreSqlDialect(mondrian.spi.impl.PostgreSqlDialect) MondrianException(mondrian.olap.MondrianException)

Example 18 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class SchemaVersionTest method testSchema4noVersion.

public void testSchema4noVersion() {
    TestContext testContext = TestContext.instance().withSchema(SCHEMA_4_NVHEADER + SCHEMA_4_BODY);
    Util.PropertyList connectInfo = testContext.getConnectionProperties();
    try {
        Connection conn = DriverManager.getConnection(connectInfo, null);
        conn.close();
        Assert.fail("No exception thrown for version 4 schema.");
    } catch (MondrianException e) {
        assertTrue(e.getMessage().contains("Schema version"));
    }
}
Also used : Connection(mondrian.olap.Connection) Util(mondrian.olap.Util) MondrianException(mondrian.olap.MondrianException)

Example 19 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class MondrianServerImpl method addStatement.

@Override
public synchronized void addStatement(Statement statement) {
    if (shutdown) {
        throw new MondrianException("Server already shutdown.");
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("addStatement " + ", id=" + id + ", statements=" + statementMap.size() + ", connections=" + connectionMap.size());
    }
    statementMap.put(statement.getId(), statement);
    final RolapConnection connection = statement.getMondrianConnection();
    monitor.sendEvent(new StatementStartEvent(System.currentTimeMillis(), connection.getServer().getId(), connection.getId(), statement.getId()));
}
Also used : RolapConnection(mondrian.rolap.RolapConnection) MondrianException(mondrian.olap.MondrianException)

Example 20 with MondrianException

use of mondrian.olap.MondrianException in project mondrian by pentaho.

the class MondrianServerImpl method removeStatement.

@Override
public synchronized void removeStatement(Statement statement) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("removeStatement " + ", id=" + id + ", statements=" + statementMap.size() + ", connections=" + connectionMap.size());
    }
    if (shutdown) {
        throw new MondrianException("Server already shutdown.");
    }
    statementMap.remove(statement.getId());
    final RolapConnection connection = statement.getMondrianConnection();
    monitor.sendEvent(new StatementEndEvent(System.currentTimeMillis(), connection.getServer().getId(), connection.getId(), statement.getId()));
}
Also used : RolapConnection(mondrian.rolap.RolapConnection) MondrianException(mondrian.olap.MondrianException)

Aggregations

MondrianException (mondrian.olap.MondrianException)23 Util (mondrian.olap.Util)5 PostgreSqlDialect (mondrian.spi.impl.PostgreSqlDialect)5 Connection (mondrian.olap.Connection)4 RolapConnection (mondrian.rolap.RolapConnection)4 SQLException (java.sql.SQLException)3 Test (org.junit.Test)3 IMondrianCatalogService (org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 Query (mondrian.olap.Query)2 AbortException (mondrian.rolap.agg.SegmentCacheManager.AbortException)2 SegmentCacheIndex (mondrian.rolap.cache.SegmentCacheIndex)2 Locus (mondrian.server.Locus)2 FileSystemException (org.apache.commons.vfs2.FileSystemException)2 XOMException (org.eigenbase.xom.XOMException)2