ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [16/57] [abbrv] incubator-ignite git commit: # IGNITE-226: WIP (4)
Date Fri, 13 Feb 2015 10:54:26 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/915f997d/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerAbstractSelfTest.java
new file mode 100644
index 0000000..cbd7e56
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerAbstractSelfTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.ignitefs;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.fs.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ * Fragmentizer abstract self test.
+ */
+public class IgfsFragmentizerAbstractSelfTest extends IgfsCommonAbstractTest {
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+    /** Test nodes count. */
+    protected static final int NODE_CNT = 4;
+
+    /** GGFS block size. */
+    protected static final int GGFS_BLOCK_SIZE = 1024;
+
+    /** GGFS group size. */
+    protected static final int GGFS_GROUP_SIZE = 32;
+
+    /** Metadata cache name. */
+    private static final String META_CACHE_NAME = "meta";
+
+    /** File data cache name. */
+    protected static final String DATA_CACHE_NAME = "data";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        cfg.setCacheConfiguration(metaConfiguration(), dataConfiguration());
+
+        IgniteFsConfiguration ggfsCfg = new IgniteFsConfiguration();
+
+        ggfsCfg.setName("ggfs");
+        ggfsCfg.setMetaCacheName(META_CACHE_NAME);
+        ggfsCfg.setDataCacheName(DATA_CACHE_NAME);
+        ggfsCfg.setBlockSize(GGFS_BLOCK_SIZE);
+
+        // Need to set this to avoid thread starvation.
+        ggfsCfg.setPerNodeParallelBatchCount(8);
+
+        ggfsCfg.setFragmentizerThrottlingBlockLength(16 * GGFS_BLOCK_SIZE);
+        ggfsCfg.setFragmentizerThrottlingDelay(10);
+
+        cfg.setGgfsConfiguration(ggfsCfg);
+
+        return cfg;
+    }
+
+    /**
+     * Gets meta cache configuration.
+     *
+     * @return Meta cache configuration.
+     */
+    protected CacheConfiguration metaConfiguration() {
+        CacheConfiguration cfg = defaultCacheConfiguration();
+
+        cfg.setName(META_CACHE_NAME);
+
+        cfg.setCacheMode(REPLICATED);
+        cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        cfg.setQueryIndexEnabled(false);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+
+        return cfg;
+    }
+
+    /**
+     * Gets data cache configuration.
+     *
+     * @return Data cache configuration.
+     */
+    protected CacheConfiguration dataConfiguration() {
+        CacheConfiguration cfg = defaultCacheConfiguration();
+
+        cfg.setName(DATA_CACHE_NAME);
+
+        cfg.setCacheMode(PARTITIONED);
+        cfg.setBackups(0);
+        cfg.setAffinityMapper(new IgniteFsGroupDataBlocksKeyMapper(GGFS_GROUP_SIZE));
+        cfg.setDistributionMode(CacheDistributionMode.PARTITIONED_ONLY);
+        cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+        cfg.setQueryIndexEnabled(false);
+        cfg.setAtomicityMode(TRANSACTIONAL);
+
+        return cfg;
+    }
+
+    /**
+     * @param gridIdx Grid index.
+     * @param path Path to await.
+     * @throws Exception If failed.
+     */
+    protected void awaitFileFragmenting(int gridIdx, IgniteFsPath path) throws Exception
{
+        IgfsEx ggfs = (IgfsEx)grid(gridIdx).fileSystem("ggfs");
+
+        IgfsMetaManager meta = ggfs.context().meta();
+
+        IgniteUuid fileId = meta.fileId(path);
+
+        if (fileId == null)
+            throw new IgniteFsFileNotFoundException("File not found: " + path);
+
+        IgfsFileInfo fileInfo = meta.info(fileId);
+
+        do {
+            if (fileInfo == null)
+                throw new IgniteFsFileNotFoundException("File not found: " + path);
+
+            if (fileInfo.fileMap().ranges().isEmpty())
+                return;
+
+            U.sleep(100);
+
+            fileInfo = meta.info(fileId);
+        }
+        while (true);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        startGrids(NODE_CNT);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        grid(0).fileSystem("ggfs").format();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/915f997d/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerSelfTest.java
new file mode 100644
index 0000000..5d70960
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerSelfTest.java
@@ -0,0 +1,268 @@
+/*
+ * 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.ignitefs;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.fs.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.testframework.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Tests fragmentizer work.
+ */
+public class IgfsFragmentizerSelfTest extends IgfsFragmentizerAbstractSelfTest {
+    /**
+     * @throws Exception If failed.
+     */
+    public void testReadFragmentizing() throws Exception {
+        IgniteFs ggfs = grid(0).fileSystem("ggfs");
+
+        IgniteFsPath path = new IgniteFsPath("/someFile");
+
+        try (IgniteFsOutputStream out = ggfs.create(path, true)) {
+            // Write 10 groups.
+            for (int i = 0; i < 10 * GGFS_GROUP_SIZE; i++) {
+                byte[] data = new byte[GGFS_BLOCK_SIZE];
+
+                Arrays.fill(data, (byte)i);
+
+                out.write(data);
+            }
+        }
+
+        long start = System.currentTimeMillis();
+
+        do {
+            try (IgniteFsInputStream in = ggfs.open(path)) {
+                for (int i = 0; i < 10 * GGFS_GROUP_SIZE; i++) {
+                    for (int j = 0; j < GGFS_BLOCK_SIZE; j++)
+                        assertEquals(i & 0xFF, in.read());
+                }
+
+                assertEquals(-1, in.read());
+            }
+        }
+        while (System.currentTimeMillis() - start < 7000);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testAppendFragmentizing() throws Exception {
+        checkAppendFragmentizing(GGFS_BLOCK_SIZE / 4, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testAppendFragmentizingAligned() throws Exception {
+        checkAppendFragmentizing(GGFS_BLOCK_SIZE, false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testAppendFragmentizingDifferentNodes() throws Exception {
+        checkAppendFragmentizing(GGFS_BLOCK_SIZE / 4, true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testAppendFragmentizingAlignedDifferentNodes() throws Exception {
+        checkAppendFragmentizing(GGFS_BLOCK_SIZE, true);
+    }
+
+    /**
+    * @throws Exception If failed.
+    */
+    private void checkAppendFragmentizing(int chunkSize, boolean rotate) throws Exception
{
+        IgniteFsPath path = new IgniteFsPath("/someFile");
+
+        long written = 0;
+
+        int i = 0;
+        int ggfsIdx = 0;
+
+        int fileSize = 30 * GGFS_GROUP_SIZE * GGFS_BLOCK_SIZE;
+
+        while (written < fileSize) {
+            IgniteFs ggfs = grid(ggfsIdx).fileSystem("ggfs");
+
+            try (IgniteFsOutputStream out = ggfs.append(path, true)) {
+                byte[] data = new byte[chunkSize];
+
+                Arrays.fill(data, (byte)i);
+
+                out.write(data);
+            }
+
+            System.out.println("Written [start=" + written + ", filler=" + i + ']');
+
+            written += chunkSize;
+            i++;
+
+            if (rotate && i % 5 == 0) {
+                ggfsIdx++;
+
+                if (ggfsIdx >= NODE_CNT)
+                    ggfsIdx = 0;
+            }
+        }
+
+        IgniteFs ggfs = grid(0).fileSystem("ggfs");
+
+        try (IgniteFsInputStream in = ggfs.open(path)) {
+            i = 0;
+
+            int read = 0;
+
+            byte[] chunk = new byte[chunkSize];
+
+            while (read < fileSize) {
+                readFully(in, chunk);
+
+                for (byte b : chunk)
+                    assertEquals("For read offset [start=" + read + ", filler=" + (i &
0xFF) + ']',
+                        i & 0xFF, b & 0xFF);
+
+                i++;
+
+                read += chunkSize;
+            }
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFlushFragmentizing() throws Exception {
+        checkFlushFragmentizing(GGFS_BLOCK_SIZE / 4);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFlushFragmentizingAligned() throws Exception {
+        checkFlushFragmentizing(GGFS_BLOCK_SIZE);
+    }
+
+    /**
+     * @param chunkSize Chunk size to test.
+     * @throws Exception If failed.
+     */
+    private void checkFlushFragmentizing(int chunkSize) throws Exception {
+        IgniteFsPath path = new IgniteFsPath("/someFile");
+
+        long written = 0;
+        int cnt = 0;
+
+        int fileSize = 50 * GGFS_GROUP_SIZE * GGFS_BLOCK_SIZE;
+
+        IgniteFs ggfs = grid(0).fileSystem("ggfs");
+
+        byte[] chunk = new byte[chunkSize];
+
+        while (written < fileSize) {
+            try (IgniteFsOutputStream out = ggfs.append(path, true)) {
+                for (int i = 0; i < 8; i++) {
+                    Arrays.fill(chunk, (byte)cnt);
+
+                    out.write(chunk);
+
+                    out.flush();
+
+                    written += chunkSize;
+
+                    cnt++;
+                }
+            }
+        }
+
+        try (IgniteFsInputStream in = ggfs.open(path)) {
+            cnt = 0;
+
+            int read = 0;
+
+            while (read < fileSize) {
+                readFully(in, chunk);
+
+                for (byte b : chunk)
+                    assertEquals("For read offset [start=" + read + ", filler=" + (cnt &
0xFF) + ']',
+                        cnt & 0xFF, b & 0xFF);
+
+                cnt++;
+
+                read += chunkSize;
+            }
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testDeleteFragmentizing() throws Exception {
+        IgfsImpl ggfs = (IgfsImpl)grid(0).fileSystem("ggfs");
+
+        for (int i = 0; i < 30; i++) {
+            IgniteFsPath path = new IgniteFsPath("/someFile" + i);
+
+            try (IgniteFsOutputStream out = ggfs.create(path, true)) {
+                for (int j = 0; j < 5 * GGFS_GROUP_SIZE; j++)
+                    out.write(new byte[GGFS_BLOCK_SIZE]);
+            }
+
+            U.sleep(200);
+        }
+
+        ggfs.delete(new IgniteFsPath("/"), true);
+
+        ggfs.awaitDeletesAsync().get();
+
+        GridTestUtils.retryAssert(log, 50, 100, new CA() {
+            @Override public void apply() {
+                for (int i = 0; i < NODE_CNT; i++) {
+                    IgniteEx g = grid(i);
+
+                    GridCache<Object, Object> cache = g.cachex(DATA_CACHE_NAME);
+
+                    assertTrue("Data cache is not empty [keys=" + cache.keySet() +
+                        ", node=" + g.localNode().id() + ']', cache.isEmpty());
+                }
+            }
+        });
+    }
+
+    /**
+     * @param in Input stream to read from.
+     * @param data Byte array to read to.
+     * @throws IOException If read failed.
+     */
+    private static void readFully(InputStream in, byte[] data) throws IOException {
+        int read = 0;
+
+        while(read < data.length)
+            read += in.read(data, read, data.length - read);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/915f997d/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerTopologySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerTopologySelfTest.java
new file mode 100644
index 0000000..94f78e5
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsFragmentizerTopologySelfTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.ignitefs;
+
+import org.apache.ignite.*;
+
+/**
+ * Tests coordinator transfer from one node to other.
+ */
+public class IgfsFragmentizerTopologySelfTest extends IgfsFragmentizerAbstractSelfTest {
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCoordinatorLeave() throws Exception {
+        stopGrid(0);
+
+        // Now node 1 should be coordinator.
+        try {
+            IgniteFsPath path = new IgniteFsPath("/someFile");
+
+            IgniteFs ggfs = grid(1).fileSystem("ggfs");
+
+            try (IgniteFsOutputStream out = ggfs.create(path, true)) {
+                for (int i = 0; i < 10 * GGFS_GROUP_SIZE; i++)
+                    out.write(new byte[GGFS_BLOCK_SIZE]);
+            }
+
+            awaitFileFragmenting(1, path);
+        }
+        finally {
+            startGrid(0);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/915f997d/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsPathSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsPathSelfTest.java b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsPathSelfTest.java
new file mode 100644
index 0000000..5a9e0c6
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsPathSelfTest.java
@@ -0,0 +1,162 @@
+/*
+ * 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.ignitefs;
+
+import org.apache.ignite.*;
+import org.apache.ignite.marshaller.*;
+import org.apache.ignite.marshaller.optimized.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+import org.jetbrains.annotations.*;
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+/**
+ * {@link org.apache.ignite.ignitefs.IgniteFsPath} self test.
+ */
+public class IgfsPathSelfTest extends GridCommonAbstractTest {
+    /** Marshaller to test {@link Externalizable} interface. */
+    private final Marshaller marshaller = new OptimizedMarshaller();
+
+    /**
+     * Test public methods of ggfs path.
+     *
+     * @throws Exception In case of any exception.
+     */
+    public void testMethods() throws Exception {
+        IgniteFsPath path = new IgniteFsPath("/a/s/d/f");
+
+        validateParent("/a/s/d/f", "/a/s/d");
+        validateParent("/a/s/d", "/a/s");
+        validateParent("/a/s", "/a");
+        validateParent("/a", "/");
+        validateParent("/", null);
+
+        assertEquals(new IgniteFsPath("/a/s/d/f-2"), path.suffix("-2"));
+        assertEquals(Arrays.asList("a", "s", "d", "f"), path.components());
+        assertEquals(4, path.depth());
+        assertEquals(3, path.parent().depth());
+        assertEquals("f", path.name());
+
+        assertEquals(path, mu(path));
+
+        IgniteFsPath parent = path.parent();
+
+        assertTrue(path.compareTo(new IgniteFsPath(parent, "e")) > 0);
+        assertTrue(path.compareTo(new IgniteFsPath(parent, "g")) < 0);
+    }
+
+    /**
+     * Validate parent resolution is correct.
+     *
+     * @param child Child path.
+     * @param parent Expected parent path.
+     */
+    private void validateParent(String child, @Nullable String parent) {
+        assertEquals(parent == null ? null : new IgniteFsPath(parent), new IgniteFsPath(child).parent());
+    }
+
+    /**
+     * Marshal/unmarshal object.
+     *
+     * @param obj Object to marshal/unmarshal.
+     * @return Marshalled and then unmarshalled object.
+     * @throws IgniteCheckedException In case of any marshalling exception.
+     */
+    private <T> T mu(T obj) throws IgniteCheckedException {
+        return marshaller.unmarshal(marshaller.marshal(obj), null);
+    }
+
+    /**
+     * Test ggfs path constructors.
+     *
+     * @throws Exception In case of any exception.
+     */
+    @SuppressWarnings("TooBroadScope")
+    public void testConstructors() throws Exception {
+        String pathStr = "///";
+        URI uri = URI.create(pathStr);
+        IgniteFsPath path = new IgniteFsPath(uri);
+
+        assertNotNull(new IgniteFsPath(uri));
+        assertNotNull(new IgniteFsPath(pathStr));
+        assertNotNull(new IgniteFsPath("/"));
+        assertNotNull(new IgniteFsPath(path, pathStr));
+        assertNotNull(new IgniteFsPath());
+
+        Class nullUri = URI.class;
+        Class nullStr = String.class;
+        Class nullPath = IgniteFsPath.class;
+
+        expectConstructorThrows(NullPointerException.class, nullUri);
+        expectConstructorThrows(IllegalArgumentException.class, nullStr);
+        expectConstructorThrows(IllegalArgumentException.class, nullStr, nullStr, nullStr);
+        expectConstructorThrows(NullPointerException.class, nullPath, nullStr);
+        expectConstructorThrows(NullPointerException.class, nullPath, nullUri);
+
+        String name = "with space in path.txt";
+
+        assertEquals(name, new IgniteFsPath(path, name).name());
+    }
+
+    /**
+     * Validate ggfs path constructor fails with specified exception.
+     *
+     * @param cls Expected exception.
+     * @param args Constructor arguments. Null-values are passed as Class instancies: null-string
=> String.class.
+     */
+    private void expectConstructorThrows(Class<? extends Exception> cls, final Object...
args) {
+        final Class<?>[] paramTypes = new Class[args.length];
+
+        for (int i = 0, size = args.length; i < size; i++) {
+            Object arg = args[i];
+
+            if (arg instanceof Class) {
+                paramTypes[i] = (Class)arg;
+                args[i] = null; // Reset argument of specified type to null.
+            }
+            else
+                paramTypes[i] = arg.getClass();
+        }
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                try {
+                    Constructor<IgniteFsPath> constructor = IgniteFsPath.class.getConstructor(paramTypes);
+
+                    constructor.newInstance(args);
+                }
+                catch (InvocationTargetException e) {
+                    Throwable cause = e.getCause();
+
+                    // Unwrap invocation target exception.
+                    if (cause instanceof Exception)
+                        throw (Exception)cause;
+
+                    throw e;
+                }
+
+                return null;
+            }
+        }, cls, null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/915f997d/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsTestInputGenerator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsTestInputGenerator.java
b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsTestInputGenerator.java
new file mode 100644
index 0000000..dc0ee7f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/ignitefs/IgfsTestInputGenerator.java
@@ -0,0 +1,51 @@
+/*
+ * 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.ignitefs;
+
+import java.io.*;
+
+/**
+ *
+ */
+public class IgfsTestInputGenerator {
+    public static void main(String[] args) throws IOException {
+        if (args.length != 2) {
+            System.out.println("Run: GridGgfsTestInputGenerator <file name> <length>");
+            System.exit(-1);
+        }
+
+        String outFileName = args[0];
+
+        long len = Long.parseLong(args[1]);
+
+        long start = System.currentTimeMillis();
+
+        OutputStream out = new BufferedOutputStream(new FileOutputStream(outFileName), 32*1024*1024);
+
+        for (long i = 0; i < len; i++)
+                out.write(read(i));
+
+        out.close();
+
+        System.out.println("Finished in: " + (System.currentTimeMillis() - start));
+    }
+
+    private static int read(long pos) {
+        return (int)(pos % 116) + 10;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/915f997d/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/IgfsSizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/IgfsSizeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/IgfsSizeSelfTest.java
index ebeed32..880163d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/IgfsSizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/fs/IgfsSizeSelfTest.java
@@ -315,13 +315,13 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         }
 
         // Perform writes.
-        Collection<GgfsFile> files = write();
+        Collection<IgfsFile> files = write();
 
         // Check sizes.
         Map<UUID, Integer> expSizes = new HashMap<>(GRID_CNT, 1.0f);
 
-        for (GgfsFile file : files) {
-            for (GgfsBlock block : file.blocks()) {
+        for (IgfsFile file : files) {
+            for (IgfsBlock block : file.blocks()) {
                 Collection<UUID> ids = primaryOrBackups(block.key());
 
                 for (UUID id : ids) {
@@ -346,7 +346,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         // Perform reads which could potentially be non-local.
         byte[] buf = new byte[BLOCK_SIZE];
 
-        for (GgfsFile file : files) {
+        for (IgfsFile file : files) {
             for (int i = 0; i < GRID_CNT; i++) {
                 int total = 0;
 
@@ -385,7 +385,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
             // All data must exist on each cache.
             int totalSize = 0;
 
-            for (GgfsFile file : files)
+            for (IgfsFile file : files)
                 totalSize += file.length();
 
             for (int i = 0; i < GRID_CNT; i++) {
@@ -398,11 +398,11 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         }
 
         // Delete data and ensure that all counters are 0 now.
-        for (GgfsFile file : files) {
+        for (IgfsFile file : files) {
             ggfs(0).delete(file.path(), false);
 
             // Await for actual delete to occur.
-            for (GgfsBlock block : file.blocks()) {
+            for (IgfsBlock block : file.blocks()) {
                 for (int i = 0; i < GRID_CNT; i++) {
                     while (cache(grid(i).localNode().id()).peek(block.key()) != null)
                         U.sleep(100);
@@ -567,13 +567,13 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         startUp();
 
         // Perform writes.
-        Collection<GgfsFile> files = write();
+        Collection<IgfsFile> files = write();
 
         // Check sizes.
         Map<UUID, Integer> expSizes = new HashMap<>(GRID_CNT, 1.0f);
 
-        for (GgfsFile file : files) {
-            for (GgfsBlock block : file.blocks()) {
+        for (IgfsFile file : files) {
+            for (IgfsBlock block : file.blocks()) {
                 Collection<UUID> ids = primaryOrBackups(block.key());
 
                 for (UUID id : ids) {
@@ -622,8 +622,8 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         // Check sizes again.
         expSizes.clear();
 
-        for (GgfsFile file : files) {
-            for (GgfsBlock block : file.blocks()) {
+        for (IgfsFile file : files) {
+            for (IgfsBlock block : file.blocks()) {
                 Collection<UUID> ids = primaryOrBackups(block.key());
 
                 assert !ids.isEmpty();
@@ -756,8 +756,8 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
      * @return Collection of written file descriptors.
      * @throws Exception If failed.
      */
-    private Collection<GgfsFile> write() throws Exception {
-        Collection<GgfsFile> res = new HashSet<>(FILES_CNT, 1.0f);
+    private Collection<IgfsFile> write() throws Exception {
+        Collection<IgfsFile> res = new HashSet<>(FILES_CNT, 1.0f);
 
         ThreadLocalRandom8 rand = ThreadLocalRandom8.current();
 
@@ -777,18 +777,18 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
             int fullBlocks = fileSize / BLOCK_SIZE;
             int remainderSize = fileSize % BLOCK_SIZE;
 
-            Collection<GgfsBlock> blocks = new ArrayList<>(fullBlocks + remainderSize
> 0 ? 1 : 0);
+            Collection<IgfsBlock> blocks = new ArrayList<>(fullBlocks + remainderSize
> 0 ? 1 : 0);
 
             for (int j = 0; j < fullBlocks; j++)
-                blocks.add(new GgfsBlock(new IgfsBlockKey(fileId, null, true, j), BLOCK_SIZE));
+                blocks.add(new IgfsBlock(new IgfsBlockKey(fileId, null, true, j), BLOCK_SIZE));
 
             if (remainderSize > 0)
-                blocks.add(new GgfsBlock(new IgfsBlockKey(fileId, null, true, fullBlocks),
remainderSize));
+                blocks.add(new IgfsBlock(new IgfsBlockKey(fileId, null, true, fullBlocks),
remainderSize));
 
-            GgfsFile file = new GgfsFile(path, fileSize, blocks);
+            IgfsFile file = new IgfsFile(path, fileSize, blocks);
 
             // Actual write.
-            for (GgfsBlock block : blocks) {
+            for (IgfsBlock block : blocks) {
                 IgniteFsOutputStream os = ggfs(0).append(path, false);
 
                 os.write(chunk(block.length()));
@@ -804,7 +804,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
     }
 
     /** A file written to the file system. */
-    private static class GgfsFile {
+    private static class IgfsFile {
         /** Path to the file, */
         private final IgniteFsPath path;
 
@@ -812,7 +812,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         private final int len;
 
         /** Blocks with their corresponding locations. */
-        private final Collection<GgfsBlock> blocks;
+        private final Collection<IgfsBlock> blocks;
 
         /**
          * Constructor.
@@ -821,7 +821,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
          * @param len Length.
          * @param blocks Blocks.
          */
-        private GgfsFile(IgniteFsPath path, int len, Collection<GgfsBlock> blocks)
{
+        private IgfsFile(IgniteFsPath path, int len, Collection<IgfsBlock> blocks)
{
             this.path = path;
             this.len = len;
             this.blocks = blocks;
@@ -838,13 +838,13 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
         }
 
         /** @return Blocks. */
-        Collection<GgfsBlock> blocks() {
+        Collection<IgfsBlock> blocks() {
             return blocks;
         }
     }
 
     /** Block written to the file system. */
-    private static class GgfsBlock {
+    private static class IgfsBlock {
         /** Block key. */
         private final IgfsBlockKey key;
 
@@ -857,7 +857,7 @@ public class IgfsSizeSelfTest extends IgfsCommonAbstractTest {
          * @param key Block key.
          * @param len Block length.
          */
-        private GgfsBlock(IgfsBlockKey key, int len) {
+        private IgfsBlock(IgfsBlockKey key, int len) {
             this.key = key;
             this.len = len;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/915f997d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteFsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteFsTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteFsTestSuite.java
index 7cbac79..41996d9 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteFsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteFsTestSuite.java
@@ -61,8 +61,8 @@ public class IgniteFsTestSuite extends TestSuite {
 
         suite.addTest(new TestSuite(IgfsModeResolverSelfTest.class));
 
-        suite.addTestSuite(GridGgfsFragmentizerSelfTest.class);
-        suite.addTestSuite(GridGgfsFragmentizerTopologySelfTest.class);
+        suite.addTestSuite(IgfsFragmentizerSelfTest.class);
+        suite.addTestSuite(IgfsFragmentizerTopologySelfTest.class);
         suite.addTestSuite(IgfsFileMapSelfTest.class);
 
         suite.addTestSuite(IgfsByteDelimiterRecordResolverSelfTest.class);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/915f997d/modules/hadoop/src/test/java/org/apache/ignite/ignitefs/IgniteFsEventsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hadoop/src/test/java/org/apache/ignite/ignitefs/IgniteFsEventsTestSuite.java
b/modules/hadoop/src/test/java/org/apache/ignite/ignitefs/IgniteFsEventsTestSuite.java
index a040dcc..2d07e9d 100644
--- a/modules/hadoop/src/test/java/org/apache/ignite/ignitefs/IgniteFsEventsTestSuite.java
+++ b/modules/hadoop/src/test/java/org/apache/ignite/ignitefs/IgniteFsEventsTestSuite.java
@@ -74,7 +74,7 @@ public class IgniteFsEventsTestSuite extends TestSuite {
     /**
      * Shared memory IPC in PRIVATE mode.
      */
-    public static class ShmemPrivate extends GridGgfsEventsAbstractSelfTest {
+    public static class ShmemPrivate extends IgfsEventsAbstractSelfTest {
         /** {@inheritDoc} */
         @Override protected IgniteFsConfiguration getGgfsConfiguration() throws IgniteCheckedException
{
             IgniteFsConfiguration ggfsCfg = super.getGgfsConfiguration();
@@ -91,7 +91,7 @@ public class IgniteFsEventsTestSuite extends TestSuite {
     /**
      * Loopback socket IPS in PRIVATE mode.
      */
-    public static class LoopbackPrivate extends GridGgfsEventsAbstractSelfTest {
+    public static class LoopbackPrivate extends IgfsEventsAbstractSelfTest {
         /** {@inheritDoc} */
         @Override protected IgniteFsConfiguration getGgfsConfiguration() throws IgniteCheckedException
{
             IgniteFsConfiguration ggfsCfg = super.getGgfsConfiguration();
@@ -108,7 +108,7 @@ public class IgniteFsEventsTestSuite extends TestSuite {
     /**
      * Base class for all GGFS tests with primary and secondary file system.
      */
-    public abstract static class PrimarySecondaryTest extends GridGgfsEventsAbstractSelfTest
{
+    public abstract static class PrimarySecondaryTest extends IgfsEventsAbstractSelfTest
{
         /** Secondary file system. */
         private static IgniteFs ggfsSec;
 


Mime
View raw message