Home » Modeling » Modeling (top-level project) » How to make sure that a resource is written
|
Re: How to make sure that a resource is written [message #483995 is a reply to message #483877] |
Thu, 03 September 2009 20:36 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Roland,
Please post EMF questions to the EMF newsgroup, which I've added to the
"to" list of the reply. More comments below.
Roland Brand wrote:
> Hi all
>
> I'm trying to read an EMF resource. In case it does not exist, I
> create a new one, add some default content to it and call save().
>
> Now I've got the problem, that after the save(), the resource might
> still not exist and an IOException is thrown when I try to load the
> resource. It seems like a race condition to me, since it never occurs
> in the debugger. So I helped myself with the following loop:
>
> while
> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
> Collections.EMPTY_MAP))
> {
> System.out.println("save it");
> resource.save(saveOptions);
> }
>
> It is now clear, that save() does not guarantee the existence of the
> resource after it has been called. I have seen up to 30 executions of
> the while-loop until the resource finally existed.
What's the value of the URI?
>
> My question is: how can I make sure, that the new resource really
> exists? The while-loop does not look like a nice solution to me. Or am
> I misunderstanding something?
I wouldn't expect this kind of behavior...
>
>
> Thanks for your helpful posts ;-)
>
> Roland
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to make sure that a resource is written [message #484060 is a reply to message #483995] |
Fri, 04 September 2009 07:02 |
Roland Brand Messages: 42 Registered: July 2009 |
Member |
|
|
Hi Ed
Ed Merks wrote:
> Please post EMF questions to the EMF newsgroup, which I've added to the
> "to" list of the reply. More comments below.
Oops, sorry.
> Roland Brand wrote:
>> Hi all
>>
>> I'm trying to read an EMF resource. In case it does not exist, I
>> create a new one, add some default content to it and call save().
>>
>> Now I've got the problem, that after the save(), the resource might
>> still not exist and an IOException is thrown when I try to load the
>> resource. It seems like a race condition to me, since it never occurs
>> in the debugger. So I helped myself with the following loop:
>>
>> while
>> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
>> Collections.EMPTY_MAP))
>> {
>> System.out.println("save it");
>> resource.save(saveOptions);
>> }
>>
>> It is now clear, that save() does not guarantee the existence of the
>> resource after it has been called. I have seen up to 30 executions of
>> the while-loop until the resource finally existed.
> What's the value of the URI?
The URI is archive:file://home/rbrand/model.zip!/semantic.xmi
As you can probably guess, I have a Zipfile containing GMF resources: a
semantic model and a notation model.
>>
>> My question is: how can I make sure, that the new resource really
>> exists? The while-loop does not look like a nice solution to me. Or am
>> I misunderstanding something?
> I wouldn't expect this kind of behavior...
>>
>>
>> Thanks for your helpful posts ;-)
>>
>> Roland
>>
|
|
|
Re: How to make sure that a resource is written [message #484200 is a reply to message #484060] |
Fri, 04 September 2009 15:05 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Roland,
Perhaps there is a bug in exists for this case. If you could create a
test case demonstrating the problem in a bugzilla report, I'll quickly
have a look and fix it if there is a basic problem.
Roland Brand wrote:
> Hi Ed
>
> Ed Merks wrote:
>> Please post EMF questions to the EMF newsgroup, which I've added to
>> the "to" list of the reply. More comments below.
>
> Oops, sorry.
>
>
>> Roland Brand wrote:
>>> Hi all
>>>
>>> I'm trying to read an EMF resource. In case it does not exist, I
>>> create a new one, add some default content to it and call save().
>>>
>>> Now I've got the problem, that after the save(), the resource might
>>> still not exist and an IOException is thrown when I try to load the
>>> resource. It seems like a race condition to me, since it never
>>> occurs in the debugger. So I helped myself with the following loop:
>>>
>>> while
>>> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
>>> Collections.EMPTY_MAP))
>>> {
>>> System.out.println("save it");
>>> resource.save(saveOptions);
>>> }
>>>
>>> It is now clear, that save() does not guarantee the existence of the
>>> resource after it has been called. I have seen up to 30 executions
>>> of the while-loop until the resource finally existed.
>> What's the value of the URI?
>
> The URI is archive:file://home/rbrand/model.zip!/semantic.xmi
>
> As you can probably guess, I have a Zipfile containing GMF resources:
> a semantic model and a notation model.
>
>>>
>>> My question is: how can I make sure, that the new resource really
>>> exists? The while-loop does not look like a nice solution to me. Or
>>> am I misunderstanding something?
>> I wouldn't expect this kind of behavior...
>>>
>>>
>>> Thanks for your helpful posts ;-)
>>>
>>> Roland
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | |
Re: How to make sure that a resource is written [message #484641 is a reply to message #484542] |
Tue, 08 September 2009 14:38 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Roland,
Unfortunately it works fine for me so I can only assume that
network/filesystem issues specific to Linux are at play. I'm not even
in a position to reproduce OS-specific issues nor can I imagine how EMF
itself could address such things.
Roland Brand wrote:
> Hi Ed
>
> I just filed bug #288799 for this, hoping you can reproduce the problem.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to make sure that a resource is written [message #617812 is a reply to message #483877] |
Thu, 03 September 2009 20:36 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Roland,
Please post EMF questions to the EMF newsgroup, which I've added to the
"to" list of the reply. More comments below.
Roland Brand wrote:
> Hi all
>
> I'm trying to read an EMF resource. In case it does not exist, I
> create a new one, add some default content to it and call save().
>
> Now I've got the problem, that after the save(), the resource might
> still not exist and an IOException is thrown when I try to load the
> resource. It seems like a race condition to me, since it never occurs
> in the debugger. So I helped myself with the following loop:
>
> while
> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
> Collections.EMPTY_MAP))
> {
> System.out.println("save it");
> resource.save(saveOptions);
> }
>
> It is now clear, that save() does not guarantee the existence of the
> resource after it has been called. I have seen up to 30 executions of
> the while-loop until the resource finally existed.
What's the value of the URI?
>
> My question is: how can I make sure, that the new resource really
> exists? The while-loop does not look like a nice solution to me. Or am
> I misunderstanding something?
I wouldn't expect this kind of behavior...
>
>
> Thanks for your helpful posts ;-)
>
> Roland
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: How to make sure that a resource is written [message #617814 is a reply to message #483995] |
Fri, 04 September 2009 07:02 |
Roland Brand Messages: 42 Registered: July 2009 |
Member |
|
|
Hi Ed
Ed Merks wrote:
> Please post EMF questions to the EMF newsgroup, which I've added to the
> "to" list of the reply. More comments below.
Oops, sorry.
> Roland Brand wrote:
>> Hi all
>>
>> I'm trying to read an EMF resource. In case it does not exist, I
>> create a new one, add some default content to it and call save().
>>
>> Now I've got the problem, that after the save(), the resource might
>> still not exist and an IOException is thrown when I try to load the
>> resource. It seems like a race condition to me, since it never occurs
>> in the debugger. So I helped myself with the following loop:
>>
>> while
>> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
>> Collections.EMPTY_MAP))
>> {
>> System.out.println("save it");
>> resource.save(saveOptions);
>> }
>>
>> It is now clear, that save() does not guarantee the existence of the
>> resource after it has been called. I have seen up to 30 executions of
>> the while-loop until the resource finally existed.
> What's the value of the URI?
The URI is archive:file://home/rbrand/model.zip!/semantic.xmi
As you can probably guess, I have a Zipfile containing GMF resources: a
semantic model and a notation model.
>>
>> My question is: how can I make sure, that the new resource really
>> exists? The while-loop does not look like a nice solution to me. Or am
>> I misunderstanding something?
> I wouldn't expect this kind of behavior...
>>
>>
>> Thanks for your helpful posts ;-)
>>
>> Roland
>>
|
|
|
Re: How to make sure that a resource is written [message #617816 is a reply to message #484060] |
Fri, 04 September 2009 15:05 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Roland,
Perhaps there is a bug in exists for this case. If you could create a
test case demonstrating the problem in a bugzilla report, I'll quickly
have a look and fix it if there is a basic problem.
Roland Brand wrote:
> Hi Ed
>
> Ed Merks wrote:
>> Please post EMF questions to the EMF newsgroup, which I've added to
>> the "to" list of the reply. More comments below.
>
> Oops, sorry.
>
>
>> Roland Brand wrote:
>>> Hi all
>>>
>>> I'm trying to read an EMF resource. In case it does not exist, I
>>> create a new one, add some default content to it and call save().
>>>
>>> Now I've got the problem, that after the save(), the resource might
>>> still not exist and an IOException is thrown when I try to load the
>>> resource. It seems like a race condition to me, since it never
>>> occurs in the debugger. So I helped myself with the following loop:
>>>
>>> while
>>> (!resource.getResourceSet().getURIConverter().exists(resourc e.getURI(),
>>> Collections.EMPTY_MAP))
>>> {
>>> System.out.println("save it");
>>> resource.save(saveOptions);
>>> }
>>>
>>> It is now clear, that save() does not guarantee the existence of the
>>> resource after it has been called. I have seen up to 30 executions
>>> of the while-loop until the resource finally existed.
>> What's the value of the URI?
>
> The URI is archive:file://home/rbrand/model.zip!/semantic.xmi
>
> As you can probably guess, I have a Zipfile containing GMF resources:
> a semantic model and a notation model.
>
>>>
>>> My question is: how can I make sure, that the new resource really
>>> exists? The while-loop does not look like a nice solution to me. Or
>>> am I misunderstanding something?
>> I wouldn't expect this kind of behavior...
>>>
>>>
>>> Thanks for your helpful posts ;-)
>>>
>>> Roland
>>>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: How to make sure that a resource is written [message #617820 is a reply to message #484352] |
Mon, 07 September 2009 13:16 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Roland,
It could well be an OS issue I suppose... I'm just not sure what to do
about it...
Roland Brand wrote:
> Hi Ed
>
> I think the exists() is working properly. When I omit the while-loop
> and call resource.save() only once, I get an IOException when I try to
> read the resource. It really does not exists for a short amount of time.
>
> java.io.IOException: Archive entry not found
> archive:file://home/rbrand/model.zip!/semantic.xmi
> at
> org.eclipse.emf.common.archive.ArchiveURLConnection.getInput Stream(ArchiveURLConnection.java:244)
>
> at
> org.eclipse.emf.ecore.resource.impl.ArchiveURIHandlerImpl.cr eateInputStream(ArchiveURIHandlerImpl.java:59)
>
> at
> org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterIm pl.createInputStream(ExtensibleURIConverterImpl.java:301)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1254)
>
>
>
> Stepping into the resource.save() I could see that the OutputStream is
> closed. But nevertheless it seems not to be written to disk directly.
> Could there be OS caches? Is there a possiblity to flush the Zipfile?
>
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: How to make sure that a resource is written [message #618207 is a reply to message #484542] |
Tue, 08 September 2009 14:38 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Roland,
Unfortunately it works fine for me so I can only assume that
network/filesystem issues specific to Linux are at play. I'm not even
in a position to reproduce OS-specific issues nor can I imagine how EMF
itself could address such things.
Roland Brand wrote:
> Hi Ed
>
> I just filed bug #288799 for this, hoping you can reproduce the problem.
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Wed Sep 25 20:18:15 GMT 2024
Powered by FUDForum. Page generated in 0.06674 seconds
|