use of org.voltdb.compiler.deploymentfile.SystemSettingsType.Query in project voltdb by VoltDB.
the class TestJSONInterface method testUpdateDeployment.
public void testUpdateDeployment() 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");
assertTrue(jdep.contains("cluster"));
//POST deployment with no content
String pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 400, "application/json", null);
assertTrue(pdep.contains("Failed"));
Map<String, String> params = new HashMap<>();
params.put("deployment", jdep);
pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
assertTrue(pdep.contains("Deployment Updated"));
//POST deployment in admin mode
params.put("admin", "true");
pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
assertTrue(pdep.contains("Deployment Updated"));
ObjectMapper mapper = new ObjectMapper();
DeploymentType deptype = mapper.readValue(jdep, DeploymentType.class);
//Test change heartbeat.
if (deptype.getHeartbeat() == null) {
HeartbeatType hb = new HeartbeatType();
hb.setTimeout(99);
deptype.setHeartbeat(hb);
} else {
deptype.getHeartbeat().setTimeout(99);
}
String ndeptype = mapper.writeValueAsString(deptype);
params.put("deployment", ndeptype);
pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
System.out.println("POST result is: " + pdep);
assertTrue(pdep.contains("Deployment Updated"));
jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
assertTrue(jdep.contains("cluster"));
deptype = mapper.readValue(jdep, DeploymentType.class);
int nto = deptype.getHeartbeat().getTimeout();
assertEquals(99, nto);
//Test change Query timeout
SystemSettingsType ss = deptype.getSystemsettings();
if (ss == null) {
ss = new SystemSettingsType();
deptype.setSystemsettings(ss);
}
Query qv = ss.getQuery();
if (qv == null) {
qv = new Query();
qv.setTimeout(99);
} else {
qv.setTimeout(99);
}
ss.setQuery(qv);
deptype.setSystemsettings(ss);
ndeptype = mapper.writeValueAsString(deptype);
params.put("deployment", ndeptype);
pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
System.out.println("POST result is: " + pdep);
assertTrue(pdep.contains("Deployment Updated"));
jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
assertTrue(jdep.contains("cluster"));
deptype = mapper.readValue(jdep, DeploymentType.class);
nto = deptype.getSystemsettings().getQuery().getTimeout();
assertEquals(99, nto);
qv.setTimeout(88);
ss.setQuery(qv);
deptype.setSystemsettings(ss);
ndeptype = mapper.writeValueAsString(deptype);
params.put("deployment", ndeptype);
pdep = postUrlOverJSON(protocolPrefix + "localhost:8095/deployment/", null, null, null, 200, "application/json", params);
System.out.println("POST result is: " + pdep);
assertTrue(pdep.contains("Deployment Updated"));
jdep = getUrlOverJSON(protocolPrefix + "localhost:8095/deployment", null, null, null, 200, "application/json");
assertTrue(jdep.contains("cluster"));
deptype = mapper.readValue(jdep, DeploymentType.class);
nto = deptype.getSystemsettings().getQuery().getTimeout();
assertEquals(88, nto);
} finally {
if (server != null) {
server.shutdown();
server.join();
}
server = null;
}
}
Aggregations