Search in sources :

Example 1 with ResourceMonitorType

use of org.voltdb.compiler.deploymentfile.ResourceMonitorType in project voltdb by VoltDB.

the class VoltProjectBuilder method setupDiskLimitType.

private void setupDiskLimitType(SystemSettingsType systemSettingsType, org.voltdb.compiler.deploymentfile.ObjectFactory factory) {
    Set<FeatureNameType> featureNames = new HashSet<>();
    if (m_featureDiskLimits != null && !m_featureDiskLimits.isEmpty()) {
        featureNames.addAll(m_featureDiskLimits.keySet());
    }
    if (m_snmpFeatureDiskLimits != null && !m_snmpFeatureDiskLimits.isEmpty()) {
        featureNames.addAll(m_snmpFeatureDiskLimits.keySet());
    }
    if (featureNames.isEmpty()) {
        return;
    }
    DiskLimitType diskLimit = factory.createDiskLimitType();
    for (FeatureNameType featureName : featureNames) {
        DiskLimitType.Feature feature = factory.createDiskLimitTypeFeature();
        feature.setName(featureName);
        if (m_featureDiskLimits != null && m_featureDiskLimits.containsKey(featureName)) {
            feature.setSize(m_featureDiskLimits.get(featureName));
        }
        if (m_snmpFeatureDiskLimits != null && m_snmpFeatureDiskLimits.containsKey(featureName)) {
            feature.setAlert(m_snmpFeatureDiskLimits.get(featureName));
        }
        diskLimit.getFeature().add(feature);
    }
    ResourceMonitorType monitorType = initializeResourceMonitorType(systemSettingsType, factory);
    monitorType.setDisklimit(diskLimit);
}
Also used : FeatureNameType(org.voltdb.compiler.deploymentfile.FeatureNameType) ResourceMonitorType(org.voltdb.compiler.deploymentfile.ResourceMonitorType) DiskLimitType(org.voltdb.compiler.deploymentfile.DiskLimitType) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with ResourceMonitorType

use of org.voltdb.compiler.deploymentfile.ResourceMonitorType in project voltdb by VoltDB.

the class VoltProjectBuilder method initializeResourceMonitorType.

private ResourceMonitorType initializeResourceMonitorType(SystemSettingsType systemSettingType, org.voltdb.compiler.deploymentfile.ObjectFactory factory) {
    ResourceMonitorType monitorType = systemSettingType.getResourcemonitor();
    if (monitorType == null) {
        monitorType = factory.createResourceMonitorType();
        systemSettingType.setResourcemonitor(monitorType);
    }
    return monitorType;
}
Also used : ResourceMonitorType(org.voltdb.compiler.deploymentfile.ResourceMonitorType)

Example 3 with ResourceMonitorType

use of org.voltdb.compiler.deploymentfile.ResourceMonitorType in project voltdb by VoltDB.

the class VoltProjectBuilder method createSystemSettingsType.

