use of org.voltdb.compiler.deploymentfile.DeploymentType 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;
}
}
use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.
the class TestCatalogDiffs method testConnectorPropertiesChanges.
public void testConnectorPropertiesChanges() throws Exception {
// not supported in community
if (!MiscUtils.isPro()) {
return;
}
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
final String ddl = "CREATE STREAM export_data export to target default ( id BIGINT default 0 , value BIGINT DEFAULT 0 );";
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(ddl);
final String origXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + " <export>" + " <configuration target='default' enabled='true' type='file'>" + " <property name=\"type\">CSV</property>" + " <property name=\"with-schema\">false</property>" + " <property name=\"nonce\">pre-fix</property>" + " <property name=\"outdir\">" + m_dir + "</property>" + " </configuration>" + " </export>" + "</deployment>";
builder.compile(testDir + File.separator + "propexport1.jar");
Catalog origCat = catalogForJar(testDir + File.separator + "propexport1.jar");
final File origFile = VoltProjectBuilder.writeStringToTempFile(origXml);
DeploymentType origDepl = CatalogUtil.getDeployment(new FileInputStream(origFile));
String msg = CatalogUtil.compileDeployment(origCat, origDepl, false);
assertTrue("Deployment file failed to parse: " + msg, msg == null);
final String newPropXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + " <export>" + " <configuration target='default' enabled='true' type='file'>" + " <property name=\"type\">CSV</property>" + " <property name=\"with-schema\">false</property>" + " <property name=\"nonce\">pre-fix</property>" + " <property name=\"outdir\">" + m_dir + "</property>" + " <property name=\"iamnew\">see_me_roar</property>" + " </configuration>" + " </export>" + "</deployment>";
builder.compile(testDir + File.separator + "propexport2.jar");
Catalog newPropCat = catalogForJar(testDir + File.separator + "propexport2.jar");
final File newPropFile = VoltProjectBuilder.writeStringToTempFile(newPropXml);
DeploymentType newPropDepl = CatalogUtil.getDeployment(new FileInputStream(newPropFile));
msg = CatalogUtil.compileDeployment(newPropCat, newPropDepl, false);
assertTrue("Deployment file failed to parse: " + msg, msg == null);
final String modPropXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + " <export>" + " <configuration target='default' enabled='true' type='file'>" + " <property name=\"type\">TSV</property>" + " <property name=\"with-schema\">true</property>" + " <property name=\"nonce\">pre-fix-other</property>" + " <property name=\"outdir\">" + m_dir + "</property>" + " </configuration>" + " </export>" + "</deployment>";
builder.compile(testDir + File.separator + "propexport3.jar");
Catalog modPropCat = catalogForJar(testDir + File.separator + "propexport3.jar");
final File modPropFile = VoltProjectBuilder.writeStringToTempFile(modPropXml);
DeploymentType modPropDepl = CatalogUtil.getDeployment(new FileInputStream(modPropFile));
msg = CatalogUtil.compileDeployment(modPropCat, modPropDepl, false);
assertTrue("Deployment file failed to parse: " + msg, msg == null);
final String modTypeXml = "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" + "<deployment>" + "<cluster hostcount='3' kfactor='1' sitesperhost='2'/>" + " <export>" + " <configuration target='default' enabled='false' type='custom' exportconnectorclass=\"org.voltdb.exportclient.NoOpTestExportClient\" >" + " <property name=\"foo\">false</property>" + " <property name=\"type\">CSV</property>" + " <property name=\"with-schema\">false</property>" + " </configuration>" + " </export>" + "</deployment>";
builder.compile(testDir + File.separator + "propexport4.jar");
Catalog modTypeCat = catalogForJar(testDir + File.separator + "propexport4.jar");
final File modTypeFile = VoltProjectBuilder.writeStringToTempFile(modTypeXml);
DeploymentType modTypeDepl = CatalogUtil.getDeployment(new FileInputStream(modTypeFile));
msg = CatalogUtil.compileDeployment(modTypeCat, modTypeDepl, false);
assertTrue("Deployment file failed to parse: " + msg, msg == null);
// test delete
verifyDiff(newPropCat, origCat, null, null, true, true, false);
// test add
verifyDiff(origCat, newPropCat, null, null, true, true, false);
// test modification
verifyDiff(origCat, modPropCat, null, null, true, true, false);
// test modification
verifyDiff(modPropCat, modTypeCat, null, null, true, true, false);
}
use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.
the class TestCatalogDiffs method generateCatalogWithDeployment.
private static Catalog generateCatalogWithDeployment(String ddl, String defaultDepXml) throws IOException {
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(ddl);
final File jarPath = VoltFile.createTempFile("drrole", "jar");
builder.compile(jarPath.getAbsolutePath());
Catalog catalog = catalogForJar(jarPath.getAbsolutePath());
File file = VoltProjectBuilder.writeStringToTempFile(defaultDepXml);
DeploymentType deployment = CatalogUtil.getDeployment(new FileInputStream(file));
CatalogUtil.compileDeployment(catalog, deployment, false);
jarPath.delete();
return catalog;
}
use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.
the class TestInitStartLocalClusterAllOutOfProcess method testGetDeployment.
// Test get deployment
public void testGetDeployment() throws Exception {
File deployment = File.createTempFile("get_deployment", ".xm");
if (deployment.exists())
deployment.delete();
Configuration config = new VoltDB.Configuration(new String[] { "get", "deployment", "getvoltdbroot", voltDBRootParentPath, "file", deployment.getAbsolutePath() + "l", "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
DeploymentType dt = CatalogUtil.parseDeployment(deployment.getAbsolutePath() + "l");
assertNotNull(dt);
assertEquals(dt.getPaths().getVoltdbroot().getPath(), voltDbRootPath);
}
use of org.voltdb.compiler.deploymentfile.DeploymentType in project voltdb by VoltDB.
the class TestInitStartLocalClusterInProcess method testGetDeployment.
// Test get deployment
public void testGetDeployment() throws Exception {
File deployment = File.createTempFile("get_deployment", ".xm");
Configuration config = new VoltDB.Configuration(new String[] { "get", "deployment", "getvoltdbroot", voltDBRootParentPath, "file", deployment.getAbsolutePath() + "l", "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
DeploymentType dt = CatalogUtil.parseDeployment(deployment.getAbsolutePath() + "l");
assertNotNull(dt);
assertEquals(dt.getPaths().getVoltdbroot().getPath(), voltDbRootPath);
}
Aggregations