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