void CtaArtefactActivation::UpdateActivation()
{
	if (!IsInProgress())
		return;

	VERIFY(!physics_world()->Processing());
	m_cur_state_time				+=	Device.fTimeDelta;
	if(m_cur_state_time				>=	m_activation_states[int(m_cur_activation_state)].m_time){
		m_cur_activation_state		=	(EActivationStates)(int)(m_cur_activation_state+1);
		
		if(m_cur_activation_state == eMax){
			m_cur_activation_state = eNone;
			//m_af->processing_deactivate			();
			//m_af->DestroyObject();
		}

		m_cur_state_time	= 0.0f;
		ChangeEffects				();


	if(m_cur_activation_state==eSpawnZone && OnServer())
		SpawnAnomaly	();

	}
	UpdateEffects				();
}
bool  CVotingSystem::StartVoting(EntityId id, const CTimeValue& start, EVotingState st, EntityId eid, const char* subj)
{
  if(st == eVS_none)
    return false;
  if(IsInProgress())
    return false;
  SVoting v;
  v.initiator = id;
  v.startTime = start;
  m_votings.push_back(v);
  m_votesFor.resize(0);
  m_votesAgainst.resize(0);

	m_subject = subj?subj:"";
  m_state = st;
  m_id = eid;

  m_startTime = start;
  return true;
}
Exemplo n.º 3
0
// Test to make sure that the restorer sends restore request
// and sends it to all stmgrs
TEST(StatefulRestorer, test_restore_send) {
  CommonResources common;
  SetUpCommonResources(common);

  // Start the tmaster etc.
  StartDummyTMaster(common);

  // Distribute workers across stmgrs
  DistributeWorkersAcrossStmgrs(common);

  // Start the stmgr
  StartStMgrs(common);

  // Wait until all stmgrs registered
  while (common.tmaster_->stmgrs().size() != common.num_stmgrs_) sleep(1);

  // Make sure that stmgrs have not gotten any restore message
  for (auto stmgr : common.stmgrs_list_) {
    EXPECT_FALSE(stmgr->GotRestoreMessage());
  }
  // Start Restorer
  auto restorer = new heron::tmaster::StatefulRestorer();
  EXPECT_FALSE(restorer->IsInProgress());
  common.tmaster_piper_->ExecuteInEventLoop(
        std::bind(&heron::tmaster::StatefulRestorer::StartRestore,
                  restorer, "ckpt-1", common.tmaster_->stmgrs()));

  sleep(1);
  // all stmgrs should have received restore message
  for (auto stmgr : common.stmgrs_list_) {
    EXPECT_TRUE(stmgr->GotRestoreMessage());
  }
  EXPECT_TRUE(restorer->IsInProgress());
  sp_int64 txid = restorer->GetRestoreTxid();

  // Simulate restored message
  for (auto stmgr : common.stmgrs_list_) {
    EXPECT_FALSE(restorer->GotResponse(stmgr->stmgrid()));
    EXPECT_FALSE(stmgr->GotStartProcessingMessage());
    common.tmaster_piper_->ExecuteInEventLoop(
        std::bind(&heron::tmaster::StatefulRestorer::HandleStMgrRestored,
                  restorer, stmgr->stmgrid(), "ckpt-1", txid, common.tmaster_->stmgrs()));
    sleep(1);
    EXPECT_TRUE(restorer->GotResponse(stmgr->stmgrid()));
  }

  // The 2 phase commit should have finished
  EXPECT_FALSE(restorer->IsInProgress());

  sleep(1);

  // All stmgrs should have gotten start message
  for (auto stmgr : common.stmgrs_list_) {
    EXPECT_TRUE(stmgr->GotStartProcessingMessage());
  }

  // Stop the schedulers
  for (size_t i = 0; i < common.ss_list_.size(); ++i) {
    common.ss_list_[i]->loopExit();
  }

  // Wait for the threads to terminate
  common.tmaster_thread_->join();
  for (size_t i = 0; i < common.stmgrs_threads_list_.size(); ++i) {
    common.stmgrs_threads_list_[i]->join();
  }

  // Delete the common resources
  TearCommonResources(common);
  delete restorer;
}