I have written IGFS java application. I want to write shared file such that
if I write file from one node then it is accessible to all other node in
cluster. How to do that ?? 
I referred stack overflow and configured discovery spi to shared file system
but then also it is not working. The program written is accessible to only
the node who written that file not to other node (Other terminal). 
        When I tried to read by giving IGFS path to the file then I received
IGFS file not found exception. Where IGFS store this file. 


public class FileExample
{
        public static void main(String[] args) throws Exception
        {
                Ignite ignite =
Ignition.start("/root/apache-ignite-fabric-2.6.0-bin/examples/config/filesystem/example-igfs.xml");


                System.out.println("\n");
                System.out.println("IGFS example started.....");

                IgniteFileSystem fs = ignite.fileSystem("myFileSystem");
                IgfsPath dir = new
IgfsPath("myFileSystem://192.168.1.5:9060/Preeti");
                fs.mkdirs(dir);

                IgfsPath file = new IgfsPath(dir, "myFile.txt");

                System.out.println(fs.info(file));


                try (OutputStream out = fs.create(file, true))
                {
                        OutputStreamWriter outputStreamWriter = new
OutputStreamWriter(out);
                        outputStreamWriter.write("This is Apache ignite file
system example .... Preeri Nidgunde ......Veriats Infoscale .... VXVM");
                        System.out.println("Done .....");
                        outputStreamWriter.close();
                }catch(Exception e){}


                try (InputStream in = fs.open(file))
                 {
                        Reader inputStreamReader = new
InputStreamReader(in);
                        int data = inputStreamReader.read();
                        while(data != -1)
                        {
                                 char theChar = (char) data;
                                System.out.print(theChar);
                                 data = inputStreamReader.read();
                        }

                        inputStreamReader.close();
                }catch(Exception e){}

                System.out.println("Read data from file");
        }
}

On other node I am trying to read file like

public class ReadFile
{
        public static void main(String[] args) throws Exception
        {
                Ignite ignite =
Ignition.start("/root/apache-ignite-fabric-2.6.0-bin/examples/config/filesystem/example-igfs.xml");

                System.out.println("\n");
                System.out.println("IGFS Read example started.....");

                IgniteFileSystem fs = ignite.fileSystem("myFileSystem");

                try (InputStream in = fs.open(new
IgfsPath("myFileSystem://192.168.1.5:9060/Preeti/myFile.txt")))
                 {
                        Reader inputStreamReader = new
InputStreamReader(in);
                        int data = inputStreamReader.read();
                        while(data != -1)
                        {
                                 char theChar = (char) data;
                                System.out.print(theChar);
                                 data = inputStreamReader.read();
                        }

                        inputStreamReader.close();
                }catch(Exception e){e.printStackTrace();}

                System.out.println("Read data from file");
        }
}
But it is not working.

I have written file on one node and I want to access that written file from
other node. 

Please help me.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to