You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2017/01/26 14:53:11 UTC
[12/15] ignite git commit: IGNITE-3922 : Simplified IgfsTaskSelfTest.
This closes #1079.
IGNITE-3922 : Simplified IgfsTaskSelfTest. This closes #1079.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/58b49b6c
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/58b49b6c
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/58b49b6c
Branch: refs/heads/ignite-comm-balance-master
Commit: 58b49b6c2e9a834386ee4d8d06e8578a8229953c
Parents: e8067a6
Author: devozerov <vo...@gridgain.com>
Authored: Thu Jan 26 12:24:27 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Thu Jan 26 12:24:27 2017 +0300
----------------------------------------------------------------------
.../processors/igfs/IgfsTaskSelfTest.java | 87 +++++---------------
1 file changed, 20 insertions(+), 67 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/58b49b6c/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
index e5abfea..7b972c3 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsTaskSelfTest.java
@@ -17,12 +17,6 @@
package org.apache.ignite.internal.processors.igfs;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.cache.CacheWriteSynchronizationMode;
@@ -42,9 +36,7 @@ import org.apache.ignite.igfs.mapreduce.IgfsTaskArgs;
import org.apache.ignite.igfs.mapreduce.records.IgfsStringDelimiterRecordResolver;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteFuture;
import org.apache.ignite.resources.IgniteInstanceResource;
import org.apache.ignite.resources.JobContextResource;
import org.apache.ignite.resources.TaskSessionResource;
@@ -52,6 +44,13 @@ import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+
import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -76,13 +75,10 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
private static final int BLOCK_SIZE = 64 * 1024;
/** Total words in file. */
- private static final int TOTAL_WORDS = 2 * 1024 * 1024;
+ private static final int TOTAL_WORDS = 1024 * 1024;
/** Node count */
- private static final int NODE_CNT = 4;
-
- /** Repeat count. */
- private static final int REPEAT_CNT = 10;
+ private static final int NODE_CNT = 3;
/** IGFS. */
private static IgniteFileSystem igfs;
@@ -159,63 +155,18 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
*
* @throws Exception If failed.
*/
+ @SuppressWarnings("ConstantConditions")
public void testTask() throws Exception {
- U.sleep(3000); // TODO: Sleep in order to wait for fragmentizing to finish.
-
- for (int i = 0; i < REPEAT_CNT; i++) {
- String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)];
-
- generateFile(TOTAL_WORDS);
- Long genLen = igfs.info(FILE).length();
-
- IgniteBiTuple<Long, Integer> taskRes = igfs.execute(new Task(),
- new IgfsStringDelimiterRecordResolver(" "), Collections.singleton(FILE), arg);
-
- assert F.eq(genLen, taskRes.getKey());
- assert F.eq(TOTAL_WORDS, taskRes.getValue());
- }
- }
-
- /**
- * Test task.
- *
- * @throws Exception If failed.
- */
- public void testTaskAsync() throws Exception {
- U.sleep(3000);
-
- assertFalse(igfs.isAsync());
-
- IgniteFileSystem igfsAsync = igfs.withAsync();
-
- assertTrue(igfsAsync.isAsync());
-
- for (int i = 0; i < REPEAT_CNT; i++) {
- String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)];
-
- generateFile(TOTAL_WORDS);
- Long genLen = igfs.info(FILE).length();
-
- assertNull(igfsAsync.execute(
- new Task(), new IgfsStringDelimiterRecordResolver(" "), Collections.singleton(FILE), arg));
-
- IgniteFuture<IgniteBiTuple<Long, Integer>> fut = igfsAsync.future();
-
- assertNotNull(fut);
-
- IgniteBiTuple<Long, Integer> taskRes = fut.get();
-
- assert F.eq(genLen, taskRes.getKey());
- assert F.eq(TOTAL_WORDS, taskRes.getValue());
- }
-
- igfsAsync.format();
+ String arg = DICTIONARY[new Random(System.currentTimeMillis()).nextInt(DICTIONARY.length)];
- IgniteFuture<?> fut = igfsAsync.future();
+ generateFile(TOTAL_WORDS);
+ Long genLen = igfs.info(FILE).length();
- assertNotNull(fut);
+ IgniteBiTuple<Long, Integer> taskRes = igfs.execute(new Task(),
+ new IgfsStringDelimiterRecordResolver(" "), Collections.singleton(FILE), arg);
- fut.get();
+ assert F.eq(genLen, taskRes.getKey());
+ assert F.eq(TOTAL_WORDS, taskRes.getValue());
}
/**
@@ -252,12 +203,13 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
}
/** {@inheritDoc} */
+ @SuppressWarnings("ConstantConditions")
@Override public IgniteBiTuple<Long, Integer> reduce(List<ComputeJobResult> ress) {
long totalLen = 0;
int argCnt = 0;
for (ComputeJobResult res : ress) {
- IgniteBiTuple<Long, Integer> res0 = (IgniteBiTuple<Long, Integer>)res.getData();
+ IgniteBiTuple<Long, Integer> res0 = res.getData();
if (res0 != null) {
totalLen += res0.getKey();
@@ -272,6 +224,7 @@ public class IgfsTaskSelfTest extends IgfsCommonAbstractTest {
/**
* Job.
*/
+ @SuppressWarnings("unused")
private static class Job implements IgfsJob, Serializable {
@IgniteInstanceResource
private Ignite ignite;