Search in sources :

Example 6 with SystemSettingsType

use of org.voltdb.compiler.deploymentfile.SystemSettingsType 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

SystemSettingsType (org.voltdb.compiler.deploymentfile.SystemSettingsType)6 DeploymentType (org.voltdb.compiler.deploymentfile.DeploymentType)4 File (java.io.File)3 HeartbeatType (org.voltdb.compiler.deploymentfile.HeartbeatType)3 PartitionDetectionType (org.voltdb.compiler.deploymentfile.PartitionDetectionType)3 ResourceMonitorType (org.voltdb.compiler.deploymentfile.ResourceMonitorType)3 SecurityType (org.voltdb.compiler.deploymentfile.SecurityType)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)2 Configuration (org.voltdb.VoltDB.Configuration)2 VoltProjectBuilder (org.voltdb.compiler.VoltProjectBuilder)2 CommandLogType (org.voltdb.compiler.deploymentfile.CommandLogType)2 HttpdType (org.voltdb.compiler.deploymentfile.HttpdType)2 PathsType (org.voltdb.compiler.deploymentfile.PathsType)2 Memorylimit (org.voltdb.compiler.deploymentfile.ResourceMonitorType.Memorylimit)2 SnapshotType (org.voltdb.compiler.deploymentfile.SnapshotType)2 SslType (org.voltdb.compiler.deploymentfile.SslType)2 Temptables (org.voltdb.compiler.deploymentfile.SystemSettingsType.Temptables)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1