@Test public void testPromoteWithCommandLogging() throws Exception { org.voltdb.catalog.CommandLog logConfig = m_context.cluster.getLogconfig().get("log"); boolean wasEnabled = logConfig.getEnabled(); logConfig.setEnabled(true); try { final ByteBuffer msg = createMsg("@Promote"); m_ci.handleRead(msg, m_handler, m_cxn); // Verify that the truncation request node was created. verify(m_zk, never()) .create( eq(VoltZK.request_truncation_snapshot), any(byte[].class), eq(Ids.OPEN_ACL_UNSAFE), eq(CreateMode.PERSISTENT)); } finally { logConfig.setEnabled(wasEnabled); } }
public void configureLogging( boolean enabled, boolean sync, int fsyncInterval, int maxTxns, String logPath, String snapshotPath) { org.voltdb.catalog.CommandLog logConfig = getCluster().getLogconfig().get("log"); if (logConfig == null) { logConfig = getCluster().getLogconfig().add("log"); } logConfig.setEnabled(enabled); logConfig.setSynchronous(sync); logConfig.setFsyncinterval(fsyncInterval); logConfig.setMaxtxns(maxTxns); logConfig.setLogpath(logPath); logConfig.setInternalsnapshotpath(snapshotPath); }
@Override public void run() { if (!m_isRejoin && !m_config.m_isRejoinTest && !m_rvdb.m_joining) { String snapshotPath = null; if (m_rvdb .m_catalogContext .cluster .getDatabases() .get("database") .getSnapshotschedule() .get("default") != null) { snapshotPath = m_rvdb .m_catalogContext .cluster .getDatabases() .get("database") .getSnapshotschedule() .get("default") .getPath(); } int[] allPartitions = new int[m_rvdb.m_configuredNumberOfPartitions]; for (int ii = 0; ii < allPartitions.length; ii++) { allPartitions[ii] = ii; } org.voltdb.catalog.CommandLog cl = m_rvdb.m_catalogContext.cluster.getLogconfig().get("log"); try { m_rvdb.m_restoreAgent = new RestoreAgent( m_rvdb.m_messenger, m_rvdb.getSnapshotCompletionMonitor(), m_rvdb, m_config.m_startAction, cl.getEnabled(), cl.getLogpath(), cl.getInternalsnapshotpath(), snapshotPath, allPartitions, CatalogUtil.getVoltDbRoot(m_deployment.getPaths()).getAbsolutePath()); } catch (IOException e) { VoltDB.crashLocalVoltDB("Unable to construct the RestoreAgent", true, e); } m_rvdb.m_globalServiceElector.registerService(m_rvdb.m_restoreAgent); m_rvdb.m_restoreAgent.setCatalogContext(m_rvdb.m_catalogContext); // Generate plans and get (hostID, catalogPath) pair Pair<Integer, String> catalog = m_rvdb.m_restoreAgent.findRestoreCatalog(); // if the restore agent found a catalog, set the following info // so the right node can send it out to the others if (catalog != null) { // Make sure the catalog corresponds to the current server version. // Prevent automatic upgrades by rejecting mismatched versions. int hostId = catalog.getFirst().intValue(); String catalogPath = catalog.getSecond(); // Perform a version check when the catalog jar is available // 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)) { VoltDB.crashLocalVoltDB( String.format( "Unable to load version %s catalog \"%s\" " + "from snapshot into a version %s server.", catalogVersion, catalogPath, serverVersion), false, null); } } catch (IOException e) { // Make it non-fatal with no check performed. hostLog.warn( String.format( "Unable to load catalog for version check due to exception: %s.", e.getMessage())); } } hostLog.debug("Found catalog to load on host " + hostId + ": " + catalogPath); m_rvdb.m_hostIdWithStartupCatalog = hostId; assert (m_rvdb.m_hostIdWithStartupCatalog >= 0); m_rvdb.m_pathToStartupCatalog = catalogPath; assert (m_rvdb.m_pathToStartupCatalog != null); } } }