Search in sources :

Example 1 with Deployment

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

the class Site method initializeEE.

/** Create a native VoltDB execution engine */
ExecutionEngine initializeEE() {
    String hostname = CoreUtils.getHostnameOrAddress();
    HashinatorConfig hashinatorConfig = TheHashinator.getCurrentConfig();
    ExecutionEngine eeTemp = null;
    Deployment deploy = m_context.cluster.getDeployment().get("deployment");
    // 512KB
    final int defaultDrBufferSize = Integer.getInteger("DR_DEFAULT_BUFFER_SIZE", 512 * 1024);
    try {
        if (m_backend == BackendTarget.NATIVE_EE_JNI) {
            eeTemp = new ExecutionEngineJNI(m_context.cluster.getRelativeIndex(), m_siteId, m_partitionId, CoreUtils.getHostIdFromHSId(m_siteId), hostname, m_context.cluster.getDrclusterid(), defaultDrBufferSize, deploy.getSystemsettings().get("systemsettings").getTemptablemaxsize(), hashinatorConfig, m_hasMPDRGateway);
        } else if (m_backend == BackendTarget.NATIVE_EE_SPY_JNI) {
            Class<?> spyClass = Class.forName("org.mockito.Mockito");
            Method spyMethod = spyClass.getDeclaredMethod("spy", Object.class);
            ExecutionEngine internalEE = new ExecutionEngineJNI(m_context.cluster.getRelativeIndex(), m_siteId, m_partitionId, CoreUtils.getHostIdFromHSId(m_siteId), hostname, m_context.cluster.getDrclusterid(), defaultDrBufferSize, m_context.cluster.getDeployment().get("deployment").getSystemsettings().get("systemsettings").getTemptablemaxsize(), hashinatorConfig, m_hasMPDRGateway);
            eeTemp = (ExecutionEngine) spyMethod.invoke(null, internalEE);
        } else {
            // set up the EE over IPC
            eeTemp = new ExecutionEngineIPC(m_context.cluster.getRelativeIndex(), m_siteId, m_partitionId, CoreUtils.getHostIdFromHSId(m_siteId), hostname, m_context.cluster.getDrclusterid(), defaultDrBufferSize, deploy.getSystemsettings().get("systemsettings").getTemptablemaxsize(), m_backend, VoltDB.instance().getConfig().m_ipcPort, hashinatorConfig, m_hasMPDRGateway);
        }
        eeTemp.loadCatalog(m_startupConfig.m_timestamp, m_startupConfig.m_serializedCatalog);
        eeTemp.setBatchTimeout(m_context.cluster.getDeployment().get("deployment").getSystemsettings().get("systemsettings").getQuerytimeout());
    }// just print error info an bail if we run into an error here
     catch (final Exception ex) {
        hostLog.l7dlog(Level.FATAL, LogKeys.host_ExecutionSite_FailedConstruction.name(), new Object[] { m_siteId, m_siteIndex }, ex);
        VoltDB.crashLocalVoltDB(ex.getMessage(), true, ex);
    }
    return eeTemp;
}
Also used : HashinatorConfig(org.voltdb.TheHashinator.HashinatorConfig) MockExecutionEngine(org.voltdb.jni.MockExecutionEngine) ExecutionEngine(org.voltdb.jni.ExecutionEngine) ExecutionEngineJNI(org.voltdb.jni.ExecutionEngineJNI) Deployment(org.voltdb.catalog.Deployment) ExecutionEngineIPC(org.voltdb.jni.ExecutionEngineIPC) Method(java.lang.reflect.Method) EEException(org.voltdb.exceptions.EEException) VoltAbortException(org.voltdb.VoltProcedure.VoltAbortException) IOException(java.io.IOException)

Example 2 with Deployment

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

the class VoltCompiler method generateCatalogReport.

