Search in sources :

Example 1 with Connector

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

the class ExportManager method updateProcessorConfig.

private void updateProcessorConfig(final CatalogMap<Connector> connectors) {
    Map<String, Pair<Properties, Set<String>>> config = new HashMap<>();
    // If the export source changes before the previous generation drains
    // then the outstanding exports will go to the new source when export resumes.
    int connCount = 0;
    int tableCount = 0;
    for (Connector conn : connectors) {
        // skip disabled connectors
        if (!conn.getEnabled() || conn.getTableinfo().isEmpty()) {
            continue;
        }
        connCount++;
        Properties properties = new Properties();
        Set<String> tables = new HashSet<>();
        String targetName = conn.getTypeName();
        for (ConnectorTableInfo ti : conn.getTableinfo()) {
            tables.add(ti.getTable().getTypeName());
            tableCount++;
        }
        if (conn.getConfig() != null) {
            Iterator<ConnectorProperty> connPropIt = conn.getConfig().iterator();
            while (connPropIt.hasNext()) {
                ConnectorProperty prop = connPropIt.next();
                properties.put(prop.getName(), prop.getValue().trim());
                if (!prop.getName().toLowerCase().contains("password")) {
                    properties.put(prop.getName(), prop.getValue().trim());
                } else {
                    //Dont trim passwords
                    properties.put(prop.getName(), prop.getValue());
                }
            }
        }
        Pair<Properties, Set<String>> connConfig = new Pair<>(properties, tables);
        config.put(targetName, connConfig);
    }
    m_connCount = connCount;
    m_exportTablesCount = tableCount;
    m_processorConfig = config;
}
Also used : Connector(org.voltdb.catalog.Connector) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ConnectorProperty(org.voltdb.catalog.ConnectorProperty) Properties(java.util.Properties) ConnectorTableInfo(org.voltdb.catalog.ConnectorTableInfo) Pair(org.voltcore.utils.Pair) HashSet(java.util.HashSet)

Example 2 with Connector

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

the class TestVoltCompiler method checkRoleDDL.

private void checkRoleDDL(String ddl, String errorRegex, TestRole... roles) throws Exception {
    VoltCompiler compiler = new VoltCompiler(false);
    final boolean success = compileDDL(ddl, compiler);
    String error = (success || compiler.m_errors.size() == 0 ? "" : compiler.m_errors.get(compiler.m_errors.size() - 1).message);
    if (errorRegex == null) {
        assertTrue(String.format("Expected success\nDDL: %s\nERR: %s", ddl, error), success);
        Database db = compiler.getCatalog().getClusters().get("cluster").getDatabases().get("database");
        CatalogMap<Group> groups = db.getGroups();
        CatalogMap<Connector> connectors = db.getConnectors();
        if (connectors.get("0") == null) {
            connectors.add("0");
        }
        assertNotNull(groups);
        assertTrue(roles.length <= groups.size());
        for (TestRole role : roles) {
            Group group = groups.get(role.name);
            assertNotNull(String.format("Missing role \"%s\"", role.name), group);
            assertEquals(String.format("Role \"%s\" sql flag mismatch:", role.name), role.sql, group.getSql());
            assertEquals(String.format("Role \"%s\" sqlread flag mismatch:", role.name), role.sqlread, group.getSqlread());
            assertEquals(String.format("Role \"%s\" admin flag mismatch:", role.name), role.sysproc, group.getAdmin());
            assertEquals(String.format("Role \"%s\" defaultproc flag mismatch:", role.name), role.defaultproc, group.getDefaultproc());
            assertEquals(String.format("Role \"%s\" defaultprocread flag mismatch:", role.name), role.defaultprocread, group.getDefaultprocread());
            assertEquals(String.format("Role \"%s\" allproc flag mismatch:", role.name), role.allproc, group.getAllproc());
        }
    } else {
        assertFalse(String.format("Expected error (\"%s\")\n\nDDL: %s", errorRegex, ddl), success);
        assertFalse("Expected at least one error message.", error.isEmpty());
        Matcher m = Pattern.compile(errorRegex).matcher(error);
        assertTrue(String.format("%s\nEXPECTED: %s", error, errorRegex), m.matches());
    }
}
Also used : Group(org.voltdb.catalog.Group) Connector(org.voltdb.catalog.Connector) Matcher(java.util.regex.Matcher) Database(org.voltdb.catalog.Database)

Example 3 with Connector

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

