You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Kobe <rk...@mailcity.com> on 2016/01/13 01:11:41 UTC
Re: How is igfs:// URL resolved?
Denis Magda wrote
> Hi Kobe,
>
> If I understood you task properly you want to map a path portion of an
> HTTP request to an IGFS path.
>
> If this is your case then I would suggest doing the following:
> - create a Web application that is running in a Tomcat container;
> - the application will use Ignite in the embedded mode (start an Ignite
> node from the app code);
> - process incoming HTTP requests as usual extracting the path part from a
> request;
> - take instance of Igfs from previously started Ignite node and pass the
> path and content to it. Refer to IgfsExample that is a part of Ignite
> bundle/sources for more details.
>
> Regards,
> Denis
Denis,
I went through the IGFS examples and did not quite see what I wanted. My
problem is simply this:
I am generating content into a file in IGFS that needs to be displayed on
the browser. If the content (on the server) were in file
webapps/myapp/content.gif I would return the URL
http://<server>/myapp/content.gif
to the browser to the content may be rendered on the browser.
Since my content is in IGFS, what would be the file:// URL of a file in
(embedded) IGFS instance
"myigfs" in path /data/content.gif as shown below?
> IgniteFileSystem fs = ignite.fileSystem("myigfs");
>
> // Image path.
> IgfsPath workDir = new IgfsPath("/data/content.gif");
Thanx,
kobe
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-is-igfs-URL-resolved-tp2142p2523.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: How is igfs:// URL resolved?
Posted by Denis Magda <dm...@gridgain.com>.
Kobe,
In my understanding everything looks fine in your approach.
Summarizing the execution flow will look like this:
- client sends a request "http:/some.host.com/get/myigfs/data/content.gif";
- server receives the request and gets IGFS file system name (myigfs)
and a path to a file to return (data/content.gif) from it;
- server code gets a reference to IgniteFIleSystem named "myigfs" and
opens IgfsInputStream to the content path;
- reads data from IgfsInputStream and writes it back to response's
OutputStream
--
Denis
On 1/13/2016 7:31 PM, Kobe wrote:
> Denis,
>
> I am afraid I do not understand how I can convert the two elements:
>
>
>> IgniteFileSystem fs = ignite.fileSystem("myigfs");
>>
>> // Image path.
>> IgfsPath workDir = new IgfsPath("/data/content.gif");
> into a URL that the client can consume.
>
> The only thought I have is that I could open IgfsInputStream and stream it
> into HttpConnection OutputStream after setting the appropriate content-type
> like so:
>
>
>> // Open input stream to the image in IGFS ...
>> IgniteFileSystem fs = ignite.fileSystem("myigfs");
>> IgfsPath myImage = new IgfsPath("/data/content.gif");
>> IgfsInputStream inps = fs.open(myImage);
>>
>> byte[] buf = new byte[4096];
>> int len = -1;
>>
>> // Read from IGFS input stream and stuff into servlet response output
>> stream
>> while ((len = inStream.read(buf)) != -1) {
>> outStream.write(buf, 0, len);
>> }
>>
>> outStream.flush();
>> outStream.close();
> Is there a better way?
>
> thanks again for your assistance.
>
> /Kobe
>
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-is-igfs-URL-resolved-tp2142p2545.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: How is igfs:// URL resolved?
Posted by Kobe <rk...@mailcity.com>.
Denis,
I am afraid I do not understand how I can convert the two elements:
> IgniteFileSystem fs = ignite.fileSystem("myigfs");
>
> // Image path.
> IgfsPath workDir = new IgfsPath("/data/content.gif");
into a URL that the client can consume.
The only thought I have is that I could open IgfsInputStream and stream it
into HttpConnection OutputStream after setting the appropriate content-type
like so:
> // Open input stream to the image in IGFS ...
> IgniteFileSystem fs = ignite.fileSystem("myigfs");
> IgfsPath myImage = new IgfsPath("/data/content.gif");
> IgfsInputStream inps = fs.open(myImage);
>
> byte[] buf = new byte[4096];
> int len = -1;
>
> // Read from IGFS input stream and stuff into servlet response output
> stream
> while ((len = inStream.read(buf)) != -1) {
> outStream.write(buf, 0, len);
> }
>
> outStream.flush();
> outStream.close();
Is there a better way?
thanks again for your assistance.
/Kobe
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-is-igfs-URL-resolved-tp2142p2545.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: How is igfs:// URL resolved?
Posted by Denis Magda <dm...@gridgain.com>.
Hi Kobe,
There is no an example for your specific use case.
However your understanding is correct on how this should be implemented.
This is exactly what I had in mind when was going the suggestions in the
previous reply
IgniteFileSystem fs = ignite.fileSystem("myigfs");
// Image path.
IgfsPath workDir = new IgfsPath("/data/content.gif");
--
Denis
On 1/13/2016 3:11 AM, Kobe wrote:
> Denis Magda wrote
>> Hi Kobe,
>>
>> If I understood you task properly you want to map a path portion of an
>> HTTP request to an IGFS path.
>>
>> If this is your case then I would suggest doing the following:
>> - create a Web application that is running in a Tomcat container;
>> - the application will use Ignite in the embedded mode (start an Ignite
>> node from the app code);
>> - process incoming HTTP requests as usual extracting the path part from a
>> request;
>> - take instance of Igfs from previously started Ignite node and pass the
>> path and content to it. Refer to IgfsExample that is a part of Ignite
>> bundle/sources for more details.
>>
>> Regards,
>> Denis
> Denis,
>
> I went through the IGFS examples and did not quite see what I wanted. My
> problem is simply this:
> I am generating content into a file in IGFS that needs to be displayed on
> the browser. If the content (on the server) were in file
> webapps/myapp/content.gif I would return the URL
> http://<server>/myapp/content.gif
> to the browser to the content may be rendered on the browser.
>
> Since my content is in IGFS, what would be the file:// URL of a file in
> (embedded) IGFS instance
> "myigfs" in path /data/content.gif as shown below?
>
>> IgniteFileSystem fs = ignite.fileSystem("myigfs");
>>
>> // Image path.
>> IgfsPath workDir = new IgfsPath("/data/content.gif");
> Thanx,
>
> kobe
>
>
>
>
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-is-igfs-URL-resolved-tp2142p2523.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.