Launches polling thread on a particular mount point with starting txId.

@param mountId launch polling thread on a mount id
@param txId specifies the transaction id to initialize the pollling thread
761079
public void launchPollingThread(long mountId, long txId) {
    LOG.debug("launch polling thread for mount id {}, txId {}", mountId, txId);
    if (!mPollerMap.containsKey(mountId)) {
      try (CloseableResource<UnderFileSystem> ufsClient =
               mMountTable.getUfsClient(mountId).acquireUfsResource()) {
        ufsClient.get().startActiveSyncPolling(txId);
      } catch (IOException e) {
        LOG.warn("IO Exception trying to launch Polling thread {}", e);
      }
      ActiveSyncer syncer = new ActiveSyncer(mFileSystemMaster, this, mMountTable, mountId);
      Future<?> future = getExecutor().submit(
          new HeartbeatThread(HeartbeatContext.MASTER_ACTIVE_UFS_SYNC,
              syncer, (int) ServerConfiguration.getMs(PropertyKey.MASTER_ACTIVE_UFS_SYNC_INTERVAL),
              ServerConfiguration.global()));
      mPollerMap.put(mountId, future);
    }
  }
590791
public void setCommittedTxId(long txid, boolean force) {
    for (AsyncLogger logger : loggers) {
      logger.setCommittedTxId(txid, force);
    }
  }
263911
private void pingTransactions() {
        log.info("Start sending transaction pings.");
        txnList.stream().forEach(uuid -> {
            try {
                log.debug("Sending ping request for txn ID: {} with lease: {}", uuid, txnLeaseMillis);
                controller.pingTransaction(stream, uuid, txnLeaseMillis)
                .exceptionally(e -> {
                    log.warn("Ping Transaction for txn ID:{} failed", uuid, e);
                    return null;
                });
            } catch (Exception e) {
                // Suppressing exception to prevent future pings from not being executed. 
                log.warn("Encountered exception when attepting to ping transactions", e);
            }
        });
        log.trace("Completed sending transaction pings.");
    }
