zoukankan      html  css  js  c++  java
  • ice使用过程遇到的问题

    1 设置代理超时时间ice_timeout

       ICE的每个连接都有两个超时时间:ice_timeout、ice_connectiontimeout,分别对应消息的超时时间和连接建立
       的超时时间,可以通过在代理上调用上述方法来设置超时,也可以通过属性Ice.Override.Timeout、Ice.Override.ConnectTimeout
       来强制改变超时时间。

    示例如下,

    MyAdapter.Endpoints=tcp –p 9999 –t 5000

    base = __ice_runtime.stringToProxy(settings.CONF_DATA_CENTER_SERVERS).ice_timeout(500) //获得代理的超时时间


     在客户端,我们使用对象代理进行远程调用,就如它们就在本地一样。但有时,网络问题还是要考虑的,于是Ice的对象代理提供了几个包装方法,以支持一些网络特性:

    ice_timeout方法,声明为:Ice::ObjectPrx ice_timeout(int) const;返回一个超时代理,当在指定的时间(单位毫秒)内没有得到服务器端响应时,操作终止并抛出Ice::TimeoutException异常。

    示例代码
    1. Filesystem::FilePrx myFile = ...;
    2. FileSystem::FilePrx timeoutFile
    3. = FileSystem::FilePrx::uncheckedCast(
    4.         myFile->ice_timeout(5000));
    5. try {
    6.     Lines text = timeoutFile->read(); // Read with timeout
    7. catch(const Ice::TimeoutException &) {
    8.     cerr << "invocation timed out" << endl;
    9. }
    10. Lines text = myFile->read(); // Read without timeout




    1设置定位服务缓存超时时间

    Ice.Default.LocatorCacheTimeout  

    对于定位服务,可以缓存 代理对应的端点地址,这样可以减少定位请求。

    Description

    Specifies the default locator cache timeout for indirect proxies. If num is set to a value larger than zero, locator cache entries older than num seconds are ignored. If set to 0, the locator cache is not used. If set to -1, locator cache entries do not expire.

    Once a cache entry has expired, the Ice run time performs a new locate request to refresh the cache before sending the next invocation; therefore, the invocation is delayed until the run time has refreshed the entry. If you set Ice.BackgroundLocatorCacheUpdates to a non-zero value, the lookup to refresh the cache is still performed but happens in the background; this avoids the delay for the first invocation that follows expiry of a cache entry.


     Ice.BackgroundLocatorCacheUpdates 


    2  报异常IceUtil::NullHandleException:

    Null Smart Pointers

    A null smart pointer contains a null C++ pointer to its underlying instance. This means that if you attempt to dereference a null smart pointer, you get an IceUtil::NullHandleException:

    C++
    TimeOfDayPtr tod;               // Construct null handle
    
    try {
        tod->minute = 0;            // Dereference null handle
        assert(false);              // Cannot get here
    } catch (const IceUtil::NullHandleException&) {
        ; // OK, expected
    } catch (...) {
        assert(false);              // Must get NullHandleException
    }


    Default constructor

    You can default-construct a proxy handle. The default constructor creates a proxy that points nowhere (that is, points at no object at all). If you invoke an operation on such a null proxy, you get an IceUtil::NullHandleException:

    C++
    try {
        SimplePrx s;        // Default-constructed proxy
        s->op();            // Call via nil proxy
        assert(0);          // Can't get here
    } catch (const IceUtil::NullHandleException&) {
        cout << "As expected, got a NullHandleException" << endl;
    }
    
    
    
    
  • 相关阅读:
    no-return-assign (Rules) – Eslint 中文开发手册
    CSS 字体图标
    CSS 元素的显示与隐藏
    CSS 定位
    CSS 清除浮动
    CSS 浮动
    java 运算符
    Java 初识
    CSS3 完善盒模型
    CSS 盒子模型
  • 原文地址:https://www.cnblogs.com/catkins/p/5270389.html
Copyright © 2011-2022 走看看