You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Gareth <ga...@gmail.com> on 2012/10/02 17:47:42 UTC

Startup Race Conditions For FileInstall/Blueprint

Hello,

I have some questions about FileInstall/Blueprint in apache karaf 2.2.9.

I created for myself a custom karaf installation that by default puts a
blueprint file into the deploy directory which is available on first
startup.

Unfortunately I found a small race condition with doing this. Sometimes, on
first startup, fileinstall will try to process the file before blueprint is
initialized so I see the following error:

2012-10-01 18:39:44,386 | ERROR | []:[] | pw-133-61/deploy |
BlueprintDeploymentListener      | rint.BlueprintDeploymentListener   65 |
12 - org.apache.karaf.deployer.blueprint - 2.2.8 | Unable to build blueprint
application bundle
java.net.MalformedURLException: unknown protocol: blueprint
        at java.net.URL.<init>(URL.java:395)[:1.6.0_29]
        at java.net.URL.<init>(URL.java:283)[:1.6.0_29]
        at java.net.URL.<init>(URL.java:306)[:1.6.0_29]
        at
org.apache.karaf.deployer.blueprint.BlueprintDeploymentListener.transform(BlueprintDeploymentListener.java:63)[12:org.apache.karaf.deployer.blueprint:2.2.8]
        at
org.apache.felix.fileinstall.internal.DirectoryWatcher.transformArtifact(DirectoryWatcher.java:548)[6:org.apache.felix.fileinstall:3.2.4]
        at
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:467)[6:org.apache.felix.fileinstall:3.2.4]
        at
org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:291)[6:org.apache.felix.fileinstall:3.2.4]

To get around this issue in the past (apache karaf 2.2.5), I had setup
fileinstall to delay checking the deploy directory:

felix.fileinstall.poll    = 30000
felix.fileinstall.start.level = 80
felix.fileinstall.noInitialDelay = true

Whilst this works fine on karaf 2.2.5, when I update to karaf 2.2.9 this
causes me problems on karaf restarts. This configuration now causes my
bundle to be started then stopped/started again on the first check of the
deploy directory (fileinstall refreshes the bundle even though there has
been no change). I suspect this new behaviour is caused by the following
change in felix fileinstall 3.2.2:

    * [FELIX-3398] - Track new versions of artifact listener and optionally
update all bundles when a new version is detected

Given all this information, I have the following questions:

(1) Am I doing anything wrong here? Is it bad form for me to put a file in
the deploy directory before first karaf startup? I am putting it in the
deploy directory rather than creating a bundle so I can mess with the
blueprint file if needed. I put it in the deploy directory on initial start
as this application is static - I am not going to be updating bundles after
initial install.

(2) Is it a bug for felix fileinstall to refresh the bundle even though
nothing has changed...or should I just be accepting that it will always do
this? I ask because, as my application is static and initializes a lot of
resources, I hadn't planned to worry too much about clean start/stop/start
(I only run this app in OSGi as it shares a lot of code with my real OSGi
work).

Any suggestions would be greatly appreciated.

thanks in advance,
Gareth




 



--
View this message in context: http://karaf.922171.n3.nabble.com/Startup-Race-Conditions-For-FileInstall-Blueprint-tp4026233.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Startup Race Conditions For FileInstall/Blueprint

Posted by Guillaume Nodet <gn...@gmail.com>.
In theory, fileinstall is supposed to compute a checksum of the files and
thus be able to detect real changes.
So at a first glance, it does not really seem a desired behavior, but given
we use a listener, things may be a little more subtle.

On Tue, Oct 2, 2012 at 5:47 PM, Gareth <ga...@gmail.com> wrote:

> Hello,
>
> I have some questions about FileInstall/Blueprint in apache karaf 2.2.9.
>
> I created for myself a custom karaf installation that by default puts a
> blueprint file into the deploy directory which is available on first
> startup.
>
> Unfortunately I found a small race condition with doing this. Sometimes, on
> first startup, fileinstall will try to process the file before blueprint is
> initialized so I see the following error:
>
> 2012-10-01 18:39:44,386 | ERROR | []:[] | pw-133-61/deploy |
> BlueprintDeploymentListener      | rint.BlueprintDeploymentListener   65 |
> 12 - org.apache.karaf.deployer.blueprint - 2.2.8 | Unable to build
> blueprint
> application bundle
> java.net.MalformedURLException: unknown protocol: blueprint
>         at java.net.URL.<init>(URL.java:395)[:1.6.0_29]
>         at java.net.URL.<init>(URL.java:283)[:1.6.0_29]
>         at java.net.URL.<init>(URL.java:306)[:1.6.0_29]
>         at
>
> org.apache.karaf.deployer.blueprint.BlueprintDeploymentListener.transform(BlueprintDeploymentListener.java:63)[12:org.apache.karaf.deployer.blueprint:2.2.8]
>         at
>
> org.apache.felix.fileinstall.internal.DirectoryWatcher.transformArtifact(DirectoryWatcher.java:548)[6:org.apache.felix.fileinstall:3.2.4]
>         at
>
> org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:467)[6:org.apache.felix.fileinstall:3.2.4]
>         at
>
> org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:291)[6:org.apache.felix.fileinstall:3.2.4]
>
> To get around this issue in the past (apache karaf 2.2.5), I had setup
> fileinstall to delay checking the deploy directory:
>
> felix.fileinstall.poll    = 30000
> felix.fileinstall.start.level = 80
> felix.fileinstall.noInitialDelay = true
>
> Whilst this works fine on karaf 2.2.5, when I update to karaf 2.2.9 this
> causes me problems on karaf restarts. This configuration now causes my
> bundle to be started then stopped/started again on the first check of the
> deploy directory (fileinstall refreshes the bundle even though there has
> been no change). I suspect this new behaviour is caused by the following
> change in felix fileinstall 3.2.2:
>
>     * [FELIX-3398] - Track new versions of artifact listener and optionally
> update all bundles when a new version is detected
>
> Given all this information, I have the following questions:
>
> (1) Am I doing anything wrong here? Is it bad form for me to put a file in
> the deploy directory before first karaf startup? I am putting it in the
> deploy directory rather than creating a bundle so I can mess with the
> blueprint file if needed. I put it in the deploy directory on initial start
> as this application is static - I am not going to be updating bundles after
> initial install.
>
> (2) Is it a bug for felix fileinstall to refresh the bundle even though
> nothing has changed...or should I just be accepting that it will always do
> this? I ask because, as my application is static and initializes a lot of
> resources, I hadn't planned to worry too much about clean start/stop/start
> (I only run this app in OSGi as it shares a lot of code with my real OSGi
> work).
>
> Any suggestions would be greatly appreciated.
>
> thanks in advance,
> Gareth
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://karaf.922171.n3.nabble.com/Startup-Race-Conditions-For-FileInstall-Blueprint-tp4026233.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
FuseSource, Integration everywhere
http://fusesource.com