1264594
@Override
    public void run(SiteProcedureConnection siteConnection)
    {
        final String threadName = Thread.currentThread().getName(); // Thread name has to be materialized here
        final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.MPSITE);
        if (traceLog != null) {
            traceLog.add(() -> VoltTrace.meta("thread_name", "name", threadName))
                    .add(() -> VoltTrace.meta("thread_sort_index", "sort_index", Integer.toString(1000)))
                    .add(() -> VoltTrace.beginDuration("mpinittask",
                                                       "txnId", TxnEgo.txnIdToString(getTxnId())));
        }

        // Cast up. Could avoid ugliness with Iv2TransactionClass baseclass
        MpTransactionState txn = (MpTransactionState)m_txnState;
        // Check for restarting sysprocs
        String spName = txn.m_initiationMsg.getStoredProcedureName();
        // could be null if not a sysproc
        final SystemProcedureCatalog.Config sysproc = SystemProcedureCatalog.listing.get(spName);

        // certain system procs can and can't be restarted
        // Right now this is adhoc, catalog update, load MP table, and apply binary log MP.
        //
        // Note that we don't restart @BalancePartitions transactions, because they do
        // partition to master HSID lookups in the run() method. When transactions are
        // restarted, the run() method is not rerun. Let the elastic join coordinator reissue it.
        if (m_isRestart &&
                sysproc != null &&
                !sysproc.isRestartable())
        {
            InitiateResponseMessage errorResp = new InitiateResponseMessage(txn.m_initiationMsg);
            errorResp.setResults(new ClientResponseImpl(ClientResponse.UNEXPECTED_FAILURE,
                        new VoltTable[] {},
                        "Failure while running system procedure " + txn.m_initiationMsg.getStoredProcedureName() +
                        ", and system procedures can not be restarted."));
            errorResp.m_isFromNonRestartableSysproc = true;
            errorResp.m_sourceHSId = m_initiator.getHSId();
            m_txnState.setDone();
            m_queue.flush(getTxnId());
            m_initiator.deliver(errorResp);

            if (hostLog.isDebugEnabled()) {
                hostLog.debug("SYSPROCFAIL: " + this);
            }
            return;
        }

        // Let's ensure that we flush any previous attempts of this transaction
        // at the masters we're going to try to use this time around.
        if (m_isRestart) {
            CompleteTransactionMessage restart = new CompleteTransactionMessage(
                    m_initiator.getHSId(), // who is the "initiator" now??
                    m_initiator.getHSId(),
                    m_txnState.txnId,
                    m_txnState.isReadOnly(),
                    0,
                    true,   // rollback
                    false,  // really don't want to have ack the ack.
                    true,   // Don't clear/flush the txn because we are restarting it
                    m_msg.isForReplay(),
                    txn.isNPartTxn(),
                    false,
                    false);
            // TransactionTaskQueue uses it to find matching CompleteTransactionMessage
            long ts = m_restartSeqGenerator.getNextSeqNum();
            restart.setTimestamp(ts);
            // Update the timestamp to txnState so following restarted fragments could use it
            m_txnState.setTimestamp(ts);
            restart.setTruncationHandle(m_msg.getTruncationHandle());
            //restart.setForReplica(false);
            if (hostLog.isDebugEnabled()) {
                hostLog.debug("MP restart cleanup CompleteTransactionMessage "+ MpRestartSequenceGenerator.restartSeqIdToString(ts) +
                        " to: " + CoreUtils.hsIdCollectionToString(m_initiatorHSIds));
            }
            m_initiator.send(com.google_voltpatches.common.primitives.Longs.toArray(m_initiatorHSIds), restart);
        }
        if (hostLog.isDebugEnabled()) {
            hostLog.debug("[MpProcedureTask] STARTING: " + this);
        }
        final InitiateResponseMessage response = processInitiateTask(txn.m_initiationMsg, siteConnection);
        // We currently don't want to restart read-only MP transactions because:
        // 1) We're not writing the Iv2InitiateTaskMessage to the first
        // FragmentTaskMessage in read-only case in the name of some unmeasured
        // performance impact,
        // 2) We don't want to perturb command logging and/or DR this close to the 3.0 release
        // 3) We don't guarantee the restarted results returned to the client
        // anyway, so not restarting the read is currently harmless.
        // We could actually restart this here, since we have the invocation, but let's be consistent?
        int status = response.getClientResponseData().getStatus();
        if (status == ClientResponse.TXN_MISROUTED) {
            if (m_msg.isReadOnly()) {
                if (!response.shouldCommit()) {
                    txn.setNeedsRollback(true);
                }
                completeInitiateTask(siteConnection);
                response.m_sourceHSId = m_initiator.getHSId();
                response.setMisrouted(m_msg.getStoredProcedureInvocation());
                m_initiator.deliver(response);
            } else {
                restartTransaction();
            }
            if (hostLog.isDebugEnabled()) {
                hostLog.debug("[MpProcedureTask] MISROUTED-RESTART: " + this);
            }
        } else {
            if (status != ClientResponse.TXN_RESTART || (status == ClientResponse.TXN_RESTART && m_msg.isReadOnly())) {
                if (!response.shouldCommit()) {
                    txn.setNeedsRollback(true);
                }
                else {
                    // rollback responses won't advance the truncation point so skip the update
                    response.setMpFragmentSent(txn.haveSentFragment());
                }
                completeInitiateTask(siteConnection);
                // Set the source HSId (ugh) to ourselves so we track the message path correctly
                response.m_sourceHSId = m_initiator.getHSId();
                m_initiator.deliver(response);
                execLog.l7dlog( Level.TRACE, LogKeys.org_voltdb_ExecutionSite_SendingCompletedWUToDtxn.name(), null);
                if (hostLog.isDebugEnabled()) {
                    hostLog.debug("[MpProcedureTask] COMPLETE: " + this);
                }
            } else {
                restartTransaction();
                if (hostLog.isDebugEnabled()) {
                    hostLog.debug("[MpProcedureTask] RESTART: " + this);
                }
            }
        }

        if (traceLog != null) {
            traceLog.add(VoltTrace::endDuration);
        }
    }
