You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/30 16:31:42 UTC
[1/3] incubator-ignite git commit: # ignite-gg-1064 allow start if
can not initialize multicast
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-sprint-7 28525acbe -> e91bc484e
# ignite-gg-1064 allow start if can not initialize multicast
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b5bc06ee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b5bc06ee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b5bc06ee
Branch: refs/heads/ignite-sprint-7
Commit: b5bc06ee813471643c460aaa74ef4395ad79bd53
Parents: bade9f1
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 30 12:40:53 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 30 12:40:53 2015 +0300
----------------------------------------------------------------------
.../TcpDiscoveryMulticastIpFinder.java | 74 ++++++++++++++++----
1 file changed, 60 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b5bc06ee/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
index 8e5a1fd..014d937 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/multicast/TcpDiscoveryMulticastIpFinder.java
@@ -26,7 +26,6 @@ import org.apache.ignite.marshaller.*;
import org.apache.ignite.marshaller.jdk.*;
import org.apache.ignite.resources.*;
import org.apache.ignite.spi.*;
-import org.apache.ignite.spi.discovery.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.jetbrains.annotations.*;
@@ -278,7 +277,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
addrSnds = new ArrayList<>(locAddrs.size());
- Collection<InetAddress> reqItfs = new ArrayList<>(locAddrs.size()); // Interfaces used to send requests.
+ Set<InetAddress> reqItfs = new HashSet<>(locAddrs.size()); // Interfaces used to send requests.
for (String locAddr : locAddrs) {
InetAddress addr;
@@ -309,6 +308,8 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
}
}
+ boolean mcastErr = false;
+
if (!clientMode) {
if (addrSnds.isEmpty()) {
try {
@@ -317,13 +318,31 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
addrSnds.add(new AddressSender(mcastAddr, null, addrs));
}
catch (IOException e) {
- throw new IgniteSpiException("Failed to create multicast socket [mcastAddr=" + mcastAddr +
- ", mcastGrp=" + mcastGrp + ", mcastPort=" + mcastPort + ']', e);
+ if (log.isDebugEnabled())
+ log.debug("Failed to create multicast socket [mcastAddr=" + mcastAddr +
+ ", mcastGrp=" + mcastGrp + ", mcastPort=" + mcastPort + ", err=" + e + ']');
+ }
+
+ if (addrSnds.isEmpty()) {
+ try {
+ addrSnds.add(new AddressSender(mcastAddr, mcastAddr, addrs));
+
+ reqItfs.add(mcastAddr);
+ }
+ catch (IOException e) {
+ log.debug("Failed to create multicast socket [mcastAddr=" + mcastAddr +
+ ", mcastGrp=" + mcastGrp + ", mcastPort=" + mcastPort + ", locAddr=" + mcastAddr +
+ ", err=" + e + ']');
+ }
}
}
- for (AddressSender addrSnd : addrSnds)
- addrSnd.start();
+ if (!addrSnds.isEmpty()) {
+ for (AddressSender addrSnd : addrSnds)
+ addrSnd.start();
+ }
+ else
+ mcastErr = true;
}
else
assert addrSnds.isEmpty() : addrSnds;
@@ -358,10 +377,30 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
}
}
}
- else
- ret = requestAddresses(mcastAddr, F.first(reqItfs));
+ else {
+ T2<Collection<InetSocketAddress>, Boolean> res = requestAddresses(mcastAddr, F.first(reqItfs));
+
+ ret = res.get1();
+
+ mcastErr |= res.get2();
+ }
+
+ if (ret.isEmpty()) {
+ if (mcastErr) {
+ if (getRegisteredAddresses().isEmpty()) {
+ InetSocketAddress addr = new InetSocketAddress("localhost", TcpDiscoverySpi.DFLT_PORT);
+
+ U.quietAndWarn(log, "TcpDiscoveryMulticastIpFinder failed to initialize multicast, " +
+ "will use default address: " + addr);
- if (!ret.isEmpty())
+ registerAddresses(Collections.singleton(addr));
+ }
+ else
+ U.quietAndWarn(log, "TcpDiscoveryMulticastIpFinder failed to initialize multicast, " +
+ "will use pre-configured addresses.");
+ }
+ }
+ else
registerAddresses(ret);
}
@@ -379,11 +418,16 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
*
* @param mcastAddr Multicast address where to send request.
* @param sockItf Optional interface multicast socket should be bound to.
- * @return Collection of received addresses.
+ * @return Tuple where first value is collection of received addresses, second is boolean which is
+ * {@code true} if got error on send.
*/
- private Collection<InetSocketAddress> requestAddresses(InetAddress mcastAddr, @Nullable InetAddress sockItf) {
+ private T2<Collection<InetSocketAddress>, Boolean> requestAddresses(InetAddress mcastAddr,
+ @Nullable InetAddress sockItf)
+ {
Collection<InetSocketAddress> rmtAddrs = new HashSet<>();
+ boolean sndErr = false;
+
try {
DatagramPacket reqPckt = new DatagramPacket(MSG_ADDR_REQ_DATA, MSG_ADDR_REQ_DATA.length,
mcastAddr, mcastPort);
@@ -414,6 +458,8 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
sock.send(reqPckt);
}
catch (IOException e) {
+ sndErr = true;
+
if (!handleNetworkError(e))
break;
@@ -486,14 +532,14 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
if (rmtAddrs.isEmpty() && sndError)
U.quietAndWarn(log, "Failed to send multicast message (is multicast enabled on this node?).");
- return rmtAddrs;
+ return new T2<>(rmtAddrs, sndErr);
}
catch (IgniteInterruptedCheckedException ignored) {
U.warn(log, "Got interrupted while sending address request.");
Thread.currentThread().interrupt();
- return rmtAddrs;
+ return new T2<>(rmtAddrs, sndErr);
}
}
@@ -610,7 +656,7 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
/** {@inheritDoc} */
@Override protected void body() throws InterruptedException {
- addrs = requestAddresses(mcastAddr, sockAddr);
+ addrs = requestAddresses(mcastAddr, sockAddr).get1();
}
/**
[3/3] incubator-ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-1064' into ignite-sprint-7
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-1064' into ignite-sprint-7
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e91bc484
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e91bc484
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e91bc484
Branch: refs/heads/ignite-sprint-7
Commit: e91bc484e224ce8a039ef5bba71aa7f093dce262
Parents: 28525ac 0ef74a1
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 30 17:31:22 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 30 17:31:22 2015 +0300
----------------------------------------------------------------------
.../processors/clock/GridClockServer.java | 21 ++++--
.../TcpDiscoveryMulticastIpFinder.java | 74 ++++++++++++++++----
2 files changed, 76 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
[2/3] incubator-ignite git commit: # ignite-gg-1064 use loopback
address in clock server if failed to get local host
Posted by sb...@apache.org.
# ignite-gg-1064 use loopback address in clock server if failed to get local host
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0ef74a14
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0ef74a14
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0ef74a14
Branch: refs/heads/ignite-sprint-7
Commit: 0ef74a1449d503ae65a200e48da735b545e923da
Parents: b5bc06e
Author: sboikov <sb...@gridgain.com>
Authored: Tue Jun 30 15:07:18 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Tue Jun 30 15:07:18 2015 +0300
----------------------------------------------------------------------
.../processors/clock/GridClockServer.java | 21 +++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0ef74a14/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockServer.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockServer.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockServer.java
index e47d1fa..a835da8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockServer.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/clock/GridClockServer.java
@@ -62,9 +62,20 @@ public class GridClockServer {
int startPort = ctx.config().getTimeServerPortBase();
int endPort = startPort + ctx.config().getTimeServerPortRange() - 1;
- InetAddress locHost = !F.isEmpty(ctx.config().getLocalHost()) ?
- InetAddress.getByName(ctx.config().getLocalHost()) :
- U.getLocalHost();
+ InetAddress locHost;
+
+ if (F.isEmpty(ctx.config().getLocalHost())) {
+ try {
+ locHost = U.getLocalHost();
+ }
+ catch (IOException e) {
+ locHost = InetAddress.getLoopbackAddress();
+
+ U.warn(log, "Failed to get local host address, will use loopback address: " + locHost);
+ }
+ }
+ else
+ locHost = InetAddress.getByName(ctx.config().getLocalHost());
for (int p = startPort; p <= endPort; p++) {
try {
@@ -83,8 +94,8 @@ public class GridClockServer {
}
if (sock == null)
- throw new IgniteCheckedException("Failed to bind time server socket within specified port range [locHost=" +
- locHost + ", startPort=" + startPort + ", endPort=" + endPort + ']');
+ throw new IgniteCheckedException("Failed to bind time server socket within specified port range " +
+ "[locHost=" + locHost + ", startPort=" + startPort + ", endPort=" + endPort + ']');
}
catch (IOException e) {
throw new IgniteCheckedException("Failed to start time server (failed to get local host address)", e);