http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java index d9a0f52..6a58546 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiSelfTest.java @@ -23,8 +23,8 @@ import org.gridgain.grid.*; import org.apache.ignite.spi.collision.jobstealing.*; import org.apache.ignite.spi.failover.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiStartStopSelfTest.java index abdf6dc..20add52 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/jobstealing/GridJobStealingFailoverSpiStartStopSelfTest.java @@ -21,8 +21,8 @@ import org.apache.ignite.internal.*; import org.gridgain.grid.spi.*; import org.apache.ignite.spi.collision.jobstealing.*; import org.apache.ignite.spi.failover.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java index a51f2ca..4e259a5 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiSelfTest.java @@ -20,8 +20,8 @@ package org.apache.ignite.spi.failover.never; import org.apache.ignite.cluster.*; import org.gridgain.grid.*; import org.apache.ignite.spi.failover.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiStartStopSelfTest.java index 182d550..0bbe0ca 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/failover/never/GridNeverFailoverSpiStartStopSelfTest.java @@ -19,7 +19,7 @@ package org.apache.ignite.spi.failover.never; import org.gridgain.grid.spi.*; import org.apache.ignite.spi.failover.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.junits.spi.*; /** * Never-failover SPI start-stop test. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java index 6702fec..f54eda1 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiConfigSelfTest.java @@ -17,7 +17,7 @@ package org.apache.ignite.spi.loadbalancing.adaptive; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.junits.spi.*; /** * http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java index 3e44e03..20b1b2e 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiMultipleNodeSelfTest.java @@ -20,8 +20,8 @@ package org.apache.ignite.spi.loadbalancing.adaptive; import org.apache.ignite.cluster.*; import org.apache.ignite.lang.*; import org.gridgain.grid.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java index 2408378..eb6fc77 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiSelfTest.java @@ -21,8 +21,8 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.compute.*; import org.apache.ignite.lang.*; import org.gridgain.grid.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java index 913b8bf..cd9eab4 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/adaptive/GridAdaptiveLoadBalancingSpiStartStopSelfTest.java @@ -18,7 +18,7 @@ package org.apache.ignite.spi.loadbalancing.adaptive; import org.gridgain.grid.spi.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.junits.spi.*; /** * Adaptive load balancing SPI start-stop test. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java index bc4a612..6b30f28 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingNotPerTaskMultithreadedSelfTest.java @@ -21,8 +21,8 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.compute.*; import org.apache.ignite.lang.*; import org.gridgain.grid.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; import java.util.concurrent.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java index 779fc35..0f91260 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiLocalNodeSelfTest.java @@ -20,7 +20,7 @@ package org.apache.ignite.spi.loadbalancing.roundrobin; import org.apache.ignite.cluster.*; import org.apache.ignite.lang.*; import org.gridgain.grid.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java index 72c11cb..6fb7fa2 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiMultipleNodesSelfTest.java @@ -22,8 +22,8 @@ import org.apache.ignite.compute.*; import org.apache.ignite.events.*; import org.apache.ignite.lang.*; import org.gridgain.grid.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java index 09ad884..826519c 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiNotPerTaskSelfTest.java @@ -23,8 +23,8 @@ import org.apache.ignite.compute.*; import org.apache.ignite.events.*; import org.apache.ignite.lang.*; import org.gridgain.grid.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java index 630e642..c9905bc 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiStartStopSelfTest.java @@ -18,7 +18,7 @@ package org.apache.ignite.spi.loadbalancing.roundrobin; import org.gridgain.grid.spi.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.junits.spi.*; /** * Tests correct start of {@link RoundRobinLoadBalancingSpi}. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java index 928d0f5..1b783d3 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/roundrobin/GridRoundRobinLoadBalancingSpiTopologyChangeSelfTest.java @@ -21,8 +21,8 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.compute.*; import org.apache.ignite.lang.*; import org.gridgain.grid.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java index 80070d9..00e32f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiConfigSelfTest.java @@ -17,7 +17,7 @@ package org.apache.ignite.spi.loadbalancing.weightedrandom; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.junits.spi.*; /** * http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java index 4ae51aa..1fc3c76 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiSelfTest.java @@ -19,8 +19,8 @@ package org.apache.ignite.spi.loadbalancing.weightedrandom; import org.apache.ignite.cluster.*; import org.gridgain.grid.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java index 3c984cc..1157735 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiStartStopSelfTest.java @@ -18,7 +18,7 @@ package org.apache.ignite.spi.loadbalancing.weightedrandom; import org.gridgain.grid.spi.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.junits.spi.*; /** * Wighted random load balancing SPI start-stop test. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java index c35ea0d..c63a4aa 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/loadbalancing/weightedrandom/GridWeightedRandomLoadBalancingSpiWeightedSelfTest.java @@ -21,8 +21,8 @@ import org.apache.ignite.cluster.*; import org.apache.ignite.lang.*; import org.gridgain.grid.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.spi.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.spi.*; import java.util.*; import static org.apache.ignite.spi.loadbalancing.weightedrandom.WeightedRandomLoadBalancingSpi.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java index 97a9aa1..86d1c87 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/GridSwapSpaceSpiAbstractSelfTest.java @@ -21,7 +21,7 @@ import org.apache.ignite.lang.*; import org.apache.ignite.spi.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.testframework.junits.common.*; +import org.apache.ignite.testframework.junits.common.*; import org.jetbrains.annotations.*; import java.io.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapCompactionSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapCompactionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapCompactionSelfTest.java index 1711076..ba08623 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapCompactionSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/file/GridFileSwapCompactionSelfTest.java @@ -18,7 +18,7 @@ package org.apache.ignite.spi.swapspace.file; import org.apache.ignite.internal.util.typedef.*; -import org.gridgain.testframework.junits.common.*; +import org.apache.ignite.testframework.junits.common.*; import java.io.File; import java.nio.ByteBuffer; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/noop/GridNoopSwapSpaceSpiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/noop/GridNoopSwapSpaceSpiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/noop/GridNoopSwapSpaceSpiSelfTest.java index 4f1d7fe..40e4781 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/swapspace/noop/GridNoopSwapSpaceSpiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/swapspace/noop/GridNoopSwapSpaceSpiSelfTest.java @@ -22,7 +22,7 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.spi.swapspace.*; -import org.gridgain.testframework.junits.common.*; +import org.apache.ignite.testframework.junits.common.*; /** * Tests for "noop" realization of {@link org.apache.ignite.spi.swapspace.SwapSpaceSpi}. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java b/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java new file mode 100644 index 0000000..4868455 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/startup/GridRandomCommandLineLoader.java @@ -0,0 +1,400 @@ +/* + * 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.startup; + +import org.apache.commons.cli.*; +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.lifecycle.*; +import org.apache.log4j.*; +import org.apache.log4j.varia.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.logger.*; +import org.jetbrains.annotations.*; +import org.springframework.beans.*; +import org.springframework.context.*; +import org.springframework.context.support.*; + +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.concurrent.*; + +import static org.apache.ignite.IgniteState.*; + +/** + * This class defines random command-line GridGain loader. This loader can be used + * to randomly start and stop GridGain from command line for tests. This loader is a Java + * application with {@link #main(String[])} method that accepts command line arguments. + * See below for details. + */ +public final class GridRandomCommandLineLoader { + /** Name of the system property defining name of command line program. */ + private static final String GRIDGAIN_PROG_NAME = "GRIDGAIN_PROG_NAME"; + + /** Copyright text. Ant processed. */ + private static final String COPYRIGHT = "Copyright (C) 2014 GridGain Systems."; + + /** Version. Ant processed. */ + private static final String VER = "x.x.x"; + + /** */ + private static final String OPTION_HELP = "help"; + + /** */ + private static final String OPTION_CFG = "cfg"; + + /** */ + private static final String OPTION_MIN_TTL = "minTtl"; + + /** */ + private static final String OPTION_MAX_TTL = "maxTtl"; + + /** */ + private static final String OPTION_DURATION = "duration"; + + /** */ + private static final String OPTION_LOG_CFG = "logCfg"; + + /** Minimal value for timeout in milliseconds. */ + private static final long DFLT_MIN_TIMEOUT = 1000; + + /** Maximum value for timeout in milliseconds. */ + private static final long DFLT_MAX_TIMEOUT = 1000 * 20; + + /** Work timeout in milliseconds. */ + private static final long DFLT_RUN_TIMEOUT = 1000 * 60 * 5; + + /** Latch. */ + private static CountDownLatch latch; + + /** + * Enforces singleton. + */ + private GridRandomCommandLineLoader() { + // No-op. + } + + /** + * Echos the given messages. + * + * @param msg Message to echo. + */ + private static void echo(String msg) { + assert msg != null; + + System.out.println(msg); + } + + /** + * Echos exception stack trace. + * + * @param e Exception to print. + */ + private static void echo(IgniteCheckedException e) { + assert e != null; + + System.err.println(e); + } + + /** + * Exists with optional error message, usage show and exit code. + * + * @param errMsg Optional error message. + * @param options Command line options to show usage information. + * @param exitCode Exit code. + */ + private static void exit(@Nullable String errMsg, @Nullable Options options, int exitCode) { + if (errMsg != null) + echo("ERROR: " + errMsg); + + String runner = System.getProperty(GRIDGAIN_PROG_NAME, "randggstart.{sh|bat}"); + + int space = runner.indexOf(' '); + + runner = runner.substring(0, space == -1 ? runner.length() : space); + + if (options != null) { + HelpFormatter formatter = new HelpFormatter(); + + formatter.printHelp(runner, options); + } + + System.exit(exitCode); + } + + /** + * Prints logo. + */ + private static void logo() { + echo("GridGain Random Command Line Loader, ver. " + VER); + echo(COPYRIGHT); + echo(""); + } + + /** + * Main entry point. + * + * @param args Command line arguments. + */ + @SuppressWarnings({"BusyWait"}) + public static void main(String[] args) { + System.setProperty(IgniteSystemProperties.GG_UPDATE_NOTIFIER, "false"); + + logo(); + + Options options = createOptions(); + + // Create the command line parser. + CommandLineParser parser = new PosixParser(); + + String cfgPath = null; + + long minTtl = DFLT_MIN_TIMEOUT; + long maxTtl = DFLT_MAX_TIMEOUT; + long duration = DFLT_RUN_TIMEOUT; + + String logCfgPath = null; + + try { + CommandLine cmd = parser.parse(options, args); + + if (cmd.hasOption(OPTION_HELP)) + exit(null, options, 0); + + if (!cmd.hasOption(OPTION_LOG_CFG)) + exit("-log should be set", options, -1); + else + logCfgPath = cmd.getOptionValue(OPTION_LOG_CFG); + + if (cmd.hasOption(OPTION_CFG)) + cfgPath = cmd.getOptionValue(OPTION_CFG); + + try { + if (cmd.hasOption(OPTION_DURATION)) + duration = Long.parseLong(cmd.getOptionValue(OPTION_DURATION)); + } + catch (NumberFormatException ignored) { + exit("Invalid argument for option: " + OPTION_DURATION, options, -1); + } + + try { + if (cmd.hasOption(OPTION_MIN_TTL)) + minTtl = Long.parseLong(cmd.getOptionValue(OPTION_MIN_TTL)); + } + catch (NumberFormatException ignored) { + exit("Invalid argument for option: " + OPTION_MIN_TTL, options, -1); + } + + try { + if (cmd.hasOption(OPTION_MAX_TTL)) + maxTtl = Long.parseLong(cmd.getOptionValue(OPTION_MAX_TTL)); + } + catch (NumberFormatException ignored) { + exit("Invalid argument for option: " + OPTION_MAX_TTL, options, -1); + } + + if (minTtl >= maxTtl) + exit("Invalid arguments for options: " + OPTION_MAX_TTL + ", " + OPTION_MIN_TTL, options, -1); + } + catch (ParseException e) { + exit(e.getMessage(), options, -1); + } + + System.out.println("Configuration path: " + cfgPath); + System.out.println("Log4j configuration path: " + logCfgPath); + System.out.println("Duration: " + duration); + System.out.println("Minimum TTL: " + minTtl); + System.out.println("Maximum TTL: " + maxTtl); + + G.addListener(new IgniteListener() { + @Override public void onStateChange(String name, IgniteState state) { + if (state == STOPPED && latch != null) + latch.countDown(); + } + }); + + Random rand = new Random(); + + long now = System.currentTimeMillis(); + + long end = duration + System.currentTimeMillis(); + + try { + while (now < end) { + G.start(getConfiguration(cfgPath, logCfgPath)); + + long delay = rand.nextInt((int)(maxTtl - minTtl)) + minTtl; + + delay = (now + delay > end) ? (end - now) : delay; + + now = System.currentTimeMillis(); + + echo("Time left (ms): " + (end - now)); + + echo("Going to sleep for (ms): " + delay); + + Thread.sleep(delay); + + G.stopAll(false); + + now = System.currentTimeMillis(); + } + } + catch (IgniteCheckedException e) { + echo(e); + + exit("Failed to start grid: " + e.getMessage(), null, -1); + } + catch (InterruptedException e) { + echo("Loader was interrupted (exiting): " + e.getMessage()); + } + + latch = new CountDownLatch(G.allGrids().size()); + + try { + while (latch.getCount() > 0) + latch.await(); + } + catch (InterruptedException e) { + echo("Loader was interrupted (exiting): " + e.getMessage()); + } + + System.exit(0); + } + + /** + * Initializes configurations. + * + * @param springCfgPath Configuration file path. + * @param logCfgPath Log file name. + * @return List of configurations. + * @throws IgniteCheckedException If an error occurs. + */ + @SuppressWarnings("unchecked") + private static IgniteConfiguration getConfiguration(String springCfgPath, @Nullable String logCfgPath) + throws IgniteCheckedException { + assert springCfgPath != null; + + File path = GridTestUtils.resolveGridGainPath(springCfgPath); + + if (path == null) + throw new IgniteCheckedException("Spring XML configuration file path is invalid: " + new File(springCfgPath) + + ". Note that this path should be either absolute path or a relative path to GRIDGAIN_HOME."); + + if (!path.isFile()) + throw new IgniteCheckedException("Provided file path is not a file: " + path); + + // Add no-op logger to remove no-appender warning. + Appender app = new NullAppender(); + + Logger.getRootLogger().addAppender(app); + + ApplicationContext springCtx; + + try { + springCtx = new FileSystemXmlApplicationContext(path.toURI().toURL().toString()); + } + catch (BeansException | MalformedURLException e) { + throw new IgniteCheckedException("Failed to instantiate Spring XML application context: " + e.getMessage(), e); + } + + Map cfgMap; + + try { + // Note: Spring is not generics-friendly. + cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class); + } + catch (BeansException e) { + throw new IgniteCheckedException("Failed to instantiate bean [type=" + IgniteConfiguration.class + ", err=" + + e.getMessage() + ']', e); + } + + if (cfgMap == null) + throw new IgniteCheckedException("Failed to find a single grid factory configuration in: " + path); + + // Remove previously added no-op logger. + Logger.getRootLogger().removeAppender(app); + + if (cfgMap.size() != 1) + throw new IgniteCheckedException("Spring configuration file should contain exactly 1 grid configuration: " + path); + + IgniteConfiguration cfg = (IgniteConfiguration)F.first(cfgMap.values()); + + assert cfg != null; + + if (logCfgPath != null) + cfg.setGridLogger(new GridTestLog4jLogger(U.resolveGridGainUrl(logCfgPath))); + + return cfg; + } + + /** + * Creates cli options. + * + * @return Command line options + */ + private static Options createOptions() { + Options options = new Options(); + + Option help = new Option(OPTION_HELP, "print this message"); + + Option cfg = new Option(null, OPTION_CFG, true, "path to Spring XML configuration file."); + + cfg.setValueSeparator('='); + cfg.setType(String.class); + + Option minTtl = new Option(null, OPTION_MIN_TTL, true, "node minimum time to live."); + + minTtl.setValueSeparator('='); + minTtl.setType(Long.class); + + Option maxTtl = new Option(null, OPTION_MAX_TTL, true, "node maximum time to live."); + + maxTtl.setValueSeparator('='); + maxTtl.setType(Long.class); + + Option duration = new Option(null, OPTION_DURATION, true, "run timeout."); + + duration.setValueSeparator('='); + duration.setType(Long.class); + + Option log = new Option(null, OPTION_LOG_CFG, true, "path to log4j configuration file."); + + log.setValueSeparator('='); + log.setType(String.class); + + options.addOption(help); + + OptionGroup grp = new OptionGroup(); + + grp.setRequired(true); + + grp.addOption(cfg); + grp.addOption(minTtl); + grp.addOption(maxTtl); + grp.addOption(duration); + grp.addOption(log); + + options.addOptionGroup(grp); + + return options; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/startup/GridVmNodesStarter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/startup/GridVmNodesStarter.java b/modules/core/src/test/java/org/apache/ignite/startup/GridVmNodesStarter.java new file mode 100644 index 0000000..0246376 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/startup/GridVmNodesStarter.java @@ -0,0 +1,271 @@ +/* + * 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.startup; + +import org.apache.commons.cli.*; +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.log4j.*; +import org.apache.log4j.varia.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.testframework.*; +import org.springframework.beans.*; +import org.springframework.context.*; +import org.springframework.context.support.*; + +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.*; + +import static org.apache.ignite.IgniteSystemProperties.*; + +/** + * This class + * + */ +public final class GridVmNodesStarter { + /** Name of the system property defining name of command line program. */ + private static final String GRIDGAIN_PROG_NAME = "GRIDGAIN_PROG_NAME"; + + /** */ + private static final String GRID_NAME_PREF = "gg-vm-grid-"; + + /** */ + private static final int DFLT_NODES_COUNT = 20; + + /** */ + private static final String OPTION_CFG = "cfg"; + + /** */ + private static final String OPTION_N = "n"; + + /** */ + private static final AtomicInteger gridCnt = new AtomicInteger(); + + /** + * Enforces singleton. + */ + private GridVmNodesStarter() { + // No-op. + } + + /** + * Echos the given messages. + * + * @param msg Message to echo. + */ + private static void echo(String msg) { + assert msg != null; + + System.out.println(msg); + } + + /** + * Echos exception stack trace. + * + * @param e Exception to print. + */ + private static void echo(IgniteCheckedException e) { + assert e != null; + + System.err.println(e); + } + + /** + * Exists with optional error message, usage show and exit code. + * + * @param errMsg Optional error message. + * @param options Command line options to show usage information. + * @param exitCode Exit code. + */ + private static void exit(String errMsg, Options options, int exitCode) { + if (errMsg != null) + echo("ERROR: " + errMsg); + + String runner = System.getProperty(GRIDGAIN_PROG_NAME, "randggstart.{sh|bat}"); + + int space = runner.indexOf(' '); + + runner = runner.substring(0, space == -1 ? runner.length() : space); + + if (options != null) { + HelpFormatter formatter = new HelpFormatter(); + + formatter.printHelp(runner, options); + } + + System.exit(exitCode); + } + + /** + * Main entry point. + * + * @param args Command line arguments. + * @throws IgniteCheckedException If failed. + */ + public static void main(String[] args) throws IgniteCheckedException { + System.setProperty(GG_UPDATE_NOTIFIER, "false"); + + Options options = createOptions(); + + // Create the command line parser. + CommandLineParser parser = new PosixParser(); + + String cfgPath = null; + + Integer nodesCnt = null; + + try { + CommandLine cmd = parser.parse(options, args); + + if (cmd.hasOption(OPTION_CFG)) + cfgPath = cmd.getOptionValue(OPTION_CFG); + + if (cmd.hasOption(OPTION_N)) + try { + nodesCnt = Integer.parseInt(cmd.getOptionValue(OPTION_N)); + } + catch (NumberFormatException ignored) { + // No-op. + } + + if (nodesCnt == null) + nodesCnt = DFLT_NODES_COUNT; + } + catch (ParseException e) { + exit(e.getMessage(), options, -1); + } + + System.out.println(); + System.out.println(">>> VM Nodes Starter parameters:"); + System.out.println(" Nodes Count: " + nodesCnt); + System.out.println(" Config Path: " + cfgPath); + System.out.println(); + + final IgniteConfiguration[] cfgs = new IgniteConfiguration[nodesCnt]; + + for (int i = 0; i < nodesCnt; i++) + cfgs[i] = getConfigurations(cfgPath).iterator().next(); + + final AtomicInteger cfgIdx = new AtomicInteger(0); + + GridTestUtils.runMultiThreadedAsync(new Callable<Object>() { + @Override public Object call() throws Exception { + G.start(cfgs[cfgIdx.getAndIncrement()]); + + return null; + } + }, nodesCnt, "test-node-starter"); + } + + /** + * Initializes configurations. + * + * + * @param springCfgPath Configuration file path. + * @return List of configurations. + * @throws IgniteCheckedException If an error occurs. + */ + @SuppressWarnings("unchecked") + private static Iterable<IgniteConfiguration> getConfigurations(String springCfgPath) + throws IgniteCheckedException { + File path = GridTestUtils.resolveGridGainPath(springCfgPath); + + if (path == null) + throw new IgniteCheckedException("Spring XML configuration file path is invalid: " + new File(springCfgPath) + + ". Note that this path should be either absolute path or a relative path to GRIDGAIN_HOME."); + + if (!path.isFile()) + throw new IgniteCheckedException("Provided file path is not a file: " + path); + + // Add no-op logger to remove no-appender warning. + Appender app = new NullAppender(); + + Logger.getRootLogger().addAppender(app); + + ApplicationContext springCtx; + + try { + springCtx = new FileSystemXmlApplicationContext(path.toURI().toURL().toString()); + } + catch (BeansException | MalformedURLException e) { + throw new IgniteCheckedException("Failed to instantiate Spring XML application context: " + e.getMessage(), e); + } + + Map cfgMap; + + try { + // Note: Spring is not generics-friendly. + cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class); + } + catch (BeansException e) { + throw new IgniteCheckedException("Failed to instantiate bean [type=" + IgniteConfiguration.class + ", err=" + + e.getMessage() + ']', e); + } + + if (cfgMap == null) + throw new IgniteCheckedException("Failed to find a single grid factory configuration in: " + path); + + // Remove previously added no-op logger. + Logger.getRootLogger().removeAppender(app); + + if (cfgMap.isEmpty()) + throw new IgniteCheckedException("Can't find grid factory configuration in: " + path); + + Collection<IgniteConfiguration> res = new ArrayList<>(); + + for (IgniteConfiguration cfg : (Collection<IgniteConfiguration>)cfgMap.values()) { + res.add(cfg); + + cfg.setGridName(GRID_NAME_PREF + gridCnt.incrementAndGet()); + } + + return res; + } + + /** + * Creates cli options. + * + * @return Command line options + */ + private static Options createOptions() { + Options options = new Options(); + + OptionGroup grp = new OptionGroup(); + + grp.setRequired(true); + + Option cfg = new Option(OPTION_CFG, null, true, "path to Spring XML configuration file."); + + cfg.setArgName("file"); + + Option n = new Option(null, OPTION_N, true, "nodes count."); + + n.setValueSeparator('='); + n.setType(Integer.class); + + grp.addOption(cfg); + grp.addOption(n); + + options.addOptionGroup(grp); + + return options; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java index 816d088..26d8663 100644 --- a/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java +++ b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineLoaderTest.java @@ -21,7 +21,7 @@ import org.apache.ignite.*; import org.apache.ignite.lifecycle.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.testframework.junits.common.*; +import org.apache.ignite.testframework.junits.common.*; import java.util.concurrent.*; import static org.apache.ignite.IgniteState.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java index eaa5c27..618dfd8 100644 --- a/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/startup/cmdline/GridCommandLineTransformerSelfTest.java @@ -17,8 +17,8 @@ package org.apache.ignite.startup.cmdline; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.common.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.common.*; import java.util.concurrent.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/startup/package.html ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/startup/package.html b/modules/core/src/test/java/org/apache/ignite/startup/package.html new file mode 100644 index 0000000..1f85ff2 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/startup/package.html @@ -0,0 +1,23 @@ +<!-- + 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. + --> +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<body> + <!-- Package description. --> + Contains internal tests or test related classes and interfaces. +</body> +</html> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesNode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesNode.java b/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesNode.java new file mode 100644 index 0000000..11fbc74 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesNode.java @@ -0,0 +1,140 @@ +/* + * 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.storevalbytes; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +import org.gridgain.grid.kernal.processors.cache.*; +import org.apache.ignite.spi.communication.tcp.*; +import org.apache.ignite.spi.discovery.tcp.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; +import org.apache.ignite.internal.util.typedef.*; + +import java.util.*; + +import static org.apache.ignite.cache.GridCacheMode.*; +import static org.apache.ignite.cache.GridCacheDistributionMode.*; + +/** + * + */ +public class GridCacheStoreValueBytesNode { + /** + * @return Discovery SPI. + * @throws Exception If failed. + */ + static TcpDiscoverySpi discovery() throws Exception { + TcpDiscoverySpi disc = new TcpDiscoverySpi(); + + disc.setLocalAddress("localhost"); + + TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); + + Collection<String> addrs = new ArrayList<>(); + + for (int i = 0; i < 10; i++) + addrs.add("localhost:" + (TcpDiscoverySpi.DFLT_PORT + i)); + + ipFinder.setAddresses(addrs); + + disc.setIpFinder(ipFinder); + + return disc; + } + + /** + * @param size Size. + * @return Value. + */ + static String createValue(int size) { + StringBuilder str = new StringBuilder(); + + str.append(new char[size]); + + return str.toString(); + } + + /** + * @param args Arguments. + * @param nearOnly Near only flag. + * @return Configuration. + * @throws Exception If failed. + */ + static IgniteConfiguration parseConfiguration(String[] args, boolean nearOnly) throws Exception { + boolean p2pEnabled = false; + + boolean storeValBytes = false; + + for (int i = 0; i < args.length; i++) { + String arg = args[i]; + + switch (arg) { + case "-p2p": + p2pEnabled = Boolean.parseBoolean(args[++i]); + + break; + + case "-storeValBytes": + storeValBytes = Boolean.parseBoolean(args[++i]); + + break; + } + } + + X.println("Peer class loading enabled: " + p2pEnabled); + X.println("Store value bytes: " + storeValBytes); + + IgniteConfiguration cfg = new IgniteConfiguration(); + + TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); + commSpi.setSharedMemoryPort(-1); + + cfg.setCommunicationSpi(commSpi); + + cfg.setDiscoverySpi(discovery()); + + cfg.setPeerClassLoadingEnabled(p2pEnabled); + + CacheConfiguration cacheCfg = new CacheConfiguration(); + + cacheCfg.setCacheMode(PARTITIONED); + + cacheCfg.setStoreValueBytes(storeValBytes); + + cacheCfg.setBackups(1); + + if (nearOnly) { + cacheCfg.setNearEvictionPolicy(new GridCacheAlwaysEvictionPolicy()); + + cacheCfg.setDistributionMode(NEAR_ONLY); + } + + cfg.setCacheConfiguration(cacheCfg); + + return cfg; + } + + /** + * @param args Arguments. + * @throws Exception If failed. + */ + public static void main(String[] args) throws Exception { + Ignition.start(parseConfiguration(args, false)); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesTest.java b/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesTest.java new file mode 100644 index 0000000..f70ea1b --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/storevalbytes/GridCacheStoreValueBytesTest.java @@ -0,0 +1,340 @@ +/* + * 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.storevalbytes; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.loadtests.util.*; + +import java.util.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.*; + +import static org.apache.ignite.storevalbytes.GridCacheStoreValueBytesNode.*; + +/** + * + */ +public class GridCacheStoreValueBytesTest { + /** */ + static final int KEYS_NUM = 10000; + + /** */ + static final Integer[] KEYS = new Integer[KEYS_NUM]; + + /** */ + static final int DFL_MIN_VAL_SIZE = 512; + + /** */ + static final int DFL_MAX_VAL_SIZE = 1024; + + static { + for (int i = 0; i < KEYS_NUM; i++) + KEYS[i] = i; + } + + /** */ + private static final int DFLT_THREADS_NUM = 2; + + /** */ + private static final boolean DFLT_RANDOM_GET = false; + + /** */ + private static final int DFLT_DURATION_MIN = 3; + + /** */ + private static final int UPDATE_INTERVAL_SEC = 10; + + /** */ + private static final int DFLT_WARMUP_TIME_SEC = 10; + + /** */ + private static final int DFLT_CONCURRENT_GET_NUM = 5000; + + /** */ + private static final int DFLT_GET_KEY_NUM = 20; + + /** + * @param args Args. + * @throws Exception If failed. + */ + public static void main(String[] args) throws Exception { + boolean randomGet = DFLT_RANDOM_GET; + + int duration = DFLT_DURATION_MIN; + + boolean put = false; + + int warmup = DFLT_WARMUP_TIME_SEC; + + int concurrentGetNum = DFLT_CONCURRENT_GET_NUM; + + int threadsNum = DFLT_THREADS_NUM; + + int getKeyNum = DFLT_GET_KEY_NUM; + + int minSize = DFL_MIN_VAL_SIZE; + + int maxSize = DFL_MAX_VAL_SIZE; + + for (int i = 0; i < args.length; i++) { + String arg = args[i]; + + switch (arg) { + case "-c": + concurrentGetNum = Integer.parseInt(args[++i]); + + break; + + case "-t": + threadsNum = Integer.parseInt(args[++i]); + + break; + + case "-k": + getKeyNum = Integer.parseInt(args[++i]); + + break; + + case "-randomGet": + randomGet = Boolean.parseBoolean(args[++i]); + + break; + + case "-d": + duration = Integer.parseInt(args[++i]); + + break; + + case "-w": + warmup = Integer.parseInt(args[++i]); + + break; + + case "-put": + put = Boolean.parseBoolean(args[++i]); + + break; + + case "-min": + minSize = Integer.parseInt(args[++i]); + + break; + + case "-max": + maxSize = Integer.parseInt(args[++i]); + + break; + } + } + + X.println("Duration: " + duration + " minutes"); + X.println("Warmup time: " + warmup + " seconds"); + X.println("Threads number: " + threadsNum); + X.println("Concurrent get number: " + concurrentGetNum); + X.println("Get keys number: " + getKeyNum); + X.println("Random get: " + randomGet); + + Ignite ignite = Ignition.start(GridCacheStoreValueBytesNode.parseConfiguration(args, true)); + + if (put) { + X.println("Putting data in cache..."); + X.println("Min value size: " + minSize); + X.println("Max value size: " + maxSize); + + Random random = new Random(1); + + int sizeRange = maxSize - minSize; + + GridCache<Integer, String> cache = ignite.cache(null); + + if (sizeRange == 0) { + for (Integer key : KEYS) + cache.put(key, createValue(minSize)); + } + else { + for (Integer key : KEYS) + cache.put(key, createValue(minSize + random.nextInt(sizeRange))); + } + } + + try { + runTest(ignite, concurrentGetNum, threadsNum, getKeyNum, duration * 60000, warmup * 1000, randomGet); + } + finally { + G.stopAll(true); + } + } + + /** + * @param exec Pool. + * @param ignite Grid. + * @param concurrentGetNum Concurrent GET operations. + * @param threadsNum Thread count. + * @param getKeyNum Keys count. + * @param finish Finish flag. + * @param cntr Counter. + * @param randomGet {@code True} to get random keys. + * @return Futures. + */ + static Collection<Future<?>> startThreads(ExecutorService exec, final Ignite ignite, int concurrentGetNum, + int threadsNum, final int getKeyNum, final AtomicBoolean finish, final AtomicLong cntr, + final boolean randomGet) { + + final Semaphore sem = new Semaphore(concurrentGetNum); + + final IgniteInClosure<IgniteFuture> lsnr = new CI1<IgniteFuture>() { + @Override public void apply(IgniteFuture t) { + sem.release(); + } + }; + + finish.set(false); + + cntr.set(0); + + Collection<Future<?>> futs = new ArrayList<>(threadsNum); + + for (int i = 0; i < threadsNum; i++) { + futs.add(exec.submit(new Callable<Void>() { + @Override public Void call() throws Exception { + GridCache<Integer, String> cache = ignite.cache(null); + + Random random = new Random(); + + while (!finish.get()) { + Collection<Integer> keys = new ArrayList<>(getKeyNum); + + for (int i = 0; i < KEYS_NUM; i++) { + Integer key = KEYS[randomGet ? random.nextInt(KEYS_NUM) : i]; + + keys.add(key); + + if (keys.size() == getKeyNum) { + sem.acquire(); + + IgniteFuture<Map<Integer, String>> f = cache.getAllAsync(keys); + + f.listenAsync(lsnr); + + cntr.incrementAndGet(); + + keys.clear(); + } + } + } + + return null; + } + })); + } + + return futs; + } + + /** + * @param ignite Grid. + * @param concurrentGetNum Number of concurrent getAllAsync operations. + * @param threadsNum Thread count. + * @param getKeyNum Keys count. + * @param duration Test duration. + * @param warmup Warmup duration. + * @param randomGet If {@code true} then selects keys randomly, otherwise selects keys sequentially. + * @throws Exception If failed. + */ + static void runTest(final Ignite ignite, int concurrentGetNum, int threadsNum, int getKeyNum, final long duration, + long warmup, final boolean randomGet) throws Exception { + ExecutorService exec = Executors.newFixedThreadPool(threadsNum); + + try { + final AtomicBoolean finish = new AtomicBoolean(); + + final AtomicLong cntr = new AtomicLong(); + + X.println("Warming up..."); + + Collection<Future<?>> futs = startThreads(exec, ignite, concurrentGetNum, threadsNum, getKeyNum, finish, + cntr, randomGet); + + U.sleep(warmup); + + finish.set(true); + + boolean failed = false; + + for (Future<?> fut : futs) { + try { + fut.get(); + } + catch (ExecutionException e) { + X.error("Error during warmup: " + e); + + e.getCause().printStackTrace(); + + failed = true; + } + } + + if (failed) + return; + + X.println("Running test..."); + + futs = startThreads(exec, ignite, concurrentGetNum, threadsNum, getKeyNum, finish, cntr, randomGet); + + long end = System.currentTimeMillis() + duration; + + GridCumulativeAverage avgGetPerSec = new GridCumulativeAverage(); + + while (System.currentTimeMillis() < end) { + long c1 = cntr.get(); + + U.sleep(UPDATE_INTERVAL_SEC * 1000); + + long c2 = cntr.get(); + + long getPerSec = (c2 - c1) / UPDATE_INTERVAL_SEC; + + X.println(">>> Gets/s: " + getPerSec); + + avgGetPerSec.update(getPerSec); + } + + finish.set(true); + + for (Future<?> fut : futs) { + try { + fut.get(); + } + catch (ExecutionException e) { + X.error("Error during execution: " + e); + + e.getCause().printStackTrace(); + } + } + + X.println(">>> Average gets/s: " + avgGetPerSec); + } + finally { + exec.shutdown(); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/streamer/index/GridStreamerIndexSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/streamer/index/GridStreamerIndexSelfTest.java b/modules/core/src/test/java/org/apache/ignite/streamer/index/GridStreamerIndexSelfTest.java index 06d5fdf..e7692f0 100644 --- a/modules/core/src/test/java/org/apache/ignite/streamer/index/GridStreamerIndexSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/streamer/index/GridStreamerIndexSelfTest.java @@ -24,14 +24,14 @@ import org.apache.ignite.streamer.index.tree.*; import org.apache.ignite.streamer.window.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.testframework.junits.common.*; +import org.apache.ignite.testframework.junits.common.*; import org.jetbrains.annotations.*; import java.util.*; import java.util.concurrent.atomic.*; import static org.apache.ignite.streamer.index.StreamerIndexPolicy.*; -import static org.gridgain.testframework.GridTestUtils.*; +import static org.apache.ignite.testframework.GridTestUtils.*; /** * Tests for Streamer window index. http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/streamer/window/GridStreamerWindowSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/streamer/window/GridStreamerWindowSelfTest.java b/modules/core/src/test/java/org/apache/ignite/streamer/window/GridStreamerWindowSelfTest.java index 0a2e78b..cd164bb 100644 --- a/modules/core/src/test/java/org/apache/ignite/streamer/window/GridStreamerWindowSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/streamer/window/GridStreamerWindowSelfTest.java @@ -23,8 +23,8 @@ import org.apache.ignite.lang.*; import org.apache.ignite.streamer.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.testframework.*; -import org.gridgain.testframework.junits.common.*; +import org.apache.ignite.testframework.*; +import org.apache.ignite.testframework.junits.common.*; import java.util.*; import java.util.concurrent.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/testframework/GridFileLock.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridFileLock.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridFileLock.java new file mode 100644 index 0000000..5c267a1 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridFileLock.java @@ -0,0 +1,110 @@ +/* + * 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.testframework; + +import org.apache.ignite.*; +import org.apache.ignite.internal.util.typedef.internal.*; + +import java.io.*; +import java.nio.channels.*; + +/** + * OS-level file lock implementation. + */ +public class GridFileLock { + /** FS file for lock. */ + private final File file; + + /** Random access file for FS file. */ + private final RandomAccessFile raFile; + + /** File lock. */ + private FileLock fileLock; + + /** + * Initializes the lock. + * + * The constructor opens the lock file, which then should be + * closed with {@link #close()} method. + * + * @param file FS file to use as a lock file. + * @throws FileNotFoundException If error occurs on opening or creating the file. + */ + GridFileLock(File file) throws FileNotFoundException { + this.file = file; + + raFile = new RandomAccessFile(file, "rw"); + } + + /** + * Performs an exclusive lock on a file, that + * this lock instance was constructed with. + * + * @throws IgniteCheckedException If failed to perform locking. The file remains open. + */ + public void lock() throws IgniteCheckedException { + lock(false); + } + + /** + * Performs a lock (shared or exclusive) on a file, that + * this lock instance was constructed with. + * + * @param shared Whether a lock is shared (non-exclusive). + * @throws IgniteCheckedException If failed to perform locking. The file remains open. + */ + public void lock(boolean shared) throws IgniteCheckedException { + if (fileLock != null) + throw new IgniteCheckedException("Already locked [lockFile=" + file + ']'); + + try { + fileLock = raFile.getChannel().tryLock(0, Long.MAX_VALUE, shared); + + if (fileLock == null) + throw new IgniteCheckedException("Failed to get exclusive lock on lock file [lockFile=" + file + ']'); + } + catch (IOException | OverlappingFileLockException e) { + throw new IgniteCheckedException("Failed to get exclusive lock on lock file [lockFile=" + file + ']', e); + } + } + + /** + * Unlocks the file. + */ + public void unlock() { + if (fileLock != null) { + U.releaseQuiet(fileLock); + + fileLock = null; + } + } + + /** + * Unlocks and closes the file. + */ + public void close() { + unlock(); + + U.closeQuiet(raFile); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(GridFileLock.class, this); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/testframework/GridJarClassLoader.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridJarClassLoader.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridJarClassLoader.java new file mode 100644 index 0000000..980e9f2 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridJarClassLoader.java @@ -0,0 +1,178 @@ +/* + * 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.testframework; + +import java.io.*; +import java.security.*; +import java.util.*; +import java.util.jar.*; + +/** + * Jar class loader. + */ +public final class GridJarClassLoader extends SecureClassLoader { + /** Cached loaded classes as bytes. */ + private final Map<String, byte[]> clsArrs; + + /** List of excluded classes/packages. */ + @SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized") + private List<String> excludedCls = new ArrayList<>(); + + /** */ + private static GridJarClassLoader instance; + + /** + * Get classloader singleton instance. + * + * @param files Files. + * @param parent Parent classloader. + * @return Instance of Jar class loader. + * @throws IOException If fies can't be read, + */ + public static synchronized GridJarClassLoader getInstance(List<String> files, ClassLoader parent) + throws IOException{ + if (instance == null) + instance = new GridJarClassLoader(files, parent); + + return instance; + } + + /** + * Constructor. + * + * @param files Files. + * @param parent Parent classloader. + * @throws IOException If fies can't be read, + */ + private GridJarClassLoader(Iterable<String> files, ClassLoader parent) throws IOException { + super(parent); + + clsArrs = new HashMap<>(); + + for (String fileName: files) + readJarFile(fileName); + } + + /** {@inheritDoc} */ + @Override protected synchronized Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { + boolean excluded = false; + + for (String cls: excludedCls) + if (name.startsWith(cls)) { + excluded = true; + + break; + } + + // If class is from Jar file(s) and not in excluded (note we use name with '.'). + if (clsArrs.containsKey(name) && !excluded) { + Class<?> cls = findLoadedClass(name); + + if (cls == null) + cls = findClass(name); + + if (resolve) + resolveClass(cls); + + return cls; + } + + return super.loadClass(name, resolve); + } + + + /** {@inheritDoc} */ + @Override protected Class<?> findClass(String name) throws ClassNotFoundException { + + SecurityManager sm = System.getSecurityManager(); + + if (sm != null) { + int i = name.lastIndexOf('.'); + + if (i >= 0) + sm.checkPackageDefinition(name.substring(0, i)); + } + + byte[] buf = clsArrs.get(name); + + if (buf != null) + return defineClass(name, buf, 0, buf.length, (CodeSource)null); + + throw new ClassNotFoundException(name); + } + + /** + * Reads JAR file and stored classes locally. + * + * @param fileName Name of file to read. + * @throws IOException If read failed. + */ + private void readJarFile(String fileName) throws IOException { + JarEntry je; + + JarInputStream jis = new JarInputStream(new FileInputStream(fileName)); + + while ((je = jis.getNextJarEntry()) != null) { + String jarName = je.getName(); + + if (jarName.endsWith(".class")) + loadClassBytes(jis, jarName); + + // Else ignore it; it could be an image or audio file. + jis.closeEntry(); + } + } + + /** + * Loads class bytes to storege. + * + * @param jis Input stream. + * @param jarName Name of the JAR file. + * @throws IOException If read failed. + */ + private void loadClassBytes(JarInputStream jis, String jarName) throws IOException { + BufferedInputStream jarBuf = new BufferedInputStream(jis); + ByteArrayOutputStream jarOut = new ByteArrayOutputStream(); + + int b; + + while ((b = jarBuf.read()) != -1) + jarOut.write(b); + + // Remove ".class". + String urlName = jarName.substring(0, jarName.length() - 6); + + String name = urlName.replace('/', '.'); + + clsArrs.put(name, jarOut.toByteArray()); + } + + /** + * @return the excludedCls + */ + public List<String> getExcludedCls() { + return excludedCls; + } + + /** + * @param excludedCls the excludedCls to set + */ + public void setExcludedCls(List<String> excludedCls) { + this.excludedCls = excludedCls; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd28003b/modules/core/src/test/java/org/apache/ignite/testframework/GridLoadTestUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/GridLoadTestUtils.java b/modules/core/src/test/java/org/apache/ignite/testframework/GridLoadTestUtils.java new file mode 100644 index 0000000..88c7a7c --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/testframework/GridLoadTestUtils.java @@ -0,0 +1,152 @@ +/* + * 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.testframework; + +import org.apache.ignite.internal.util.typedef.internal.*; +import org.jetbrains.annotations.*; + +import java.io.*; +import java.text.*; +import java.util.concurrent.*; +import java.util.concurrent.atomic.*; + +/** + * Utility class for load tests. + */ +public class GridLoadTestUtils { + /** Date and time format. */ + public static final SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); + + /** Lock file. */ + public static final File LOCK_FILE = new File(System.getProperty("user.home"), ".gg-loadtest-lock"); + + /** */ + private GridLoadTestUtils() { + // No-op. + } + + /** + * Appends a line to a file. Creates parent directories if any of those do not + * exist. + * + * @param fileName Name of a file to append to. + * @param format A line format. + * @param vals A line format args. + * @throws IOException If IO error occurs. + */ + public static void appendLineToFile(String fileName, String format, Object... vals) throws IOException { + new File(fileName).getParentFile().mkdirs(); + + try (Writer out = new BufferedWriter(new FileWriter(fileName, true))) { + out.write(String.format(format + '\n', vals)); + } + } + + /** + * Runs a given callable in loop in multiple threads for specified period of time. + * + * @param c Callable to run. + * @param threadCnt Thread count. + * @param dur Run duration in milliseconds. + */ + public static void runMultithreadedInLoop(final Callable<?> c, int threadCnt, long dur) { + ExecutorService pool = Executors.newFixedThreadPool(threadCnt); + final AtomicBoolean finish = new AtomicBoolean(); + + for (int i = 0; i < threadCnt; i++) + pool.submit(new Callable<Object>() { + @Nullable @Override public Object call() throws Exception { + while (!finish.get()) + c.call(); + + return null; + } + }); + + try { + Thread.sleep(dur); + } + catch (InterruptedException ignored) { + // No-op. + } + + finish.set(true); + + pool.shutdown(); + } + + /** + * Performs operation, measuring it's time. + * + * @param c Operation to perform. + * @param threadCnt Number of parallel threads to perform operation (>= 1). + * @return Number of milliseconds, in which the operation was completed. + * @throws Exception If provided callable has thrown exception. + */ + public static long measureTime(Callable<Object> c, int threadCnt) throws Exception { + A.ensure(threadCnt >= 1, "threadCnt should be >= 1"); + + long start = System.currentTimeMillis(); + + if (threadCnt == 1) + c.call(); + else + GridTestUtils.runMultiThreaded(c, threadCnt, "test-worker"); + + return System.currentTimeMillis() - start; + } + + /** + * Starts a daemon thread. + * + * @param r Thread runnable. + * @return Started daemon thread. + */ + public static Thread startDaemon(Runnable r) { + Thread t = new Thread(r); + + t.setDaemon(true); + + t.start(); + + return t; + } + + /** + * Returns a new instance of {@link GridFileLock}, that + * can be used to synchronize on a lock file, which resides + * in a temporary directory. + * <p> + * If a lock file does not exist, it is created. + * <p> + * If a temporary directory does not exist, an exception is + * thrown. + * + * @return An file lock instance. Calling {@link GridFileLock#lock()} + * will perform actual locking. + * @throws RuntimeException If a temporary directory is not found. + */ + public static GridFileLock fileLock() { + try { + return new GridFileLock(LOCK_FILE); + } + catch (FileNotFoundException e) { + throw new RuntimeException("tmp.dir not found", e); + } + } +}