diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-10-27 19:11:20 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-10-27 19:11:20 +0100 |
commit | 8c701618a42fc6c08456e53154bac1a1d40f9534 (patch) | |
tree | c6683dbbd27d9d85aa9d9b139ca0e2bd175ef54d | |
parent | ICE-5781: UDP test failure with IPv6 on OS X (diff) | |
download | ice-8c701618a42fc6c08456e53154bac1a1d40f9534.tar.bz2 ice-8c701618a42fc6c08456e53154bac1a1d40f9534.tar.xz ice-8c701618a42fc6c08456e53154bac1a1d40f9534.zip |
Fixed IceDiscovery and IceGridDiscovery to check for Ice.PreferIPv6Address to configure UDP
-rw-r--r-- | cpp/src/IceDiscovery/PluginI.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceGrid/Client.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceGridLib/DiscoveryPluginI.cpp | 3 | ||||
-rwxr-xr-x | cpp/test/IceDiscovery/simple/run.py | 4 | ||||
-rw-r--r-- | cpp/test/IceGrid/simple/AllTests.cpp | 6 | ||||
-rw-r--r-- | cs/src/IceDiscovery/PluginI.cs | 3 | ||||
-rw-r--r-- | cs/src/IceGrid/DiscoveryPluginI.cs | 3 | ||||
-rw-r--r-- | cs/test/IceGrid/simple/AllTests.cs | 5 | ||||
-rw-r--r-- | java/src/IceDiscovery/src/main/java/IceDiscovery/PluginI.java | 3 | ||||
-rw-r--r-- | java/src/IceGrid/src/main/java/IceGrid/DiscoveryPluginI.java | 3 | ||||
-rw-r--r-- | java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java | 135 | ||||
-rwxr-xr-x | java/test/src/main/java/test/IceDiscovery/simple/run.py | 2 | ||||
-rw-r--r-- | java/test/src/main/java/test/IceGrid/simple/AllTests.java | 5 | ||||
-rw-r--r-- | scripts/IceGridAdmin.py | 3 |
15 files changed, 117 insertions, 67 deletions
diff --git a/cpp/src/IceDiscovery/PluginI.cpp b/cpp/src/IceDiscovery/PluginI.cpp index 88c2bb91ba5..60bdf42e9a4 100644 --- a/cpp/src/IceDiscovery/PluginI.cpp +++ b/cpp/src/IceDiscovery/PluginI.cpp @@ -41,8 +41,9 @@ PluginI::initialize() Ice::PropertiesPtr properties = _communicator->getProperties(); bool ipv4 = properties->getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; + bool preferIPv6 = properties->getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; - if(ipv4) + if(ipv4 && !preferIPv6) { address = properties->getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1"); } diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp index 6e9b51388e2..20e8fe7cdc4 100644 --- a/cpp/src/IceGrid/Client.cpp +++ b/cpp/src/IceGrid/Client.cpp @@ -551,7 +551,8 @@ Client::run(StringSeq& originalArgs) { bool ipv4 = properties->getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; string address; - if(ipv4) + bool preferIPv6 = properties->getPropertyAsInt("Ice.PreferIPv6Address") > 0; + if(ipv4 && !preferIPv6) { address = properties->getPropertyWithDefault("IceGridAdmin.Discovery.Address", "239.255.0.1"); } diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index 843b8b15cfa..e49f0cf49bf 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -577,8 +577,9 @@ RegistryI::startImpl() if(properties->getPropertyAsIntWithDefault("IceGrid.Registry.Discovery.Enabled", 1) > 0) { bool ipv4 = properties->getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; + bool preferIPv6 = properties->getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; - if(ipv4) + if(ipv4 && !preferIPv6) { address = properties->getPropertyWithDefault("IceGrid.Registry.Discovery.Address", "239.255.0.1"); } diff --git a/cpp/src/IceGridLib/DiscoveryPluginI.cpp b/cpp/src/IceGridLib/DiscoveryPluginI.cpp index b6c587d6c09..c9803cdf3e5 100644 --- a/cpp/src/IceGridLib/DiscoveryPluginI.cpp +++ b/cpp/src/IceGridLib/DiscoveryPluginI.cpp @@ -179,8 +179,9 @@ DiscoveryPluginI::initialize() Ice::PropertiesPtr properties = _communicator->getProperties(); bool ipv4 = properties->getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; + bool preferIPv6 = properties->getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; - if(ipv4) + if(ipv4 && !preferIPv6) { address = properties->getPropertyWithDefault("IceGridDiscovery.Address", "239.255.0.1"); } diff --git a/cpp/test/IceDiscovery/simple/run.py b/cpp/test/IceDiscovery/simple/run.py index bfd22278207..d26af2db53d 100755 --- a/cpp/test/IceDiscovery/simple/run.py +++ b/cpp/test/IceDiscovery/simple/run.py @@ -30,7 +30,9 @@ args += " --IceDiscovery.Timeout=100" args += " --IceDiscovery.RetryCount=1" if not TestUtil.ipv6: args += " --IceDiscovery.Interface=127.0.0.1" - +elif TestUtil.isDarwin(): + args += " --IceDiscovery.Interface=\"::1\"" + serverProc = [] for i in range(0, num): sys.stdout.write("starting server #%d... " % (i + 1)) diff --git a/cpp/test/IceGrid/simple/AllTests.cpp b/cpp/test/IceGrid/simple/AllTests.cpp index 184e18adac7..4f650f40fae 100644 --- a/cpp/test/IceGrid/simple/AllTests.cpp +++ b/cpp/test/IceGrid/simple/AllTests.cpp @@ -67,6 +67,12 @@ allTests(const Ice::CommunicatorPtr& communicator) initData.properties = communicator->getProperties()->clone(); initData.properties->setProperty("Ice.Default.Locator", ""); initData.properties->setProperty("Ice.Plugin.IceGridDiscovery", "IceGrid:createIceGridDiscovery"); +#ifdef __APPLE__ + if(initData.properties->getPropertyAsInt("Ice.PreferIPv6Address") > 0) + { + initData.properties->setProperty("IceGridDiscovery.Interface", "::1"); + } +#endif initData.properties->setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter"); initData.properties->setProperty("AdapterForDiscoveryTest.Endpoints", "default"); diff --git a/cs/src/IceDiscovery/PluginI.cs b/cs/src/IceDiscovery/PluginI.cs index 0cdb4a5f185..31efcad36cc 100644 --- a/cs/src/IceDiscovery/PluginI.cs +++ b/cs/src/IceDiscovery/PluginI.cs @@ -35,8 +35,9 @@ namespace IceDiscovery Ice.Properties properties = _communicator.getProperties(); bool ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; + bool preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; - if(ipv4) + if(ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1"); } diff --git a/cs/src/IceGrid/DiscoveryPluginI.cs b/cs/src/IceGrid/DiscoveryPluginI.cs index 583ba9ff872..d6ac2445604 100644 --- a/cs/src/IceGrid/DiscoveryPluginI.cs +++ b/cs/src/IceGrid/DiscoveryPluginI.cs @@ -308,8 +308,9 @@ namespace IceGrid Ice.Properties properties = _communicator.getProperties(); bool ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; + bool preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; string address; - if(ipv4) + if(ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceGridDiscovery.Address", "239.255.0.1"); } diff --git a/cs/test/IceGrid/simple/AllTests.cs b/cs/test/IceGrid/simple/AllTests.cs index 30de9de2a61..428cca22e22 100644 --- a/cs/test/IceGrid/simple/AllTests.cs +++ b/cs/test/IceGrid/simple/AllTests.cs @@ -83,6 +83,11 @@ public class AllTests initData.properties = communicator.getProperties().ice_clone_(); initData.properties.setProperty("Ice.Default.Locator", ""); initData.properties.setProperty("Ice.Plugin.IceGridDiscovery", "IceGrid:IceGrid.DiscoveryPluginFactoryI"); + if(IceInternal.AssemblyUtil.osx_ && + initData.properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0) + { + initData.properties.setProperty("IceGridDiscovery.Interface", "::1"); + } initData.properties.setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter"); initData.properties.setProperty("AdapterForDiscoveryTest.Endpoints", "default"); diff --git a/java/src/IceDiscovery/src/main/java/IceDiscovery/PluginI.java b/java/src/IceDiscovery/src/main/java/IceDiscovery/PluginI.java index 6be47ee2750..6fea4934d1e 100644 --- a/java/src/IceDiscovery/src/main/java/IceDiscovery/PluginI.java +++ b/java/src/IceDiscovery/src/main/java/IceDiscovery/PluginI.java @@ -24,8 +24,9 @@ public class PluginI implements Ice.Plugin Ice.Properties properties = _communicator.getProperties(); boolean ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; + boolean preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; String address; - if(ipv4) + if(ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceDiscovery.Address", "239.255.0.1"); } diff --git a/java/src/IceGrid/src/main/java/IceGrid/DiscoveryPluginI.java b/java/src/IceGrid/src/main/java/IceGrid/DiscoveryPluginI.java index 30c9c02301c..877910c6dac 100644 --- a/java/src/IceGrid/src/main/java/IceGrid/DiscoveryPluginI.java +++ b/java/src/IceGrid/src/main/java/IceGrid/DiscoveryPluginI.java @@ -329,8 +329,9 @@ class DiscoveryPluginI implements Ice.Plugin Ice.Properties properties = _communicator.getProperties(); boolean ipv4 = properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0; + boolean preferIPv6 = properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0; String address; - if(ipv4) + if(ipv4 && !preferIPv6) { address = properties.getPropertyWithDefault("IceGridDiscovery.Address", "239.255.0.1"); } diff --git a/java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java b/java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java index 52f9536fac5..4e739ac3290 100644 --- a/java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java +++ b/java/src/IceGridGUI/src/main/java/IceGridGUI/SessionKeeper.java @@ -1224,45 +1224,53 @@ public class SessionKeeper final Ice.Properties properties = communicator.getProperties(); final String intf = properties.getProperty("IceGridAdmin.Discovery.Interface"); String lookupEndpoints = properties.getProperty("IceGridAdmin.Discovery.Lookup"); - + String address; + if(properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0 && + properties.getPropertyAsInt("Ice.PreferIPv6Address") <= 0) + { + address = "239.255.0.1"; + } + else + { + address = "ff15::1"; + } if(lookupEndpoints.isEmpty()) { StringBuilder s = new StringBuilder(); s.append("udp -h \""); - s.append(properties.getPropertyWithDefault("IceGridAdmin.Discovery.Address", - (properties.getPropertyAsIntWithDefault("Ice.IPv4", 1) > 0) ? "239.255.0.1" : "ff15::1")); + s.append(properties.getPropertyWithDefault("IceGridAdmin.Discovery.Address", address)); s.append("\" -p "); s.append(4061); if(!intf.isEmpty()) { - s.append(" --interface \"").append(intf); + s.append(" --interface \"").append(intf).append("\""); } lookupEndpoints = s.toString(); } - final LookupPrx lookupPrx = LookupPrxHelper.uncheckedCast( - communicator.stringToProxy("IceGrid/Lookup -d:" + lookupEndpoints).ice_collocationOptimized(false) - .ice_router(null)); - - new Thread(new Runnable() + try { - @Override - public void run() + final LookupPrx lookupPrx = LookupPrxHelper.uncheckedCast( + communicator.stringToProxy("IceGrid/Lookup -d:" + lookupEndpoints).ice_collocationOptimized(false) + .ice_router(null)); + + new Thread(new Runnable() { - synchronized(SessionKeeper.this) + @Override + public void run() { - // - // If search is in progress when refresh is hit, cancel the - // finish task we will schedule a new one with this new - // search. - // - if(_discoveryFinishTask != null) - { - _discoveryFinishTask.cancel(); - } - - if(_discoveryAdapter == null) + synchronized(SessionKeeper.this) { + // + // If search is in progress when refresh is hit, cancel the + // finish task we will schedule a new one with this new + // search. + // + if(_discoveryFinishTask != null) + { + _discoveryFinishTask.cancel(); + } + if(properties.getProperty("IceGridAdmin.Discovery.Reply.Endpoints").isEmpty()) { StringBuilder s = new StringBuilder(); @@ -1273,41 +1281,44 @@ public class SessionKeeper } properties.setProperty("IceGridAdmin.Discovery.Reply.Endpoints", s.toString()); } - - _discoveryAdapter = communicator.createObjectAdapter("IceGridAdmin.Discovery.Reply"); - _discoveryAdapter.activate(); - _discoveryReplyPrx = - LookupReplyPrxHelper.uncheckedCast( - _discoveryAdapter.addWithUUID(_discoveryLookupReply).ice_datagram()); - } - - try - { - lookupPrx.findLocator("", _discoveryReplyPrx); - } - catch(final Ice.LocalException ex) - { - ex.printStackTrace(); - destroyDisconveryAdapter(); - SwingUtilities.invokeLater(new Runnable() + + try { - @Override - public void run() + if(_discoveryAdapter == null) { - JOptionPane.showMessageDialog(ConnectionWizardDialog.this, - ex.toString(), - "Error while loopup locator endpoints", - JOptionPane.ERROR_MESSAGE); + _discoveryAdapter = communicator.createObjectAdapter( + "IceGridAdmin.Discovery.Reply"); + _discoveryAdapter.activate(); + _discoveryReplyPrx = + LookupReplyPrxHelper.uncheckedCast( + _discoveryAdapter.addWithUUID(_discoveryLookupReply).ice_datagram()); } - }); - } - - // - // We schedule a timer task to destroy the discovery adapter after 2 - // seconds, the user doesn't need to wait, discovered proxies are - // added as they are found. - // - _discoveryFinishTask = new java.util.TimerTask() + + lookupPrx.findLocator("", _discoveryReplyPrx); + } + catch(final Ice.LocalException ex) + { + ex.printStackTrace(); + destroyDisconveryAdapter(); + SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + JOptionPane.showMessageDialog(ConnectionWizardDialog.this, + ex.toString(), + "Error while looking up locator endpoints", + JOptionPane.ERROR_MESSAGE); + } + }); + } + + // + // We schedule a timer task to destroy the discovery adapter after 2 + // seconds, the user doesn't need to wait, discovered proxies are + // added as they are found. + // + _discoveryFinishTask = new java.util.TimerTask() { @Override public void run() @@ -1315,10 +1326,18 @@ public class SessionKeeper destroyDisconveryAdapter(); } }; - new java.util.Timer().schedule(_discoveryFinishTask, 2000); + new java.util.Timer().schedule(_discoveryFinishTask, 2000); + } } - } - }).start(); + }).start(); + } + catch(Ice.LocalException ex) + { + JOptionPane.showMessageDialog(ConnectionWizardDialog.this, + ex.toString(), + "Error while looking up locator endpoints", + JOptionPane.ERROR_MESSAGE); + } } private void initialize(String title, final JDialog parent) diff --git a/java/test/src/main/java/test/IceDiscovery/simple/run.py b/java/test/src/main/java/test/IceDiscovery/simple/run.py index 2f14ff0442f..f761e694812 100755 --- a/java/test/src/main/java/test/IceDiscovery/simple/run.py +++ b/java/test/src/main/java/test/IceDiscovery/simple/run.py @@ -31,6 +31,8 @@ args += " --IceDiscovery.Timeout=30" args += " --IceDiscovery.RetryCount=1" if not TestUtil.ipv6: args += " --IceDiscovery.Interface=127.0.0.1" +elif TestUtil.isDarwin(): + args += " --IceDiscovery.Interface=\"::1\"" serverProc = [] for i in range(0, num): diff --git a/java/test/src/main/java/test/IceGrid/simple/AllTests.java b/java/test/src/main/java/test/IceGrid/simple/AllTests.java index b6aba8b8594..d18a5da35fa 100644 --- a/java/test/src/main/java/test/IceGrid/simple/AllTests.java +++ b/java/test/src/main/java/test/IceGrid/simple/AllTests.java @@ -87,6 +87,11 @@ public class AllTests initData.properties = communicator.getProperties()._clone(); initData.properties.setProperty("Ice.Default.Locator", ""); initData.properties.setProperty("Ice.Plugin.IceGridDiscovery", "IceGrid:IceGrid.DiscoveryPluginFactoryI"); + if(System.getProperty("os.name").contains("OS X") && + initData.properties.getPropertyAsInt("Ice.PreferIPv6Address") > 0) + { + initData.properties.setProperty("IceGridDiscovery.Interface", "::1"); + } initData.properties.setProperty("AdapterForDiscoveryTest.AdapterId", "discoveryAdapter"); initData.properties.setProperty("AdapterForDiscoveryTest.Endpoints", "default"); diff --git a/scripts/IceGridAdmin.py b/scripts/IceGridAdmin.py index a7b645de47f..e5b998a43bb 100644 --- a/scripts/IceGridAdmin.py +++ b/scripts/IceGridAdmin.py @@ -60,6 +60,9 @@ registryOptions = r' --Ice.Warn.Connections=0' + \ r' --IceGrid.Registry.DefaultTemplates="' + \ os.path.abspath(os.path.join(TestUtil.toplevel, "cpp", "config", "templates.xml") + '"') +if TestUtil.ipv6: + registryOptions += r' --IceGrid.Registry.Discovery.Interface="::1"' + def getDefaultLocatorProperty(): i = 0 |