ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [49/51] [abbrv] incubator-ignite git commit: Merge branch 'sprint-1' into ignite-164
Date Wed, 04 Feb 2015 12:34:44 GMT
Merge branch 'sprint-1' into ignite-164


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b80f00a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b80f00a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b80f00a3

Branch: refs/heads/ignite-164
Commit: b80f00a31c327d4dfc07b5a66b7f1212e6ccbe3d
Parents: fc1724a fae12da
Author: Artem SHutak <ashutak@gridgain.com>
Authored: Wed Feb 4 14:36:05 2015 +0300
Committer: Artem SHutak <ashutak@gridgain.com>
Committed: Wed Feb 4 14:36:05 2015 +0300

----------------------------------------------------------------------
 docs/core-site.ignite.xml                       |   2 +-
 examples/config/example-cache.xml               |  14 +-
 examples/config/example-compute.xml             |   8 +-
 examples/config/example-streamer.xml            |  30 +-
 examples/config/filesystem/core-site.xml        |  10 +-
 examples/config/filesystem/example-ggfs.xml     | 165 -----------
 examples/config/filesystem/example-ignitefs.xml | 165 +++++++++++
 examples/config/filesystem/readme.txt           |   8 +-
 .../hibernate/example-hibernate-L2-cache.xml    |   6 +-
 examples/config/servlet/WEB-INF/web.xml         |   2 +-
 examples/rest/http-rest-example.php             |   8 +-
 examples/rest/memcache-rest-example.php         |   4 +-
 .../ignite/examples/ComputeNodeStartup.java     |   4 +-
 .../apache/ignite/examples/ExamplesUtils.java   |   6 +-
 .../compute/ComputeBroadcastExample.java        |  34 +--
 .../compute/ComputeCallableExample.java         |  18 +-
 .../examples/compute/ComputeClosureExample.java |  20 +-
 .../compute/ComputeContinuousMapperExample.java |  24 +-
 .../compute/ComputeExecutorServiceExample.java  |  16 +-
 .../ComputeFibonacciContinuationExample.java    |  35 ++-
 .../compute/ComputeProjectionExample.java       |  23 +-
 .../examples/compute/ComputeReducerExample.java |  20 +-
 .../compute/ComputeRunnableExample.java         |  17 +-
 .../compute/ComputeScheduleExample.java         |  14 +-
 .../examples/compute/ComputeTaskMapExample.java |  30 +-
 .../compute/ComputeTaskSplitExample.java        |  26 +-
 .../failover/ComputeFailoverExample.java        |  17 +-
 .../failover/ComputeFailoverNodeStartup.java    |  12 +-
 .../compute/montecarlo/CreditRiskExample.java   |  30 +-
 .../compute/montecarlo/CreditRiskManager.java   |  14 +-
 .../apache/ignite/examples/compute/package.html |   2 +-
 .../examples/datagrid/CacheAffinityExample.java |  37 ++-
 .../examples/datagrid/CacheApiExample.java      | 104 ++-----
 .../datagrid/CacheContinuousQueryExample.java   |  10 +-
 .../datagrid/CacheDataLoaderExample.java        |  16 +-
 .../examples/datagrid/CacheEventsExample.java   |  21 +-
 .../examples/datagrid/CacheNodeStartup.java     |   4 +-
 .../datagrid/CachePopularNumbersExample.java    |  32 +--
 .../examples/datagrid/CachePutGetExample.java   |  29 +-
 .../examples/datagrid/CacheQueryExample.java    |  26 +-
 .../datagrid/CacheTransactionExample.java       |  41 ++-
 .../datastructures/CacheAtomicLongExample.java  |  16 +-
 .../CacheAtomicReferenceExample.java            |  24 +-
 .../CacheAtomicSequenceExample.java             |  14 +-
 .../CacheAtomicStampedExample.java              |  22 +-
 .../CacheCountDownLatchExample.java             |  16 +-
 .../datastructures/CacheQueueExample.java       |  46 +--
 .../datastructures/CacheSetExample.java         |  36 +--
 .../hibernate/HibernateL2CacheExample.java      |  18 +-
 .../HibernateL2CacheExampleNodeStartup.java     |  12 +-
 .../ignite/examples/datagrid/package.html       |   2 +-
 .../starschema/CacheStarSchemaExample.java      |  57 ++--
 .../datagrid/starschema/DimProduct.java         |   3 +-
 .../examples/datagrid/starschema/DimStore.java  |   3 +-
 .../datagrid/starschema/FactPurchase.java       |   3 +-
 .../examples/datagrid/starschema/package.html   |   2 +-
 .../store/CacheNodeWithStoreStartup.java        |  12 +-
 .../datagrid/store/CacheStoreExample.java       |  17 +-
 .../store/CacheStoreLoadDataExample.java        |  15 +-
 .../store/dummy/CacheDummyPersonStore.java      |   9 +-
 .../datagrid/store/hibernate/hibernate.cfg.xml  |   2 +-
 .../store/jdbc/CacheJdbcPersonStore.java        |  10 +-
 .../ignite/examples/events/EventsExample.java   |  32 +--
 .../ignite/examples/fs/IgniteFsExample.java     | 278 +++++++++++++++++++
 .../examples/fs/IgniteFsMapReduceExample.java   | 249 +++++++++++++++++
 .../ignite/examples/fs/IgniteFsNodeStartup.java |  41 +++
 .../org/apache/ignite/examples/fs/package.html  |  23 ++
 .../ignite/examples/ggfs/GgfsExample.java       | 278 -------------------
 .../examples/ggfs/GgfsMapReduceExample.java     | 249 -----------------
 .../ignite/examples/ggfs/GgfsNodeStartup.java   |  41 ---
 .../apache/ignite/examples/ggfs/package.html    |  23 --
 .../examples/messaging/MessagingExample.java    |  36 +--
 .../messaging/MessagingPingPongExample.java     |  26 +-
 .../MessagingPingPongListenActorExample.java    |  20 +-
 .../client/memcache/MemcacheRestExample.java    |  22 +-
 .../MemcacheRestExampleNodeStartup.java         |  14 +-
 .../misc/deployment/DeploymentExample.java      |  34 +--
 .../misc/lifecycle/LifecycleExample.java        |  24 +-
 .../misc/springbean/SpringBeanExample.java      |  30 +-
 .../examples/misc/springbean/package.html       |   2 +-
 .../examples/misc/springbean/spring-bean.xml    |   8 +-
 .../org/apache/ignite/examples/package.html     |   2 +-
 .../examples/services/ServicesExample.java      |  16 +-
 .../streaming/StreamingCheckInExample.java      |  30 +-
 .../streaming/StreamingNodeStartup.java         |   4 +-
 .../StreamingPopularNumbersExample.java         |  40 +--
 .../streaming/StreamingPriceBarsExample.java    |  38 +--
 .../StreamingRunningAverageExample.java         |   6 +-
 .../apache/ignite/examples/ComputeExample.java  |  12 +-
 .../ignite/examples/MessagingExample.java       |  48 ++--
 .../examples/ScalarCacheAffinityExample1.scala  |  22 +-
 .../examples/ScalarCacheAffinityExample2.scala  |  18 +-
 .../ScalarCacheAffinitySimpleExample.scala      |   6 +-
 .../scalar/examples/ScalarCacheExample.scala    |   4 +-
 .../ScalarCachePopularNumbersExample.scala      |  26 +-
 .../examples/ScalarCacheQueryExample.scala      |  20 +-
 .../scalar/examples/ScalarClosureExample.scala  |  20 +-
 .../examples/ScalarContinuationExample.scala    |  33 ++-
 .../examples/ScalarCreditRiskExample.scala      |  22 +-
 .../scalar/examples/ScalarJvmCloudExample.scala |  22 +-
 .../examples/ScalarPiCalculationExample.scala   |   6 +-
 .../scalar/examples/ScalarPingPongExample.scala |  14 +-
 .../scalar/examples/ScalarPrimeExample.scala    |  16 +-
 .../scalar/examples/ScalarScheduleExample.scala |   6 +-
 .../examples/ScalarSnowflakeSchemaExample.scala |  40 +--
 .../scalar/examples/ScalarTaskExample.scala     |  14 +-
 .../examples/ScalarWorldShortestMapReduce.scala |   2 +-
 .../BasicExamplesMultiNodeSelfTest.java         |  28 ++
 .../ignite/examples/BasicExamplesSelfTest.java  |  82 ++++++
 .../CacheExamplesMultiNodeSelfTest.java         |  48 ++++
 .../ignite/examples/CacheExamplesSelfTest.java  | 155 +++++++++++
 ...heStoreLoadDataExampleMultiNodeSelfTest.java |  39 +++
 .../examples/CheckpointExamplesSelfTest.java    |  45 +++
 .../ContinuationExamplesMultiNodeSelfTest.java  |  28 ++
 .../examples/ContinuationExamplesSelfTest.java  |  33 +++
 ...ntinuousMapperExamplesMultiNodeSelfTest.java |  28 ++
 .../ContinuousMapperExamplesSelfTest.java       |  33 +++
 .../DeploymentExamplesMultiNodeSelfTest.java    |  30 ++
 .../examples/DeploymentExamplesSelfTest.java    |  33 +++
 .../EventsExamplesMultiNodeSelfTest.java        |  28 ++
 .../ignite/examples/EventsExamplesSelfTest.java |  33 +++
 .../GridBasicExamplesMultiNodeSelfTest.java     |  28 --
 .../examples/GridBasicExamplesSelfTest.java     |  82 ------
 .../GridCacheExamplesMultiNodeSelfTest.java     |  48 ----
 .../examples/GridCacheExamplesSelfTest.java     | 155 -----------
 ...heStoreLoadDataExampleMultiNodeSelfTest.java |  39 ---
 .../GridCheckpointExamplesSelfTest.java         |  45 ---
 ...idContinuationExamplesMultiNodeSelfTest.java |  28 --
 .../GridContinuationExamplesSelfTest.java       |  33 ---
 ...ntinuousMapperExamplesMultiNodeSelfTest.java |  28 --
 .../GridContinuousMapperExamplesSelfTest.java   |  33 ---
 ...GridDeploymentExamplesMultiNodeSelfTest.java |  30 --
 .../GridDeploymentExamplesSelfTest.java         |  33 ---
 .../GridEventsExamplesMultiNodeSelfTest.java    |  28 --
 .../examples/GridEventsExamplesSelfTest.java    |  33 ---
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  31 ---
 .../GridHibernateL2CacheExampleSelfTest.java    |  33 ---
 .../examples/GridLifecycleExamplesSelfTest.java |  33 ---
 ...idMemcacheRestExamplesMultiNodeSelfTest.java |  31 ---
 .../GridMemcacheRestExamplesSelfTest.java       |  41 ---
 .../examples/GridMessagingExamplesSelfTest.java |  52 ----
 ...GridMonteCarloExamplesMultiNodeSelfTest.java |  28 --
 .../GridMonteCarloExamplesSelfTest.java         |  74 -----
 .../examples/GridProjectionExampleSelfTest.java |  39 ---
 .../GridSpringBeanExamplesSelfTest.java         |  33 ---
 .../GridTaskExamplesMultiNodeSelfTest.java      |  28 --
 .../examples/GridTaskExamplesSelfTest.java      |  40 ---
 ...ibernateL2CacheExampleMultiNodeSelfTest.java |  31 +++
 .../HibernateL2CacheExampleSelfTest.java        |  33 +++
 .../examples/IgniteFsExamplesSelfTest.java      |  16 +-
 .../examples/LifecycleExamplesSelfTest.java     |  33 +++
 .../MemcacheRestExamplesMultiNodeSelfTest.java  |  31 +++
 .../examples/MemcacheRestExamplesSelfTest.java  |  41 +++
 .../examples/MessagingExamplesSelfTest.java     |  52 ++++
 .../MonteCarloExamplesMultiNodeSelfTest.java    |  28 ++
 .../examples/MonteCarloExamplesSelfTest.java    |  74 +++++
 .../examples/ProjectionExampleSelfTest.java     |  39 +++
 .../examples/SpringBeanExamplesSelfTest.java    |  33 +++
 .../examples/TaskExamplesMultiNodeSelfTest.java |  28 ++
 .../ignite/examples/TaskExamplesSelfTest.java   |  40 +++
 .../testsuites/IgniteExamplesSelfTestSuite.java |  54 ++--
 .../ScalarExamplesSelfTestSuite.scala           |   7 +-
 .../src/main/java/org/apache/ignite/Ignite.java |   4 +-
 .../org/apache/ignite/cluster/ClusterGroup.java |   9 +-
 .../ignite/internal/ClusterGroupAdapter.java    |  51 +---
 .../ignite/internal/IgniteClusterAsyncImpl.java |  12 +-
 .../apache/ignite/internal/IgniteKernal.java    |   2 +-
 .../processors/cache/GridCacheMapEntry.java     |   6 +-
 .../processors/cache/IgniteCacheProxy.java      |   7 +
 .../test/config/load/mongo-multinode-foster.xml | 170 ------------
 .../GridProjectionForCachesSelfTest.java        |  27 +-
 .../fs/GridGgfsCommonAbstractTest.java          |   4 +-
 .../ipc/shmem/GgfsSharedMemoryTestServer.java   |   2 +-
 .../IpcSharedMemoryCrashDetectionSelfTest.java  |   2 +-
 .../IpcSharedMemoryBenchmarkReader.java         |   2 +-
 .../ignite/p2p/GridP2PUndeploySelfTest.java     |   2 +-
 .../GridAbstractCommunicationSelfTest.java      |   6 +-
 ...mmunicationSpiConcurrentConnectSelfTest.java |   6 +-
 .../tcp/GridTcpCommunicationSpiLanTest.java     |   6 +-
 ...cpCommunicationSpiMultithreadedSelfTest.java |   6 +-
 ...dTcpCommunicationSpiRecoveryAckSelfTest.java |   6 +-
 ...GridTcpCommunicationSpiRecoverySelfTest.java |   6 +-
 .../discovery/AbstractDiscoverySelfTest.java    |  12 +-
 .../testframework/junits/GridAbstractTest.java  |  10 +-
 .../testframework/junits/GridTestIgnite.java    | 230 ---------------
 .../testframework/junits/GridTestResources.java | 255 -----------------
 .../ignite/testframework/junits/IgniteMock.java | 230 +++++++++++++++
 .../junits/IgniteTestResources.java             | 255 +++++++++++++++++
 .../junits/spi/GridSpiAbstractTest.java         |   6 +-
 ...idHadoopDefaultMapReducePlannerSelfTest.java |   6 +-
 .../scala/org/apache/ignite/scalar/scalar.scala |  14 +-
 .../tests/ScalarAffinityRoutingSpec.scala       |  12 +-
 .../tests/ScalarCacheProjectionSpec.scala       |   2 +-
 .../ignite/scalar/tests/ScalarCacheSpec.scala   |   2 +-
 .../scalar/tests/ScalarProjectionSpec.scala     |  36 +--
 .../org/apache/ignite/IgniteSpringBean.java     |   2 +-
 196 files changed, 3394 insertions(+), 3663 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b80f00a3/modules/core/src/main/java/org/apache/ignite/internal/ClusterGroupAdapter.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b80f00a3/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b80f00a3/modules/core/src/test/java/org/apache/ignite/spi/communication/GridAbstractCommunicationSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b80f00a3/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridTcpCommunicationSpiMultithreadedSelfTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b80f00a3/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
