Re: EventAdmin Bundle Installation

2014-02-02 Thread masti whoknows
Thanks Marcel for the quick response. 
 
Can someone help clarify: Can I use EventAdmin to pass the event data from an 
non-osgi bundle to an osgi bundle? Or is the eventAdmin only used for 
communicating between osgi bundles?
 
My main application receiving the metrics data/event is non-osgi and it needs 
to forward this event/data to an osgi-bundle. I was using this before: 
bundleContext.registerService(SOME_DATA_TYPE, dataHolderMap, null);
 
This works fine for low volume of calls but starts to hang the thread gets 
blocked.
 
Thanks
Masti



On Saturday, February 1, 2014 2:44 PM, Marcel Offermans 
marcel.offerm...@luminis.eu wrote:
  
On 01 Feb 2014, at 23:20 pm, masti whoknows masti...@yahoo.com wrote:

     Here is simple Java code that I am using to install the EventAdmin bundle
 //now install the EventAdmin: org.apache.felix.eventadmin 1.3.2
 Bundle eventAdminBundle = 
 framework.getBundleContext().installBundle(org.apache.felix.eventadmin);
 eventAdminBundle.start();Is this not the right way? 

No, as you can see from your own stacktrace, installBundle takes a location [1] 
which is interpreted as a URL. Alternatively, you can use the other 
installBundle method [2] that takes a location (which can then be anything) and 
an inputstream (to your bundle).

That should at least get you to the next point. :)

To learn more about embedding Felix, please read [3] and especially the 
Host/Felix interaction part of that document. It contains a lot of 
information related to what you're trying to do.

Greetings, Marcel


[1] 
http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html#installBundle(java.lang.String)
[2] 
http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html#installBundle(java.lang.String,
 java.io.InputStream)

[3] 
http://felix.apache.org/documentation/subprojects/apache-felix-framework/apache-felix-framework-launching-and-embedding.html

Re: EventAdmin Bundle Installation

2014-02-02 Thread masti whoknows
Neil you are everywhere my Friend! It is good to see people willing to help 
others!
 
You got the understanding of the application correctly. My Application installs 
bundles and all bundles live on single JVM.
 
I am able to install the felix org.apache.felix.eventadmin with version 
1.3.2 bundle. 
 
Now pushing the events using the following example: 
http://felix.apache.org/site/apache-felix-event-admin.html is not clear with as 
how the casting will work. 
 if (ref != null) { EventAdmin eventAdmin = (EventAdmin) 
context.getService(ref);
Here EventAdmin should be casted to what? The only class/package available from 
felix is impl package and that does not have EventAdmin.
 
If I use import org.osgi.service.event.Event;import 
org.osgi.service.event.EventAdmin; which I see also available through the same 
felix bundle I get the following class cast 
exceptionjava.lang.ClassCastException: 
org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator 
incompatible with org.osgi.service.event.EventAdmin
 
I am sure I am doing something wrong or missing something.
 
Any pointers are appreciated
 
Thanks
Masti

 
  



On Sunday, February 2, 2014 8:30 AM, Neil Bartlett njbartl...@gmail.com wrote:
  





On Sun, Feb 2, 2014 at 4:16 PM, masti whoknows masti...@yahoo.com wrote:

Thanks Marcel for the quick response.
 
Can someone help clarify: Can I use EventAdmin to pass the event data from an 
non-osgi bundle to an osgi bundle? Or is the eventAdmin only used for 
communicating between osgi bundles?


Yes Event Admin can be used in a non-OSGi environment. However it is not a 
remote or distributed event broker, it works purely within a single JVM 
(although some people have built remoting gateways or bridges that work 
alongside Event Admin).

Therefore if you're talking about using it with both non-OSGi and OSGi 
artifacts then you probably mean you have an embedded OSGi framework in your 
application. Assuming that's the case, then the embedding application can 
interact with Event Admin by publishing an EventHandler interface into OSGi 
using the system bundle's BundleContext. The limitation is that the API package 
for Event Admin will need to be exported by the system bundle using the 
FRAMEWORK_SYSTEM_PACKAGES_EXTRA property.
 
 
My main application receiving the metrics data/event is non-osgi and it needs 
to forward this event/data to an osgi-bundle. I was using this before: 
bundleContext.registerService(SOME_DATA_TYPE, dataHolderMap, null);


Ah yes... I recall your StackOverflow question.

 

 
This works fine for low volume of calls but starts to hang the thread gets 
blocked.
 
Thanks
Masti




On Saturday, February 1, 2014 2:44 PM, Marcel Offermans 
marcel.offerm...@luminis.eu wrote:

On 01 Feb 2014, at 23:20 pm, masti whoknows masti...@yahoo.com wrote:

     Here is simple Java code that I am using to install the EventAdmin bundle
 //now install the EventAdmin: org.apache.felix.eventadmin 1.3.2
 Bundle eventAdminBundle =
 framework.getBundleContext().installBundle(org.apache.felix.eventadmin);
 eventAdminBundle.start();Is this not the right way?

No, as you can see from your own stacktrace, installBundle takes a location 
[1] which is interpreted as a URL. Alternatively, you can use the other 
installBundle method [2] that takes a location (which can then be anything) 
and an inputstream (to your bundle).

That should at least get you to the next point. :)

