You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Sateesh Karuturi <sa...@gmail.com> on 2016/10/04 05:35:38 UTC
Accessing igfs file through java
Hello experts,
I am new to the Apache Ignite , and i need to access igfs file through java.
Till now what i tried is :
import java.io.InputStream;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteFileSystem;
import org.apache.ignite.Ignition;
import org.apache.ignite.igfs.IgfsPath;
public class Ignite_Spark {
public static void main(String[] args) throws Exception {
Ignite ignite =
Ignition.start("/usr/local/hadoop/apache-ignite-hadoop-1.6.0-bin/config/default-config.xml");
Ignite ignites = Ignition.ignite();
IgniteFileSystem fs = ignites.fileSystem("igfs");
IgfsPath workDir = new IgfsPath("igfs://localhost:8020/ignite/fs");
fs.mkdirs(workDir);
IgfsPath filePath = new IgfsPath(workDir, "ttypes.csv");
try (InputStream in = fs.open(filePath)) {
in.read();
}
}
}
But getting java.lang.IllegalArgumentException: Path should be absolute:
igfs://localhost:8020/ignite/fs exception.
anyone please help me out.
Thanks .
Re: Accessing igfs file through java
Posted by Jörn Franke <jo...@gmail.com>.
You need to configure the igfs in the HDFS configuration file. Then you use the standard APIs to access HDFS files and it will go automatically through the cache.
> On 4 Oct 2016, at 07:35, Sateesh Karuturi <sa...@gmail.com> wrote:
>
> Hello experts,
> I am new to the Apache Ignite , and i need to access igfs file through java.
> Till now what i tried is :
>
> import java.io.InputStream;
>
> import org.apache.ignite.Ignite;
> import org.apache.ignite.IgniteFileSystem;
> import org.apache.ignite.Ignition;
> import org.apache.ignite.igfs.IgfsPath;
>
> public class Ignite_Spark {
>
> public static void main(String[] args) throws Exception {
> Ignite ignite = Ignition.start("/usr/local/hadoop/apache-ignite-hadoop-1.6.0-bin/config/default-config.xml");
> Ignite ignites = Ignition.ignite();
>
> IgniteFileSystem fs = ignites.fileSystem("igfs");
>
> IgfsPath workDir = new IgfsPath("igfs://localhost:8020/ignite/fs");
> fs.mkdirs(workDir);
>
>
> IgfsPath filePath = new IgfsPath(workDir, "ttypes.csv");
>
> try (InputStream in = fs.open(filePath)) {
> in.read();
> }
> }
>
> }
>
>
> But getting java.lang.IllegalArgumentException: Path should be absolute: igfs://localhost:8020/ignite/fs exception.
> anyone please help me out.
> Thanks .
>
Re: Accessing igfs file through java
Posted by vkulichenko <va...@gmail.com>.
Sateesh,
IgfsPath should be a "local" path, e.g. /ignite/fs. You work with IGFS as
with a regular file system, but the data will be stored in a distributed
fashion on the cluster.
-Val
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Accessing-igfs-file-through-java-tp8073p8092.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.