Search in sources :

Example 1 with RpcGetFile

use of org.apache.crail.rpc.RpcGetFile in project incubator-crail by apache.

the class CoreDataStore method lookup.

public Upcoming<CrailNode> lookup(String path) throws Exception {
    FileName name = new FileName(path);
    if (CrailConstants.DEBUG) {
        LOG.info("lookupDirectory: path " + path);
    }
    RpcFuture<RpcGetFile> fileRes = rpcConnection.getFile(name, false);
    return new LookupNodeFuture(this, path, fileRes);
}
Also used : FileName(org.apache.crail.metadata.FileName) RpcGetFile(org.apache.crail.rpc.RpcGetFile)

Example 2 with RpcGetFile

use of org.apache.crail.rpc.RpcGetFile in project incubator-crail by apache.

the class CoreDataStore method _listEntries.

public DirectoryInputStream _listEntries(String name, boolean randomize) throws Exception {
    FileName directory = new FileName(name);
    if (CrailConstants.DEBUG) {
        LOG.info("getDirectoryList: " + name);
    }
    RpcGetFile fileRes = rpcConnection.getFile(directory, false).get(CrailConstants.RPC_TIMEOUT, TimeUnit.MILLISECONDS);
    if (fileRes.getError() != RpcErrors.ERR_OK) {
        LOG.info("getDirectoryList: " + RpcErrors.messages[fileRes.getError()]);
        throw new FileNotFoundException(RpcErrors.messages[fileRes.getError()]);
    }
    FileInfo dirInfo = fileRes.getFile();
    if (!dirInfo.getType().isContainer()) {
        LOG.info("getDirectoryList: " + RpcErrors.messages[RpcErrors.ERR_FILE_IS_NOT_DIR]);
        throw new FileNotFoundException(RpcErrors.messages[RpcErrors.ERR_FILE_IS_NOT_DIR]);
    }
    CoreDirectory dirFile = new CoreDirectory(this, dirInfo, name);
    DirectoryInputStream inputStream = dirFile.getDirectoryInputStream(randomize);
    return inputStream;
}
Also used : FileInfo(org.apache.crail.metadata.FileInfo) FileName(org.apache.crail.metadata.FileName) FileNotFoundException(java.io.FileNotFoundException) RpcGetFile(org.apache.crail.rpc.RpcGetFile)

Aggregations

FileName (org.apache.crail.metadata.FileName)2 RpcGetFile (org.apache.crail.rpc.RpcGetFile)2 FileNotFoundException (java.io.FileNotFoundException)1 FileInfo (org.apache.crail.metadata.FileInfo)1