Examples of InMemoryJarfile


Examples of org.voltdb.utils.InMemoryJarfile

            // We know the ZK bytes are okay because the run() method wrote them before sending
            // out fragments
            CatalogAndIds catalogStuff = null;
            try {
                catalogStuff = CatalogUtil.getCatalogFromZK(VoltDB.instance().getHostMessenger().getZK());
                InMemoryJarfile testjar = new InMemoryJarfile(catalogStuff.catalogBytes);
                JarLoader testjarloader = testjar.getLoader();
                for (String classname : testjarloader.getClassNames()) {
                    try {
                        Class.forName(classname, true, testjarloader);
                    }
                    // LinkageError catches most of the various class loading errors we'd
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

    }

    public static void dorkDowngradeVersion(String srcJar, String dstJar, String buildstring)
        throws Exception
    {
        InMemoryJarfile memCatalog = CatalogUpgradeTools.loadFromPath(srcJar);
        String[] bi = getBuildInfoLines(memCatalog);
        bi[0] = buildstring;
        memCatalog.put(CatalogUtil.CATALOG_BUILDINFO_FILENAME, StringUtils.join(bi, '\n').getBytes());
        memCatalog.writeToFile(new File(dstJar));
    }
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

    }

    public static void dorkJar(String srcJar, String dstJar, String statement)
            throws IOException
    {
        InMemoryJarfile memCatalog = CatalogUpgradeTools.loadFromPath(srcJar);
        dorkVersion(memCatalog);
        if (statement != null) {
            dorkDDL(memCatalog, statement);
        }
        memCatalog.writeToFile(new File(dstJar));
    }
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

    }

    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) {
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

                    // on the current host.
                    // Check that this host is the one providing the catalog.
                    if (m_rvdb.m_myHostId == hostId) {
                        try {
                            byte[] catalogBytes = readCatalog(catalogPath);
                            InMemoryJarfile inMemoryJar = CatalogUtil.loadInMemoryJarFile(catalogBytes);
                            // This call pre-checks and returns the build info/version.
                            String[] buildInfo = CatalogUtil.getBuildInfoFromJar(inMemoryJar);
                            String catalogVersion = buildInfo[0];
                            String serverVersion = m_rvdb.getVersionString();
                            if (!catalogVersion.equals(serverVersion)) {
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

    private byte[] addDDLToCatalog(byte[] oldCatalogBytes, String[] adhocDDLStmts)
    throws IOException
    {
        VoltCompilerReader ddlReader = null;
        try {
            InMemoryJarfile jarfile = CatalogUtil.loadInMemoryJarFile(oldCatalogBytes);
            // Yoink the current cluster catalog's canonical DDL and append the supplied
            // adhoc DDL to it.
            String oldDDL = new String(jarfile.get(VoltCompiler.AUTOGEN_DDL_FILE_NAME),
                    Constants.UTF8ENCODING);
            compilerLog.debug("OLD DDL: " + oldDDL);
            StringBuilder sb = new StringBuilder();
            sb.append(oldDDL);
            sb.append("\n");
            for (String stmt : adhocDDLStmts) {
                sb.append(stmt);
                sb.append(";\n");
            }
            compilerLog.debug("Adhoc-modified DDL:\n" + sb.toString());
            // Put the new DDL back into the InMemoryJarfile we built because that's
            // the artifact the compiler is expecting to work on.  This allows us to preserve any
            // stored procedure classes and the class loader that came with the catalog
            // before we appended to it.
            ddlReader =
                new VoltCompilerStringReader(VoltCompiler.AUTOGEN_DDL_FILE_NAME, sb.toString());
            ddlReader.putInJar(jarfile, VoltCompiler.AUTOGEN_DDL_FILE_NAME);
            VoltCompiler compiler = new VoltCompiler();
            compiler.compileInMemoryJarfile(jarfile);
            return jarfile.getFullJarBytes();
        }
        finally {
            if (ddlReader != null) {
                try {
                    ddlReader.close();
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

            byte[] newClassBytes) throws IOException
    {
        // Create a new InMemoryJarfile based on the original catalog bytes,
        // modify it in place based on the @UpdateClasses inputs, and then
        // recompile it if necessary
        InMemoryJarfile jarfile = CatalogUtil.loadInMemoryJarFile(oldCatalogBytes);
        boolean deletedClasses = false;
        if (deletePatterns != null) {
            String[] patterns = deletePatterns.split(",");
            ClassMatcher matcher = new ClassMatcher();
            // Need to concatenate all the classnames together for ClassMatcher
            String currentClasses = "";
            for (String classname : jarfile.getLoader().getClassNames()) {
                currentClasses = currentClasses.concat(classname + "\n");
            }
            matcher.m_classList = currentClasses;
            for (String pattern : patterns) {
                ClassNameMatchStatus status = matcher.addPattern(pattern.trim());
                if (status == ClassNameMatchStatus.MATCH_FOUND) {
                    deletedClasses = true;
                }
            }
            for (String classname : matcher.getMatchedClassList()) {
                jarfile.removeClassFromJar(classname);
            }
        }
        boolean foundClasses = false;
        if (newClassBytes != null) {
            InMemoryJarfile newJarfile = new InMemoryJarfile(newClassBytes);
            for (Entry<String, byte[]> e : newJarfile.entrySet()) {
                String filename = e.getKey();
                if (!filename.endsWith(".class")) {
                    continue;
                }
                foundClasses = true;
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

        String catalogJar = testDir + File.separator + jarName;
        assertTrue("Project failed to compile", project.compile(catalogJar));

        // Load the catalog to an in-memory jar and tweak the version.
        byte[] bytes = MiscUtils.fileToBytes(new File(catalogJar));
        InMemoryJarfile memCatalog = CatalogUpgradeTools.loadCatalog(bytes, false);
        CatalogUpgradeTools.dorkVersion(memCatalog);

        // Load/upgrade and check against the server version.
        InMemoryJarfile memCatalog2 = CatalogUpgradeTools.loadCatalog(memCatalog.getFullJarBytes(), true);
        assertNotNull(memCatalog2);
        String[] buildInfoLines2 = CatalogUpgradeTools.getBuildInfoLines(memCatalog2);
        String serverVersion = VoltDB.instance().getVersionString();
        assertTrue(serverVersion.equals(buildInfoLines2[0]));
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

        String catalogJar = testDir + File.separator + jarName;
        assertTrue("Project failed to compile", project.compile(catalogJar));

        // Load the catalog to an in-memory jar and tweak the version to make it incompatible.
        byte[] bytes = MiscUtils.fileToBytes(new File(catalogJar));
        InMemoryJarfile memCatalog = CatalogUpgradeTools.loadCatalog(bytes, false);
        CatalogUpgradeTools.dorkVersion(memCatalog);
        // Squizzle creation is no longer supported.
        CatalogUpgradeTools.dorkDDL(memCatalog, "CREATE SQUIZZLE");

        // Check the (hopefully) upgraded catalog version against the server version.
        try {
            CatalogUpgradeTools.loadCatalog(memCatalog.getFullJarBytes(), true);
            fail("Expected load to generate an exception");
        }
        catch (IOException e) {
            // Happy if the message mentions the bad create statement.
            String message = e.getMessage();
View Full Code Here

Examples of org.voltdb.utils.InMemoryJarfile

        String catalogJar = testDir + File.separator + jarName;
        assertTrue("Project failed to compile", project.compile(catalogJar));

        // Load the catalog to an in-memory jar and tweak the version.
        byte[] bytes = MiscUtils.fileToBytes(new File(catalogJar));
        InMemoryJarfile memCatalog = CatalogUpgradeTools.loadCatalog(bytes, false);
        CatalogUpgradeTools.dorkVersion(memCatalog);
        CatalogUpgradeTools.dorkDDL(memCatalog,
            "CREATE PROCEDURE groovy.procedures.SelectItem AS ### \n" +
            "  selectItem = new SQLStmt('SELECT I_ID, I_NAME FROM ITEM WHERE I_ID = ?') \n" +
            "  transactOn = { id -> \n" +
            "    voltQueueSQL(selectItem, EXPECT_ZERO_OR_ONE_ROW, id) \n" +
            "    voltExecuteSQL(true) \n" +
            "  } \n" +
            "### LANGUAGE GROOVY");

        // Load/upgrade and check against the server version.
        InMemoryJarfile memCatalog2 = CatalogUpgradeTools.loadCatalog(memCatalog.getFullJarBytes(), true);
        assertNotNull(memCatalog2);
        String[] buildInfoLines2 = CatalogUpgradeTools.getBuildInfoLines(memCatalog2);
        String serverVersion = VoltDB.instance().getVersionString();
        assertTrue(serverVersion.equals(buildInfoLines2[0]));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.