当前位置: 首页>>代码示例>>C++>>正文


C++ Slave类代码示例

本文整理汇总了C++中Slave的典型用法代码示例。如果您正苦于以下问题:C++ Slave类的具体用法?C++ Slave怎么用?C++ Slave使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Slave类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: perror

void* RTSPServer::clientAcceptLoop(void *arg) {
    if (pthread_detach(pthread_self())) {
        perror("ERROR on pthread_detach");
        return NULL;
    }

    RTSPServer *server = (RTSPServer*)arg;
    while (true) {
        sockaddr_in sa_cli;
        socklen_t cli_addr_len = sizeof(sa_cli);
        int connfd = accept(server->sfd, (sockaddr*)&sa_cli, &cli_addr_len);
        if (connfd < 0) {
            perror("ERROR on slave accept");
            return NULL;
        }

        char clientIP[16];
        inet_ntop(AF_INET, &sa_cli.sin_addr.s_addr, clientIP, sizeof(clientIP));
        printf("slave %s:%d connected\n", clientIP, ntohs(sa_cli.sin_port));

        Slave *slave = new Slave(connfd);
        slave->setIPandPort(clientIP, ntohs(sa_cli.sin_port));
        server->addSlave(connfd, slave);

        pthread_t thread;
        if (pthread_create(&thread, NULL, clientLoop, slave)) {
            perror("ERROR on pthread_create clientLoop");
            delete slave;
            server->delSlave(connfd);
            return NULL;
        }
    }

    return NULL;
}
开发者ID:csehydrogen,项目名称:KimchiMediaServer,代码行数:35,代码来源:RTSPServer.cpp

示例2: FetchAndStoreAndExpungeAndExpunge

void FetchAndStoreAndExpungeAndExpunge(State* state)
{
  Future<Variable<Slaves> > future1 = state->fetch<Slaves>("slaves");
  AWAIT_READY(future1);

  Variable<Slaves> variable = future1.get();

  Slaves slaves1 = variable.get();
  ASSERT_EQ(0, slaves1.slaves().size());

  Slave* slave = slaves1.add_slaves();
  slave->mutable_info()->set_hostname("localhost");

  variable = variable.mutate(slaves1);

  Future<Option<Variable<Slaves> > > future2 = state->store(variable);
  AWAIT_READY(future2);
  ASSERT_SOME(future2.get());

  variable = future2.get().get();

  Future<bool> future3 = state->expunge(variable);
  AWAIT_READY(future3);
  ASSERT_TRUE(future3.get());

  future3 = state->expunge(variable);
  AWAIT_READY(future3);
  ASSERT_FALSE(future3.get());
}
开发者ID:rowhit,项目名称:mesos,代码行数:29,代码来源:state_tests.cpp

示例3: addSlave

void Master::addSlave(Machine slaveToAdd){
	//Slave p = new Slave(slaveToAdd);
						//cout<<"HERERERERERE"<<endl;
	Slave newSlaveToAdd;
	newSlaveToAdd.setMachineID(slaveToAdd.getMachineID());
	newSlaveToAdd.setMachineIP(slaveToAdd.getMachineIP());
	newSlaveToAdd.setMachineStatus(slaveToAdd.getMachineStatus());
	newSlaveToAdd.setMachineType(slaveToAdd.getMachineType());
	if(slaveCount != 0){
		Slave temp[slaveCount];
		for(int i = 0; i < slaveCount; i++){
			temp[i] = masterSlaves[i];
		}
		masterSlaves = new Slave[slaveCount+1];
		for(int j = 0; j < slaveCount; j++){
			masterSlaves[j] = temp[j];
		}
		masterSlaves[slaveCount] = newSlaveToAdd;
	}
	else{
		//cout<<"dont have"<<endl;
		masterSlaves = new Slave[slaveCount+1];
		masterSlaves[slaveCount] = newSlaveToAdd;
	}
	//masterSlaves[slaveCount] = slaveToAdd;
	slaveCount++;
	//cout<<"leaving"<<endl;
}
开发者ID:hhvvkk,项目名称:COS301DistrobutedApplicationManger,代码行数:28,代码来源:Master.cpp

示例4: main

int main(int argc, char** argv) {

    parse_args(argc, argv);

    MPI_Init(&argc, &argv);
    MPI_Comm_rank(MPI_COMM_WORLD, &RANK);
    MPI_Comm_size(MPI_COMM_WORLD, &WORLD_SIZE);

    if (RANK == 0) {

        printf("* width: %u\n", WIDTH);
        printf("* height: %u\n", HEIGHT);
        printf("* depth: %u\n", DEPTH);
        printf("\n");

        comm = new CommunicatorMaster(WORLD_SIZE - 1);
        game();
        delete comm;

    } else {

        Slave slave;
        slave.run();
    }

    MPI_Finalize();

    return 0;
}
开发者ID:mariokostelac,项目名称:connect4-mpi,代码行数:29,代码来源:game.cpp

