use of org.voltdb.utils.InMemoryJarfile in project voltdb by VoltDB.
the class RegressionSuite method getCurrentCatalog.
private static Catalog getCurrentCatalog() {
CatalogContext context = VoltDB.instance().getCatalogContext();
if (context == null) {
return null;
}
InMemoryJarfile currentCatalogJar = context.getCatalogJar();
String serializedCatalogString = CatalogUtil.getSerializedCatalogStringFromJar(currentCatalogJar);
assertNotNull(serializedCatalogString);
Catalog c = new Catalog();
c.execute(serializedCatalogString);
return c;
}
use of org.voltdb.utils.InMemoryJarfile in project voltdb by VoltDB.
the class TestInitStartLocalClusterAllOutOfProcess method getProcJarFromCatalog.
InMemoryJarfile getProcJarFromCatalog() throws IOException {
File jar = File.createTempFile("procedure", ".jar");
Configuration config = new VoltDB.Configuration(new String[] { "get", "classes", "getvoltdbroot", voltDBRootParentPath, "file", jar.getAbsolutePath(), "forceget" });
ServerThread server = new ServerThread(config);
try {
server.cli();
} catch (Throwable ex) {
//Good
}
byte[] bytesRead = Files.readAllBytes(Paths.get(jar.getAbsolutePath()));
assertNotNull(bytesRead);
assertTrue(bytesRead.length > 0);
return new InMemoryJarfile(bytesRead);
}
use of org.voltdb.utils.InMemoryJarfile in project voltdb by VoltDB.
the class TestInitStartLocalClusterInProcess method testGetClasses.
public void testGetClasses() throws IOException {
InMemoryJarfile jarFile = getProcJarFromCatalog();
assertTrue(!anyCatalogDefaultArtifactsExists(jarFile));
org.voltdb.client.ClientResponse resp = null;
// No java stored proc at this time, will give jar with no classes
try {
resp = client.callProcedure("@SystemCatalog", "CLASSES");
} catch (ProcCallException excp) {
assert false : "@SystemCatalogClasses failed";
}
assertTrue(jarFile.getLoader().getClassNames().size() == resp.getResults()[0].getRowCount());
// load java stored proc classes and verify the retrieved classes count
loadAndAddProcs();
jarFile = getProcJarFromCatalog();
assertTrue(!anyCatalogDefaultArtifactsExists(jarFile));
try {
resp = client.callProcedure("@SystemCatalog", "CLASSES");
} catch (ProcCallException excp) {
assert false : "@SystemCatalogClasses failed";
}
assertTrue(jarFile.getLoader().getClassNames().size() == resp.getResults()[0].getRowCount());
}
use of org.voltdb.utils.InMemoryJarfile in project voltdb by VoltDB.
the class TestInitStartLocalClusterInProcess method loadAndAddProcs.
void loadAndAddProcs() throws IOException, NoConnectionsException {
ClientResponse resp = null;
long numberOfClasses = 0;
try {
resp = client.callProcedure("@SystemCatalog", "CLASSES");
} catch (ProcCallException excp) {
assert false : "@SystemCatalogClasses failed";
}
numberOfClasses = resp.getResults()[0].getRowCount();
InMemoryJarfile jarfile = new InMemoryJarfile();
VoltCompiler comp = new VoltCompiler(false);
try {
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.testImportProc.class);
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.testCreateProcFromClassProc.class);
comp.addClassToJar(jarfile, org.voltdb_testprocs.updateclasses.InnerClassesTestProc.class);
comp.addClassToJar(jarfile, RangeCount.class);
} catch (Exception e) {
assert false : "Failed add class to jar: " + e.getMessage();
}
try {
client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
} catch (ProcCallException excp) {
assert false : "Failed updating the class";
}
try {
resp = client.callProcedure("@SystemCatalog", "CLASSES");
} catch (ProcCallException excp) {
assert false : "@SystemCatalogClasses failed";
}
assertTrue((numberOfClasses + jarfile.getLoader().getClassNames().size()) == resp.getResults()[0].getRowCount());
}
use of org.voltdb.utils.InMemoryJarfile in project voltdb by VoltDB.
the class TestLiveDDLSchemaSwitch method testReplicaWithUAC.
@Test
public void testReplicaWithUAC() throws Exception {
generateCatalogsAndDeployments(false);
// Fire up a cluster with no catalog
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = m_pathToOtherCatalog;
config.m_pathToDeployment = m_pathToReplicaDeployment;
try {
startSystem(config);
// UAC with schema should succeed
assertFalse(findTableInSystemCatalogResults("FOO"));
boolean threw = false;
try {
m_client.updateApplicationCatalog(new File(m_pathToCatalog), null);
} catch (ProcCallException pce) {
threw = true;
}
assertFalse("@UAC add table should be accepted on the consumer cluster", threw);
assertTrue(findTableInSystemCatalogResults("FOO"));
// deployment-only UAC should succeed
threw = false;
try {
m_client.updateApplicationCatalog(null, new File(m_pathToOtherReplicaDeployment));
} catch (ProcCallException pce) {
threw = true;
}
assertFalse("@UAC to new catalog on consumer cluster should have succeed", threw);
assertEquals(getHeartbeatTimeout(), 6);
// Adhoc DDL should be rejected
assertFalse(findTableInSystemCatalogResults("BAR"));
threw = false;
try {
m_client.callProcedure("@AdHoc", "create table BAR (ID integer, VAL varchar(50));");
} catch (ProcCallException pce) {
threw = true;
System.out.println(pce.getMessage());
assertTrue(pce.getMessage().contains("AdHoc DDL is forbidden"));
}
assertTrue("Adhoc DDL should have failed", threw);
assertFalse(findTableInSystemCatalogResults("BAR"));
// @UpdateClasses (which is an AdHoc capability) should be rejected
assertFalse(findClassInSystemCatalog("org.voltdb_testprocs.fullddlfeatures.testImportProc"));
threw = false;
try {
InMemoryJarfile jarfile = new InMemoryJarfile();
VoltCompiler comp = new VoltCompiler(false);
comp.addClassToJar(jarfile, org.voltdb_testprocs.fullddlfeatures.testImportProc.class);
m_client.callProcedure("@UpdateClasses", jarfile.getFullJarBytes(), null);
} catch (ProcCallException pce) {
threw = true;
assertTrue(pce.getMessage().contains("@UpdateClasses is forbidden"));
}
assertTrue("@UpdateClasses should have failed", threw);
assertFalse(findClassInSystemCatalog("org.voltdb_testprocs.fullddlfeatures.testImportProc"));
// Promote, should behave like the original master test
m_client.callProcedure("@Promote");
verifyMasterWithUAC();
} finally {
teardownSystem();
}
}
Aggregations