本文整理汇总了Java中org.voltdb.utils.CatalogUtil.loadInMemoryJarFile方法的典型用法代码示例。如果您正苦于以下问题:Java CatalogUtil.loadInMemoryJarFile方法的具体用法?Java CatalogUtil.loadInMemoryJarFile怎么用?Java CatalogUtil.loadInMemoryJarFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.voltdb.utils.CatalogUtil
的用法示例。
在下文中一共展示了CatalogUtil.loadInMemoryJarFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCatalog
import org.voltdb.utils.CatalogUtil; //导入方法依赖的package包/类
public static InMemoryJarfile loadCatalog(byte[] catalogBytes, boolean expectUpgrade)
throws IOException
{
InMemoryJarfile jarfile = CatalogUtil.loadInMemoryJarFile(catalogBytes);
// Let VoltCompiler do a version check and upgrade the catalog on the fly.
// I.e. jarfile may be modified.
VoltCompiler compiler = new VoltCompiler();
String upgradeFromVersion = compiler.upgradeCatalogAsNeeded(jarfile);
if (expectUpgrade) {
TestCase.assertTrue(upgradeFromVersion!=null);
}
else {
TestCase.assertTrue(upgradeFromVersion==null);
}
return jarfile;
}
示例2: addDDLToCatalog
import org.voltdb.utils.CatalogUtil; //导入方法依赖的package包/类
/**
* Append the supplied adhoc DDL to the current catalog's DDL and recompile the
* jarfile
*/
private byte[] addDDLToCatalog(Catalog oldCatalog, byte[] oldCatalogBytes, String[] adhocDDLStmts)
throws IOException
{
VoltCompilerReader ddlReader = null;
try {
InMemoryJarfile jarfile = CatalogUtil.loadInMemoryJarFile(oldCatalogBytes);
StringBuilder sb = new StringBuilder();
compilerLog.info("Applying the following DDL to cluster:");
for (String stmt : adhocDDLStmts) {
compilerLog.info("\t" + stmt);
sb.append(stmt);
sb.append(";\n");
}
String newDDL = sb.toString();
compilerLog.trace("Adhoc-modified DDL:\n" + newDDL);
VoltCompiler compiler = new VoltCompiler();
compiler.compileInMemoryJarfileWithNewDDL(jarfile, newDDL, oldCatalog);
return jarfile.getFullJarBytes();
}
finally {
if (ddlReader != null) {
try {
ddlReader.close();
}
catch (IOException ioe) {}
}
}
}
示例3: testEng7357
import org.voltdb.utils.CatalogUtil; //导入方法依赖的package包/类
public void testEng7357() throws Exception
{
String pathToCatalog = Configuration.getPathToCatalogForTest("adhocddl.jar");
String pathToDeployment = Configuration.getPathToCatalogForTest("adhocddl.xml");
VoltProjectBuilder builder = new VoltProjectBuilder();
builder.addLiteralSchema(
"create table FOO (" +
"ID integer not null," +
"VAL bigint, " +
"constraint pk_tree primary key (ID)" +
");\n"
);
builder.addPartitionInfo("FOO", "ID");
builder.setUseDDLSchema(true);
boolean success = builder.compile(pathToCatalog, 2, 1, 0);
assertTrue("Schema compilation failed", success);
MiscUtils.copyFile(builder.getPathToDeployment(), pathToDeployment);
// Mutate the catalog to look old-school. Revert version to 4.2.0.1
// and move the autogen DDL to some other name.
CatalogUpgradeTools.dorkDowngradeVersion(pathToCatalog, pathToCatalog, "4.2.0.1 voltdb-4.2.0.1");
File catFile = new File(pathToCatalog);
InMemoryJarfile jarfile = CatalogUtil.loadInMemoryJarFile(MiscUtils.fileToBytes(catFile));
byte[] sql = jarfile.get(VoltCompiler.AUTOGEN_DDL_FILE_NAME);
jarfile.remove(VoltCompiler.AUTOGEN_DDL_FILE_NAME);
jarfile.put("oldschool.sql", sql);
catFile.delete();
jarfile.writeToFile(catFile);
VoltDB.Configuration config = new VoltDB.Configuration();
config.m_pathToCatalog = pathToCatalog;
config.m_pathToDeployment = pathToDeployment;
try {
startSystem(config);
// Try to create a new table
try {
m_client.callProcedure("@AdHoc",
"create table bar (id integer);");
}
catch (ProcCallException pce) {
pce.printStackTrace();
fail("Should be able to do DDL on an old loaded/upgraded catalog");
}
assertTrue(findTableInSystemCatalogResults("bar"));
}
finally {
teardownSystem();
}
}
示例4: loadFromPath
import org.voltdb.utils.CatalogUtil; //导入方法依赖的package包/类
public static InMemoryJarfile loadFromPath(String path) throws IOException
{
return CatalogUtil.loadInMemoryJarFile(MiscUtils.fileToBytes(new File(path)));
}