dev@glassfish.java.net

Re: asadmin set and ConfigListener

From: Sreenivas Munnangi <Sreenivas.Munnangi_at_Sun.COM>
Date: Wed, 06 Aug 2008 14:42:16 -0700

Amy Roh wrote:
> Hi Sreeni,
>
> Sreenivas Munnangi wrote:
>> Amy Roh wrote:
>>
>>> Hi,
>>>
>>> I am noticing that asadmin set isn't triggering
>>> org.jvnet.hk2.config.ConfigListener notification
>>
>> This was working yesterday night (based on asadmin set) and now it
>> doesn't. Did some thing change in config ?
>
> How were you testing asadmin set notification last night?
munnangi[49]: ./asadmin get
"configs.config.server-config.monitoring-service.module-monitoring-levels.http-service"
configs.config.server-config.monitoring-service.module-monitoring-levels.http-service=ON

Command get executed successfully.
munnangi[50]: ./asadmin set
"configs.config.server-config.monitoring-service.module-monitoring-levels.http-service=ON"
configs.config.server-config.monitoring-service.module-monitoring-levels.http-service=ON

Command set executed successfully.
munnangi[51]:


the corresponding listener code has the following:

punit[51]: cat WebMonitorStartup.java.diff
Index: WebMonitorStartup.java
===================================================================
--- WebMonitorStartup.java (revision 21613)
+++ WebMonitorStartup.java (working copy)
@@ -46,8 +46,11 @@
 import org.glassfish.flashlight.provider.ProbeProviderEventManager;
 import org.glassfish.flashlight.client.ProbeClientMediator;
 import org.glassfish.flashlight.client.ProbeClientMethodHandle;
-
 import java.util.Collection;
+import com.sun.enterprise.config.serverbeans.ModuleMonitoringLevels;
+import java.beans.PropertyChangeEvent;
+import org.jvnet.hk2.config.UnprocessedChangeEvents;
+import org.jvnet.hk2.config.ConfigListener;
 
 /**
  * Provides for bootstarpping web telemetry during startup and
@@ -57,7 +60,8 @@
  */
 @Service
 @Scoped(Singleton.class)
-public class WebMonitorStartup implements Startup, PostConstruct,
ProbeProviderListener {
+public class WebMonitorStartup implements
+ Startup, PostConstruct, ProbeProviderListener, ConfigListener {
 
     @Inject
     private ProbeProviderEventManager ppem;
@@ -67,7 +71,22 @@
     private SessionStatsTelemetry sessionsTM = null;
     private Collection<ProbeClientMethodHandle> handles;
    
+ @Inject
+ private ModuleMonitoringLevels ml;
    
+ public UnprocessedChangeEvents changed(PropertyChangeEvent[] events) {
+ // handle monitoring level change events
+ for (PropertyChangeEvent event : events) {
+ String propName = event.getPropertyName();
+ if ("http-service".equals(propName)) {
+ ml = (ModuleMonitoringLevels) event.getSource();
+ String enabled = event.getNewValue().toString();
+ System.out.println("MSR: WebTelemetry: changed:
http-service enabled = " + enabled);
+ }
+ }
+ return null;
+ }
+
     public void postConstruct() {
         System.out.println("In the Web Monitor startup ************");
         ppem.registerProbeProviderListener(this);
punit[52]:


*The out put I see is *

Aug 6, 2008 1:52:09 PM
INFO: MSR: WebTelemetry: changed: http-service enabled = ON
Aug 6, 2008 2:35:54 PM
INFO: MSR: WebTelemetry: changed: http-service enabled = ON


> So do you confirm it's no longer working?
I am trying to find out and when I know for sure, I'll let you know.
>>> whereas the events do get triggered if I test using admingui.
>>>
>>> Do asadmin set (property, etc.) and admin gui share the same code
>>> path regarding sending ConfigListener notification? Where can I
>>> look to get more info on this to debug further?
>>
>> asadmin set uses
>> core/kernel/src/main/java/com/sun/enterprise/v3/admin/SetCommand.java
>> and GUI uses amx api.
>
> I'll take a look at these.
>
> Thanks,
> Amy
>
>>
>>>
>>> Thanks,
>>> Amy
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>