LocatorI(string name, LookupPrx lookup, Ice.Properties properties, string instanceName, Ice.LocatorPrx voidLocator) { _lookup = lookup; _timeout = properties.getPropertyAsIntWithDefault(name + ".Timeout", 300); _retryCount = properties.getPropertyAsIntWithDefault(name + ".RetryCount", 3); _retryDelay = properties.getPropertyAsIntWithDefault(name + ".RetryDelay", 2000); _timer = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer(); _traceLevel = properties.getPropertyAsInt(name + ".Trace.Lookup"); _instanceName = instanceName; _warned = false; _locator = lookup.ice_getCommunicator().getDefaultLocator(); _voidLocator = voidLocator; _pendingRetryCount = 0; _failureCount = 0; _warnOnce = true; // // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast // datagram on each endpoint. // var single = new Ice.Endpoint[1]; foreach (var endpt in lookup.ice_getEndpoints()) { single[0] = endpt; _lookups[(LookupPrx)lookup.ice_endpoints(single)] = null; } Debug.Assert(_lookups.Count > 0); }
public LocatorKey(Ice.LocatorPrx prx) { Reference r = ((Ice.ObjectPrxHelperBase)prx).iceReference(); _id = r.getIdentity(); _encoding = r.getEncoding(); }
invoke(Ice.LocatorPrx l) { if (_locatorPrx == null || !_locatorPrx.Equals(l)) { _locatorPrx = l; l.ice_invokeAsync(_operation, _mode, _inParams, _context).ContinueWith( (task) => { try { SetResult(task.Result); } catch (AggregateException ae) { exception(ae.InnerException); } }, TaskScheduler.Current); } else { Debug.Assert(_exception != null); throw _exception; } }
invoke(Ice.LocatorPrx locator, Request request) { lock (this) { if (request != null && _locator != null && _locator != locator) { request.invoke(_locator); } else if (request != null && IceInternal.Time.currentMonotonicTimeMillis() < _nextRetry) { request.invoke(_voidLocator); // Don't retry to find a locator before the retry delay expires } else { _locator = null; if (request != null) { _pendingRequests.Add(request); } if (_pendingRetryCount == 0) // No request in progress { _pendingRetryCount = _retryCount; _failureCount = 0; try { foreach (var l in _lookups) { l.Key.findLocatorAsync(_instanceName, l.Value).ContinueWith(t => { try { t.Wait(); } catch (AggregateException ex) { exception(ex.InnerException); } }); // Send multicast request. } _timer.schedule(this, _timeout); } catch (Ice.LocalException) { foreach (Request req in _pendingRequests) { req.invoke(_voidLocator); } _pendingRequests.Clear(); _pendingRetryCount = 0; } } } } }
setDefaultLocator(Ice.LocatorPrx locator) { lock (this) { if (_state == StateDestroyed) { throw new Ice.CommunicatorDestroyedException(); } _referenceFactory = _referenceFactory.setDefaultLocator(locator); } }
public LocatorI(LookupPrx lookup, Ice.Properties properties, string instanceName, Ice.LocatorPrx voidLocator) { _lookup = lookup; _timeout = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.Timeout", 300); _retryCount = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryCount", 3); _retryDelay = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryDelay", 2000); _timer = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer(); _instanceName = instanceName; _warned = false; _locator = lookup.ice_getCommunicator().getDefaultLocator(); _voidLocator = voidLocator; _pendingRetryCount = 0; }
LocatorI(LookupPrx lookup, Ice.Properties properties, string instanceName, Ice.LocatorPrx voidLocator) { _lookup = lookup; _timeout = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.Timeout", 300); _retryCount = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryCount", 3); _retryDelay = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.RetryDelay", 2000); _timer = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer(); _instanceName = instanceName; _warned = false; _locator = lookup.ice_getCommunicator().getDefaultLocator(); _voidLocator = voidLocator; _pendingRetryCount = 0; }
public ReferenceFactory setDefaultLocator(Ice.LocatorPrx defaultLocator) { if (_defaultLocator == null ? defaultLocator == null : _defaultLocator.Equals(defaultLocator)) { return(this); } ReferenceFactory factory = new ReferenceFactory(instance_, _communicator); factory._defaultLocator = defaultLocator; factory._defaultRouter = _defaultRouter; return(factory); }
LocatorI(string name, LookupPrx lookup, Ice.Properties properties, string instanceName, Ice.LocatorPrx voidLocator) { _timeout = properties.getPropertyAsIntWithDefault(name + ".Timeout", 300); _retryCount = properties.getPropertyAsIntWithDefault(name + ".RetryCount", 3); _retryDelay = properties.getPropertyAsIntWithDefault(name + ".RetryDelay", 2000); _timer = IceInternal.Util.getInstance(lookup.ice_getCommunicator()).timer(); _instanceName = instanceName; _warned = false; _locator = lookup.ice_getCommunicator().getDefaultLocator(); _voidLocator = voidLocator; _pendingRetryCount = 0; try { lookup.ice_getConnection(); } catch (Ice.LocalException ex) { StringBuilder b = new StringBuilder(); b.Append("IceLocatorDiscovery is unable to establish a multicast connection:\n"); b.Append("proxy = "); b.Append(lookup.ToString()); b.Append('\n'); b.Append(ex.ToString()); throw new Ice.PluginInitializationException(b.ToString()); } // // Create one lookup proxy per endpoint from the given proxy. We want to send a multicast // datagram on each endpoint. // var single = new Ice.Endpoint[1]; foreach (var endpt in lookup.ice_getEndpoints()) { try { single[0] = endpt; LookupPrx l = (LookupPrx)lookup.ice_endpoints(single); l.ice_getConnection(); _lookup[(LookupPrx)lookup.ice_endpoints(single)] = null; } catch (Ice.LocalException) { // Ignore } } Debug.Assert(_lookup.Count > 0); }
invoke(Ice.LocatorPrx l) { _locatorPrx = l; try { l.begin_ice_invoke(_operation, _mode, _inParams, _context).whenCompleted( (bool ok, byte[] outParams) => { _amdCB.ice_response(ok, outParams); }, (Ice.Exception ex) => { exception(ex); }); } catch (Ice.LocalException ex) { exception(ex); } }
// // Returns locator info for a given locator. Automatically creates // the locator info if it doesn't exist yet. // public LocatorInfo get(Ice.LocatorPrx loc) { if (loc == null) { return(null); } // // The locator can't be located. // Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(loc.ice_locator(null)); // // TODO: reap unused locator info objects? // lock (this) { LocatorInfo info = null; if (!_table.TryGetValue(locator, out info)) { // // Rely on locator identity for the adapter table. We want to // have only one table per locator (not one per locator // proxy). // LocatorTable table = null; LocatorKey key = new LocatorKey(locator); if (!_locatorTables.TryGetValue(key, out table)) { table = new LocatorTable(); _locatorTables[key] = table; } info = new LocatorInfo(locator, table, _background); _table[locator] = info; } return(info); } }
invoke(Ice.LocatorPrx locator, Request request) { lock (this) { if (_locator != null && _locator != locator) { request.invoke(_locator); } else if (IceInternal.Time.currentMonotonicTimeMillis() < _nextRetry) { request.invoke(_voidLocator); // Don't retry to find a locator before the retry delay expires } else { _locator = null; _pendingRequests.Add(request); if (_pendingRetryCount == 0) // No request in progress { _pendingRetryCount = _retryCount; try { _lookup.begin_findLocator(_instanceName, _lookupReply); // Send multicast request. _timer.schedule(this, _timeout); } catch (Ice.LocalException) { foreach (Request req in _pendingRequests) { req.invoke(_voidLocator); } _pendingRequests.Clear(); _pendingRetryCount = 0; } } } } }
invoke(Ice.LocatorPrx l) { _locatorPrx = l; try { l.ice_invokeAsync(_operation, _mode, _inParams, _context).ContinueWith( (task) => { try { SetResult(task.Result); } catch (AggregateException ae) { exception(ae.InnerException); } }); } catch (Ice.LocalException ex) { exception(ex); } }
public static Test.MyClassPrx allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Write("testing stringToProxy... "); Flush(); string rf = "test:" + app.getTestEndpoint(0); Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf); test(baseProxy != null); Ice.ObjectPrx b1 = communicator.stringToProxy("test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("test "); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy(" test "); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy(" test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("'test -f facet'"); test(b1.ice_getIdentity().name.Equals("test -f facet") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); try { b1 = communicator.stringToProxy("\"test -f facet'"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("\"test -f facet\""); test(b1.ice_getIdentity().name.Equals("test -f facet") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("\"test -f facet@test\""); test(b1.ice_getIdentity().name.Equals("test -f facet@test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("\"test -f facet@test @test\""); test(b1.ice_getIdentity().name.Equals("test -f facet@test @test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); try { b1 = communicator.stringToProxy("test test"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test\\040test"); test(b1.ice_getIdentity().name.Equals("test test") && b1.ice_getIdentity().category.Length == 0); try { b1 = communicator.stringToProxy("test\\777"); test(false); } catch (Ice.IdentityParseException) { } b1 = communicator.stringToProxy("test\\40test"); test(b1.ice_getIdentity().name.Equals("test test")); // Test some octal and hex corner cases. b1 = communicator.stringToProxy("test\\4test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\04test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\004test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\1114test"); test(b1.ice_getIdentity().name.Equals("test\u00494test")); b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test"); test(b1.ice_getIdentity().name.Equals("test\b\f\n\r\t\'\"\\test") && b1.ice_getIdentity().category.Length == 0); b1 = communicator.stringToProxy("category/test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy(""); test(b1 == null); b1 = communicator.stringToProxy("\"\""); test(b1 == null); try { b1 = communicator.stringToProxy("\"\" test"); // Invalid trailing characters. test(false); } catch (Ice.ProxyParseException) { } try { b1 = communicator.stringToProxy("test:"); // Missing endpoint. test(false); } catch (Ice.EndpointParseException) { } b1 = communicator.stringToProxy("test@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Equals("adapter")); try { b1 = communicator.stringToProxy("id@adapter test"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("category/test@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("category/test@adapter:tcp"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter:tcp")); b1 = communicator.stringToProxy("'category 1/test'@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category 1") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("'category/test 1'@adapter"); test(b1.ice_getIdentity().name.Equals("test 1") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("'category/test'@'adapter 1'"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter 1")); b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category /test@foo") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\""); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category /test@foo") && b1.ice_getAdapterId().Equals("adapter:tcp")); b1 = communicator.stringToProxy("id -f facet"); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet")); b1 = communicator.stringToProxy("id -f 'facet x'"); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet x")); b1 = communicator.stringToProxy("id -f \"facet x\""); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet x")); try { b1 = communicator.stringToProxy("id -f \"facet x"); test(false); } catch (Ice.ProxyParseException) { } try { b1 = communicator.stringToProxy("id -f \'facet x"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test -f facet:tcp"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f \"facet:tcp\""); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet:tcp") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f facet@test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet") && b1.ice_getAdapterId().Equals("test")); b1 = communicator.stringToProxy("test -f 'facet@test'"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet@test") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f 'facet@test'@test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet@test") && b1.ice_getAdapterId().Equals("test")); try { b1 = communicator.stringToProxy("test -f facet@test @test"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test"); test(b1.ice_isTwoway()); b1 = communicator.stringToProxy("test -t"); test(b1.ice_isTwoway()); b1 = communicator.stringToProxy("test -o"); test(b1.ice_isOneway()); b1 = communicator.stringToProxy("test -O"); test(b1.ice_isBatchOneway()); b1 = communicator.stringToProxy("test -d"); test(b1.ice_isDatagram()); b1 = communicator.stringToProxy("test -D"); test(b1.ice_isBatchDatagram()); b1 = communicator.stringToProxy("test"); test(!b1.ice_isSecure()); b1 = communicator.stringToProxy("test -s"); test(b1.ice_isSecure()); test(b1.ice_getEncodingVersion().Equals(Ice.Util.currentEncoding)); b1 = communicator.stringToProxy("test -e 1.0"); test(b1.ice_getEncodingVersion().major == 1 && b1.ice_getEncodingVersion().minor == 0); b1 = communicator.stringToProxy("test -e 6.5"); test(b1.ice_getEncodingVersion().major == 6 && b1.ice_getEncodingVersion().minor == 5); b1 = communicator.stringToProxy("test -p 1.0 -e 1.0"); test(b1.ToString().Equals("test -t -e 1.0")); b1 = communicator.stringToProxy("test -p 6.5 -e 1.0"); test(b1.ToString().Equals("test -t -p 6.5 -e 1.0")); try { communicator.stringToProxy("test:tcp@adapterId"); test(false); } catch (Ice.EndpointParseException) { } // This is an unknown endpoint warning, not a parse exception. // //try //{ // b1 = communicator.stringToProxy("test -f the:facet:tcp"); // test(false); //} //catch(Ice.EndpointParseException) //{ //} try { communicator.stringToProxy("test: :tcp"); test(false); } catch (Ice.EndpointParseException) { } // // Test invalid endpoint syntax // try { communicator.createObjectAdapterWithEndpoints("BadAdapter", " : "); test(false); } catch (Ice.EndpointParseException) { } try { communicator.createObjectAdapterWithEndpoints("BadAdapter", "tcp: "); test(false); } catch (Ice.EndpointParseException) { } try { communicator.createObjectAdapterWithEndpoints("BadAdapter", ":tcp"); test(false); } catch (Ice.EndpointParseException) { } // // Test for bug ICE-5543: escaped escapes in stringToIdentity // Ice.Identity id = new Ice.Identity("test", ",X2QNUAzSBcJ_e$AV;E\\"); Ice.Identity id2 = Ice.Util.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); id = new Ice.Identity("test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\"); id2 = Ice.Util.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); id = new Ice.Identity("/test", "cat/"); string idStr = communicator.identityToString(id); test(idStr == "cat\\//\\/test"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); // Input string with various pitfalls id = Ice.Util.stringToIdentity("\\342\\x82\\254\\60\\x9\\60\\"); test(id.name == "€0\t0\\" && id.category == ""); try { // Illegal character < 32 id = Ice.Util.stringToIdentity("xx\01FooBar"); test(false); } catch (Ice.IdentityParseException) { } try { // Illegal surrogate id = Ice.Util.stringToIdentity("xx\\ud911"); test(false); } catch (Ice.IdentityParseException) { } // Testing bytes 127 (\x7F, \177) and € id = new Ice.Identity("test", "\x7f€"); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.Unicode); test(idStr == "\\u007f€/test"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); test(Ice.Util.identityToString(id) == idStr); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.ASCII); test(idStr == "\\u007f\\u20ac/test"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.Compat); test(idStr == "\\177\\342\\202\\254/test"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); id2 = Ice.Util.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); // More unicode character id = new Ice.Identity("banana \x0E-\ud83c\udf4c\u20ac\u00a2\u0024", "greek \ud800\udd6a"); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.Unicode); test(idStr == "greek \ud800\udd6a/banana \\u000e-\ud83c\udf4c\u20ac\u00a2$"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.ASCII); test(idStr == "greek \\U0001016a/banana \\u000e-\\U0001f34c\\u20ac\\u00a2$"); id2 = Ice.Util.stringToIdentity(idStr); test(id.Equals(id2)); idStr = Ice.Util.identityToString(id, Ice.ToStringMode.Compat); id2 = Ice.Util.stringToIdentity(idStr); test(idStr == "greek \\360\\220\\205\\252/banana \\016-\\360\\237\\215\\214\\342\\202\\254\\302\\242$"); test(id.Equals(id2)); WriteLine("ok"); Write("testing proxyToString... "); Flush(); b1 = communicator.stringToProxy(rf); Ice.ObjectPrx b2 = communicator.stringToProxy(communicator.proxyToString(b1)); test(b1.Equals(b2)); if (b1.ice_getConnection() != null) // not colloc-optimized target { b2 = b1.ice_getConnection().createProxy(Ice.Util.stringToIdentity("fixed")); String str = communicator.proxyToString(b2); test(b2.ToString() == str); String str2 = b1.ice_identity(b2.ice_getIdentity()).ice_secure(b2.ice_isSecure()).ToString(); // Verify that the stringified fixed proxy is the same as a regular stringified proxy // but without endpoints test(str2.StartsWith(str)); test(str2[str.Length] == ':'); } WriteLine("ok"); Write("testing propertyToProxy... "); Flush(); Ice.Properties prop = communicator.getProperties(); String propertyPrefix = "Foo.Proxy"; prop.setProperty(propertyPrefix, "test:" + app.getTestEndpoint(0)); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Length == 0 && b1.ice_getFacet().Length == 0); string property; property = propertyPrefix + ".Locator"; test(b1.ice_getLocator() == null); prop.setProperty(property, "locator:default -p 10000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name.Equals("locator")); try { prop.setProperty(property, ""); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } property = propertyPrefix + ".LocatorCacheTimeout"; test(b1.ice_getLocatorCacheTimeout() == -1); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocatorCacheTimeout() == 1); prop.setProperty(property, ""); // Now retest with an indirect proxy. prop.setProperty(propertyPrefix, "test"); property = propertyPrefix + ".Locator"; prop.setProperty(property, "locator:default -p 10000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name.Equals("locator")); prop.setProperty(property, ""); property = propertyPrefix + ".LocatorCacheTimeout"; test(b1.ice_getLocatorCacheTimeout() == -1); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocatorCacheTimeout() == 1); prop.setProperty(property, ""); // This cannot be tested so easily because the property is cached // on communicator initialization. // //prop.setProperty("Ice.Default.LocatorCacheTimeout", "60"); //b1 = communicator.propertyToProxy(propertyPrefix); //test(b1.ice_getLocatorCacheTimeout() == 60); //prop.setProperty("Ice.Default.LocatorCacheTimeout", ""); prop.setProperty(propertyPrefix, "test:" + app.getTestEndpoint(0)); property = propertyPrefix + ".Router"; test(b1.ice_getRouter() == null); prop.setProperty(property, "router:default -p 10000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getRouter() != null && b1.ice_getRouter().ice_getIdentity().name.Equals("router")); prop.setProperty(property, ""); property = propertyPrefix + ".PreferSecure"; test(!b1.ice_isPreferSecure()); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_isPreferSecure()); prop.setProperty(property, ""); property = propertyPrefix + ".ConnectionCached"; test(b1.ice_isConnectionCached()); prop.setProperty(property, "0"); b1 = communicator.propertyToProxy(propertyPrefix); test(!b1.ice_isConnectionCached()); prop.setProperty(property, ""); property = propertyPrefix + ".InvocationTimeout"; test(b1.ice_getInvocationTimeout() == -1); prop.setProperty(property, "1000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getInvocationTimeout() == 1000); prop.setProperty(property, ""); property = propertyPrefix + ".EndpointSelection"; test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); prop.setProperty(property, "Random"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); prop.setProperty(property, "Ordered"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); prop.setProperty(property, ""); property = propertyPrefix + ".CollocationOptimized"; test(b1.ice_isCollocationOptimized()); prop.setProperty(property, "0"); b1 = communicator.propertyToProxy(propertyPrefix); test(!b1.ice_isCollocationOptimized()); prop.setProperty(property, ""); property = propertyPrefix + ".Context.c1"; test(!b1.ice_getContext().ContainsKey("c1")); prop.setProperty(property, "TEST"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getContext()["c1"].Equals("TEST")); property = propertyPrefix + ".Context.c2"; test(!b1.ice_getContext().ContainsKey("c2")); prop.setProperty(property, "TEST"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getContext()["c2"].Equals("TEST")); prop.setProperty(propertyPrefix + ".Context.c1", ""); prop.setProperty(propertyPrefix + ".Context.c2", ""); WriteLine("ok"); Write("testing proxyToProperty... "); Flush(); b1 = communicator.stringToProxy("test"); b1 = b1.ice_collocationOptimized(true); b1 = b1.ice_connectionCached(true); b1 = b1.ice_preferSecure(false); b1 = b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered); b1 = b1.ice_locatorCacheTimeout(100); b1 = b1.ice_invocationTimeout(1234); b1 = b1.ice_encodingVersion(new Ice.EncodingVersion(1, 0)); Ice.ObjectPrx router = communicator.stringToProxy("router"); router = router.ice_collocationOptimized(false); router = router.ice_connectionCached(true); router = router.ice_preferSecure(true); router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random); router = router.ice_locatorCacheTimeout(200); router = router.ice_invocationTimeout(1500); Ice.ObjectPrx locator = communicator.stringToProxy("locator"); locator = locator.ice_collocationOptimized(true); locator = locator.ice_connectionCached(false); locator = locator.ice_preferSecure(true); locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random); locator = locator.ice_locatorCacheTimeout(300); locator = locator.ice_invocationTimeout(1500); locator = locator.ice_router(Ice.RouterPrxHelper.uncheckedCast(router)); b1 = b1.ice_locator(Ice.LocatorPrxHelper.uncheckedCast(locator)); Dictionary <string, string> proxyProps = communicator.proxyToProperty(b1, "Test"); test(proxyProps.Count == 21); test(proxyProps["Test"].Equals("test -t -e 1.0")); test(proxyProps["Test.CollocationOptimized"].Equals("1")); test(proxyProps["Test.ConnectionCached"].Equals("1")); test(proxyProps["Test.PreferSecure"].Equals("0")); test(proxyProps["Test.EndpointSelection"].Equals("Ordered")); test(proxyProps["Test.LocatorCacheTimeout"].Equals("100")); test(proxyProps["Test.InvocationTimeout"].Equals("1234")); test(proxyProps["Test.Locator"].Equals( "locator -t -e " + Ice.Util.encodingVersionToString(Ice.Util.currentEncoding))); // Locator collocation optimization is always disabled. //test(proxyProps["Test.Locator.CollocationOptimized"].Equals("1")); test(proxyProps["Test.Locator.ConnectionCached"].Equals("0")); test(proxyProps["Test.Locator.PreferSecure"].Equals("1")); test(proxyProps["Test.Locator.EndpointSelection"].Equals("Random")); test(proxyProps["Test.Locator.LocatorCacheTimeout"].Equals("300")); test(proxyProps["Test.Locator.InvocationTimeout"].Equals("1500")); test(proxyProps["Test.Locator.Router"].Equals( "router -t -e " + Ice.Util.encodingVersionToString(Ice.Util.currentEncoding))); test(proxyProps["Test.Locator.Router.CollocationOptimized"].Equals("0")); test(proxyProps["Test.Locator.Router.ConnectionCached"].Equals("1")); test(proxyProps["Test.Locator.Router.PreferSecure"].Equals("1")); test(proxyProps["Test.Locator.Router.EndpointSelection"].Equals("Random")); test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"].Equals("200")); test(proxyProps["Test.Locator.Router.InvocationTimeout"].Equals("1500")); WriteLine("ok"); Write("testing ice_getCommunicator... "); Flush(); test(baseProxy.ice_getCommunicator() == communicator); WriteLine("ok"); Write("testing proxy methods... "); // Disable Obsolete warning/error #pragma warning disable 612, 618 test(communicator.identityToString( baseProxy.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()).Equals("other")); #pragma warning restore 612, 618 test(baseProxy.ice_facet("facet").ice_getFacet().Equals("facet")); test(baseProxy.ice_adapterId("id").ice_getAdapterId().Equals("id")); test(baseProxy.ice_twoway().ice_isTwoway()); test(baseProxy.ice_oneway().ice_isOneway()); test(baseProxy.ice_batchOneway().ice_isBatchOneway()); test(baseProxy.ice_datagram().ice_isDatagram()); test(baseProxy.ice_batchDatagram().ice_isBatchDatagram()); test(baseProxy.ice_secure(true).ice_isSecure()); test(!baseProxy.ice_secure(false).ice_isSecure()); test(baseProxy.ice_collocationOptimized(true).ice_isCollocationOptimized()); test(!baseProxy.ice_collocationOptimized(false).ice_isCollocationOptimized()); test(baseProxy.ice_preferSecure(true).ice_isPreferSecure()); test(!baseProxy.ice_preferSecure(false).ice_isPreferSecure()); try { baseProxy.ice_timeout(0); test(false); } catch (ArgumentException) { } try { baseProxy.ice_timeout(-1); } catch (ArgumentException) { test(false); } try { baseProxy.ice_timeout(-2); test(false); } catch (ArgumentException) { } try { baseProxy.ice_invocationTimeout(0); test(false); } catch (ArgumentException) { } try { baseProxy.ice_invocationTimeout(-1); baseProxy.ice_invocationTimeout(-2); } catch (ArgumentException) { test(false); } try { baseProxy.ice_invocationTimeout(-3); test(false); } catch (ArgumentException) { } try { baseProxy.ice_locatorCacheTimeout(0); } catch (ArgumentException) { test(false); } try { baseProxy.ice_locatorCacheTimeout(-1); } catch (ArgumentException) { test(false); } try { baseProxy.ice_locatorCacheTimeout(-2); test(false); } catch (ArgumentException) { } WriteLine("ok"); Write("testing proxy comparison... "); Flush(); test(communicator.stringToProxy("foo").Equals(communicator.stringToProxy("foo"))); test(!communicator.stringToProxy("foo").Equals(communicator.stringToProxy("foo2"))); Ice.ObjectPrx compObj = communicator.stringToProxy("foo"); test(compObj.ice_facet("facet").Equals(compObj.ice_facet("facet"))); test(!compObj.ice_facet("facet").Equals(compObj.ice_facet("facet1"))); test(compObj.ice_oneway().Equals(compObj.ice_oneway())); test(!compObj.ice_oneway().Equals(compObj.ice_twoway())); test(compObj.ice_secure(true).Equals(compObj.ice_secure(true))); test(!compObj.ice_secure(false).Equals(compObj.ice_secure(true))); test(compObj.ice_collocationOptimized(true).Equals(compObj.ice_collocationOptimized(true))); test(!compObj.ice_collocationOptimized(false).Equals(compObj.ice_collocationOptimized(true))); test(compObj.ice_connectionCached(true).Equals(compObj.ice_connectionCached(true))); test(!compObj.ice_connectionCached(false).Equals(compObj.ice_connectionCached(true))); test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random).Equals( compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random))); test(!compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random).Equals( compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))); test(compObj.ice_connectionId("id2").Equals(compObj.ice_connectionId("id2"))); test(!compObj.ice_connectionId("id1").Equals(compObj.ice_connectionId("id2"))); test(compObj.ice_connectionId("id1").ice_getConnectionId().Equals("id1")); test(compObj.ice_connectionId("id2").ice_getConnectionId().Equals("id2")); test(compObj.ice_compress(true).Equals(compObj.ice_compress(true))); test(!compObj.ice_compress(false).Equals(compObj.ice_compress(true))); test(!compObj.ice_getCompress().HasValue); test(compObj.ice_compress(true).ice_getCompress().Value == true); test(compObj.ice_compress(false).ice_getCompress().Value == false); test(compObj.ice_timeout(20).Equals(compObj.ice_timeout(20))); test(!compObj.ice_timeout(10).Equals(compObj.ice_timeout(20))); test(!compObj.ice_getTimeout().HasValue); test(compObj.ice_timeout(10).ice_getTimeout().Value == 10); test(compObj.ice_timeout(20).ice_getTimeout().Value == 20); Ice.LocatorPrx loc1 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000")); Ice.LocatorPrx loc2 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc2:default -p 10000")); test(compObj.ice_locator(null).Equals(compObj.ice_locator(null))); test(compObj.ice_locator(loc1).Equals(compObj.ice_locator(loc1))); test(!compObj.ice_locator(loc1).Equals(compObj.ice_locator(null))); test(!compObj.ice_locator(null).Equals(compObj.ice_locator(loc2))); test(!compObj.ice_locator(loc1).Equals(compObj.ice_locator(loc2))); Ice.RouterPrx rtr1 = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("rtr1:default -p 10000")); Ice.RouterPrx rtr2 = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("rtr2:default -p 10000")); test(compObj.ice_router(null).Equals(compObj.ice_router(null))); test(compObj.ice_router(rtr1).Equals(compObj.ice_router(rtr1))); test(!compObj.ice_router(rtr1).Equals(compObj.ice_router(null))); test(!compObj.ice_router(null).Equals(compObj.ice_router(rtr2))); test(!compObj.ice_router(rtr1).Equals(compObj.ice_router(rtr2))); Dictionary <string, string> ctx1 = new Dictionary <string, string>(); ctx1["ctx1"] = "v1"; Dictionary <string, string> ctx2 = new Dictionary <string, string>(); ctx2["ctx2"] = "v2"; test(compObj.ice_context(null).Equals(compObj.ice_context(null))); test(compObj.ice_context(ctx1).Equals(compObj.ice_context(ctx1))); test(!compObj.ice_context(ctx1).Equals(compObj.ice_context(null))); test(!compObj.ice_context(null).Equals(compObj.ice_context(ctx2))); test(!compObj.ice_context(ctx1).Equals(compObj.ice_context(ctx2))); test(compObj.ice_preferSecure(true).Equals(compObj.ice_preferSecure(true))); test(!compObj.ice_preferSecure(true).Equals(compObj.ice_preferSecure(false))); Ice.ObjectPrx compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000"); Ice.ObjectPrx compObj2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001"); test(!compObj1.Equals(compObj2)); compObj1 = communicator.stringToProxy("foo@MyAdapter1"); compObj2 = communicator.stringToProxy("foo@MyAdapter2"); test(!compObj1.Equals(compObj2)); test(compObj1.ice_locatorCacheTimeout(20).Equals(compObj1.ice_locatorCacheTimeout(20))); test(!compObj1.ice_locatorCacheTimeout(10).Equals(compObj1.ice_locatorCacheTimeout(20))); test(compObj1.ice_invocationTimeout(20).Equals(compObj1.ice_invocationTimeout(20))); test(!compObj1.ice_invocationTimeout(10).Equals(compObj1.ice_invocationTimeout(20))); compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 1000"); compObj2 = communicator.stringToProxy("foo@MyAdapter1"); test(!compObj1.Equals(compObj2)); Ice.Endpoint[] endpts1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints(); Ice.Endpoint[] endpts2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001").ice_getEndpoints(); test(!endpts1[0].Equals(endpts2[0])); test(endpts1[0].Equals(communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints()[0])); Ice.Connection baseConnection = baseProxy.ice_getConnection(); if (baseConnection != null) { Ice.Connection baseConnection2 = baseProxy.ice_connectionId("base2").ice_getConnection(); compObj1 = compObj1.ice_fixed(baseConnection); compObj2 = compObj2.ice_fixed(baseConnection2); test(!compObj1.Equals(compObj2)); } WriteLine("ok"); Write("testing checked cast... "); Flush(); Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy); test(cl != null); Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(cl); test(derived != null); test(cl.Equals(baseProxy)); test(derived.Equals(baseProxy)); test(cl.Equals(derived)); WriteLine("ok"); Write("testing checked cast with context... "); Flush(); Dictionary <string, string> c = cl.getContext(); test(c == null || c.Count == 0); c = new Dictionary <string, string>(); c["one"] = "hello"; c["two"] = "world"; cl = Test.MyClassPrxHelper.checkedCast(baseProxy, c); Dictionary <string, string> c2 = cl.getContext(); test(Ice.CollectionComparer.Equals(c, c2)); WriteLine("ok"); Write("testing ice_fixed... "); Flush(); { Ice.Connection connection = cl.ice_getConnection(); if (connection != null) { Test.MyClassPrx prx = (Test.MyClassPrx)cl.ice_fixed(connection); prx.ice_ping(); test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure()); test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet().Equals("facet")); test(cl.ice_oneway().ice_fixed(connection).ice_isOneway()); Dictionary <string, string> ctx = new Dictionary <string, string>(); ctx["one"] = "hello"; ctx["two"] = "world"; test(cl.ice_fixed(connection).ice_getContext().Count == 0); test(cl.ice_context(ctx).ice_fixed(connection).ice_getContext().Count == 2); test(cl.ice_fixed(connection).ice_getInvocationTimeout() == -1); test(cl.ice_invocationTimeout(10).ice_fixed(connection).ice_getInvocationTimeout() == 10); test(cl.ice_fixed(connection).ice_getConnection() == connection); test(cl.ice_fixed(connection).ice_fixed(connection).ice_getConnection() == connection); test(!cl.ice_fixed(connection).ice_getTimeout().HasValue); test(cl.ice_compress(true).ice_fixed(connection).ice_getCompress().Value); Ice.Connection fixedConnection = cl.ice_connectionId("ice_fixed").ice_getConnection(); test(cl.ice_fixed(connection).ice_fixed(fixedConnection).ice_getConnection() == fixedConnection); try { cl.ice_secure(!connection.getEndpoint().getInfo().secure()).ice_fixed(connection).ice_ping(); } catch (Ice.NoEndpointException) { } try { cl.ice_datagram().ice_fixed(connection).ice_ping(); } catch (Ice.NoEndpointException) { } } else { try { cl.ice_fixed(connection); test(false); } catch (ArgumentException) { // Expected with null connection. } } } WriteLine("ok"); Write("testing encoding versioning... "); Flush(); string ref20 = "test -e 2.0:" + app.getTestEndpoint(0); Test.MyClassPrx cl20 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); try { cl20.ice_ping(); test(false); } catch (Ice.UnsupportedEncodingException) { // Server 2.0 endpoint doesn't support 1.1 version. } string ref10 = "test -e 1.0:" + app.getTestEndpoint(0); Test.MyClassPrx cl10 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref10)); cl10.ice_ping(); cl10.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); cl.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the // call will use the 1.1 encoding string ref13 = "test -e 1.3:" + app.getTestEndpoint(0); Test.MyClassPrx cl13 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); cl13.end_ice_ping(cl13.begin_ice_ping()); try { // Send request with bogus 1.2 encoding. Ice.EncodingVersion version = new Ice.EncodingVersion(1, 2); Ice.OutputStream os = new Ice.OutputStream(communicator); os.startEncapsulation(); os.endEncapsulation(); byte[] inEncaps = os.finished(); inEncaps[4] = version.major; inEncaps[5] = version.minor; byte[] outEncaps; cl.ice_invoke("ice_ping", Ice.OperationMode.Normal, inEncaps, out outEncaps); test(false); } catch (Ice.UnknownLocalException ex) { // The server thrown an UnsupportedEncodingException test(ex.unknown.IndexOf("UnsupportedEncodingException") > 0); } try { // Send request with bogus 2.0 encoding. Ice.EncodingVersion version = new Ice.EncodingVersion(2, 0); Ice.OutputStream os = new Ice.OutputStream(communicator); os.startEncapsulation(); os.endEncapsulation(); byte[] inEncaps = os.finished(); inEncaps[4] = version.major; inEncaps[5] = version.minor; byte[] outEncaps; cl.ice_invoke("ice_ping", Ice.OperationMode.Normal, inEncaps, out outEncaps); test(false); } catch (Ice.UnknownLocalException ex) { // The server thrown an UnsupportedEncodingException test(ex.unknown.IndexOf("UnsupportedEncodingException") > 0); } WriteLine("ok"); Write("testing protocol versioning... "); Flush(); ref20 = "test -p 2.0:" + app.getTestEndpoint(0); cl20 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); try { cl20.ice_ping(); test(false); } catch (Ice.UnsupportedProtocolException) { // Server 2.0 proxy doesn't support 1.0 version. } ref10 = "test -p 1.0:" + app.getTestEndpoint(0); cl10 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref10)); cl10.ice_ping(); // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the // call will use the 1.1 protocol ref13 = "test -p 1.3:" + app.getTestEndpoint(0); cl13 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); cl13.end_ice_ping(cl13.begin_ice_ping()); WriteLine("ok"); Write("testing opaque endpoints... "); Flush(); try { // Invalid -x option communicator.stringToProxy("id:opaque -t 99 -v abcd -x abc"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -t and -v communicator.stringToProxy("id:opaque"); test(false); } catch (Ice.EndpointParseException) { } try { // Repeated -t communicator.stringToProxy("id:opaque -t 1 -t 1 -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Repeated -v communicator.stringToProxy("id:opaque -t 1 -v abcd -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -t communicator.stringToProxy("id:opaque -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -v communicator.stringToProxy("id:opaque -t 1"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing arg for -t communicator.stringToProxy("id:opaque -t -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing arg for -v communicator.stringToProxy("id:opaque -t 1 -v"); test(false); } catch (Ice.EndpointParseException) { } try { // Not a number for -t communicator.stringToProxy("id:opaque -t x -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // < 0 for -t communicator.stringToProxy("id:opaque -t -1 -v abcd"); test(false); } catch (Ice.EndpointParseException) { } try { // Invalid char for -v communicator.stringToProxy("id:opaque -t 99 -v x?c"); test(false); } catch (Ice.EndpointParseException) { } try { // Invalid lenght for base64 input communicator.stringToProxy("id:opaque -t 99 -v xc"); test(false); } catch (Ice.EndpointParseException) { } // Legal TCP endpoint expressed as opaque endpoint Ice.ObjectPrx p1 = communicator.stringToProxy("test -e 1.1:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); string pstr = communicator.proxyToString(p1); test(pstr.Equals("test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")); // Opaque endpoint encoded with 1.1 encoding. Ice.ObjectPrx p2 = communicator.stringToProxy("test -e 1.1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); test(communicator.proxyToString(p2).Equals("test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")); if (communicator.getProperties().getPropertyAsInt("Ice.IPv6") == 0) { // Working? bool ssl = communicator.getProperties().getProperty("Ice.Default.Protocol").Equals("ssl"); bool tcp = communicator.getProperties().getProperty("Ice.Default.Protocol").Equals("tcp"); // Two legal TCP endpoints expressed as opaque endpoints p1 = communicator.stringToProxy("test -e 1.0:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMusuAAAQJwAAAA=="); pstr = communicator.proxyToString(p1); test(pstr.Equals("test -t -e 1.0:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000")); // Test that an SSL endpoint and a nonsense endpoint get written back out as an opaque endpoint. p1 = communicator.stringToProxy("test -e 1.0:opaque -e 1.0 -t 2 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -e 1.0 -t 99 -v abch"); pstr = communicator.proxyToString(p1); if (ssl) { test(pstr.Equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch")); } else if (tcp) { test(pstr.Equals( "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch")); } } WriteLine("ok"); Write("testing communicator shutdown/destroy... "); Flush(); { Ice.Communicator com = Ice.Util.initialize(); com.shutdown(); test(com.isShutdown()); com.waitForShutdown(); com.destroy(); com.shutdown(); test(com.isShutdown()); com.waitForShutdown(); com.destroy(); } WriteLine("ok"); return(cl); }
foundLocator(Ice.LocatorPrx locator, Ice.Current current) { _locator.foundLocator(locator); }
initialize() { Ice.Properties properties = _communicator.getProperties(); bool ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; bool preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; if (ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceLocatorDiscovery.Address", "239.255.0.1"); } else { address = properties.getPropertyWithDefault("IceLocatorDiscovery.Address", "ff15::1"); } int port = properties.getPropertyAsIntWithDefault("IceLocatorDiscovery.Port", 4061); string intf = properties.getProperty("IceLocatorDiscovery.Interface"); if (properties.getProperty("IceLocatorDiscovery.Reply.Endpoints").Length == 0) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("udp"); if (intf.Length > 0) { s.Append(" -h \""); s.Append(intf); s.Append("\""); } properties.setProperty("IceLocatorDiscovery.Reply.Endpoints", s.ToString()); } if (properties.getProperty("IceLocatorDiscovery.Locator.Endpoints").Length == 0) { properties.setProperty("IceLocatorDiscovery.Locator.AdapterId", Guid.NewGuid().ToString()); } _replyAdapter = _communicator.createObjectAdapter("IceLocatorDiscovery.Reply"); _locatorAdapter = _communicator.createObjectAdapter("IceLocatorDiscovery.Locator"); // We don't want those adapters to be registered with the locator so clear their locator. _replyAdapter.setLocator(null); _locatorAdapter.setLocator(null); string lookupEndpoints = properties.getProperty("IceLocatorDiscovery.Lookup"); if (lookupEndpoints.Length == 0) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("udp -h \""); s.Append(address); s.Append("\" -p "); s.Append(port); if (intf.Length > 0) { s.Append(" --interface \""); s.Append(intf); s.Append("\""); } lookupEndpoints = s.ToString(); } Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceLocatorDiscovery/Lookup -d:" + lookupEndpoints); lookupPrx = lookupPrx.ice_collocationOptimized(false); // No colloc optimization for the multicast proxy! try { lookupPrx.ice_getConnection(); // Ensure we can establish a connection to the multicast proxy } catch (Ice.LocalException ex) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("IceLocatorDiscovery is unable to establish a multicast connection:\n"); s.Append("proxy = "); s.Append(lookupPrx.ToString()); s.Append("\n"); s.Append(ex); throw new Ice.PluginInitializationException(s.ToString()); } Ice.LocatorPrx voidLo = Ice.LocatorPrxHelper.uncheckedCast(_locatorAdapter.addWithUUID(new VoidLocatorI())); string instanceName = properties.getProperty("IceLocatorDiscovery.InstanceName"); Ice.Identity id = new Ice.Identity(); id.name = "Locator"; id.category = instanceName.Length > 0 ? instanceName : Guid.NewGuid().ToString(); LocatorI locator = new LocatorI(LookupPrxHelper.uncheckedCast(lookupPrx), properties, instanceName, voidLo); _communicator.setDefaultLocator(Ice.LocatorPrxHelper.uncheckedCast(_locatorAdapter.addWithUUID(locator))); Ice.ObjectPrx lookupReply = _replyAdapter.addWithUUID(new LookupReplyI(locator)).ice_datagram(); locator.setLookupReply(LookupReplyPrxHelper.uncheckedCast(lookupReply)); _replyAdapter.activate(); _locatorAdapter.activate(); }
foundLocator(Ice.LocatorPrx locator) { lock (this) { if (locator == null || (_instanceName.Length > 0 && !locator.ice_getIdentity().category.Equals(_instanceName))) { return; } // // If we already have a locator assigned, ensure the given locator // has the same identity, otherwise ignore it. // if (_locator != null && !locator.ice_getIdentity().category.Equals(_locator.ice_getIdentity().category)) { if (!_warned) { _warned = true; // Only warn once locator.ice_getCommunicator().getLogger().warning( "received Ice locator with different instance name:\n" + "using = `" + _locator.ice_getIdentity().category + "'\n" + "received = `" + locator.ice_getIdentity().category + "'\n" + "This is typically the case if multiple Ice locators with different " + "instance names are deployed and the property `IceLocatorDiscovery.InstanceName'" + "is not set."); } return; } if (_pendingRetryCount > 0) // No need to retry, we found a locator { _timer.cancel(this); _pendingRetryCount = 0; } if (_locator != null) { // // We found another locator replica, append its endpoints to the // current locator proxy endpoints. // List <Ice.Endpoint> newEndpoints = new List <Ice.Endpoint>(_locator.ice_getEndpoints()); foreach (Ice.Endpoint p in locator.ice_getEndpoints()) { // // Only add endpoints if not already in the locator proxy endpoints // bool found = false; foreach (Ice.Endpoint q in newEndpoints) { if (p.Equals(q)) { found = true; break; } } if (!found) { newEndpoints.Add(p); } } _locator = (Ice.LocatorPrx)_locator.ice_endpoints(newEndpoints.ToArray()); } else { _locator = locator; if (_instanceName.Length == 0) { _instanceName = _locator.ice_getIdentity().category; // Stick to the first locator } } // // Send pending requests if any. // foreach (Request req in _pendingRequests) { req.invoke(_locator); } _pendingRequests.Clear(); } }
internal LocatorInfo(Ice.LocatorPrx locator, LocatorTable table, bool background) { _locator = locator; _table = table; _background = background; }
public void foundLocator(Ice.LocatorPrx locator) { lock(this) { if(locator == null || (_instanceName.Length > 0 && !locator.ice_getIdentity().category.Equals(_instanceName))) { return; } // // If we already have a locator assigned, ensure the given locator // has the same identity, otherwise ignore it. // if(_locator != null && !locator.ice_getIdentity().category.Equals(_locator.ice_getIdentity().category)) { if(!_warned) { _warned = true; // Only warn once locator.ice_getCommunicator().getLogger().warning( "received Ice locator with different instance name:\n" + "using = `" + _locator.ice_getIdentity().category + "'\n" + "received = `" + locator.ice_getIdentity().category + "'\n" + "This is typically the case if multiple Ice locators with different " + "instance names are deployed and the property `IceLocatorDiscovery.InstanceName'" + "is not set."); } return; } if(_pendingRetryCount > 0) // No need to retry, we found a locator { _timer.cancel(this); _pendingRetryCount = 0; } if(_locator != null) { // // We found another locator replica, append its endpoints to the // current locator proxy endpoints. // List<Ice.Endpoint> newEndpoints = new List<Ice.Endpoint>(_locator.ice_getEndpoints()); foreach(Ice.Endpoint p in locator.ice_getEndpoints()) { // // Only add endpoints if not already in the locator proxy endpoints // bool found = false; foreach(Ice.Endpoint q in newEndpoints) { if(p.Equals(q)) { found = true; break; } } if(!found) { newEndpoints.Add(p); } } _locator = (Ice.LocatorPrx) _locator.ice_endpoints(newEndpoints.ToArray()); } else { _locator = locator; if(_instanceName.Length == 0) { _instanceName = _locator.ice_getIdentity().category; // Stick to the first locator } } // // Send pending requests if any. // foreach(Request req in _pendingRequests) { req.invoke(_locator); } _pendingRequests.Clear(); } }
foundLocator(Ice.LocatorPrx locator) { lock (this) { if (locator == null || (_instanceName.Length > 0 && !locator.ice_getIdentity().category.Equals(_instanceName))) { if (_traceLevel > 2) { StringBuilder s = new StringBuilder("ignoring locator reply: instance name doesn't match\n"); s.Append("expected = ").Append(_instanceName); s.Append("received = ").Append(locator.ice_getIdentity().category); _lookup.ice_getCommunicator().getLogger().trace("Lookup", s.ToString()); } return; } // // If we already have a locator assigned, ensure the given locator // has the same identity, otherwise ignore it. // if (_pendingRequests.Count > 0 && _locator != null && !locator.ice_getIdentity().category.Equals(_locator.ice_getIdentity().category)) { if (!_warned) { _warned = true; // Only warn once locator.ice_getCommunicator().getLogger().warning( "received Ice locator with different instance name:\n" + "using = `" + _locator.ice_getIdentity().category + "'\n" + "received = `" + locator.ice_getIdentity().category + "'\n" + "This is typically the case if multiple Ice locators with different " + "instance names are deployed and the property `IceLocatorDiscovery.InstanceName'" + "is not set."); } return; } if (_pendingRetryCount > 0) // No need to retry, we found a locator { _timer.cancel(this); _pendingRetryCount = 0; } if (_traceLevel > 0) { StringBuilder s = new StringBuilder("locator lookup succeeded:\nlocator = "); s.Append(locator); if (_instanceName.Length == 0) { s.Append("\ninstance name = ").Append(_instanceName); } _lookup.ice_getCommunicator().getLogger().trace("Lookup", s.ToString()); } Ice.LocatorPrx l = null; if (_pendingRequests.Count == 0) { _locators.TryGetValue(locator.ice_getIdentity().category, out _locator); } else { l = _locator; } if (l != null) { // // We found another locator replica, append its endpoints to the // current locator proxy endpoints. // List <Ice.Endpoint> newEndpoints = new List <Ice.Endpoint>(l.ice_getEndpoints()); foreach (Ice.Endpoint p in locator.ice_getEndpoints()) { // // Only add endpoints if not already in the locator proxy endpoints // bool found = false; foreach (Ice.Endpoint q in newEndpoints) { if (p.Equals(q)) { found = true; break; } } if (!found) { newEndpoints.Add(p); } } l = (Ice.LocatorPrx)l.ice_endpoints(newEndpoints.ToArray()); } else { l = locator; } if (_pendingRequests.Count == 0) { _locators[locator.ice_getIdentity().category] = l; Monitor.Pulse(this); } else { _locator = l; if (_instanceName.Length == 0) { _instanceName = _locator.ice_getIdentity().category; // Stick to the first locator } // // Send pending requests if any. // foreach (Request req in _pendingRequests) { req.invoke(_locator); } _pendingRequests.Clear(); } } }
public void invoke(Ice.LocatorPrx l) { _locatorPrx = l; try { l.begin_ice_invoke(_operation, _mode, _inParams, _context).whenCompleted( (bool ok, byte[] outParams) => { _amdCB.ice_response(ok, outParams); }, (Ice.Exception ex) => { exception(ex); }); } catch(Ice.LocalException ex) { exception(ex); } }
invoke(Ice.LocatorPrx locator, Request request) { lock (this) { if (request != null && _locator != null && _locator != locator) { request.invoke(_locator); } else if (request != null && IceInternal.Time.currentMonotonicTimeMillis() < _nextRetry) { request.invoke(_voidLocator); // Don't retry to find a locator before the retry delay expires } else { _locator = null; if (request != null) { _pendingRequests.Add(request); } if (_pendingRetryCount == 0) // No request in progress { _pendingRetryCount = _retryCount; _failureCount = 0; try { if (_traceLevel > 1) { StringBuilder s = new StringBuilder("looking up locator:\nlookup = "); s.Append(_lookup); if (_instanceName.Length == 0) { s.Append("\ninstance name = ").Append(_instanceName); } _lookup.ice_getCommunicator().getLogger().trace("Lookup", s.ToString()); } foreach (var l in _lookups) { l.Key.findLocatorAsync(_instanceName, l.Value).ContinueWith(t => { try { t.Wait(); } catch (AggregateException ex) { exception(ex.InnerException); } }, l.Key.ice_scheduler()); // Send multicast request. } _timer.schedule(this, _timeout); } catch (Ice.LocalException ex) { if (_traceLevel > 0) { StringBuilder s = new StringBuilder("locator lookup failed:\nlookup = "); s.Append(_lookup); if (_instanceName.Length == 0) { s.Append("\ninstance name = ").Append(_instanceName); } s.Append("\n").Append(ex); _lookup.ice_getCommunicator().getLogger().trace("Lookup", s.ToString()); } foreach (Request req in _pendingRequests) { req.invoke(_voidLocator); } _pendingRequests.Clear(); _pendingRetryCount = 0; } } } } }
public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); ServerManagerPrx manager = ServerManagerPrxHelper.checkedCast( communicator.stringToProxy("ServerManager :" + app.getTestEndpoint(0))); test(manager != null); TestLocatorPrx locator = TestLocatorPrxHelper.uncheckedCast(communicator.getDefaultLocator()); test(locator != null); TestLocatorRegistryPrx registry = TestLocatorRegistryPrxHelper.checkedCast(locator.getRegistry()); test(registry != null); Write("testing stringToProxy... "); Flush(); Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter"); Ice.ObjectPrx base2 = communicator.stringToProxy("test @ TestAdapter"); Ice.ObjectPrx base3 = communicator.stringToProxy("test"); Ice.ObjectPrx base4 = communicator.stringToProxy("ServerManager"); Ice.ObjectPrx base5 = communicator.stringToProxy("test2"); Ice.ObjectPrx base6 = communicator.stringToProxy("test @ ReplicatedAdapter"); WriteLine("ok"); Write("testing ice_locator and ice_getLocator... "); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0); Ice.LocatorPrx anotherLocator = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("anotherLocator")); @base = @base.ice_locator(anotherLocator); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0); communicator.setDefaultLocator(null); @base = communicator.stringToProxy("test @ TestAdapter"); test(@base.ice_getLocator() == null); @base = @base.ice_locator(anotherLocator); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), anotherLocator) == 0); communicator.setDefaultLocator(locator); @base = communicator.stringToProxy("test @ TestAdapter"); test(Ice.Util.proxyIdentityCompare(@base.ice_getLocator(), communicator.getDefaultLocator()) == 0); // // We also test ice_router/ice_getRouter (perhaps we should add a // test/Ice/router test?) // test(@base.ice_getRouter() == null); Ice.RouterPrx anotherRouter = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("anotherRouter")); @base = @base.ice_router(anotherRouter); test(Ice.Util.proxyIdentityCompare(@base.ice_getRouter(), anotherRouter) == 0); Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("dummyrouter")); communicator.setDefaultRouter(router); @base = communicator.stringToProxy("test @ TestAdapter"); test(Ice.Util.proxyIdentityCompare(@base.ice_getRouter(), communicator.getDefaultRouter()) == 0); communicator.setDefaultRouter(null); @base = communicator.stringToProxy("test @ TestAdapter"); test(@base.ice_getRouter() == null); WriteLine("ok"); Write("starting server... "); Flush(); manager.startServer(); WriteLine("ok"); Write("testing checked cast... "); Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); test(obj != null); TestIntfPrx obj2 = TestIntfPrxHelper.checkedCast(base2); test(obj2 != null); TestIntfPrx obj3 = TestIntfPrxHelper.checkedCast(base3); test(obj3 != null); ServerManagerPrx obj4 = ServerManagerPrxHelper.checkedCast(base4); test(obj4 != null); TestIntfPrx obj5 = TestIntfPrxHelper.checkedCast(base5); test(obj5 != null); TestIntfPrx obj6 = TestIntfPrxHelper.checkedCast(base6); test(obj6 != null); WriteLine("ok"); Write("testing id@AdapterId indirect proxy... "); Flush(); obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } WriteLine("ok"); Write("testing id@ReplicaGroupId indirect proxy... "); Flush(); obj.shutdown(); manager.startServer(); try { obj6.ice_ping(); } catch (Ice.LocalException) { test(false); } WriteLine("ok"); Write("testing identity indirect proxy... "); Flush(); obj.shutdown(); manager.startServer(); try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj2.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj3.ice_ping(); } catch (Ice.LocalException) { test(false); } obj.shutdown(); manager.startServer(); try { obj5 = TestIntfPrxHelper.checkedCast(base5); obj5.ice_ping(); } catch (Ice.LocalException) { test(false); } WriteLine("ok"); Write("testing proxy with unknown identity... "); Flush(); try { @base = communicator.stringToProxy("unknown/unknown"); @base.ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object")); test(ex.id.Equals("unknown/unknown")); } WriteLine("ok"); Write("testing proxy with unknown adapter... "); Flush(); try { @base = communicator.stringToProxy("test @ TestAdapterUnknown"); @base.ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object adapter")); test(ex.id.Equals("TestAdapterUnknown")); } WriteLine("ok"); Write("testing locator cache timeout... "); Flush(); int count = locator.getRequestCount(); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. test(++count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. test(++count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. test(count == locator.getRequestCount()); System.Threading.Thread.Sleep(1200); // 1200ms communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. test(++count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. count += 2; test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout test(count == locator.getRequestCount()); System.Threading.Thread.Sleep(1200); // 1200ms communicator.stringToProxy("test").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout count += 2; test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_locatorCacheTimeout(-1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_locatorCacheTimeout(-1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter").ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test").ice_ping(); test(count == locator.getRequestCount()); test(communicator.stringToProxy("test").ice_locatorCacheTimeout(99).ice_getLocatorCacheTimeout() == 99); WriteLine("ok"); Write("testing proxy from server... "); Flush(); obj = TestIntfPrxHelper.checkedCast(communicator.stringToProxy("test@TestAdapter")); HelloPrx hello = obj.getHello(); test(hello.ice_getAdapterId().Equals("TestAdapter")); hello.sayHello(); hello = obj.getReplicatedHello(); test(hello.ice_getAdapterId().Equals("ReplicatedAdapter")); hello.sayHello(); WriteLine("ok"); Write("testing locator request queuing... "); Flush(); hello = (HelloPrx)obj.getReplicatedHello().ice_locatorCacheTimeout(0).ice_connectionCached(false); count = locator.getRequestCount(); hello.ice_ping(); test(++count == locator.getRequestCount()); List <Ice.AsyncResult <Test.Callback_Hello_sayHello> > results = new List <Ice.AsyncResult <Test.Callback_Hello_sayHello> >(); for (int i = 0; i < 1000; i++) { Ice.AsyncResult <Test.Callback_Hello_sayHello> result = hello.begin_sayHello(). whenCompleted( () => { }, (Ice.Exception ex) => { test(false); }); results.Add(result); } foreach (Ice.AsyncResult <Test.Callback_Hello_sayHello> result in results) { result.waitForCompleted(); } results.Clear(); test(locator.getRequestCount() > count && locator.getRequestCount() < count + 999); if (locator.getRequestCount() > count + 800) { Write("queuing = " + (locator.getRequestCount() - count)); } count = locator.getRequestCount(); hello = (HelloPrx)hello.ice_adapterId("unknown"); for (int i = 0; i < 1000; i++) { Ice.AsyncResult <Test.Callback_Hello_sayHello> result = hello.begin_sayHello(). whenCompleted( () => { test(false); }, (Ice.Exception ex) => { test(ex is Ice.NotRegisteredException); }); results.Add(result); } foreach (Ice.AsyncResult <Test.Callback_Hello_sayHello> result in results) { result.waitForCompleted(); } results.Clear(); // XXX: // Take into account the retries. test(locator.getRequestCount() > count && locator.getRequestCount() < count + 1999); if (locator.getRequestCount() > count + 800) { Write("queuing = " + (locator.getRequestCount() - count)); } WriteLine("ok"); Write("testing adapter locator cache... "); Flush(); try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject == "object adapter"); test(ex.id.Equals("TestAdapter3")); } registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); registry.setAdapterDirectProxy("TestAdapter3", communicator.stringToProxy("dummy:tcp")); communicator.stringToProxy("test@TestAdapter3").ice_ping(); } catch (Ice.LocalException) { test(false); } try { communicator.stringToProxy("test@TestAdapter3").ice_locatorCacheTimeout(0).ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.setAdapterDirectProxy("TestAdapter3", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test@TestAdapter3").ice_ping(); } catch (Ice.LocalException) { test(false); } WriteLine("ok"); Write("testing well-known object locator cache... "); Flush(); registry.addObject(communicator.stringToProxy("test3@TestUnknown")); try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject == "object adapter"); test(ex.id.Equals("TestUnknown")); } registry.addObject(communicator.stringToProxy("test3@TestAdapter4")); // Update registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.setAdapterDirectProxy("TestAdapter4", locator.findAdapterById("TestAdapter")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } registry.setAdapterDirectProxy("TestAdapter4", communicator.stringToProxy("dummy:tcp")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } try { communicator.stringToProxy("test@TestAdapter4").ice_locatorCacheTimeout(0).ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test@TestAdapter4").ice_ping(); test(false); } catch (Ice.LocalException) { } try { communicator.stringToProxy("test3").ice_ping(); test(false); } catch (Ice.LocalException) { } registry.addObject(communicator.stringToProxy("test3@TestAdapter")); try { communicator.stringToProxy("test3").ice_ping(); } catch (Ice.LocalException) { test(false); } registry.addObject(communicator.stringToProxy("test4")); try { communicator.stringToProxy("test4").ice_ping(); test(false); } catch (Ice.NoEndpointException) { } WriteLine("ok"); Write("testing locator cache background updates... "); Flush(); { Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.BackgroundLocatorCacheUpdates", "1"); Ice.Communicator ic = Ice.Util.initialize(initData); registry.setAdapterDirectProxy("TestAdapter5", locator.findAdapterById("TestAdapter")); registry.addObject(communicator.stringToProxy("test3@TestAdapter")); count = locator.getRequestCount(); ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. ic.stringToProxy("test3").ice_locatorCacheTimeout(0).ice_ping(); // No locator cache. count += 3; test(count == locator.getRequestCount()); registry.setAdapterDirectProxy("TestAdapter5", null); registry.addObject(communicator.stringToProxy("test3:tcp")); ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout. ic.stringToProxy("test3").ice_locatorCacheTimeout(10).ice_ping(); // 10s timeout. test(count == locator.getRequestCount()); System.Threading.Thread.Sleep(1200); // The following request should trigger the background // updates but still use the cached endpoints and // therefore succeed. ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. try { while (true) { ic.stringToProxy("test@TestAdapter5").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. System.Threading.Thread.Sleep(10); } } catch (Ice.LocalException) { // Expected to fail once they endpoints have been updated in the background. } try { while (true) { ic.stringToProxy("test3").ice_locatorCacheTimeout(1).ice_ping(); // 1s timeout. System.Threading.Thread.Sleep(10); } } catch (Ice.LocalException) { // Expected to fail once they endpoints have been updated in the background. } ic.destroy(); } WriteLine("ok"); Write("testing proxy from server after shutdown... "); Flush(); hello = obj.getReplicatedHello(); obj.shutdown(); manager.startServer(); hello.sayHello(); WriteLine("ok"); Write("testing object migration... "); Flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); obj.migrateHello(); hello.ice_getConnection().close(Ice.ConnectionClose.GracefullyWithWait); hello.sayHello(); obj.migrateHello(); hello.sayHello(); obj.migrateHello(); hello.sayHello(); WriteLine("ok"); Write("testing locator encoding resolution... "); Flush(); hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello")); count = locator.getRequestCount(); communicator.stringToProxy("test@TestAdapter").ice_encodingVersion(Ice.Util.Encoding_1_1).ice_ping(); test(count == locator.getRequestCount()); communicator.stringToProxy("test@TestAdapter10").ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); test(++count == locator.getRequestCount()); communicator.stringToProxy("test -e 1.0@TestAdapter10-2").ice_ping(); test(++count == locator.getRequestCount()); WriteLine("ok"); Write("shutdown server... "); Flush(); obj.shutdown(); WriteLine("ok"); Write("testing whether server is gone... "); Flush(); try { obj2.ice_ping(); test(false); } catch (Ice.LocalException) { } try { obj3.ice_ping(); test(false); } catch (Ice.LocalException) { } try { obj5.ice_ping(); test(false); } catch (Ice.LocalException) { } WriteLine("ok"); Write("testing indirect proxies to collocated objects... "); Flush(); // // Set up test for calling a collocated object through an // indirect, adapterless reference. // Ice.Properties properties = communicator.getProperties(); properties.setProperty("Ice.PrintAdapterReady", "0"); Ice.ObjectAdapter adapter = communicator.createObjectAdapterWithEndpoints("Hello", "tcp -h *"); adapter.setLocator(locator); Ice.Identity id = new Ice.Identity(); id.name = Guid.NewGuid().ToString(); registry.addObject(adapter.add(new HelloI(), id)); adapter.activate(); HelloPrx helloPrx = HelloPrxHelper.checkedCast( communicator.stringToProxy("\"" + communicator.identityToString(id) + "\"")); test(helloPrx.ice_getConnection() == null); adapter.deactivate(); WriteLine("ok"); Write("shutdown server manager... "); Flush(); manager.shutdown(); WriteLine("ok"); }
public void invoke(Ice.LocatorPrx locator, Request request) { lock(this) { if(_locator != null && _locator != locator) { request.invoke(_locator); } else if(IceInternal.Time.currentMonotonicTimeMillis() < _nextRetry) { request.invoke(_voidLocator); // Don't retry to find a locator before the retry delay expires } else { _locator = null; _pendingRequests.Add(request); if(_pendingRetryCount == 0) // No request in progress { _pendingRetryCount = _retryCount; try { _lookup.begin_findLocator(_instanceName, _lookupReply); // Send multicast request. _timer.schedule(this, _timeout); } catch(Ice.LocalException) { foreach(Request req in _pendingRequests) { req.invoke(_voidLocator); } _pendingRequests.Clear(); _pendingRetryCount = 0; } } } } }
initialize() { Ice.Properties properties = _communicator.getProperties(); bool ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; bool preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; if (ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault(_name + ".Address", "239.255.0.1"); } else { address = properties.getPropertyWithDefault(_name + ".Address", "ff15::1"); } int port = properties.getPropertyAsIntWithDefault(_name + ".Port", 4061); string intf = properties.getProperty(_name + ".Interface"); string lookupEndpoints = properties.getProperty(_name + ".Lookup"); if (lookupEndpoints.Length == 0) { int protocol = ipv4 && !preferIPv6 ? IceInternal.Network.EnableIPv4 : IceInternal.Network.EnableIPv6; var interfaces = IceInternal.Network.getInterfacesForMulticast(intf, protocol); foreach (string p in interfaces) { if (p != interfaces[0]) { lookupEndpoints += ":"; } lookupEndpoints += "udp -h \"" + address + "\" -p " + port + " --interface \"" + p + "\""; } } if (properties.getProperty(_name + ".Reply.Endpoints").Length == 0) { properties.setProperty(_name + ".Reply.Endpoints", "udp -h " + (intf.Length == 0 ? "*" : "\"" + intf + "\"")); } if (properties.getProperty(_name + ".Locator.Endpoints").Length == 0) { properties.setProperty(_name + ".Locator.AdapterId", Guid.NewGuid().ToString()); } _replyAdapter = _communicator.createObjectAdapter(_name + ".Reply"); _locatorAdapter = _communicator.createObjectAdapter(_name + ".Locator"); // We don't want those adapters to be registered with the locator so clear their locator. _replyAdapter.setLocator(null); _locatorAdapter.setLocator(null); Ice.ObjectPrx lookupPrx = _communicator.stringToProxy("IceLocatorDiscovery/Lookup -d:" + lookupEndpoints); // No colloc optimization or router for the multicast proxy! lookupPrx = lookupPrx.ice_collocationOptimized(false).ice_router(null); Ice.LocatorPrx voidLo = Ice.LocatorPrxHelper.uncheckedCast(_locatorAdapter.addWithUUID(new VoidLocatorI())); string instanceName = properties.getProperty(_name + ".InstanceName"); Ice.Identity id = new Ice.Identity(); id.name = "Locator"; id.category = instanceName.Length > 0 ? instanceName : Guid.NewGuid().ToString(); _defaultLocator = _communicator.getDefaultLocator(); _locator = new LocatorI(_name, LookupPrxHelper.uncheckedCast(lookupPrx), properties, instanceName, voidLo); _locatorPrx = Ice.LocatorPrxHelper.uncheckedCast(_locatorAdapter.addWithUUID(_locator)); _communicator.setDefaultLocator(_locatorPrx); Ice.ObjectPrx lookupReply = _replyAdapter.addWithUUID(new LookupReplyI(_locator)).ice_datagram(); _locator.setLookupReply(LookupReplyPrxHelper.uncheckedCast(lookupReply)); _replyAdapter.activate(); _locatorAdapter.activate(); }
internal LocatorInfo(Ice.LocatorPrx locator, LocatorTable table, bool background) { _locator = locator; _table = table; _background = background; }
public static Test.MyClassPrx allTests(Ice.Communicator communicator) { Write("testing stringToProxy... "); Flush(); string rf = "test:default -p 12010"; Ice.ObjectPrx baseProxy = communicator.stringToProxy(rf); test(baseProxy != null); Ice.ObjectPrx b1 = communicator.stringToProxy("test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("test "); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy(" test "); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy(" test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("'test -f facet'"); test(b1.ice_getIdentity().name.Equals("test -f facet") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); try { b1 = communicator.stringToProxy("\"test -f facet'"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("\"test -f facet\""); test(b1.ice_getIdentity().name.Equals("test -f facet") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("\"test -f facet@test\""); test(b1.ice_getIdentity().name.Equals("test -f facet@test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); b1 = communicator.stringToProxy("\"test -f facet@test @test\""); test(b1.ice_getIdentity().name.Equals("test -f facet@test @test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Length == 0); try { b1 = communicator.stringToProxy("test test"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test\\040test"); test(b1.ice_getIdentity().name.Equals("test test") && b1.ice_getIdentity().category.Length == 0); try { b1 = communicator.stringToProxy("test\\777"); test(false); } catch (Ice.IdentityParseException) { } b1 = communicator.stringToProxy("test\\40test"); test(b1.ice_getIdentity().name.Equals("test test")); // Test some octal and hex corner cases. b1 = communicator.stringToProxy("test\\4test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\04test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\004test"); test(b1.ice_getIdentity().name.Equals("test\u0004test")); b1 = communicator.stringToProxy("test\\1114test"); test(b1.ice_getIdentity().name.Equals("test\u00494test")); b1 = communicator.stringToProxy("test\\b\\f\\n\\r\\t\\'\\\"\\\\test"); test(b1.ice_getIdentity().name.Equals("test\b\f\n\r\t\'\"\\test") && b1.ice_getIdentity().category.Length == 0); b1 = communicator.stringToProxy("category/test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy(""); test(b1 == null); b1 = communicator.stringToProxy("\"\""); test(b1 == null); try { b1 = communicator.stringToProxy("\"\" test"); // Invalid trailing characters. test(false); } catch (Ice.ProxyParseException) { } try { b1 = communicator.stringToProxy("test:"); // Missing endpoint. test(false); } catch (Ice.EndpointParseException) { } b1 = communicator.stringToProxy("test@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Equals("adapter")); try { b1 = communicator.stringToProxy("id@adapter test"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("category/test@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("category/test@adapter:tcp"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter:tcp")); b1 = communicator.stringToProxy("'category 1/test'@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category 1") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("'category/test 1'@adapter"); test(b1.ice_getIdentity().name.Equals("test 1") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("'category/test'@'adapter 1'"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category") && b1.ice_getAdapterId().Equals("adapter 1")); b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@adapter"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category /test@foo") && b1.ice_getAdapterId().Equals("adapter")); b1 = communicator.stringToProxy("\"category \\/test@foo/test\"@\"adapter:tcp\""); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Equals("category /test@foo") && b1.ice_getAdapterId().Equals("adapter:tcp")); b1 = communicator.stringToProxy("id -f facet"); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet")); b1 = communicator.stringToProxy("id -f 'facet x'"); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet x")); b1 = communicator.stringToProxy("id -f \"facet x\""); test(b1.ice_getIdentity().name.Equals("id") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet x")); try { b1 = communicator.stringToProxy("id -f \"facet x"); test(false); } catch (Ice.ProxyParseException) { } try { b1 = communicator.stringToProxy("id -f \'facet x"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test -f facet:tcp"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f \"facet:tcp\""); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet:tcp") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f facet@test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet") && b1.ice_getAdapterId().Equals("test")); b1 = communicator.stringToProxy("test -f 'facet@test'"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet@test") && b1.ice_getAdapterId().Length == 0); b1 = communicator.stringToProxy("test -f 'facet@test'@test"); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getFacet().Equals("facet@test") && b1.ice_getAdapterId().Equals("test")); try { b1 = communicator.stringToProxy("test -f facet@test @test"); test(false); } catch (Ice.ProxyParseException) { } b1 = communicator.stringToProxy("test"); test(b1.ice_isTwoway()); b1 = communicator.stringToProxy("test -t"); test(b1.ice_isTwoway()); b1 = communicator.stringToProxy("test -o"); test(b1.ice_isOneway()); b1 = communicator.stringToProxy("test -O"); test(b1.ice_isBatchOneway()); b1 = communicator.stringToProxy("test -d"); test(b1.ice_isDatagram()); b1 = communicator.stringToProxy("test -D"); test(b1.ice_isBatchDatagram()); b1 = communicator.stringToProxy("test"); test(!b1.ice_isSecure()); b1 = communicator.stringToProxy("test -s"); test(b1.ice_isSecure()); test(b1.ice_getEncodingVersion().Equals(Ice.Util.currentEncoding)); b1 = communicator.stringToProxy("test -e 1.0"); test(b1.ice_getEncodingVersion().major == 1 && b1.ice_getEncodingVersion().minor == 0); b1 = communicator.stringToProxy("test -e 6.5"); test(b1.ice_getEncodingVersion().major == 6 && b1.ice_getEncodingVersion().minor == 5); b1 = communicator.stringToProxy("test -p 1.0 -e 1.0"); test(b1.ToString().Equals("test -t -e 1.0")); b1 = communicator.stringToProxy("test -p 6.5 -e 1.0"); test(b1.ToString().Equals("test -t -p 6.5 -e 1.0")); try { b1 = communicator.stringToProxy("test:tcp@adapterId"); test(false); } catch (Ice.EndpointParseException) { } // This is an unknown endpoint warning, not a parse exception. // //try //{ // b1 = communicator.stringToProxy("test -f the:facet:tcp"); // test(false); //} //catch(Ice.EndpointParseException) //{ //} try { b1 = communicator.stringToProxy("test::tcp"); test(false); } catch (Ice.EndpointParseException) { } // // Test for bug ICE-5543: escaped escapes in stringToIdentity // Ice.Identity id = new Ice.Identity("test", ",X2QNUAzSBcJ_e$AV;E\\"); Ice.Identity id2 = communicator.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); id = new Ice.Identity("test", ",X2QNUAz\\SB\\/cJ_e$AV;E\\\\"); id2 = communicator.stringToIdentity(communicator.identityToString(id)); test(id.Equals(id2)); WriteLine("ok"); Write("testing propertyToProxy... "); Flush(); Ice.Properties prop = communicator.getProperties(); String propertyPrefix = "Foo.Proxy"; prop.setProperty(propertyPrefix, "test:default -p 12010"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getIdentity().name.Equals("test") && b1.ice_getIdentity().category.Length == 0 && b1.ice_getAdapterId().Length == 0 && b1.ice_getFacet().Length == 0); String property; property = propertyPrefix + ".Locator"; test(b1.ice_getLocator() == null); prop.setProperty(property, "locator:default -p 10000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name.Equals("locator")); try { prop.setProperty(property, ""); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } property = propertyPrefix + ".LocatorCacheTimeout"; test(b1.ice_getLocatorCacheTimeout() == -1); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocatorCacheTimeout() == 1); prop.setProperty(property, ""); // Now retest with an indirect proxy. prop.setProperty(propertyPrefix, "test"); property = propertyPrefix + ".Locator"; prop.setProperty(property, "locator:default -p 10000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocator() != null && b1.ice_getLocator().ice_getIdentity().name.Equals("locator")); prop.setProperty(property, ""); property = propertyPrefix + ".LocatorCacheTimeout"; test(b1.ice_getLocatorCacheTimeout() == -1); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getLocatorCacheTimeout() == 1); prop.setProperty(property, ""); // This cannot be tested so easily because the property is cached // on communicator initialization. // //prop.setProperty("Ice.Default.LocatorCacheTimeout", "60"); //b1 = communicator.propertyToProxy(propertyPrefix); //test(b1.ice_getLocatorCacheTimeout() == 60); //prop.setProperty("Ice.Default.LocatorCacheTimeout", ""); prop.setProperty(propertyPrefix, "test:default -p 12010"); property = propertyPrefix + ".Router"; test(b1.ice_getRouter() == null); prop.setProperty(property, "router:default -p 10000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getRouter() != null && b1.ice_getRouter().ice_getIdentity().name.Equals("router")); prop.setProperty(property, ""); property = propertyPrefix + ".PreferSecure"; test(!b1.ice_isPreferSecure()); prop.setProperty(property, "1"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_isPreferSecure()); prop.setProperty(property, ""); property = propertyPrefix + ".ConnectionCached"; test(b1.ice_isConnectionCached()); prop.setProperty(property, "0"); b1 = communicator.propertyToProxy(propertyPrefix); test(!b1.ice_isConnectionCached()); prop.setProperty(property, ""); property = propertyPrefix + ".InvocationTimeout"; test(b1.ice_getInvocationTimeout() == -1); prop.setProperty(property, "1000"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getInvocationTimeout() == 1000); prop.setProperty(property, ""); property = propertyPrefix + ".EndpointSelection"; test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); prop.setProperty(property, "Random"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Random); prop.setProperty(property, "Ordered"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getEndpointSelection() == Ice.EndpointSelectionType.Ordered); prop.setProperty(property, ""); property = propertyPrefix + ".CollocationOptimized"; test(b1.ice_isCollocationOptimized()); prop.setProperty(property, "0"); b1 = communicator.propertyToProxy(propertyPrefix); test(!b1.ice_isCollocationOptimized()); prop.setProperty(property, ""); property = propertyPrefix + ".Context.c1"; test(!b1.ice_getContext().ContainsKey("c1")); prop.setProperty(property, "TEST"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getContext()["c1"].Equals("TEST")); property = propertyPrefix + ".Context.c2"; test(!b1.ice_getContext().ContainsKey("c2")); prop.setProperty(property, "TEST"); b1 = communicator.propertyToProxy(propertyPrefix); test(b1.ice_getContext()["c2"].Equals("TEST")); prop.setProperty(propertyPrefix + ".Context.c1", ""); prop.setProperty(propertyPrefix + ".Context.c2", ""); WriteLine("ok"); Write("testing proxyToProperty... "); Flush(); b1 = communicator.stringToProxy("test"); b1 = b1.ice_collocationOptimized(true); b1 = b1.ice_connectionCached(true); b1 = b1.ice_preferSecure(false); b1 = b1.ice_endpointSelection(Ice.EndpointSelectionType.Ordered); b1 = b1.ice_locatorCacheTimeout(100); b1 = b1.ice_invocationTimeout(1234); b1 = b1.ice_encodingVersion(new Ice.EncodingVersion(1, 0)); Ice.ObjectPrx router = communicator.stringToProxy("router"); router = router.ice_collocationOptimized(false); router = router.ice_connectionCached(true); router = router.ice_preferSecure(true); router = router.ice_endpointSelection(Ice.EndpointSelectionType.Random); router = router.ice_locatorCacheTimeout(200); router = router.ice_invocationTimeout(1500); Ice.ObjectPrx locator = communicator.stringToProxy("locator"); locator = locator.ice_collocationOptimized(true); locator = locator.ice_connectionCached(false); locator = locator.ice_preferSecure(true); locator = locator.ice_endpointSelection(Ice.EndpointSelectionType.Random); locator = locator.ice_locatorCacheTimeout(300); locator = locator.ice_invocationTimeout(1500); locator = locator.ice_router(Ice.RouterPrxHelper.uncheckedCast(router)); b1 = b1.ice_locator(Ice.LocatorPrxHelper.uncheckedCast(locator)); Dictionary <string, string> proxyProps = communicator.proxyToProperty(b1, "Test"); test(proxyProps.Count == 21); test(proxyProps["Test"].Equals("test -t -e 1.0")); test(proxyProps["Test.CollocationOptimized"].Equals("1")); test(proxyProps["Test.ConnectionCached"].Equals("1")); test(proxyProps["Test.PreferSecure"].Equals("0")); test(proxyProps["Test.EndpointSelection"].Equals("Ordered")); test(proxyProps["Test.LocatorCacheTimeout"].Equals("100")); test(proxyProps["Test.InvocationTimeout"].Equals("1234")); test(proxyProps["Test.Locator"].Equals( "locator -t -e " + Ice.Util.encodingVersionToString(Ice.Util.currentEncoding))); // Locator collocation optimization is always disabled. //test(proxyProps["Test.Locator.CollocationOptimized"].Equals("1")); test(proxyProps["Test.Locator.ConnectionCached"].Equals("0")); test(proxyProps["Test.Locator.PreferSecure"].Equals("1")); test(proxyProps["Test.Locator.EndpointSelection"].Equals("Random")); test(proxyProps["Test.Locator.LocatorCacheTimeout"].Equals("300")); test(proxyProps["Test.Locator.InvocationTimeout"].Equals("1500")); test(proxyProps["Test.Locator.Router"].Equals( "router -t -e " + Ice.Util.encodingVersionToString(Ice.Util.currentEncoding))); test(proxyProps["Test.Locator.Router.CollocationOptimized"].Equals("0")); test(proxyProps["Test.Locator.Router.ConnectionCached"].Equals("1")); test(proxyProps["Test.Locator.Router.PreferSecure"].Equals("1")); test(proxyProps["Test.Locator.Router.EndpointSelection"].Equals("Random")); test(proxyProps["Test.Locator.Router.LocatorCacheTimeout"].Equals("200")); test(proxyProps["Test.Locator.Router.InvocationTimeout"].Equals("1500")); WriteLine("ok"); Write("testing ice_getCommunicator... "); Flush(); test(baseProxy.ice_getCommunicator() == communicator); WriteLine("ok"); Write("testing proxy methods... "); test(communicator.identityToString( baseProxy.ice_identity(communicator.stringToIdentity("other")).ice_getIdentity()).Equals("other")); test(baseProxy.ice_facet("facet").ice_getFacet().Equals("facet")); test(baseProxy.ice_adapterId("id").ice_getAdapterId().Equals("id")); test(baseProxy.ice_twoway().ice_isTwoway()); test(baseProxy.ice_oneway().ice_isOneway()); test(baseProxy.ice_batchOneway().ice_isBatchOneway()); test(baseProxy.ice_datagram().ice_isDatagram()); test(baseProxy.ice_batchDatagram().ice_isBatchDatagram()); test(baseProxy.ice_secure(true).ice_isSecure()); test(!baseProxy.ice_secure(false).ice_isSecure()); test(baseProxy.ice_collocationOptimized(true).ice_isCollocationOptimized()); test(!baseProxy.ice_collocationOptimized(false).ice_isCollocationOptimized()); test(baseProxy.ice_preferSecure(true).ice_isPreferSecure()); test(!baseProxy.ice_preferSecure(false).ice_isPreferSecure()); try { baseProxy.ice_timeout(0); test(false); } catch (ArgumentException) { } try { baseProxy.ice_timeout(-1); } catch (ArgumentException) { test(false); } try { baseProxy.ice_timeout(-2); test(false); } catch (ArgumentException) { } try { baseProxy.ice_invocationTimeout(0); test(false); } catch (ArgumentException) { } try { baseProxy.ice_invocationTimeout(-1); baseProxy.ice_invocationTimeout(-2); } catch (ArgumentException) { test(false); } try { baseProxy.ice_invocationTimeout(-3); test(false); } catch (ArgumentException) { } try { baseProxy.ice_locatorCacheTimeout(0); } catch (ArgumentException) { test(false); } try { baseProxy.ice_locatorCacheTimeout(-1); } catch (ArgumentException) { test(false); } try { baseProxy.ice_locatorCacheTimeout(-2); test(false); } catch (ArgumentException) { } WriteLine("ok"); Write("testing proxy comparison... "); Flush(); test(communicator.stringToProxy("foo").Equals(communicator.stringToProxy("foo"))); test(!communicator.stringToProxy("foo").Equals(communicator.stringToProxy("foo2"))); Ice.ObjectPrx compObj = communicator.stringToProxy("foo"); test(compObj.ice_facet("facet").Equals(compObj.ice_facet("facet"))); test(!compObj.ice_facet("facet").Equals(compObj.ice_facet("facet1"))); test(compObj.ice_oneway().Equals(compObj.ice_oneway())); test(!compObj.ice_oneway().Equals(compObj.ice_twoway())); test(compObj.ice_secure(true).Equals(compObj.ice_secure(true))); test(!compObj.ice_secure(false).Equals(compObj.ice_secure(true))); test(compObj.ice_collocationOptimized(true).Equals(compObj.ice_collocationOptimized(true))); test(!compObj.ice_collocationOptimized(false).Equals(compObj.ice_collocationOptimized(true))); test(compObj.ice_connectionCached(true).Equals(compObj.ice_connectionCached(true))); test(!compObj.ice_connectionCached(false).Equals(compObj.ice_connectionCached(true))); test(compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random).Equals( compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random))); test(!compObj.ice_endpointSelection(Ice.EndpointSelectionType.Random).Equals( compObj.ice_endpointSelection(Ice.EndpointSelectionType.Ordered))); test(compObj.ice_connectionId("id2").Equals(compObj.ice_connectionId("id2"))); test(!compObj.ice_connectionId("id1").Equals(compObj.ice_connectionId("id2"))); test(compObj.ice_connectionId("id1").ice_getConnectionId().Equals("id1")); test(compObj.ice_connectionId("id2").ice_getConnectionId().Equals("id2")); test(compObj.ice_compress(true).Equals(compObj.ice_compress(true))); test(!compObj.ice_compress(false).Equals(compObj.ice_compress(true))); test(compObj.ice_timeout(20).Equals(compObj.ice_timeout(20))); test(!compObj.ice_timeout(10).Equals(compObj.ice_timeout(20))); Ice.LocatorPrx loc1 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc1:default -p 10000")); Ice.LocatorPrx loc2 = Ice.LocatorPrxHelper.uncheckedCast(communicator.stringToProxy("loc2:default -p 10000")); test(compObj.ice_locator(null).Equals(compObj.ice_locator(null))); test(compObj.ice_locator(loc1).Equals(compObj.ice_locator(loc1))); test(!compObj.ice_locator(loc1).Equals(compObj.ice_locator(null))); test(!compObj.ice_locator(null).Equals(compObj.ice_locator(loc2))); test(!compObj.ice_locator(loc1).Equals(compObj.ice_locator(loc2))); Ice.RouterPrx rtr1 = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("rtr1:default -p 10000")); Ice.RouterPrx rtr2 = Ice.RouterPrxHelper.uncheckedCast(communicator.stringToProxy("rtr2:default -p 10000")); test(compObj.ice_router(null).Equals(compObj.ice_router(null))); test(compObj.ice_router(rtr1).Equals(compObj.ice_router(rtr1))); test(!compObj.ice_router(rtr1).Equals(compObj.ice_router(null))); test(!compObj.ice_router(null).Equals(compObj.ice_router(rtr2))); test(!compObj.ice_router(rtr1).Equals(compObj.ice_router(rtr2))); Dictionary <string, string> ctx1 = new Dictionary <string, string>(); ctx1["ctx1"] = "v1"; Dictionary <string, string> ctx2 = new Dictionary <string, string>(); ctx2["ctx2"] = "v2"; test(compObj.ice_context(null).Equals(compObj.ice_context(null))); test(compObj.ice_context(ctx1).Equals(compObj.ice_context(ctx1))); test(!compObj.ice_context(ctx1).Equals(compObj.ice_context(null))); test(!compObj.ice_context(null).Equals(compObj.ice_context(ctx2))); test(!compObj.ice_context(ctx1).Equals(compObj.ice_context(ctx2))); test(compObj.ice_preferSecure(true).Equals(compObj.ice_preferSecure(true))); test(!compObj.ice_preferSecure(true).Equals(compObj.ice_preferSecure(false))); Ice.ObjectPrx compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000"); Ice.ObjectPrx compObj2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001"); test(!compObj1.Equals(compObj2)); compObj1 = communicator.stringToProxy("foo@MyAdapter1"); compObj2 = communicator.stringToProxy("foo@MyAdapter2"); test(!compObj1.Equals(compObj2)); test(compObj1.ice_locatorCacheTimeout(20).Equals(compObj1.ice_locatorCacheTimeout(20))); test(!compObj1.ice_locatorCacheTimeout(10).Equals(compObj1.ice_locatorCacheTimeout(20))); test(compObj1.ice_invocationTimeout(20).Equals(compObj1.ice_invocationTimeout(20))); test(!compObj1.ice_invocationTimeout(10).Equals(compObj1.ice_invocationTimeout(20))); compObj1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 1000"); compObj2 = communicator.stringToProxy("foo@MyAdapter1"); test(!compObj1.Equals(compObj2)); Ice.Endpoint[] endpts1 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints(); Ice.Endpoint[] endpts2 = communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10001").ice_getEndpoints(); test(!endpts1[0].Equals(endpts2[0])); test(endpts1[0].Equals(communicator.stringToProxy("foo:tcp -h 127.0.0.1 -p 10000").ice_getEndpoints()[0])); // // TODO: Ideally we should also test comparison of fixed proxies. // WriteLine("ok"); Write("testing checked cast... "); Flush(); Test.MyClassPrx cl = Test.MyClassPrxHelper.checkedCast(baseProxy); test(cl != null); Test.MyDerivedClassPrx derived = Test.MyDerivedClassPrxHelper.checkedCast(cl); test(derived != null); test(cl.Equals(baseProxy)); test(derived.Equals(baseProxy)); test(cl.Equals(derived)); WriteLine("ok"); Write("testing checked cast with context... "); Flush(); Dictionary <string, string> c = cl.getContext(); test(c == null || c.Count == 0); c = new Dictionary <string, string>(); c["one"] = "hello"; c["two"] = "world"; cl = Test.MyClassPrxHelper.checkedCast(baseProxy, c); Dictionary <string, string> c2 = cl.getContext(); test(Ice.CollectionComparer.Equals(c, c2)); WriteLine("ok"); Write("testing encoding versioning... "); Flush(); string ref20 = "test -e 2.0:default -p 12010"; Test.MyClassPrx cl20 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); try { cl20.ice_ping(); test(false); } catch (Ice.UnsupportedEncodingException) { // Server 2.0 endpoint doesn't support 1.1 version. } string ref10 = "test -e 1.0:default -p 12010"; Test.MyClassPrx cl10 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref10)); cl10.ice_ping(); cl10.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); cl.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the // call will use the 1.1 encoding string ref13 = "test -e 1.3:default -p 12010"; Test.MyClassPrx cl13 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); cl13.end_ice_ping(cl13.begin_ice_ping()); try { // Send request with bogus 1.2 encoding. Ice.EncodingVersion version = new Ice.EncodingVersion(1, 2); Ice.OutputStream os = new Ice.OutputStream(communicator); os.startEncapsulation(); os.endEncapsulation(); byte[] inEncaps = os.finished(); inEncaps[4] = version.major; inEncaps[5] = version.minor; byte[] outEncaps; cl.ice_invoke("ice_ping", Ice.OperationMode.Normal, inEncaps, out outEncaps); test(false); } catch (Ice.UnknownLocalException ex) { // The server thrown an UnsupportedEncodingException test(ex.unknown.IndexOf("UnsupportedEncodingException") > 0); } try { // Send request with bogus 2.0 encoding. Ice.EncodingVersion version = new Ice.EncodingVersion(2, 0); Ice.OutputStream os = new Ice.OutputStream(communicator); os.startEncapsulation(); os.endEncapsulation(); byte[] inEncaps = os.finished(); inEncaps[4] = version.major; inEncaps[5] = version.minor; byte[] outEncaps; cl.ice_invoke("ice_ping", Ice.OperationMode.Normal, inEncaps, out outEncaps); test(false); } catch (Ice.UnknownLocalException ex) { // The server thrown an UnsupportedEncodingException test(ex.unknown.IndexOf("UnsupportedEncodingException") > 0); } WriteLine("ok"); Write("testing protocol versioning... "); Flush(); ref20 = "test -p 2.0:default -p 12010"; cl20 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref20)); try { cl20.ice_ping(); test(false); } catch (Ice.UnsupportedProtocolException) { // Server 2.0 proxy doesn't support 1.0 version. } ref10 = "test -p 1.0:default -p 12010"; cl10 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref10)); cl10.ice_ping(); // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the // call will use the 1.1 protocol ref13 = "test -p 1.3:default -p 12010"; cl13 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); cl13.end_ice_ping(cl13.begin_ice_ping()); WriteLine("ok"); Write("testing opaque endpoints... "); Flush(); try { // Invalid -x option communicator.stringToProxy("id:opaque -t 99 -v abc -x abc"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -t and -v communicator.stringToProxy("id:opaque"); test(false); } catch (Ice.EndpointParseException) { } try { // Repeated -t communicator.stringToProxy("id:opaque -t 1 -t 1 -v abc"); test(false); } catch (Ice.EndpointParseException) { } try { // Repeated -v communicator.stringToProxy("id:opaque -t 1 -v abc -v abc"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -t communicator.stringToProxy("id:opaque -v abc"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing -v communicator.stringToProxy("id:opaque -t 1"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing arg for -t communicator.stringToProxy("id:opaque -t -v abc"); test(false); } catch (Ice.EndpointParseException) { } try { // Missing arg for -v communicator.stringToProxy("id:opaque -t 1 -v"); test(false); } catch (Ice.EndpointParseException) { } try { // Not a number for -t communicator.stringToProxy("id:opaque -t x -v abc"); test(false); } catch (Ice.EndpointParseException) { } try { // < 0 for -t communicator.stringToProxy("id:opaque -t -1 -v abc"); test(false); } catch (Ice.EndpointParseException) { } try { // Invalid char for -v communicator.stringToProxy("id:opaque -t 99 -v x?c"); test(false); } catch (Ice.EndpointParseException) { } // Legal TCP endpoint expressed as opaque endpoint Ice.ObjectPrx p1 = communicator.stringToProxy("test -e 1.1:opaque -t 1 -e 1.0 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); string pstr = communicator.proxyToString(p1); test(pstr.Equals("test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")); // Opaque endpoint encoded with 1.1 encoding. Ice.ObjectPrx p2 = communicator.stringToProxy("test -e 1.1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA=="); test(communicator.proxyToString(p2).Equals("test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")); if (communicator.getProperties().getPropertyAsInt("Ice.IPv6") == 0) { // Working? bool ssl = communicator.getProperties().getProperty("Ice.Default.Protocol").Equals("ssl"); bool tcp = communicator.getProperties().getProperty("Ice.Default.Protocol").Equals("tcp"); if (tcp) { p1.ice_encodingVersion(Ice.Util.Encoding_1_0).ice_ping(); } // Two legal TCP endpoints expressed as opaque endpoints p1 = communicator.stringToProxy("test -e 1.0:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMusuAAAQJwAAAA=="); pstr = communicator.proxyToString(p1); test(pstr.Equals("test -t -e 1.0:tcp -h 127.0.0.1 -p 12010 -t 10000:tcp -h 127.0.0.2 -p 12011 -t 10000")); // Test that an SSL endpoint and a nonsense endpoint get written back out as an opaque endpoint. p1 = communicator.stringToProxy("test -e 1.0:opaque -e 1.0 -t 2 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -e 1.0 -t 99 -v abch"); pstr = communicator.proxyToString(p1); if (ssl) { test(pstr.Equals("test -t -e 1.0:ssl -h 127.0.0.1 -p 10001 -t infinite:opaque -t 99 -e 1.0 -v abch")); } else if (tcp) { test(pstr.Equals( "test -t -e 1.0:opaque -t 2 -e 1.0 -v CTEyNy4wLjAuMREnAAD/////AA==:opaque -t 99 -e 1.0 -v abch")); } } WriteLine("ok"); return(cl); }
getAdmin() { Ice.ObjectAdapter adapter = null; string serverId = null; Ice.LocatorPrx defaultLocator = null; lock (this) { if (_state == StateDestroyed) { throw new Ice.CommunicatorDestroyedException(); } string adminOA = "Ice.Admin"; if (_adminAdapter != null) { return(_adminAdapter.createProxy(_adminIdentity)); } else if (_initData.properties.getProperty(adminOA + ".Endpoints").Length == 0) { return(null); } else { serverId = _initData.properties.getProperty("Ice.Admin.ServerId"); string instanceName = _initData.properties.getProperty("Ice.Admin.InstanceName"); defaultLocator = _referenceFactory.getDefaultLocator(); if ((defaultLocator != null && serverId.Length > 0) || instanceName.Length > 0) { if (_adminIdentity == null) { if (instanceName.Length == 0) { instanceName = System.Guid.NewGuid().ToString(); } _adminIdentity = new Ice.Identity("admin", instanceName); // // Afterwards, _adminIdentity is read-only // } // // Create OA // _adminAdapter = _objectAdapterFactory.createObjectAdapter(adminOA, null); // // Add all facets to OA // Dictionary <string, Ice.Object> filteredFacets = new Dictionary <string, Ice.Object>(); foreach (KeyValuePair <string, Ice.Object> entry in _adminFacets) { if (_adminFacetFilter.Count == 0 || _adminFacetFilter.Contains(entry.Key)) { _adminAdapter.addFacet(entry.Value, _adminIdentity, entry.Key); } else { filteredFacets.Add(entry.Key, entry.Value); } } _adminFacets = filteredFacets; adapter = _adminAdapter; } } } if (adapter == null) { return(null); } else { try { adapter.activate(); } catch (Ice.LocalException) { // // We cleanup _adminAdapter, however this error is not recoverable // (can't call again getAdmin() after fixing the problem) // since all the facets (servants) in the adapter are lost // adapter.destroy(); lock (this) { _adminAdapter = null; } throw; } Ice.ObjectPrx admin = adapter.createProxy(_adminIdentity); if (defaultLocator != null && serverId.Length > 0) { Ice.ProcessPrx process = Ice.ProcessPrxHelper.uncheckedCast(admin.ice_facet("Process")); try { // // Note that as soon as the process proxy is registered, the communicator might be // shutdown by a remote client and admin facets might start receiving calls. // defaultLocator.getRegistry().setServerProcessProxy(serverId, process); } catch (Ice.ServerNotFoundException) { if (_traceLevels.location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't register server `" + serverId + "' with the locator registry:\n"); s.Append("the server is not known to the locator registry"); _initData.logger.trace(_traceLevels.locationCat, s.ToString()); } throw new Ice.InitializationException("Locator knows nothing about server '" + serverId + "'"); } catch (Ice.LocalException ex) { if (_traceLevels.location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("couldn't register server `" + serverId + "' with the locator registry:\n" + ex); _initData.logger.trace(_traceLevels.locationCat, s.ToString()); } throw; // TODO: Shall we raise a special exception instead of a non obvious local exception? } if (_traceLevels.location >= 1) { System.Text.StringBuilder s = new System.Text.StringBuilder(); s.Append("registered server `" + serverId + "' with the locator registry"); _initData.logger.trace(_traceLevels.locationCat, s.ToString()); } } return(admin); } }
private Reference create(Ice.Identity ident, string facet, Reference.Mode mode, bool secure, Ice.ProtocolVersion protocol, Ice.EncodingVersion encoding, EndpointI[] endpoints, string adapterId, string propertyPrefix) { DefaultsAndOverrides defaultsAndOverrides = instance_.defaultsAndOverrides(); // // Default local proxy options. // LocatorInfo locatorInfo = null; if (_defaultLocator != null) { if (!((Ice.ObjectPrxHelperBase)_defaultLocator).reference__().getEncoding().Equals(encoding)) { locatorInfo = instance_.locatorManager().get( (Ice.LocatorPrx)_defaultLocator.ice_encodingVersion(encoding)); } else { locatorInfo = instance_.locatorManager().get(_defaultLocator); } } RouterInfo routerInfo = instance_.routerManager().get(_defaultRouter); bool collocOptimized = defaultsAndOverrides.defaultCollocationOptimization; bool cacheConnection = true; bool preferSecure = defaultsAndOverrides.defaultPreferSecure; Ice.EndpointSelectionType endpointSelection = defaultsAndOverrides.defaultEndpointSelection; int locatorCacheTimeout = defaultsAndOverrides.defaultLocatorCacheTimeout; int invocationTimeout = defaultsAndOverrides.defaultInvocationTimeout; Dictionary <string, string> context = null; // // Override the defaults with the proxy properties if a property prefix is defined. // if (propertyPrefix != null && propertyPrefix.Length > 0) { Ice.Properties properties = instance_.initializationData().properties; // // Warn about unknown properties. // if (properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) { checkForUnknownProperties(propertyPrefix); } string property; property = propertyPrefix + ".Locator"; Ice.LocatorPrx locator = Ice.LocatorPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)); if (locator != null) { if (!((Ice.ObjectPrxHelperBase)locator).reference__().getEncoding().Equals(encoding)) { locatorInfo = instance_.locatorManager().get( (Ice.LocatorPrx)locator.ice_encodingVersion(encoding)); } else { locatorInfo = instance_.locatorManager().get(locator); } } property = propertyPrefix + ".Router"; Ice.RouterPrx router = Ice.RouterPrxHelper.uncheckedCast(_communicator.propertyToProxy(property)); if (router != null) { if (propertyPrefix.EndsWith(".Router", StringComparison.Ordinal)) { string s = "`" + property + "=" + properties.getProperty(property) + "': cannot set a router on a router; setting ignored"; instance_.initializationData().logger.warning(s); } else { routerInfo = instance_.routerManager().get(router); } } property = propertyPrefix + ".CollocationOptimized"; collocOptimized = properties.getPropertyAsIntWithDefault(property, collocOptimized ? 1 : 0) > 0; property = propertyPrefix + ".ConnectionCached"; cacheConnection = properties.getPropertyAsIntWithDefault(property, cacheConnection ? 1 : 0) > 0; property = propertyPrefix + ".PreferSecure"; preferSecure = properties.getPropertyAsIntWithDefault(property, preferSecure ? 1 : 0) > 0; property = propertyPrefix + ".EndpointSelection"; if (properties.getProperty(property).Length > 0) { string type = properties.getProperty(property); if (type.Equals("Random")) { endpointSelection = Ice.EndpointSelectionType.Random; } else if (type.Equals("Ordered")) { endpointSelection = Ice.EndpointSelectionType.Ordered; } else { throw new Ice.EndpointSelectionTypeParseException("illegal value `" + type + "'; expected `Random' or `Ordered'"); } } property = propertyPrefix + ".LocatorCacheTimeout"; string val = properties.getProperty(property); if (val.Length > 0) { locatorCacheTimeout = properties.getPropertyAsIntWithDefault(property, locatorCacheTimeout); if (locatorCacheTimeout < -1) { locatorCacheTimeout = -1; StringBuilder msg = new StringBuilder("invalid value for "); msg.Append(property); msg.Append(" `"); msg.Append(properties.getProperty(property)); msg.Append("': defaulting to -1"); instance_.initializationData().logger.warning(msg.ToString()); } } property = propertyPrefix + ".InvocationTimeout"; val = properties.getProperty(property); if (val.Length > 0) { invocationTimeout = properties.getPropertyAsIntWithDefault(property, invocationTimeout); if (invocationTimeout < 1 && invocationTimeout != -1) { invocationTimeout = -1; StringBuilder msg = new StringBuilder("invalid value for "); msg.Append(property); msg.Append(" `"); msg.Append(properties.getProperty(property)); msg.Append("': defaulting to -1"); instance_.initializationData().logger.warning(msg.ToString()); } } property = propertyPrefix + ".Context."; Dictionary <string, string> contexts = properties.getPropertiesForPrefix(property); if (contexts.Count != 0) { context = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> e in contexts) { context.Add(e.Key.Substring(property.Length), e.Value); } } } // // Create new reference // return(new RoutableReference(instance_, _communicator, ident, facet, mode, secure, protocol, encoding, endpoints, adapterId, locatorInfo, routerInfo, collocOptimized, cacheConnection, preferSecure, endpointSelection, locatorCacheTimeout, invocationTimeout, context)); }