Search in sources :

Example 1 with CrailConfiguration

use of org.apache.crail.conf.CrailConfiguration in project incubator-crail by apache.

the class CrailFsck method getLocations.

public void getLocations(String filename, long offset, long length) throws Exception {
    System.out.println("getLocations, filename " + filename + ", offset " + offset + ", len " + length);
    CrailConfiguration conf = new CrailConfiguration();
    CrailStore fs = CrailStore.newInstance(conf);
    CrailBlockLocation[] locations = fs.lookup(filename).get().getBlockLocations(offset, length);
    for (int i = 0; i < locations.length; i++) {
        System.out.println("location " + i + " : " + locations[i].toString());
    }
    fs.close();
}
Also used : CrailBlockLocation(org.apache.crail.CrailBlockLocation) CrailStore(org.apache.crail.CrailStore) CrailConfiguration(org.apache.crail.conf.CrailConfiguration)

Example 2 with CrailConfiguration

use of org.apache.crail.conf.CrailConfiguration in project incubator-crail by apache.

the class CrailFsck method ping.

public void ping() throws Exception {
    CrailConfiguration conf = new CrailConfiguration();
    CrailConstants.updateConstants(conf);
    CoreDataStore fs = new CoreDataStore(conf);
    fs.ping();
    fs.closeFileSystem();
}
Also used : CrailConfiguration(org.apache.crail.conf.CrailConfiguration) CoreDataStore(org.apache.crail.core.CoreDataStore)

Example 3 with CrailConfiguration

use of org.apache.crail.conf.CrailConfiguration in project incubator-crail by apache.

the class CrailFsck method blockStatistics.

public void blockStatistics(String filename) throws Exception {
    HashMap<String, AtomicInteger> stats = new HashMap<String, AtomicInteger>();
    CrailConfiguration conf = new CrailConfiguration();
    CrailStore fs = CrailStore.newInstance(conf);
    CrailNode node = fs.lookup(filename).get();
    if (node.getType() == CrailNodeType.DIRECTORY) {
        CrailDirectory directory = node.asDirectory();
        Iterator<String> iter = directory.listEntries();
        while (iter.hasNext()) {
            String path = iter.next();
            CrailFile child = fs.lookup(path).get().asFile();
            walkBlocks(stats, fs, child.getPath(), 0, child.getCapacity());
        }
    } else if (node.getType() == CrailNodeType.DATAFILE) {
        CrailFile file = node.asFile();
        walkBlocks(stats, fs, file.getPath(), 0, file.getCapacity());
    } else if (node.getType() == CrailNodeType.MULTIFILE) {
        CrailMultiFile directory = node.asMultiFile();
        Iterator<String> iter = directory.listEntries();
        while (iter.hasNext()) {
            String path = iter.next();
            CrailFile child = fs.lookup(path).get().asFile();
            walkBlocks(stats, fs, child.getPath(), 0, child.getCapacity());
        }
    }
    printStats(stats);
    fs.close();
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) CrailDirectory(org.apache.crail.CrailDirectory) CrailNode(org.apache.crail.CrailNode) CrailMultiFile(org.apache.crail.CrailMultiFile) CrailStore(org.apache.crail.CrailStore) CrailFile(org.apache.crail.CrailFile) CrailConfiguration(org.apache.crail.conf.CrailConfiguration)

Example 4 with CrailConfiguration

use of org.apache.crail.conf.CrailConfiguration in project incubator-crail by apache.

the class CrailFsck method createDirectory.

public void createDirectory(String filename, int storageClass, int locationClass) throws Exception {
    System.out.println("createDirectory, filename " + filename + ", storageClass " + storageClass + ", locationClass " + locationClass);
    CrailConfiguration conf = new CrailConfiguration();
    CrailStore fs = CrailStore.newInstance(conf);
    fs.create(filename, CrailNodeType.DIRECTORY, CrailStorageClass.get(storageClass), CrailLocationClass.get(locationClass), true).get().syncDir();
    fs.close();
}
Also used : CrailStore(org.apache.crail.CrailStore) CrailConfiguration(org.apache.crail.conf.CrailConfiguration)

Example 5 with CrailConfiguration

use of org.apache.crail.conf.CrailConfiguration in project incubator-crail by apache.

the class CrailFsck method namenodeDump.

public void namenodeDump() throws Exception {
    CrailConfiguration conf = new CrailConfiguration();
    CoreDataStore fs = new CoreDataStore(conf);
    fs.dumpNameNode();
    fs.close();
}
Also used : CrailConfiguration(org.apache.crail.conf.CrailConfiguration) CoreDataStore(org.apache.crail.core.CoreDataStore)

Aggregations

CrailConfiguration (org.apache.crail.conf.CrailConfiguration)11 CrailStore (org.apache.crail.CrailStore)3 CoreDataStore (org.apache.crail.core.CoreDataStore)3 HashMap (java.util.HashMap)2 CommandLine (org.apache.commons.cli.CommandLine)2 CommandLineParser (org.apache.commons.cli.CommandLineParser)2 DefaultParser (org.apache.commons.cli.DefaultParser)2 HelpFormatter (org.apache.commons.cli.HelpFormatter)2 Option (org.apache.commons.cli.Option)2 Options (org.apache.commons.cli.Options)2 ParseException (org.apache.commons.cli.ParseException)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 URI (java.net.URI)1 StringTokenizer (java.util.StringTokenizer)1 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 CrailBlockLocation (org.apache.crail.CrailBlockLocation)1 CrailDirectory (org.apache.crail.CrailDirectory)1