public static void allTests(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); String rf = "test @ TestAdapter"; Ice.ObjectPrx @base = communicator.stringToProxy(rf); test(@base != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing IceGrid.Locator is present... "); IceGrid.LocatorPrx locator = IceGrid.LocatorPrxHelper.uncheckedCast(@base); test(locator != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); test(obj != null); test(obj.Equals(@base)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing locator finder... "); Ice.Identity finderId = new Ice.Identity(); finderId.category = "Ice"; finderId.name = "LocatorFinder"; Ice.LocatorFinderPrx finder = Ice.LocatorFinderPrxHelper.checkedCast( communicator.getDefaultLocator().ice_identity(finderId)); test(finder.getLocator() != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing discovery... "); { // Add test well-known object IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast( communicator.stringToProxy(communicator.getDefaultLocator().ice_getIdentity().category + "/Registry")); test(registry != null); try { IceGrid.AdminSessionPrx session = registry.createAdminSession("foo", "bar"); session.getAdmin().addObjectWithType(@base, "::Test"); session.destroy(); } catch (Ice.UserException) { test(false); } // // Ensure the IceGrid discovery locator can discover the // registries and make sure locator requests are forwarded. // Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.Default.Locator", ""); initData.properties.setProperty("Ice.Plugin.IceLocatorDiscovery", "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"); initData.properties.setProperty("IceLocatorDiscovery.Port", app.getTestPort(99).ToString()); initData.properties.setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter"); initData.properties.setProperty("AdapterForDiscoveryTest.Endpoints", "default"); Ice.Communicator com = Ice.Util.initialize(initData); test(com.getDefaultLocator() != null); com.stringToProxy("test @ TestAdapter").ice_ping(); com.stringToProxy("test").ice_ping(); test(com.getDefaultLocator().getRegistry() != null); test(IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalRegistry() != null); test(IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalQuery() != null); Ice.ObjectAdapter adapter = com.createObjectAdapter("AdapterForDiscoveryTest"); adapter.activate(); adapter.deactivate(); com.destroy(); // // Now, ensure that the IceGrid discovery locator correctly // handles failure to find a locator. // initData.properties.setProperty("IceLocatorDiscovery.InstanceName", "unknown"); initData.properties.setProperty("IceLocatorDiscovery.RetryCount", "1"); initData.properties.setProperty("IceLocatorDiscovery.Timeout", "100"); com = Ice.Util.initialize(initData); test(com.getDefaultLocator() != null); try { com.stringToProxy("test @ TestAdapter").ice_ping(); } catch (Ice.NoEndpointException) { } try { com.stringToProxy("test").ice_ping(); } catch (Ice.NoEndpointException) { } test(com.getDefaultLocator().getRegistry() == null); test(IceGrid.LocatorPrxHelper.checkedCast(com.getDefaultLocator()) == null); try { IceGrid.LocatorPrxHelper.uncheckedCast(com.getDefaultLocator()).getLocalRegistry(); } catch (Ice.OperationNotExistException) { } adapter = com.createObjectAdapter("AdapterForDiscoveryTest"); adapter.activate(); adapter.deactivate(); com.destroy(); } Console.Out.WriteLine("ok"); Console.Out.Write("shutting down server... "); Console.Out.Flush(); obj.shutdown(); Console.Out.WriteLine("ok"); }
allTestsWithDeploy(TestCommon.Application app) { Ice.Communicator communicator = app.communicator(); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter"); test(@base != null); Ice.ObjectPrx @base2 = communicator.stringToProxy("test"); test(@base2 != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); test(obj != null); test(obj.Equals(@base)); TestIntfPrx obj2 = TestIntfPrxHelper.checkedCast(@base2); test(obj2 != null); test(obj2.Equals(@base2)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.ice_ping(); obj2.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing encoding versioning... "); Console.Out.Flush(); Ice.ObjectPrx base10 = communicator.stringToProxy("test10 @ TestAdapter10"); test(base10 != null); Ice.ObjectPrx base102 = communicator.stringToProxy("test10"); test(base102 != null); try { base10.ice_ping(); test(false); } catch (Ice.NoEndpointException) { } try { base102.ice_ping(); test(false); } catch (Ice.NoEndpointException) { } base10 = base10.ice_encodingVersion(Ice.Util.Encoding_1_0); base102 = base102.ice_encodingVersion(Ice.Util.Encoding_1_0); base10.ice_ping(); base102.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown identity... "); Console.Out.Flush(); try { communicator.stringToProxy("unknown/unknown").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object")); test(ex.id.Equals("unknown/unknown")); } Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown adapter... "); Console.Out.Flush(); try { communicator.stringToProxy("test @ TestAdapterUnknown").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object adapter")); test(ex.id.Equals("TestAdapterUnknown")); } Console.Out.WriteLine("ok"); IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast( communicator.stringToProxy(communicator.getDefaultLocator().ice_getIdentity().category + "/Registry")); test(registry != null); IceGrid.AdminSessionPrx session = null; try { session = registry.createAdminSession("foo", "bar"); } catch (IceGrid.PermissionDeniedException) { test(false); } session.ice_getConnection().setACM(registry.getACMTimeout(), Ice.Util.None, Ice.ACMHeartbeat.HeartbeatAlways); IceGrid.AdminPrx admin = session.getAdmin(); test(admin != null); try { admin.enableServer("server", false); admin.stopServer("server"); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.ServerStopException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } Console.Out.Write("testing whether server is still reachable... "); Console.Out.Flush(); try { obj = TestIntfPrxHelper.checkedCast(@base); test(false); } catch (Ice.NoEndpointException) { } try { obj2 = TestIntfPrxHelper.checkedCast(@base2); test(false); } catch (Ice.NoEndpointException) { } try { admin.enableServer("server", true); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } try { obj = TestIntfPrxHelper.checkedCast(@base); } catch (Ice.NoEndpointException) { test(false); } try { obj2 = TestIntfPrxHelper.checkedCast(@base2); } catch (Ice.NoEndpointException) { test(false); } Console.Out.WriteLine("ok"); try { admin.stopServer("server"); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.ServerStopException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } session.destroy(); }
allTestsWithDeploy(Ice.Communicator communicator) { Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); Ice.ObjectPrx @base = communicator.stringToProxy("test @ TestAdapter"); test(@base != null); Ice.ObjectPrx @base2 = communicator.stringToProxy("test"); test(@base2 != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); TestIntfPrx obj = TestIntfPrxHelper.checkedCast(@base); test(obj != null); test(obj.Equals(@base)); TestIntfPrx obj2 = TestIntfPrxHelper.checkedCast(@base2); test(obj2 != null); test(obj2.Equals(@base2)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.ice_ping(); obj2.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing encoding versioning... "); Console.Out.Flush(); Ice.ObjectPrx base10 = communicator.stringToProxy("test10 @ TestAdapter10"); test(base10 != null); Ice.ObjectPrx base102 = communicator.stringToProxy("test10"); test(base102 != null); try { base10.ice_ping(); test(false); } catch (Ice.NoEndpointException) { } try { base102.ice_ping(); test(false); } catch (Ice.NoEndpointException) { } base10 = base10.ice_encodingVersion(Ice.Util.Encoding_1_0); base102 = base102.ice_encodingVersion(Ice.Util.Encoding_1_0); base10.ice_ping(); base102.ice_ping(); Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown identity... "); Console.Out.Flush(); try { communicator.stringToProxy("unknown/unknown").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object")); test(ex.id.Equals("unknown/unknown")); } Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown adapter... "); Console.Out.Flush(); try { communicator.stringToProxy("test @ TestAdapterUnknown").ice_ping(); test(false); } catch (Ice.NotRegisteredException ex) { test(ex.kindOfObject.Equals("object adapter")); test(ex.id.Equals("TestAdapterUnknown")); } Console.Out.WriteLine("ok"); IceGrid.RegistryPrx registry = IceGrid.RegistryPrxHelper.checkedCast( communicator.stringToProxy("IceGrid/Registry")); test(registry != null); IceGrid.AdminSessionPrx session = null; try { session = registry.createAdminSession("foo", "bar"); } catch (IceGrid.PermissionDeniedException) { test(false); } SessionKeepAliveThread keepAlive = new SessionKeepAliveThread(session, registry.getSessionTimeout() / 2); Thread keepAliveThread = new Thread(new ThreadStart(keepAlive.run)); keepAliveThread.Start(); IceGrid.AdminPrx admin = session.getAdmin(); test(admin != null); try { admin.enableServer("server", false); admin.stopServer("server"); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.ServerStopException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } Console.Out.Write("testing whether server is still reachable... "); Console.Out.Flush(); try { obj = TestIntfPrxHelper.checkedCast(@base); test(false); } catch (Ice.NoEndpointException) { } try { obj2 = TestIntfPrxHelper.checkedCast(@base2); test(false); } catch (Ice.NoEndpointException) { } try { admin.enableServer("server", true); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } try { obj = TestIntfPrxHelper.checkedCast(@base); } catch (Ice.NoEndpointException) { test(false); } try { obj2 = TestIntfPrxHelper.checkedCast(@base2); } catch (Ice.NoEndpointException) { test(false); } Console.Out.WriteLine("ok"); try { admin.stopServer("server"); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.ServerStopException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } keepAlive.terminate(); keepAliveThread.Join(); session.destroy(); }
public IceManager(string adapterName, string host, int port, bool catchSignals = true) { IceGridHost = host; IceGridPort = port; Name = adapterName; logger = log4net.LogManager.GetLogger(this.GetType().Name + "::" + Name); _ServantIds = new List <Ice.Identity>(); //keep track of servants for emergency cleanup string myIP = findLocalIPAddress(); logger.Info("My IPAddress is: " + myIP); //initialize Ice Ice.Properties prop = Ice.Util.createProperties(); prop.setProperty("hms.AdapterId", adapterName); prop.setProperty("hms.Endpoints", "tcp -h " + myIP + ":udp -h " + myIP); prop.setProperty("Ice.Default.Locator", "IceGrid/Locator:tcp -p " + IceGridPort + " -h " + IceGridHost); prop.setProperty("Ice.ThreadPool.Server.Size", "5"); prop.setProperty("Ice.ThreadPool.Server.SizeMax", "100000"); prop.setProperty("Ice.ThreadPool.Client.Size", "5"); prop.setProperty("Ice.ThreadPool.Client.SizeMax", "100000"); Ice.InitializationData iceidata = new Ice.InitializationData(); iceidata.properties = prop; Communicator = Ice.Util.initialize(iceidata); // could add sys.argv try { _Adapter = Communicator.createObjectAdapter("hms"); _Adapter.activate(); } catch (Exception ex) { logger.Fatal("Network error, check configuration: " + ex.Message); logger.Fatal("Endpoint(should be local machine): " + prop.getProperty("hms.Endpoints")); logger.Fatal("Locator (should be IceGrid Server): " + prop.getProperty("Ice.Default.Locator")); throw (ex); // we are dead anyway } //Now are we ready to communicate with others //getting usefull proxies try { // proxy to icegrid to register our vc devices Query = IceGrid.QueryPrxHelper.checkedCast(Communicator.stringToProxy("IceGrid/Query")); if (Query == null) { logger.Error("invalid ICeGrid proxy"); } // proxy to icestorm to publish events EventMgr = IceStorm.TopicManagerPrxHelper.checkedCast(Communicator.stringToProxy("EventServer/TopicManager")); if (EventMgr == null) { logger.Error("invalid IceStorm proxy"); } //these 2 objects are only needed to get the IceGrid admin object in order to register _Registry = IceGrid.RegistryPrxHelper.uncheckedCast(Communicator.stringToProxy("IceGrid/Registry")); updateIceGridAdmin(); } catch (Ice.NotRegisteredException e) { logger.Fatal("If we fail here it is probably because the Icebox objects are not registered: " + e.Message); } catch (Exception e) { logger.Fatal("IceGrid Server not found!!!!!: " + e.Message); throw (e);//without yellow page system, there is no need to start } if (catchSignals) { setupSignals(); } }
allTestsWithDeploy(Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); IObjectPrx @base = IObjectPrx.Parse("test @ TestAdapter", communicator); test(@base != null); IObjectPrx @base2 = IObjectPrx.Parse("test", communicator); test(@base2 != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); TestIntfPrx obj = TestIntfPrx.CheckedCast(@base); test(obj.Equals(@base)); TestIntfPrx obj2 = TestIntfPrx.CheckedCast(@base2); test(obj2.Equals(@base2)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.IcePing(); obj2.IcePing(); Console.Out.WriteLine("ok"); Console.Out.Write("testing encoding versioning... "); Console.Out.Flush(); IObjectPrx base10 = IObjectPrx.Parse("test10 @ TestAdapter10", communicator); IObjectPrx base102 = IObjectPrx.Parse("test10", communicator); try { base10.IcePing(); test(false); } catch (Ice.NoEndpointException) { } try { base102.IcePing(); test(false); } catch (Ice.NoEndpointException) { } base10 = base10.Clone(encodingVersion: Util.Encoding_1_0); base102 = base102.Clone(encodingVersion: Util.Encoding_1_0); base10.IcePing(); base102.IcePing(); Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown identity... "); Console.Out.Flush(); try { IObjectPrx.Parse("unknown/unknown", communicator).IcePing(); test(false); } catch (NotRegisteredException ex) { test(ex.kindOfObject.Equals("object")); test(ex.id.Equals("unknown/unknown")); } Console.Out.WriteLine("ok"); Console.Out.Write("testing reference with unknown adapter... "); Console.Out.Flush(); try { IObjectPrx.Parse("test @ TestAdapterUnknown", communicator).IcePing(); test(false); } catch (NotRegisteredException ex) { test(ex.kindOfObject.Equals("object adapter")); test(ex.id.Equals("TestAdapterUnknown")); } Console.Out.WriteLine("ok"); IceGrid.RegistryPrx registry = IceGrid.RegistryPrx.Parse( communicator.getDefaultLocator().Identity.category + "/Registry", communicator); IceGrid.AdminSessionPrx session = registry.createAdminSession("foo", "bar"); session.GetConnection().setACM(registry.getACMTimeout(), null, ACMHeartbeat.HeartbeatAlways); IceGrid.AdminPrx admin = session.getAdmin(); admin.enableServer("server", false); admin.stopServer("server"); Console.Out.Write("testing whether server is still reachable... "); Console.Out.Flush(); try { obj = TestIntfPrx.CheckedCast(@base); test(false); } catch (Ice.NoEndpointException) { } try { obj2 = TestIntfPrx.CheckedCast(@base2); test(false); } catch (Ice.NoEndpointException) { } try { admin.enableServer("server", true); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } try { obj = TestIntfPrx.CheckedCast(@base); } catch (Ice.NoEndpointException) { test(false); } try { obj2 = TestIntfPrx.CheckedCast(@base2); } catch (Ice.NoEndpointException) { test(false); } Console.Out.WriteLine("ok"); try { admin.stopServer("server"); } catch (IceGrid.ServerNotExistException) { test(false); } catch (IceGrid.ServerStopException) { test(false); } catch (IceGrid.NodeUnreachableException) { test(false); } session.destroy(); }
public static void allTests(Test.TestHelper helper) { Ice.Communicator communicator = helper.communicator(); Console.Out.Write("testing stringToProxy... "); Console.Out.Flush(); string rf = "test @ TestAdapter"; var @base = IObjectPrx.Parse(rf, communicator); Console.Out.WriteLine("ok"); Console.Out.Write("testing IceGrid.Locator is present... "); IceGrid.LocatorPrx locator = IceGrid.LocatorPrx.UncheckedCast(@base); Console.Out.WriteLine("ok"); Console.Out.Write("testing checked cast... "); Console.Out.Flush(); TestIntfPrx obj = TestIntfPrx.CheckedCast(@base); test(obj.Equals(@base)); Console.Out.WriteLine("ok"); Console.Out.Write("pinging server... "); Console.Out.Flush(); obj.IcePing(); Console.Out.WriteLine("ok"); Console.Out.Write("testing locator finder... "); Ice.Identity finderId = new Ice.Identity(); finderId.category = "Ice"; finderId.name = "LocatorFinder"; Ice.LocatorFinderPrx finder = Ice.LocatorFinderPrx.CheckedCast(communicator.getDefaultLocator().Clone(finderId)); test(finder.getLocator() != null); Console.Out.WriteLine("ok"); Console.Out.Write("testing discovery... "); { // Add test well-known object IceGrid.RegistryPrx registry = IceGrid.RegistryPrx.Parse( communicator.getDefaultLocator().Identity.category + "/Registry", communicator); IceGrid.AdminSessionPrx session = registry.createAdminSession("foo", "bar"); session.getAdmin().addObjectWithType(@base, "::Test"); session.destroy(); // // Ensure the IceGrid discovery locator can discover the // registries and make sure locator requests are forwarded. // Ice.InitializationData initData = new Ice.InitializationData(); initData.properties = communicator.Properties.Clone(); initData.properties.setProperty("Ice.Default.Locator", ""); initData.properties.setProperty("Ice.Plugin.IceLocatorDiscovery", "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"); initData.properties.setProperty("IceLocatorDiscovery.Port", helper.getTestPort(99).ToString()); initData.properties.setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter"); initData.properties.setProperty("AdapterForDiscoveryTest.Endpoints", "default"); Ice.Communicator com = Ice.Util.initialize(initData); test(com.getDefaultLocator() != null); IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); IObjectPrx.Parse("test", com).IcePing(); test(com.getDefaultLocator().getRegistry() != null); test(IceGrid.LocatorPrx.UncheckedCast(com.getDefaultLocator()).getLocalRegistry() != null); test(IceGrid.LocatorPrx.UncheckedCast(com.getDefaultLocator()).getLocalQuery() != null); Ice.ObjectAdapter adapter = com.createObjectAdapter("AdapterForDiscoveryTest"); adapter.Activate(); adapter.Deactivate(); com.destroy(); // // Now, ensure that the IceGrid discovery locator correctly // handles failure to find a locator. // initData.properties.setProperty("IceLocatorDiscovery.InstanceName", "unknown"); initData.properties.setProperty("IceLocatorDiscovery.RetryCount", "1"); initData.properties.setProperty("IceLocatorDiscovery.Timeout", "100"); com = Ice.Util.initialize(initData); test(com.getDefaultLocator() != null); try { IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); } catch (Ice.NoEndpointException) { } try { IObjectPrx.Parse("test", com).IcePing(); } catch (Ice.NoEndpointException) { } test(com.getDefaultLocator().getRegistry() == null); test(IceGrid.LocatorPrx.CheckedCast(com.getDefaultLocator()) == null); try { IceGrid.LocatorPrx.UncheckedCast(com.getDefaultLocator()).getLocalRegistry(); } catch (Ice.OperationNotExistException) { } adapter = com.createObjectAdapter("AdapterForDiscoveryTest"); adapter.Activate(); adapter.Deactivate(); com.destroy(); string multicast; if (communicator.Properties.getProperty("Ice.IPv6").Equals("1")) { multicast = "\"ff15::1\""; } else { multicast = "239.255.0.1"; } // // Test invalid lookup endpoints // initData.properties = communicator.Properties.Clone(); initData.properties.setProperty("Ice.Default.Locator", ""); initData.properties.setProperty("Ice.Plugin.IceLocatorDiscovery", "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"); initData.properties.setProperty("IceLocatorDiscovery.Lookup", $"udp -h {multicast} --interface unknown"); com = Ice.Util.initialize(initData); test(com.getDefaultLocator() != null); try { IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); test(false); } catch (NoEndpointException) { } com.destroy(); initData.properties = communicator.Properties.Clone(); initData.properties.setProperty("Ice.Default.Locator", ""); initData.properties.setProperty("IceLocatorDiscovery.RetryCount", "0"); initData.properties.setProperty("Ice.Plugin.IceLocatorDiscovery", "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"); initData.properties.setProperty("IceLocatorDiscovery.Lookup", "udp -h " + multicast + " --interface unknown"); com = Util.initialize(initData); test(com.getDefaultLocator() != null); try { IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); test(false); } catch (NoEndpointException) { } com.destroy(); initData.properties = communicator.Properties.Clone(); initData.properties.setProperty("Ice.Default.Locator", ""); initData.properties.setProperty("IceLocatorDiscovery.RetryCount", "1"); initData.properties.setProperty("Ice.Plugin.IceLocatorDiscovery", "IceLocatorDiscovery:IceLocatorDiscovery.PluginFactory"); { string intf = initData.properties.getProperty("IceLocatorDiscovery.Interface"); if (!intf.Equals("")) { intf = " --interface \"" + intf + "\""; } string port = helper.getTestPort(99).ToString(); initData.properties.setProperty("IceLocatorDiscovery.Lookup", "udp -h " + multicast + " --interface unknown:" + "udp -h " + multicast + " -p " + port + intf); } com = Ice.Util.initialize(initData); test(com.getDefaultLocator() != null); try { IObjectPrx.Parse("test @ TestAdapter", com).IcePing(); } catch (NoEndpointException) { test(false); } com.destroy(); } Console.Out.WriteLine("ok"); Console.Out.Write("shutting down server... "); Console.Out.Flush(); obj.shutdown(); Console.Out.WriteLine("ok"); }
public IceManager(string adapterName, string host, int port, bool catchSignals = true) { IceGridHost = host; IceGridPort = port; Name = adapterName; logger = log4net.LogManager.GetLogger(this.GetType().Name + "::" + Name); _ServantIds = new List<Ice.Identity>(); //keep track of servants for emergency cleanup string myIP = findLocalIPAddress(); logger.Info("My IPAddress is: " + myIP); //initialize Ice Ice.Properties prop = Ice.Util.createProperties(); prop.setProperty("hms.AdapterId", adapterName); prop.setProperty("hms.Endpoints", "tcp -h " + myIP + ":udp -h " + myIP); prop.setProperty("Ice.Default.Locator", "IceGrid/Locator:tcp -p " + IceGridPort + " -h " + IceGridHost); prop.setProperty("Ice.ThreadPool.Server.Size", "5"); prop.setProperty("Ice.ThreadPool.Server.SizeMax", "100000"); prop.setProperty("Ice.ThreadPool.Client.Size", "5"); prop.setProperty("Ice.ThreadPool.Client.SizeMax", "100000"); Ice.InitializationData iceidata = new Ice.InitializationData(); iceidata.properties = prop; Communicator = Ice.Util.initialize(iceidata); // could add sys.argv try { _Adapter = Communicator.createObjectAdapter("hms"); _Adapter.activate(); } catch (Exception ex) { logger.Fatal("Network error, check configuration: " + ex.Message); logger.Fatal("Endpoint(should be local machine): " + prop.getProperty("hms.Endpoints")); logger.Fatal("Locator (should be IceGrid Server): " + prop.getProperty("Ice.Default.Locator")); throw (ex); // we are dead anyway } //Now are we ready to communicate with others //getting usefull proxies try { // proxy to icegrid to register our vc devices Query = IceGrid.QueryPrxHelper.checkedCast(Communicator.stringToProxy("IceGrid/Query")); if (Query == null) { logger.Error("invalid ICeGrid proxy"); } // proxy to icestorm to publish events EventMgr = IceStorm.TopicManagerPrxHelper.checkedCast(Communicator.stringToProxy("EventServer/TopicManager")); if (EventMgr == null) { logger.Error("invalid IceStorm proxy"); } //these 2 objects are only needed to get the IceGrid admin object in order to register _Registry = IceGrid.RegistryPrxHelper.uncheckedCast(Communicator.stringToProxy("IceGrid/Registry")); updateIceGridAdmin(); } catch (Ice.NotRegisteredException e) { logger.Fatal("If we fail here it is probably because the Icebox objects are not registered: " + e.Message); } catch (Exception e) { logger.Fatal("IceGrid Server not found!!!!!: " + e.Message); throw (e);//without yellow page system, there is no need to start } if (catchSignals) { setupSignals(); } }