Use several file server processes

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Use several file server processes

Vladimir Gordeev
Greetings,

I want to start separate erlang shell processes (via shell:start/2) on my erlang node. I want each of these shells to have their own CWD, that could be read/written by file:get_cwd/0, file:set_cwd/1.

I hoped to find something like that: http://erlang.org/doc/apps/stdlib/io_protocol.html but for file operations.

I looked up in stdlib file.erl and discovered that it makes gen_server:call to process registered under file_server_2, which is hardcoded in source.

There is not way to achieve what I want?

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use several file server processes

Vladimir Gordeev
I had an idea to use slave nodes expecting them so start their own independent file server,
but turns out it relays to master-node file server: http://erlang.org/doc/man/slave.html#start-1

On Tue, May 30, 2017 at 7:57 PM, Vladimir Gordeev <[hidden email]> wrote:
Greetings,

I want to start separate erlang shell processes (via shell:start/2) on my erlang node. I want each of these shells to have their own CWD, that could be read/written by file:get_cwd/0, file:set_cwd/1.

I hoped to find something like that: http://erlang.org/doc/apps/stdlib/io_protocol.html but for file operations.

I looked up in stdlib file.erl and discovered that it makes gen_server:call to process registered under file_server_2, which is hardcoded in source.

There is not way to achieve what I want?


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use several file server processes

Paul Fisher

Use prim_file and create separate ports for each process you want to run fileops in parallel.  We have a fileops module that just creates ports and stuff it into the process dictionary to reused, which works out well, since lifecycle of the ports works with the lifetime of the process.  This works around the file_server_2 bottleneck.


These two functions should give you the idea:


read_file(Name) ->
Port = get_port(),
prim_file:read_file( Port, Name ).


get_port() ->
case get( ?MODULE ) of
undefined ->
Port = case prim_file:start() of
{ok, Port0} -> Port0;
{error, Reason} ->
exit( {?MODULE, failed_to_create_prim_file, Reason} )
end,
put( ?MODULE, Port ),
Port;
Port -> Port
end.


--

paul

Fellow, Engineering


From: [hidden email] <[hidden email]> on behalf of Vladimir Gordeev <[hidden email]>
Sent: Tuesday, May 30, 2017 1:25:02 PM
To: [hidden email]
Subject: Re: [erlang-questions] Use several file server processes
 
I had an idea to use slave nodes expecting them so start their own independent file server,
but turns out it relays to master-node file server: http://erlang.org/doc/man/slave.html#start-1

On Tue, May 30, 2017 at 7:57 PM, Vladimir Gordeev <[hidden email]> wrote:
Greetings,

I want to start separate erlang shell processes (via shell:start/2) on my erlang node. I want each of these shells to have their own CWD, that could be read/written by file:get_cwd/0, file:set_cwd/1.

I hoped to find something like that: http://erlang.org/doc/apps/stdlib/io_protocol.html but for file operations.

I looked up in stdlib file.erl and discovered that it makes gen_server:call to process registered under file_server_2, which is hardcoded in source.

There is not way to achieve what I want?

Confidentiality Notice | This email and any included attachments may be privileged, confidential and/or otherwise protected from disclosure. Access to this email by anyone other than the intended recipient is unauthorized. If you believe you have received this email in error, please contact the sender immediately and delete all copies. If you are not the intended recipient, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...