Package org.voltdb.utils.CatalogUtil

Examples of org.voltdb.utils.CatalogUtil.CatalogAndIds


            // Don't actually care about the returned table, just need to send something
            // back to the MPI scoreboard

            // 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
                    // care about here.
                    catch (LinkageError | ClassNotFoundException e) {
                        String cause = e.getMessage();
                        if (cause == null && e.getCause() != null) {
                            cause = e.getCause().getMessage();
                        }
                        String msg = "Error loading class: " + classname + " from catalog: " +
                            e.getClass().getCanonicalName() + ", " + cause;
                        log.warn(msg);
                        throw new VoltAbortException(e);
                    }
                }
            } catch (Exception e) {
                Throwables.propagate(e);
            }

            return new DependencyPair(DEP_updateCatalogSync,
                    new VoltTable(new ColumnInfo[] { new ColumnInfo("UNUSED", VoltType.BIGINT) } ));
        }
        else if (fragmentId == SysProcFragmentId.PF_updateCatalogPrecheckAndSyncAggregate) {
            // Don't actually care about the returned table, just need to send something
            // back to the MPI scoreboard
            return new DependencyPair(DEP_updateCatalogSyncAggregate,
                    new VoltTable(new ColumnInfo[] { new ColumnInfo("UNUSED", VoltType.BIGINT) } ));
        }
        else if (fragmentId == SysProcFragmentId.PF_updateCatalog) {
            String catalogDiffCommands = (String)params.toArray()[0];
            String commands = Encoder.decodeBase64AndDecompress(catalogDiffCommands);
            int expectedCatalogVersion = (Integer)params.toArray()[1];
            boolean requiresSnapshotIsolation = ((Byte) params.toArray()[2]) != 0;

            CatalogAndIds catalogStuff = null;
            try {
                catalogStuff = CatalogUtil.getCatalogFromZK(VoltDB.instance().getHostMessenger().getZK());
            } catch (Exception e) {
                Throwables.propagate(e);
            }

            String replayInfo = m_runner.getTxnState().isForReplay() ? " (FOR REPLAY)" : "";

            // if this is a new catalog, do the work to update
            if (context.getCatalogVersion() == expectedCatalogVersion) {

                // update the global catalog if we get there first
                @SuppressWarnings("deprecation")
                Pair<CatalogContext, CatalogSpecificPlanner> p =
                VoltDB.instance().catalogUpdate(
                        commands,
                        catalogStuff.catalogBytes,
                        catalogStuff.getCatalogHash(),
                        expectedCatalogVersion,
                        getVoltPrivateRealTransactionIdDontUseMe(),
                        getUniqueId(),
                        catalogStuff.getDeploymentHash());

                // update the local catalog.  Safe to do this thanks to the check to get into here.
                context.updateCatalog(commands, p.getFirst(), p.getSecond(), requiresSnapshotIsolation);

                log.info(String.format("Site %s completed catalog update with catalog hash %s, deployment hash %s%s.",
                        CoreUtils.hsIdToString(m_site.getCorrespondingSiteId()),
                        Encoder.hexEncode(catalogStuff.getCatalogHash()).substring(0, 10),
                        Encoder.hexEncode(catalogStuff.getDeploymentHash()).substring(0, 10),
                        replayInfo));
            }
            // if seen before by this code, then check to see if this is a restart
            else if ((context.getCatalogVersion() == (expectedCatalogVersion + 1) &&
                     (Arrays.equals(context.getCatalogHash(), catalogStuff.getCatalogHash()) &&
                      Arrays.equals(context.getDeploymentHash(), catalogStuff.getDeploymentHash()))))
            {
                log.info(String.format("Site %s will NOT apply an assumed restarted and identical catalog update with catalog hash %s and deployment hash %s.",
                            CoreUtils.hsIdToString(m_site.getCorrespondingSiteId()),
                            Encoder.hexEncode(catalogStuff.getCatalogHash()),
                            Encoder.hexEncode(catalogStuff.getDeploymentHash())));
            }
            else {
                VoltDB.crashLocalVoltDB("Invalid catalog update.  Expected version: " + expectedCatalogVersion +
                        ", current version: " + context.getCatalogVersion(), false, null);
            }
View Full Code Here


        // Pull the current catalog and deployment version and hash info.  Validate that we're either:
        // (a) starting a new, valid catalog or deployment update
        // (b) restarting a valid catalog or deployment update
        // otherwise, we can bomb out early.  This should guarantee that we only
        // ever write valid catalog and deployment state to ZK.
        CatalogAndIds catalogStuff = CatalogUtil.getCatalogFromZK(zk);
        // New update?
        if (catalogStuff.version == expectedCatalogVersion) {
            log.debug("New catalog update from: " + catalogStuff.toString());
            log.debug("To: catalog hash: " + Encoder.hexEncode(catalogHash).substring(0, 10) +
                    ", deployment hash: " + Encoder.hexEncode(deploymentHash).substring(0, 10));
        }
        // restart?
        else {
            if (catalogStuff.version == (expectedCatalogVersion + 1) &&
                (Arrays.equals(catalogStuff.getCatalogHash(), catalogHash) &&
                 Arrays.equals(catalogStuff.getDeploymentHash(), deploymentHash)))
            {
                log.debug("Restarting catalog update: " + catalogStuff.toString());
            }
            else {
                String errmsg = "Invalid catalog update.  Catalog or deployment change was planned " +
                        "against one version of the cluster configuration but that version was " +
                        "no longer live when attempting to apply the change.  This is likely " +
View Full Code Here

                    long catalogTxnId;
                    catalogTxnId = TxnEgo.makeZero(MpInitiator.MP_INIT_PID).getTxnId();

                    // Need to get the deployment bytes from ZK
                    CatalogAndIds catalogStuff =
                        CatalogUtil.getCatalogFromZK(m_rvdb.getHostMessenger().getZK());
                    byte[] deploymentBytes = catalogStuff.deploymentBytes;

                    // publish the catalog bytes to ZK
                    CatalogUtil.updateCatalogToZK(
View Full Code Here

            dependsOn(DistributeCatalog.class);
        }

        @Override
        public void run() {
            CatalogAndIds catalogStuff = null;
            do {
                try {
                    catalogStuff = CatalogUtil.getCatalogFromZK(m_rvdb.getHostMessenger().getZK());
                }
                catch (org.apache.zookeeper_voltpatches.KeeperException.NoNodeException e) {
View Full Code Here

                File deploymentFile = new File(pathToConfigInfoDir, "deployment.xml");
                if (deploymentFile.exists()) {
                    deploymentFile.delete();
                }
                FileOutputStream fileOutputStream = new FileOutputStream(deploymentFile);
                CatalogAndIds catalogStuff =
                    CatalogUtil.getCatalogFromZK(getHostMessenger().getZK());
                fileOutputStream.write(catalogStuff.deploymentBytes);
                fileOutputStream.close();
            } catch (Exception e) {
                hostLog.error("Failed to log deployment file: " + e.getMessage());
View Full Code Here

            newCatalog.execute(newCatalogCommands);

            // Retrieve the original deployment string, if necessary
            if (deploymentString == null) {
                // Go get the deployment string from ZK.  Hope it's there and up-to-date.  Yeehaw!
                CatalogAndIds catalogStuff =
                    CatalogUtil.getCatalogFromZK(VoltDB.instance().getHostMessenger().getZK());
                byte[] deploymentBytes = catalogStuff.deploymentBytes;
                if (deploymentBytes != null) {
                    deploymentString = new String(deploymentBytes, "UTF-8");
                }
View Full Code Here

                            new byte[] {}// spin loop in Inits.LoadCatalog.run() needs
                                            // this to be of zero length until we have a real catalog.
                            deploymentBytes);
                    hostLog.info("URL of deployment: " + m_config.m_pathToDeployment);
                } else {
                    CatalogAndIds catalogStuff = CatalogUtil.getCatalogFromZK(zk);
                    deploymentBytes = catalogStuff.deploymentBytes;
                }
            } catch (KeeperException.NodeExistsException e) {
                CatalogAndIds catalogStuff = CatalogUtil.getCatalogFromZK(zk);
                byte[] deploymentBytesTemp = catalogStuff.deploymentBytes;
                if (deploymentBytesTemp != null) {
                    //Check hash if its a supplied deployment on command line.
                    //We will ignore the supplied or default deployment anyways.
                    if (deploymentBytes != null && !m_config.m_deploymentDefault) {
                        byte[] deploymentHashHere =
                            CatalogUtil.makeCatalogOrDeploymentHash(deploymentBytes);
                        if (!(Arrays.equals(deploymentHashHere, catalogStuff.getDeploymentHash())))
                        {
                            hostLog.warn("The locally provided deployment configuration did not " +
                                    " match the configuration information found in the cluster.");
                        } else {
                            hostLog.info("Deployment configuration pulled from other cluster node.");
View Full Code Here

TOP

Related Classes of org.voltdb.utils.CatalogUtil.CatalogAndIds

Copyright © 2018 www.massapicom. 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.