private void logToDR(PartitionDRGateway drGateway) { // Log invocation to DR if (drGateway != null && !m_txnState.isForReplay() && !m_txnState.isReadOnly() && !m_completeMsg.isRollback()) { FragmentTaskMessage fragment = (FragmentTaskMessage) m_txnState.getNotice(); Iv2InitiateTaskMessage initiateTask = fragment.getInitiateTask(); assert (initiateTask != null); if (initiateTask == null) { hostLog.error( "Unable to log MP transaction to DR because of missing InitiateTaskMessage, " + "fragment: " + fragment.toString()); } StoredProcedureInvocation invocation = initiateTask.getStoredProcedureInvocation().getShallowCopy(); drGateway.onSuccessfulMPCall( m_txnState.m_spHandle, m_txnState.txnId, m_txnState.uniqueId, m_completeMsg.getHash(), invocation, m_txnState.getResults()); } }
@Override public void configure( BackendTarget backend, String serializedCatalog, CatalogContext catalogContext, int kfactor, CatalogSpecificPlanner csp, int numberOfPartitions, VoltDB.START_ACTION startAction, StatsAgent agent, MemoryStats memStats, CommandLog cl, NodeDRGateway nodeDRGateway, String coreBindIds) throws KeeperException, InterruptedException, ExecutionException { try { m_leaderCache.start(true); } catch (Exception e) { VoltDB.crashLocalVoltDB("Unable to configure SpInitiator.", true, e); } // configure DR PartitionDRGateway drGateway = PartitionDRGateway.getInstance( m_partitionId, nodeDRGateway, true, VoltDB.createForRejoin(startAction)); ((SpScheduler) m_scheduler).setDRGateway(drGateway); super.configureCommon( backend, serializedCatalog, catalogContext, csp, numberOfPartitions, startAction, agent, memStats, cl, coreBindIds, drGateway); m_tickProducer.start(); // add ourselves to the ephemeral node list which BabySitters will watch for this // partition LeaderElector.createParticipantNode( m_messenger.getZK(), LeaderElector.electionDirForPartition(m_partitionId), Long.toString(getInitiatorHSId()), null); }
/** * Load the full subclass if it should, otherwise load the noop stub. * * @param partitionId partition id * @param overflowDir * @return Instance of PartitionDRGateway */ public static PartitionDRGateway getInstance( int partitionId, NodeDRGateway nodeGateway, boolean isRejoin) { final VoltDBInterface vdb = VoltDB.instance(); LicenseApi api = vdb.getLicenseApi(); final boolean licensedToDR = api.isDrReplicationAllowed(); // if this is a primary cluster in a DR-enabled scenario // try to load the real version of this class PartitionDRGateway pdrg = null; if (licensedToDR && nodeGateway != null) { pdrg = tryToLoadProVersion(); } if (pdrg == null) { pdrg = new PartitionDRGateway(); } // init the instance and return try { pdrg.init(partitionId, nodeGateway, isRejoin); } catch (IOException e) { VoltDB.crashLocalVoltDB(e.getMessage(), false, e); } return pdrg; }