Search in sources :

Example 16 with IgniteFileSystem

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

the class IgfsFragmentizerSelfTest method checkFlushFragmentizing.

/**
 * @param chunkSize Chunk size to test.
 * @throws Exception If failed.
 */
private void checkFlushFragmentizing(int chunkSize) throws Exception {
    IgfsPath path = new IgfsPath("/someFile");
    long written = 0;
    int cnt = 0;
    int fileSize = 50 * IGFS_GROUP_SIZE * IGFS_BLOCK_SIZE;
    IgniteFileSystem igfs = grid(0).fileSystem("igfs");
    byte[] chunk = new byte[chunkSize];
    while (written < fileSize) {
        try (IgfsOutputStream out = igfs.append(path, true)) {
            for (int i = 0; i < 8; i++) {
                Arrays.fill(chunk, (byte) cnt);
                out.write(chunk);
                out.flush();
                written += chunkSize;
                cnt++;
            }
        }
    }
    try (IgfsInputStream in = igfs.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;
        }
    }
}
Also used : IgniteFileSystem(org.apache.ignite.IgniteFileSystem)

Example 17 with IgniteFileSystem

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

the class IgfsFragmentizerTopologySelfTest method testCoordinatorLeave.

/**
 * @throws Exception If failed.
 */
public void testCoordinatorLeave() throws Exception {
    stopGrid(0);
    // Now node 1 should be coordinator.
    try {
        IgfsPath path = new IgfsPath("/someFile");
        IgniteFileSystem igfs = grid(1).fileSystem("igfs");
        try (IgfsOutputStream out = igfs.create(path, true)) {
            for (int i = 0; i < 10 * IGFS_GROUP_SIZE; i++) out.write(new byte[IGFS_BLOCK_SIZE]);
        }
        awaitFileFragmenting(1, path);
    } finally {
        startGrid(0);
    }
}
Also used : IgniteFileSystem(org.apache.ignite.IgniteFileSystem)

Example 18 with IgniteFileSystem

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

the class VisorNodeDataCollectorJob method igfs.

/**
 * Collect IGFSs.
 *
 * @param res Job result.
 */
protected void igfs(VisorNodeDataCollectorJobResult res) {
    try {
        IgfsProcessorAdapter igfsProc = ignite.context().igfs();
        for (IgniteFileSystem igfs : igfsProc.igfss()) {
            long start0 = U.currentTimeMillis();
            FileSystemConfiguration igfsCfg = igfs.configuration();
            if (proxyCache(igfsCfg.getDataCacheConfiguration().getName()) || proxyCache(igfsCfg.getMetaCacheConfiguration().getName()))
                continue;
            try {
                Collection<IpcServerEndpoint> endPoints = igfsProc.endpoints(igfs.name());
                if (endPoints != null) {
                    for (IpcServerEndpoint ep : endPoints) if (ep.isManagement())
                        res.getIgfsEndpoints().add(new VisorIgfsEndpoint(igfs.name(), ignite.name(), ep.getHost(), ep.getPort()));
                }
                res.getIgfss().add(new VisorIgfs(igfs));
            } finally {
                if (debug)
                    log(ignite.log(), "Collected IGFS: " + igfs.name(), getClass(), start0);
            }
        }
    } catch (Exception e) {
        res.setIgfssEx(new VisorExceptionWrapper(e));
    }
}
Also used : IgfsProcessorAdapter(org.apache.ignite.internal.processors.igfs.IgfsProcessorAdapter) IpcServerEndpoint(org.apache.ignite.internal.util.ipc.IpcServerEndpoint) VisorIgfsEndpoint(org.apache.ignite.internal.visor.igfs.VisorIgfsEndpoint) VisorIgfs(org.apache.ignite.internal.visor.igfs.VisorIgfs) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) VisorExceptionWrapper(org.apache.ignite.internal.visor.util.VisorExceptionWrapper) FileSystemConfiguration(org.apache.ignite.configuration.FileSystemConfiguration)

Example 19 with IgniteFileSystem

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

the class IgfsJobImpl method execute.

/**
 * {@inheritDoc}
 */
@Override
public Object execute() {
    IgniteFileSystem fs = ignite.fileSystem(igfsName);
    try (IgfsInputStream in = fs.open(path)) {
        IgfsFileRange split = new IgfsFileRange(path, start, len);
        if (rslvr != null) {
            split = rslvr.resolveRecords(fs, in, split);
            if (split == null) {
                log.warning("No data found for split on local node after resolver is applied " + "[igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']');
                return null;
            }
        }
        in.seek(split.start());
        return job.execute(fs, new IgfsFileRange(path, split.start(), split.length()), in);
    } catch (IOException e) {
        throw new IgniteException("Failed to execute IGFS job for file split [igfsName=" + igfsName + ", path=" + path + ", start=" + start + ", len=" + len + ']', e);
    }
}
Also used : IgfsInputStream(org.apache.ignite.igfs.IgfsInputStream) IgfsFileRange(org.apache.ignite.igfs.mapreduce.IgfsFileRange) IgniteException(org.apache.ignite.IgniteException) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) IOException(java.io.IOException)

Example 20 with IgniteFileSystem

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

the class IgfsMetricsSelfTest method testMultipleClose.

/**
 * @throws Exception If failed.
 */
public void testMultipleClose() throws Exception {
    IgniteFileSystem fs = igfsPrimary[0];
    IgfsOutputStream out = fs.create(new IgfsPath("/primary/file"), false);
    out.close();
    out.close();
    IgfsInputStream in = fs.open(new IgfsPath("/primary/file"));
    in.close();
    in.close();
    IgfsMetrics m = fs.metrics();
    assertEquals(0, m.filesOpenedForWrite());
    assertEquals(0, m.filesOpenedForRead());
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) IgfsInputStream(org.apache.ignite.igfs.IgfsInputStream) IgfsMetrics(org.apache.ignite.igfs.IgfsMetrics) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) IgfsOutputStream(org.apache.ignite.igfs.IgfsOutputStream)

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