608479
public void createCheckpoint(Transaction checkpointTx) {
		// stop access new tx request and find out active txs by using a write
		// lock on threadTxNums
		List<Long> txNums;
		// for (Transaction tx : activeTxs)
		// if (tx.getTransactionNumber() != checkpointTx
		// .getTransactionNumber())
		// txNums.add(tx.getTransactionNumber());

		// activeTxsLock.writeLock().lock();
		// try {
		// for (Long l : threadTxNums) {
		// if (l >= 0) {
		// txNums.add(l);
		// }
		// }
		//
		// // flush all buffers
		// // CT : Pick a tx and call its bufferMgr flushAll, or get
		// // bufferPoolMgr (init it at VanillaDb)
		// checkpointTx.bufferMgr().flushAll();
		// // wrtie a checkpoint record and flush to disk
		// LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums);
		// VanillaDb.logMgr().flush(lsn);
		// System.out.println("Chkpnt :" + txNums);
		// } finally {
		// activeTxsLock.writeLock().unlock();
		// }

		// Old method
		synchronized (this) {
			txNums = new LinkedList<Long>(activeTxs);
			checkpointTx.bufferMgr().flushAll();
			LogSeqNum lsn = checkpointTx.recoveryMgr().checkpoint(txNums);
			VanillaDb.logMgr().flush(lsn);
		}
	}
1055793
@Override
  public PollResult startPoll(PollController conn)
  {
    if (! _lifecycle.isActive()) {
      log.warning(this + " select disabled");
        
      return PollResult.CLOSED;
    }
    else if (_selectMax <= _connectionCount.get()) {
      log.warning(this + " keepalive overflow "
                  + _connectionCount + " max=" + _selectMax);
      System.out.println("OVERFLOW:");
      
      return PollResult.CLOSED;
    }
    
    if (! conn.toKeepaliveStart()) {
      return PollResult.CLOSED;
    }

    return poll(conn);
  }
554317
public void stopSyncForMount(long mountId) throws InvalidPathException, IOException {
    LOG.debug("Stop sync for mount id {}", mountId);
    if (mFilterMap.containsKey(mountId)) {
      List<Pair<AlluxioURI, MountTable.Resolution>> toBeDeleted = new ArrayList<>();
      for (AlluxioURI uri : mFilterMap.get(mountId)) {
        MountTable.Resolution resolution = resolveSyncPoint(uri);
        if (resolution != null) {
          toBeDeleted.add(new Pair<>(uri, resolution));
        }
      }
      // Calling stopSyncInternal outside of the traversal of mFilterMap.get(mountId) to avoid
      // ConcurrentModificationException
      for (Pair<AlluxioURI, MountTable.Resolution> deleteInfo : toBeDeleted) {
        stopSyncInternal(deleteInfo.getFirst(), deleteInfo.getSecond());
      }
    }
  }
83122
@Override
  public void onNext(final String alarmId) {
    LOG.log(Level.INFO, "Alarm {0} triggered", alarmId);
    final ClientAlarm clientAlarm = this.alarmMap.remove(alarmId);
    if (clientAlarm != null) {
      clientAlarm.run();
    } else {
      LOG.log(Level.SEVERE, "Unknown alarm id {0}", alarmId);
    }
  }
156162
public function startTransaction()
    {

        if (!is_a($this->resourceId, "mysqli")) {
            throw new QueryException("No valid db resource Id found. This is required to start a transaction");
            return false;
        }
        $this->resourceId->autocommit(FALSE); //Turns autocommit off;

    }
544006
protected function addPageToMountingSiteIndexQueue($mountedPageId, array $mountProperties)
    {
        $siteRepository = GeneralUtility::makeInstance(SiteRepository::class);
        $mountingSite = $siteRepository->getSiteByPageId($mountProperties['mountPageDestination']);

        /** @var $pageInitializer Page */
        $pageInitializer = GeneralUtility::makeInstance(Page::class);
        $pageInitializer->setSite($mountingSite);

        $pageInitializer->initializeMountedPage($mountProperties, $mountedPageId);
    }
303093
@Override
  public void resetState() {
    for (long mountId : mFilterMap.keySet()) {
      try {
        // stops sync point under this mount point. Note this clears the sync point and
        // stops associated polling threads.
        stopSyncForMount(mountId);
      } catch (IOException | InvalidPathException e) {
        LOG.info("Exception resetting mountId {}, exception: {}", mountId, e);
      }
    }
  }
715436
@Override
  public final boolean setRoutingObjectID(DBID objectID) {
    if(objectID == routingObjectID || DBIDUtil.equal(objectID, routingObjectID)) {
      return false;
    }
    this.routingObjectID = objectID;
    return true;
  }
