Search in sources :

Example 11 with Cluster

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

the class CatalogUtil method setHTTPDInfo.

private static void setHTTPDInfo(Catalog catalog, HttpdType httpd, SslType ssl) {
    Cluster cluster = catalog.getClusters().get("cluster");
    // set the catalog info
    int defaultPort = VoltDB.DEFAULT_HTTP_PORT;
    if (ssl != null && ssl.isEnabled()) {
        defaultPort = VoltDB.DEFAULT_HTTPS_PORT;
    }
    cluster.setHttpdportno(httpd.getPort() == null ? defaultPort : httpd.getPort());
    cluster.setJsonapi(httpd.getJsonapi().isEnabled());
}
Also used : Cluster(org.voltdb.catalog.Cluster) Constraint(org.voltdb.catalog.Constraint)

Example 12 with Cluster

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

the class RealVoltDB method readDeploymentAndCreateStarterCatalogContext.

boolean readDeploymentAndCreateStarterCatalogContext(VoltDB.Configuration config) {
    /*
         * Debate with the cluster what the deployment file should be
         */
    try {
        ZooKeeper zk = m_messenger.getZK();
        byte[] deploymentBytes = null;
        try {
            deploymentBytes = org.voltcore.utils.CoreUtils.urlToBytes(m_config.m_pathToDeployment);
        } catch (Exception ex) {
        //Let us get bytes from ZK
        }
        DeploymentType deployment = null;
        try {
            if (deploymentBytes != null) {
                CatalogUtil.writeCatalogToZK(zk, // Fill in innocuous values for non-deployment stuff
                0, 0L, 0L, // spin loop in Inits.LoadCatalog.run() needs
                new byte[] {}, // this to be of zero length until we have a real catalog.
                null, deploymentBytes);
                hostLog.info("URL of deployment: " + m_config.m_pathToDeployment);
            } else {
                CatalogAndIds catalogStuff = CatalogUtil.getCatalogFromZK(zk);
                deploymentBytes = catalogStuff.deploymentBytes;
            }
        } catch (KeeperException.NodeExistsException e) {
            CatalogAndIds catalogStuff = CatalogUtil.getCatalogFromZK(zk);
            byte[] deploymentBytesTemp = catalogStuff.deploymentBytes;
            if (deploymentBytesTemp != null) {
                //We will ignore the supplied or default deployment anyways.
                if (deploymentBytes != null && !m_config.m_deploymentDefault) {
                    byte[] deploymentHashHere = CatalogUtil.makeDeploymentHash(deploymentBytes);
                    if (!(Arrays.equals(deploymentHashHere, catalogStuff.getDeploymentHash()))) {
                        hostLog.warn("The locally provided deployment configuration did not " + " match the configuration information found in the cluster.");
                    } else {
                        hostLog.info("Deployment configuration pulled from other cluster node.");
                    }
                }
                //Use remote deployment obtained.
                deploymentBytes = deploymentBytesTemp;
            } else {
                hostLog.error("Deployment file could not be loaded locally or remotely, " + "local supplied path: " + m_config.m_pathToDeployment);
                deploymentBytes = null;
            }
        } catch (KeeperException.NoNodeException e) {
            // no deploymentBytes case is handled below. So just log this error.
            if (hostLog.isDebugEnabled()) {
                hostLog.debug("Error trying to get deployment bytes from cluster", e);
            }
        }
        if (deploymentBytes == null) {
            hostLog.error("Deployment information could not be obtained from cluster node or locally");
            VoltDB.crashLocalVoltDB("No such deployment file: " + m_config.m_pathToDeployment, false, null);
        }
        if (deployment == null) {
            deployment = CatalogUtil.getDeployment(new ByteArrayInputStream(deploymentBytes));
        }
        // wasn't a valid xml deployment file
        if (deployment == null) {
            hostLog.error("Not a valid XML deployment file at URL: " + m_config.m_pathToDeployment);
            VoltDB.crashLocalVoltDB("Not a valid XML deployment file at URL: " + m_config.m_pathToDeployment, false, null);
        }
        /*
             * Check for invalid deployment file settings (enterprise-only) in the community edition.
             * Trick here is to print out all applicable problems and then stop, rather than stopping
             * after the first one is found.
             */
        if (!m_config.m_isEnterprise) {
            boolean shutdownDeployment = false;
            boolean shutdownAction = false;
            // check license features for community version
            if ((deployment.getCluster() != null) && (deployment.getCluster().getKfactor() > 0)) {
                consoleLog.error("K-Safety is not supported " + "in the community edition of VoltDB.");
                shutdownDeployment = true;
            }
            if ((deployment.getSnapshot() != null) && (deployment.getSnapshot().isEnabled())) {
                consoleLog.error("Snapshots are not supported " + "in the community edition of VoltDB.");
                shutdownDeployment = true;
            }
            if ((deployment.getCommandlog() != null) && (deployment.getCommandlog().isEnabled())) {
                consoleLog.error("Command logging is not supported " + "in the community edition of VoltDB.");
                shutdownDeployment = true;
            }
            if ((deployment.getExport() != null) && deployment.getExport().getConfiguration() != null && !deployment.getExport().getConfiguration().isEmpty()) {
                consoleLog.error("Export is not supported " + "in the community edition of VoltDB.");
                shutdownDeployment = true;
            }
            // check the start action for the community edition
            if (m_config.m_startAction != StartAction.CREATE) {
                consoleLog.error("Start action \"" + m_config.m_startAction.getClass().getSimpleName() + "\" is not supported in the community edition of VoltDB.");
                shutdownAction = true;
            }
            // if the process needs to stop, try to be helpful
            if (shutdownAction || shutdownDeployment) {
                String msg = "This process will exit. Please run VoltDB with ";
                if (shutdownDeployment) {
                    msg += "a deployment file compatible with the community edition";
                }
                if (shutdownDeployment && shutdownAction) {
                    msg += " and ";
                }
                if (shutdownAction && !shutdownDeployment) {
                    msg += "the CREATE start action";
                }
                msg += ".";
                VoltDB.crashLocalVoltDB(msg, false, null);
            }
        }
        // note the heart beats are specified in seconds in xml, but ms internally
        HeartbeatType hbt = deployment.getHeartbeat();
        if (hbt != null) {
            m_config.m_deadHostTimeoutMS = hbt.getTimeout() * 1000;
            m_messenger.setDeadHostTimeout(m_config.m_deadHostTimeoutMS);
        } else {
            hostLog.info("Dead host timeout set to " + m_config.m_deadHostTimeoutMS + " milliseconds");
        }
        PartitionDetectionType pt = deployment.getPartitionDetection();
        if (pt != null) {
            m_config.m_partitionDetectionEnabled = pt.isEnabled();
            m_messenger.setPartitionDetectionEnabled(m_config.m_partitionDetectionEnabled);
        }
        // get any consistency settings into config
        ConsistencyType consistencyType = deployment.getConsistency();
        if (consistencyType != null) {
            m_config.m_consistencyReadLevel = Consistency.ReadLevel.fromReadLevelType(consistencyType.getReadlevel());
        }
        final String elasticSetting = deployment.getCluster().getElastic().trim().toUpperCase();
        if (elasticSetting.equals("ENABLED")) {
            TheHashinator.setConfiguredHashinatorType(HashinatorType.ELASTIC);
        } else if (!elasticSetting.equals("DISABLED")) {
            VoltDB.crashLocalVoltDB("Error in deployment file,  elastic attribute of " + "cluster element must be " + "'enabled' or 'disabled' but was '" + elasticSetting + "'", false, null);
        } else {
            TheHashinator.setConfiguredHashinatorType(HashinatorType.LEGACY);
        }
        // log system setting information
        SystemSettingsType sysType = deployment.getSystemsettings();
        if (sysType != null) {
            if (sysType.getElastic() != null) {
                hostLog.info("Elastic duration set to " + sysType.getElastic().getDuration() + " milliseconds");
                hostLog.info("Elastic throughput set to " + sysType.getElastic().getThroughput() + " mb/s");
            }
            if (sysType.getTemptables() != null) {
                hostLog.info("Max temptable size set to " + sysType.getTemptables().getMaxsize() + " mb");
            }
            if (sysType.getSnapshot() != null) {
                hostLog.info("Snapshot priority set to " + sysType.getSnapshot().getPriority() + " [0 - 10]");
            }
            if (sysType.getQuery() != null) {
                if (sysType.getQuery().getTimeout() > 0) {
                    hostLog.info("Query timeout set to " + sysType.getQuery().getTimeout() + " milliseconds");
                    m_config.m_queryTimeout = sysType.getQuery().getTimeout();
                } else if (sysType.getQuery().getTimeout() == 0) {
                    hostLog.info("Query timeout set to unlimited");
                    m_config.m_queryTimeout = 0;
                }
            }
        }
        // log a warning on console log if security setting is turned off, like durability warning.
        SecurityType securityType = deployment.getSecurity();
        if (securityType == null || !securityType.isEnabled()) {
            consoleLog.warn(SECURITY_OFF_WARNING);
        }
        // create a dummy catalog to load deployment info into
        Catalog catalog = new Catalog();
        // Need these in the dummy catalog
        Cluster cluster = catalog.getClusters().add("cluster");
        cluster.getDatabases().add("database");
        String result = CatalogUtil.compileDeployment(catalog, deployment, true);
        if (result != null) {
            // Any other non-enterprise deployment errors will be caught and handled here
            // (such as <= 0 host count)
            VoltDB.crashLocalVoltDB(result);
        }
        m_catalogContext = new CatalogContext(//txnid
        TxnEgo.makeZero(MpInitiator.MP_INIT_PID).getTxnId(), //timestamp
        0, catalog, new DbSettings(m_clusterSettings, m_nodeSettings), new byte[] {}, null, deploymentBytes, 0, m_messenger);
        return ((deployment.getCommandlog() != null) && (deployment.getCommandlog().isEnabled()));
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : CatalogAndIds(org.voltdb.utils.CatalogUtil.CatalogAndIds) SecurityType(org.voltdb.compiler.deploymentfile.SecurityType) Cluster(org.voltdb.catalog.Cluster) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) SocketException(java.net.SocketException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) JSONException(org.json_voltpatches.JSONException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) KeeperException(org.apache.zookeeper_voltpatches.KeeperException) SettingsException(org.voltdb.settings.SettingsException) Catalog(org.voltdb.catalog.Catalog) DbSettings(org.voltdb.settings.DbSettings) HeartbeatType(org.voltdb.compiler.deploymentfile.HeartbeatType) ConsistencyType(org.voltdb.compiler.deploymentfile.ConsistencyType) ZooKeeper(org.apache.zookeeper_voltpatches.ZooKeeper) SystemSettingsType(org.voltdb.compiler.deploymentfile.SystemSettingsType) ByteArrayInputStream(java.io.ByteArrayInputStream) PartitionDetectionType(org.voltdb.compiler.deploymentfile.PartitionDetectionType) KeeperException(org.apache.zookeeper_voltpatches.KeeperException)

Example 13 with Cluster

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

the class TestEELibraryLoader method testLoader.

@Test
public void testLoader() {
    VoltDB.Configuration configuration = new VoltDB.Configuration();
    configuration.m_noLoadLibVOLTDB = true;
    MockVoltDB mockvolt = new MockVoltDB();
    VoltDB.ignoreCrash = true;
    VoltDB.replaceVoltDBInstanceForTest(mockvolt);
    mockvolt.m_noLoadLib = true;
    assertFalse(EELibraryLoader.loadExecutionEngineLibrary(false));
    assertFalse(VoltDB.wasCrashCalled);
    boolean threw = false;
    try {
        assertFalse(EELibraryLoader.loadExecutionEngineLibrary(true));
    } catch (AssertionError ae) {
        threw = true;
    }
    assertTrue(threw);
    assertTrue(VoltDB.wasCrashCalled);
    VoltDB.wasCrashCalled = false;
    VoltDB.initialize(configuration);
    assertFalse(EELibraryLoader.loadExecutionEngineLibrary(true));
    assertFalse(VoltDB.wasCrashCalled);
    // Now test SUCCESS case
    configuration = new VoltDB.Configuration();
    VoltDBInterface mockitovolt = mock(VoltDBInterface.class);
    VoltDBInterface realvolt = new RealVoltDB();
    when(mockitovolt.getEELibraryVersionString()).thenReturn(realvolt.getEELibraryVersionString());
    CatalogContext catContext = mock(CatalogContext.class);
    Cluster cluster = mock(Cluster.class);
    when(catContext.getCluster()).thenReturn(cluster);
    when(mockitovolt.getCatalogContext()).thenReturn(catContext);
    VoltDB.replaceVoltDBInstanceForTest(mockitovolt);
    VoltDB.initialize(configuration);
    assertTrue(EELibraryLoader.loadExecutionEngineLibrary(true));
}
Also used : Cluster(org.voltdb.catalog.Cluster) Test(org.junit.Test)

Example 14 with Cluster

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

the class TestFragmentProgressUpdate method setUp.

@Override
protected void setUp() throws Exception {
    final int CLUSTER_ID = 2;
    final long NODE_ID = 1;
    super.setUp();
    VoltDB.instance().readBuildInfo("Test");
    m_warehousedata = new VoltTable(new VoltTable.ColumnInfo("W_ID", VoltType.SMALLINT), new VoltTable.ColumnInfo("W_NAME", VoltType.STRING), new VoltTable.ColumnInfo("W_STREET_1", VoltType.STRING), new VoltTable.ColumnInfo("W_STREET_2", VoltType.STRING), new VoltTable.ColumnInfo("W_CITY", VoltType.STRING), new VoltTable.ColumnInfo("W_STATE", VoltType.STRING), new VoltTable.ColumnInfo("W_ZIP", VoltType.STRING), new VoltTable.ColumnInfo("W_TAX", VoltType.FLOAT), new VoltTable.ColumnInfo("W_YTD", VoltType.FLOAT));
    m_itemData = new VoltTable(new VoltTable.ColumnInfo("I_ID", VoltType.INTEGER), new VoltTable.ColumnInfo("I_IM_ID", VoltType.INTEGER), new VoltTable.ColumnInfo("I_NAME", VoltType.STRING), new VoltTable.ColumnInfo("I_PRICE", VoltType.FLOAT), new VoltTable.ColumnInfo("I_DATA", VoltType.STRING));
    TPCCProjectBuilder builder = new TPCCProjectBuilder();
    m_catalog = builder.createTPCCSchemaCatalog();
    Cluster cluster = m_catalog.getClusters().get("cluster");
    WAREHOUSE_TABLEID = m_catalog.getClusters().get("cluster").getDatabases().get("database").getTables().get("WAREHOUSE").getRelativeIndex();
    ITEM_TABLEID = m_catalog.getClusters().get("cluster").getDatabases().get("database").getTables().get("ITEM").getRelativeIndex();
    CatalogMap<Procedure> procedures = cluster.getDatabases().get("database").getProcedures();
    m_testProc = procedures.getIgnoreCase("FragmentUpdateTestProcedure");
    m_ee = new ExecutionEngineJNI(CLUSTER_ID, NODE_ID, 0, 0, "", 0, 64 * 1024, 100, new HashinatorConfig(HashinatorType.LEGACY, LegacyHashinator.getConfigureBytes(1), 0, 0), false);
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) Cluster(org.voltdb.catalog.Cluster) Procedure(org.voltdb.catalog.Procedure) VoltTable(org.voltdb.VoltTable) TPCCProjectBuilder(org.voltdb.benchmark.tpcc.TPCCProjectBuilder)

Example 15 with Cluster

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

the class Site method loadTable.

@Override
public byte[] loadTable(long txnId, long spHandle, long uniqueId, String clusterName, String databaseName, String tableName, VoltTable data, boolean returnUniqueViolations, boolean shouldDRStream, boolean undo) throws VoltAbortException {
    Cluster cluster = m_context.cluster;
    if (cluster == null) {
        throw new VoltAbortException("cluster '" + clusterName + "' does not exist");
    }
    Database db = cluster.getDatabases().get(databaseName);
    if (db == null) {
        throw new VoltAbortException("database '" + databaseName + "' does not exist in cluster " + clusterName);
    }
    Table table = db.getTables().getIgnoreCase(tableName);
    if (table == null) {
        throw new VoltAbortException("table '" + tableName + "' does not exist in database " + clusterName + "." + databaseName);
    }
    return loadTable(txnId, spHandle, uniqueId, table.getRelativeIndex(), data, returnUniqueViolations, shouldDRStream, undo);
}
Also used : VoltTable(org.voltdb.VoltTable) Table(org.voltdb.catalog.Table) Database(org.voltdb.catalog.Database) Cluster(org.voltdb.catalog.Cluster) VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException)

Aggregations

Cluster (org.voltdb.catalog.Cluster)21 Database (org.voltdb.catalog.Database)10 File (java.io.File)9 IOException (java.io.IOException)4 Catalog (org.voltdb.catalog.Catalog)4 Constraint (org.voltdb.catalog.Constraint)4 VoltTable (org.voltdb.VoltTable)3 Table (org.voltdb.catalog.Table)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 Connector (org.voltdb.catalog.Connector)2 Procedure (org.voltdb.catalog.Procedure)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileWriter (java.io.FileWriter)1 SocketException (java.net.SocketException)1 URL (java.net.URL)1 DateFormat (java.text.DateFormat)1 Date (java.util.Date)1 Properties (java.util.Properties)1