Search in sources :

Example 6 with IgniteFileSystem

use of org.apache.ignite.IgniteFileSystem in project ignite by apache.

the class IgfsProcessorSelfTest method testigfsEnabled.

/**
 * @throws Exception If failed.
 */
public void testigfsEnabled() throws Exception {
    IgniteFileSystem igfs = grid(0).fileSystem(igfsName());
    assertNotNull(igfs);
}
Also used : IgniteFileSystem(org.apache.ignite.IgniteFileSystem)

Example 7 with IgniteFileSystem

use of org.apache.ignite.IgniteFileSystem in project ignite by apache.

the class HadoopIgfs20FileSystemAbstractSelfTest method testZeroReplicationFactor.

/**
 * @throws Exception If failed.
 */
public void testZeroReplicationFactor() throws Exception {
    // This test doesn't make sense for any mode except of PRIMARY.
    if (mode == PRIMARY) {
        Path igfsHome = new Path(primaryFsUri);
        Path file = new Path(igfsHome, "someFile");
        try (FSDataOutputStream out = fs.create(file, EnumSet.noneOf(CreateFlag.class), Options.CreateOpts.perms(FsPermission.getDefault()), Options.CreateOpts.repFac((short) 1))) {
            out.write(new byte[1024 * 1024]);
        }
        IgniteFileSystem igfs = grid(0).fileSystem("igfs");
        IgfsPath filePath = new IgfsPath("/someFile");
        IgfsFile fileInfo = igfs.info(filePath);
        Collection<IgfsBlockLocation> locations = igfs.affinity(filePath, 0, fileInfo.length());
        assertEquals(1, locations.size());
        IgfsBlockLocation location = F.first(locations);
        assertEquals(1, location.nodeIds().size());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) IgfsPath(org.apache.ignite.igfs.IgfsPath) CreateFlag(org.apache.hadoop.fs.CreateFlag) IgfsPath(org.apache.ignite.igfs.IgfsPath) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) IgfsBlockLocation(org.apache.ignite.igfs.IgfsBlockLocation) IgfsFile(org.apache.ignite.igfs.IgfsFile)

Example 8 with IgniteFileSystem

use of org.apache.ignite.IgniteFileSystem in project ignite by apache.

the class IgfsFragmentizerSelfTest method testReadFragmentizing.

/**
 * @throws Exception If failed.
 */
public void testReadFragmentizing() throws Exception {
    IgniteFileSystem igfs = grid(0).fileSystem("igfs");
    IgfsPath path = new IgfsPath("/someFile");
    try (IgfsOutputStream out = igfs.create(path, true)) {
        // Write 10 groups.
        for (int i = 0; i < 10 * IGFS_GROUP_SIZE; i++) {
            byte[] data = new byte[IGFS_BLOCK_SIZE];
            Arrays.fill(data, (byte) i);
            out.write(data);
        }
    }
    long start = System.currentTimeMillis();
    do {
        try (IgfsInputStream in = igfs.open(path)) {
            for (int i = 0; i < 10 * IGFS_GROUP_SIZE; i++) {
                for (int j = 0; j < IGFS_BLOCK_SIZE; j++) assertEquals(i & 0xFF, in.read());
            }
            assertEquals(-1, in.read());
        }
    } while (System.currentTimeMillis() - start < 7000);
}
Also used : IgniteFileSystem(org.apache.ignite.IgniteFileSystem)

Example 9 with IgniteFileSystem

use of org.apache.ignite.IgniteFileSystem in project ignite by apache.

the class IgfsFragmentizerSelfTest method checkAppendFragmentizing.

/**
 * @throws Exception If failed.
 */
private void checkAppendFragmentizing(int chunkSize, boolean rotate) throws Exception {
    IgfsPath path = new IgfsPath("/someFile");
    long written = 0;
    int i = 0;
    int igfsIdx = 0;
    int fileSize = 30 * IGFS_GROUP_SIZE * IGFS_BLOCK_SIZE;
    while (written < fileSize) {
        IgniteFileSystem igfs = grid(igfsIdx).fileSystem("igfs");
        try (IgfsOutputStream out = igfs.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) {
            igfsIdx++;
            if (igfsIdx >= NODE_CNT)
                igfsIdx = 0;
        }
    }
    IgniteFileSystem igfs = grid(0).fileSystem("igfs");
    try (IgfsInputStream in = igfs.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;
        }
    }
}
Also used : IgniteFileSystem(org.apache.ignite.IgniteFileSystem)

Example 10 with IgniteFileSystem

use of org.apache.ignite.IgniteFileSystem in project ignite by apache.

the class HadoopClientProtocolMultipleServersSelfTest method beforeJob.

/**
 * @throws Exception If failed.
 */
private void beforeJob() throws Exception {
    IgniteFileSystem igfs = grid(0).fileSystem(HadoopAbstractSelfTest.igfsName);
    igfs.clear();
    igfs.mkdirs(new IgfsPath(PATH_INPUT));
    try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(igfs.create(new IgfsPath(PATH_INPUT + "/test.file"), true)))) {
        bw.write("word");
    }
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter)

Aggregations

IgniteFileSystem (org.apache.ignite.IgniteFileSystem)26 IgfsPath (org.apache.ignite.igfs.IgfsPath)14 OutputStreamWriter (java.io.OutputStreamWriter)6 Ignite (org.apache.ignite.Ignite)6 Path (org.apache.hadoop.fs.Path)5 BufferedWriter (java.io.BufferedWriter)4 IgfsInputStream (org.apache.ignite.igfs.IgfsInputStream)4 IgfsOutputStream (org.apache.ignite.igfs.IgfsOutputStream)4 IOException (java.io.IOException)3 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)3 IgniteException (org.apache.ignite.IgniteException)3 IgfsBlockLocation (org.apache.ignite.igfs.IgfsBlockLocation)3 IgfsFile (org.apache.ignite.igfs.IgfsFile)3 IgfsMetrics (org.apache.ignite.igfs.IgfsMetrics)3 PrintWriter (java.io.PrintWriter)2 Configuration (org.apache.hadoop.conf.Configuration)2 CreateFlag (org.apache.hadoop.fs.CreateFlag)2 Job (org.apache.hadoop.mapreduce.Job)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 IgfsProcessorAdapter (org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter)2