Search in sources :

Example 21 with IgniteFileSystem

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

the class IgfsMetricsSelfTest method testMetrics.

/**
 * @throws Exception If failed.
 */
public void testMetrics() throws Exception {
    IgniteFileSystem fs = igfsPrimary[0];
    assertNotNull(fs);
    IgfsMetrics m = fs.metrics();
    assertNotNull(m);
    assertEquals(0, m.directoriesCount());
    assertEquals(0, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
    fs.mkdirs(new IgfsPath("/primary/dir1"));
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(2, m.directoriesCount());
    assertEquals(0, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
    fs.mkdirs(new IgfsPath("/primary/dir1/dir2/dir3"));
    fs.mkdirs(new IgfsPath("/primary/dir4"));
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(5, m.directoriesCount());
    assertEquals(0, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
    IgfsOutputStream out1 = fs.create(new IgfsPath("/primary/dir1/file1"), false);
    IgfsOutputStream out2 = fs.create(new IgfsPath("/primary/dir1/file2"), false);
    IgfsOutputStream out3 = fs.create(new IgfsPath("/primary/dir1/dir2/file"), false);
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(5, m.directoriesCount());
    assertEquals(3, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(3, m.filesOpenedForWrite());
    out1.write(new byte[10]);
    out2.write(new byte[20]);
    out3.write(new byte[30]);
    out1.close();
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(5, m.directoriesCount());
    assertEquals(3, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(2, m.filesOpenedForWrite());
    out2.close();
    out3.close();
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(5, m.directoriesCount());
    assertEquals(3, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
    IgfsOutputStream out = fs.append(new IgfsPath("/primary/dir1/file1"), false);
    out.write(new byte[20]);
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(5, m.directoriesCount());
    assertEquals(3, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(1, m.filesOpenedForWrite());
    out.write(new byte[20]);
    out.close();
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(5, m.directoriesCount());
    assertEquals(3, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
    IgfsInputStream in1 = fs.open(new IgfsPath("/primary/dir1/file1"));
    IgfsInputStream in2 = fs.open(new IgfsPath("/primary/dir1/file2"));
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(5, m.directoriesCount());
    assertEquals(3, m.filesCount());
    assertEquals(2, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
    in1.close();
    in2.close();
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(5, m.directoriesCount());
    assertEquals(3, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
    fs.delete(new IgfsPath("/primary/dir1/file1"), false);
    fs.delete(new IgfsPath("/primary/dir1/dir2"), true);
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(3, m.directoriesCount());
    assertEquals(1, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
    fs.clear();
    m = fs.metrics();
    assertNotNull(m);
    assertEquals(0, m.directoriesCount());
    assertEquals(0, m.filesCount());
    assertEquals(0, m.filesOpenedForRead());
    assertEquals(0, m.filesOpenedForWrite());
}
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)

Example 22 with IgniteFileSystem

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

the class IgniteHadoopFileSystemHandshakeSelfTest method startUp.

/**
 * Perform startup.
 *
 * @param dfltIgniteInstanceName Default Ignite instance name.
 * @param dfltIgfsName Default IGFS name.
 * @throws Exception If failed.
 */
private void startUp(boolean dfltIgniteInstanceName, boolean dfltIgfsName) throws Exception {
    Ignite ignite = G.start(gridConfiguration(dfltIgniteInstanceName));
    IgniteFileSystem igfs = ignite.fileSystem(dfltIgfsName ? "" : IGFS_NAME);
    igfs.mkdirs(PATH);
}
Also used : Ignite(org.apache.ignite.Ignite) IgniteFileSystem(org.apache.ignite.IgniteFileSystem)

Example 23 with IgniteFileSystem

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

the class HadoopExternalTaskExecutionSelfTest method prepareTestFile.

/**
 * @param filePath File path to prepare.
 * @throws Exception If failed.
 */
private void prepareTestFile(String filePath) throws Exception {
    IgniteFileSystem igfs = grid(0).fileSystem(igfsName);
    try (IgfsOutputStream out = igfs.create(new IgfsPath(filePath), true)) {
        PrintWriter wr = new PrintWriter(new OutputStreamWriter(out));
        for (int i = 0; i < 1000; i++) wr.println("Hello, world: " + i);
        wr.flush();
    }
}
Also used : IgfsPath(org.apache.ignite.igfs.IgfsPath) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) OutputStreamWriter(java.io.OutputStreamWriter) IgfsOutputStream(org.apache.ignite.igfs.IgfsOutputStream) PrintWriter(java.io.PrintWriter)

Example 24 with IgniteFileSystem

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

the class IgniteHadoopFileSystemAbstractSelfTest 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(PRIMARY_URI);
        Path file = new Path(igfsHome, "someFile");
        try (FSDataOutputStream out = fs.create(file, (short) 0)) {
            out.write(new byte[1024 * 1024]);
        }
        IgniteFileSystem igfs = grid(0).fileSystem("igfs");
        IgfsPath filePath = new IgfsPath("/someFile");
        IgfsFile fileInfo = igfs.info(filePath);
        awaitPartitionMapExchange();
        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) 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 25 with IgniteFileSystem

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

the class HadoopIgfs20FileSystemAbstractSelfTest method testStatus.

/**
 * @throws Exception If failed.
 */
public void testStatus() throws Exception {
    Path file1 = new Path("/file1");
    try (FSDataOutputStream file = fs.create(file1, EnumSet.noneOf(CreateFlag.class), Options.CreateOpts.perms(FsPermission.getDefault()))) {
        file.write(new byte[1024 * 1024]);
    }
    FsStatus status = fs.getFsStatus();
    assertEquals(getClientFsUser(), fs.getFileStatus(file1).getOwner());
    assertEquals(4, grid(0).cluster().nodes().size());
    long used = 0, max = 0;
    for (int i = 0; i < 4; i++) {
        IgniteFileSystem igfs = grid(i).fileSystem("igfs");
        IgfsMetrics metrics = igfs.metrics();
        used += metrics.localSpaceSize();
        max += metrics.maxSpaceSize();
    }
    assertEquals(used, status.getUsed());
    assertEquals(max, status.getCapacity());
}
Also used : Path(org.apache.hadoop.fs.Path) IgfsPath(org.apache.ignite.igfs.IgfsPath) CreateFlag(org.apache.hadoop.fs.CreateFlag) IgfsMetrics(org.apache.ignite.igfs.IgfsMetrics) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) FsStatus(org.apache.hadoop.fs.FsStatus)

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