void setup() { #ifdef ARDUINO_ARCH_AVR sleep_setup(); // if you want to use sleep, or use the optiboot watchdog #endif //wdt_disable(); Serial.begin(115200); #ifdef ARDUINO_ARCH_AVR printf_begin(); #endif printf_P(PSTR("HomeMesh 1.0\r\n")); printf_P(PSTR("(c) koverg70 %s %s\r\n"), __DATE__, __TIME__); /* pinMode(LED_PIN, OUTPUT); for (int i=1; i<3; ++i) { digitalWrite(LED_PIN, HIGH); delay(500); digitalWrite(LED_PIN, LOW); delay(500); } */ printf_P(PSTR("NodeID: %d, CE pin: %d, CS pin: %d\r\n"), NODE_ID, NRF24_CE_PIN, NRF24_CS_PIN); // a very simple RF24 radio test delay(500); mesh.setNodeID(NODE_ID); printf_P(PSTR("NodeID: %d, CE pin: %d, CS pin: %d\r\n"), NODE_ID, NRF24_CE_PIN, NRF24_CS_PIN); mesh.begin(); printf_P(PSTR("NodeID: %d, CE pin: %d, CS pin: %d\r\n"), NODE_ID, NRF24_CE_PIN, NRF24_CS_PIN); // --- now we initialize the tasks the are regularily called with new messages and to process information ---- addTask(new TimeSync(60000, 0)); // sync frequency and target node to require time from #if NODE_ID == 0 Master *master = new Master(); addTask(master); // TODO: where to store received data #ifdef ESP8266 addTask(new ESP8266Ntp()); addTask(new ESP8266Web(master->getSensors())); #else // addTask(new Wifi(master->getSensors())); addTask(new Ethernet(master->getSensors())); #endif #else addTask(new Sensors(0)); // the target node to send sensor data to #endif #ifdef SCHEDULE_PIN addTask(new Schedule(SCHEDULE_PIN)); // sync frequency and target node to require time from #endif // ------------------------------------------------------------------------------------------------------------ for (int i = 0; i < taskCount; ++i) { tasks[i]->begin(); printf_P(PSTR("Task started: %s\r\n"), tasks[i]->name()); } }
void OldMaid::main( int argc, char* argv[] ) { // 進行役の生成 Master* master = new Master() ; // 場の生成 Table* field = new Table() ; // プレイヤーの生成 Player* murata = new Player( "村田", master, field ) ; Player* yamada = new Player( "山田", master, field ) ; Player* saito = new Player( "斎藤", master, field ) ; // 進行役へプレイヤーを登録 master->registerPlayer( murata ) ; master->registerPlayer( yamada ) ; master->registerPlayer( saito ) ; // トランプを生成する Hand* trump = OldMaid::createTrump() ; // ゲームの準備をする master->prepareGame( trump ) ; // ゲームを開始する master->startGame() ; // 終了処理 delete master ; delete field ; delete murata ; delete yamada ; delete saito ; }
int main(int argc, char * argv[]) { Master master; if (!master.StartMaster(argc,argv)) return -1; return 0; }
int main() { unsigned int portServeurs = 1500; unsigned int portClients = 1600; Master* masterServeur; string msg = ""; cout << "Vous êtes sur le point de lancer un Master Server pour le jeu Bataille Spatiale." << endl; cout << "Veuillez entrer le port sur lequel écouter les serveurs de jeu [" << portServeurs << "]" << endl; getline(cin, msg); if(!msg.empty()) { portServeurs = atoi(msg.c_str()); } cout << "Veuillez entrer le port sur lequel écouter les clients de jeu [" << portClients << "]" << endl; getline(cin, msg); if(!msg.empty()) { portClients = atoi(msg.c_str()); } masterServeur = new Master(portServeurs, portClients); while(true) { masterServeur->ecouterReseau(); masterServeur->verifierServeursActifs(); sf::sleep(sf::milliseconds(50)); } }
void sort(Master& master, //!< master object const Assigner& assigner, //!< assigner object std::vector<T> Block::* values, //!< all values to sort std::vector<T> Block::* samples, //!< (output) boundaries of blocks size_t num_samples, //!< desired number of samples const Cmp& cmp, //!< comparison function int k = 2, //!< k-ary reduction will be used bool samples_only = false) //!< false: results will be all_to_all exchanged; true: only sort but don't exchange results { bool immediate = master.immediate(); master.set_immediate(false); // NB: although sorter will go out of scope, its member functions sample() // and exchange() will return functors whose copies get saved inside reduce detail::SampleSort<Block,T,Cmp> sorter(values, samples, cmp, num_samples); // swap-reduce to all-gather samples RegularDecomposer<DiscreteBounds> decomposer(1, interval(0,assigner.nblocks()), assigner.nblocks()); RegularSwapPartners partners(decomposer, k); reduce(master, assigner, partners, sorter.sample(), detail::SkipIntermediate(partners.rounds())); // all_to_all to exchange the values if (!samples_only) all_to_all(master, assigner, sorter.exchange(), k); master.set_immediate(immediate); }
int main(int argc, char **argv) { //args check if(argc < 2){ printf("usage: fooking config.lua\n"); return -1; } //init process info proc.argc = argc; proc.argv = argv; srandom(time(NULL)); //init config Config *cc = Config::getInstance(); if(!cc->load(argv[1])){ return -1; } //init log Log *pLog = Log::getInstance(); if(!cc->sLogFile.empty()){ if(cc->sLogFile == "stdout"){ pLog->init(cc->nLogLevel, STDOUT_FILENO); }else if(cc->sLogFile == "stderr"){ pLog->init(cc->nLogLevel, STDERR_FILENO); }else if(!pLog->init(cc->nLogLevel, cc->sLogFile.c_str())){ printf("init log failed\n"); return -1; } } //daemonize if(cc->bDaemonize){ daemonize(); } //title init utils::initProcTitle(argc, argv); //server if(cc->bRouter){ //router server Router *pRouter = new Router(argc, argv); pRouter->start(); delete pRouter; }else{ //gateway server Master *pMaster = new Master(argc, argv); pMaster->start(); delete pMaster; } //release config Config::release(); return 0; }
/** * This prevents deadlock which happens when the processing thread tries to create new MidiSession while the main thread is waiting for it to terminate. * The cause is that creating MidiSession blocks the processing thread and invokes corresponding slot of Master in its thread as required. * On the other hand, stop() is usually called in the main thread - the thread of Master. So, we attempt to unblock * by processing posted QEvent::MetaCall events directed to Master. */ void MidiDriver::waitForProcessingThread(QThread &thread, MasterClockNanos timeout) { while (!thread.wait(timeout / MasterClock::NANOS_PER_MILLISECOND)) { Master *master = Master::getInstance(); if (QThread::currentThread() == master->thread()) { QCoreApplication::sendPostedEvents(master, QEvent::MetaCall); } } }
MasterNodeConnection::MasterNodeConnection(Master &master): _master(master), service(master.ioService()), accepted(false), disposed(false) { socket = std::make_shared<socketType>(master.library()->ioService()); }
static void OnDumpFileSendComplete(void* data) { std::pair<void*, void*>* p = (std::pair<void*, void*>*) data; Master* master = (Master*) p->first; SlaveConnection* slave = (SlaveConnection*) p->second; DELETE(p); close(slave->repldbfd); slave->repldbfd = -1; INFO_LOG("Send complete."); master->SendCacheToSlave(*slave); }
Master *Master::getInstance() { static Master master; // This fixes a deadlock caused by static initialization algorithm of GCC // Instead, MSVC invokes constructors for static vars only once static bool initialized = false; if (!initialized) { initialized = true; master.init(); } return &master; }
int main(int argc, char **argv) { ifstream fin; fin.open(argv[1]); ms.InitMS(fin); cout<<ms; ms.Setsocket(); int sockfd_tcp, sockfd_udp, maxfd; struct sockaddr_in srvaddr; fd_set allset, rset; socklen_t len = sizeof(struct sockaddr_in); sockfd_tcp = ms.Getsockfd_tcp(); sockfd_udp = ms.Getsockfd_udp(); maxfd = max(sockfd_tcp, sockfd_udp) + 1; FD_ZERO(&allset); FD_SET(sockfd_tcp, &allset); FD_SET(sockfd_udp, &allset); char buf[MAXLINE]; int i; pthread_t tid_probe; Pthread_create(&tid_probe, NULL, &probing, NULL); //create an another thread to timely probe the time_sheet in order to find the failed server while(1) { Signal(SIGINT, sig_int_handle); Signal(SIGTERM, sig_term_handle); if (sigsetjmp(jmpbuf, 1)!=0 || sigsetjmp(jmpbuf, 2)!=0) //if SIGINT or SIGTERM signal caught, master close all sockets and exits { ms.Closesockets(); cout<<"Master exits, all sockets are closed"<<endl; exit(1); } rset = allset; if ((Select(maxfd, &rset, NULL, NULL, NULL)) < 1) //master listen to its udp socket to receive ping from server continue; if (FD_ISSET(sockfd_udp, &rset)) { i = recvfrom(sockfd_udp, buf, MAXLINE, 0, (SA*)&srvaddr, &len); if (i < 0) { cerr<<"recv error"<<endl; continue; } else { pthread_t tid; Pthread_create(&tid, NULL, &handle_ping, (void *)buf); //when received server ping, handle it } } } return 1; }
int main() { Master master; try { master.init(); master.run(); } catch (Exception e) { e.showError(); master.quit(); getchar(); } return 0; }
int main(int argv, char **args) { QApplication app(argv, args); app.setApplicationName("Munt mt32emu-qt"); app.setQuitOnLastWindowClosed(false); QProcessEnvironment::systemEnvironment().insert("PA_ALSA_PLUGHW", "1"); Master *master = Master::getInstance(); QSystemTrayIcon *trayIcon = NULL; if (QSystemTrayIcon::isSystemTrayAvailable()) { trayIcon = new QSystemTrayIcon(QIcon(":/images/note.gif")); trayIcon->setToolTip("Munt: MT-32 Emulator"); trayIcon->show(); master->setTrayIcon(trayIcon); } MainWindow mainWindow(master); if (trayIcon == NULL || !master->getSettings()->value("Master/startIconized", "0").toBool()) mainWindow.show(); master->startPinnedSynthRoute(); master->startMidiProcessing(); master->processCommandLine(app.arguments()); app.exec(); master->setTrayIcon(NULL); delete trayIcon; return 0; }
static void *handle_ping(void *arg) //master handle ping from server { Pthread_detach(pthread_self()); char *buf = (char *)arg; pair <int, int> srv_name; depacketize(buf, srv_name); //printf("%s\n",seperator); printf("Ping received: 127.0.0.1:%d\n",srv_name.second); ms.update_time_sheet(srv_name); //ms.display_time_sheet(); if (!ms.Server_exists(srv_name)) //if the server doesn't exist, it means that new server joined, start chain extension { printf("New server joined:127.0.0.1:%d, chain extension start\n",srv_name.second); Server *s = new Server(srv_name); ms.Addserver(s); ms.client_notify(srv_name, true); ms.server_notify(srv_name, true); } }
void kdtree_sampling (Master& master, //!< master object const Assigner& assigner, //!< assigner object int dim, //!< dimensionality const ContinuousBounds& domain, //!< global data extents std::vector<Point> Block::* points, //!< input points to sort into kd-tree size_t samples, //!< number of samples to take in each block bool wrap = false)//!< periodic boundaries in all dimensions { if (assigner.nblocks() & (assigner.nblocks() - 1)) { fprintf(stderr, "KD-tree requires a number of blocks that's a power of 2, got %d\n", assigner.nblocks()); std::abort(); } typedef diy::RegularContinuousLink RCLink; for (size_t i = 0; i < master.size(); ++i) { RCLink* link = static_cast<RCLink*>(master.link(i)); *link = RCLink(dim, domain, domain); if (wrap) // set up the links to self { diy::BlockID self = { master.gid(i), master.communicator().rank() }; for (int j = 0; j < dim; ++j) { diy::Direction dir, wrap_dir; // left dir.x[j] = -1; wrap_dir.x[j] = -1; link->add_neighbor(self); link->add_bounds(domain); link->add_direction(dir); link->add_wrap(wrap_dir); // right dir.x[j] = 1; wrap_dir.x[j] = 1; link->add_neighbor(self); link->add_bounds(domain); link->add_direction(dir); link->add_wrap(wrap_dir); } } } detail::KDTreeSamplingPartition<Block,Point> kdtree_partition(dim, points, samples); detail::KDTreePartners partners(dim, assigner.nblocks(), wrap, domain); reduce(master, assigner, partners, kdtree_partition); // update master.expected to match the links int expected = 0; for (size_t i = 0; i < master.size(); ++i) expected += master.link(i)->size_unique(); master.set_expected(expected); }
int main() { Master *m = new Master(); m->run(); return 0; /*string filename = root + prefixr + "/" + prefixr + "_" + toString(75) + suffix;*/ /*IplImage *test = cvLoadImage(filename.c_str(), 0); cvNamedWindow("img"); cvShowImage("img", test); cvWaitKey(-1);*/ /*Mat m = imread(filename); for (int i = 0; i < 65536; i++) { int p = (int)m.at<unsigned char>(i / 256, i % 256); if (p != 0) cout << p << endl; } imshow("img", m); cvWaitKey(-1); system("pause");*/ }
// Recv messages with user1 signalling void Master::SignalHandler(eUserSig eSignal) { switch(eSignal) { case SIGUSER1: { // We would also like to disable the user1 signal at this point to get called again. char *pMsg = NULL; { // We also need to iterate also MutexGuard mutex(Master::messageBox); pMsg = Master::messageBox.PopFront(); } if(NULL != pMsg) { TLV tlv; ProcService proc; MsgOper::Get(pMsg, tlv); string str(tlv.pcValue, tlv.tl.uLength); TRACE(proc.Get(), "Recvd Message", str); MsgOper::Destroy(pMsg); pMsg = NULL; } else { ProcService proc; TRACE(proc.Get(), "Recvd Message", "NULL"); } break; } case SIGINTR: { ProcService proc; Master *pThis = proc.Get(); pThis->InternalSignal(); TRACE(pThis, "Recv Signal", "SIGINTR"); } } }
void MainWindow::afficherNouveauDresseur() { addmaster *a = new addmaster(this); a->exec(); // if return QDialog::Accepted QIcon masterIcon = a->getMasterIcon(); QString masterName = a->getMasterName(); Master *m = new Master(masterIcon, masterName); if (masters->indexOf(*m) == -1) { QAction *action = ui->menuDresseurs->addAction(masterIcon, masterName); m->setAction(action); masters->append(*m); this->popMessage(QString("Nouveau dresseur"), QString("Le dresseur a ete cree avec succes (cf. Dresseurs)."), a->windowIcon()); } else this->popMessage(QString("Nouveau dresseur"), QString("Un dresseur de ce nom existe déjà."), a->windowIcon()); delete m; }
static void *probing(void *arg) //master probe the time_sheet in every 5 seconds { Pthread_detach(pthread_self()); while (1) { sleep(5); printf("start probing\n"); time_t cur_time = time(NULL); for(map<pair<int, int>, time_t >::iterator it = ms.Gettimesheet().begin(); it != ms.Gettimesheet().end(); ++it) { if (cur_time - (it->second) > 5) //if certain server's last ping from now is more than 5 seconds, it means the server fails, start notify client and server the failure { printf("%s\n",seperator); printf("Server 127.0.0.1:%d FAILS\n",it->first.second); ms.client_notify(it->first, false); ms.server_notify(it->first, false); it = ms.Gettimesheet().erase(it); if (it == ms.Gettimesheet().end()) break; } } } }
//outputs the set of feasible solutions void MaximumCPlanarSubgraph::writeFeasible(const String &filename, Master &master, ABA_MASTER::STATUS &status) { const ClusterGraph& CG = *(master.getClusterGraph()); const Graph& G = CG.getGraph(); node v; //first compute the nodepairs that are potential candidates to connect //chunks in a cluster //potential connection edges NodeArray< NodeArray<bool> > potConn(G); forall_nodes(v, G) { potConn[v].init(G, false); }
void Master::client_notify(pair <int, int> srv, bool extension) //notify client of server fail or chain extension { char send_msg[MAXLINE]; socklen_t len = sizeof(struct sockaddr_in); ms.packetize(send_msg, srv, !extension, extension); //printf("%s\n",send_msg); map<int, list<Client*> >::iterator it1 = clients.find(srv.first); for(list<Client *>::iterator it2 = it1->second.begin(); it2 != it1->second.end(); ++it2) { Sendto(sockfd_udp, send_msg, MAXLINE, 0, (SA*)&((*it2)->Getsockaddr()), len); } if (extension) printf("Push notification of chain extension to all clients sent\n"); else printf("Push notification of server fail to all clients sent\n"); }
bool dfs(const vector<string> &wordlist, Master &master, const Adj &adj, int u, vector<bool> &vis) { //printf("in dfs\n"); vis[u] = true; int m = master.guess(wordlist[u]); if (m == 6) { //printf("found!\n"); return true; } for (const auto &p: adj[u]) { if (p.first == m) continue; for (int v: p.second) vis[v] = true; } for (int v: adj[u].at(m)) { if (!vis[v]) { if (dfs(wordlist, master, adj, v, vis)) return true; } } return false; }
int main(int argv, char **args) { QApplication app(argv, args); app.setApplicationName("Munt mt32emu-qt"); app.setQuitOnLastWindowClosed(false); { Master master; QSystemTrayIcon *trayIcon = NULL; if (QSystemTrayIcon::isSystemTrayAvailable()) { trayIcon = new QSystemTrayIcon(QIcon(":/images/note.gif")); trayIcon->setToolTip("Munt: MT-32 Emulator"); trayIcon->show(); master.setTrayIcon(trayIcon); } MainWindow mainWindow(&master); if (trayIcon == NULL || !master.getSettings()->value("Master/startIconized", false).toBool()) mainWindow.show(); if (argv > 1) master.processCommandLine(app.arguments()); master.startPinnedSynthRoute(); master.startMidiProcessing(); app.exec(); master.setTrayIcon(NULL); delete trayIcon; } return 0; }
void Run() { serv->ClearNilSlave(); }
void Run() { serv->OnHeartbeat(); }
int main(int argc, char** argv) { GOOGLE_PROTOBUF_VERIFY_VERSION; master::Flags flags; // The following flags are executable specific (e.g., since we only // have one instance of libprocess per execution, we only want to // advertise the IP and port option once, here). Option<string> ip; flags.add(&ip, "ip", "IP address to listen on"); uint16_t port; flags.add(&port, "port", "Port to listen on", MasterInfo().port()); Option<string> zk; flags.add(&zk, "zk", "ZooKeeper URL (used for leader election amongst masters)\n" "May be one of:\n" " zk://host1:port1,host2:port2,.../path\n" " zk://username:password@host1:port1,host2:port2,.../path\n" " file://path/to/file (where file contains one of the above)"); bool help; flags.add(&help, "help", "Prints this help message", false); Try<Nothing> load = flags.load("MESOS_", argc, argv); if (load.isError()) { cerr << load.error() << endl; usage(argv[0], flags); exit(1); } if (flags.version) { version(); exit(0); } if (help) { usage(argv[0], flags); exit(1); } // Initialize libprocess. if (ip.isSome()) { os::setenv("LIBPROCESS_IP", ip.get()); } os::setenv("LIBPROCESS_PORT", stringify(port)); process::initialize("master"); logging::initialize(argv[0], flags, true); // Catch signals. LOG(INFO) << "Build: " << build::DATE << " by " << build::USER; LOG(INFO) << "Version: " << MESOS_VERSION; if (build::GIT_TAG.isSome()) { LOG(INFO) << "Git tag: " << build::GIT_TAG.get(); } if (build::GIT_SHA.isSome()) { LOG(INFO) << "Git SHA: " << build::GIT_SHA.get(); } allocator::AllocatorProcess* allocatorProcess = new allocator::HierarchicalDRFAllocatorProcess(); allocator::Allocator* allocator = new allocator::Allocator(allocatorProcess); state::Storage* storage = NULL; Log* log = NULL; if (flags.registry == "in_memory") { if (flags.registry_strict) { EXIT(1) << "Cannot use '--registry_strict' when using in-memory storage" << " based registry"; } storage = new state::InMemoryStorage(); } else if (flags.registry == "replicated_log" || flags.registry == "log_storage") { // TODO(bmahler): "log_storage" is present for backwards // compatibility, can be removed before 0.19.0. if (flags.work_dir.isNone()) { EXIT(1) << "--work_dir needed for replicated log based registry"; } if (zk.isSome()) { // Use replicated log with ZooKeeper. if (flags.quorum.isNone()) { EXIT(1) << "Need to specify --quorum for replicated log based registry" << " when using ZooKeeper"; } // TODO(vinod): Add support for "--zk=file://". Try<URL> url = URL::parse(zk.get()); if (url.isError()) { EXIT(1) << "Error parsing ZooKeeper URL: " << url.error(); } log = new Log( flags.quorum.get(), path::join(flags.work_dir.get(), "replicated_log"), url.get().servers, flags.zk_session_timeout, path::join(url.get().path, "log_replicas"), url.get().authentication, flags.log_auto_initialize); } else { // Use replicated log without ZooKeeper. log = new Log( 1, path::join(flags.work_dir.get(), "replicated_log"), set<UPID>(), flags.log_auto_initialize); } storage = new state::LogStorage(log); } else { EXIT(1) << "'" << flags.registry << "' is not a supported" << " option for registry persistence"; } CHECK_NOTNULL(storage); state::protobuf::State* state = new state::protobuf::State(storage); Registrar* registrar = new Registrar(flags, state); Repairer* repairer = new Repairer(); Files files; MasterContender* contender; MasterDetector* detector; // TODO(vinod): 'MasterContender::create()' should take // Option<string>. Try<MasterContender*> contender_ = MasterContender::create(zk.get("")); if (contender_.isError()) { EXIT(1) << "Failed to create a master contender: " << contender_.error(); } contender = contender_.get(); // TODO(vinod): 'MasterDetector::create()' should take // Option<string>. Try<MasterDetector*> detector_ = MasterDetector::create(zk.get("")); if (detector_.isError()) { EXIT(1) << "Failed to create a master detector: " << detector_.error(); } detector = detector_.get(); LOG(INFO) << "Starting Mesos master"; Master* master = new Master( allocator, registrar, repairer, &files, contender, detector, flags); if (zk.isNone()) { // It means we are using the standalone detector so we need to // appoint this Master as the leader. dynamic_cast<StandaloneMasterDetector*>(detector)->appoint(master->info()); } process::spawn(master); process::wait(master->self()); delete master; delete allocator; delete allocatorProcess; delete registrar; delete repairer; delete state; delete storage; delete log; delete contender; delete detector; return 0; }
int main(int argc, char** argv) { GOOGLE_PROTOBUF_VERIFY_VERSION; master::Flags flags; // The following flags are executable specific (e.g., since we only // have one instance of libprocess per execution, we only want to // advertise the IP and port option once, here). Option<string> ip; flags.add(&ip, "ip", "IP address to listen on"); uint16_t port; flags.add(&port, "port", "Port to listen on", MasterInfo().port()); string zk; flags.add(&zk, "zk", "ZooKeeper URL (used for leader election amongst masters)\n" "May be one of:\n" " zk://host1:port1,host2:port2,.../path\n" " zk://username:password@host1:port1,host2:port2,.../path\n" " file://path/to/file (where file contains one of the above)", ""); bool help; flags.add(&help, "help", "Prints this help message", false); Try<Nothing> load = flags.load("MESOS_", argc, argv); if (load.isError()) { cerr << load.error() << endl; usage(argv[0], flags); exit(1); } if (help) { usage(argv[0], flags); exit(1); } // Initialize libprocess. if (ip.isSome()) { os::setenv("LIBPROCESS_IP", ip.get()); } os::setenv("LIBPROCESS_PORT", stringify(port)); process::initialize("master"); logging::initialize(argv[0], flags, true); // Catch signals. LOG(INFO) << "Build: " << build::DATE << " by " << build::USER; LOG(INFO) << "Starting Mesos master"; allocator::AllocatorProcess* allocatorProcess = new allocator::HierarchicalDRFAllocatorProcess(); allocator::Allocator* allocator = new allocator::Allocator(allocatorProcess); state::Storage* storage = NULL; if (strings::startsWith(flags.registry, "zk://")) { // TODO(benh): EXIT(1) << "ZooKeeper based registry unimplemented"; } else if (flags.registry == "local") { storage = new state::LevelDBStorage(path::join(flags.work_dir, "registry")); } else { EXIT(1) << "'" << flags.registry << "' is not a supported" << " option for registry persistence"; } CHECK_NOTNULL(storage); state::protobuf::State* state = new state::protobuf::State(storage); Registrar* registrar = new Registrar(state); Files files; Master* master = new Master(allocator, registrar, &files, flags); process::spawn(master); Try<MasterDetector*> detector = MasterDetector::create(zk, master->self(), true, flags.quiet); CHECK_SOME(detector) << "Failed to create a master detector"; process::wait(master->self()); delete master; delete allocator; delete allocatorProcess; delete registrar; delete state; delete storage; MasterDetector::destroy(detector.get()); return 0; }
void master_Code(void) { Master master; clock_t start_Time = clock(); master.initialise(); master.send_Parameters(); master.send_Tetrads(); for (int istep = 0; istep < master.io.nsteps; istep += master.io.ntsync) { cout << "istep: " << istep << endl; master.generate_Pair_Lists(); master.generate_Indexes(); master.send_Workload_Indexes(); for (int i = 0; i < master.io.ntsync; i++) { master.calculate_Forces(); master.update_Velocity(); master.update_Coordinate(); } master.merge_Vels_n_Crds(); if (istep % master.io.ntwt == 0) { master.write_Info(istep); } if (istep % master.io.ntpr == 0) { master.write_Crds(); } } master.finalise(); double time_Usage = double (clock() - start_Time) / CLOCKS_PER_SEC; cout << "Simulation ended.\nTime usage of simualtion: " << time_Usage << endl << endl; }
int main(int argc, char *argv[]) { // Library container should be alive during exception catching Library::List libraries; try { // check if all arguments are provided if (argc < 2) { fprintf(stderr, "GolemInteropLoader <configuration_file>\n"); return 1; } /************************************************************************* * * Initialisation * **************************************************************************/ // read config std::ifstream ifsconfig(argv[1]); if (!ifsconfig.good()) throw std::runtime_error("golem::interop::GolemInteropLoader: Unable to open: " + std::string(argv[1])); boost::property_tree::ptree ptconfig; boost::property_tree::read_xml(ifsconfig, ptconfig); // extract interface info, load libraries and interfaces Interface::Map interfaces; Master* master = nullptr; BOOST_FOREACH(const boost::property_tree::ptree::value_type& value, ptconfig.get_child("golem.loader")) { if (value.first == "library") { const Interface::Info info(value.second.get<std::string>("<xmlattr>.library"), value.second.get<std::string>("<xmlattr>.param")); if (interfaces.find(info) == interfaces.end()) { // load library and create interface Interface *pinterface = libraries.insert(info.library)->getInterface(info.param); // find Master interface if (!master) master = Interface::is<Master>(pinterface); // update interface container interfaces.insert(std::make_pair(info, pinterface)); } } } if (!master) throw std::runtime_error("golem::interop::GolemInteropLoader: No Master interfaces specified: " + std::string(argv[1])); /************************************************************************* * * Run master * **************************************************************************/ master->run(interfaces); } catch (const std::exception& ex) { fprintf(stderr, "%s\n", ex.what()); return 1; } catch (...) { fprintf(stderr, "golem::interop::GolemInteropLoader: unknown exception\n"); return 1; } return 0; }
int main(int argc, char **argv) { Configurator configurator; Logging::registerOptions(&configurator); Master::registerOptions(&configurator); configurator.addOption<int>("port", 'p', "Port to listen on", 5050); configurator.addOption<string>("ip", "IP address to listen on"); configurator.addOption<string>("url", 'u', "URL used for leader election"); #ifdef MESOS_WEBUI configurator.addOption<int>("webui_port", 'w', "Web UI port", 8080); #endif if (argc == 2 && string("--help") == argv[1]) { usage(argv[0], configurator); exit(1); } Configuration conf; try { conf = configurator.load(argc, argv, true); } catch (ConfigurationException& e) { cerr << "Configuration error: " << e.what() << endl; exit(1); } Logging::init(argv[0], conf); if (conf.contains("port")) { setenv("LIBPROCESS_PORT", conf["port"].c_str(), 1); } if (conf.contains("ip")) { setenv("LIBPROCESS_IP", conf["ip"].c_str(), 1); } // Initialize libprocess library (but not glog, done above). process::initialize(false); string url = conf.get("url", ""); LOG(INFO) << "Build: " << build::DATE << " by " << build::USER; LOG(INFO) << "Starting Mesos master"; if (chdir(dirname(argv[0])) != 0) { fatalerror("Could not chdir into %s", dirname(argv[0])); } Master* master = new Master(conf); process::spawn(master); MasterDetector* detector = MasterDetector::create(url, master->self(), true, Logging::isQuiet(conf)); #ifdef MESOS_WEBUI webui::start(master->self(), conf); #endif process::wait(master->self()); delete master; MasterDetector::destroy(detector); return 0; }