Search in sources :

Example 1 with Memorylimit

use of org.voltdb.compiler.deploymentfile.ResourceMonitorType.Memorylimit 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)

Example 2 with Memorylimit

use of org.voltdb.compiler.deploymentfile.ResourceMonitorType.Memorylimit 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)

Aggregations

ResourceMonitorType (org.voltdb.compiler.deploymentfile.ResourceMonitorType)2 Memorylimit (org.voltdb.compiler.deploymentfile.ResourceMonitorType.Memorylimit)2 SystemSettingsType (org.voltdb.compiler.deploymentfile.SystemSettingsType)2 File (java.io.File)1 HashMap (java.util.HashMap)1 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)1 Configuration (org.voltdb.VoltDB.Configuration)1 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)1 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)1 Temptables (org.voltdb.compiler.deploymentfile.SystemSettingsType.Temptables)1