示例5: FetchAndStoreAndFetch

void FetchAndStoreAndFetch(State* state)
{
  Future<Variable<Slaves> > future1 = state->fetch<Slaves>("slaves");
  AWAIT_READY(future1);

  Variable<Slaves> variable = future1.get();

  Slaves slaves1 = variable.get();
  ASSERT_EQ(0, slaves1.slaves().size());

  Slave* slave = slaves1.add_slaves();
  slave->mutable_info()->set_hostname("localhost");

  variable = variable.mutate(slaves1);

  Future<Option<Variable<Slaves> > > future2 = state->store(variable);
  AWAIT_READY(future2);
  ASSERT_SOME(future2.get());

  future1 = state->fetch<Slaves>("slaves");
  AWAIT_READY(future1);

  variable = future1.get();

  Slaves slaves2 = variable.get();
  ASSERT_EQ(1, slaves2.slaves().size());
  EXPECT_EQ("localhost", slaves2.slaves(0).info().hostname());
}
开发者ID:dharmeshkakadia,项目名称:mesos,代码行数:28,代码来源:state_tests.cpp

示例6: main

int main(int argc, char** argv)
{
   cout << SectorVersionString << endl;

   SlaveConf global_conf;

   CmdLineParser clp;
   clp.parse(argc, argv);

   for (map<string, string>::const_iterator i = clp.m_mDFlags.begin(); i != clp.m_mDFlags.end(); ++ i)
   {
      if (i->first == "mh")
         global_conf.m_strMasterHost = i->second;
      else if (i->first == "mp")
         global_conf.m_iMasterPort = atoi(i->second.c_str());
      else if (i->first == "h")
      {
         global_conf.m_strHomeDir = i->second;
      }
      else if (i->first == "ds")
         global_conf.m_llMaxDataSize = atoll(i->second.c_str()) * 1024 * 1024;
      else if (i->first == "log")
         global_conf.m_iLogLevel = atoi(i->second.c_str());
      else
      {
         cout << "warning: unrecognized flag " << i->first << endl;
         help();
      }
   }

   string base = "";
   if (clp.m_vParams.size() == 1)
      base = clp.m_vParams.front();
   else if (clp.m_vParams.size() > 1)
      cout << "warning: wrong parameters ignored.\n";

   Slave s;

   if (s.init(&base, &global_conf) < 0)
   {
      cout << "error: failed to initialize the slave. check slave configurations.\n";
      return-1;
   }

   if (s.connect() < 0)
   {
      cout << "error: failed to connect to the master, or the connection request is rejected.\n";
      return -1;
   }

   s.run();

   s.close();

   return 0;
}
开发者ID:norouzi4d,项目名称:sector,代码行数:56,代码来源:start_slave.cpp

示例7: locateLocal

Slave* Slave::holdSlave( const QString &protocol, const KURL& url )
{
    //kdDebug(7002) << "holdSlave '" << protocol << "' for " << url.prettyURL() << endl;
    // Firstly take into account all special slaves
    if (protocol == "data")
        return 0;

    DCOPClient *client = kapp->dcopClient();
    if (!client->isAttached())
	client->attach();

    QString prefix = locateLocal("socket", KGlobal::instance()->instanceName());
    KTempFile socketfile(prefix, QString::fromLatin1(".slave-socket"));
    if ( socketfile.status() != 0 )
	return 0;

#ifdef __CYGWIN__
   socketfile.close();
   socketfile.unlink();
#endif

#ifndef Q_WS_WIN
    KServerSocket *kss = new KServerSocket(QFile::encodeName(socketfile.name()));

    Slave *slave = new Slave(kss, protocol, socketfile.name());
#else
    Slave *slave = 0;
#endif

    QByteArray params, reply;
    QCString replyType;
    QDataStream stream(params, IO_WriteOnly);
    stream << url << socketfile.name();

    QCString launcher = KApplication::launcher();
    if (!client->call(launcher, launcher, "requestHoldSlave(KURL,QString)",
        params, replyType, reply)) {
        delete slave;
        return 0;
    }
    QDataStream stream2(reply, IO_ReadOnly);
    pid_t pid;
    stream2 >> pid;
    if (!pid)
    {
        delete slave;
        return 0;
    }
#ifndef Q_WS_WIN
    slave->setPID(pid);
    QTimer::singleShot(1000*SLAVE_CONNECTION_TIMEOUT_MIN, slave, SLOT(timeout()));
#endif
    return slave;
}
开发者ID:,项目名称:,代码行数:54,代码来源:

示例8: ACE_TMAIN

// Listing 0 code/ch10
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  if (argc > 1)   // Slave mode
    {
      Slave s;
      return s.doWork ();
    }

  // Else, Master mode
  Manager m (argv[0]);
  return m.doWork ();
}
开发者ID:azraelly,项目名称:knetwork,代码行数:13,代码来源:Spawn.cpp

