Esempio n. 1
0
void UserNameWriterAdapter::run()
{
	while(true)
	{
		MyUtil::IntSeq ids;
		{
			IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_mutex);
			if(_idSet.empty())
			{
				_mutex.wait();
			}
			ids.insert(ids.end(), _idSet.begin(), _idSet.end());
			_idSet.clear();
		}
		for(MyUtil::IntSeq::const_iterator it = ids.begin(); it != ids.end(); ++it)
		{
			UserNameWriterPrx prx = getUserNameWriter(*it);
			if(prx)
			{
				try
				{
					prx->reload(*it);
				}catch(Ice::Exception& e)
				{
					MCE_WARN("UserNameWriterAdapter::run reload Exception id = " << *it <<" " << e.what());
				}
			}
		}
	}
}
Esempio n. 2
0
void MiniGroupWriterAdapter::run() {
  while (true) {
    MyUtil::IntSeq userIds;
    MyUtil::LongSeq miniGroupIds;
    {
      IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_mutex);
      if (_userIdSet.empty() && _miniGroupIdSet.empty()) {
        _mutex.wait();
      }
      userIds.insert(userIds.end(), _userIdSet.begin(), _userIdSet.end());
      _userIdSet.clear();
      miniGroupIds.insert(miniGroupIds.end(), _miniGroupIdSet.begin(), _miniGroupIdSet.end());
      _miniGroupIdSet.clear();
    }
    if (!userIds.empty()) {
      try {
        getMiniGroupWriterPrx(0)->reloadUsers(userIds);
      } catch(Ice::Exception& e) {
        MCE_WARN("[MiniGroupWriterAdapter::run] reloadUsers size = " << userIds.size());
      }
    }
    if (!miniGroupIds.empty()) {
      try {
        getMiniGroupWriterPrx(0)->reloadMiniGroups(miniGroupIds);
      } catch(Ice::Exception& e) {
        MCE_WARN("[MiniGroupWriterAdapter::run] reloadMiniGroups size = " << miniGroupIds.size());
      }
    }
  }
}
Esempio n. 3
0
void RoomManagerI::removeRoom(const RoomIdPtr& rid, const Ice::Current&) {
	IceUtil::RWRecMutex::WLock lock(_mutex);
	MCE_DEBUG("RoomManagerI::removeRoom --> remove room, "
			<< roomIdToString(rid));

	Ice::Long hashcode = StrUtil::hashcode(roomIdToString(rid));
	RoomClusterPtr rc = ServiceI::instance().findObject<RoomClusterPtr>(ROOM_CLUSTER, hashcode);
	if (!rc) {
		return;
	}
	rc->remove(rid);

	MemberListPtr ml = ServiceI::instance().locateObject<MemberListPtr>(MEMBER_LIST, hashcode);
	if (!ml) {
		return;
	}

	Int2IntSeqMap memMap = ml->getMemberList(rid);
/*	for (Int2IntSeqMap::iterator it = memMap.begin(); it != memMap.end(); ++it) {
		for (size_t i = 0; i < it->second.size(); ++i) {
			RoomListPtr rl = ServiceI::instance().findObject<RoomListPtr>(ROOM_LIST, it->second.at(i));
			if (rl) {
				rl->removeRoom(rid);
			}
		}
	}
*/
	ml->remove(rid);

	Statement sql;
	sql << "delete from room where roomid='" << roomIdToString(rid) << "'";
	Statement sql2;
	sql2 << "delete from room_member where roomid='" << roomIdToString(rid)
			<< "'";

	try {
		QueryRunner("im_groupchat", CDbWServer).store(sql);
		QueryRunner("im_groupchat", CDbWServer).store(sql2);
	} catch(Ice::Exception& e) {
		MCE_WARN(e << " at " << __FILE__ << ":" << __LINE__);
	} catch (std::exception& e) {
		MCE_WARN(e.what() << " at " << __FILE__ << ":" << __LINE__);
	} catch (...) {
		MCE_WARN("Unkown exception at " << __FILE__ << ":" << __LINE__);
	}
	MyUtil::IntSeq userIds;
	for (Int2IntSeqMap::iterator it = memMap.begin(); it != memMap.end(); ++it) {
		if(it->first < Member){
			continue;
		}
		userIds.insert(userIds.end(), it->second.begin(), it->second.end());
	}
	UserRoomAdapter::instance().removeRoomIds(userIds, rid);
}
Esempio n. 4
0
//--------------------------------------------------------------------------------
void VertifyPipe::handle(const ObjectSeq& seq) {

	//MCE_INFO("VertifyPipe::handle --> thread_id = " << pthread_self());
	if (seq.empty()) {
		return;
	} else {
		//MCE_DEBUG("VertifyPipe::handle --> objectseq size = " <<seq.size());
	}
	
	VerifySeq vSeq;
	IntSeq needNotVerifyUsers;
	for (size_t i = 0; i < seq.size(); ++i) {
		MessagePtr m = MessagePtr::dynamicCast(seq.at(i));
		//MCE_INFO("m->from = " << m->from->userId << " m->to = " << m->to->userId);
		if( (m->type != MESSAGE && m->type != OFFLINE_MESSAGE) || (m->from->userId == 365734329 || m->to->userId == 365734329) ){//客服ID,不检查好友。
			//MCE_INFO("VertifyPipe::handle --> m->from = " << m->from << " m->to = " << m->to);
			needNotVerifyUsers.push_back(i);
			continue;
		}
		VerifyPtr v = new Verify();
		v->from = m->from->userId;
		v->to = m->to->userId;
		/*if(MESSAGE != m->type){
			v->to = v->from;
		}*/
		v->type = m->type;

/*		if (v->type == SYSTEM_MESSAGE) {
			v->sysMsgType = m->from->endpoint;
		}*/
		v->index = i;

		vSeq.push_back(v);
	}
	MyUtil::IntSeq indexSeq;
	try{
	 indexSeq = TalkRightAdapter::instance().batchVerify(getIndex(), vSeq);
	}catch(Ice::Exception& e){
		MCE_WARN("VertifyPipe::handle-->TalkRightAdapter::batchVerify-->" << e);
		}
	indexSeq.insert(indexSeq.end(), needNotVerifyUsers.begin(), needNotVerifyUsers.end());

	//MCE_DEBUG("VertifyPipe::handle -->indexSeq size:"<<indexSeq.size());
	for (size_t i = 0; i < indexSeq.size(); ++i) {
		MessagePtr m = MessagePtr::dynamicCast(seq.at(indexSeq.at(i)));
		//MCE_DEBUG("VertifyPipe::handle --> "<<m->to->index);
		if (m->to->index == 0 || m->to->index == 2 || m->to->index >1) {
			//MCE_DEBUG("VertifyPipe::handle --> endpoint:"<<m->to->endpoint);
			PipePool::instance().push(m->to->endpoint, 0, m);
		}
	}

}
Esempio n. 5
0
MyUtil::IntSeq TalkRightAdapter::batchVerify(const VerifySeq& seq) {
	map<int, VerifySeq> vMap;
	for (size_t i = 0; i < seq.size(); ++i) {
		vMap[abs(seq.at(i)->to) % getCluster()].push_back(seq.at(i));
	}
	MyUtil::IntSeq res;
	for (map<int,VerifySeq>::iterator it = vMap.begin(); it != vMap.end(); ++it) {
		try {
			MyUtil::IntSeq tmp = getManager(it->first)->batchVerify(it->second);
			res.insert(res.end(),tmp.begin(),tmp.end());
		} catch(...) {
			for(size_t i = 0; i < it->second.size(); ++i){
				res.push_back(it->second.at(i)->index);
			}
		}
	}
	return res;
}
Esempio n. 6
0
void xce::distcache::userapicache::DelayReloadThread::run()
{
  while(true)
  {
    MyUtil::IntSeq ids;
    {
      IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_mutex);
      if(_idSet.empty())
      {
        _mutex.timedWait(IceUtil::Time::seconds(1));
      }
      if(_idSet.empty())
      {
        continue;
      }
      ids.insert(ids.end(),_idSet.begin(), _idSet.end());
      _idSet.clear();
    }
    MyUtil::TaskManager::instance().execute(new ReloadTask(ids));
  }
}