private SystemSettingsType createSystemSettingsType(org.voltdb.compiler.deploymentfile.ObjectFactory factory) {
    SystemSettingsType systemSettingType = factory.createSystemSettingsType();
    Temptables temptables = factory.createSystemSettingsTypeTemptables();
    temptables.setMaxsize(m_maxTempTableMemory);
    systemSettingType.setTemptables(temptables);
    if (m_snapshotPriority != null) {
        SystemSettingsType.Snapshot snapshot = factory.createSystemSettingsTypeSnapshot();
        snapshot.setPriority(m_snapshotPriority);
        systemSettingType.setSnapshot(snapshot);
    }
    if (m_elasticThroughput != null || m_elasticDuration != null) {
        SystemSettingsType.Elastic elastic = factory.createSystemSettingsTypeElastic();
        if (m_elasticThroughput != null)
            elastic.setThroughput(m_elasticThroughput);
        if (m_elasticDuration != null)
            elastic.setDuration(m_elasticDuration);
        systemSettingType.setElastic(elastic);
    }
    if (m_queryTimeout != null) {
        SystemSettingsType.Query query = factory.createSystemSettingsTypeQuery();
        query.setTimeout(m_queryTimeout);
        systemSettingType.setQuery(query);
    }
    if (m_rssLimit != null || m_snmpRssLimit != null) {
        ResourceMonitorType monitorType = initializeResourceMonitorType(systemSettingType, factory);
        Memorylimit memoryLimit = factory.createResourceMonitorTypeMemorylimit();
        if (m_rssLimit != null) {
            memoryLimit.setSize(m_rssLimit);
        }
        if (m_snmpRssLimit != null) {
            memoryLimit.setAlert(m_snmpRssLimit);
        }
        monitorType.setMemorylimit(memoryLimit);
    }
    if (m_resourceCheckInterval != null) {
        ResourceMonitorType monitorType = initializeResourceMonitorType(systemSettingType, factory);
        monitorType.setFrequency(m_resourceCheckInterval);
    }
    setupDiskLimitType(systemSettingType, factory);
    return systemSettingType;
}
Also used : Temptables(org.voltdb.compiler.deploymentfile.SystemSettingsType.Temptables) SystemSettingsType(org.voltdb.compiler.deploymentfile.SystemSettingsType) Memorylimit(org.voltdb.compiler.deploymentfile.ResourceMonitorType.Memorylimit) ResourceMonitorType(org.voltdb.compiler.deploymentfile.ResourceMonitorType)

Example 4 with ResourceMonitorType

use of org.voltdb.compiler.deploymentfile.ResourceMonitorType in project voltdb by VoltDB.

the class CatalogUtil method populateDefaultDeployment.