----------------------------------------------------------------------
diff --cc modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
index 8308715,0000000..06f64ea
mode 100644,000000..100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/AbstractDiscoverySelfTest.java
@@@ -1,496 -1,0 +1,496 @@@
 +/*
 + * 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;
 +
 +import mx4j.tools.adaptor.http.*;
 +import org.apache.ignite.cluster.*;
 +import org.apache.ignite.internal.managers.security.*;
 +import org.apache.ignite.internal.util.typedef.internal.*;
 +import org.apache.ignite.marshaller.*;
 +import org.apache.ignite.plugin.security.*;
 +import org.apache.ignite.spi.*;
 +import org.apache.ignite.testframework.config.*;
 +import org.apache.ignite.testframework.junits.*;
 +import org.apache.ignite.testframework.junits.spi.*;
 +
 +import javax.management.*;
 +import java.io.*;
 +import java.util.*;
 +import java.util.concurrent.atomic.*;
 +
 +import static org.apache.ignite.events.IgniteEventType.*;
 +import static org.apache.ignite.lang.IgniteProductVersion.*;
 +
 +/**
 + * Base discovery self-test class.
 + * @param <T> SPI implementation class.
 + */
 +@SuppressWarnings({"JUnitAbstractTestClassNamingConvention"})
 +public abstract class AbstractDiscoverySelfTest<T extends IgniteSpi> extends GridSpiAbstractTest<T>
{
 +    /** */
 +    private static final List<DiscoverySpi> spis = new ArrayList<>();
 +
 +    /** */
-     private static final Collection<GridTestResources> spiRsrcs = new ArrayList<>();
++    private static final Collection<IgniteTestResources> spiRsrcs = new ArrayList<>();
 +
 +    /** */
 +    private static long spiStartTime;
 +
 +    /** */
 +    private static final Object mux = new Object();
 +
 +    /** */
 +    private static final String TEST_ATTRIBUTE_NAME = "test.node.prop";
 +
 +    /** */
 +    protected AbstractDiscoverySelfTest() {
 +        super(false);
 +    }
 +
 +    /**
 +     * Checks that each started discovery spi found all other SPI's.
 +     * @throws Exception If failed.
 +     */
 +    @SuppressWarnings({"UnconditionalWait"})
 +    public void testDiscovery() throws Exception {
 +        assert spis.size() > 1;
 +        assert spiStartTime > 0;
 +        assert spiRsrcs.size() == getSpiCount();
 +
 +        boolean isAllDiscovered = false;
 +
 +        while (!isAllDiscovered) {
 +            for (DiscoverySpi spi : spis) {
 +                if (spi.getRemoteNodes().size() < (getSpiCount() - 1)) {
 +                    isAllDiscovered = false;
 +
 +                    break;
 +                }
 +
 +                isAllDiscovered = true;
 +
-                 for (GridTestResources rscrs : spiRsrcs) {
++                for (IgniteTestResources rscrs : spiRsrcs) {
 +                    UUID nodeId = rscrs.getNodeId();
 +
 +                    if (!nodeId.equals(spi.getLocalNode().id())) {
 +                        if (!isContainsNodeId(spi.getRemoteNodes(), nodeId)) {
 +                            isAllDiscovered = false;
 +
 +                            break;
 +                        }
 +                    }
 +                }
 +            }
 +
 +            if (isAllDiscovered)
 +                info("All nodes discovered.");
 +            else {
 +                if (System.currentTimeMillis() > spiStartTime + getMaxDiscoveryTime())
{
 +                    for (int i = 0; i < getSpiCount(); i++) {
 +                        DiscoverySpi spi = spis.get(i);
 +
 +                        info("Remote nodes [spiIdx=" + i + ", nodes=" + spi.getRemoteNodes()
+ ']');
 +                    }
 +
 +                    fail("Nodes were not discovered.");
 +                }
 +                else {
 +                    synchronized (mux) {
 +                        mux.wait(getMaxDiscoveryTime());
 +                    }
 +                }
 +            }
 +        }
 +    }
 +
 +    /** */
 +    private static class DiscoveryListener implements DiscoverySpiListener {
 +        /** * */
 +        private boolean isMetricsUpdate;
 +
 +        /**
 +         *
 +         *
 +         * @return Metrics updates.
 +         */
 +        public boolean isMetricsUpdated() {
 +            return isMetricsUpdate;
 +        }
 +
 +        /** {@inheritDoc} */
 +        @Override public void onDiscovery(int type, long topVer, ClusterNode node, Collection<ClusterNode>
topSnapshot,
 +            Map<Long, Collection<ClusterNode>> topHist) {
 +            if (type == EVT_NODE_METRICS_UPDATED)
 +                isMetricsUpdate = true;
 +        }
 +    }
 +
 +    /**
 +     * @throws Exception If failed.
 +     */
 +    @SuppressWarnings({"UnconditionalWait"})
 +    public void testMetrics() throws Exception {
 +        Collection<DiscoveryListener> listeners = new ArrayList<>();
 +
 +        long metricsStartTime = System.currentTimeMillis();
 +
 +        for (DiscoverySpi spi : spis) {
 +            DiscoveryListener metricsUpdateLsnr = new DiscoveryListener();
 +
 +            spi.setListener(metricsUpdateLsnr);
 +
 +            listeners.add(metricsUpdateLsnr);
 +        }
 +
 +        boolean isAllSpiMetricUpdated = false;
 +
 +        while (!isAllSpiMetricUpdated) {
 +            isAllSpiMetricUpdated = true;
 +
 +            for (DiscoveryListener lsnr : listeners) {
 +                if (!lsnr.isMetricsUpdated()) {
 +                    isAllSpiMetricUpdated = false;
 +
 +                    break;
 +                }
 +            }
 +
 +            if (isAllSpiMetricUpdated)
 +                info("All SPI metrics updated.");
 +            else {
 +                if (System.currentTimeMillis() > metricsStartTime + getMaxMetricsWaitTime())
{
 +                    for (int i = 0; i < getSpiCount(); i++) {
 +                        DiscoverySpi spi = spis.get(i);
 +
 +                        info("Remote nodes [spiIdx=" + i + ", nodes=" + spi.getRemoteNodes()
+ ']');
 +                    }
 +
 +                    fail("SPI Metrics not updated.");
 +                }
 +                else {
 +                    synchronized (mux) {
 +                        mux.wait(getMaxMetricsWaitTime());
 +                    }
 +                }
 +            }
 +        }
 +    }
 +
 +    /**
 +     * Tests whether local node heartbeats cause METRICS_UPDATE event.
 +     *
 +     * @throws Exception If test failed.
 +     */
 +    public void testLocalHeartbeat() throws Exception {
 +        AtomicInteger[] locUpdCnts = new AtomicInteger[getSpiCount()];
 +
 +        int i = 0;
 +
 +        for (final DiscoverySpi spi : spis) {
 +            final AtomicInteger spiCnt = new AtomicInteger(0);
 +
 +            DiscoverySpiListener locHeartbeatLsnr = new DiscoverySpiListener() {
 +                @Override public void onDiscovery(int type, long topVer, ClusterNode node,
 +                    Collection<ClusterNode> topSnapshot, Map<Long, Collection<ClusterNode>>
topHist) {
 +                    // If METRICS_UPDATED came from local node
 +                    if (type == EVT_NODE_METRICS_UPDATED
 +                        && node.id().equals(spi.getLocalNode().id()))
 +                        spiCnt.addAndGet(1);
 +                }
 +            };
 +
 +            locUpdCnts[i] = spiCnt;
 +
 +            spi.setListener(locHeartbeatLsnr);
 +
 +            i++;
 +        }
 +
 +        // Sleep fro 3 Heartbeats.
 +        Thread.sleep(getMaxDiscoveryTime() * 3);
 +
 +        for (AtomicInteger cnt : locUpdCnts) {
 +            assert cnt.get() > 1 : "One of the SPIs did not get at least 2 METRICS_UPDATE
events from local node";
 +        }
 +    }
 +
 +    /**
 +     * @param nodes Nodes iterator.
 +     * @param nodeId Node UUID.
 +     * @return {@code true} if provided iterator contains node with provided UUID.
 +     */
 +    private boolean isContainsNodeId(Iterable<ClusterNode> nodes, UUID nodeId) {
 +        for (ClusterNode node : nodes) {
 +            assert node.id() != null;
 +
 +            if (node.id().equals(nodeId))
 +                return true;
 +        }
 +
 +        return false;
 +    }
 +
 +    /**
 +     * Checks that physical address of local node is equal to local.ip property.
 +     */
 +    public void testLocalNode() {
 +        for (DiscoverySpi spi : spis) {
 +            ClusterNode loc = spi.getLocalNode();
 +
 +            Collection<ClusterNode> rmt = spi.getRemoteNodes();
 +
 +            assert !rmt.contains(loc);
 +        }
 +    }
 +
 +    /**
 +     * Check that "test.node.prop" is present on all nodes.
 +     */
 +    public void testNodeAttributes() {
 +        for (DiscoverySpi spi : spis) {
 +            assert !spi.getRemoteNodes().isEmpty() : "No remote nodes found in Spi.";
 +
 +            Collection<UUID> nodeIds = new HashSet<>();
 +
-             for (GridTestResources rsrc : spiRsrcs) {
++            for (IgniteTestResources rsrc : spiRsrcs) {
 +                nodeIds.add(rsrc.getNodeId());
 +            }
 +
 +            for (ClusterNode node : spi.getRemoteNodes()) {
 +                if (nodeIds.contains(node.id())) {
 +                    Serializable attr = node.attribute(TEST_ATTRIBUTE_NAME);
 +
 +                    if (attr == null || !(attr instanceof String)) {
 +                        fail("Node does not contains attribute [attr=" + TEST_ATTRIBUTE_NAME
+ ", nodeId=" +
 +                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
 +                    }
 +                    else if (!"true".equals(attr)) {
 +                        fail("Attribute value is wrong [attr=" + TEST_ATTRIBUTE_NAME + ",
value=" + attr + ", nodeId=" +
 +                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
 +                    }
 +                    else {
 +                        info("Node contains attribute [attr=" + TEST_ATTRIBUTE_NAME + ",
value=" + attr + ", nodeId=" +
 +                            node.id() + ", spiIdx=" + spis.indexOf(spi) + ']');
 +                    }
 +                }
 +                else
 +                    error("Discovered unknown node [node=" + node + ", spiIdx=" + spis.indexOf(spi)
+ ']');
 +            }
 +        }
 +    }
 +
 +    /**
 +     * Checks that each spi can pings all other.
 +     */
 +    public void testPing() {
 +        for (DiscoverySpi spi : spis) {
-             for (GridTestResources rscrs : spiRsrcs) {
++            for (IgniteTestResources rscrs : spiRsrcs) {
 +                UUID nodeId = rscrs.getNodeId();
 +
 +                if (spi.pingNode(nodeId))
 +                    info("Ping node success [nodeId=" + nodeId + ", spiIdx=" + spis.indexOf(spi)
+ ']');
 +                else
 +                    fail("Ping node error [nodeId=" + nodeId + ", spiIdx=" + spis.indexOf(spi)
+ ']');
 +            }
 +        }
 +    }
 +
 +    /**
 +     * Checks that node serializable.
 +     *
 +     * @throws Exception If failed.
 +     */
 +    public void testNodeSerialize() throws Exception {
 +        for (DiscoverySpi spi : spis) {
 +            ClusterNode node = spi.getLocalNode();
 +
 +            assert node != null;
 +
 +            writeObject(node);
 +
 +            info("Serialize node success [nodeId=" + node.id() + ", spiIdx=" + spis.indexOf(spi)
+ ']');
 +        }
 +    }
 +
 +    /**
 +     * @param idx Index.
 +     * @return Discovery SPI.
 +     */
 +    protected abstract DiscoverySpi getSpi(int idx);
 +
 +    /**
 +     * @return SPI count.
 +     */
 +    protected int getSpiCount() {
 +        return 2;
 +    }
 +
 +    /**
 +     * @return Maximum discovery time.
 +     */
 +    protected long getMaxDiscoveryTime() {
 +        return 10000;
 +    }
 +
 +    /**
 +     * @return Maximum metrics wait time.
 +     */
 +    protected long getMaxMetricsWaitTime() {
 +        return getMaxDiscoveryTime();
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected void beforeTestsStarted() throws Exception {
 +        try {
 +            for (int i = 0; i < getSpiCount(); i++) {
 +                DiscoverySpi spi = getSpi(i);
 +
-                 GridTestResources rsrcMgr = new GridTestResources(getMBeanServer(i));
++                IgniteTestResources rsrcMgr = new IgniteTestResources(getMBeanServer(i));
 +
 +                rsrcMgr.inject(spi);
 +
 +                spi.setNodeAttributes(Collections.<String, Object>singletonMap(TEST_ATTRIBUTE_NAME,
"true"),
 +                    fromString("99.99.99"));
 +
 +                spi.setListener(new DiscoverySpiListener() {
 +                    @SuppressWarnings({"NakedNotify"})
 +                    @Override public void onDiscovery(int type, long topVer, ClusterNode
node,
 +                        Collection<ClusterNode> topSnapshot, Map<Long, Collection<ClusterNode>>
topHist) {
 +                        info("Discovery event [type=" + type + ", node=" + node + ']');
 +
 +                        synchronized (mux) {
 +                            mux.notifyAll();
 +                        }
 +                    }
 +                });
 +
 +                spi.setDataExchange(new DiscoverySpiDataExchange() {
 +                    @Override public List<Object> collect(UUID nodeId) {
 +                        return new LinkedList<>();
 +                    }
 +
 +                    @Override public void onExchange(List<Object> data) {
 +                        // No-op.
 +                    }
 +                });
 +
 +                spi.setAuthenticator(new DiscoverySpiNodeAuthenticator() {
 +                    @Override public GridSecurityContext authenticateNode(ClusterNode n,
GridSecurityCredentials cred) {
 +                        GridSecuritySubjectAdapter subj = new GridSecuritySubjectAdapter(
 +                            GridSecuritySubjectType.REMOTE_NODE, n.id());
 +
 +                        subj.permissions(new GridAllowAllPermissionSet());
 +
 +                        return new GridSecurityContext(subj);
 +                    }
 +
 +                    @Override public boolean isGlobalNodeAuthentication() {
 +                        return false;
 +                    }
 +                });
 +
 +
 +                spi.spiStart(getTestGridName() + i);
 +
 +                spis.add(spi);
 +
 +                spiRsrcs.add(rsrcMgr);
 +
 +                // Force to use test context instead of default dummy context.
 +                spi.onContextInitialized(initSpiContext());
 +            }
 +        }
 +        catch (Throwable e) {
 +            e.printStackTrace();
 +        }
 +
 +        spiStartTime = System.currentTimeMillis();
 +    }
 +
 +    /**
 +     * @param idx Index.
 +     * @return MBean server.
 +     * @throws Exception If failed.
 +     */
 +    private MBeanServer getMBeanServer(int idx) throws Exception {
 +        HttpAdaptor adaptor = new HttpAdaptor();
 +
 +        MBeanServer srv = MBeanServerFactory.createMBeanServer();
 +
 +        adaptor.setPort(Integer.valueOf(GridTestProperties.getProperty("discovery.mbeanserver.selftest.baseport"))
+
 +            idx);
 +
 +        srv.registerMBean(adaptor, new ObjectName("mbeanAdaptor:protocol=HTTP"));
 +
 +        adaptor.start();
 +
 +        return srv;
 +    }
 +
 +    /** {@inheritDoc} */
 +    @Override protected void afterTestsStopped() throws Exception {
 +        assert spis.size() > 1;
 +        assert spis.size() == spiRsrcs.size();
 +
 +        for (DiscoverySpi spi : spis) {
 +            spi.setListener(null);
 +
 +            spi.spiStop();
 +        }
 +
-         for (GridTestResources rscrs : spiRsrcs) {
++        for (IgniteTestResources rscrs : spiRsrcs) {
 +            rscrs.stopThreads();
 +        }
 +
 +        // Clear.
 +        spis.clear();
 +        spiRsrcs.clear();
 +
 +        spiStartTime = 0;
 +
 +        tearDown();
 +    }
 +
 +    /**
 +     * @param node Grid node.
 +     * @throws IOException If write failed.
 +     */
 +    private void writeObject(ClusterNode node) throws Exception {
 +
 +        IgniteMarshaller marshaller = getTestResources().getMarshaller();
 +
 +        OutputStream out = new NullOutputStream();
 +
 +        try {
 +            marshaller.marshal(node, out);
 +        }
 +        finally {
 +            U.close(out, null);
 +        }
 +    }
 +
 +    /**
 +     *
 +     */
 +    private static class NullOutputStream extends OutputStream {
 +        /** {@inheritDoc} */
 +        @Override public void write(int b) throws IOException {
 +            // No-op
 +        }
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b80f00a3/modules/core/src/test/java/org/apache/ignite/testframework/junits/spi/GridSpiAbstractTest.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b80f00a3/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------


Mime
View raw message