private void generateCatalogReport(String ddlWithBatchSupport) throws IOException {
    VoltDBInterface voltdb = VoltDB.instance();
    // try to get a catalog context
    CatalogContext catalogContext = voltdb != null ? voltdb.getCatalogContext() : null;
    ClusterSettings clusterSettings = catalogContext != null ? catalogContext.getClusterSettings() : null;
    int tableCount = catalogContext != null ? catalogContext.tables.size() : 0;
    Deployment deployment = catalogContext != null ? catalogContext.cluster.getDeployment().get("deployment") : null;
    int hostcount = clusterSettings != null ? clusterSettings.hostcount() : 1;
    int kfactor = deployment != null ? deployment.getKfactor() : 0;
    int sitesPerHost = 8;
    if (voltdb != null && voltdb.getCatalogContext() != null) {
        sitesPerHost = voltdb.getCatalogContext().getNodeSettings().getLocalSitesCount();
    }
    boolean isPro = MiscUtils.isPro();
    long minHeapRqt = RealVoltDB.computeMinimumHeapRqt(isPro, tableCount, sitesPerHost, kfactor);
    m_report = ReportMaker.report(m_catalog, minHeapRqt, isPro, hostcount, sitesPerHost, kfactor, m_warnings, ddlWithBatchSupport);
    m_reportPath = null;
    File file = null;
    // write to working dir when using VoltCompiler directly
    if (standaloneCompiler) {
        file = new File("catalog-report.html");
    } else {
        // if we have a context, write report to voltroot
        if (catalogContext != null) {
            file = new File(VoltDB.instance().getVoltDBRootPath(), "catalog-report.html");
        }
    }
    // if there's a good place to write the report, do so
    if (file != null) {
        FileWriter fw = new FileWriter(file);
        fw.write(m_report);
        fw.close();
        m_reportPath = file.getAbsolutePath();
    }
}
Also used : VoltDBInterface(org.voltdb.VoltDBInterface) ClusterSettings(org.voltdb.settings.ClusterSettings) FileWriter(java.io.FileWriter) Deployment(org.voltdb.catalog.Deployment) JarFile(java.util.jar.JarFile) File(java.io.File) CatalogContext(org.voltdb.CatalogContext)

Example 3 with Deployment

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

the class CatalogUtil method setClusterInfo.

/**
     * Set cluster info in the catalog.
     * @param leader The leader hostname
     * @param catalog The catalog to be updated.
     * @param printLog Whether or not to print cluster configuration.
     */
private static void setClusterInfo(Catalog catalog, DeploymentType deployment) {
    ClusterType cluster = deployment.getCluster();
    int kFactor = cluster.getKfactor();
    Cluster catCluster = catalog.getClusters().get("cluster");
    // copy the deployment info that is currently not recorded anywhere else
    Deployment catDeploy = catCluster.getDeployment().get("deployment");
    catDeploy.setKfactor(kFactor);
    if (deployment.getPartitionDetection().isEnabled()) {
        catCluster.setNetworkpartition(true);
    } else {
        catCluster.setNetworkpartition(false);
    }
    setSystemSettings(deployment, catDeploy);
    catCluster.setHeartbeattimeout(deployment.getHeartbeat().getTimeout());
    // copy schema modification behavior from xml to catalog
    if (cluster.getSchema() != null) {
        catCluster.setUseddlschema(cluster.getSchema() == SchemaType.DDL);
    } else {
        // Don't think we can get here, deployment schema guarantees a default value
        hostLog.warn("Schema modification setting not found. " + "Forcing default behavior of UpdateCatalog to modify database schema.");
        catCluster.setUseddlschema(false);
    }
}
Also used : Cluster(org.voltdb.catalog.Cluster) Deployment(org.voltdb.catalog.Deployment) ClusterType(org.voltdb.compiler.deploymentfile.ClusterType) Constraint(org.voltdb.catalog.Constraint)

Example 4 with Deployment

use of org.voltdb.catalog.Deployment 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)

Example 5 with Deployment

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

the class CatalogContext method getDebuggingInfoFromCatalog.