the class TestVoltCompiler method testExportTableCase.

// test that Export configuration is insensitive to the case of the table name
public void testExportTableCase() throws IOException {
    if (!MiscUtils.isPro()) {
        return;
    }
    // not supported in community
    VoltProjectBuilder project = new VoltProjectBuilder();
    project.addSchema(TestVoltCompiler.class.getResource("ExportTester-ddl.sql"));
    project.addStmtProcedure("Dummy", "insert into a values (?, ?, ?);", "a.a_id: 0");
    project.addExport(true);
    try {
        assertTrue(project.compile("/tmp/exportsettingstest.jar"));
        String catalogContents = VoltCompilerUtils.readFileFromJarfile("/tmp/exportsettingstest.jar", "catalog.txt");
        Catalog cat = new Catalog();
        cat.execute(catalogContents);
        CatalogUtil.compileDeployment(cat, project.getPathToDeployment(), false);
        Connector connector = cat.getClusters().get("cluster").getDatabases().get("database").getConnectors().get(Constants.DEFAULT_EXPORT_CONNECTOR_NAME);
        assertTrue(connector.getEnabled());
        // Assert that all tables exist in the connector section of catalog
        assertNotNull(connector.getTableinfo().getIgnoreCase("a"));
        assertNotNull(connector.getTableinfo().getIgnoreCase("b"));
        assertNotNull(connector.getTableinfo().getIgnoreCase("e"));
        assertNotNull(connector.getTableinfo().getIgnoreCase("f"));
    } finally {
        File jar = new File("/tmp/exportsettingstest.jar");
        jar.delete();
    }
}
Also used : Connector(org.voltdb.catalog.Connector) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 4 with Connector

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

the class TestVoltCompiler method testExportSetting.

// TestExportSuite tests most of these options are tested end-to-end; however need to test
// that a disabled connector is really disabled and that auth data is correct.
public void testExportSetting() throws IOException {
    VoltProjectBuilder project = new VoltProjectBuilder();
    project.addSchema(getClass().getResource("ExportTester-ddl.sql"));
    project.addExport(false);
    try {
        assertTrue(project.compile("/tmp/exportsettingstest.jar"));
        String catalogContents = VoltCompilerUtils.readFileFromJarfile("/tmp/exportsettingstest.jar", "catalog.txt");
        Catalog cat = new Catalog();
        cat.execute(catalogContents);
        Connector connector = cat.getClusters().get("cluster").getDatabases().get("database").getConnectors().get(Constants.DEFAULT_EXPORT_CONNECTOR_NAME);
        assertFalse(connector.getEnabled());
    } finally {
        File jar = new File("/tmp/exportsettingstest.jar");
        jar.delete();
    }
}
Also used : Connector(org.voltdb.catalog.Connector) File(java.io.File) Catalog(org.voltdb.catalog.Catalog)

Example 5 with Connector

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

the class SystemInformation method populateDeploymentProperties.

