ignite-sprint-6: merge from 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/8a98daf7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8a98daf7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8a98daf7 Branch: refs/heads/ignite-484-1 Commit: 8a98daf789de0a7cfba229597edc09e3416ab4af Parents: 37c56f6 Author: Denis Magda <dma...@gridgain.com> Authored: Thu Jun 11 15:59:10 2015 +0300 Committer: Denis Magda <dma...@gridgain.com> Committed: Thu Jun 11 15:59:10 2015 +0300 ---------------------------------------------------------------------- idea/ignite_codeStyle.xml | 147 +++++++++++++++++++ .../ignite/spi/discovery/tcp/ServerImpl.java | 38 +---- .../tcp/TcpClientDiscoverySpiSelfTest.java | 114 +++++++++++++- parent/pom.xml | 1 + 4 files changed, 263 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a98daf7/idea/ignite_codeStyle.xml ---------------------------------------------------------------------- diff --git a/idea/ignite_codeStyle.xml b/idea/ignite_codeStyle.xml new file mode 100644 index 0000000..14faf54 --- /dev/null +++ b/idea/ignite_codeStyle.xml @@ -0,0 +1,147 @@ +<code_scheme name="ignite"> + <option name="USE_SAME_INDENTS" value="true" /> + <option name="IGNORE_SAME_INDENTS_FOR_LANGUAGES" value="true" /> + <option name="OTHER_INDENT_OPTIONS"> + <value> + <option name="INDENT_SIZE" value="4" /> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + <option name="TAB_SIZE" value="4" /> + <option name="USE_TAB_CHARACTER" value="false" /> + <option name="SMART_TABS" value="false" /> + <option name="LABEL_INDENT_SIZE" value="0" /> + <option name="LABEL_INDENT_ABSOLUTE" value="false" /> + <option name="USE_RELATIVE_INDENTS" value="false" /> + </value> + </option> + <option name="PREFER_LONGER_NAMES" value="false" /> + <option name="USE_SINGLE_CLASS_IMPORTS" value="false" /> + <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="0" /> + <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="0" /> + <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND"> + <value /> + </option> + <option name="IMPORT_LAYOUT_TABLE"> + <value> + <package name="org.apache" withSubpackages="true" static="false" /> + <package name="import org.gridgain" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="javax" withSubpackages="true" static="false" /> + <package name="java" withSubpackages="true" static="false" /> + <emptyLine /> + <package name="" withSubpackages="true" static="true" /> + </value> + </option> + <option name="JD_ALIGN_PARAM_COMMENTS" value="false" /> + <option name="JD_ALIGN_EXCEPTION_COMMENTS" value="false" /> + <option name="JD_P_AT_EMPTY_LINES" value="false" /> + <option name="JD_KEEP_INVALID_TAGS" value="false" /> + <option name="JD_DO_NOT_WRAP_ONE_LINE_COMMENTS" value="true" /> + <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" /> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" /> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="ELSE_ON_NEW_LINE" value="true" /> + <option name="WHILE_ON_NEW_LINE" value="true" /> + <option name="CATCH_ON_NEW_LINE" value="true" /> + <option name="FINALLY_ON_NEW_LINE" value="true" /> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> + <option name="ALIGN_MULTILINE_FOR" value="false" /> + <option name="SPACE_AFTER_TYPE_CAST" value="false" /> + <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" /> + <option name="METHOD_PARAMETERS_WRAP" value="1" /> + <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" /> + <option name="LABELED_STATEMENT_WRAP" value="1" /> + <option name="WRAP_COMMENTS" value="true" /> + <option name="METHOD_ANNOTATION_WRAP" value="1" /> + <option name="CLASS_ANNOTATION_WRAP" value="1" /> + <option name="FIELD_ANNOTATION_WRAP" value="1" /> + <JavaCodeStyleSettings> + <option name="CLASS_NAMES_IN_JAVADOC" value="3" /> + </JavaCodeStyleSettings> + <XML> + <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> + </XML> + <ADDITIONAL_INDENT_OPTIONS fileType="haml"> + <option name="INDENT_SIZE" value="2" /> + </ADDITIONAL_INDENT_OPTIONS> + <codeStyleSettings language="Groovy"> + <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" /> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" /> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="ELSE_ON_NEW_LINE" value="true" /> + <option name="CATCH_ON_NEW_LINE" value="true" /> + <option name="FINALLY_ON_NEW_LINE" value="true" /> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> + <option name="ALIGN_MULTILINE_FOR" value="false" /> + <option name="SPACE_AFTER_TYPE_CAST" value="false" /> + <option name="METHOD_PARAMETERS_WRAP" value="1" /> + <option name="METHOD_ANNOTATION_WRAP" value="1" /> + <option name="CLASS_ANNOTATION_WRAP" value="1" /> + <option name="FIELD_ANNOTATION_WRAP" value="1" /> + <option name="PARENT_SETTINGS_INSTALLED" value="true" /> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="HOCON"> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="PARENT_SETTINGS_INSTALLED" value="true" /> + </codeStyleSettings> + <codeStyleSettings language="JAVA"> + <option name="KEEP_CONTROL_STATEMENT_IN_ONE_LINE" value="false" /> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" /> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="ELSE_ON_NEW_LINE" value="true" /> + <option name="WHILE_ON_NEW_LINE" value="true" /> + <option name="CATCH_ON_NEW_LINE" value="true" /> + <option name="FINALLY_ON_NEW_LINE" value="true" /> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> + <option name="ALIGN_MULTILINE_FOR" value="false" /> + <option name="SPACE_AFTER_TYPE_CAST" value="false" /> + <option name="SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE" value="true" /> + <option name="METHOD_PARAMETERS_WRAP" value="1" /> + <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" /> + <option name="LABELED_STATEMENT_WRAP" value="1" /> + <option name="METHOD_ANNOTATION_WRAP" value="1" /> + <option name="CLASS_ANNOTATION_WRAP" value="1" /> + <option name="FIELD_ANNOTATION_WRAP" value="1" /> + <option name="PARENT_SETTINGS_INSTALLED" value="true" /> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="JSON"> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="PARENT_SETTINGS_INSTALLED" value="true" /> + </codeStyleSettings> + <codeStyleSettings language="Scala"> + <option name="KEEP_BLANK_LINES_IN_DECLARATIONS" value="1" /> + <option name="KEEP_BLANK_LINES_IN_CODE" value="1" /> + <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" /> + <option name="ELSE_ON_NEW_LINE" value="true" /> + <option name="WHILE_ON_NEW_LINE" value="true" /> + <option name="CATCH_ON_NEW_LINE" value="true" /> + <option name="FINALLY_ON_NEW_LINE" value="true" /> + <option name="ALIGN_MULTILINE_PARAMETERS" value="false" /> + <option name="ALIGN_MULTILINE_FOR" value="false" /> + <option name="METHOD_PARAMETERS_WRAP" value="1" /> + <option name="METHOD_ANNOTATION_WRAP" value="1" /> + <option name="CLASS_ANNOTATION_WRAP" value="1" /> + <option name="FIELD_ANNOTATION_WRAP" value="1" /> + <option name="PARENT_SETTINGS_INSTALLED" value="true" /> + <indentOptions> + <option name="INDENT_SIZE" value="4" /> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + <option name="TAB_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> + <codeStyleSettings language="XML"> + <indentOptions> + <option name="CONTINUATION_INDENT_SIZE" value="4" /> + </indentOptions> + </codeStyleSettings> +</code_scheme> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a98daf7/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 5aceaae..44374db 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 @@ -1752,6 +1752,9 @@ class ServerImpl extends TcpDiscoveryImpl { @Nullable Collection<TcpDiscoveryAbstractMessage> messages(IgniteUuid lastMsgId) { assert lastMsgId != null; + if (msgs.isEmpty()) + return Collections.emptyList(); + Collection<TcpDiscoveryAbstractMessage> cp = new ArrayList<>(msgs.size()); boolean skip = true; @@ -1769,30 +1772,6 @@ class ServerImpl extends TcpDiscoveryImpl { } /** - * Resets pending messages. - * - * @param msgs Message. - * @param discardId Discarded message ID. - */ - void reset(@Nullable Collection<TcpDiscoveryAbstractMessage> msgs, @Nullable IgniteUuid discardId) { - this.msgs.clear(); - - if (msgs != null) - this.msgs.addAll(msgs); - - this.discardId = discardId; - } - - /** - * Clears pending messages. - */ - void clear() { - msgs.clear(); - - discardId = null; - } - - /** * Discards message with provided ID and all before it. * * @param id Discarded message ID. @@ -2921,8 +2900,7 @@ class ServerImpl extends TcpDiscoveryImpl { topHist.clear(); topHist.putAll(msg.topologyHistory()); - // Restore pending messages. - pendingMsgs.reset(msg.messages(), msg.discardedMessageId()); + pendingMsgs.discard(msg.discardedMessageId()); // Clear data to minimize message size. msg.messages(null, null); @@ -3180,10 +3158,6 @@ class ServerImpl extends TcpDiscoveryImpl { if (log.isDebugEnabled()) log.debug("Removed node from topology: " + leftNode); - // Clear pending messages map. - if (!ring.hasRemoteNodes()) - pendingMsgs.clear(); - long topVer; if (locNodeCoord) { @@ -3347,10 +3321,6 @@ class ServerImpl extends TcpDiscoveryImpl { assert node != null; - // Clear pending messages map. - if (!ring.hasRemoteNodes()) - pendingMsgs.clear(); - long topVer; if (locNodeCoord) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a98daf7/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java index 7333020..55a14e4 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiSelfTest.java @@ -103,12 +103,17 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { /** */ private boolean longSockTimeouts; + /** */ + private int maxMissedClientHbs = TcpDiscoverySpi.DFLT_MAX_MISSED_CLIENT_HEARTBEATS; + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); TcpDiscoverySpi disco = new TestTcpDiscoverySpi(); + disco.setMaxMissedClientHeartbeats(maxMissedClientHbs); + if (gridName.startsWith("server")) disco.setIpFinder(IP_FINDER); else if (gridName.startsWith("client")) { @@ -494,6 +499,96 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { /** * @throws Exception If failed. */ + public void testClientReconnectTopologyChange1() throws Exception { + maxMissedClientHbs = 100; + + clientsPerSrv = 1; + + startServerNodes(2); + startClientNodes(1); + + checkNodes(2, 1); + + srvLeftLatch = new CountDownLatch(3); + srvFailedLatch = new CountDownLatch(1); + + attachListeners(2, 0); + + Ignite ignite = G.ignite("client-0"); + + TestTcpDiscoverySpi spi = ((TestTcpDiscoverySpi)ignite.configuration().getDiscoverySpi()); + + spi.pauseAll(); + + try { + spi.brakeConnection(); + + Ignite g = startGrid("server-" + srvIdx.getAndIncrement()); + + g.close(); + + spi.resumeAll(); + + assertFalse(srvFailedLatch.await(2000, TimeUnit.MILLISECONDS)); + + assertEquals(1L, srvLeftLatch.getCount()); + + checkNodes(2, 1); + } + finally { + spi.resumeAll(); + } + } + + /** + * @throws Exception If failed. + */ + public void testClientReconnectTopologyChange2() throws Exception { + fail("https://issues.apache.org/jira/browse/IGNITE-998"); + + maxMissedClientHbs = 100; + + clientsPerSrv = 1; + + startServerNodes(1); + startClientNodes(1); + + checkNodes(1, 1); + + srvLeftLatch = new CountDownLatch(2); + srvFailedLatch = new CountDownLatch(1); + + attachListeners(1, 0); + + Ignite ignite = G.ignite("client-0"); + + TestTcpDiscoverySpi spi = ((TestTcpDiscoverySpi)ignite.configuration().getDiscoverySpi()); + + spi.pauseAll(); + + try { + spi.brakeConnection(); + + Ignite g = startGrid("server-" + srvIdx.getAndIncrement()); + + g.close(); + + spi.resumeAll(); + + assertFalse(srvFailedLatch.await(2000, TimeUnit.MILLISECONDS)); + + assertEquals(1L, srvLeftLatch.getCount()); + + checkNodes(1, 1); + } + finally { + spi.resumeAll(); + } + } + + /** + * @throws Exception If failed. + */ public void testGetMissedMessagesOnReconnect() throws Exception { clientsPerSrv = 1; @@ -731,8 +826,6 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { } /** - * TODO: IGNITE-587. - * * @throws Exception If failed. */ public void testDataExchangeFromClient() throws Exception { @@ -740,6 +833,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { } /** + * @param masterName Node name * @throws Exception If failed. */ private void testDataExchange(String masterName) throws Exception { @@ -890,7 +984,8 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { } /** - * @param clientIdx Index. + * @param clientIdx Client index. + * @param srvIdx Server index. * @throws Exception In case of error. */ private void setClientRouter(int clientIdx, int srvIdx) throws Exception { @@ -948,6 +1043,7 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { /** * @param srvCnt Number of server nodes. * @param clientCnt Number of client nodes. + * @throws Exception If failed. */ private void attachListeners(int srvCnt, int clientCnt) throws Exception { if (srvJoinedLatch != null) { @@ -1040,6 +1136,8 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { * @param clientCnt Number of client nodes. */ private void checkNodes(int srvCnt, int clientCnt) { + long topVer = -1; + for (int i = 0; i < srvCnt; i++) { Ignite g = G.ignite("server-" + i); @@ -1048,6 +1146,11 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { assertFalse(g.cluster().localNode().isClient()); checkRemoteNodes(g, srvCnt + clientCnt - 1); + + if (topVer < 0) + topVer = g.cluster().topologyVersion(); + else + assertEquals(topVer, g.cluster().topologyVersion()); } for (int i = 0; i < clientCnt; i++) { @@ -1060,6 +1163,11 @@ public class TcpClientDiscoverySpiSelfTest extends GridCommonAbstractTest { assertTrue(g.cluster().localNode().isClient()); checkRemoteNodes(g, srvCnt + clientCnt - 1); + + if (topVer < 0) + topVer = g.cluster().topologyVersion(); + else + assertEquals(topVer, g.cluster().topologyVersion()); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8a98daf7/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index f5b73df..b167932 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -626,6 +626,7 @@ <exclude>**/keystore/*.pem</exclude><!--auto generated files--> <exclude>**/keystore/*.pfx</exclude><!--bin-files--> <!--special excludes--> + <exclude>idea/ignite_codeStyle.xml</exclude> <exclude>DEVNOTES.txt</exclude> <exclude>src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridOffHeapSnapTreeMap.java</exclude><!--BSD license--> <exclude>src/main/java/org/apache/ignite/internal/util/snaptree/*.java</exclude><!--BSD license-->