Esempio n. 1
0
//////////////////////////////////////////////////////////////////////////
// flushJobs
void SysJobQueue::flushJobs( BcBool ForceExecute )
{
	while( anyJobsWaiting() )
	{
		if( ForceExecute )
		{
			SysJob* Job = nullptr;
			if( popJob( Job ) )
			{
				Job->internalExecute();
			}
		}

		Parent_->notifySchedule();
		std::this_thread::yield();
	}
}
Esempio n. 2
0
// main method
void MPlayerManager::run()
	throw()
{
	__BEGIN_TRY

	string host     = g_pConfig->getProperty("DB_HOST");
	string db       = g_pConfig->getProperty("DB_DB");
	string user     = g_pConfig->getProperty("DB_USER");
	string password = g_pConfig->getProperty("DB_PASSWORD");
	uint port		= 0;
	if (g_pConfig->hasKey("DB_PORT") )
		port = g_pConfig->getPropertyInt("DB_PORT");

	Connection* pConnection = new Connection(host, db, user, password, port);
    g_pDatabaseManager->addConnection(Thread::self(), pConnection);
	//cout << "******************************************************" << endl;
	//cout << " Mofus THREAD CONNECT DB " << endl;
	//cout << "******************************************************" << endl;

	Timeval dummyQueryTime;
	getCurrentTime(dummyQueryTime);

	while (1 )
	{
		usleep(100);

		// 현재 진행중인 Job 확인
		if (m_pCurrentJob == NULL )
		{
			m_pCurrentJob = popJob();
		}

		// 현재 진행중인 Job 이 있다면
		if (m_pCurrentJob != NULL )
		{
			// Mofus 와 연결해서 작업을 할 새 Player를 생성
			MPlayer* pPlayer = new MPlayer(m_pCurrentJob);

			// 파워포인트 가져오기 작업 진행
			pPlayer->process();

			// 결과처리
			processResult();

			// Player/Job 삭제
			SAFE_DELETE(pPlayer);
			SAFE_DELETE(m_pCurrentJob);
		}

		Timeval currentTime;
		getCurrentTime(currentTime);

		if (dummyQueryTime < currentTime )
		{
			g_pDatabaseManager->executeDummyQuery(pConnection);

			dummyQueryTime.tv_sec += (60 + rand() % 30 ) * 60;
		}
	}

	__END_CATCH
}
Esempio n. 3
0
int CScatteredManage::processJobs()
{
	SCNode nd;
	SCJob sj;
	tcps_Array<PCC_ModuleFile> moudleFiles;
	PCC_ModuleIndex index;
	//bool b_rest = true,b_r2 = false;
	int pre_node_num =-1;
	while (1)
	{
		if(pre_node_num != getNodeCounts())
		{
			printf("##当前可调度节点数:%d,待处理作业数:%d\n",pre_node_num = getNodeCounts(),getJobsCounts());
			
		}
		
		//检测job队列
		if(popJob(sj))
		{
			
			printf("当前可调度节点数:%d,待处理作业数:%d\n",getNodeCounts(),getJobsCounts()+1);

			//先判断jobkey对应的会话是否有效 //这一步看需求,是否支持不要回调通知的作业提交,这里标志以回调有效的方式处理
            if(!isValidJobRequest(sj.jobKey))
				continue;//忽略

			while(1)//轮询等待有空余节点可做scattered计算
			{
				
				if(popNode(nd))// 注意节点要在作业处理完后收回
				{
				    
					//nd.ps->m_ss = sj.ss;//回调senssion句柄 要是m_ss的servece_s的客户端断开了连接,这个指针会失效//jobkey
					
                    
					nd.ps->m_jobkey = sj.jobKey;
					printf("节点%p处理作业:%lld\n",nd.ps,sj.jobKey);
					index.moduleKey = sj.moduleKey;
					//确保节点端存在 moduleKey指定的模块
					moudleFiles.Release();
				    BOOL isFound = false;
					if(TCPS_OK ==nd.ps->FindModule(sj.moduleKey,isFound) )// 节点端没有,同步此模块
					{
						if(!isFound)
						{
							//读取模块 填充 index,moudleFiles
							if(getModules(index,moudleFiles))
							{
								//再次调用接口
								if(nd.ps->AddModule(sj.moduleKey,moudleFiles) != TCPS_OK)
								{
									nd.ps->m_ss = NULL;//for mark
									pushNode(nd.key,nd.ps);
									NPLogError(("模块更新失败,作业无法调度\n"));
									break;
								}
							}
							else
							{
								nd.ps->m_ss = NULL;//for mark
								pushNode(nd.key,nd.ps);
								NPLogError(("模块读取失败,作业无法调度\n"));
								break;
							}
						}
					}
					else
					{
						pushNode(nd.key,nd.ps);
						NPLogError(("无法获取模块状态!\n"));
						break;
					}
					//节点暂时分离出去了
					//这里应当添加节点处理超时
					nd.ps->Compute(sj.moduleKey,
					sj.jobKey,
					sj.info.dataInputUrl,
					sj.info.dataOutputUrl,
					sj.info.programParam);
					//nd.ps->AddMoudle(index,moudleFiles);
					//nd.ps->RemoveModule(0);
				
					break;
				}
				Sleep(1);
			}
		}
		
		Sleep(1);
	}
	return 0;
}