示例9: LoadRDBRoutine

 void Slave::LoadRDBRoutine(void* cb)
 {
     Slave* slave = (Slave*) cb;
     if (NULL != slave->m_client)
     {
         slave->m_client->GetService().Continue();
     }
     if (time(NULL) - slave->m_routine_ts > 10)
     {
         slave->Routine();
     }
 }
开发者ID:yuanshankongmeng,项目名称:ardb,代码行数:12,代码来源:slave.cpp

示例10:

SSDBServer::~SSDBServer(){
	std::vector<Slave *>::iterator it;
	for(it = slaves.begin(); it != slaves.end(); it++){
		Slave *slave = *it;
		slave->stop();
		delete slave;
	}

	delete backend_dump;
	delete backend_sync;
	delete expiration;
	delete cluster;

	log_debug("SSDBServer finalized");
}
开发者ID:dryangkun,项目名称:ssdb,代码行数:15,代码来源:serv.cpp

示例11: main

int main(int argc, char** argv)
{
   Slave s;

   int res;

   if (argc > 1)
      res = s.init(argv[1]);
   else
      res = s.init();

   if (res < 0)
      return -1;

   if (s.connect() < 0)
      return -1;

   s.run();

   return 1;
}
开发者ID:besquared,项目名称:sector-sphere,代码行数:21,代码来源:start_slave.cpp

示例12:

SSDB::~SSDB(){
	for(std::vector<Slave *>::iterator it = slaves.begin(); it != slaves.end(); it++){
		Slave *slave = *it;
		slave->stop();
		delete slave;
	}
	if(binlogs){
		delete binlogs;
	}
	if(db){
		delete db;
	}
	if(options.block_cache){
		delete options.block_cache;
	}
	if(options.filter_policy){
		delete options.filter_policy;
	}
	if(meta_db){
		delete meta_db;
	}
	log_debug("SSDB finalized");
}
开发者ID:KerwinMa,项目名称:ssdb,代码行数:23,代码来源:ssdb.cpp

示例13: Names

void Names(State* state)
{
  Future<Variable<Slaves> > future1 = state->fetch<Slaves>("slaves");
  AWAIT_READY(future1);

  Variable<Slaves> variable = future1.get();

  Slaves slaves1 = variable.get();
  ASSERT_EQ(0, slaves1.slaves().size());

  Slave* slave = slaves1.add_slaves();
  slave->mutable_info()->set_hostname("localhost");

  variable = variable.mutate(slaves1);

  Future<Option<Variable<Slaves> > > future2 = state->store(variable);
  AWAIT_READY(future2);
  ASSERT_SOME(future2.get());

  Future<set<string> > names = state->names();
  AWAIT_READY(names);
  ASSERT_EQ(1u, names.get().size());
  EXPECT_NE(names.get().find("slaves"), names.get().end());
}
开发者ID:rowhit,项目名称:mesos,代码行数:24,代码来源:state_tests.cpp

示例14: TEST_F

TEST_F(LogStateTest, Timeout)
{
  Clock::pause();

  Future<Variable<Slaves> > future1 = state->fetch<Slaves>("slaves");
  AWAIT_READY(future1);

  Variable<Slaves> variable = future1.get();

  Slaves slaves1 = variable.get();
  ASSERT_EQ(0, slaves1.slaves().size());

  Slave* slave = slaves1.add_slaves();
  slave->mutable_info()->set_hostname("localhost");

  variable = variable.mutate(slaves1);

  // Now terminate the replica so the store will timeout.
  terminate(replica2->pid());
  wait(replica2->pid());

  Future<Option<Variable<Slaves> > > future2 = state->store(variable);

  Future<Option<Variable<Slaves> > > future3 =
    future2.after(Seconds(5), lambda::bind(&timeout, lambda::_1));

  ASSERT_TRUE(future2.isPending());
  ASSERT_TRUE(future3.isPending());

  Clock::advance(Seconds(5));

  AWAIT_DISCARDED(future2);
  AWAIT_FAILED(future3);

  Clock::resume();
}
开发者ID:rowhit,项目名称:mesos,代码行数:36,代码来源:state_tests.cpp

示例15: proc_info

int proc_info(NetworkServer *net, Link *link, const Request &req,
    Response *resp){
    Slave *slave = (Slave *)net->data;

    resp->push_back("ok");
    resp->push_back("info");
    resp->push_back(slave->name());
    resp->push_back("links");
    resp->add(net->link_count);

    int64_t calls = 0;
    for(proc_map_t::iterator it = net->proc_map.begin();
        it != net->proc_map.end(); it++){
        Command *cmd = it->second;
        calls += cmd->calls;
    }
    resp->push_back("total_calls");
    resp->add(calls);

    resp->push_back("master");
    resp->push_back(slave->master->name());

    return 0;
}
开发者ID:whl739,项目名称:mapreduce-lw,代码行数:24,代码来源:slave.cpp


注:本文中的Slave类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。