Search in sources :

Example 26 with IgniteFileSystem

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

the class IgfsBenchmark method main.

/**
 * @param args Commandline arguments
 */
public static void main(String[] args) {
    Ignition.setClientMode(Boolean.getBoolean("clientMode"));
    Ignite ignite = Ignition.start(System.getProperty("cfg", "default-config.xml"));
    int wormUpCount = Integer.getInteger("wormup", 2);
    int cycles = Integer.getInteger("cycles", 10);
    final IgfsBenchmark fsTest = new IgfsBenchmark(System.getProperty("testDir", "/test"), Integer.getInteger("depth", 3), Integer.getInteger("subDirs", 10), Integer.getInteger("files", 10), Integer.getInteger("fileSize", 8) * 1024);
    final IgniteFileSystem fs = ignite.fileSystem("igfs");
    try {
        for (int i = 0; i < wormUpCount; ++i) {
            System.out.println("Wormup #" + i + " / " + wormUpCount);
            fsTest.testWriteFile(fs);
            fsTest.testReadFile(fs);
            fsTest.testDeleteFile(fs);
        }
    } catch (Exception ex) {
        System.err.println("Wormup error");
        ex.printStackTrace(System.err);
        Ignition.stop(false);
        return;
    }
    List<Long> writeRes = new ArrayList<>(cycles);
    List<Long> readRes = new ArrayList<>(cycles);
    List<Long> infoRes = new ArrayList<>(cycles);
    List<Long> listRes = new ArrayList<>(cycles);
    List<Long> delRes = new ArrayList<>(cycles);
    try {
        for (int i = 0; i < cycles; ++i) {
            System.out.println("Benchmark cycle #" + i + " / " + cycles);
            writeRes.add(bench(new Runnable() {

                @Override
                public void run() {
                    fsTest.testWriteFile(fs);
                }
            }));
            readRes.add(bench(new Runnable() {

                @Override
                public void run() {
                    fsTest.testReadFile(fs);
                }
            }));
            infoRes.add(bench(new Runnable() {

                @Override
                public void run() {
                    fsTest.testInfoFile(fs);
                }
            }));
            listRes.add(bench(new Runnable() {

                @Override
                public void run() {
                    fsTest.testListPathFile(fs);
                }
            }));
            delRes.add(bench(new Runnable() {

                @Override
                public void run() {
                    fsTest.testDeleteFile(fs);
                }
            }));
        }
        System.out.println("\n");
        System.out.println("Write " + avg(writeRes) + " +/- " + stdDev(writeRes, avg(writeRes)));
        System.out.println("Read " + avg(readRes) + " +/- " + stdDev(readRes, avg(readRes)));
        System.out.println("Info " + avg(infoRes) + " +/- " + stdDev(infoRes, avg(infoRes)));
        System.out.println("List " + avg(listRes) + " +/- " + stdDev(listRes, avg(listRes)));
        System.out.println("Delete " + avg(delRes) + " +/- " + stdDev(delRes, avg(delRes)));
    } catch (Exception ex) {
        System.err.println("Benchmark error");
        ex.printStackTrace(System.err);
    } finally {
        Ignition.stop(false);
    }
}
Also used : ArrayList(java.util.ArrayList) Ignite(org.apache.ignite.Ignite) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) IgniteException(org.apache.ignite.IgniteException) IOException(java.io.IOException) IgfsPathNotFoundException(org.apache.ignite.igfs.IgfsPathNotFoundException)

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