public static VoltTable populateDeploymentProperties(Cluster cluster, Database database, ClusterSettings clusterSettings, NodeSettings nodeSettings) {
    VoltTable results = new VoltTable(clusterInfoSchema);
    // it would be awesome if these property names could come
    // from the RestApiDescription.xml (or the equivalent thereof) someday --izzy
    results.addRow("voltdbroot", VoltDB.instance().getVoltDBRootPath());
    Deployment deploy = cluster.getDeployment().get("deployment");
    results.addRow("hostcount", Integer.toString(clusterSettings.hostcount()));
    results.addRow("kfactor", Integer.toString(deploy.getKfactor()));
    results.addRow("sitesperhost", Integer.toString(nodeSettings.getLocalSitesCount()));
    String http_enabled = "false";
    int http_port = VoltDB.instance().getConfig().m_httpPort;
    if (http_port != -1 && http_port != Integer.MAX_VALUE) {
        http_enabled = "true";
        results.addRow("httpport", Integer.toString(http_port));
    }
    results.addRow("httpenabled", http_enabled);
    String json_enabled = "false";
    if (cluster.getJsonapi()) {
        json_enabled = "true";
    }
    results.addRow("jsonenabled", json_enabled);
    SnapshotSchedule snaps = database.getSnapshotschedule().get("default");
    String snap_enabled = "false";
    if (snaps != null && snaps.getEnabled()) {
        snap_enabled = "true";
        String snap_freq = Integer.toString(snaps.getFrequencyvalue()) + snaps.getFrequencyunit();
        results.addRow("snapshotpath", VoltDB.instance().getSnapshotPath());
        results.addRow("snapshotprefix", snaps.getPrefix());
        results.addRow("snapshotfrequency", snap_freq);
        results.addRow("snapshotretain", Integer.toString(snaps.getRetain()));
    }
    results.addRow("snapshotenabled", snap_enabled);
    for (Connector export_conn : database.getConnectors()) {
        if (export_conn != null && export_conn.getEnabled()) {
            results.addRow("exportoverflowpath", VoltDB.instance().getExportOverflowPath());
            break;
        }
    }
    results.addRow("export", Boolean.toString(CatalogUtil.isExportEnabled()));
    String partition_detect_enabled = "false";
    if (cluster.getNetworkpartition()) {
        partition_detect_enabled = "true";
    }
    results.addRow("partitiondetection", partition_detect_enabled);
    results.addRow("heartbeattimeout", Integer.toString(cluster.getHeartbeattimeout()));
    results.addRow("adminport", Integer.toString(VoltDB.instance().getConfig().m_adminPort));
    String command_log_enabled = "false";
    // log name is MAGIC, you knoooow
    CommandLog command_log = cluster.getLogconfig().get("log");
    if (command_log.getEnabled()) {
        command_log_enabled = "true";
        String command_log_mode = "async";
        if (command_log.getSynchronous()) {
            command_log_mode = "sync";
        }
        String command_log_path = VoltDB.instance().getCommandLogPath();
        String command_log_snaps = VoltDB.instance().getCommandLogSnapshotPath();
        String command_log_fsync_interval = Integer.toString(command_log.getFsyncinterval());
        String command_log_max_txns = Integer.toString(command_log.getMaxtxns());
        results.addRow("commandlogmode", command_log_mode);
        results.addRow("commandlogfreqtime", command_log_fsync_interval);
        results.addRow("commandlogfreqtxns", command_log_max_txns);
        results.addRow("commandlogpath", command_log_path);
        results.addRow("commandlogsnapshotpath", command_log_snaps);
    }
    results.addRow("commandlogenabled", command_log_enabled);
    String users = "";
    for (User user : database.getUsers()) {
        users += addEscapes(user.getTypeName());
        if (user.getGroups() != null && user.getGroups().size() > 0) {
            users += ":";
            for (GroupRef gref : user.getGroups()) {
                users += addEscapes(gref.getGroup().getTypeName());
                users += ",";
            }
            users = users.substring(0, users.length() - 1);
        }
        users += ";";
    }
    results.addRow("users", users);
    // Add system setting information also
    // the attribute names follows the above naming rule
    Systemsettings sysSettings = deploy.getSystemsettings().get("systemsettings");
    results.addRow("elasticduration", Integer.toString(sysSettings.getElasticduration()));
    results.addRow("elasticthroughput", Integer.toString(sysSettings.getElasticthroughput()));
    results.addRow("snapshotpriority", Integer.toString(sysSettings.getSnapshotpriority()));
    results.addRow("temptablesmaxsize", Integer.toString(sysSettings.getTemptablemaxsize()));
    results.addRow("querytimeout", Integer.toString(sysSettings.getQuerytimeout()));
    return results;
}
Also used : Connector(org.voltdb.catalog.Connector) User(org.voltdb.catalog.User) Systemsettings(org.voltdb.catalog.Systemsettings) CommandLog(org.voltdb.catalog.CommandLog) Deployment(org.voltdb.catalog.Deployment) SnapshotSchedule(org.voltdb.catalog.SnapshotSchedule) GroupRef(org.voltdb.catalog.GroupRef) VoltTable(org.voltdb.VoltTable)

Aggregations

Connector (org.voltdb.catalog.Connector)7 File (java.io.File)3 HashSet (java.util.HashSet)2 Catalog (org.voltdb.catalog.Catalog)2 ConnectorTableInfo (org.voltdb.catalog.ConnectorTableInfo)2 Database (org.voltdb.catalog.Database)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Matcher (java.util.regex.Matcher)1 Pair (org.voltcore.utils.Pair)1 VoltTable (org.voltdb.VoltTable)1 Cluster (org.voltdb.catalog.Cluster)1 CommandLog (org.voltdb.catalog.CommandLog)1 ConnectorProperty (org.voltdb.catalog.ConnectorProperty)1 Deployment (org.voltdb.catalog.Deployment)1 Group (org.voltdb.catalog.Group)1