To learn more about embedding Felix, please read [3] and especially the 
Host/Felix interaction part of that document. It contains a lot of 
information related to what you're trying to do.

Greetings, Marcel


[1] 
http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html#installBundle(java.lang.String)
[2] 
http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html#installBundle(java.lang.String,
 java.io.InputStream)

[3] 
http://felix.apache.org/documentation/subprojects/apache-felix-framework/apache-felix-framework-launching-and-embedding.html
 

EventAdmin Bundle Installation

2014-02-01 Thread masti whoknows
Hi OSGi Gurus,
 
    I am new to OSGi. I have an application that processes messages/metrics 
events in a high volume
 
   My main application which recieves these events/metrics is an non-OSGi 
bundle. However, the task for this application is to forward the event/payload 
to an OSGi bundle. I don't have issues with OSGi bundle as I am able to install 
the bundle and also added the EventHandler there.My issue occurs when I send 
the events from my main application. My service reference is always null. In 
short EventAdmin reference is always null.
 
   I am sure I need to install the EventAdmin as a bundle. How can I do it at 
the top level application? Can you please help me the actual Java code/pseudo 
that would install the bundle?
 
  Dependencies in my pom:
 dependencies
  dependency
   groupIdcom.ebay.external/groupId
   artifactIducirrus-db/artifactId
   version0.7.3/version
  /dependency
  dependency
   groupIdorg.apache.felix/groupId
   artifactIdorg.apache.felix.framework/artifactId
   version4.2.1/version
  /dependency
  dependency
   groupIdorg.apache.felix/groupId
   artifactIdorg.apache.felix.bundlerepository/artifactId
   version1.6.6/version
  /dependency
  dependency
   groupIdorg.ops4j.pax.url/groupId
   artifactIdpax-url-mvn/artifactId
   version1.3.6/version
  /dependency
  dependency
   groupIdorg.apache.felix/groupId
   artifactIdorg.apache.felix.eventadmin/artifactId
   version1.3.2/version
  /dependency
  dependency
   groupIdmockit/groupId
   artifactIdjmockit/artifactId
   version0.999.4/version
   typejar/type
   scopetest/scope
  /dependency
  dependency
   groupIdjunit/groupId
   artifactIdjunit/artifactId
   scopetest/scope
   version4.5/version!--$NO-MVN-MAN-VER$ --
  /dependency
  dependency
   groupIdorg.osgi/groupId
   artifactIdorg.osgi.core/artifactId
   version4.3.0/version!--$NO-MVN-MAN-VER$ --
   typejar/type
   scopecompile/scope
  /dependency
  dependency
   groupIdorg.osgi/groupId
   artifactIdorg.osgi.compendium/artifactId
   version4.3.1/version
   typejar/type
   scopecompile/scope
  /dependency
 /dependencies

    Here is simple Java code that I am using to install the EventAdmin bundle
//now install the EventAdmin: org.apache.felix.eventadmin 1.3.2
Bundle eventAdminBundle = 
framework.getBundleContext().installBundle(org.apache.felix.eventadmin);
eventAdminBundle.start();Is this not the right way? 
 
