bool CmdSrvHosts::processArguments( int argc, char** argv, af::Msg &msg) { Py_InitializeEx(0); std::string command( argv[1]); std::list<std::string> hosts; for( int a = 2; a < argc; a++) hosts.push_back( argv[a]); std::string wdir; int capacity = -1; std::string files; af::Service service( argv[0], wdir, command, files, capacity, hosts); if( service.isInitialized() == false) { AFERRAR("Service '%s' initialization failed.\n", argv[0]); return false; } command = service.getCommand(); std::cout << "Result Command:"; std::cout << std::endl; std::cout << command; std::cout << std::endl; Py_Finalize(); return true; }
bool ParserHost::shiftData( int shift) { if( shift < 0 ) { AFERRAR("ParserHost::shiftData: shift < 0 (%d<0)\n", shift); return false; } if( shift == 0 ) return true; memcpy( m_data+ms_DataSizeHalf, m_data+ms_DataSizeHalf+shift, m_datasize-ms_DataSizeHalf-shift); m_datasize -= shift; return true; }
void RenderAf::addService( const std::string & type) { af::farm()->serviceLimitAdd( type, m_name); for( int i = 0; i < m_services_num; i++) { if( m_host.getServiceName(i) == type) { m_services_counts[i]++; if((m_host.getServiceCount(i) > 0 ) && (m_services_counts[i] > m_host.getServiceCount(i))) AFERRAR("RenderAf::addService: m_services_counts > host.getServiceCount for '%s' (%d>=%d)", type.c_str(), m_services_counts[i], m_host.getServiceCount(i)) return; } }
bool afqt::sendMessage( QTcpSocket * qSocket, const af::Msg * msg) { #ifdef AFOUTPUT printf("afqt::sendMessage: "); msg->v_stdOut(); #endif // // sending message to server int result = qSocket->write( msg->buffer(), msg->writeSize()); qSocket->waitForBytesWritten( WAITFORBYTESWRITTEN); if( result < msg->writeSize()) { AFERRAR("qtcom::sendMessage: sending writing message failed, result < msg.writeSize() ( %d < %d )\n", result, msg->writeSize()); return false; } return true; }
void JobContainer::updateTaskState( af::MCTaskUp &taskup, RenderContainer * renders, MonitorContainer * monitoring) { switch( taskup.getStatus()) { case af::TaskExec::UPNULL: case af::TaskExec::UPNoTaskRunning: case af::TaskExec::UPNoJob: case af::TaskExec::UPLAST: AFERRAR("JobContainer::updateTaskState: Bad task update status (jobID=%d).\n", taskup.getNumJob()); return; } JobContainerIt jobsIt( this); JobAf* job = jobsIt.getJob( taskup.getNumJob()); if( job != NULL ) { job->v_updateTaskState( taskup, renders, monitoring); return; } // Job does not exist! AFERRAR("JobContainer::updateTaskState: Job with id=%d does not exists.", taskup.getNumJob()) if( taskup.getStatus() == af::TaskExec::UPPercent) RenderAf::closeLostTask( taskup); }
void AfList::moveNodes( const std::vector<int32_t> & i_list, int i_type) { #ifdef AFOUTPUT printf("AfList::moveNodes:\n"); #endif // // ensure in proper type // switch ( i_type) { case MoveUp: case MoveDown: case MoveTop: case MoveBottom: break; default: AFERRAR("AfList::moveNodes: Invalid type = %d\n", i_type); return; } // // return if no nodes ids to move // if( i_list.size() == 0) { AFERROR("AfList::moveNodes: Move nodes ids list is empty.\n"); return; } // // creating move nodes list // std::list<AfNodeSrv*> move_list; std::list<AfNodeSrv*>::iterator it_begin = nodes_list.begin(); std::list<AfNodeSrv*>::iterator it_end = nodes_list.end(); std::list<AfNodeSrv*>::iterator it = it_begin; while( it != it_end) { for( unsigned n = 0; n < i_list.size(); n++) { if( (*it)->m_node->m_id == i_list[n] ) { #ifdef AFOUTPUT //printf("Found a node \"%s\"-%d\n", (*it)->getName().c_str(), (*it)->m_node->m_id); printf("Found a node \"%s\"-%d\n", (*it)->m_node->m_name.c_str(), (*it)->m_node->m_id ); #endif move_list.push_back( *it); break; } } it++; } // // return if it os no nodes to move // if( move_list.size() == 0 ) { AFERROR("AfList::moveNodes: Can't find nodes with such ids.\n"); return; } // // moving nodes in move list // std::list<AfNodeSrv*>::iterator it_move_begin = move_list.begin(); std::list<AfNodeSrv*>::iterator it_move_end = move_list.end(); std::list<AfNodeSrv*>::iterator it_move; if(( i_type == MoveDown) || ( i_type == MoveTop)) it_move = it_move_end; else it_move = it_move_begin; for(;;) { AfNodeSrv * node; if(( i_type == MoveDown) || ( i_type == MoveTop)) { if( it_move == it_move_begin ) break; it_move--; node = *it_move; } else { if( it_move == it_move_end ) break; node = *it_move; it_move++; } #ifdef AFOUTPUT //printf("Processing node \"%s\"-%d\n", node->getName().c_str(), node->getId()); printf("Processing node \"%s\"-%d\n", node->m_node->m_name.c_str(), node->m_node->m_id ); #endif std::list<AfNodeSrv*>::iterator it_insert = nodes_list.begin(); while( it_insert != it_end) { if((*it_insert) == node) break; it_insert++; } if( it_insert == it_end) { AFERRAR("AfList::moveNodes: Lost node - \"%s\" - %d.\n", node->m_node->m_name.c_str(), node->m_node->m_id); continue; } switch ( i_type) { case MoveUp: { #ifdef AFOUTPUT printf("AfList::MoveUp:\n"); #endif if( it_insert == it_begin) { #ifdef AFOUTPUT printf("Node is already at top.\n"); #endif continue; } it_insert--; if( **it_insert != *node) { #ifdef AFOUTPUT printf("Node above has another priority\n"); #endif continue; } break; } case MoveDown: { #ifdef AFOUTPUT printf("AfList::MoveDown:\n"); #endif it_insert++; if( it_insert == it_end) { #ifdef AFOUTPUT printf("Node is already at bottom.\n"); #endif continue; } if( **it_insert != *node ) { #ifdef AFOUTPUT printf("Node below has another priority\n"); #endif continue; } it_insert++; break; } case MoveTop: { #ifdef AFOUTPUT printf("AfList::MoveTop:\n"); #endif if( it_insert == it_begin) { #ifdef AFOUTPUT printf("Node is already at top.\n"); #endif continue; } for(;;) { it_insert--; if( **it_insert != *node ) { it_insert++; break; } if( it_insert == it_begin) break; } break; } case MoveBottom: { it_insert++; if( it_insert == it_end) { #ifdef AFOUTPUT printf("Node is already at bottom.\n"); #endif continue; } #ifdef AFOUTPUT printf("AfList::MoveBottom:\n"); #endif for(;;) { if( **it_insert != *node ) break; it_insert++; if( it_insert == it_end) break; } break; } } if( it_insert == it_end) { #ifdef AFOUTPUT printf("Pushing node back\n"); #endif nodes_list.remove( node); nodes_list.push_back( node); continue; } AfNodeSrv * node_move = (*it_insert); if( node_move == NULL) { AFERROR("AfList::moveNodes: node_move == NULL\n"); continue; } if( node_move == node ) { #ifdef AFOUTPUT printf("Node is already at it's position.\n"); #endif continue; } #ifdef AFOUTPUT //printf("Inserting at \"%s\"-%d\n", node_move->getName().c_str(), node_move->getId()); printf("Inserting at \"%s\"-%d\n", node_move->m_node->m_name.c_str(), node_move->m_node->m_id ); #endif nodes_list.remove( node); nodes_list.insert( it_insert, node); } }