Discussion:
Writing in a file on a remote machine
Khadija EL MAHRSI
2012-02-27 13:21:50 UTC
Permalink
Hi,
I'm trying to create a distributed system with "central" log files. By
"central" I mean that the log files are to be created on one machine only
while the remote elements of the system access the log files on this
machine and write in them. Is it possible to achieve this?

Thanks
Yves Jaradin
2012-02-27 14:17:18 UTC
Permalink
Post by Khadija EL MAHRSI
Hi,
I'm trying to create a distributed system with "central" log files. By
"central" I mean that the log files are to be created on one machine
only while the remote elements of the system access the log files on
this machine and write in them. Is it possible to achieve this?
Thanks
_________________________________________________________________________________
http://www.mozart-oz.org/mailman/listinfo/mozart-users
Hello,

Quite easily. Here is a function that takes a class and returns a class
with the same behaviour except that the code will run on the machine
where the function was called. By doing RemoteFile={MakeRemoteClass
Open.file}, you should be able to distribute RemoteFile and use it as
Open.file except the file will be read and written on the machine that
created RemoteFile. It should also be possible to use something more
specific to the case at hand...

Be careful that I didn't test this code thoroughly.

Yves

fun{MakeRemoteClass K}
MasterPort={NewPort thread
for R#I#D in $ do Obj in
thread
try
Obj={New K I}
D=unit
catch E then
D={Value.failed E}
end
end
R={NewPort
thread
for M#D in $ do
thread
try
{Obj M}
D=unit
catch E then
D={Value.failed E}
end
end
end
end}
end
end}
in
class
attr remotePort:unit
meth otherwise(M) O N D in
O=remotePort:=N
if O==unit then
{Send MasterPort N#M#D}
else
N=O
{Send O M#D}
end
{Wait D}
end
end
end
_________________________________________________________________________________
mozart-users mailing list mozart-***@mozart-oz.org
http://www.mozart-oz.org/mailman/listinfo/mozart-users
Khadija EL MAHRSI
2012-03-01 14:30:16 UTC
Permalink
Hi,
I tried the code you gave me and it worked the way I wanted it to.
I really appreciate your help.
Post by Yves Jaradin
Post by Khadija EL MAHRSI
Hi,
I'm trying to create a distributed system with "central" log files. By
"central" I mean that the log files are to be created on one machine
only while the remote elements of the system access the log files on
this machine and write in them. Is it possible to achieve this?
Thanks
______________________________**______________________________**
_____________________
mozart-users mailing list
http://www.mozart-oz.org/**mailman/listinfo/mozart-users<http://www.mozart-oz.org/mailman/listinfo/mozart-users>
Hello,
Quite easily. Here is a function that takes a class and returns a class
with the same behaviour except that the code will run on the machine where
the function was called. By doing RemoteFile={MakeRemoteClass Open.file},
you should be able to distribute RemoteFile and use it as Open.file except
the file will be read and written on the machine that created RemoteFile.
It should also be possible to use something more specific to the case at
hand...
Be careful that I didn't test this code thoroughly.
Yves
fun{MakeRemoteClass K}
MasterPort={NewPort thread
for R#I#D in $ do Obj in
thread
try
Obj={New K I}
D=unit
catch E then
D={Value.failed E}
end
end
R={NewPort
thread
for M#D in $ do
thread
try
{Obj M}
D=unit
catch E then
D={Value.failed E}
end
end
end
end}
end
end}
in
class
attr remotePort:unit
meth otherwise(M) O N D in
O=remotePort:=N
if O==unit then
{Send MasterPort N#M#D}
else
N=O
{Send O M#D}
end
{Wait D}
end
end
end
______________________________**______________________________**
_____________________
mozart-users mailing list
http://www.mozart-oz.org/**mailman/listinfo/mozart-users<http://www.mozart-oz.org/mailman/listinfo/mozart-users>
Loading...