Any pointers are highly appreciated
 
Thanks
Masti

[osgi-dev] CPU Measurement on a Bundle

2012-01-27 Thread masti whoknows
Hi All,
 
    Is there a way or has anyone done any kind of CPU measurements on 
Bundles? I have a bunch of bundles and would like to know if there is a way to 
meausre how much CPU usage is done by each of the bundles. The requirement is 
to do it in the code and no using any third party profilers (unless they can be 
hooked into the code at run time to get profiles)
 
  Any guidance is highly appreciated.
 
Thanks
Masti___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Question about Memory Usage per Bundle

2011-11-18 Thread masti whoknows
Hi Chris/BJ,
 
   Thanks for the detailed explanation. I knew if I would ask a question here I 
would get a straight and direct answer!
 
    Maybe the work around (this will give a rough estimate) would be to look at 
the resident objects within a given bundle (include all the objects inside it)? 
Not sure if that's also possible.
 
-Thanks
Masti



From: chris.g...@k-embedded-java.com chris.g...@k-embedded-java.com
To: OSGi Developer Mail List osgi-dev@mail.osgi.org
Sent: Friday, November 18, 2011 4:17 AM
Subject: Re: [osgi-dev] Question about Memory Usage per Bundle

BJ is right, the quantity you are trying to measure is not well-defined. 
We were able to modify the Mika VM to associate each allocation with the
most local non-system class loader on the stack at the time of allocation,
which gives an answer to the question how much memory has this bundle
allocated which has not yet been reclaimed by GC, for one possible
definition of memory is allocated by a bundle.  But if a bundle were
generating objects which should be short-lived, but some other bundle is
obsessively cacheing them then our system would blame the first bundle
when in fact it is the second which is the real culprit.

Carrying out measurements when the bundle is loaded/started is probably
not very realistic either, I wouldn't expect many Java modules to allocate
all the memory they need at startup time.  For that you should be looking
at something like Fortran (prior to Fortran 90).

-- 
Chris Gray

 How do you define how much memory a bundle uses? It is generally not
 possible to do this unless you have a very specific definition of memory
 use. Bundles can extend classes imported from other bundles. Bundles can
 call other bundles which allocate memory for the caller. To which bundle
 does this memory belong? A bundle is a unit of encapsulation and
 classloader isolation but it is not a unit of memory isolation. From a
 memory perspective, bundles are very intertwined and it is extremely hard
 to try and disentangle them.

 --

 BJ Hargrave
 Senior Technical Staff Member, IBM
 OSGi Fellow and CTO of the OSGi Alliance
 hargr...@us.ibm.com

 office: +1 386 848 1781
 mobile: +1 386 848 3788





 From:  masti whoknows masti...@yahoo.com
 To:    osgi-dev@mail.osgi.org osgi-dev@mail.osgi.org,
 Date:  2011/11/17 12:51
 Subject:        [osgi-dev] Question about Memory Usage per Bundle
 Sent by:        osgi-dev-boun...@mail.osgi.org



 Hi,

      I am using OSGi to create a plug  play framework. My goal is to
 measure how much memory each bundle is using. Is there a way to do this
 dynamically when the bundle is loaded/started? Please note I don't want to
 use any external tools. I want to do it while the system is running.

    Any help is highly appreciated.

 Thanks
 Masti___
 OSGi Developer Mail List
 osgi-dev@mail.osgi.org
 https://mail.osgi.org/mailman/listinfo/osgi-dev
 ___
 OSGi Developer Mail List
 osgi-dev@mail.osgi.org
 https://mail.osgi.org/mailman/listinfo/osgi-dev


___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

[osgi-dev] Question about Memory Usage per Bundle

2011-11-17 Thread masti whoknows
Hi,
 
 I am using OSGi to create a plug  play framework. My goal is to measure 
how much memory each bundle is using. Is there a way to do this dynamically 
when the bundle is loaded/started? Please note I don't want to use any external 
tools. I want to do it while the system is running.
 
   Any help is highly appreciated.
 
Thanks
Masti___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev