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;
}
}
Aggregations