// Generate helpful status messages based on configuration present in the
// catalog.  Used to generated these messages at startup and after an
// @UpdateApplicationCatalog
SortedMap<String, String> getDebuggingInfoFromCatalog(boolean verbose) {
    SortedMap<String, String> logLines = new TreeMap<>();
    // topology
    Deployment deployment = cluster.getDeployment().iterator().next();
    int hostCount = m_dbSettings.getCluster().hostcount();
    if (verbose) {
        Map<Integer, Integer> sphMap;
        try {
            sphMap = m_messenger.getSitesPerHostMapFromZK();
        } catch (KeeperException | InterruptedException | JSONException e) {
            hostLog.warn("Failed to get sitesperhost information from Zookeeper", e);
            sphMap = null;
        }
        int kFactor = deployment.getKfactor();
        if (sphMap == null) {
            logLines.put("deployment1", String.format("Cluster has %d hosts with leader hostname: \"%s\". [unknown] local sites count. K = %d.", hostCount, VoltDB.instance().getConfig().m_leader, kFactor));
            logLines.put("deployment2", "Unable to retrieve partition information from the cluster.");
        } else {
            int localSitesCount = sphMap.get(m_messenger.getHostId());
            logLines.put("deployment1", String.format("Cluster has %d hosts with leader hostname: \"%s\". %d local sites count. K = %d.", hostCount, VoltDB.instance().getConfig().m_leader, localSitesCount, kFactor));
            int totalSitesCount = 0;
            for (Map.Entry<Integer, Integer> e : sphMap.entrySet()) {
                totalSitesCount += e.getValue();
            }
            int replicas = kFactor + 1;
            int partitionCount = totalSitesCount / replicas;
            logLines.put("deployment2", String.format("The entire cluster has %d %s of%s %d logical partition%s.", replicas, replicas > 1 ? "copies" : "copy", partitionCount > 1 ? " each of the" : "", partitionCount, partitionCount > 1 ? "s" : ""));
        }
    }
    // voltdb root
    logLines.put("voltdbroot", "Using \"" + VoltDB.instance().getVoltDBRootPath() + "\" for voltdbroot directory.");
    // partition detection
    if (cluster.getNetworkpartition()) {
        logLines.put("partition-detection", "Detection of network partitions in the cluster is enabled.");
    } else {
        logLines.put("partition-detection", "Detection of network partitions in the cluster is not enabled.");
    }
    // security info
    if (cluster.getSecurityenabled()) {
        logLines.put("sec-enabled", "Client authentication is enabled.");
    } else {
        logLines.put("sec-enabled", "Client authentication is not enabled. Anonymous clients accepted.");
    }
    // auto snapshot info
    SnapshotSchedule ssched = database.getSnapshotschedule().get("default");
    if (ssched == null || !ssched.getEnabled()) {
        logLines.put("snapshot-schedule1", "No schedule set for automated snapshots.");
    } else {
        final String frequencyUnitString = ssched.getFrequencyunit().toLowerCase();
        final char frequencyUnit = frequencyUnitString.charAt(0);
        String msg = "[unknown frequency]";
        switch(frequencyUnit) {
            case 's':
                msg = String.valueOf(ssched.getFrequencyvalue()) + " seconds";
                break;
            case 'm':
                msg = String.valueOf(ssched.getFrequencyvalue()) + " minutes";
                break;
            case 'h':
                msg = String.valueOf(ssched.getFrequencyvalue()) + " hours";
                break;
        }
        logLines.put("snapshot-schedule1", "Automatic snapshots enabled, saved to " + VoltDB.instance().getSnapshotPath() + " and named with prefix '" + ssched.getPrefix() + "'.");
        logLines.put("snapshot-schedule2", "Database will retain a history of " + ssched.getRetain() + " snapshots, generated every " + msg + ".");
    }
    return logLines;
}
Also used : Deployment(org.voltdb.catalog.Deployment) JSONException(org.json_voltpatches.JSONException) TreeMap(java.util.TreeMap) SnapshotSchedule(org.voltdb.catalog.SnapshotSchedule) Map(java.util.Map) TreeMap(java.util.TreeMap) CatalogMap(org.voltdb.catalog.CatalogMap) SortedMap(java.util.SortedMap) KeeperException(org.apache.zookeeper_voltpatches.KeeperException)

Aggregations

Deployment (org.voltdb.catalog.Deployment)6 SnapshotSchedule (org.voltdb.catalog.SnapshotSchedule)2 Systemsettings (org.voltdb.catalog.Systemsettings)2 File (java.io.File)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 JarFile (java.util.jar.JarFile)1 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)1 JSONException (org.json_voltpatches.JSONException)1 CatalogContext (org.voltdb.CatalogContext)1 HashinatorConfig (org.voltdb.TheHashinator.HashinatorConfig)1 VoltDBInterface (org.voltdb.VoltDBInterface)1 VoltAbortException (org.voltdb.VoltProcedure.VoltAbortException)1 VoltTable (org.voltdb.VoltTable)1 CatalogMap (org.voltdb.catalog.CatalogMap)1 Cluster (org.voltdb.catalog.Cluster)1