public static void populateDefaultDeployment(DeploymentType deployment) {
    //partition detection
    PartitionDetectionType pd = deployment.getPartitionDetection();
    if (pd == null) {
        pd = new PartitionDetectionType();
        deployment.setPartitionDetection(pd);
    }
    //heartbeat
    if (deployment.getHeartbeat() == null) {
        HeartbeatType hb = new HeartbeatType();
        deployment.setHeartbeat(hb);
    }
    SslType ssl = deployment.getSsl();
    if (ssl == null) {
        ssl = new SslType();
        deployment.setSsl(ssl);
    }
    //httpd
    HttpdType httpd = deployment.getHttpd();
    if (httpd == null) {
        httpd = new HttpdType();
        // Find next available port starting with the default
        httpd.setPort(Constants.HTTP_PORT_AUTO);
        deployment.setHttpd(httpd);
    }
    //jsonApi
    HttpdType.Jsonapi jsonApi = httpd.getJsonapi();
    if (jsonApi == null) {
        jsonApi = new HttpdType.Jsonapi();
        httpd.setJsonapi(jsonApi);
    }
    //snapshot
    if (deployment.getSnapshot() == null) {
        SnapshotType snap = new SnapshotType();
        snap.setEnabled(false);
        deployment.setSnapshot(snap);
    }
    //Security
    if (deployment.getSecurity() == null) {
        SecurityType sec = new SecurityType();
        deployment.setSecurity(sec);
    }
    //Paths
    if (deployment.getPaths() == null) {
        PathsType paths = new PathsType();
        deployment.setPaths(paths);
    }
    //create paths entries
    PathsType paths = deployment.getPaths();
    if (paths.getVoltdbroot() == null) {
        PathsType.Voltdbroot root = new PathsType.Voltdbroot();
        paths.setVoltdbroot(root);
    }
    //snapshot
    if (paths.getSnapshots() == null) {
        PathsType.Snapshots snap = new PathsType.Snapshots();
        paths.setSnapshots(snap);
    }
    if (paths.getCommandlog() == null) {
        //cl
        PathsType.Commandlog cl = new PathsType.Commandlog();
        paths.setCommandlog(cl);
    }
    if (paths.getCommandlogsnapshot() == null) {
        //cl snap
        PathsType.Commandlogsnapshot clsnap = new PathsType.Commandlogsnapshot();
        paths.setCommandlogsnapshot(clsnap);
    }
    if (paths.getExportoverflow() == null) {
        //export overflow
        PathsType.Exportoverflow exp = new PathsType.Exportoverflow();
        paths.setExportoverflow(exp);
    }
    if (paths.getDroverflow() == null) {
        final PathsType.Droverflow droverflow = new PathsType.Droverflow();
        paths.setDroverflow(droverflow);
    }
    //Command log info
    if (deployment.getCommandlog() == null) {
        boolean enabled = false;
        if (MiscUtils.isPro()) {
            enabled = true;
        }
        CommandLogType cl = new CommandLogType();
        cl.setEnabled(enabled);
        Frequency freq = new Frequency();
        cl.setFrequency(freq);
        deployment.setCommandlog(cl);
    }
    //System settings
    SystemSettingsType ss = deployment.getSystemsettings();
    if (deployment.getSystemsettings() == null) {
        ss = new SystemSettingsType();
        deployment.setSystemsettings(ss);
    }
    SystemSettingsType.Elastic sse = ss.getElastic();
    if (sse == null) {
        sse = new SystemSettingsType.Elastic();
        ss.setElastic(sse);
    }
    SystemSettingsType.Query query = ss.getQuery();
    if (query == null) {
        query = new SystemSettingsType.Query();
        ss.setQuery(query);
    }
    SystemSettingsType.Snapshot snap = ss.getSnapshot();
    if (snap == null) {
        snap = new SystemSettingsType.Snapshot();
        ss.setSnapshot(snap);
    }
    SystemSettingsType.Temptables tt = ss.getTemptables();
    if (tt == null) {
        tt = new SystemSettingsType.Temptables();
        ss.setTemptables(tt);
    }
    ResourceMonitorType rm = ss.getResourcemonitor();
    if (rm == null) {
        rm = new ResourceMonitorType();
        ss.setResourcemonitor(rm);
    }
    ResourceMonitorType.Memorylimit mem = rm.getMemorylimit();
    if (mem == null) {
        mem = new ResourceMonitorType.Memorylimit();
        rm.setMemorylimit(mem);
    }
}
Also used : SecurityType(org.voltdb.compiler.deploymentfile.SecurityType) HeartbeatType(org.voltdb.compiler.deploymentfile.HeartbeatType) PathsType(org.voltdb.compiler.deploymentfile.PathsType) CommandLogType(org.voltdb.compiler.deploymentfile.CommandLogType) SystemSettingsType(org.voltdb.compiler.deploymentfile.SystemSettingsType) PartitionDetectionType(org.voltdb.compiler.deploymentfile.PartitionDetectionType) ResourceMonitorType(org.voltdb.compiler.deploymentfile.ResourceMonitorType) HttpdType(org.voltdb.compiler.deploymentfile.HttpdType) Frequency(org.voltdb.compiler.deploymentfile.CommandLogType.Frequency) SslType(org.voltdb.compiler.deploymentfile.SslType) SnapshotType(org.voltdb.compiler.deploymentfile.SnapshotType)

Example 5 with ResourceMonitorType

use of org.voltdb.compiler.deploymentfile.ResourceMonitorType in project voltdb by VoltDB.

the class TestJSONInterface method testUpdateDeploymentMemoryLimit.

