Search in sources :

Example 31 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompilerAlterDropTable method verifyTableColumnSize.

//Check given col size
private void verifyTableColumnSize(VoltCompiler compiler, String tableName, String colName, int sz) {
    Database db = compiler.m_catalog.getClusters().get("cluster").getDatabases().get("database");
    Table table = db.getTables().get(tableName);
    Column col = table.getColumns().get(colName);
    assertNotNull(col);
    assertEquals(sz, col.getSize());
}
Also used : Table(org.voltdb.catalog.Table) Column(org.voltdb.catalog.Column) Database(org.voltdb.catalog.Database)

Example 32 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class TestVoltCompilerAlterDropTable method verifyIndexGone.

//Check given index exists
private void verifyIndexGone(VoltCompiler compiler, String tableName, String idxName) {
    Database db = compiler.m_catalog.getClusters().get("cluster").getDatabases().get("database");
    Table table = db.getTables().get(tableName);
    if (table == null) {
        //Index must be gone.
        return;
    }
    Index idx = table.getIndexes().get(idxName);
    assertNull(idx);
}
Also used : Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) Index(org.voltdb.catalog.Index)

Example 33 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class CatalogUtil method setSecurityEnabled.

/**
     * Set the security setting in the catalog from the deployment file
     * @param catalog the catalog to be updated
     * @param security security element of the deployment xml
     */
private static void setSecurityEnabled(Catalog catalog, SecurityType security) {
    Cluster cluster = catalog.getClusters().get("cluster");
    Database database = cluster.getDatabases().get("database");
    cluster.setSecurityenabled(security.isEnabled());
    database.setSecurityprovider(security.getProvider().value());
}
Also used : Database(org.voltdb.catalog.Database) Cluster(org.voltdb.catalog.Cluster)

Example 34 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class SnapshotSiteProcessor method populateSequenceNumbersForExecutionSite.

/*
     * Synchronization is handled by SnapshotSaveAPI.startSnapshotting
     * Store the export sequence numbers for every table and partition. This will
     * be called by every execution site before the snapshot starts. Then the execution
     * site that gets the setup permit will  use getExportSequenceNumbers to retrieve the full
     * set and reset the contents.
     */
public static void populateSequenceNumbersForExecutionSite(SystemProcedureExecutionContext context) {
    Database database = context.getDatabase();
    for (Table t : database.getTables()) {
        if (!CatalogUtil.isTableExportOnly(database, t))
            continue;
        Map<Integer, Pair<Long, Long>> sequenceNumbers = m_exportSequenceNumbers.get(t.getTypeName());
        if (sequenceNumbers == null) {
            sequenceNumbers = new HashMap<Integer, Pair<Long, Long>>();
            m_exportSequenceNumbers.put(t.getTypeName(), sequenceNumbers);
        }
        long[] ackOffSetAndSequenceNumber = context.getSiteProcedureConnection().getUSOForExportTable(t.getSignature());
        sequenceNumbers.put(context.getPartitionId(), Pair.of(ackOffSetAndSequenceNumber[0], ackOffSetAndSequenceNumber[1]));
    }
    TupleStreamStateInfo drStateInfo = context.getSiteProcedureConnection().getDRTupleStreamStateInfo();
    m_drTupleStreamInfo.put(context.getPartitionId(), drStateInfo);
    if (drStateInfo.containsReplicatedStreamInfo) {
        m_drTupleStreamInfo.put(MpInitiator.MP_INIT_PID, drStateInfo);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) Pair(org.voltcore.utils.Pair)

Example 35 with Database

use of org.voltdb.catalog.Database in project voltdb by VoltDB.

the class AdHocNTBase method processExplainDefaultProc.

/**
     * Explain Proc for a default proc is routed through the regular Explain
     * path using ad hoc planning and all. Take the result from that async
     * process and format it like other explains for procedures.
     */
static CompletableFuture<ClientResponse> processExplainDefaultProc(AdHocPlannedStmtBatch planBatch) {
    Database db = VoltDB.instance().getCatalogContext().database;
    // from a default procedure
    assert (planBatch.getPlannedStatementCount() == 1);
    AdHocPlannedStatement ahps = planBatch.getPlannedStatement(0);
    String sql = new String(ahps.sql, StandardCharsets.UTF_8);
    String explain = planBatch.explainStatement(0, db);
    VoltTable vt = new VoltTable(new VoltTable.ColumnInfo("SQL_STATEMENT", VoltType.STRING), new VoltTable.ColumnInfo("EXECUTION_PLAN", VoltType.STRING));
    vt.addRow(sql, explain);
    ClientResponseImpl response = new ClientResponseImpl(ClientResponseImpl.SUCCESS, ClientResponse.UNINITIALIZED_APP_STATUS_CODE, null, new VoltTable[] { vt }, null);
    CompletableFuture<ClientResponse> fut = new CompletableFuture<>();
    fut.complete(response);
    return fut;
}
Also used : ClientResponse(org.voltdb.client.ClientResponse) CompletableFuture(java.util.concurrent.CompletableFuture) AdHocPlannedStatement(org.voltdb.compiler.AdHocPlannedStatement) Database(org.voltdb.catalog.Database) ClientResponseImpl(org.voltdb.ClientResponseImpl) VoltTable(org.voltdb.VoltTable)

Aggregations

Database (org.voltdb.catalog.Database)62 Table (org.voltdb.catalog.Table)22 Catalog (org.voltdb.catalog.Catalog)12 Cluster (org.voltdb.catalog.Cluster)10 File (java.io.File)9 Column (org.voltdb.catalog.Column)9 Procedure (org.voltdb.catalog.Procedure)9 IOException (java.io.IOException)5 VoltTable (org.voltdb.VoltTable)5 ArrayList (java.util.ArrayList)4 Group (org.voltdb.catalog.Group)4 Connector (org.voltdb.catalog.Connector)3 Constraint (org.voltdb.catalog.Constraint)3 Statement (org.voltdb.catalog.Statement)3 FileNotFoundException (java.io.FileNotFoundException)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 HashMap (java.util.HashMap)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 JAXBException (javax.xml.bind.JAXBException)2