Author: alessio.soldano(a)jboss.com
Date: 2007-12-18 07:01:58 -0500 (Tue, 18 Dec 2007)
New Revision: 5342
Added:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
Removed:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordExtractor.java
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordExtractorMBean.java
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordExtractor.java
Modified:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
Log:
- Improved MBean hierarchy
- Fixed MemoryBufferRecorder implementation
Modified:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java 2007-12-18
11:58:13 UTC (rev 5341)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java 2007-12-18
12:01:58 UTC (rev 5342)
@@ -31,10 +31,8 @@
import org.jboss.wsf.common.ObjectNameFactory;
import org.jboss.wsf.framework.management.recording.LogRecorder;
-import org.jboss.wsf.framework.management.recording.ManagedRecordExtractor;
import org.jboss.wsf.framework.management.recording.ManagedRecordProcessor;
import org.jboss.wsf.framework.management.recording.MemoryBufferRecorder;
-import org.jboss.wsf.framework.management.recording.RecordExtractor;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -88,16 +86,19 @@
{
try
{
- mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(ep.getName() + ",recordProcessor=" +
processor.getName()));
- if (processor instanceof RecordExtractor)
- {
- mbeanServer.registerMBean(new
ManagedRecordExtractor((RecordExtractor)processor), ObjectNameFactory.create(ep.getName()
+ ",recordExtractor="
- + processor.getName()));
- }
+ mbeanServer.registerMBean(processor, ObjectNameFactory.create(ep.getName() +
",recordProcessor=" + processor.getName()));
}
catch (JMException ex)
{
- log.error("Cannot register record processor with JMX server", ex);
+ log.debug("Cannot register endpoint with JMX server, trying with the
default ManagedRecordProcessor: " + ex.getMessage());
+ try
+ {
+ mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(ep.getName() + ",recordProcessor=" +
processor.getName()));
+ }
+ catch (JMException innerEx)
+ {
+ log.error("Cannot register endpoint with JMX server", innerEx);
+ }
}
}
@@ -106,10 +107,6 @@
try
{
mbeanServer.unregisterMBean(ObjectNameFactory.create(ep.getName() +
",recordProcessor=" + processor.getName()));
- if (processor instanceof RecordExtractor)
- {
- mbeanServer.unregisterMBean(ObjectNameFactory.create(ep.getName() +
",recordExtractor=" + processor.getName()));
- }
}
catch (JMException ex)
{
Modified:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java 2007-12-18
11:58:13 UTC (rev 5341)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/ManagedEndpoint.java 2007-12-18
12:01:58 UTC (rev 5342)
@@ -31,9 +31,7 @@
import org.jboss.logging.Logger;
import org.jboss.wsf.common.ObjectNameFactory;
-import org.jboss.wsf.framework.management.recording.ManagedRecordExtractor;
import org.jboss.wsf.framework.management.recording.ManagedRecordProcessor;
-import org.jboss.wsf.framework.management.recording.RecordExtractor;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.management.EndpointMetrics;
import org.jboss.wsf.spi.management.recording.Record;
@@ -131,16 +129,19 @@
this.getRecordProcessors().add(processor);
try
{
- mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(endpoint.getName() + ",recordProcessor=" +
processor.getName()));
- if (processor instanceof RecordExtractor)
- {
- mbeanServer.registerMBean(new
ManagedRecordExtractor((RecordExtractor)processor),
ObjectNameFactory.create(endpoint.getName() + ",recordExtractor="
- + processor.getName()));
- }
+ mbeanServer.registerMBean(processor, ObjectNameFactory.create(endpoint.getName()
+ ",recordProcessor=" + processor.getName()));
}
catch (JMException ex)
{
- log.error("Cannot register endpoint with JMX server", ex);
+ log.debug("Cannot register endpoint with JMX server, trying with the
default ManagedRecordProcessor: " + ex.getMessage());
+ try
+ {
+ mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(endpoint.getName() + ",recordProcessor=" +
processor.getName()));
+ }
+ catch (JMException innerEx)
+ {
+ log.error("Cannot register endpoint with JMX server", innerEx);
+ }
}
}
@@ -157,10 +158,6 @@
try
{
mbeanServer.unregisterMBean(ObjectNameFactory.create(endpoint.getName() +
",recordProcessor=" + processor.getName()));
- if (processor instanceof RecordExtractor)
- {
- mbeanServer.unregisterMBean(ObjectNameFactory.create(endpoint.getName() +
",recordExtractor=" + processor.getName()));
- }
}
catch (JMException ex)
{
@@ -173,16 +170,19 @@
{
try
{
- mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(endpoint.getName() + ",recordProcessor=" +
processor.getName()));
- if (processor instanceof RecordExtractor)
- {
- mbeanServer.registerMBean(new
ManagedRecordExtractor((RecordExtractor)processor),
ObjectNameFactory.create(endpoint.getName() + ",recordExtractor="
- + processor.getName()));
- }
+ mbeanServer.registerMBean(processor,
ObjectNameFactory.create(endpoint.getName() + ",recordProcessor=" +
processor.getName()));
}
catch (JMException ex)
{
- log.error("Cannot register endpoint with JMX server", ex);
+ log.debug("Cannot register endpoint with JMX server, trying with the
default ManagedRecordProcessor: " + ex.getMessage());
+ try
+ {
+ mbeanServer.registerMBean(new ManagedRecordProcessor(processor),
ObjectNameFactory.create(endpoint.getName() + ",recordProcessor=" +
processor.getName()));
+ }
+ catch (JMException innerEx)
+ {
+ log.error("Cannot register endpoint with JMX server", innerEx);
+ }
}
}
}
Deleted:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordExtractor.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordExtractor.java 2007-12-18
11:58:13 UTC (rev 5341)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordExtractor.java 2007-12-18
12:01:58 UTC (rev 5342)
@@ -1,68 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.framework.management.recording;
-
-//$Id$
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.wsf.spi.management.recording.Record;
-import org.jboss.wsf.spi.management.recording.RecordFilter;
-
-/**
- * The record extractor MBean representation
- *
- * @author alessio.soldano(a)jboss.org
- * @since 12-Dec-2007
- */
-public class ManagedRecordExtractor implements ManagedRecordExtractorMBean
-{
- private RecordExtractor extractor;
-
- public ManagedRecordExtractor(RecordExtractor extractor)
- {
- this.extractor = extractor;
- }
-
- public Set<String> getClientHosts()
- {
- return ((RecordExtractor)extractor).getClientHosts();
- }
-
- public Map<String, List<Record>> getMatchingRecords(RecordFilter[]
filters)
- {
- return ((RecordExtractor)extractor).getMatchingRecords(filters);
- }
-
- public Map<String, List<Record>> getRecordsByClientHost(String
clientHost)
- {
- return ((RecordExtractor)extractor).getRecordsByClientHost(clientHost);
- }
-
- public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart)
- {
- return ((RecordExtractor)extractor).getRecordsByOperation(namespace, localPart);
- }
-
-}
Deleted:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordExtractorMBean.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordExtractorMBean.java 2007-12-18
11:58:13 UTC (rev 5341)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/ManagedRecordExtractorMBean.java 2007-12-18
12:01:58 UTC (rev 5342)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.framework.management.recording;
-
-//$Id$
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.wsf.spi.management.recording.Record;
-import org.jboss.wsf.spi.management.recording.RecordFilter;
-
-/**
- * The record extractor MBean interface
- *
- * @author alessio.soldano(a)jboss.com
- * @since 12-Dec-2007
- */
-public interface ManagedRecordExtractorMBean
-{
- public Map<String, List<Record>> getMatchingRecords(RecordFilter[]
filters);
-
- public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart);
-
- public Map<String, List<Record>> getRecordsByClientHost(String
clientHost);
-
- public Set<String> getClientHosts();
-}
Modified:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java 2007-12-18
11:58:13 UTC (rev 5341)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java 2007-12-18
12:01:58 UTC (rev 5342)
@@ -45,11 +45,11 @@
* @author alessio.soldano(a)jboss.com
* @since 12-Dec-2007
*/
-public class MemoryBufferRecorder extends AbstractRecordProcessor implements
RecordExtractor
+public class MemoryBufferRecorder extends AbstractRecordProcessor implements
MemoryBufferRecorderMBean
{
private Map<String, List<Record>> recentRecords =
Collections.synchronizedMap(new HashMap<String, List<Record>>());
- private ConcurrentLinkedQueue<Long> recentRecordGroups = new
ConcurrentLinkedQueue<Long>();
+ private ConcurrentLinkedQueue<String> recentRecordGroups = new
ConcurrentLinkedQueue<String>();
private int size = 0;
private int maxSize = 50;
@@ -59,26 +59,33 @@
{
synchronized (recentRecords)
{
- if (size >= maxSize)
- {
- Long id = recentRecordGroups.poll();
- if (id != null)
- {
- recentRecords.remove(id);
- size--;
- }
- }
List<Record> list = recentRecords.get(record.getGroupID());
if (list == null)
{
list = new LinkedList<Record>();
recentRecords.put(record.getGroupID(), list);
+ while (size > maxSize)
+ {
+ this.deleteOldestRecord();
+ }
+ recentRecordGroups.offer(record.getGroupID());
+ size++;
}
list.add(record);
- size++;
}
}
+
+ private void deleteOldestRecord()
+ {
+ String id = recentRecordGroups.poll();
+ if (id != null)
+ {
+ recentRecords.remove(id);
+ size--;
+ }
+ }
+
private Map<String, List<Record>> getRecentRecords()
{
synchronized (recentRecords)
@@ -141,4 +148,26 @@
return this.getMatchingRecords(filters);
}
+ public int getMaxSize()
+ {
+ return maxSize;
+ }
+
+ public void setMaxSize(int maxSize)
+ {
+ synchronized (recentRecords)
+ {
+ while (maxSize < size)
+ {
+ this.deleteOldestRecord();
+ }
+ this.maxSize = maxSize;
+ }
+ }
+
+ public int getSize()
+ {
+ return size;
+ }
+
}
Added:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
(rev 0)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java 2007-12-18
12:01:58 UTC (rev 5342)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.wsf.framework.management.recording;
+
+//$Id$
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+
+/**
+ * The MemoryBufferRecorder's MBean view
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 18-Dec-2007
+ */
+public interface MemoryBufferRecorderMBean extends ManagedRecordProcessorMBean
+{
+ /**
+ * Gets the records matching the provided filters. Records having the
+ * same group ID are returned together.
+ *
+ * @param filters
+ * @return The matching records as a map GroupID->List<Record>
+ */
+ public Map<String, List<Record>> getMatchingRecords(RecordFilter[]
filters);
+
+ /**
+ * Gets the records with the given operation. Records having the
+ * same group ID are returned together.
+ *
+ * @param namespace
+ * @param localPart
+ * @return The matching records as a map GroupID->List<Record>
+ */
+ public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart);
+
+ /**
+ * Gets the records with the given client host. Records having the
+ * same group ID are returned together.
+ *
+ * @param clientHost
+ * @return The matching records as a map GroupID->List<Record>
+ */
+ public Map<String, List<Record>> getRecordsByClientHost(String
clientHost);
+
+ /**
+ * Gets a set containing the client hosts of the last saved records.
+ *
+ * @return
+ */
+ public Set<String> getClientHosts();
+
+ /**
+ * Gets the current buffer max size (i.e. the number of record groups stored at the
same time)
+ *
+ * @return
+ */
+ public int getMaxSize();
+
+ public void setMaxSize(int maxSize);
+
+ /**
+ * Gets the buffer's current size
+ * @return
+ */
+ public int getSize();
+}
Property changes on:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorderMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordExtractor.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordExtractor.java 2007-12-18
11:58:13 UTC (rev 5341)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordExtractor.java 2007-12-18
12:01:58 UTC (rev 5342)
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.wsf.framework.management.recording;
-
-//$Id$
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.wsf.spi.management.recording.Record;
-import org.jboss.wsf.spi.management.recording.RecordFilter;
-
-/**
- * A record extractor provides users with statistics about the collected records
- *
- * @author alessio.soldano(a)jboss.com
- * @since 12-Dec-2007
- */
-public interface RecordExtractor
-{
- /**
- * Gets the records matching the provided filters. Records having the
- * same group ID are returned together.
- *
- * @param filters
- * @return The matching records as a map GroupID->List<Record>
- */
- public Map<String, List<Record>> getMatchingRecords(RecordFilter[]
filters);
-
- /**
- * Gets the records with the given operation. Records having the
- * same group ID are returned together.
- *
- * @param namespace
- * @param localPart
- * @return The matching records as a map GroupID->List<Record>
- */
- public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart);
-
- /**
- * Gets the records with the given client host. Records having the
- * same group ID are returned together.
- *
- * @param clientHost
- * @return The matching records as a map GroupID->List<Record>
- */
- public Map<String, List<Record>> getRecordsByClientHost(String
clientHost);
-
- /**
- * Gets a set containing the client hosts of the last saved records.
- *
- * @return
- */
- public Set<String> getClientHosts();
-
-}