public void testUpdateDeploymentMemoryLimit() throws Exception {
    try {
        String simpleSchema = "CREATE TABLE foo (\n" + "    bar BIGINT NOT NULL,\n" + "    PRIMARY KEY (bar)\n" + ");";
        File schemaFile = VoltProjectBuilder.writeStringToTempFile(simpleSchema);
        String schemaPath = schemaFile.getPath();
        schemaPath = URLEncoder.encode(schemaPath, "UTF-8");
        VoltProjectBuilder builder = new VoltProjectBuilder();
        builder.addSchema(schemaPath);
        builder.addPartitionInfo("foo", "bar");
        builder.addProcedures(DelayProc.class);
        builder.setHTTPDPort(8095);
        boolean success = builder.compile(Configuration.getPathToCatalogForTest("json.jar"));
        assertTrue(success);
        VoltDB.Configuration config = new VoltDB.Configuration();
        config.m_pathToCatalog = config.setPathToCatalogForTest("json.jar");
        config.m_pathToDeployment = builder.getPathToDeployment();
        server = new ServerThread(config);
        server.start();
        server.waitForInitialization();
        //Get deployment
        String jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
        Map<String, String> params = new HashMap<>();
        ObjectMapper mapper = new ObjectMapper();
        DeploymentType deptype = mapper.readValue(jdep, DeploymentType.class);
        SystemSettingsType ss = deptype.getSystemsettings();
        if (ss == null) {
            ss = new SystemSettingsType();
            deptype.setSystemsettings(ss);
        }
        ResourceMonitorType resourceMonitor = new ResourceMonitorType();
        Memorylimit memLimit = new Memorylimit();
        memLimit.setSize("10");
        memLimit.setAlert("5");
        resourceMonitor.setMemorylimit(memLimit);
        ss.setResourcemonitor(resourceMonitor);
        String ndeptype = mapper.writeValueAsString(deptype);
        params.put("deployment", ndeptype);
        String pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
        assertTrue(pdep.contains("Deployment Updated"));
        jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
        DeploymentType gotValue = mapper.readValue(jdep, DeploymentType.class);
        assertEquals("10", gotValue.getSystemsettings().getResourcemonitor().getMemorylimit().getSize());
        memLimit.setSize("90%");
        ndeptype = mapper.writeValueAsString(deptype);
        params.put("deployment", ndeptype);
        pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
        assertTrue(pdep.contains("Deployment Updated"));
        jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
        gotValue = mapper.readValue(jdep, DeploymentType.class);
        assertEquals("90%", gotValue.getSystemsettings().getResourcemonitor().getMemorylimit().getSize());
        // decimal values not allowed for percentages
        memLimit.setSize("90.5%25");
        ndeptype = mapper.writeValueAsString(deptype);
        params.put("deployment", ndeptype);
        pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
        jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
        gotValue = mapper.readValue(jdep, DeploymentType.class);
        // must be still the old value
        assertEquals("90%", gotValue.getSystemsettings().getResourcemonitor().getMemorylimit().getSize());
    } finally {
        if (server != null) {
            server.shutdown();
            server.join();
        }
        server = null;
    }
}
Also used : Configuration(org.voltdb.VoltDB.Configuration) HashMap(java.util.HashMap) ResourceMonitorType(org.voltdb.compiler.deploymentfile.ResourceMonitorType) DeploymentType(org.voltdb.compiler.deploymentfile.DeploymentType) SystemSettingsType(org.voltdb.compiler.deploymentfile.SystemSettingsType) VoltProjectBuilder(org.voltdb.compiler.VoltProjectBuilder) Memorylimit(org.voltdb.compiler.deploymentfile.ResourceMonitorType.Memorylimit) Configuration(org.voltdb.VoltDB.Configuration) File(java.io.File) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Aggregations

ResourceMonitorType (org.voltdb.compiler.deploymentfile.ResourceMonitorType)5 SystemSettingsType (org.voltdb.compiler.deploymentfile.SystemSettingsType)3 Memorylimit (org.voltdb.compiler.deploymentfile.ResourceMonitorType.Memorylimit)2 File (java.io.File)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Configuration (org.voltdb.VoltDB.Configuration)1 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)1 CommandLogType (org.voltdb.compiler.deploymentfile.CommandLogType)1 Frequency (org.voltdb.compiler.deploymentfile.CommandLogType.Frequency)1 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)1 DiskLimitType (org.voltdb.compiler.deploymentfile.DiskLimitType)1 FeatureNameType (org.voltdb.compiler.deploymentfile.FeatureNameType)1 HeartbeatType (org.voltdb.compiler.deploymentfile.HeartbeatType)1 HttpdType (org.voltdb.compiler.deploymentfile.HttpdType)1 PartitionDetectionType (org.voltdb.compiler.deploymentfile.PartitionDetectionType)1 PathsType (org.voltdb.compiler.deploymentfile.PathsType)1 SecurityType (org.voltdb.compiler.deploymentfile.SecurityType)1