Esempio n. 1
0
/// @brief initialize ICE run time
/// @todo multi-thread scenario
/// @todo to call ic->destroy()
void MyICE::InitialzieICE(){
  static char* endpoint=NULL;
  try{
    int argc = 1; 
    char **argv = new char*[1];
    argv[0]=new char[1];
    strcpy_s(argv[0],1,"");
    Ice::CommunicatorPtr ic = Ice::initialize(argc, argv);

    if (endpoint==NULL){
      int clen=0;
      endpoint = _6bees_net::GetDataByHTTP(epurl,clen);
      //endpoint = "UUICE:tcp -h 118.123.7.85 -p 9090 -t 9000 -z";
      if (endpoint==NULL){
        UUDEBUG((LOG_ERROR,"Cannot connect to endpoint URL."));
        return;
      }else{
        Ice::ObjectPrx base = ic->stringToProxy(endpoint);
        _user = UUTOOLBAR::UserPrx::checkedCast(base);
      }
    }else{
      Ice::ObjectPrx base = ic->stringToProxy(endpoint);
      _user = UUTOOLBAR::UserPrx::checkedCast(base);
    }
  }catch(const Ice::Exception& e){
    const char* s = e.what();
     UUDEBUG((LOG_ERROR,s));
  }catch (...) {
    UUDEBUG((LOG_ERROR,"ICE unexpected error!"));
  } 
}
Esempio n. 2
0
void
allTestsWithTarget(const Ice::CommunicatorPtr& comm)
{
    RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
        comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
    test(registry);
    AdminSessionPrx session = registry->createAdminSession("foo", "bar");

    session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatOnIdle);

    AdminPrx admin = session->getAdmin();
    test(admin);

    cout << "testing targets... " << flush;

    TestIntfPrx obj = TestIntfPrx::checkedCast(comm->stringToProxy("*****@*****.**"));
    obj = TestIntfPrx::checkedCast(comm->stringToProxy("[email protected]"));
    obj = TestIntfPrx::checkedCast(comm->stringToProxy("[email protected]"));

    obj = TestIntfPrx::checkedCast(comm->stringToProxy("[email protected]"));

    obj = TestIntfPrx::checkedCast(comm->stringToProxy("*****@*****.**"));
    test(obj->getProperty("TargetProp") == "1");

    cout << "ok" << endl;

    session->destroy();
}
Esempio n. 3
0
void ConnectionPoolManager::initialize() {
	IceUtil::RWRecMutex::WLock lock(_mutex);
	if (_observer || _descriptor) {
		return;
	}
	
  Ice::CommunicatorPtr ic = xiaonei_grid();
	ostringstream adapterEndpoints;
  adapterEndpoints << "tcp -h " << ::base::Network::local_ip();
	_adapter = ic->createObjectAdapterWithEndpoints("DbCxxPool",
			adapterEndpoints.str());
	_adapter->activate();
	Ice::PropertiesPtr props = ic->getProperties();

	string identity = props->getPropertyWithDefault(
			"Service.DbDescriptor.Identity", "DCS@DbDescriptor");

	if (identity != "") {
		_descriptor = DbDescriptorPrx::uncheckedCast(
				ic->stringToProxy(identity));
		LOG(INFO) << "ConnectionPoolManager::DbDescriptor.Proxy -> "
				<< _descriptor;
	}
	_observer = DbObserverPrx::uncheckedCast(_adapter->addWithUUID(this));
	LOG(INFO) << "ConnectionPoolManager::DbObserver.Proxy -> " << _observer;

	// MyUtil::TaskManager::instance().schedule(new VerifyTimerTask(10 * 60 ));
  ::base::Post(boost::bind(&ConnectionPoolManager::verify, this), 10 * 60 * 1000, 0);
}
Esempio n. 4
0
pointcloudClient::pointcloudClient(Ice::CommunicatorPtr ic, std::string prefix, std::string proxy)
{
	this->newData=false;

	this->prefix=prefix;
	Ice::PropertiesPtr prop;
	prop = ic->getProperties();
	this->refreshRate=0;

	int fps=prop->getPropertyAsIntWithDefault(prefix+"Fps",10);
	this->cycle=(float)(1/(float)fps)*1000000;
	try{
		Ice::ObjectPrx basePointCloud = ic->stringToProxy(proxy);
		if (0==basePointCloud){
			throw prefix + " Could not create proxy";
		}
		else {
			this->prx = jderobot::pointCloudPrx::checkedCast(basePointCloud);
			if (0==this->prx)
				throw "Invalid proxy" + prefix;

		}
	}catch (const Ice::Exception& ex) {
		std::cerr << ex << std::endl;
		throw "Invalid proxy" + prefix;
	}
	catch (const char* msg) {
		std::cerr << msg << std::endl;
		jderobot::Logger::getInstance()->error(prefix + " Not camera provided");
		throw "Invalid proxy" + prefix;
	}
	_done=false;
	this->pauseStatus=false;
}
Esempio n. 5
0
Test::PriorityPrx
allTests(const Ice::CommunicatorPtr& communicator)
{
    cout << "testing server priority... " << flush;
    string ref = "test:default -p 12010 -t 10000";
    Ice::ObjectPrx base = communicator->stringToProxy(ref);
    test(base);

    Test::PriorityPrx priority = Test::PriorityPrx::checkedCast(base);

    try
    {
#ifdef _WIN32
        test(1 == priority->getPriority());
#else
        test(50 == priority->getPriority());
#endif
    }
    catch(...)
    {
        test(false);
    }
    cout << "ok" << endl;

    return priority;
}
Esempio n. 6
0
void
testUOE(const Ice::CommunicatorPtr& communicator)
{
    string ref = "uoet:default -p 12010";
    Ice::ObjectPrx base = communicator->stringToProxy(ref);
    test(base);
    UnexpectedObjectExceptionTestPrx uoet = UnexpectedObjectExceptionTestPrx::uncheckedCast(base);
    test(uoet);
    try
    {
        uoet->op();
        test(false);
    }
    catch(const Ice::UnexpectedObjectException& ex)
    {
        test(ex.type == "::Test::AlsoEmpty");
        test(ex.expectedType == "::Test::Empty");
    }
    catch(const Ice::Exception& ex)
    {
        cout << ex << endl;
        test(false);
    }
    catch(...)
    {
        test(false);
    }
}
Esempio n. 7
0
void* mos_init(void *p)
{
	vuser_node_st_t *pVuser = (vuser_node_st_t*)p;
	bench_t *bp = (bench_t *)pVuser->b->b;
	mos_st *ap = (mos_st *)malloc(sizeof(mos_st));
	pVuser->verb = ap;
	srand(time(0));
	create_transaction(pVuser,"MOS");

	int status = 0;
	Ice::CommunicatorPtr ic;

	try{
		ic = Ice::initialize();

		Ice::ObjectPrx base = ic->stringToProxy("mosInterfaceAdapter:default -h 10.249.65.38 -p 40001");
		MOSInterfacePrx mos = MOSInterfacePrx::checkedCast(base);
		if(!mos){
			throw "Invalid proxy";
		}
		ap->mos = new MOSInterfacePrx(mos);
		ap->ic = new Ice::CommunicatorPtr(ic);
	}catch(const Ice::Exception& ex){
		cerr << ex << endl;
		status = 1;
	}catch(const char* msg){
		cerr << msg << endl;
		status = 1;
	}
}
Esempio n. 8
0
//chunkserver enroll
int MasterDaemon::enroll()
{
    static int init = 0;


    try{
    if (init==0){
    Ice::CommunicatorPtr ic = Ice::initialize();
    Ice::ObjectPrx base	= ic->stringToProxy(((m_pConf->MASTER_PROXY_INFO).c_str()));
    m_pServicePrx = ChunkServerServicePrx::checkedCast(base);
    }

    }catch(const Ice::Exception &ex){
        cout<<"ice enroll failed"<<endl;
        return -1;
    }

    init = 1;

    Address addr;
    addr.name=m_pConf->LOCALE_IP;
    addr.port=m_pConf->DATA_SOCKET_PORT;
    m_pServicePrx->enroll(addr);
    return 1;
}
Esempio n. 9
0
int main(int argc, char *argv[]) {
    int status = 0;
    Ice::CommunicatorPtr ic;

    try {
        ic = Ice::initialize(argc, argv);
        Ice::ObjectPrx base 
            = ic->stringToProxy(
                "SimplePrinter:default -p 10000");
        PrinterPrx printer = PrinterPrx::checkedCast(base);
        if (!printer)
            throw "Invalid proxy";

        printer->printString("Hello world from hupantingxue!");
    } catch (const Ice::Exception &e) {
        cerr << e << endl;
        status = 1;
    } catch (const char *msg) {
        cerr << msg << endl;
        status = 1;
    }

    if (ic) {
        ic->destroy();
    }
    return status;
}
Esempio n. 10
0
Client::Client() {
    try {
        // We use ip address and process id to identify a client.
        char hostname[100];
        gethostname(hostname, 100);
        m_address.name = hostname;
        m_address.port = getpid();

        // Get configuration.
        string homedir = getenv("HOME");
        if (!m_configured && !setFromFile("tfs_client.ini") 
                    && !setFromFile(homedir + "/.tfs_client.ini")
                    && !setFromFile("/etc/tfs_client.ini")) {
            //LOG_FATAL("Client: Throw api::LoadConfigurationError")
            throw api::LoadConfigurationError();
        }

        // Initialize client logger.    
        if (m_conf.logFile[0] == '~')
            m_conf.logFile = homedir + m_conf.logFile.substr(1);
        helpers::LogLog::getLogLog()->setInternalDebugging(false);
        SharedAppenderPtr append_1(
            new RollingFileAppender(m_conf.logFile, 1024 * 1024, 1));
        std::string pattern = "%D %p - %m\n";
        append_1->setLayout(std::auto_ptr<Layout>(new PatternLayout(pattern)));
        Logger logger = Logger::getInstance("tfs_client");
        logger.addAppender(append_1);

        // Set logger level
        if (m_conf.logLevel == "FATAL") logger.setLogLevel(FATAL_LOG_LEVEL);
        if (m_conf.logLevel == "ERROR") logger.setLogLevel(ERROR_LOG_LEVEL);
        if (m_conf.logLevel == "WARN") logger.setLogLevel(WARN_LOG_LEVEL);
        if (m_conf.logLevel == "INFO") logger.setLogLevel(INFO_LOG_LEVEL);
        if (m_conf.logLevel == "DEBUG") logger.setLogLevel(DEBUG_LOG_LEVEL);
        LOG_INFO("Client: Starts TFS Client instance.");
        LOG_INFO("Client: Get master address: " <<m_conf.masterIP <<":" 
                                                <<m_conf.masterPort);
        LOG_INFO("Client: Get default buffer size: " <<m_conf.bufferSize);
        LOG_INFO("Client: Get log level: " <<m_conf.logLevel);
        LOG_INFO("Client: Get log file: " <<m_conf.logFile);

        // Initialize ice.
        Ice::CommunicatorPtr ic = Ice::initialize();
        Ice::ObjectPrx base = ic->stringToProxy(
            "ClientService:tcp -h " + m_conf.masterIP + " -p " + m_conf.masterPort);
        m_service = slice::ClientServicePrx::checkedCast(base);
        LOG_INFO("Client: Ice service initialized.")

        // Begin heartbeat.
        IceUtil::ThreadPtr deamon = new HeartbeatDeamon(m_address,
                                                        m_service);
        deamon->start();
        LOG_INFO("Client: Heartbeat Deamon started.")
    } catch (Ice::Exception &ex) {
        LOG_FATAL("Client: Get Ice Exception:" <<ex.ice_name());
        LOG_FATAL("Client: Throw api::ConnectionError");
        throw api::ConnectionError();
    }
}
Esempio n. 11
0
int main(int argc, char* argv[])
{
  int status = 0;
  Ice::CommunicatorPtr ic;
  try {
    ic = Ice::initialize(argc, argv);

    if (argc != 4) {
      cerr << "Usage: " << argv[0] << " servername NameService-host local-port\n";
      goto clean_up;
    }

    // Look up the name service.
    ostringstream ns_formatter;
    ns_formatter << "NameService:tcp -h " << argv[2] << " -p 9010";
    Ice::ObjectPrx base =
      ic->stringToProxy(ns_formatter.str().c_str());
    NameServicePrx ns = NameServicePrx::checkedCast(base);
    if (!ns)
      throw "Invalid NameService";

    // Create local chat display object and support infrastructure.
    ostringstream server_formatter;
    server_formatter << "tcp -p " << argv[3];
    Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(
      "ChatterAdapter", server_formatter.str().c_str());
    Ice::ObjectPtr object = new RoomManager_impl(adapter);
    Ice::ObjectPrx server =
      adapter->add(object, ic->stringToIdentity("RoomManager"));
    adapter->activate();

    // Register object.
    // ns->registerName(argv[1], server);

    ic->waitForShutdown();
  }
  catch (const Ice::Exception& e) {
    cerr << e << endl;
    status = 1;
  }
  catch (const char* msg) {
    cerr << msg << endl;
    status = 1;
  }

 clean_up:
  // We must call ic->destroy() even if an exception is throw above.
  if (ic) {
    try {
      ic->destroy();
    }
    catch (const Ice::Exception& e) {
      cerr << e << endl;
      status = 1;
    }
  }
  return status;
}
Esempio n. 12
0
void
NodeSessionManager::create(const NodeIPtr& node)
{
    {
        Lock sync(*this);
        assert(!_node);

        const_cast<NodeIPtr&>(_node) = node;

        Ice::CommunicatorPtr communicator = _node->getCommunicator();
        assert(communicator->getDefaultLocator());
        Ice::Identity id = communicator->getDefaultLocator()->ice_getIdentity();

        //
        // Initialize the IceGrid::Query objects. The IceGrid::Query
        // interface is used to lookup the registry proxy in case it
        // becomes unavailable. Since replicas might not always have
        // an up to date registry proxy, we need to query all the
        // replicas.
        //
        Ice::EndpointSeq endpoints = communicator->getDefaultLocator()->ice_getEndpoints();
        id.name = "Query";
        QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy(communicator->identityToString(id)));
        for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
        {
            Ice::EndpointSeq singleEndpoint;
            singleEndpoint.push_back(*p);
            _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
        }

        id.name = "InternalRegistry-Master";
        _master = InternalRegistryPrx::uncheckedCast(communicator->stringToProxy(communicator->identityToString(id)));

        _thread = new Thread(*this);
        _thread->start();
    }

    //
    // Try to create the session. It's important that we wait for the
    // creation of the session as this will also try to create sessions
    // with replicas (see createdSession below) and this must be done 
    // before the node is activated.
    //
    _thread->tryCreateSession(true, IceUtil::Time::seconds(3));
}
Esempio n. 13
0
RemoteConfig::RemoteConfig(const std::string& name, int argc, char** argv, const Ice::CommunicatorPtr& communicator) :
    _status(1)
{
    //
    // If ControllerHost is defined, we are using a server on a remote host. We expect a
    // test controller will already be active. We let exceptions propagate out to
    // the caller.
    //
    // Also look for a ConfigName property, which specifies the name of the configuration
    // we are currently testing.
    //
    std::string controllerHost;
    std::string configName;
    for(int i = 1; i < argc; ++i)
    {
        std::string opt = argv[i];
        if(opt.find("--ControllerHost") == 0)
        {
            std::string::size_type pos = opt.find('=');
            if(pos != std::string::npos && opt.size() > pos + 1)
            {
                controllerHost = opt.substr(pos + 1);
            }
        }
        else if(opt.find("--ConfigName") == 0)
        {
            std::string::size_type pos = opt.find('=');
            if(pos != std::string::npos && opt.size() > pos + 1)
            {
                configName = opt.substr(pos + 1);
            }
        }
    }

    Test::Common::ServerPrxPtr server;

    if(!controllerHost.empty())
    {
        std::string prot = communicator->getProperties()->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
        std::string host;
        if(prot != "bt")
        {
            host = communicator->getProperties()->getProperty("Ice.Default.Host");
        }

        Test::Common::StringSeq options;

        Test::Common::ControllerPrxPtr controller = ICE_CHECKED_CAST(Test::Common::ControllerPrx,
            communicator->stringToProxy("controller:tcp -h " + controllerHost + " -p 15000"));
        server = controller->runServer("cpp", name, prot, host, false, configName, options);
        server->waitForServer();
    }

    _server = server;
}
Esempio n. 14
0
int
run(int, char**, const Ice::CommunicatorPtr& comm)
{
    void allTests(const Ice::CommunicatorPtr&);
    allTests(comm);

    //
    // Shutdown the IceBox server.
    //
    ICE_UNCHECKED_CAST(Ice::ProcessPrx, comm->stringToProxy("DemoIceBox/admin -f Process:default -p 9996"))->shutdown();

    return EXIT_SUCCESS;
}
Esempio n. 15
0
void
ServerManagerI::startServer(const Ice::Current&)
{
    for(::std::vector<Ice::CommunicatorPtr>::const_iterator i = _communicators.begin(); i != _communicators.end(); ++i)
    {
        (*i)->waitForShutdown();
        (*i)->destroy();
    }
    _communicators.clear();

    //
    // Simulate a server: create a new communicator and object
    // adapter. The object adapter is started on a system allocated
    // port. The configuration used here contains the Ice.Locator
    // configuration variable. The new object adapter will register
    // its endpoints with the locator and create references containing
    // the adapter id instead of the endpoints.
    //
    Ice::CommunicatorPtr serverCommunicator = Ice::initialize(_initData);
    _communicators.push_back(serverCommunicator);

    //
    // Use fixed port to ensure that OA re-activation doesn't re-use previous port from
    // another OA (e.g.: TestAdapter2 is re-activated using port of TestAdapter).
    //
    {
        std::ostringstream os;
        os << "default -p " << _nextPort++;
        serverCommunicator->getProperties()->setProperty("TestAdapter.Endpoints", os.str());
    }
    {
        std::ostringstream os;
        os << "default -p " << _nextPort++;
        serverCommunicator->getProperties()->setProperty("TestAdapter2.Endpoints", os.str());
    }

    Ice::ObjectAdapterPtr adapter = serverCommunicator->createObjectAdapter("TestAdapter");
    Ice::ObjectAdapterPtr adapter2 = serverCommunicator->createObjectAdapter("TestAdapter2");

    Ice::ObjectPrxPtr locator = serverCommunicator->stringToProxy("locator:default -p 12010");
    adapter->setLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));
    adapter2->setLocator(ICE_UNCHECKED_CAST(Ice::LocatorPrx, locator));

    Ice::ObjectPtr object = ICE_MAKE_SHARED(TestI, adapter, adapter2, _registry);
    _registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test")));
    _registry->addObject(adapter->add(object, serverCommunicator->stringToIdentity("test2")));
    adapter->add(object, serverCommunicator->stringToIdentity("test3"));

    adapter->activate();
    adapter2->activate();
}
Esempio n. 16
0
int main(int argc, char* argv[])
{
  int status = 0;
  Ice::CommunicatorPtr ic;

  try {
   ic = Ice::initialize(argc, argv);
   Ice::ObjectPrx base = ic->stringToProxy("asii2_adapter:default -p 10800");
   CineTicketServicePrx remoteService = CineTicketServicePrx::checkedCast(base);

   if (!remoteService)throw "Invalid proxy";


   int horaSesion;
   struct consultasesion conActual;
   int i;

   while(1){
    horaSesion=0;
        cout<<"Introduzca la hora de la sesión a consultar: (22 o 01)"<< endl;

    while(!(horaSesion==22 || horaSesion==01)){
        cin >> horaSesion;

  }

      conActual = remoteService->consulta(horaSesion);  
      cout<<"Hora sesión:"<< horaSesion<< endl;
      cout<<"Estado de la sala:"<< endl;
      for (i=0; i<10; i++){

        cout<<"["<< i+1 << "]" << conActual.s[i] << endl;

      }

    }
  

} catch (const Ice::Exception& ex) {
 cerr << ex << endl;
 status = 1;
} catch (const char* msg) {
 cerr << msg << endl;
 status = 1;
}
if (ic)
  ic->destroy();

return status;

}
Esempio n. 17
0
void
allTests(Test::TestHelper* helper)
{
    Ice::CommunicatorPtr communicator = helper->communicator();
    string sref = "test:" + helper->getTestEndpoint();
    Ice::ObjectPrxPtr obj = communicator->stringToProxy(sref);
    test(obj);

    int proxyPort = communicator->getProperties()->getPropertyAsInt("Ice.HTTPProxyPort");
    if(proxyPort == 0)
    {
        proxyPort = communicator->getProperties()->getPropertyAsInt("Ice.SOCKSProxyPort");
    }

    TestIntfPrxPtr test = ICE_CHECKED_CAST(TestIntfPrx, obj);
    test(test);

    cout << "testing connection... " << flush;
    {
        test->ice_ping();
    }
    cout << "ok" << endl;

    cout << "testing connection information... " << flush;
    {
        Ice::IPConnectionInfoPtr info = getIPConnectionInfo(test->ice_getConnection()->getInfo());
        test(info->remotePort == proxyPort); // make sure we are connected to the proxy port.
    }
    cout << "ok" << endl;

    cout << "shutting down server... " << flush;
    {
        test->shutdown();
    }
    cout << "ok" << endl;

    cout << "testing connection failure... " << flush;
    {
        try
        {
            test->ice_ping();
            test(false);
        }
        catch(const Ice::LocalException&)
        {
        }
    }
    cout << "ok" << endl;
}
Esempio n. 18
0
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
    void allTests(const Ice::CommunicatorPtr&);
    allTests(communicator);

    int num = argc == 2 ? atoi(argv[1]) : 1;
    for(int i = 0; i < num; i++)
    {
        ostringstream os;
        os << "control:tcp -p " << (12010 + i);
        TestIntfPrx::uncheckedCast(communicator->stringToProxy(os.str()))->shutdown();
    }
    return EXIT_SUCCESS;
}
Esempio n. 19
0
ObjectInfo
IceGrid::toObjectInfo(const Ice::CommunicatorPtr& communicator, const ObjectDescriptor& object, const string& adapterId)
{
    ObjectInfo info;
    info.type = object.type;
    ostringstream proxyStr;
    proxyStr << "\"" << communicator->identityToString(object.id) << "\"";
    if(!object.proxyOptions.empty())
    {
        proxyStr << ' ' << object.proxyOptions;
    }
    proxyStr << " @ " << adapterId;
    try
    {
        info.proxy = communicator->stringToProxy(proxyStr.str());
    }
    catch(const Ice::ProxyParseException&)
    {
        ostringstream fallbackProxyStr;
        fallbackProxyStr << "\"" << communicator->identityToString(object.id) << "\"" << " @ " << adapterId;
        info.proxy = communicator->stringToProxy(fallbackProxyStr.str());
    }
    return info;
}
Esempio n. 20
0
void AghPhoneSearchDirDialog::exec() {
	QString errorMessage = this->configuration->validateDirectory().c_str();

	if (errorMessage.count() > 0) {
		QMessageBox::critical( this, this->windowTitle(),
				errorMessage);

	} else {
		// search for directory
		try {
			Ice::CommunicatorPtr ic = Ice::initialize();
			stringstream a;
			a << *(configuration->directoryName)
			<< ":default -h " << *(configuration->directoryAddress)
			<< " -p " << *(configuration->directoryPort);
			cout << a.str() << endl;

			Ice::ObjectPrx base = ic->stringToProxy ( a.str() );
			directory = DirectoryPrx::checkedCast ( base );

			if ( !directory ) {
				QMessageBox::critical( this, this->windowTitle(),
						"Connection to directory failed, please check your configuration!");
			} else {
				QDialog::exec();

				int currentRow = resultTAble->currentRow();
				cout << "currentRow: " << currentRow << endl;
				QTableWidgetItem* item = resultTAble->item(currentRow, 0);

				if (item != NULL) {
					// get Terminal
					selectedTerminal = reinterpret_cast<TerminalAddress*>(qvariant_cast<void*>(item->data(Qt::UserRole)));
					cout << "XXX1: " << selectedTerminal->name.c_str() << endl;
				} else {
					selectedTerminal = 0;
				}
			}

			ic->destroy();

		} catch (...) {
			QMessageBox::critical( this, this->windowTitle(),
					"Connection to directory failed, please check your configuration!");
			return;
		}
	}
}
Esempio n. 21
0
TfsFileImpl::TfsFileImpl(const string& masterHost, int32_t port)
{
    m_address.name = "mapreduce_master";
    m_address.port = getpid();

    try {
        stringstream ss;
        ss << "ClientService:tcp -h " << masterHost << " -p " << port;
        // Initialize ice.
        Ice::CommunicatorPtr ic = Ice::initialize();
        Ice::ObjectPrx base = ic->stringToProxy(ss.str());
        m_service = tfs::slice::ClientServicePrx::checkedCast(base);
    } catch (Ice::Exception &ex) {
        cerr << "ERROR TfsFileImpl:: " << ex << endl;
    }
}
void	taskstatuswidget::setServiceObject(
		astro::discover::ServiceObject serviceobject) {

	// get the Tasks proxy
	Ice::CommunicatorPtr	ic = snowstar::CommunicatorSingleton::get();
	Ice::ObjectPrx	base = ic->stringToProxy(
		serviceobject.connect("Tasks"));
	_tasks = snowstar::TaskQueuePrx::checkedCast(base);
	if (!_tasks) {
		debug(LOG_ERR, DEBUG_LOG, 0, "could not get a taskqueue");
	}

	// get the status
	ui->taskstateWidget->update(_tasks->state());
	statusTimer.start();
}
Esempio n. 23
0
bool MapTask::getFile(const MasterCommand &mc, string &path) {
    LOG_DEBUG(LOG_MT_PREFIX <<"Get map file, chunk id " <<mc.chunkID);
    //tfs::ChunkTransfer ct;
    /**
     * add by Chen Rishan
     * the module of datatransfer had been replaced of ice
     */
    try {
        Ice::CommunicatorPtr ic = Ice::initialize();
        Ice::ObjectPrx base = ic->stringToProxy("Transfer:tcp -h " 
                + mc.chunkLocation.name + " -p " 
                + boost::lexical_cast<string>(mc.chunkLocation.port) );
        tfs::slice::TransferPrx tp = tfs::slice::TransferPrx::checkedCast(base);

        if (mc.chunkLocation.name == m_worker->address().name) {
            path = tp->getLocalPath(mc.chunkID);
            LOG_INFO(LOG_MT_PREFIX <<"Map local file " + path);
        } else {
            LOG_INFO(LOG_MT_PREFIX <<"Get remote file from " <<mc.chunkLocation.name
                    <<":" <<mc.chunkLocation.port);
            path = m_taskDir + "_" + boost::lexical_cast<string>(mc.chunkID) + ".chk.tmp";
            LOG_INFO(LOG_MT_PREFIX <<"Map file " << path);

            // Get remote file
            ofstream fout(path.c_str(), ios::binary);

            int n = 500000;
            for (int i = 0; i < (mc.chunkSize-1) / n + 1; ++i) {
                int nleft = mc.chunkSize - n * i;
                vector<unsigned char> vc = tp->read(mc.chunkID, n * i, min(n, nleft));
                assert(vc.size() == min(n, nleft));
                fout.write((const char *)&vc[0], vc.size());
                if (!fout.good()) {
                    LOG_ERROR(LOG_MT_PREFIX <<"Transfer remote file error.");
                    return false;
                }
            }
            fout.close();
            LOG_DEBUG(LOG_MT_PREFIX <<"Get map file done.")
        }
    } catch (const Ice::Exception &ex) {
        LOG_ERROR(LOG_MT_PREFIX <<"Transfer remote file error.");
        return false;
    }
    return true;
}
Esempio n. 24
0
Test::MyClassPrx
allTests(const Ice::CommunicatorPtr& communicator)
{
    string ref = "test:default -p 12010";
    Ice::ObjectPrx base = communicator->stringToProxy(ref);
    Test::MyClassPrx cl = Test::MyClassPrx::checkedCast(base);
    Test::MyDerivedClassPrx derived = Test::MyDerivedClassPrx::checkedCast(cl);

    cout << "testing twoway operations... " << flush;
    void twoways(const Ice::CommunicatorPtr&, const Test::MyClassPrx&);
    twoways(communicator, cl);
    twoways(communicator, derived);
    derived->opDerived();
    cout << "ok" << endl;

    cout << "testing oneway operations... " << flush;
    void oneways(const Ice::CommunicatorPtr&, const Test::MyClassPrx&);
    oneways(communicator, cl);
    cout << "ok" << endl;

    cout << "testing twoway operations with AMI... " << flush;
    void twowaysAMI(const Ice::CommunicatorPtr&, const Test::MyClassPrx&);
    twowaysAMI(communicator, cl);
    twowaysAMI(communicator, derived);
    cout << "ok" << endl;

    cout << "testing oneway operations with AMI... " << flush;
    void onewaysAMI(const Ice::CommunicatorPtr&, const Test::MyClassPrx&);
    onewaysAMI(communicator, cl);
    cout << "ok" << endl;

    cout << "testing batch oneway operations... " << flush;
    void batchOneways(const Test::MyClassPrx&);
    batchOneways(cl);
    batchOneways(derived);
    cout << "ok" << endl;

    cout << "testing batch AMI oneway operations... " << flush;
    void batchOnewaysAMI(const Test::MyClassPrx&);
    batchOnewaysAMI(cl);
    batchOnewaysAMI(derived);
    cout << "ok" << endl;

    return cl;
}
Esempio n. 25
0
int
main(int argc, char* argv[])
{
    int status = 0;
    int count=0;
    Ice::CommunicatorPtr ic;
    GUI gui(argc, argv);

    try {
        ic = Ice::initialize(argc, argv);
        Ice::ObjectPrx base = ic->stringToProxy("AirportInterface:default -p 10000");

        if (!base)
                  throw "Invalid base";

        ATCDisplay::AirportInterfacePrx airportsim = ATCDisplay::AirportInterfacePrx::checkedCast(base);

        if (!airportsim)
            throw "Invalid proxy";

        int milisec = 100; // length of time to sleep, in miliseconds
        struct timespec req;
        req.tv_sec = 0;
        req.tv_nsec = milisec * 1000000L;

        //while(1)
        //std::cout<<airportsim->getPoints()<<std::endl;

        gui.init(airportsim);
        gui.run();




    } catch (const Ice::Exception& ex) {
        cerr << ex << endl;
        status = 1;
    } catch (const char* msg) {
        cerr << msg << endl;
        status = 1;
    }
    if (ic)
        ic->destroy();
    return status;
}
Esempio n. 26
0
// ######################################################################
void PrimaryMotorCortexI::init(Ice::CommunicatorPtr ic, Ice::ObjectAdapterPtr adapter)
{
  Ice::ObjectPtr pmcPtr = this;
  itsObjectPrx = adapter->add(pmcPtr,
      ic->stringToIdentity("PrimaryMotorCortex"));

  IceStorm::TopicPrx topicPrx;
  itsTopicsSubscriptions.push_back(SimEventsUtils::TopicInfo("ActionMessageTopic", topicPrx));
  SimEventsUtils::initSimEvents(ic, itsObjectPrx, itsTopicsSubscriptions);

  Ice::ObjectPrx base = ic->stringToProxy(
      "IRobotService:default -p 10000 -h roomba");
  itsRobot = Robots::IRobotPrx::checkedCast(base);

  if(!itsRobot) LFATAL("Invalid Robot Proxy");
  itsRobot->sendStart();
  itsRobot->setMode(Robots::SafeMode);
}
Esempio n. 27
0
int main(int argc, char ** argv){
	vector<string> names;

	if(argc == 1){
		cout << "useage:" << endl;
		cout << "1. Dump all instances : " << argv[0] << " " << DUMPALL << endl;
		cout << "2. Dump specified instances,combine instances by space : " << argv[0] << " instance1 [...]" << endl;
		cout << "\nexample:" << endl;
		cout << argv[0] << " vipmember user_config buddycore_friend_a" << endl;
		return 0;
	} else if (argc >= 2) {
		string name = argv[1];
		if(name == DUMPALL) {
			names.push_back("");
		} else {
			for(int i=1; i<argc; i++) {
				names.push_back(argv[i]);
			}
		}
	} else {
		cout << "Argument error" << endl;
		return 0;
	}

	MyUtil::OceChannel channel;
	Ice::CommunicatorPtr ic = channel.getCommunicator();
	DbDescriptorPrx proxy = DbDescriptorPrx::checkedCast(ic->stringToProxy("DCS@DbDescriptor"));
	cout << "dumping..." << endl;
	for(vector<string>::iterator iv = names.begin(); iv < names.end(); iv++){
		if((*iv) == ""){
			DbInstanceSeq instances = proxy->getDbInstances();
			cout << "Instances size = " << instances.size() << endl;
			for(DbInstanceSeq::iterator it = instances.begin(); it != instances.end(); it++){
				dumpObserver(proxy, (*it)->name);	
			}
		} else {
			dumpObserver(proxy, (*iv));
		}
	}

	ic->destroy();
	cout << "done." << endl;
	return 0;
}
Esempio n. 28
0
int main(int argc,char *argv[])
{
	//建立通信器  
	ic = Ice::initialize(argc, argv);  
	//获得Ice对象代理,SimplePrinter-对象标识符,default -p 10000-协议与端口  
	Ice::ObjectPrx base = ic->stringToProxy("MyIceCore:default -p 10000");  
	//向下转换  
	CoreBasePrx co = CoreBasePrx::checkedCast(base);  
	if (!co) throw "Invalid proxy";  
	//调用操作  
	co->PrintMsg("Hello World!");  
	int iSum = co->add(98,2);
	cout << iSum <<endl;
	int iSub = co->sub(87,7);
	cout<<iSub<<endl;
	ic->destroy(); // 清理资源

	return 0;
}
Esempio n. 29
0
int main(int argc, char* argv[]) {
  int status = 0;
  Ice::CommunicatorPtr ic;
  try {
    ic = Ice::initialize(argc, argv);
    Ice::ObjectPrx base = ic->stringToProxy( "dodo:tcp -p 10002");
    cout<<"server info: " << base << endl;
    HelloPrx hp = HelloPrx::checkedCast(base);
    if (hp)
      hp->sayHello();
  } catch (const Ice::Exception& ex) {
    cerr << ex << endl;
    status = 1;
  } catch (const char* msg) {
    cerr << msg << endl;
    status = 1;
  }
  if (ic)
    ic->destroy();
  return status;
}
Esempio n. 30
0
void
allTests(const Ice::CommunicatorPtr& communicator)
{
    cout << "testing stringToProxy... " << flush;
    Ice::ObjectPrx base = communicator->stringToProxy("test @ TestAdapter");
    test(base);
    cout << "ok" << endl;

    cout << "testing checked cast... " << flush;
    TestIntfPrx obj = TestIntfPrx::checkedCast(base);
    test(obj);
    test(obj == base);
    cout << "ok" << endl;

    cout << "pinging server... " << flush;
    obj->ice_ping();
    cout << "ok" << endl;

    cout << "shutting down server... " << flush;
    obj->shutdown();
    cout << "ok" << endl;
}