Пример #1
0
    std::map<string, string> client::getPropertyMap(const Ice::PropertiesPtr& properties) const {

        Ice::PropertiesPtr props;
        if (!properties) {
            props = getProperties();
        } else {
            props = properties;
        }

        std::map<string, string> pm;
        Ice::PropertyDict omeroProperties = props->getPropertiesForPrefix("omero");
        Ice::PropertyDict::const_iterator beg = omeroProperties.begin();
        Ice::PropertyDict::const_iterator end = omeroProperties.end();
        while (beg != end) {
            pm[(*beg).first] = (*beg).second;
            beg++;
        }
        Ice::PropertyDict iceProperties = props->getPropertiesForPrefix("Ice");
        beg = iceProperties.begin();
        end = iceProperties.end();
        while (beg != end) {
            pm[(*beg).first] = (*beg).second;
            beg++;
        }
        return pm;
    }
Пример #2
0
NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
             NodeSessionManager& sessions,
             const ActivatorPtr& activator,
             const IceUtil::TimerPtr& timer,
             const TraceLevelsPtr& traceLevels,
             const NodePrx& proxy,
             const string& name,
             const UserAccountMapperPrx& mapper,
             const string& instanceName) :
    _communicator(adapter->getCommunicator()),
    _adapter(adapter),
    _sessions(sessions),
    _activator(activator),
    _timer(timer),
    _traceLevels(traceLevels),
    _name(name),
    _proxy(proxy),
    _redirectErrToOut(false),
    _allowEndpointsOverride(false),
    _waitTime(0),
    _instanceName(instanceName),
    _userAccountMapper(mapper),
    _platform("IceGrid.Node", _communicator, _traceLevels),
    _fileCache(new FileCache(_communicator)),
    _serial(1),
    _consistencyCheckDone(false)
{
    Ice::PropertiesPtr props = _communicator->getProperties();

    const_cast<string&>(_dataDir) = _platform.getDataDir();
    const_cast<string&>(_serversDir) = _dataDir + "/servers";
    const_cast<string&>(_tmpDir) = _dataDir + "/tmp";
    const_cast<Ice::Int&>(_waitTime) = props->getPropertyAsIntWithDefault("IceGrid.Node.WaitTime", 60);
    const_cast<string&>(_outputDir) = props->getProperty("IceGrid.Node.Output");
    const_cast<bool&>(_redirectErrToOut) = props->getPropertyAsInt("IceGrid.Node.RedirectErrToOut") > 0;
    const_cast<bool&>(_allowEndpointsOverride) = props->getPropertyAsInt("IceGrid.Node.AllowEndpointsOverride") > 0;

    //
    // Parse the properties override property.
    //
    vector<string> overrides = props->getPropertyAsList("IceGrid.Node.PropertiesOverride");
    if(!overrides.empty())
    {
        for(vector<string>::iterator p = overrides.begin(); p != overrides.end(); ++p)
        {
            if(p->find("--") != 0)
            {
                *p = "--" + *p;
            }
        }

        Ice::PropertiesPtr p = Ice::createProperties();
        p->parseCommandLineOptions("", overrides);
        Ice::PropertyDict propDict = p->getPropertiesForPrefix("");
        for(Ice::PropertyDict::const_iterator q = propDict.begin(); q != propDict.end(); ++q)
        {
            _propertiesOverride.push_back(createProperty(q->first, q->second));
        }
    }
}
Пример #3
0
TrustManager::TrustManager(const Ice::CommunicatorPtr& communicator) :
    _communicator(communicator)
{
    Ice::PropertiesPtr properties = communicator->getProperties();
    _traceLevel = properties->getPropertyAsInt("IceSSL.Trace.Security");
    string key;
    try
    {
        key = "IceSSL.TrustOnly";
        _all = parse(properties->getProperty(key));
        key = "IceSSL.TrustOnly.Client";
        _client = parse(properties->getProperty(key));
        key = "IceSSL.TrustOnly.Server";
        _allServer = parse(properties->getProperty(key));
        Ice::PropertyDict dict = properties->getPropertiesForPrefix("IceSSL.TrustOnly.Server.");
        for(Ice::PropertyDict::const_iterator p = dict.begin(); p != dict.end(); ++p)
        {
            string name = p->first.substr(string("IceSSL.TrustOnly.Server.").size());
            key = p->first;
            _server[name] = parse(p->second);
        }
    }
    catch(const ParseException& e)
    {
        Ice::PluginInitializationException ex(__FILE__, __LINE__);
        ex.reason = "IceSSL: invalid property " + key  + ":\n" + e.reason;
        throw ex;
    }
}
Пример #4
0
RangeAnalyzer::RangeAnalyzer() :
	Analyzer() {
	ServiceI& service = ServiceI::instance();
	Ice::PropertiesPtr prop = service.getCommunicator()->getProperties();
	_configMap = prop->getPropertiesForPrefix("RangeAnalyzer");
	_min = prop->getPropertyAsIntWithDefault("RangeAnalyzer.Min", 0);
	_max = prop->getPropertyAsIntWithDefault("RangeAnalyzer.Max", 100);
	_moremax = prop->getPropertyAsIntWithDefault("RangeAnalyzer.MoreMax", 200);
	_moremin = prop->getPropertyAsIntWithDefault("RangeAnalyzer.MoreMin", 0);
	_unit=prop->getPropertyWithDefault("RangeAnalyzer.Unit","");
	_deviation=prop->getPropertyAsIntWithDefault("RangeAnalyzer.Deviation",100);
}
Пример #5
0
FrequencyAnalyzer::FrequencyAnalyzer() :
	Analyzer() {
	ServiceI& service = ServiceI::instance();
	Ice::PropertiesPtr prop = service.getCommunicator()->getProperties();
	_configMap = prop->getPropertiesForPrefix("FrequencyAnalyzer");

	/*stringstream stream(prop->getProperty("Mobile"));
	string mobile;
	while (stream >> mobile) {
		_alert->addMobile(mobile);
	}*/
	_time = prop->getPropertyAsIntWithDefault("FrequencyAnalyzer.Time", 60);
	_size = prop->getPropertyAsIntWithDefault("FrequencyAnalyzer.Size", 6);
}
Пример #6
0
MurmurIce::MurmurIce() {
	count = 0;

	if (meta->mp.qsIceEndpoint.isEmpty())
		return;

	Ice::PropertiesPtr ipp = Ice::createProperties();

	::Meta::mp.qsSettings->beginGroup("Ice");
	foreach(const QString &v, ::Meta::mp.qsSettings->childKeys()) {
		ipp->setProperty(u8(v), u8(::Meta::mp.qsSettings->value(v).toString()));
	}
	::Meta::mp.qsSettings->endGroup();

	Ice::PropertyDict props = ippProperties->getPropertiesForPrefix("");
	Ice::PropertyDict::iterator i;
	for (i=props.begin(); i != props.end(); ++i) {
		ipp->setProperty((*i).first, (*i).second);
	}
	ipp->setProperty("Ice.ImplicitContext", "Shared");

	Ice::InitializationData idd;
	idd.properties = ipp;

	try {
		communicator = Ice::initialize(idd);
		if (! meta->mp.qsIceSecretWrite.isEmpty()) {
			::Ice::ImplicitContextPtr impl = communicator->getImplicitContext();
			if (impl)
				impl->put("secret", u8(meta->mp.qsIceSecretWrite));
		}
		adapter = communicator->createObjectAdapterWithEndpoints("Murmur", qPrintable(meta->mp.qsIceEndpoint));
		MetaPtr m = new MetaI;
		MetaPrx mprx = MetaPrx::uncheckedCast(adapter->add(m, communicator->stringToIdentity("Meta")));
		adapter->addServantLocator(new ServerLocator(), "s");

		iopServer = new ServerI;

		adapter->activate();
		foreach(const Ice::EndpointPtr ep, mprx->ice_getEndpoints()) {
			qWarning("MurmurIce: Endpoint \"%s\" running", qPrintable(u8(ep->toString())));
		}

		meta->connectListener(this);
	} catch (Ice::Exception &e) {
		qCritical("MurmurIce: Initialization failed: %s", qPrintable(u8(e.ice_name())));
	}
}
Пример #7
0
TrustManager::TrustManager(const Ice::CommunicatorPtr& communicator) :
    _communicator(communicator)
{
    Ice::PropertiesPtr properties = communicator->getProperties();
    _traceLevel = properties->getPropertyAsInt("IceSSL.Trace.Security");
    string key;
    try
    {
        key = "IceSSL.TrustOnly";
        parse(properties->getProperty(key), _rejectAll, _acceptAll);
        key = "IceSSL.TrustOnly.Client";
        parse(properties->getProperty(key), _rejectClient, _acceptClient);
        key = "IceSSL.TrustOnly.Server";
        parse(properties->getProperty(key), _rejectAllServer, _acceptAllServer);
        Ice::PropertyDict dict = properties->getPropertiesForPrefix("IceSSL.TrustOnly.Server.");
        for(Ice::PropertyDict::const_iterator p = dict.begin(); p != dict.end(); ++p)
        {
            string name = p->first.substr(string("IceSSL.TrustOnly.Server.").size());
            key = p->first;
            list<DistinguishedName> reject, accept;
            parse(p->second, reject, accept);
            if(!reject.empty())
            {
                _rejectServer[name] = reject;
            }
            if(!accept.empty())
            {
                _acceptServer[name] = accept;
            }
        }
    }
    catch(const ParseException& e)
    {
        Ice::PluginInitializationException ex(__FILE__, __LINE__);
        ex.reason = "IceSSL: invalid property " + key  + ":\n" + e.reason;
        throw ex;
    }
}
Пример #8
0
PlatformInfo::PlatformInfo(const string& prefix, 
                           const Ice::CommunicatorPtr& communicator, 
                           const TraceLevelsPtr& traceLevels) : 
    _traceLevels(traceLevels)
{
    //
    // Initialization of the necessary data structures to get the load average.
    //
#if defined(_WIN32)
    _terminated = false;
    _usages1.insert(_usages1.end(), 1 * 60 / 5, 0); // 1 sample every 5 seconds during 1 minutes.
    _usages5.insert(_usages5.end(), 5 * 60 / 5, 0); // 1 sample every 5 seconds during 5 minutes.
    _usages15.insert(_usages15.end(), 15 * 60 / 5, 0); // 1 sample every 5 seconds during 15 minutes.
    _last1Total = 0;
    _last5Total = 0;
    _last15Total = 0;
#elif defined(_AIX)
    struct nlist nl;
    nl.n_name = "avenrun";
    nl.n_value = 0;
    if(knlist(&nl, 1, sizeof(nl)) == 0)
    {
        _kmem = open("/dev/kmem", O_RDONLY);

        //
        // Give up root permissions to minimize security risks, it's
        // only needed to access /dev/kmem.
        //
        setuid(getuid());
        setgid(getgid());
    }
    else
    {
        _kmem = -1;
    }
#endif

    //
    // Get the number of cores/threads. E.g. a quad-core CPU with 2 threads per core will return 8.
    //
#if defined(_WIN32)
    SYSTEM_INFO sysInfo;
    GetSystemInfo(&sysInfo);
    _nProcessorThreads = sysInfo.dwNumberOfProcessors;
#elif defined(__FreeBSD__)
    static int ncpu[2] = { CTL_HW, HW_NCPU };
    size_t sz = sizeof(_nProcessorThreads);
    if(sysctl(ncpu, 2, &_nProcessorThreads, &sz, 0, 0) == -1)
    {
        Ice::SyscallException ex(__FILE__, __LINE__);
        ex.error = IceInternal::getSystemErrno();
        throw ex;
    }
#else
    _nProcessorThreads = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN));