1182593
public function setTransactionId($transactionId)
    {
        if (is_numeric($transactionId) || $transactionId === false) {
            $this->params['transactionId'] = $transactionId;
            return $this;
        }
        throw new Exception("Please use a numeric value for transaction ID");
    }
489622
public void assignTransaction(TransactionImpl v)
   {
      txs.put(Long.valueOf(Thread.currentThread().getId()), v);
   }
1263574
public void startBranch(TextBuffer tb, int startOffset,
                            boolean convertLFs)
    {
        mBranchBuffer = tb;
        mBranchStartOffset = startOffset;
        mConvertLFs = convertLFs;
        mGotCR = false;
    }
1206135
@Override
	public void onTxCommit(Transaction tx) {
		if (!tx.isReadOnly() && enableLogging) {
			LogSeqNum lsn = new CommitRecord(txNum).writeToLog();
			VanillaDb.logMgr().flush(lsn);
		}
	}
452317
@Override
    public void launch(@NonNull ThreadingModel threading) {
        this.threadingModel = threading;

        switch (threading) {
            case SINGLE_THREAD: {

                log.warn("SINGLE_THREAD model is used, performance will be significantly reduced");

                // single thread for all queues. shouldn't be used in real world
                threadA = new Thread(() -> {
                    while (runner.get()) {
                        if (subscriptionForShards != null)
                            subscriptionForShards.poll(messageHandlerForShards, 512);

                        idler.idle(subscriptionForClients.poll(messageHandlerForClients, 512));
                    }
                });

                threadA.setDaemon(true);
                threadA.start();
                }
                break;
            case DEDICATED_THREADS: {
                // we start separate thread for each handler

                /**
                 * We definitely might use less conditional code here, BUT i'll keep it as is,
                 * only because we want code to be obvious for people
                 */
                final AtomicBoolean localRunner = new AtomicBoolean(false);
                if (nodeRole == NodeRole.NONE) {
                    throw new ND4JIllegalStateException("No role is set for current node!");
                } else if (nodeRole == NodeRole.SHARD || nodeRole == NodeRole.BACKUP || nodeRole == NodeRole.MASTER) {
                    // // Shard or Backup uses two subscriptions

                    // setting up thread for shard->client communication listener
                    if (messageHandlerForShards != null) {
                        threadB = new Thread(() -> {
                            while (runner.get())
                                idler.idle(subscriptionForShards.poll(messageHandlerForShards, 512));

                        });
                        threadB.setDaemon(true);
                        threadB.setName("VoidParamServer subscription threadB [" + nodeRole + "]");
                    }

                    // setting up thread for inter-shard communication listener
                    threadA = new Thread(() -> {
                        localRunner.set(true);
                        while (runner.get())
                            idler.idle(subscriptionForClients.poll(messageHandlerForClients, 512));
                    });

                    if (threadB != null) {
                        Nd4j.getAffinityManager().attachThreadToDevice(threadB,
                                        Nd4j.getAffinityManager().getDeviceForCurrentThread());
                        threadB.setDaemon(true);
                        threadB.setName("VoidParamServer subscription threadB [" + nodeRole + "]");
                        threadB.start();
                    }
                } else {
                    // setting up thread for shard->client communication listener
                    threadA = new Thread(() -> {
                        localRunner.set(true);
                        while (runner.get())
                            idler.idle(subscriptionForClients.poll(messageHandlerForClients, 512));
                    });
                }

                // all roles have threadA anyway
                Nd4j.getAffinityManager().attachThreadToDevice(threadA,
                                Nd4j.getAffinityManager().getDeviceForCurrentThread());
                threadA.setDaemon(true);
                threadA.setName("VoidParamServer subscription threadA [" + nodeRole + "]");
                threadA.start();

                while (!localRunner.get())
                    try {
                        Thread.sleep(50);
                    } catch (Exception e) {
                    }
            }
                break;
            case SAME_THREAD: {
                // no additional threads at all, we do poll within takeMessage loop
                log.warn("SAME_THREAD model is used, performance will be dramatically reduced");
            }
                break;
            default:
                throw new IllegalStateException("Unknown thread model: [" + threading.toString() + "]");
        }
    }