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/04 13:46:09 UTC
[1/8] incubator-ignite git commit: ignite-989 Fix multicast for
client discovery
Repository: incubator-ignite
Updated Branches:
refs/heads/nodejs 290297753 -> 42e2138ea
ignite-989 Fix multicast for client discovery
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/9ad3617d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/9ad3617d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/9ad3617d
Branch: refs/heads/nodejs
Commit: 9ad3617d39f02eb98ef01f332e2aac20f97870c2
Parents: 97d0bc1
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jun 3 12:06:51 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jun 3 12:11:26 2015 +0300
----------------------------------------------------------------------
.../ignite/spi/discovery/tcp/ClientImpl.java | 3 +
.../ignite/spi/discovery/tcp/ServerImpl.java | 31 -----
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 56 +++++++-
.../tcp/ipfinder/TcpDiscoveryIpFinder.java | 10 +-
.../TcpDiscoveryMulticastIpFinder.java | 47 +++++--
.../tcp/TcpClientDiscoverySpiMulticastTest.java | 129 +++++++++++++++++++
.../IgniteSpiDiscoverySelfTestSuite.java | 1 +
.../gce/TcpDiscoveryGoogleStorageIpFinder.java | 43 ++++---
8 files changed, 244 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ad3617d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index e672d64..6a5b644 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -166,6 +166,9 @@ class ClientImpl extends TcpDiscoveryImpl {
msgWorker = new MessageWorker();
msgWorker.start();
+ if (spi.ipFinder.isShared())
+ registerLocalNodeAddress();
+
try {
joinLatch.await();
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ad3617d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 57c13d6..698835f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -272,37 +272,6 @@ class ServerImpl extends TcpDiscoveryImpl {
spi.printStartInfo();
}
- /**
- * @throws IgniteSpiException If failed.
- */
- @SuppressWarnings("BusyWait")
- private void registerLocalNodeAddress() throws IgniteSpiException {
- // Make sure address registration succeeded.
- while (true) {
- try {
- spi.ipFinder.initializeLocalAddresses(locNode.socketAddresses());
-
- // Success.
- break;
- }
- catch (IllegalStateException e) {
- throw new IgniteSpiException("Failed to register local node address with IP finder: " +
- locNode.socketAddresses(), e);
- }
- catch (IgniteSpiException e) {
- LT.error(log, e, "Failed to register local node address in IP finder on start " +
- "(retrying every 2000 ms).");
- }
-
- try {
- U.sleep(2000);
- }
- catch (IgniteInterruptedCheckedException e) {
- throw new IgniteSpiException("Thread has been interrupted.", e);
- }
- }
- }
-
/** {@inheritDoc} */
@Override public void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException {
spiCtx.registerPort(tcpSrvr.port, TCP);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ad3617d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
index f285279..b7e9e53 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
@@ -19,6 +19,8 @@ package org.apache.ignite.spi.discovery.tcp;
import org.apache.ignite.*;
import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.spi.*;
import org.apache.ignite.spi.discovery.*;
import org.apache.ignite.spi.discovery.tcp.internal.*;
@@ -58,7 +60,7 @@ abstract class TcpDiscoveryImpl {
}
/**
- *
+ * @return Local node ID.
*/
public UUID getLocalNodeId() {
return spi.getLocalNodeId();
@@ -78,42 +80,47 @@ abstract class TcpDiscoveryImpl {
public abstract void dumpDebugInfo(IgniteLogger log);
/**
- *
+ * @return SPI state string.
*/
public abstract String getSpiState();
/**
- *
+ * @return Message worker queue current size.
*/
public abstract int getMessageWorkerQueueSize();
/**
- *
+ * @return Coordinator ID.
*/
public abstract UUID getCoordinator();
/**
- *
+ * @return Collection of remote nodes.
*/
public abstract Collection<ClusterNode> getRemoteNodes();
/**
* @param nodeId Node id.
+ * @return Node with given ID or {@code null} if node is not found.
*/
@Nullable public abstract ClusterNode getNode(UUID nodeId);
/**
* @param nodeId Node id.
+ * @return {@code true} if node alive, {@code false} otherwise.
*/
public abstract boolean pingNode(UUID nodeId);
/**
+ * Tells discovery SPI to disconnect from topology.
*
+ * @throws IgniteSpiException If failed.
*/
public abstract void disconnect() throws IgniteSpiException;
/**
* @param msg Message.
+ * @throws IgniteException If failed.
*/
public abstract void sendCustomEvent(DiscoverySpiCustomMessage msg) throws IgniteException;
@@ -124,16 +131,18 @@ abstract class TcpDiscoveryImpl {
/**
* @param gridName Grid name.
+ * @throws IgniteSpiException If failed.
*/
public abstract void spiStart(@Nullable String gridName) throws IgniteSpiException;
/**
- *
+ * @throws IgniteSpiException If failed.
*/
public abstract void spiStop() throws IgniteSpiException;
/**
* @param spiCtx Spi context.
+ * @throws IgniteSpiException If failed.
*/
public abstract void onContextInitialized0(IgniteSpiContext spiCtx) throws IgniteSpiException;
@@ -164,7 +173,40 @@ abstract class TcpDiscoveryImpl {
public abstract void brakeConnection();
/**
- * FOR TEST PURPOSE ONLY!
+ * <strong>FOR TEST ONLY!!!</strong>
+ *
+ * @return Worker thread.
*/
protected abstract IgniteSpiThread workerThread();
+
+ /**
+ * @throws IgniteSpiException If failed.
+ */
+ @SuppressWarnings("BusyWait")
+ protected final void registerLocalNodeAddress() throws IgniteSpiException {
+ // Make sure address registration succeeded.
+ while (true) {
+ try {
+ spi.ipFinder.initializeLocalAddresses(locNode.socketAddresses());
+
+ // Success.
+ break;
+ }
+ catch (IllegalStateException e) {
+ throw new IgniteSpiException("Failed to register local node address with IP finder: " +
+ locNode.socketAddresses(), e);
+ }
+ catch (IgniteSpiException e) {
+ LT.error(log, e, "Failed to register local node address in IP finder on start " +
+ "(retrying every 2000 ms).");
+ }
+
+ try {
+ U.sleep(2000);
+ }
+ catch (IgniteInterruptedCheckedException e) {
+ throw new IgniteSpiException("Thread has been interrupted.", e);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ad3617d/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java
index 51ad7b4..95758e5 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinder.java
@@ -31,7 +31,7 @@ public interface TcpDiscoveryIpFinder {
* method is completed, SPI context can be stored for future access.
*
* @param spiCtx Spi context.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of error.
+ * @throws IgniteSpiException In case of error.
*/
public void onSpiContextInitialized(IgniteSpiContext spiCtx) throws IgniteSpiException;
@@ -46,7 +46,7 @@ public interface TcpDiscoveryIpFinder {
* Initializes addresses discovery SPI binds to.
*
* @param addrs Addresses discovery SPI binds to.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of error.
+ * @throws IgniteSpiException In case of error.
*/
public void initializeLocalAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException;
@@ -54,7 +54,7 @@ public interface TcpDiscoveryIpFinder {
* Gets all addresses registered in this finder.
*
* @return All known addresses, potentially empty, but never {@code null}.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of error.
+ * @throws IgniteSpiException In case of error.
*/
public Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException;
@@ -76,7 +76,7 @@ public interface TcpDiscoveryIpFinder {
* is already registered.
*
* @param addrs Addresses to register. Not {@code null} and not empty.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of error.
+ * @throws IgniteSpiException In case of error.
*/
public void registerAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException;
@@ -87,7 +87,7 @@ public interface TcpDiscoveryIpFinder {
* registered quietly (just no-op).
*
* @param addrs Addresses to unregister. Not {@code null} and not empty.
- * @throws org.apache.ignite.spi.IgniteSpiException In case of error.
+ * @throws IgniteSpiException In case of error.
*/
public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ad3617d/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 45d0816..a992620 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,6 +26,8 @@ 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.*;
@@ -254,6 +256,20 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
"(it is recommended in production to specify at least one address in " +
"TcpDiscoveryMulticastIpFinder.getAddresses() configuration property)");
+ boolean clientMode;
+
+ if (ignite != null) { // Can be null if used in tests without starting Ignite.
+ DiscoverySpi discoSpi = ignite.configuration().getDiscoverySpi();
+
+ if (!(discoSpi instanceof TcpDiscoverySpi))
+ throw new IgniteSpiException("TcpDiscoveryMulticastIpFinder should be used with " +
+ "TcpDiscoverySpi: " + discoSpi);
+
+ clientMode = ((TcpDiscoverySpi)discoSpi).isClientMode();
+ }
+ else
+ clientMode = false;
+
InetAddress mcastAddr;
try {
@@ -296,7 +312,8 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
if (!addr.isLoopbackAddress()) {
try {
- addrSnds.add(new AddressSender(mcastAddr, addr, addrs));
+ if (!clientMode)
+ addrSnds.add(new AddressSender(mcastAddr, addr, addrs));
reqItfs.add(addr);
}
@@ -309,20 +326,24 @@ public class TcpDiscoveryMulticastIpFinder extends TcpDiscoveryVmIpFinder {
}
}
- if (addrSnds.isEmpty()) {
- try {
- // Create non-bound socket if local host is loopback or failed to create sockets explicitly
- // bound to interfaces.
- 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 (!clientMode) {
+ if (addrSnds.isEmpty()) {
+ try {
+ // Create non-bound socket if local host is loopback or failed to create sockets explicitly
+ // bound to interfaces.
+ 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);
+ }
}
- }
- for (AddressSender addrSnd :addrSnds)
- addrSnd.start();
+ for (AddressSender addrSnd : addrSnds)
+ addrSnd.start();
+ }
+ else
+ assert addrSnds.isEmpty() : addrSnds;
Collection<InetSocketAddress> ret;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ad3617d/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiMulticastTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiMulticastTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiMulticastTest.java
new file mode 100644
index 0000000..d1b6232
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiMulticastTest.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spi.discovery.tcp;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.spi.discovery.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+public class TcpClientDiscoverySpiMulticastTest extends GridCommonAbstractTest {
+ /** */
+ private boolean forceSrv;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ cfg.setLocalHost("127.0.0.1");
+
+ TcpDiscoverySpi spi = new TcpDiscoverySpi();
+
+ spi.setIpFinder(new TcpDiscoveryMulticastIpFinder());
+
+ if (getTestGridName(1).equals(gridName)) {
+ cfg.setClientMode(true);
+
+ spi.setForceServerMode(forceSrv);
+ }
+
+ cfg.setDiscoverySpi(spi);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoinWithMulticast() throws Exception {
+ joinWithMulticast();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testJoinWithMulticastForceServer() throws Exception {
+ forceSrv = true;
+
+ joinWithMulticast();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ private void joinWithMulticast() throws Exception {
+ Ignite ignite0 = startGrid(0);
+
+ assertSpi(ignite0, false);
+
+ Ignite ignite1 = startGrid(1);
+
+ assertSpi(ignite1, !forceSrv);
+
+ assertTrue(ignite1.configuration().isClientMode());
+
+ assertEquals(2, ignite0.cluster().nodes().size());
+ assertEquals(2, ignite1.cluster().nodes().size());
+
+ Ignite ignite2 = startGrid(2);
+
+ assertSpi(ignite2, false);
+
+ assertEquals(3, ignite0.cluster().nodes().size());
+ assertEquals(3, ignite1.cluster().nodes().size());
+ assertEquals(3, ignite2.cluster().nodes().size());
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @param client Expected client mode flag.
+ */
+ private void assertSpi(Ignite ignite, boolean client) {
+ DiscoverySpi spi = ignite.configuration().getDiscoverySpi();
+
+ assertSame(TcpDiscoverySpi.class, spi.getClass());
+
+ TcpDiscoverySpi spi0 = (TcpDiscoverySpi)spi;
+
+ assertSame(TcpDiscoveryMulticastIpFinder.class, spi0.getIpFinder().getClass());
+
+ assertEquals(client, spi0.isClientMode());
+
+ Collection<Object> addrSnds = GridTestUtils.getFieldValue(spi0.getIpFinder(), "addrSnds");
+
+ assertNotNull(addrSnds);
+
+ if (client)
+ assertTrue(addrSnds.isEmpty()); // Check client does not send its address.
+ else
+ assertFalse(addrSnds.isEmpty());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ad3617d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
index dc35b24..ea5a7ac 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
@@ -53,6 +53,7 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite {
suite.addTest(new TestSuite(TcpClientDiscoverySpiSelfTest.class));
suite.addTest(new TestSuite(TcpClientDiscoveryMarshallerCheckSelfTest.class));
+ suite.addTest(new TestSuite(TcpClientDiscoverySpiMulticastTest.class));
return suite;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/9ad3617d/modules/gce/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/gce/TcpDiscoveryGoogleStorageIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/gce/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/gce/TcpDiscoveryGoogleStorageIpFinder.java b/modules/gce/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/gce/TcpDiscoveryGoogleStorageIpFinder.java
index b496f60..48991e8 100644
--- a/modules/gce/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/gce/TcpDiscoveryGoogleStorageIpFinder.java
+++ b/modules/gce/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/gce/TcpDiscoveryGoogleStorageIpFinder.java
@@ -68,34 +68,37 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
* Note that this finder is shared by default (see {@link org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder#isShared()}.
*/
public class TcpDiscoveryGoogleStorageIpFinder extends TcpDiscoveryIpFinderAdapter {
- /* Default object's content. */
+ /** Default object's content. */
private final static ByteArrayInputStream OBJECT_CONTENT = new ByteArrayInputStream(new byte[0]);
/** Grid logger. */
@LoggerResource
private IgniteLogger log;
- /* Google Cloud Platform's project name.*/
+ /** Google Cloud Platform's project name.*/
private String projectName;
- /* Google Storage bucket name. */
+ /** Google Storage bucket name. */
private String bucketName;
- /* Service account p12 private key file name. */
- private String serviceAccountP12FilePath;
+ /** Service account p12 private key file name. */
+ private String srvcAccountP12FilePath;
- /* Service account id. */
- private String serviceAccountId;
+ /** Service account id. */
+ private String srvcAccountId;
- /* Google storage. */
+ /** Google storage. */
private Storage storage;
- /* Init routine guard. */
+ /** Init routine guard. */
private final AtomicBoolean initGuard = new AtomicBoolean();
- /* Init routine latch. */
+ /** Init routine latch. */
private final CountDownLatch initLatch = new CountDownLatch(1);
+ /**
+ *
+ */
public TcpDiscoveryGoogleStorageIpFinder() {
setShared(true);
}
@@ -221,7 +224,7 @@ public class TcpDiscoveryGoogleStorageIpFinder extends TcpDiscoveryIpFinderAdapt
*/
@IgniteSpiConfiguration(optional = false)
public void setServiceAccountP12FilePath(String p12FileName) {
- this.serviceAccountP12FilePath = p12FileName;
+ this.srvcAccountP12FilePath = p12FileName;
}
/**
@@ -235,7 +238,7 @@ public class TcpDiscoveryGoogleStorageIpFinder extends TcpDiscoveryIpFinderAdapt
*/
@IgniteSpiConfiguration(optional = false)
public void setServiceAccountId(String id) {
- this.serviceAccountId = id;
+ this.srvcAccountId = id;
}
/**
@@ -245,13 +248,13 @@ public class TcpDiscoveryGoogleStorageIpFinder extends TcpDiscoveryIpFinderAdapt
*/
private void init() throws IgniteSpiException {
if (initGuard.compareAndSet(false, true)) {
- if (serviceAccountId == null ||
- serviceAccountP12FilePath == null ||
+ if (srvcAccountId == null ||
+ srvcAccountP12FilePath == null ||
projectName == null ||
bucketName == null) {
throw new IgniteSpiException(
"One or more of the required parameters is not set [serviceAccountId=" +
- serviceAccountId + ", serviceAccountP12FilePath=" + serviceAccountP12FilePath + ", projectName=" +
+ srvcAccountId + ", serviceAccountP12FilePath=" + srvcAccountP12FilePath + ", projectName=" +
projectName + ", bucketName=" + bucketName + "]");
}
@@ -265,12 +268,12 @@ public class TcpDiscoveryGoogleStorageIpFinder extends TcpDiscoveryIpFinderAdapt
throw new IgniteSpiException(e);
}
- GoogleCredential credential;
+ GoogleCredential cred;
try {
- credential = new GoogleCredential.Builder().setTransport(httpTransport)
- .setJsonFactory(JacksonFactory.getDefaultInstance()).setServiceAccountId(serviceAccountId)
- .setServiceAccountPrivateKeyFromP12File(new File(serviceAccountP12FilePath))
+ cred = new GoogleCredential.Builder().setTransport(httpTransport)
+ .setJsonFactory(JacksonFactory.getDefaultInstance()).setServiceAccountId(srvcAccountId)
+ .setServiceAccountPrivateKeyFromP12File(new File(srvcAccountP12FilePath))
.setServiceAccountScopes(Collections.singleton(StorageScopes.DEVSTORAGE_FULL_CONTROL)).build();
}
@@ -279,7 +282,7 @@ public class TcpDiscoveryGoogleStorageIpFinder extends TcpDiscoveryIpFinderAdapt
}
try {
- storage = new Storage.Builder(httpTransport, JacksonFactory.getDefaultInstance(), credential)
+ storage = new Storage.Builder(httpTransport, JacksonFactory.getDefaultInstance(), cred)
.setApplicationName(projectName).build();
}
catch (Exception e) {
[6/8] incubator-ignite git commit: # ignite-sprint-5
Posted by sb...@apache.org.
# ignite-sprint-5
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7501025d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7501025d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7501025d
Branch: refs/heads/nodejs
Commit: 7501025d815a61ef881d86fa326bc6e17064ec0e
Parents: ae5189a
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jun 4 11:01:15 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jun 4 11:01:15 2015 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/internal/IgniteKernal.java | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7501025d/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 8a7dc70..a0d97c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -963,8 +963,11 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
sysPoolQSize = exec.getQueue().size();
}
+ String id = U.id8(localNode().id());
+
String msg = NL +
"Metrics for local node (to disable set 'metricsLogFrequency' to 0)" + NL +
+ " ^-- Node [id=" + id + ", name=" + name() + "]" + NL +
" ^-- H/N/C [hosts=" + hosts + ", nodes=" + nodes + ", CPUs=" + cpus + "]" + NL +
" ^-- CPU [cur=" + dblFmt.format(cpuLoadPct) + "%, avg=" +
dblFmt.format(avgCpuLoadPct) + "%, GC=" + dblFmt.format(gcPct) + "%]" + NL +
[5/8] incubator-ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-981' into ignite-sprint-5
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-981' into ignite-sprint-5
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ae5189ab
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ae5189ab
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ae5189ab
Branch: refs/heads/nodejs
Commit: ae5189ab9513120258add9769e8cfc88e1c6aad8
Parents: 1b12bb4 1603fe5
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jun 4 09:42:36 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jun 4 09:42:36 2015 +0300
----------------------------------------------------------------------
.../dht/GridDhtPartitionTopologyImpl.java | 8 ++-
.../GridDhtPartitionsExchangeFuture.java | 10 +++-
.../cache/IgniteDynamicCacheStartSelfTest.java | 62 ++++++++++++++++++++
3 files changed, 77 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
[4/8] incubator-ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-989' into ignite-sprint-5
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-989' into ignite-sprint-5
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1b12bb4a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1b12bb4a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1b12bb4a
Branch: refs/heads/nodejs
Commit: 1b12bb4a80a04071c77d2603956505bd66fa19ea
Parents: bd3abbc 9ad3617
Author: sboikov <sb...@gridgain.com>
Authored: Thu Jun 4 09:39:12 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Jun 4 09:39:12 2015 +0300
----------------------------------------------------------------------
.../ignite/spi/discovery/tcp/ClientImpl.java | 3 +
.../ignite/spi/discovery/tcp/ServerImpl.java | 31 -----
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 56 +++++++-
.../tcp/ipfinder/TcpDiscoveryIpFinder.java | 10 +-
.../TcpDiscoveryMulticastIpFinder.java | 47 +++++--
.../tcp/TcpClientDiscoverySpiMulticastTest.java | 129 +++++++++++++++++++
.../IgniteSpiDiscoverySelfTestSuite.java | 1 +
.../gce/TcpDiscoveryGoogleStorageIpFinder.java | 43 ++++---
8 files changed, 244 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
[2/8] incubator-ignite git commit: ignite-981 Do not access cache in
exchange future before cache is ready
Posted by sb...@apache.org.
ignite-981 Do not access cache in exchange future before cache is ready
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/1603fe50
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/1603fe50
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/1603fe50
Branch: refs/heads/nodejs
Commit: 1603fe502b03d5f3e57e7837e14f0d33af002236
Parents: 97d0bc1
Author: sboikov <sb...@gridgain.com>
Authored: Wed Jun 3 13:21:32 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Jun 3 13:34:01 2015 +0300
----------------------------------------------------------------------
.../dht/GridDhtPartitionTopologyImpl.java | 8 ++-
.../GridDhtPartitionsExchangeFuture.java | 10 +++-
.../cache/IgniteDynamicCacheStartSelfTest.java | 62 ++++++++++++++++++++
3 files changed, 77 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1603fe50/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index 1ae4ae7..68652c8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -740,7 +740,11 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
try {
assert node2part != null && node2part.valid() : "Invalid node2part [node2part: " + node2part +
- ", locNodeId=" + cctx.localNode().id() + ", locName=" + cctx.gridName() + ']';
+ ", cache=" + cctx.name() +
+ ", started=" + cctx.started() +
+ ", stopping=" + stopping +
+ ", locNodeId=" + cctx.localNode().id() +
+ ", locName=" + cctx.gridName() + ']';
GridDhtPartitionFullMap m = node2part;
@@ -758,6 +762,8 @@ class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
if (log.isDebugEnabled())
log.debug("Updating full partition map [exchId=" + exchId + ", parts=" + fullMapString() + ']');
+ assert partMap != null;
+
lock.writeLock().lock();
try {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1603fe50/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index db43c6c..e0bfee6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -902,8 +902,14 @@ public class GridDhtPartitionsExchangeFuture extends GridFutureAdapter<AffinityT
id.topologyVersion());
for (GridCacheContext cacheCtx : cctx.cacheContexts()) {
- if (!cacheCtx.isLocal())
- m.addFullPartitionsMap(cacheCtx.cacheId(), cacheCtx.topology().partitionMap(true));
+ if (!cacheCtx.isLocal()) {
+ AffinityTopologyVersion startTopVer = cacheCtx.startTopologyVersion();
+
+ boolean ready = startTopVer == null || startTopVer.compareTo(id.topologyVersion()) <= 0;
+
+ if (ready)
+ m.addFullPartitionsMap(cacheCtx.cacheId(), cacheCtx.topology().partitionMap(true));
+ }
}
// It is important that client topologies be added after contexts.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/1603fe50/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
index 095221e..db9e6a8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
@@ -25,6 +25,7 @@ import org.apache.ignite.events.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.managers.discovery.*;
import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -68,6 +69,9 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
private boolean testAttribute = true;
/** */
+ private boolean client;
+
+ /** */
private boolean daemon;
/**
@@ -85,6 +89,12 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+ if (client) {
+ cfg.setClientMode(true);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setForceServerMode(true);
+ }
+
cfg.setUserAttributes(F.asMap(TEST_ATTRIBUTE_NAME, testAttribute));
CacheConfiguration cacheCfg = new CacheConfiguration();
@@ -1024,4 +1034,56 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
stopGrid(nodeCount());
}
}
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testStartStopWithClientJoin() throws Exception {
+ Ignite ignite1 = ignite(1);
+
+ final AtomicBoolean stop = new AtomicBoolean();
+
+ IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+ @Override public Object call() throws Exception {
+ client = true;
+
+ int iter = 0;
+
+ while (!stop.get()) {
+ if (iter % 10 == 0)
+ log.info("Client start/stop iteration: " + iter);
+
+ iter++;
+
+ try (Ignite ignite = startGrid(nodeCount())) {
+ assertTrue(ignite.configuration().isClientMode());
+ }
+ }
+
+ return null;
+ }
+ }, 1, "client-start-stop");
+
+ try {
+ long stopTime = U.currentTimeMillis() + 30_000;
+
+ int iter = 0;
+
+ while (System.currentTimeMillis() < stopTime) {
+ if (iter % 10 == 0)
+ log.info("Cache start/stop iteration: " + iter);
+
+ try (IgniteCache<Object, Object> cache = ignite1.getOrCreateCache("cache-" + iter)) {
+ assertNotNull(cache);
+ }
+
+ iter++;
+ }
+ }
+ finally {
+ stop.set(true);
+ }
+
+ fut.get();
+ }
}
[3/8] incubator-ignite git commit: #sprint-5 - Removed dumpStack
Posted by sb...@apache.org.
#sprint-5 - Removed dumpStack
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/bd3abbc2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bd3abbc2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bd3abbc2
Branch: refs/heads/nodejs
Commit: bd3abbc277d1dcfea7bad21ec1748ed5672ef22e
Parents: 97d0bc1
Author: Alexey Goncharuk <ag...@gridgain.com>
Authored: Wed Jun 3 18:54:31 2015 -0700
Committer: Alexey Goncharuk <ag...@gridgain.com>
Committed: Wed Jun 3 18:54:31 2015 -0700
----------------------------------------------------------------------
.../apache/ignite/internal/processors/cache/GridCacheContext.java | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd3abbc2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index b20e59d..46db7c7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1469,9 +1469,6 @@ public class GridCacheContext<K, V> implements Externalizable {
Collection<ClusterNode> dhtNodeIds = new ArrayList<>(dhtRemoteNodes);
Collection<ClusterNode> nearNodeIds = F.isEmpty(nearRemoteNodes) ? null : new ArrayList<>(nearRemoteNodes);
- if (!F.isEmpty(nearNodeIds))
- U.dumpStack("Added near mapped nodes: " + entry + ", " + nearNodeIds);
-
entry.mappings(explicitLockVer, dhtNodeIds, nearNodeIds);
}
[8/8] incubator-ignite git commit: #nodejs: add Java Test.
Posted by sb...@apache.org.
#nodejs: add Java Test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/42e2138e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/42e2138e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/42e2138e
Branch: refs/heads/nodejs
Commit: 42e2138ea0ba5aa329b620fac31d5db1afc2cdfc
Parents: b7d61b5
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 4 14:45:45 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 4 14:45:45 2015 +0300
----------------------------------------------------------------------
.../ignite/internal/util/GridJavaProcess.java | 39 ++++++++++++++++++++
1 file changed, 39 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/42e2138e/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
index 42fe089..62655e7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridJavaProcess.java
@@ -174,6 +174,45 @@ public final class GridJavaProcess {
}
/**
+ * Executes cmd in a separate system process.
+ *
+ * @param cmd Command to run.
+ * @param log Log to use.
+ * @param printC Optional closure to be called each time wrapped process prints line to system.out or system.err.
+ * @param procKilledC Optional closure to be called when process termination is detected.
+ * @return Wrapper around {@link Process}
+ * @throws Exception If any problem occurred.
+ */
+ public static GridJavaProcess exec(String cmd, @Nullable IgniteLogger log,
+ @Nullable IgniteInClosure<String> printC, @Nullable GridAbsClosure procKilledC)
+ throws Exception {
+
+ if (!(U.isLinux() || U.isMacOs() || U.isWindows()))
+ throw new Exception("Your OS is not supported.");
+
+ GridJavaProcess gjProc = new GridJavaProcess();
+
+ gjProc.log = log;
+ gjProc.procKilledC = procKilledC;
+
+ ProcessBuilder builder = new ProcessBuilder(cmd);
+
+ builder.redirectErrorStream(true);
+
+ Process proc = builder.start();
+
+ gjProc.osGrabber = gjProc.new ProcessStreamGrabber(proc.getInputStream(), printC);
+ gjProc.esGrabber = gjProc.new ProcessStreamGrabber(proc.getErrorStream(), printC);
+
+ gjProc.osGrabber.start();
+ gjProc.esGrabber.start();
+
+ gjProc.proc = proc;
+
+ return gjProc;
+ }
+
+ /**
* Kills the java process.
*
* @throws Exception If any problem occurred.
[7/8] incubator-ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-sprint-5' into nodejs
Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/origin/ignite-sprint-5' into nodejs
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b7d61b55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b7d61b55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b7d61b55
Branch: refs/heads/nodejs
Commit: b7d61b5519e6c67a5c9627390a7ab6d7964c2713
Parents: 2902977 7501025
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jun 4 11:07:41 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jun 4 11:07:41 2015 +0300
----------------------------------------------------------------------
.../apache/ignite/internal/IgniteKernal.java | 3 +
.../processors/cache/GridCacheContext.java | 3 -
.../dht/GridDhtPartitionTopologyImpl.java | 8 +-
.../GridDhtPartitionsExchangeFuture.java | 10 +-
.../ignite/spi/discovery/tcp/ClientImpl.java | 3 +
.../ignite/spi/discovery/tcp/ServerImpl.java | 31 -----
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 56 +++++++-
.../tcp/ipfinder/TcpDiscoveryIpFinder.java | 10 +-
.../TcpDiscoveryMulticastIpFinder.java | 47 +++++--
.../cache/IgniteDynamicCacheStartSelfTest.java | 62 +++++++++
.../tcp/TcpClientDiscoverySpiMulticastTest.java | 129 +++++++++++++++++++
.../IgniteSpiDiscoverySelfTestSuite.java | 1 +
.../gce/TcpDiscoveryGoogleStorageIpFinder.java | 43 ++++---
13 files changed, 324 insertions(+), 82 deletions(-)
----------------------------------------------------------------------