#endif

    //
    // Get the rest of the node information.
    //
#ifdef _WIN32
    _os = "Windows";
    char hostname[MAX_COMPUTERNAME_LENGTH + 1];
    unsigned long size = sizeof(hostname);
    if(GetComputerName(hostname, &size))
    {
        _hostname = hostname;
    }
    OSVERSIONINFO osInfo;
    osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    GetVersionEx(&osInfo);
    ostringstream os;
    os << osInfo.dwMajorVersion << "." << osInfo.dwMinorVersion;
    _release = os.str();
    _version = osInfo.szCSDVersion;

    switch(sysInfo.wProcessorArchitecture)
    {
    case PROCESSOR_ARCHITECTURE_AMD64:
        _machine = "x64";
        break;
    case PROCESSOR_ARCHITECTURE_IA64:
        _machine = "IA64";
        break;
    case PROCESSOR_ARCHITECTURE_INTEL:
        _machine = "x86";
        break;
    default:
        _machine = "unknown";
        break;
    };
#else
    struct utsname utsinfo;
    uname(&utsinfo);
    _os = utsinfo.sysname;
    _hostname = utsinfo.nodename;
    _release = utsinfo.release;
    _version = utsinfo.version;
    _machine = utsinfo.machine;
#endif

    Ice::PropertiesPtr properties = communicator->getProperties();

    //
    // Try to obtain the number of processor sockets.
    //
    _nProcessorSockets = properties->getPropertyAsIntWithDefault("IceGrid.Node.ProcessorSocketCount", 0);
    if(_nProcessorSockets == 0)
    {
#if defined(_WIN32)
        _nProcessorSockets = getSocketCount(_traceLevels->logger);
#elif defined(__linux)
        IceUtilInternal::ifstream is(string("/proc/cpuinfo"));
        set<string> ids;
        
        int nprocessor = 0;
        while(is)
        {
            string line;
            getline(is, line);
            if(line.find("processor") == 0)
            {
                nprocessor++;
            }
            else if(line.find("physical id") == 0)
            {
                nprocessor--;
                ids.insert(line);
            }
        }
        _nProcessorSockets = nprocessor + ids.size();
#else
        // Not supported
        _nProcessorSockets = 1;
#endif
    }

    string endpointsPrefix;
    if(prefix == "IceGrid.Registry")
    {
        _name = properties->getPropertyWithDefault("IceGrid.Registry.ReplicaName", "Master");
        endpointsPrefix = prefix + ".Client";
    }
    else
    {
        _name = properties->getProperty(prefix + ".Name");
        endpointsPrefix = prefix;
    }

    Ice::PropertyDict props = properties->getPropertiesForPrefix(endpointsPrefix);
    Ice::PropertyDict::const_iterator p = props.find(endpointsPrefix + ".PublishedEndpoints");
    if(p != props.end())
    {
        _endpoints = p->second;
    }
    else
    {
        _endpoints = properties->getProperty(endpointsPrefix + ".Endpoints");
    }

    string cwd;
    if(IceUtilInternal::getcwd(cwd) != 0)
    {
        throw "cannot get the current directory:\n" + IceUtilInternal::lastErrorToString();
    }
    _cwd = string(cwd);

    _dataDir = properties->getProperty(prefix + ".Data");    
    if(!IceUtilInternal::isAbsolutePath(_dataDir))
    {
        _dataDir = _cwd + '/' + _dataDir;
    }
    if(_dataDir[_dataDir.length() - 1] == '/')
    {
        _dataDir = _dataDir.substr(0, _dataDir.length() - 1);
    }
}