[rhq] 5 commits - etc/scripts .gitignore modules/enterprise modules/plugins
by Jiri Kremser
.gitignore | 4
etc/scripts/rhqctl-completion.sh | 10 -
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/operation/OperationManagerBeanTest.java | 35 +---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 87 +++++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java | 11 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java | 21 +-
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java | 72 ++++++++
modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml | 10 +
10 files changed, 191 insertions(+), 64 deletions(-)
New commits:
commit c4725c2fa971bb1e38fe66603e09c128d802b725
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri Jun 21 00:28:53 2013 +0200
Simplifying bash script for rhqctl completion.
diff --git a/etc/scripts/rhqctl-completion.sh b/etc/scripts/rhqctl-completion.sh
index ee0d0cc..68adf2b 100755
--- a/etc/scripts/rhqctl-completion.sh
+++ b/etc/scripts/rhqctl-completion.sh
@@ -41,8 +41,7 @@ _rhqctl() {
COMPREPLY=( $(compgen -W "${dataMigratorSubopts}" -- ${cur}) )
return 0
else
- checkForBooleanSubopt ${prev}
- [[ "x$boolean" == "x1" ]] && return 0
+ checkForBooleanSubopt ${prev} && return 0
completePath ${cur}
return 0
fi
@@ -65,8 +64,7 @@ _rhqctl() {
return 0
elif [[ "x${second}" == "x--agent" ]] ; then
if [[ "${agentInstallSubopts}" == *" ${prev} "* ]] ; then
- checkForBooleanSubopt ${prev}
- [[ "x$boolean" == "x1" ]] && return 0
+ checkForBooleanSubopt ${prev} && return 0
completePath ${cur}
return 0
fi
@@ -101,9 +99,9 @@ function completePath(){
function checkForBooleanSubopt(){
if [[ "${booleanSubopts}" == *" ${prev} "* ]] ; then
COMPREPLY=( $(compgen -W "${trueFalse}" -- ${cur} ) )
- boolean="1"
+ return 0
else
- boolean="0"
+ return 1
fi
}
commit bd325e77aa3f9633a13a80fbb97a233e90693747
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Thu Jun 20 12:16:06 2013 +0200
Removing "./cassandra" and "/cassandra/" from .gitigore.
diff --git a/.gitignore b/.gitignore
index 6e09f517..359687a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,8 +4,6 @@ eclipse-classes/
logs/
antlr-generated/
gwt-tmp/
-./cassandra/
-/cassandra/
dev-container/
rhq-data/
rhq-agent/
@@ -14,8 +12,10 @@ dev-cli/
modules/enterprise/gui/portal-war/build/classes/
modules/enterprise/gui/coregui/build/classes/
modules/enterprise/gui/content_http-war/build/classes/
+
#created by rhq-enterprise-server's unit tests
modules/enterprise/server/jar/transaction.log
+
.idea/
.metadata/
*cache.html
commit 8f077b85111f3e18fe3093b768e2e6135fd39c2a
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Thu Jun 20 11:55:59 2013 +0200
Adding the "prepareForUpgrade" operation to the storage node (top level resource). This operation should be run rightbefore the upgrade to the newer version. It backs up all the keyspaces and make the server and storage stop accepting the metrics.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index fad3877..7b2d8dc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -35,7 +35,6 @@ import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
-import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.apache.commons.logging.Log;
@@ -45,14 +44,19 @@ import org.quartz.Trigger;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
+import org.rhq.core.domain.cloud.Server;
import org.rhq.core.domain.cloud.StorageNode;
import org.rhq.core.domain.cloud.StorageNode.OperationMode;
import org.rhq.core.domain.cloud.StorageNodeLoadComposite;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.MeasurementAggregate;
import org.rhq.core.domain.measurement.MeasurementUnits;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.operation.bean.OperationSchedule;
import org.rhq.core.domain.resource.InventoryStatus;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
@@ -60,12 +64,17 @@ import org.rhq.core.domain.util.PageList;
import org.rhq.core.util.StringUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.RequiredPermission;
+import org.rhq.enterprise.server.authz.RequiredPermissions;
+import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal;
import org.rhq.enterprise.server.measurement.MeasurementDataManagerLocal;
+import org.rhq.enterprise.server.operation.OperationManagerLocal;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.rest.reporting.MeasurementConverter;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
import org.rhq.enterprise.server.scheduler.jobs.StorageNodeMaintenanceJob;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
+import org.rhq.enterprise.server.util.LookupUtil;
/**
*
@@ -94,6 +103,7 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
@EJB
private SchedulerLocal quartzScheduler;
+ @Override
public synchronized List<StorageNode> scanForStorageNodes() {
List<StorageNode> existingStorageNodes = getStorageNodes();
if (log.isDebugEnabled()) {
@@ -165,6 +175,7 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
return new ArrayList<StorageNode>(storageNodeMap.values());
}
+ @Override
public void linkResource(Resource resource) {
List<StorageNode> storageNodes = this.getStorageNodes();
@@ -202,20 +213,14 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
}
}
+ @Override
@RequiredPermission(Permission.MANAGE_SETTINGS)
public StorageNodeLoadComposite getLoad(Subject subject, StorageNode node, long beginTime, long endTime) {
StorageNodeLoadComposite result = new StorageNodeLoadComposite(node, beginTime, endTime);
final String tokensMetric = "Tokens", ownershipMetric = "Ownership", loadMetric = "Load", diskUsedPercentageMetric = "Calculated.DiskSpaceUsedPercentage";
final String heapCommittedMetric = "{HeapMemoryUsage.committed}", heapUsedMetric = "{HeapMemoryUsage.used}", heapUsedPercentageMetric = "Calculated.HeapUsagePercentage";
- int resourceId;
- if (node.getResource() == null) {
- node = entityManager.find(StorageNode.class, node.getId());
- if (node.getResource() == null) { // no associated resource
- throw new IllegalStateException("This storage node [" + node.getId() + "] has no associated resource.");
- }
- }
- resourceId = node.getResource().getId();
+ int resourceId = getResourceIdFromStorageNode(node);
// get the schedule ids for Storage Service resource
TypedQuery<Object[]> query = entityManager.<Object[]> createNamedQuery(
@@ -284,22 +289,14 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
return result;
}
- private StorageNodeLoadComposite.MeasurementAggregateWithUnits getMeasurementAggregateWithUnits(Subject subject,
- int schedId, MeasurementUnits units, long beginTime, long endTime) {
- MeasurementAggregate measurementAggregate = measurementManager.getAggregate(subject, schedId, beginTime,
- endTime);
- StorageNodeLoadComposite.MeasurementAggregateWithUnits measurementAggregateWithUnits = new StorageNodeLoadComposite.MeasurementAggregateWithUnits(
- measurementAggregate, units);
- measurementAggregateWithUnits.setFormattedValue(getSummaryString(measurementAggregate, units));
- return measurementAggregateWithUnits;
- }
-
+ @Override
public List<StorageNode> getStorageNodes() {
TypedQuery<StorageNode> query = entityManager.<StorageNode> createNamedQuery(StorageNode.QUERY_FIND_ALL,
StorageNode.class);
return query.getResultList();
}
-
+
+ @Override
@RequiredPermission(Permission.MANAGE_SETTINGS)
public PageList<StorageNode> findStorageNodesByCriteria(Subject subject, StorageNodeCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
@@ -308,6 +305,25 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
return runner.execute();
}
+ @Override
+ @RequiredPermissions({ @RequiredPermission(Permission.MANAGE_SETTINGS),
+ @RequiredPermission(Permission.MANAGE_INVENTORY) })
+ public void prepareNodeForUpgrade(Subject subject, StorageNode storageNode) {
+ int storageNodeResourceId = getResourceIdFromStorageNode(storageNode);
+ TopologyManagerLocal topologyManager = LookupUtil.getTopologyManager();
+ ServerManagerLocal serverManager = LookupUtil.getServerManager();
+ OperationManagerLocal operationManager = LookupUtil.getOperationManager();
+ Server server = serverManager.getServer();
+ // setting the server mode to maintenance
+ topologyManager.updateServerMode(subject, new Integer[] { server.getId() }, Server.OperationMode.MAINTENANCE);
+
+ Configuration parameters = new Configuration();
+ parameters.setSimpleValue("snapshotName", String.valueOf(System.currentTimeMillis()));
+ // scheduling the operation
+ operationManager.scheduleResourceOperation(subject, storageNodeResourceId, "prepareForUpgrade", 0, 0, 0, 0,
+ parameters, "Run by StorageNodeManagerBean.prepareNodeForUpgrade()");
+ }
+
private String getSummaryString(MeasurementAggregate aggregate, MeasurementUnits units) {
String formattedValue = "Min: " + MeasurementConverter.format(aggregate.getMin(), units, true) + ", Max: "
+ MeasurementConverter.format(aggregate.getMax(), units, true) + ", Avg: "
@@ -377,19 +393,18 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
entityManager.flush();
}
- @SuppressWarnings("unchecked")
private void discoverResourceInformation(Map<String, StorageNode> storageNodeMap) {
- Query query = entityManager.createNamedQuery(ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN)
+ TypedQuery<ResourceType> query = entityManager.<ResourceType>createNamedQuery(ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN, ResourceType.class)
.setParameter("name", RHQ_STORAGE_RESOURCE_TYPE).setParameter("plugin", RHQ_STORAGE_PLUGIN);
- List<ResourceType> resourceTypes = (List<ResourceType>) query.getResultList();
+ List<ResourceType> resourceTypes = query.getResultList();
if (resourceTypes.isEmpty()) {
return;
}
- query = entityManager.createNamedQuery(Resource.QUERY_FIND_BY_TYPE_ADMIN).setParameter("type",
+ TypedQuery<Resource> resourceQuery = entityManager.<Resource>createNamedQuery(Resource.QUERY_FIND_BY_TYPE_ADMIN, Resource.class).setParameter("type",
resourceTypes.get(0));
- List<Resource> cassandraResources = (List<Resource>) query.getResultList();
+ List<Resource> cassandraResources = resourceQuery.getResultList();
for (Resource resource : cassandraResources) {
Configuration resourceConfiguration = resource.getPluginConfiguration();
@@ -408,4 +423,26 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal, StorageN
}
}
}
+
+ private StorageNodeLoadComposite.MeasurementAggregateWithUnits getMeasurementAggregateWithUnits(Subject subject,
+ int schedId, MeasurementUnits units, long beginTime, long endTime) {
+ MeasurementAggregate measurementAggregate = measurementManager.getAggregate(subject, schedId, beginTime,
+ endTime);
+ StorageNodeLoadComposite.MeasurementAggregateWithUnits measurementAggregateWithUnits = new StorageNodeLoadComposite.MeasurementAggregateWithUnits(
+ measurementAggregate, units);
+ measurementAggregateWithUnits.setFormattedValue(getSummaryString(measurementAggregate, units));
+ return measurementAggregateWithUnits;
+ }
+
+ private int getResourceIdFromStorageNode(StorageNode storageNode) {
+ int resourceId;
+ if (storageNode.getResource() == null) {
+ storageNode = entityManager.find(StorageNode.class, storageNode.getId());
+ if (storageNode.getResource() == null) { // no associated resource
+ throw new IllegalStateException("This storage node [" + storageNode.getId() + "] has no associated resource.");
+ }
+ }
+ resourceId = storageNode.getResource().getId();
+ return resourceId;
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index c356830..5b13428 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -61,5 +61,16 @@ public interface StorageNodeManagerLocal {
* @return list of nodes
*/
PageList<StorageNode> findStorageNodesByCriteria(Subject subject, StorageNodeCriteria criteria);
+
+ /**
+ * <p>Prepares the node for subsequent upgrade.</p>
+ * <p> CAUTION: this method will set the RHQ server to maintenance mode, RHQ storage flushes all the data to disk
+ * and backup of all the keyspaces is created</p>
+ * <p>the subject needs to have <code>MANAGE_SETTINGS</code> and <code>MANAGE_INVENTORY</code> permissions.</p>
+ *
+ * @param subject caller
+ * @param storageNode storage node on which the prepareForUpgrade operation should be run
+ */
+ void prepareNodeForUpgrade(Subject subject, StorageNode storageNode);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
index 9d6cb6a..f8185e0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
@@ -669,8 +669,8 @@ public class StartupBean implements StartupLocal {
return;
}
-
- /**
+
+ /**
* This seeds the agent clients cache with clients for all known agents. These clients will be started so they can
* immediately begin to send any persisted guaranteed messages that might already exist. This method must be called
* at a time when the server is ready to accept messages from agents because any guaranteed messages that are
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
index 606499f..08b5205 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeComponent.java
@@ -30,6 +30,9 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mc4j.ems.connection.EmsConnection;
+import org.mc4j.ems.connection.bean.EmsBean;
+import org.mc4j.ems.connection.bean.attribute.EmsAttribute;
+import org.mc4j.ems.connection.bean.operation.EmsOperation;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
@@ -56,6 +59,8 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
public OperationResult invokeOperation(String name, Configuration parameters) throws Exception {
if (name.equals("addNodeMaintenance")) {
return nodeAdded(parameters);
+ } else if (name.equals("prepareForUpgrade")) {
+ return prepareForUpgrade(parameters);
} else {
return super.invokeOperation(name, parameters);
}
@@ -178,6 +183,73 @@ public class StorageNodeComponent extends CassandraNodeComponent implements Oper
}
return result;
}
+
+ private OperationResult prepareForUpgrade(Configuration parameters) throws Exception {
+ EmsConnection emsConnection = getEmsConnection();
+ EmsBean storageService = emsConnection.getBean("org.apache.cassandra.db:type=StorageService");
+ Class<?>[] emptyParams = new Class<?>[0];
+
+ if (log.isDebugEnabled()) {
+ log.debug("Disabling native transport...");
+ }
+ EmsOperation operation = storageService.getOperation("stopNativeTransport", emptyParams);
+ operation.invoke((Object[]) emptyParams);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Disabling gossip...");
+ }
+ operation = storageService.getOperation("stopGossiping", emptyParams);
+ operation.invoke((Object[]) emptyParams);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Taking the snapshot...");
+ }
+ operation = storageService.getOperation("takeSnapshot", String.class, String[].class);
+ String snapshotName = parameters.getSimpleValue("snapshotName");
+ if (snapshotName == null || snapshotName.trim().isEmpty()) {
+ snapshotName = System.currentTimeMillis() + "";
+ }
+ operation.invoke(snapshotName, new String[] {});
+
+ // max 2 sec
+ waitForTaskToComplete(500, 10, 150);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Initiating drain...");
+ }
+ operation = storageService.getOperation("drain", emptyParams);
+ operation.invoke((Object[]) emptyParams);
+
+ return new OperationResult();
+ }
+
+ private void waitForTaskToComplete(int initialWaiting, int maxTries, int sleepMillis) {
+ // initial waiting
+ try {
+ Thread.sleep(initialWaiting);
+ } catch (InterruptedException e) {
+ if (log.isWarnEnabled()) {
+ log.warn(e);
+ }
+ }
+ EmsConnection emsConnection = getEmsConnection();
+ EmsBean flushWriterBean = emsConnection.getBean("org.apache.cassandra.internal:type=FlushWriter");
+ EmsAttribute attribute = flushWriterBean.getAttribute("PendingTasks");
+
+ Long valueObject = (Long) attribute.refresh();
+ // wait until org.apache.cassandra.internal:type=FlushWriter / PendingTasks == 0
+ while (valueObject > 0 && maxTries-- > 0) {
+ try {
+ Thread.sleep(sleepMillis);
+ } catch (InterruptedException e) {
+ if (log.isWarnEnabled()) {
+ log.warn(e);
+ }
+ }
+ valueObject = (Long) attribute.refresh();
+ }
+ flushWriterBean.unload();
+ }
private PropertyMap toPropertyMap(OpResult opResult) {
PropertyMap map = new PropertyMap("resultsMap");
diff --git a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
index 66889f8..0029cd4 100644
--- a/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/rhq-storage/src/main/resources/META-INF/rhq-plugin.xml
@@ -81,6 +81,16 @@
</results>
</operation>
+ <operation name="prepareForUpgrade" description="Prepares the storage node for upgrade (this operation consists of following steps: 1) turning off the RPC server, 2) turning off the gossiper, 3) taking the snapshot (backuping the data), 4) invoking the drain operation">
+ <parameters>
+ <c:simple-property name="snapshotName" required="false" type="string" displayName="Snapshot Name"
+ description="Snapshot name. If left empty current system time in milliseconds will be used as the snapshot name."/>
+ </parameters>
+ <results>
+ <c:simple-property name="prepareForUpgradeResult" description="Prepares the storage node for upgrade (this operation consists of following steps: 1) turning off the RPC server, 2) turning off the gossiper, 3) taking the snapshot (backuping the data), 4) invoking the drain operation"/>
+ </results>
+ </operation>
+
<operation name="updateSeedsList" description="Updatess the node's seeds property in cassandra.yaml">
<parameters>
<c:list-property name="seedsList">
commit 45ca004c350e6d70ff38e6ee4f03fb65cc37bc29
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Thu Jun 20 11:55:45 2013 +0200
Increasing the time to wait for operation to finish (the test was failing non-deterministically).
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/operation/OperationManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/operation/OperationManagerBeanTest.java
index e199fea..71aa474 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/operation/OperationManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/operation/OperationManagerBeanTest.java
@@ -1795,10 +1795,11 @@ public class OperationManagerBeanTest extends AbstractEJB3Test {
Resource resource = newResource;
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.SECOND, 2);
- ResourceOperationSchedule schedule = operationManager.scheduleResourceOperationUsingCron(overlord(),
+ Subject overlord = overlord();
+ ResourceOperationSchedule schedule = operationManager.scheduleResourceOperationUsingCron(overlord,
resource.getId(), "testOp", calendar.get(Calendar.SECOND) + " " + calendar.get(Calendar.MINUTE)
+ " * * * ?", 20, null, "desc");
-
+
assert schedule != null;
assert schedule.getDescription().equals("desc");
assert schedule.getOperationName().equals("testOp");
@@ -1806,7 +1807,7 @@ public class OperationManagerBeanTest extends AbstractEJB3Test {
assert schedule.getResource().getId() == resource.getId();
List<ResourceOperationSchedule> results;
- results = operationManager.findScheduledResourceOperations(overlord(), resource.getId());
+ results = operationManager.findScheduledResourceOperations(overlord, resource.getId());
assert results != null;
assert results.size() == 1;
ResourceOperationSchedule returnedSchedule = results.get(0);
@@ -1818,9 +1819,9 @@ public class OperationManagerBeanTest extends AbstractEJB3Test {
assert returnedSchedule.getOperationName().equals("testOp");
assert returnedSchedule.getParameters() != null;
assert returnedSchedule.getResource().getId() == resource.getId();
-
- System.out.println("WAITING FOR 4s FOR THE SCHEDULED OPERATION TO FINISH");
- Thread.sleep(4000L);
+
+ System.out.println("WAITING FOR 4.5s FOR THE SCHEDULED OPERATION TO FINISH");
+ Thread.sleep(4500L);
PageList<ResourceOperationHistory> resultsHist;
resultsHist = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null,
@@ -1857,17 +1858,17 @@ public class OperationManagerBeanTest extends AbstractEJB3Test {
PageControl.getUnlimitedInstance());
assert list.size() == 0;
}
-
+
@Test(enabled = ENABLE_TESTS)
public void testCronGroupScheduling() throws Exception {
Resource resource = newResource;
ResourceGroup group = newGroup;
Calendar calendar = new GregorianCalendar();
calendar.add(Calendar.SECOND, 2);
- GroupOperationSchedule schedule = operationManager.scheduleGroupOperationUsingCron(overlord(),
- newGroup.getId(), new int[] { resource.getId() }, true, "testOp", null, calendar.get(Calendar.SECOND) + " "
- + calendar.get(Calendar.MINUTE)
- + " * * * ?", 20, "desc");
+ Subject overlord = overlord();
+ GroupOperationSchedule schedule = operationManager.scheduleGroupOperationUsingCron(overlord, newGroup.getId(),
+ new int[] { resource.getId() }, true, "testOp", null,
+ calendar.get(Calendar.SECOND) + " " + calendar.get(Calendar.MINUTE) + " * * * ?", 20, "desc");
assert schedule != null;
assert schedule.getDescription().equals("desc");
@@ -1876,7 +1877,7 @@ public class OperationManagerBeanTest extends AbstractEJB3Test {
assert schedule.getGroup().getId() == group.getId();
List<GroupOperationSchedule> results;
- results = operationManager.findScheduledGroupOperations(overlord(), group.getId());
+ results = operationManager.findScheduledGroupOperations(overlord, group.getId());
assert results != null;
assert results.size() == 1;
GroupOperationSchedule returnedSchedule = results.get(0);
@@ -1889,13 +1890,12 @@ public class OperationManagerBeanTest extends AbstractEJB3Test {
assert returnedSchedule.getParameters() != null;
assert returnedSchedule.getGroup().getId() == group.getId();
- System.out.println("WAITING FOR 4s FOR THE SCHEDULED OPERATION TO FINISH");
- Thread.sleep(4000L);
+ System.out.println("WAITING FOR 4.5s FOR THE SCHEDULED OPERATION TO FINISH");
+ Thread.sleep(4500L);
PageList<ResourceOperationHistory> resultsHist;
resultsHist = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null,
- null,
- PageControl.getUnlimitedInstance());
+ null, PageControl.getUnlimitedInstance());
assert resultsHist != null;
assert resultsHist.size() == 1;
ResourceOperationHistory history = resultsHist.get(0);
@@ -1918,8 +1918,7 @@ public class OperationManagerBeanTest extends AbstractEJB3Test {
operationManager.deleteOperationHistory(overlord(), history.getId(), false);
resultsHist = operationManager.findCompletedResourceOperationHistories(overlord(), resource.getId(), null,
- null,
- PageControl.getUnlimitedInstance());
+ null, PageControl.getUnlimitedInstance());
assert resultsHist != null;
assert resultsHist.size() == 0;
commit ea4fa773ebe2b9fb37d715b2ef818c00ffb9e1e4
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Jun 19 17:29:04 2013 +0200
Making the javadoc consistent with the actual code.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
index 9d5251b..8713928 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerBean.java
@@ -413,6 +413,7 @@ public class GroupDefinitionManagerBean implements GroupDefinitionManagerLocal,
}
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
public PageList<GroupDefinition> findGroupDefinitionsByCriteria(Subject subject,
ResourceGroupDefinitionCriteria criteria) {
if (authorizationManager.isInventoryManager(subject) == false) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
index 11f8ed5..c44f3ff 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/GroupDefinitionManagerRemote.java
@@ -24,7 +24,6 @@ import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.criteria.ResourceGroupDefinitionCriteria;
import org.rhq.core.domain.resource.group.GroupDefinition;
import org.rhq.core.domain.resource.group.InvalidExpressionException;
-import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.resource.group.ResourceGroupDeleteException;
import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
@@ -44,8 +43,8 @@ import org.rhq.enterprise.server.resource.group.definition.exception.GroupDefini
public interface GroupDefinitionManagerRemote {
/**
- * Creates a new group definiton.
- * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ * <p>Creates a new group definition.</p>
+ * <p>The subject needs to have <code>MANAGE_INVENTORY</code> permission.</p>
*
* @param subject the user who is asking create the group definition
* @param newGroupDefinition the object defining the group definition
@@ -57,8 +56,8 @@ public interface GroupDefinitionManagerRemote {
throws GroupDefinitionAlreadyExistsException, GroupDefinitionCreateException;
/**
- * Fetches the group definitions based on provided criteria.
- * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ * <p>Fetches the group definitions based on provided criteria.</p>
+ * <p>The subject needs to have <code>MANAGE_INVENTORY</code> permission.</p>
*
* @param subject the user who is asking to find the group definitions
* @param criteria the criteria
@@ -67,8 +66,8 @@ public interface GroupDefinitionManagerRemote {
PageList<GroupDefinition> findGroupDefinitionsByCriteria(Subject subject, ResourceGroupDefinitionCriteria criteria);
/**
- * Deletes the given group definition.
- * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ * <p>Deletes the given group definition.</p>
+ * <p>The subject needs to have <code>MANAGE_INVENTORY</code> permission.</p>
*
* @param subject the user who is asking to remove the group definition
* @param groupDefinitionId the id of a group definition to be deleted
@@ -79,8 +78,8 @@ public interface GroupDefinitionManagerRemote {
GroupDefinitionDeleteException;
/**
- * Updates the given group definition.
- * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ * <p>Updates the given group definition.</p>
+ * <p>The subject needs to have <code>MANAGE_INVENTORY</code> permission.</p>
*
* @param subject the user who is asking to update the group definition
* @param updated the object defining the group definition to be changed (based on its id)
@@ -95,8 +94,8 @@ public interface GroupDefinitionManagerRemote {
ResourceGroupUpdateException;
/**
- * Explicitly recalculates the group membership, depending on the GroupDefinition's expression.
- * The subject needs to have MANAGE_INVENTORY and MANAGE_SETTINGS permissions.
+ * <p>Explicitly recalculates the group membership, depending on the GroupDefinition's expression.</p>
+ * <p>The subject needs to have <code>MANAGE_INVENTORY</code> permission.</p>
*
* @param subject the user who is asking to recalculate the group membership
* @param groupDefinitionId the id of a group definition to be recalculated
10 years, 10 months
[rhq] modules/enterprise pom.xml
by Thomas Segismont
modules/enterprise/server/ear/pom.xml | 101 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java | 7
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java | 49 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CoreServer.java | 47 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java | 81 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java | 27
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java | 68 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsServiceMBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java | 34
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/instrumentation/MeasurementMonitor.java | 49 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginService.java | 46
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/mbean/GroupDefinitionRecalculationThreadMonitor.java | 49 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/SchedulerService.java | 98 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/JMXUtil.java | 61 +
modules/enterprise/server/jar/src/main/resources/quartz.properties | 28
modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties | 42
modules/enterprise/server/jar/src/main/resources/server-comm-configuration.xml | 468 ++++++++++
modules/enterprise/server/sars/services-sar/src/main/resources/META-INF/jboss-service.xml | 96 +-
modules/enterprise/server/sars/services-sar/src/main/resources/server-comm-configuration-overrides.properties | 42
modules/enterprise/server/sars/services-sar/src/main/resources/server-comm-configuration.xml | 468 ----------
modules/enterprise/server/startup-subsystem/pom.xml | 5
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java | 8
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java | 38
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqDeploymentMarker.java | 49 +
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqInitializationProcessor.java | 53 +
modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqShutdownBeanDependenciesProcessor.java | 94 ++
modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml | 1
pom.xml | 7
28 files changed, 1279 insertions(+), 845 deletions(-)
New commits:
commit adedcb46e352d6fb08a43352447b748b9459c899
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jun 6 22:56:11 2013 +0200
Bug 957689 - Unable to complete tasks when server is shutdown
Inject the NoTxRHQDS as a @Resource in the ShutdownListener
Convert SAR services into @Singleton beans
Tweak RHQ EAR deployment with a set of DeploymentUnitProcessor classes
EAR modules now deployed in order
RHQ Startup Subsystem installs a DUP which make the ShutdownListener bean automatically depend on all other session beans.
diff --git a/modules/enterprise/server/ear/pom.xml b/modules/enterprise/server/ear/pom.xml
index ff4c171..a0e00f6 100644
--- a/modules/enterprise/server/ear/pom.xml
+++ b/modules/enterprise/server/ear/pom.xml
@@ -243,53 +243,15 @@
<filtering>true</filtering>
<defaultJavaBundleDir>lib</defaultJavaBundleDir>
<unpackTypes>war,ejb</unpackTypes>
+ <initializeInOrder>true</initializeInOrder>
<modules>
- <!-- ** WARs -->
- <webModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-coregui</artifactId>
- <bundleFileName>coregui.war</bundleFileName>
- <contextRoot>/coregui</contextRoot>
- </webModule>
-
- <webModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-portal</artifactId>
- <bundleFileName>rhq-portal.war</bundleFileName>
- <contextRoot>/</contextRoot>
- </webModule>
-
- <!-- used to expose content through http -->
- <webModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-content_http</artifactId>
- <excluded>${exclude-content_http}</excluded>
- <bundleFileName>rhq-content_http.war</bundleFileName>
- <contextRoot>/content</contextRoot>
- </webModule>
-
- <webModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-rest</artifactId>
- <bundleFileName>rhq-rest.war</bundleFileName>
- <contextRoot>/rest</contextRoot>
- </webModule>
-
- <webModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-rest-examples</artifactId>
- <bundleFileName>rhq-rest-examples.war</bundleFileName>
- <contextRoot>/rest-examples</contextRoot>
- </webModule>
-
- <webModule>
+ <!-- ** EJB-JARs -->
+ <ejbModule>
<groupId>${project.groupId}</groupId>
- <artifactId>rhq-remoting-war</artifactId>
- <bundleFileName>rhq-remoting.war</bundleFileName>
- <contextRoot>/jboss-remoting-servlet-invoker</contextRoot>
- </webModule>
+ <artifactId>rhq-core-domain</artifactId>
+ <bundleFileName>rhq-core-domain-ejb3.jar</bundleFileName>
+ </ejbModule>
- <!-- ** EJB-JARs -->
<ejbModule>
<groupId>${project.groupId}</groupId>
<artifactId>rhq-enterprise-server</artifactId>
@@ -302,12 +264,6 @@
<excluded>true</excluded>
</ejbClientModule>
- <ejbModule>
- <groupId>${project.groupId}</groupId>
- <artifactId>rhq-core-domain</artifactId>
- <bundleFileName>rhq-core-domain-ejb3.jar</bundleFileName>
- </ejbModule>
-
<!-- ** SARs -->
<!-- AS7 allows for SARs embedded in an EAR without anything in application.xml -->
@@ -339,6 +295,51 @@
<includeInApplicationXml>false</includeInApplicationXml>
</jarModule>
+ <!-- ** WARs -->
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-coregui</artifactId>
+ <bundleFileName>coregui.war</bundleFileName>
+ <contextRoot>/coregui</contextRoot>
+ </webModule>
+
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-portal</artifactId>
+ <bundleFileName>rhq-portal.war</bundleFileName>
+ <contextRoot>/</contextRoot>
+ </webModule>
+
+ <!-- used to expose content through http -->
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-content_http</artifactId>
+ <excluded>${exclude-content_http}</excluded>
+ <bundleFileName>rhq-content_http.war</bundleFileName>
+ <contextRoot>/content</contextRoot>
+ </webModule>
+
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-rest</artifactId>
+ <bundleFileName>rhq-rest.war</bundleFileName>
+ <contextRoot>/rest</contextRoot>
+ </webModule>
+
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-rest-examples</artifactId>
+ <bundleFileName>rhq-rest-examples.war</bundleFileName>
+ <contextRoot>/rest-examples</contextRoot>
+ </webModule>
+
+ <webModule>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>rhq-remoting-war</artifactId>
+ <bundleFileName>rhq-remoting.war</bundleFileName>
+ <contextRoot>/jboss-remoting-servlet-invoker</contextRoot>
+ </webModule>
+
</modules>
</configuration>
</plugin>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
index ca8dda4..e1cd145 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/RHQConstants.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server;
@@ -31,6 +31,7 @@ public class RHQConstants {
public static final String EAR_FILE_NAME = EAR_NAME + ".ear";
public static final String ENTITY_MANAGER_JNDI_NAME = "java:jboss/RHQEntityManagerFactory";
public static final String DATASOURCE_JNDI_NAME = "java:jboss/datasources/RHQDS";
+ public static final String NO_TX_DATASOURCE_JNDI_NAME = "java:jboss/datasources/NoTxRHQDS";
public static final String PERSISTENCE_UNIT_NAME = "rhqpu";
public static final String TRANSACTION_MANAGER_JNDI_NAME = "java:jboss/TransactionManager";
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java
index 812e2a6..069e002 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/engine/mbean/AlertConditionCacheMonitor.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,21 +13,32 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
+
package org.rhq.enterprise.server.alert.engine.mbean;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import javax.management.MBeanRegistration;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
+import org.rhq.core.util.ObjectNameFactory;
import org.rhq.enterprise.server.alert.engine.internal.AlertConditionCacheCoordinator;
+import org.rhq.enterprise.server.util.JMXUtil;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -35,7 +46,13 @@ import org.rhq.enterprise.server.util.LookupUtil;
*
* @author Joseph Marques
*/
-public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBean, MBeanRegistration {
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
+public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBean {
+ private static final ObjectName OBJECT_NAME = ObjectNameFactory.create("rhq:service=AlertConditionCacheMonitor");
public AtomicInteger availabilityCacheElementMatches = new AtomicInteger();
public AtomicInteger availabilityDurationCacheElementMatches = new AtomicInteger();
@@ -286,20 +303,18 @@ public class AlertConditionCacheMonitor implements AlertConditionCacheMonitorMBe
LookupUtil.getAlertConditionCacheManager().reloadAllCaches();
}
- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
- objectName = name;
- mbeanServer = server;
- return name;
- }
-
- public void postRegister(Boolean registrationDone) {
- }
-
- public void preDeregister() throws Exception {
+ @PostConstruct
+ private void init() {
+ JMXUtil.registerMBean(this, OBJECT_NAME);
+ mbeanServer = JMXUtil.getPlatformMBeanServer();
+ objectName = OBJECT_NAME;
}
- public void postDeregister() {
+ @PreDestroy
+ private void destroy() {
mbeanServer = null;
+ objectName = null;
+ JMXUtil.unregisterMBeanQuietly(OBJECT_NAME);
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CoreServer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CoreServer.java
index b74b704..edeb264 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CoreServer.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CoreServer.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,22 +13,29 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.core;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.lang.management.ManagementFactory;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Date;
import java.util.HashMap;
import java.util.Properties;
-import javax.management.MBeanServer;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.management.ObjectName;
import org.apache.commons.logging.Log;
@@ -41,15 +48,21 @@ import org.rhq.core.domain.common.ProductInfo;
import org.rhq.core.util.ObjectNameFactory;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.core.service.ManagementService;
+import org.rhq.enterprise.server.util.JMXUtil;
/**
* Get information about RHQ's underlying AS Server.
*/
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class CoreServer implements CoreServerMBean {
private static final String PRODUCT_INFO_PROPERTIES_RESOURCE_PATH =
"org/rhq/enterprise/server/core/ProductInfo.properties";
- private final Log log = LogFactory.getLog(CoreServer.class);
+ private static final Log LOG = LogFactory.getLog(CoreServer.class);
/**
* The name of the version file as found in this class's classloader
@@ -93,7 +106,10 @@ public class CoreServer implements CoreServerMBean {
private Date bootTime;
- protected void start() throws Exception {
+ @PostConstruct
+ private void init() {
+ JMXUtil.registerMBean(this, OBJECT_NAME);
+
this.buildProps = loadBuildProperties();
this.bootTime = new Date();
@@ -101,7 +117,12 @@ public class CoreServer implements CoreServerMBean {
String version = getVersion();
String buildNumber = getBuildNumber();
String buildDate = this.buildProps.getProperty(PROP_BUILD_DATE, "?");
- log.info("Version=[" + version + "], Build Number=[" + buildNumber + "], Build Date=[" + buildDate + "]");
+ LOG.info("Version=[" + version + "], Build Number=[" + buildNumber + "], Build Date=[" + buildDate + "]");
+ }
+
+ @PreDestroy
+ private void destroy() {
+ JMXUtil.unregisterMBeanQuietly(OBJECT_NAME);
}
public String getName() {
@@ -220,16 +241,10 @@ public class CoreServer implements CoreServerMBean {
}
}
- private MBeanServer getMBeanServer() {
- MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- return mbs;
- }
-
private String getServerEnvironmentAttribute(String attributeName) {
try {
- MBeanServer mbs = getMBeanServer();
ObjectName name = ObjectNameFactory.create("jboss.as:core-service=server-environment");
- Object value = mbs.getAttribute(name, attributeName);
+ Object value = JMXUtil.getPlatformMBeanServer().getAttribute(name, attributeName);
return (value != null) ? value.toString() : null;
} catch (Exception e) {
throw new RuntimeException(e);
@@ -247,7 +262,7 @@ public class CoreServer implements CoreServerMBean {
stream.close();
}
} catch (Exception e) {
- log.fatal("Failed to load [" + VERSION_FILE + "] via class loader [" + classLoader + "]");
+ LOG.fatal("Failed to load [" + VERSION_FILE + "] via class loader [" + classLoader + "]");
}
return buildProps;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
index 73eeca5..5025044 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.core;
@@ -24,9 +24,15 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.naming.AuthenticationException;
import javax.naming.Context;
import javax.naming.NamingException;
@@ -47,6 +53,7 @@ import org.rhq.enterprise.server.core.jaas.JDBCLoginModule;
import org.rhq.enterprise.server.core.jaas.JDBCPrincipalCheckLoginModule;
import org.rhq.enterprise.server.core.jaas.LdapLoginModule;
import org.rhq.enterprise.server.core.service.ManagementService;
+import org.rhq.enterprise.server.util.JMXUtil;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
@@ -54,27 +61,26 @@ import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
* Deploy the JAAS login modules that are configured. The JDBC login module is always deployed, however, the LDAP login
* module is only deployed if LDAP is enabled in the RHQ configuration.
*/
-public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceMBean, MBeanRegistration {
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
+public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceMBean {
- private Log log = LogFactory.getLog(CustomJaasDeploymentService.class.getName());
-
- /**
- * Constructor for {@link CustomJaasDeploymentService}.
- */
- public CustomJaasDeploymentService() {
- }
+ private static final Log LOG = LogFactory.getLog(CustomJaasDeploymentService.class.getName());
/**
* @see org.rhq.enterprise.server.core.CustomJaasDeploymentServiceMBean#installJaasModules()
*/
public void installJaasModules() {
try {
- log.info("Updating RHQ Server's JAAS login modules");
+ LOG.info("Updating RHQ Server's JAAS login modules");
Properties systemConfig = LookupUtil.getSystemManager().getSystemConfiguration(
LookupUtil.getSubjectManager().getOverlord());
updateJaasModules(systemConfig);
} catch (Exception e) {
- log.fatal("Error deploying JAAS login modules", e);
+ LOG.fatal("Error deploying JAAS login modules", e);
throw new RuntimeException(e);
}
}
@@ -99,40 +105,25 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
if (!ldapModulesPresent) {
- log.info("Updating RHQ Server's JAAS login modules with LDAP support");
+ LOG.info("Updating RHQ Server's JAAS login modules with LDAP support");
updateJaasModules(systemConfig);
}
}
} catch (Exception e) {
- log.fatal("Error deploying JAAS login modules", e);
+ LOG.fatal("Error deploying JAAS login modules", e);
throw new RuntimeException(e);
}
}
- /**
- * @see javax.management.MBeanRegistration#preRegister(javax.management.MBeanServer,javax.management.ObjectName)
- */
- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
- return name;
- }
-
- /**
- * @see javax.management.MBeanRegistration#postRegister(java.lang.Boolean)
- */
- public void postRegister(Boolean registrationDone) {
- }
-
- /**
- * @see javax.management.MBeanRegistration#preDeregister()
- */
- public void preDeregister() {
+ @PostConstruct
+ private void init() {
+ JMXUtil.registerMBean(this, OBJECT_NAME);
}
- /**
- * @see javax.management.MBeanRegistration#postDeregister()
- */
- public void postDeregister() {
+ @PreDestroy
+ private void destroy() {
+ JMXUtil.unregisterMBeanQuietly(OBJECT_NAME);
}
/**
@@ -150,7 +141,7 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
final SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
if (client.isSecurityDomain(RHQ_USER_SECURITY_DOMAIN)) {
- log.info("Security domain [" + RHQ_USER_SECURITY_DOMAIN + "] already exists, it will be replaced.");
+ LOG.info("Security domain [" + RHQ_USER_SECURITY_DOMAIN + "] already exists, it will be replaced.");
}
List<LoginModuleRequest> loginModules = new ArrayList<LoginModuleRequest>(3);
@@ -188,7 +179,7 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
descriptiveMessage = "Problems encountered when communicating with LDAP server."
+ " Contact the Administrator:" + e;
}
- this.log.error(descriptiveMessage, e);
+ this.LOG.error(descriptiveMessage, e);
}
// Enable the login module even if the LDAP properties have issues
@@ -200,7 +191,7 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
client.createNewSecurityDomain(RHQ_USER_SECURITY_DOMAIN,
loginModules.toArray(new LoginModuleRequest[loginModules.size()]));
client.flushSecurityDomainCache("RHQRESTSecurityDomain");
- log.info("Security domain [" + RHQ_USER_SECURITY_DOMAIN + "] re-created with login modules " + loginModules);
+ LOG.info("Security domain [" + RHQ_USER_SECURITY_DOMAIN + "] re-created with login modules " + loginModules);
} catch (Exception e) {
throw new Exception("Error registering RHQ JAAS modules", e);
@@ -278,7 +269,7 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
try {
bindPW = Obfuscator.decode(bindPW);
} catch (Exception e) {
- log.debug("Failed to decode bindPW, binding using undecoded value [" + bindPW + "]", e);
+ LOG.debug("Failed to decode bindPW, binding using undecoded value [" + bindPW + "]", e);
}
if ((bindDN != null) && (bindDN.length() != 0) && (bindPW != null) && (bindPW.length() != 0)) {
env.setProperty(Context.SECURITY_PRINCIPAL, bindDN);
@@ -286,9 +277,9 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
env.setProperty(Context.SECURITY_AUTHENTICATION, "simple");
}
- log.debug("Validating LDAP properties. Initializing context...");
+ LOG.debug("Validating LDAP properties. Initializing context...");
new InitialLdapContext(env, null).close();
return;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java
index dd2e244..585dbaf 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/ShutdownListener.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.core;
@@ -47,8 +47,15 @@ import org.rhq.enterprise.server.scheduler.SchedulerLocal;
import org.rhq.enterprise.server.util.LookupUtil;
/**
- * This listens for the RHQ server's shutdown notification and when it hears it, will start shutting down RHQ components
- * that need to clean up.
+ * <p>This listens for the RHQ server's shutdown notification and when it hears it, will start shutting down RHQ
+ * components that need to clean up.</p>
+ *
+ * <p>This session bean will depend on every over session bean in the deployment. Its class name is processed by the
+ * org.rhq.enterprise.startup.deployment.RhqShutdownDependenciesProcessor which is installed by the RHQ Startup
+ * Subsystem. This is completely AS7 specific and is a work around AS7 shutting down session beans in parallel.</p>
+ *
+ * <p><strong>DO NOT CHANGE THIS CLASS FULLY QUALIFIED NAME</strong> org.rhq.enterprise.server.core.ShutdownListener
+ * or make the change in the DUP accordingly.</p>
*
* @author John Mazzitelli
* @author Jay Shaughnessy
@@ -75,13 +82,17 @@ public class ShutdownListener {
@Resource(name = "RHQ_DS", mappedName = RHQConstants.DATASOURCE_JNDI_NAME)
private DataSource dataSource;
+ @Resource(name = "NoTx_RHQ_DS", mappedName = RHQConstants.NO_TX_DATASOURCE_JNDI_NAME)
+ @SuppressWarnings("unused")
+ // Prevent the server from closing the NoTx datasource before RHQ EAR
+ // NoTxDS is used by the Quartz scheduler
+ private DataSource noTxDataSource;
+
private File shutdownTimeLogFile;
/**
* This is called when the shutdown notification is received from the JBoss server. This gives a chance for us to
* cleanly shutdown our application in an orderly fashion.
- *
- * @see javax.management.NotificationListener#handleNotification(Notification, Object)
*/
@PreDestroy
public void handleNotification() {
@@ -219,4 +230,4 @@ public class ShutdownListener {
}
return identity.toLowerCase().indexOf("h2") != -1;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
index a609a55..13bd6c0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsService.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.core.comm;
@@ -35,10 +35,17 @@ import java.util.prefs.BackingStoreException;
import java.util.prefs.InvalidPreferencesFormatException;
import java.util.prefs.Preferences;
-import javax.management.MBeanRegistration;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
import mazz.i18n.Logger;
@@ -70,6 +77,7 @@ import org.rhq.enterprise.server.agentclient.AgentClient;
import org.rhq.enterprise.server.agentclient.impl.AgentClientImpl;
import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal;
import org.rhq.enterprise.server.remote.RemoteSafeInvocationHandler;
+import org.rhq.enterprise.server.util.JMXUtil;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -79,12 +87,17 @@ import org.rhq.enterprise.server.util.LookupUtil;
*
* @author John Mazzitelli
*/
-public class ServerCommunicationsService implements ServerCommunicationsServiceMBean, MBeanRegistration {
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
+public class ServerCommunicationsService implements ServerCommunicationsServiceMBean {
/**
* A log for subclasses to be able to use.
*/
- private static Logger LOG = ServerI18NFactory.getLogger(ServerCommunicationsService.class);
+ private static final Logger LOG = ServerI18NFactory.getLogger(ServerCommunicationsService.class);
private static final String DEFAULT_OVERRIDES_PROPERTIES_FILE = "server-comm-configuration-overrides.properties";
@@ -158,26 +171,6 @@ public class ServerCommunicationsService implements ServerCommunicationsServiceM
private RemoteSafeInvocationHandler m_remoteApiHandler;
/**
- * Sets up some internal state.
- *
- * @see MBeanRegistration#preRegister(MBeanServer, ObjectName)
- */
- public ObjectName preRegister(MBeanServer mbs, ObjectName name) throws Exception {
- m_mbs = mbs;
-
- return name;
- }
-
- /**
- * This method does nothing - it is a no-op.
- *
- * @see javax.management.MBeanRegistration#postRegister(java.lang.Boolean)
- */
- public void postRegister(Boolean arg0) {
- return; // NO-OP
- }
-
- /**
* Actually starts the communications services. Once this returns, agents can communicate with the server. This
* method exists (as opposed to "start()") because we do not want these communications services initialized until
* after we are assured the EJBs are all deployed and we are ready to begin processing incoming agent messages.
@@ -258,21 +251,18 @@ public class ServerCommunicationsService implements ServerCommunicationsServiceM
return m_started;
}
- /**
- * This method does nothing - it is a no-op.
- *
- * @see javax.management.MBeanRegistration#preDeregister()
- */
- public void preDeregister() throws Exception {
- return; // NO-OP
+ @PostConstruct
+ private void init() {
+ m_mbs = JMXUtil.getPlatformMBeanServer();
+ JMXUtil.registerMBean(this, OBJECT_NAME);
}
/**
* Cleans up the internal state of this service.
- *
- * @see javax.management.MBeanRegistration#postDeregister()
*/
- public void postDeregister() {
+ @PreDestroy
+ private void destroy() {
+ JMXUtil.unregisterMBeanQuietly(OBJECT_NAME);
m_mbs = null;
m_container = null;
m_configuration = null;
@@ -283,8 +273,6 @@ public class ServerCommunicationsService implements ServerCommunicationsServiceM
m_knownAgents.removeAllAgents();
m_knownAgentClients.clear();
m_started = false;
-
- return;
}
@Override
@@ -1069,4 +1057,4 @@ public class ServerCommunicationsService implements ServerCommunicationsServiceM
}
return newValue;
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsServiceMBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsServiceMBean.java
index 5d4c319..36bbf9f 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsServiceMBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/comm/ServerCommunicationsServiceMBean.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.core.comm;
@@ -83,7 +83,7 @@ public interface ServerCommunicationsServiceMBean extends ServiceContainerMetric
* set, then the settings specified by the configuration preferences file take effect as-is. If this is set,
* this file is a properties file whose values will override the config file prefs.
*
- * @param overrides configuration settings file that override the configuration preferences (may be<code>null</code>)
+ * @param overridesFile configuration settings file that override the configuration preferences (may be<code>null</code>)
*/
void setConfigurationOverridesFile(String overridesFile);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java
index 202459a..0162de7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/plugin/PluginDeploymentScanner.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,14 +13,24 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.core.plugin;
import java.io.File;
import java.util.Date;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -31,6 +41,7 @@ import org.rhq.core.clientapi.descriptor.AgentPluginDescriptorUtil;
import org.rhq.core.util.MessageDigestGenerator;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.file.FileUtil;
+import org.rhq.enterprise.server.util.JMXUtil;
import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.xmlschema.ServerPluginDescriptorUtil;
@@ -42,6 +53,11 @@ import org.rhq.enterprise.server.xmlschema.ServerPluginDescriptorUtil;
*
* @author John Mazzitelli
*/
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class PluginDeploymentScanner implements PluginDeploymentScannerMBean {
private Log log = LogFactory.getLog(PluginDeploymentScanner.class);
@@ -333,4 +349,16 @@ public class PluginDeploymentScanner implements PluginDeploymentScannerMBean {
return;
}
+ @PostConstruct
+ private void init() {
+ JMXUtil.registerMBean(this, OBJECT_NAME);
+ setScanPeriod("${rhq.server.plugin-scan-period-ms:300000}");
+ }
+
+ @PreDestroy
+ private void destroy() {
+ stop();
+ JMXUtil.unregisterMBeanQuietly(OBJECT_NAME);
+ }
+
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/instrumentation/MeasurementMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/instrumentation/MeasurementMonitor.java
index 3ff3a17..93feca3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/instrumentation/MeasurementMonitor.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/instrumentation/MeasurementMonitor.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,24 +13,41 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.measurement.instrumentation;
import java.util.concurrent.atomic.AtomicLong;
-import javax.management.MBeanRegistration;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
+import org.rhq.core.util.ObjectNameFactory;
+import org.rhq.enterprise.server.util.JMXUtil;
import org.rhq.enterprise.server.util.LookupUtil;
/**
* @author Greg Hinkle
*/
-public class MeasurementMonitor implements MeasurementMonitorMBean, MBeanRegistration {
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
+public class MeasurementMonitor implements MeasurementMonitorMBean {
+ private static final ObjectName OBJECT_NAME = ObjectNameFactory.create("rhq:service=MeasurementMonitor");
+
private AtomicLong measurementInsertTime = new AtomicLong();
private AtomicLong measurementsInserted = new AtomicLong();
@@ -241,19 +258,17 @@ public class MeasurementMonitor implements MeasurementMonitorMBean, MBeanRegistr
this.purgedMeasurementTraits.set(delta);
}
- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
- objectName = name;
- mbeanServer = server;
- return name;
- }
-
- public void postRegister(Boolean registrationDone) {
- }
-
- public void preDeregister() throws Exception {
+ @PostConstruct
+ private void init() {
+ JMXUtil.registerMBean(this, OBJECT_NAME);
+ mbeanServer = JMXUtil.getPlatformMBeanServer();
+ objectName = OBJECT_NAME;
}
- public void postDeregister() {
+ @PreDestroy
+ private void destroy() {
mbeanServer = null;
+ objectName = null;
+ JMXUtil.unregisterMBeanQuietly(OBJECT_NAME);
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginService.java
index 2bd3b2b..a0cfe2d 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginService.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,16 +13,27 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.plugin.pc;
import java.io.File;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.enterprise.server.util.JMXUtil;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -32,14 +43,19 @@ import org.rhq.enterprise.server.util.LookupUtil;
*
* @author John Mazzitelli
*/
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class ServerPluginService implements ServerPluginServiceMBean {
- private static final Log log = LogFactory.getLog(ServerPluginService.class);
+ private static final Log LOG = LogFactory.getLog(ServerPluginService.class);
private boolean started;
private MasterServerPluginContainer masterPluginContainer;
public synchronized void start() {
- log.debug("The server plugin service has been deployed (but master plugin container will not be started yet)");
+ LOG.debug("The server plugin service has been deployed (but master plugin container will not be started yet)");
this.started = true;
return;
}
@@ -52,7 +68,7 @@ public class ServerPluginService implements ServerPluginServiceMBean {
// only initialize if not already started; if already started/initialized, just ignore
if (this.masterPluginContainer == null) {
- log.debug("The server plugin service is now starting the master server plugin container");
+ LOG.debug("The server plugin service is now starting the master server plugin container");
this.masterPluginContainer = createMasterPluginContainer();
this.masterPluginContainer.scheduleAllPluginJobs();
}
@@ -62,7 +78,7 @@ public class ServerPluginService implements ServerPluginServiceMBean {
public synchronized void stopMasterPluginContainer() {
if (this.started && (this.masterPluginContainer != null)) {
- log.info("The server plugin service is now stopping - the master plugin container will be shutdown now");
+ LOG.info("The server plugin service is now stopping - the master plugin container will be shutdown now");
this.masterPluginContainer.shutdown();
this.masterPluginContainer = null;
@@ -93,7 +109,7 @@ public class ServerPluginService implements ServerPluginServiceMBean {
// only initialize if not already started; if already started/initialized, just ignore
if (this.masterPluginContainer == null) {
- log.debug("The server plugin service is now starting the master server plugin container!");
+ LOG.debug("The server plugin service is now starting the master server plugin container!");
this.masterPluginContainer = createMasterPluginContainer();
}
@@ -146,4 +162,16 @@ public class ServerPluginService implements ServerPluginServiceMBean {
pc.initialize(config);
return pc;
}
-}
\ No newline at end of file
+
+ @PostConstruct
+ private void init() {
+ JMXUtil.registerMBean(this, OBJECT_NAME);
+ start();
+ }
+
+ @PreDestroy
+ private void destroy() {
+ stop();
+ JMXUtil.unregisterMBeanQuietly(OBJECT_NAME);
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/mbean/GroupDefinitionRecalculationThreadMonitor.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/mbean/GroupDefinitionRecalculationThreadMonitor.java
index ed030c2..d47f2a1 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/mbean/GroupDefinitionRecalculationThreadMonitor.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/definition/mbean/GroupDefinitionRecalculationThreadMonitor.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.resource.group.definition.mbean;
@@ -24,13 +24,23 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
-import javax.management.MBeanRegistration;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import javax.management.MBeanServer;
import javax.management.MBeanServerInvocationHandler;
import javax.management.ObjectName;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.resource.group.GroupDefinition;
+import org.rhq.core.util.ObjectNameFactory;
+import org.rhq.enterprise.server.util.JMXUtil;
import org.rhq.enterprise.server.util.LookupUtil;
/**
@@ -39,8 +49,13 @@ import org.rhq.enterprise.server.util.LookupUtil;
*
* @author Joseph Marques
*/
-public class GroupDefinitionRecalculationThreadMonitor implements GroupDefinitionRecalculationThreadMonitorMBean,
- MBeanRegistration {
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
+public class GroupDefinitionRecalculationThreadMonitor implements GroupDefinitionRecalculationThreadMonitorMBean {
+ private static final ObjectName OBJECT_NAME = ObjectNameFactory.create("rhq:service=GroupDefinitionRecalculationThreadMonitor");
/*
* synchronization policy: all private attributes of this statistics object are meant to be read and written
@@ -106,12 +121,6 @@ public class GroupDefinitionRecalculationThreadMonitor implements GroupDefinitio
return proxy;
}
- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
- objectName = name;
- mbeanServer = server;
- return name;
- }
-
public void clear() {
statistics.clear();
}
@@ -156,14 +165,18 @@ public class GroupDefinitionRecalculationThreadMonitor implements GroupDefinitio
return results;
}
- public void postRegister(Boolean registrationDone) {
- }
-
- public void preDeregister() throws Exception {
+ @PostConstruct
+ private void init() {
+ JMXUtil.registerMBean(this, OBJECT_NAME);
+ mbeanServer = JMXUtil.getPlatformMBeanServer();
+ objectName = OBJECT_NAME;
}
- public void postDeregister() {
+ @PreDestroy
+ private void destroy() {
mbeanServer = null;
+ objectName = null;
+ JMXUtil.unregisterMBeanQuietly(OBJECT_NAME);
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/SchedulerService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/SchedulerService.java
index a550362..2a3c1ef 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/SchedulerService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/scheduler/SchedulerService.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,20 +13,27 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.scheduler;
+import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.ejb.ConcurrencyManagement;
+import javax.ejb.ConcurrencyManagementType;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.ejb.Startup;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -47,19 +54,22 @@ import org.quartz.spi.JobFactory;
import org.jboss.util.StringPropertyReplacer;
+import org.rhq.core.util.stream.StreamUtil;
+import org.rhq.enterprise.server.util.JMXUtil;
+
/**
* Scheduler MBean service that simply wraps the Quartz scheduler.
*/
-public class SchedulerService implements SchedulerServiceMBean, MBeanRegistration {
- // for why we need this in RHQ - see https://issues.jboss.org/browse/AS7-5336
- static {
- java.beans.PropertyEditorManager.registerEditor(Properties.class,
- org.jboss.util.propertyeditor.PropertiesEditor.class);
- }
+@Singleton
+@Startup
+@LocalBean
+(a)ConcurrencyManagement(ConcurrencyManagementType.BEAN)
+(a)TransactionAttribute(TransactionAttributeType.SUPPORTS)
+public class SchedulerService implements SchedulerServiceMBean {
- private Log log = LogFactory.getLog(SchedulerService.class);
+ private static final Log LOG = LogFactory.getLog(SchedulerService.class);
- private String TIMEOUT_PROPERTY_NAME = "rhq.server.operation-timeout";
+ private static final String TIMEOUT_PROPERTY_NAME = "rhq.server.operation-timeout";
/**
* The configuration properties for Quartz.
@@ -70,15 +80,11 @@ public class SchedulerService implements SchedulerServiceMBean, MBeanRegistratio
private StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
private Scheduler scheduler;
- public SchedulerService() {
- }
-
public Properties getQuartzProperties() {
return quartzProperties;
}
public void setQuartzProperties(Properties quartzProps) throws SchedulerException {
- // we need to replace ${var} notations because AS7 doesn't - see https://issues.jboss.org/browse/AS7-5343
if (quartzProps != null) {
Properties overrides = new Properties();
for (Map.Entry<Object, Object> entry : quartzProps.entrySet()) {
@@ -93,7 +99,7 @@ public class SchedulerService implements SchedulerServiceMBean, MBeanRegistratio
this.quartzProperties = quartzProps;
schedulerFactory.initialize(quartzProps);
- log.info("Scheduler has a default operation timeout of [" + getDefaultOperationTimeout() + "] seconds.");
+ LOG.info("Scheduler has a default operation timeout of [" + getDefaultOperationTimeout() + "] seconds.");
}
public Integer getDefaultOperationTimeout() {
@@ -105,7 +111,7 @@ public class SchedulerService implements SchedulerServiceMBean, MBeanRegistratio
try {
timeout = Integer.valueOf(timeoutStr);
} catch (Exception e) {
- log.warn("Invalid operation timeout value specified in the quartz properties: " + TIMEOUT_PROPERTY_NAME
+ LOG.warn("Invalid operation timeout value specified in the quartz properties: " + TIMEOUT_PROPERTY_NAME
+ "=" + timeoutStr);
}
}
@@ -116,16 +122,16 @@ public class SchedulerService implements SchedulerServiceMBean, MBeanRegistratio
public void initQuartzScheduler() throws SchedulerException {
if (scheduler == null) {
// TODO: if we are running in a server cluster, make sure we are using Quartz's clustering capability
- log.debug("Scheduler service will initialize Quartz scheduler now.");
+ LOG.debug("Scheduler service will initialize Quartz scheduler now.");
scheduler = schedulerFactory.getScheduler();
} else {
- log.debug("Quartz scheduler is initialized and can be started");
+ LOG.debug("Quartz scheduler is initialized and can be started");
}
}
public void startQuartzScheduler() throws SchedulerException {
initQuartzScheduler();
- log.info("Scheduler service will start Quartz scheduler now - jobs will begin executing.");
+ LOG.info("Scheduler service will start Quartz scheduler now - jobs will begin executing.");
scheduler.start();
return;
@@ -138,7 +144,7 @@ public class SchedulerService implements SchedulerServiceMBean, MBeanRegistratio
*/
public synchronized void stop() throws SchedulerException {
if ((scheduler != null) && !scheduler.isShutdown()) {
- log.info("Stopping " + scheduler);
+ LOG.info("Stopping " + scheduler);
shutdown();
scheduler = null;
}
@@ -165,7 +171,7 @@ public class SchedulerService implements SchedulerServiceMBean, MBeanRegistratio
}
public void start() {
- log.debug("Scheduler Service has started - however, Quartz is not going to be starting yet");
+ LOG.debug("Scheduler Service has started - however, Quartz is not going to be starting yet");
}
/**
@@ -374,30 +380,28 @@ public class SchedulerService implements SchedulerServiceMBean, MBeanRegistratio
return scheduler.getSchedulerListeners();
}
- public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
- return name;
- }
-
- public void postRegister(Boolean registrationDone) {
- }
-
- /**
- * Ensures that the Quartz scheduler is shutdown.
- *
- * @see javax.management.MBeanRegistration#preDeregister()
- */
- public void preDeregister() throws Exception {
- if (scheduler != null) {
- shutdown();
+ @PostConstruct
+ private void init() {
+ Properties properties = new Properties();
+ InputStream propertiesStream = getClass().getClassLoader().getResourceAsStream("quartz.properties");
+ try {
+ properties.load(propertiesStream);
+ setQuartzProperties(properties);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ StreamUtil.safeClose(propertiesStream);
}
+ JMXUtil.registerMBean(this, SCHEDULER_MBEAN_NAME);
}
- /**
- * Delegates to the Quartz scheduler.
- *
- * @see javax.management.MBeanRegistration#postDeregister()
- */
- public void postDeregister() {
+ @PreDestroy
+ private void destroy() {
+ try {
+ stop();
+ } catch (SchedulerException ignore) {
+ }
+ JMXUtil.unregisterMBeanQuietly(SCHEDULER_MBEAN_NAME);
}
// Quartz methods that are new in 1.5.1 that were not in 1.0.7
@@ -475,4 +479,4 @@ public class SchedulerService implements SchedulerServiceMBean, MBeanRegistratio
public void startDelayed(int delay) throws SchedulerException {
scheduler.startDelayed(delay);
}
-}
\ No newline at end of file
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/JMXUtil.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/JMXUtil.java
new file mode 100644
index 0000000..6404b40
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/JMXUtil.java
@@ -0,0 +1,61 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.enterprise.server.util;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author Thomas Segismont
+ */
+public class JMXUtil {
+
+ private static final Log LOG = LogFactory.getLog(JMXUtil.class);
+
+ private JMXUtil() {
+ // Defensive
+ }
+
+ public static void registerMBean(Object bean, ObjectName objectName) {
+ try {
+ getPlatformMBeanServer().registerMBean(bean, objectName);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void unregisterMBeanQuietly(ObjectName objectName) {
+ try {
+ getPlatformMBeanServer().unregisterMBean(objectName);
+ } catch (Exception e) {
+ LOG.error("Exception on " + objectName + " unregister", e);
+ }
+ }
+
+ public static MBeanServer getPlatformMBeanServer() {
+ return ManagementFactory.getPlatformMBeanServer();
+ }
+
+}
diff --git a/modules/enterprise/server/jar/src/main/resources/quartz.properties b/modules/enterprise/server/jar/src/main/resources/quartz.properties
new file mode 100644
index 0000000..4b1b904
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/resources/quartz.properties
@@ -0,0 +1,28 @@
+# RHQ custom property that defines the default timeout for all operations.
+# This is specified in seconds. If any operation takes longer than this, it is assumed to have failed.
+rhq.server.operation-timeout = ${rhq.server.operation-timeout:600}
+
+# scheduler factory config
+org.quartz.scheduler.instanceName = RHQScheduler
+org.quartz.scheduler.instanceId = AUTO
+
+# thread pool config
+org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
+org.quartz.threadPool.threadCount = 5
+
+# database config
+# note that the delegate class property should be set at build/installation time
+org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
+org.quartz.jobStore.driverDelegateClass = ${rhq.server.quartz.driverDelegateClass}
+org.quartz.jobStore.isClustered = true
+org.quartz.jobStore.clusterCheckinInterval = 30000
+org.quartz.jobStore.tablePrefix = RHQ_QRTZ_
+org.quartz.jobStore.useProperties = true
+org.quartz.jobStore.selectWithLockSQL = ${rhq.server.quartz.selectWithLockSQL}
+org.quartz.jobStore.dataSource = RHQDS
+org.quartz.dataSource.RHQDS.jndiURL = java:jboss/datasources/RHQDS
+org.quartz.dataSource.RHQDS.maxConnections = 10
+org.quartz.jobStore.nonManagedTXDataSource = NoTxRHQDS
+org.quartz.dataSource.NoTxRHQDS.jndiURL = java:jboss/datasources/NoTxRHQDS
+org.quartz.dataSource.NoTxRHQDS.maxConnections = 10
+org.quartz.jobStore.lockHandler.class = ${rhq.server.quartz.lockHandlerClass}
diff --git a/modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties b/modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties
new file mode 100644
index 0000000..91ccc85
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/resources/server-comm-configuration-overrides.properties
@@ -0,0 +1,42 @@
+# location of the plugin jars and other files agents can download directly from sever
+rhq.server.agent-files-directory=${rhq.server.home}/modules/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/rhq-downloads
+# location where data files can be stored
+rhq.communications.data-directory=${jboss.server.data.dir}
+# global limit on number of concurrent incoming messages allowed
+rhq.communications.global-concurrency-limit=${rhq.communications.global-concurrency-limit:200}
+# Server's remote endpoint for agents to talk to
+rhq.communications.connector.transport=${rhq.communications.connector.transport:servlet}
+rhq.communications.connector.bind-address=${rhq.communications.connector.bind-address}
+rhq.communications.connector.bind-port=${rhq.communications.connector.bind-port:7080}
+rhq.communications.connector.transport-params=${rhq.communications.connector.transport-params:/jboss-remoting-servlet-invoker/ServerInvokerServlet}
+# Multicast detector configuration for auto-discovery
+rhq.communications.multicast-detector.enabled=${rhq.communications.multicast-detector.enabled:false}
+rhq.communications.multicast-detector.multicast-address=${rhq.communications.multicast-detector.multicast-address:224.16.16.16}
+rhq.communications.multicast-detector.bind-address=${rhq.communications.multicast-detector.bind-address}
+rhq.communications.multicast-detector.port=${rhq.communications.multicast-detector.port:16162}
+# Server-side SSL Security Configuration (for incoming messages from agents)
+rhq.communications.connector.security.secure-socket-protocol=${rhq.communications.connector.security.secure-socket-protocol:TLS}
+rhq.communications.connector.security.keystore.file=${rhq.communications.connector.security.keystore.file}
+rhq.communications.connector.security.keystore.algorithm=${rhq.communications.connector.security.keystore.algorithm}
+rhq.communications.connector.security.keystore.type=${rhq.communications.connector.security.keystore.type:JKS}
+rhq.communications.connector.security.keystore.password=${rhq.communications.connector.security.keystore.password:rhqpwd}
+rhq.communications.connector.security.keystore.key-password=${rhq.communications.connector.security.keystore.key-password:rhqpwd}
+rhq.communications.connector.security.keystore.alias=${rhq.communications.connector.security.keystore.alias:rhq}
+rhq.communications.connector.security.truststore.file=${rhq.communications.connector.security.truststore.file}
+rhq.communications.connector.security.truststore.algorithm=${rhq.communications.connector.security.truststore.algorithm}
+rhq.communications.connector.security.truststore.type=${rhq.communications.connector.security.truststore.type:JKS}
+rhq.communications.connector.security.truststore.password=${rhq.communications.connector.security.truststore.password}
+rhq.communications.connector.security.client-auth-mode=${rhq.communications.connector.security.client-auth-mode:none}
+# Client-side SSL Security Configuration (for outgoing messages to agents)
+rhq.server.client.security.secure-socket-protocol=${rhq.server.client.security.secure-socket-protocol:TLS}
+rhq.server.client.security.keystore.file=${rhq.server.client.security.keystore.file}
+rhq.server.client.security.keystore.algorithm=${rhq.server.client.security.keystore.algorithm}
+rhq.server.client.security.keystore.type=${rhq.server.client.security.keystore.type:JKS}
+rhq.server.client.security.keystore.password=${rhq.server.client.security.keystore.password:rhqpwd}
+rhq.server.client.security.keystore.key-password=${rhq.server.client.security.keystore.key-password:rhqpwd}
+rhq.server.client.security.keystore.alias=${rhq.server.client.security.keystore.alias:rhq}
+rhq.server.client.security.truststore.file=${rhq.server.client.security.truststore.file}
+rhq.server.client.security.truststore.algorithm=${rhq.server.client.security.truststore.algorithm}
+rhq.server.client.security.truststore.type=${rhq.server.client.security.truststore.type:JKS}
+rhq.server.client.security.truststore.password=${rhq.server.client.security.truststore.password}
+rhq.server.client.security.server-auth-mode-enabled=${rhq.server.client.security.server-auth-mode-enabled:false}
diff --git a/modules/enterprise/server/jar/src/main/resources/server-comm-configuration.xml b/modules/enterprise/server/jar/src/main/resources/server-comm-configuration.xml
new file mode 100644
index 0000000..7f30276
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/resources/server-comm-configuration.xml
@@ -0,0 +1,468 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
+
+<!--
+==============================================================================
+RHQ Server Communications Configuration
+==============================================================================
+-->
+
+<preferences EXTERNAL_XML_VERSION="1.0">
+ <root type="user">
+ <map />
+ <node name="rhq-server">
+ <map />
+ <node name="default">
+ <map>
+ <!--
+ _______________________________________________________________
+ rhq.server.configuration-schema-version
+
+ Defines what version of the server configuration schema this
+ file conforms to. This is the schema for the rhq.server
+ preferences.
+ -->
+ <entry key="rhq.server.configuration-schema-version" value="1" />
+
+ <!--
+ _______________________________________________________________
+ rhq.server.agent-files-directory
+
+ This defines the directory location that contains all the files
+ that can be sent remotely to agents. If this is not defined,
+ this effectively disables the server's ability to remotely
+ send files to agents. If deploying within a JBossAS instance,
+ leave this undefined, and set this as a configuration override
+ property in the server-comm-service.xml
+ deployment configuration file. This will allow you to use the
+ ${jboss.server.home.dir} replacement variable expression
+ as part of the directory location, for example.
+ -->
+ <!--
+ <entry key="rhq.server.agent-files-directory" value="conf" />
+ -->
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.queue-size
+
+ The maximum size of the client command queue - this is the
+ maximum number of commands that can be queued for sending to
+ an agent. If this is 0, then the queue is unbounded.
+ WARNING! Setting this to 0 could lead to resources being used
+ up if for some reason commands keep getting queued but are
+ not getting sent.
+ -->
+ <entry key="rhq.server.client.queue-size" value="50000" />
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.max-concurrent
+
+ The maximum number of concurrent commands that can be in the
+ process of being sent to an agent at any one time.
+ -->
+ <entry key="rhq.server.client.max-concurrent" value="1" />
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.command-timeout-msecs
+
+ The time in milliseconds that the client sender will wait
+ before aborting a command. This is the amount of time in
+ milliseconds that the agent has in order to process commands.
+ This value is only the default if a command has not specified
+ its own timeout. A command can override this by setting its
+ own timeout in the command's configuration, so this value may
+ not be used for all commands that are sent. If this value is
+ less than or equal to 0, there will be no default timeout
+ and commands will therefore be allowed to take as long as they
+ need (again, this is the default, individual commands may
+ override this and set their own timeout). While this infinite
+ timeout default could conceivably cause a thread to hang
+ waiting for a rogue command that never finishes, it also reduces
+ the amount of short-lived threads created by the system
+ and will increase throughput, dramatically in some cases.
+ -->
+ <entry key="rhq.server.client.command-timeout-msecs" value="600000" />
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.retry-interval-msecs
+
+ This is the minimum amount of time, in milliseconds, the client
+ sender will wait before trying to resend a guaranteed command
+ that previously failed. This is not a guarantee of when
+ a command is retried - all that can be inferred is that a
+ command that fails to be sent will not be retried until at
+ least this amount of time passes.
+ Note: if the sender is currently waiting in this retry pause
+ period, the server will not be able to be shutdown until that
+ retry period is over. In other words, if the server is asked
+ to shutdown, it will wait for those commands waiting in this
+ retry interval to wake up. This is to help ensure those
+ commands are not lost.
+ -->
+ <entry key="rhq.server.client.retry-interval-msecs" value="15000" />
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.max-retries
+
+ If a guaranteed delivery message is sent, but the server fails
+ to connect to the agent and deliver the message, it will
+ always be retried. However, if the error was something other
+ than a "cannot connect" error, the command will only be retried
+ this amount of times before the command is dropped. When this
+ happens, the guaranteed command will never be delivered. This
+ will normally happen under very odd and rare circumstances.
+ Also, this setting only effects asynchronous messages that
+ are sent with guaranteed delivery. This setting has no effect
+ on other messages.
+ -->
+ <entry key="rhq.server.client.max-retries" value="10" />
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.command-spool-file.name
+
+ This defines the name of the command spool file. This
+ file must be located in the data directory (if one does not
+ exist, it will be created). Note that if you do not define
+ this setting, the default is to not spool commands to disk
+ and thus implicitly disable guaranteed delivery.
+ -->
+ <!--
+ <entry key="rhq.server.client.command-spool-file.name" value="command-spool.dat" />
+ -->
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.command-spool-file.params
+
+ This defines the parameters for the command spool file.
+ The spool file is where the server persists commands that
+ are flagged for guaranteed delivery and need to be sent.
+ The format is defined as "max-file-size:purge-percentage".
+ The first number is the size, in bytes, of the maximum file
+ size threshold. If the spool file grows larger than this, a
+ "purge" will be triggered in order to shrink the file.
+ The second number is the purge percentage which indicates how
+ large the file is allowed to be after a purge. This is
+ specified as a percentage of the first parameter - the max
+ file size threshold. For example, if the max file size is
+ 100000 (i.e. 100KB) and the purge percentage is 90, then when
+ the spool file grows larger than 100KB, a purge will be
+ triggered and the file will be shrunk to no more than
+ 90% of 100KB - which is 90KB. In effect, 10KB will be freed
+ to allow room for new commands to be spooled. When this
+ occurs, unused space is freed first and if that does not
+ free up enough space, the oldest commands in the spool file
+ will be sacrificed in order to make room for the newer
+ commands.
+ -->
+ <entry key="rhq.server.client.command-spool-file.params" value="1000000:75" />
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.command-spool-file.compressed
+
+ If this flag is true, the commands stored in the spool file
+ will be compressed. This can potentially save about 30%-40% in
+ disk space (give or take), however, it slows down the
+ persistence mechanism considerably. Recommended setting for
+ this should be false unless something on the server deployment
+ box warrants disk-saving over persistence performance.
+ -->
+ <entry key="rhq.server.client.command-spool-file.compressed" value="false" />
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.send-throttling
+
+ If this setting is defined, it will enable send throttling to
+ occur while sending commands to an agent. The format is
+ defined as "max-commands:quiet-period-milliseconds"
+ where the maximum commands defines the maximum number
+ of commands that will be sent before the start of a quiet
+ period. The quiet period defines the number of milliseconds
+ in which no commands should be sent. After this duration
+ expires, commands can again be sent, up to the maximum defined.
+ Note that send throttling only affects those commands that
+ are "throttle-able". Some commands are sent as soon as
+ possible, regardless of the throttling settings.
+
+ This affects sending commands synchronously and asynchronously.
+ -->
+ <!--
+ <entry key="rhq.server.client.send-throttling" value="100:1000" />
+ -->
+
+ <!--
+ _______________________________________________________________
+ rhq.server.client.queue-throttling
+
+ If this setting is defined, it will enable queue throttling to
+ occur while sending commands to an agent. The format is
+ defined as "max-commands-per-burst:burst-period-milliseconds"
+ where the maximum commands per burst defines the maximum number
+ of commands that can be dequeued within a burst period. The
+ burst period defines the number of milliseconds in which the
+ defined maximum number of commands can be dequeued. If more
+ than the maximum number of commands are queued within this
+ time period, they will wait until the next burst period starts
+ before being able to be dequeued.
+
+ This does not affect sending commands synchronously. It only
+ effects commands queued to be sent asynchronously.
+ -->
+ <!--
+ <entry key="rhq.server.client.queue-throttling" value="50:3000" />
+ -->
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.configuration-schema-version
+
+ Defines what version of the configuration schema this
+ file conforms to. This is the schema for the
+ rhq.communications preferences.
+ -->
+ <entry key="rhq.communications.configuration-schema-version" value="1" />
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.service-container.mbean-server-name
+
+ Name of the MBean Server that houses the communications MBean
+ services. This is actually the default domain name of the
+ MBean Server and if an MBean Server has already been registered
+ with this name, it will be used to house the communications
+ services. If an MBean Server has not yet been registered with
+ this name as its default domain, one will be created.
+ If deploying within a JBossAS instance, the JBoss MBeanServer
+ will be used, so this value can be left undefined since it
+ will be unused.
+ -->
+ <!--
+ <entry key="rhq.communications.service-container.mbean-server-name" value="jboss-on" />
+ -->
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.data-directory
+
+ The location where the communication services write internal
+ data files. If deploying within a JBossAS instance, leave
+ this undefined, and set this as a configuration override
+ property in the server-comm-service.xml deployment
+ configuration file. This will allow you to use the
+ ${jboss.server.data.dir} replacement variable as the data
+ directory location.
+ -->
+ <!--
+ <entry key="rhq.communications.data-directory" value="data" />
+ -->
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.global-concurrency-limit
+
+ The maximum number of incoming commands that are allowed to be
+ received concurrently. Any extra commands received over this
+ amount will be dropped and the client will be asked to
+ resend it later.
+ -->
+ <entry key="rhq.communications.global-concurrency-limit" value="200" />
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.multicast-detector.enabled
+ rhq.communications.multicast-detector.multicast-address
+ rhq.communications.multicast-detector.bind-address
+ rhq.communications.multicast-detector.port
+ rhq.communications.multicast-detector.default-time-delay
+ rhq.communications.multicast-detector.heartbeat-time-delay
+
+ The multicast detector configuration. This is the service that
+ listens for new remote servers/agents coming on and going offline
+ and is required if you want agent auto-detection. If you do not
+ have auto-detection enabled or your network will not
+ support multicast traffic, you should disable the multicast
+ detector.
+
+ The multicast-address is used to broadcast detection messages.
+ To be more specific, it is the IP address of the
+ multicast group the detector will join. The bind-address
+ is the IP that is bound by the network interface.
+
+ The detector will send heartbeat messages every X milliseconds
+ (this is the heartbeat-time-delay). If external servers'
+ detectors do not send their heartbeat messages within the
+ default-time-delay, our detector will assume that external
+ server has gone down. These settings affect the timeliness
+ of our auto-detection mechanism.
+ -->
+ <entry key="rhq.communications.multicast-detector.enabled" value="false" />
+ <entry key="rhq.communications.multicast-detector.multicast-address" value="224.16.16.16" />
+ <entry key="rhq.communications.multicast-detector.bind-address" value="0.0.0.0" />
+ <entry key="rhq.communications.multicast-detector.port" value="16162" />
+ <entry key="rhq.communications.multicast-detector.default-time-delay" value="5000" />
+ <entry key="rhq.communications.multicast-detector.heartbeat-time-delay" value="1000" />
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.connector.rhqtype
+ rhq.communications.connector.transport
+ rhq.communications.connector.bind-port
+ rhq.communications.connector.bind-address
+ rhq.communications.connector.transport-params
+ rhq.communications.connector.lease-period
+
+ The server connector configuration. This is the service that
+ listens for incoming agent requests and passes them to the
+ appropriate server-side components for processing. See the
+ JBoss/Remoting documentation for a full list of options
+ that can be specified. Note that because this is an XML file,
+ you must specify "&" in the transport-params value
+ when needing an ampersand to separate the parameters.
+ -->
+ <entry key="rhq.communications.connector.rhqtype" value="server" />
+ <entry key="rhq.communications.connector.transport" value="servlet" />
+ <entry key="rhq.communications.connector.bind-port" value="7080" />
+ <entry key="rhq.communications.connector.transport-params" value="/jboss-remoting-servlet-invoker/ServerInvokerServlet" />
+ <!--
+ <entry key="rhq.communications.connector.bind-address" value="127.0.0.1" />
+ <entry key="rhq.communications.connector.lease-period" value="5000" />
+ -->
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.connector.security.secure-socket-protocol
+ rhq.communications.connector.security.keystore.file
+ rhq.communications.connector.security.keystore.algorithm
+ rhq.communications.connector.security.keystore.type
+ rhq.communications.connector.security.keystore.password
+ rhq.communications.connector.security.keystore.key-password
+ rhq.communications.connector.security.keystore.alias
+ rhq.communications.connector.security.truststore.file
+ rhq.communications.connector.security.truststore.algorithm
+ rhq.communications.connector.security.truststore.type
+ rhq.communications.connector.security.truststore.password
+ rhq.communications.connector.security.client-auth-mode
+
+ rhq.server.client.security.secure-socket-protocol
+ rhq.server.client.security.keystore.file
+ rhq.server.client.security.keystore.algorithm
+ rhq.server.client.security.keystore.type
+ rhq.server.client.security.keystore.password
+ rhq.server.client.security.keystore.key-password
+ rhq.server.client.security.keystore.alias
+ rhq.server.client.security.truststore.file
+ rhq.server.client.security.truststore.algorithm
+ rhq.server.client.security.truststore.type
+ rhq.server.client.security.truststore.password
+ rhq.server.client.security.server-auth-mode-enabled
+
+ These are the settings that are used if SSL is to be used for
+ either the server or client communications. These can be left
+ unset since the defaults will normally suffice. These
+ properties are here just in case some use case occurs that
+ require one or more of these settings to be customized.
+
+ Note that if client-auth-mode is specified, it must be one of:
+ "none", "want", "need". To support Tomcat syntax, "true" can be used
+ in place of "need" and "false" can be used in place of "none".
+ -->
+ <!--
+ <entry key="rhq.communications.connector.security.secure-socket-protocol" value="TLS" />
+ <entry key="rhq.communications.connector.security.keystore.file" value="data/keystore.dat" />
+ <entry key="rhq.communications.connector.security.keystore.algorithm" value="SunX509" />
+ <entry key="rhq.communications.connector.security.keystore.type" value="JKS" />
+ <entry key="rhq.communications.connector.security.keystore.password" value="rhqpwd" />
+ <entry key="rhq.communications.connector.security.keystore.key-password" value="rhqpwd" />
+ <entry key="rhq.communications.connector.security.keystore.alias" value="rhq" />
+ <entry key="rhq.communications.connector.security.truststore.file" value="data/truststore.dat" />
+ <entry key="rhq.communications.connector.security.truststore.algorithm" value="SunX509" />
+ <entry key="rhq.communications.connector.security.truststore.type" value="JKS" />
+ <entry key="rhq.communications.connector.security.truststore.password" value="" />
+ <entry key="rhq.communications.connector.security.client-auth-mode" value="none" />
+
+ <entry key="rhq.server.client.security.secure-socket-protocol" value="TLS" />
+ <entry key="rhq.server.client.security.keystore.file" value="data/keystore.dat" />
+ <entry key="rhq.server.client.security.keystore.algorithm" value="SunX509" />
+ <entry key="rhq.server.client.security.keystore.type" value="JKS" />
+ <entry key="rhq.server.client.security.keystore.password" value="rhqpwd" />
+ <entry key="rhq.server.client.security.keystore.alias" value="rhq" />
+ <entry key="rhq.server.client.security.keystore.key-password" value="rhqpwd" />
+ <entry key="rhq.server.client.security.truststore.file" value="data/truststore.dat" />
+ <entry key="rhq.server.client.security.truststore.algorithm" value="SunX509" />
+ <entry key="rhq.server.client.security.truststore.type" value="JKS" />
+ <entry key="rhq.server.client.security.truststore.password" value="" />
+ <entry key="rhq.server.client.security.server-auth-mode-enabled" value="false" />
+ -->
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.remote-stream-max-idle-time-msecs
+
+ The maximum amount of milliseconds a remoted stream
+ is allowed to be idle before it is automatically closed and
+ removed from the server. This means that a client must
+ attempt to access the remoted stream every X milliseconds
+ (where X is the value of this setting) or that stream will no
+ longer be available. Note that this does not mean a client
+ must read or write the entire stream in this amount of time,
+ it only means a client must make a request on the stream every
+ X milliseconds (be it to read or write one byte, see how many
+ bytes are available to be read, etc).
+ -->
+ <entry key="rhq.communications.remote-stream-max-idle-time-msecs" value="300000" />
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.command-service-directory.allow-dynamic-discovery
+
+ Flag to allow new command services to be added to the command
+ services directory during runtime. If this is false, only
+ those services defined in the
+ rhq.communications.command-services preference will be available
+ during the lifetime of the command service directory.
+ -->
+ <entry key="rhq.communications.command-service-directory.allow-dynamic-discovery" value="true" />
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.command-services
+
+ Command Services that are to be added immediately at startup.
+ -->
+ <entry key="rhq.communications.command-services" value="org.rhq.enterprise.communications.command.impl.echo.server.EchoCommandService, org.rhq.enterprise.communications.command.impl.identify.server.IdentifyCommandService" />
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.remote-pojos
+
+ Objects that are to be created and their remote interfaces
+ deployed immediately at startup. The format of the value is
+ a comma separated list of implementation/interface names:
+ class.to.instantiate.via.noarg.constructor:interface.to.expose
+ -->
+ <entry key="rhq.communications.remote-pojos"
+ value="org.rhq.enterprise.communications.PingImpl:org.rhq.enterprise.communications.Ping,org.rhq.enterprise.server.core.CoreServerServiceImpl:org.rhq.core.clientapi.server.core.CoreServerService,org.rhq.enterprise.server.discovery.DiscoveryServerServiceImpl:org.rhq.core.clientapi.server.discovery.DiscoveryServerService,org.rhq.enterprise.server.measurement.MeasurementServerServiceImpl:org.rhq.core.clientapi.server.measurement.MeasurementServerService,org.rhq.enterprise.server.operation.OperationServerServiceImpl:org.rhq.core.clientapi.server.operation.OperationServerService,org.rhq.enterprise.server.configuration.ConfigurationServerServiceImpl:org.rhq.core.clientapi.server.configuration.ConfigurationServerService,org.rhq.enterprise.server.resource.ResourceFactoryServerServiceImpl:org.rhq.core.clientapi.server.inventory.ResourceFactoryServerService,org.rhq.enterprise.server.content.ContentServerServiceImpl:org.rhq.core.clientapi.server.content.ContentSer
verService,org.rhq.enterprise.server.event.EventServerServiceImpl:org.rhq.core.clientapi.server.event.EventServerService,org.rhq.enterprise.server.bundle.BundleServerServiceImpl:org.rhq.core.clientapi.server.bundle.BundleServerService,org.rhq.enterprise.server.drift.DriftServerServiceImpl:org.rhq.core.clientapi.server.drift.DriftServerService" />
+
+ <!--
+ _______________________________________________________________
+ rhq.communications.command-authenticator
+
+ A command authenticator class that will be used to authenticate incoming commands.
+ -->
+ <entry key="rhq.communications.command-authenticator" value="org.rhq.enterprise.server.core.comm.SecurityTokenCommandAuthenticator" />
+
+ </map>
+ </node>
+ </node>
+ </root>
+</preferences>
+
\ No newline at end of file
diff --git a/modules/enterprise/server/sars/services-sar/src/main/resources/META-INF/jboss-service.xml b/modules/enterprise/server/sars/services-sar/src/main/resources/META-INF/jboss-service.xml
index a4b3a9a..c427db8 100644
--- a/modules/enterprise/server/sars/services-sar/src/main/resources/META-INF/jboss-service.xml
+++ b/modules/enterprise/server/sars/services-sar/src/main/resources/META-INF/jboss-service.xml
@@ -3,65 +3,65 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:service:7.0 jboss-service_7_0.xsd">
- <mbean code="org.rhq.enterprise.server.core.CustomJaasDeploymentService"
- name="rhq:service=CustomJaasDeployment" />
+ <!--<mbean code="org.rhq.enterprise.server.core.CustomJaasDeploymentService"-->
+ <!--name="rhq:service=CustomJaasDeployment" />-->
- <mbean code="org.rhq.enterprise.server.core.CoreServer"
- name="rhq:service=CoreServer" />
+ <!--<mbean code="org.rhq.enterprise.server.core.CoreServer"-->
+ <!--name="rhq:service=CoreServer" />-->
- <mbean code="org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor"
- name="rhq:service=MeasurementMonitor" />
+ <!--<mbean code="org.rhq.enterprise.server.measurement.instrumentation.MeasurementMonitor"-->
+ <!--name="rhq:service=MeasurementMonitor" />-->
- <mbean code="org.rhq.enterprise.server.alert.engine.mbean.AlertConditionCacheMonitor"
- name="rhq:service=AlertConditionCacheMonitor" />
+ <!--<mbean code="org.rhq.enterprise.server.alert.engine.mbean.AlertConditionCacheMonitor"-->
+ <!--name="rhq:service=AlertConditionCacheMonitor" />-->
- <mbean code="org.rhq.enterprise.server.resource.group.definition.mbean.GroupDefinitionRecalculationThreadMonitor"
- name="rhq:service=GroupDefinitionRecalculationThreadMonitor" />
+ <!--<mbean code="org.rhq.enterprise.server.resource.group.definition.mbean.GroupDefinitionRecalculationThreadMonitor"-->
+ <!--name="rhq:service=GroupDefinitionRecalculationThreadMonitor" />-->
- <mbean code="org.rhq.enterprise.server.core.plugin.PluginDeploymentScanner"
- name="rhq:service=PluginDeploymentScanner">
- <attribute name="ScanPeriod">${rhq.server.plugin-scan-period-ms:300000}</attribute>
- </mbean>
+ <!--<mbean code="org.rhq.enterprise.server.core.plugin.PluginDeploymentScanner"-->
+ <!--name="rhq:service=PluginDeploymentScanner">-->
+ <!--<attribute name="ScanPeriod">${rhq.server.plugin-scan-period-ms:300000}</attribute>-->
+ <!--</mbean>-->
- <mbean code="org.rhq.enterprise.server.scheduler.SchedulerService"
- name="rhq:service=scheduler">
- <attribute name="QuartzProperties">
-# RHQ custom property that defines the default timeout for all operations.
-# This is specified in seconds. If any operation takes longer than this, it is assumed to have failed.
-rhq.server.operation-timeout = ${rhq.server.operation-timeout:600}
+ <!--<mbean code="org.rhq.enterprise.server.scheduler.SchedulerService"-->
+ <!--name="rhq:service=scheduler">-->
+ <!--<attribute name="QuartzProperties">-->
+<!--# RHQ custom property that defines the default timeout for all operations.-->
+<!--# This is specified in seconds. If any operation takes longer than this, it is assumed to have failed.-->
+<!--rhq.server.operation-timeout = ${rhq.server.operation-timeout:600}-->
-# scheduler factory config
-org.quartz.scheduler.instanceName = RHQScheduler
-org.quartz.scheduler.instanceId = AUTO
+<!--# scheduler factory config-->
+<!--org.quartz.scheduler.instanceName = RHQScheduler-->
+<!--org.quartz.scheduler.instanceId = AUTO-->
-# thread pool config
-org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
-org.quartz.threadPool.threadCount = 5
+<!--# thread pool config-->
+<!--org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool-->
+<!--org.quartz.threadPool.threadCount = 5-->
-# database config
-# note that the delegate class property should be set at build/installation time
-org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT
-org.quartz.jobStore.driverDelegateClass = ${rhq.server.quartz.driverDelegateClass}
-org.quartz.jobStore.isClustered = true
-org.quartz.jobStore.clusterCheckinInterval = 30000
-org.quartz.jobStore.tablePrefix = RHQ_QRTZ_
-org.quartz.jobStore.useProperties = true
-org.quartz.jobStore.selectWithLockSQL = ${rhq.server.quartz.selectWithLockSQL}
-org.quartz.jobStore.dataSource = RHQDS
-org.quartz.dataSource.RHQDS.jndiURL = java:jboss/datasources/RHQDS
-org.quartz.dataSource.RHQDS.maxConnections = 10
-org.quartz.jobStore.nonManagedTXDataSource = NoTxRHQDS
-org.quartz.dataSource.NoTxRHQDS.jndiURL = java:jboss/datasources/NoTxRHQDS
-org.quartz.dataSource.NoTxRHQDS.maxConnections = 10
-org.quartz.jobStore.lockHandler.class = ${rhq.server.quartz.lockHandlerClass}
- </attribute>
- </mbean>
+<!--# database config-->
+<!--# note that the delegate class property should be set at build/installation time-->
+<!--org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreCMT-->
+<!--org.quartz.jobStore.driverDelegateClass = ${rhq.server.quartz.driverDelegateClass}-->
+<!--org.quartz.jobStore.isClustered = true-->
+<!--org.quartz.jobStore.clusterCheckinInterval = 30000-->
+<!--org.quartz.jobStore.tablePrefix = RHQ_QRTZ_-->
+<!--org.quartz.jobStore.useProperties = true-->
+<!--org.quartz.jobStore.selectWithLockSQL = ${rhq.server.quartz.selectWithLockSQL}-->
+<!--org.quartz.jobStore.dataSource = RHQDS-->
+<!--org.quartz.dataSource.RHQDS.jndiURL = java:jboss/datasources/RHQDS-->
+<!--org.quartz.dataSource.RHQDS.maxConnections = 10-->
+<!--org.quartz.jobStore.nonManagedTXDataSource = NoTxRHQDS-->
+<!--org.quartz.dataSource.NoTxRHQDS.jndiURL = java:jboss/datasources/NoTxRHQDS-->
+<!--org.quartz.dataSource.NoTxRHQDS.maxConnections = 10-->
+<!--org.quartz.jobStore.lockHandler.class = ${rhq.server.quartz.lockHandlerClass}-->
+ <!--</attribute>-->
+ <!--</mbean>-->
- <mbean code="org.rhq.enterprise.server.core.comm.ServerCommunicationsService"
- name="rhq:service=ServerCommunications" />
+ <!--<mbean code="org.rhq.enterprise.server.core.comm.ServerCommunicationsService"-->
+ <!--name="rhq:service=ServerCommunications" />-->
- <mbean code="org.rhq.enterprise.server.plugin.pc.ServerPluginService"
- name="rhq:service=ServerPluginService" />
+ <!--<mbean code="org.rhq.enterprise.server.plugin.pc.ServerPluginService"-->
+ <!--name="rhq:service=ServerPluginService" />-->
<!-- TODO: first, see if we need this and if so we need to refactor this to work inside AS7
<mbean code="org.rhq.jndi.mbean.AccessCheckingInitialContextFactoryBuilderInstaller"
diff --git a/modules/enterprise/server/sars/services-sar/src/main/resources/server-comm-configuration-overrides.properties b/modules/enterprise/server/sars/services-sar/src/main/resources/server-comm-configuration-overrides.properties
deleted file mode 100644
index 91ccc85..0000000
--- a/modules/enterprise/server/sars/services-sar/src/main/resources/server-comm-configuration-overrides.properties
+++ /dev/null
@@ -1,42 +0,0 @@
-# location of the plugin jars and other files agents can download directly from sever
-rhq.server.agent-files-directory=${rhq.server.home}/modules/org/rhq/rhq-enterprise-server-startup-subsystem/main/deployments/rhq.ear/rhq-downloads
-# location where data files can be stored
-rhq.communications.data-directory=${jboss.server.data.dir}
-# global limit on number of concurrent incoming messages allowed
-rhq.communications.global-concurrency-limit=${rhq.communications.global-concurrency-limit:200}
-# Server's remote endpoint for agents to talk to
-rhq.communications.connector.transport=${rhq.communications.connector.transport:servlet}
-rhq.communications.connector.bind-address=${rhq.communications.connector.bind-address}
-rhq.communications.connector.bind-port=${rhq.communications.connector.bind-port:7080}
-rhq.communications.connector.transport-params=${rhq.communications.connector.transport-params:/jboss-remoting-servlet-invoker/ServerInvokerServlet}
-# Multicast detector configuration for auto-discovery
-rhq.communications.multicast-detector.enabled=${rhq.communications.multicast-detector.enabled:false}
-rhq.communications.multicast-detector.multicast-address=${rhq.communications.multicast-detector.multicast-address:224.16.16.16}
-rhq.communications.multicast-detector.bind-address=${rhq.communications.multicast-detector.bind-address}
-rhq.communications.multicast-detector.port=${rhq.communications.multicast-detector.port:16162}
-# Server-side SSL Security Configuration (for incoming messages from agents)
-rhq.communications.connector.security.secure-socket-protocol=${rhq.communications.connector.security.secure-socket-protocol:TLS}
-rhq.communications.connector.security.keystore.file=${rhq.communications.connector.security.keystore.file}
-rhq.communications.connector.security.keystore.algorithm=${rhq.communications.connector.security.keystore.algorithm}
-rhq.communications.connector.security.keystore.type=${rhq.communications.connector.security.keystore.type:JKS}
-rhq.communications.connector.security.keystore.password=${rhq.communications.connector.security.keystore.password:rhqpwd}
-rhq.communications.connector.security.keystore.key-password=${rhq.communications.connector.security.keystore.key-password:rhqpwd}
-rhq.communications.connector.security.keystore.alias=${rhq.communications.connector.security.keystore.alias:rhq}
-rhq.communications.connector.security.truststore.file=${rhq.communications.connector.security.truststore.file}
-rhq.communications.connector.security.truststore.algorithm=${rhq.communications.connector.security.truststore.algorithm}
-rhq.communications.connector.security.truststore.type=${rhq.communications.connector.security.truststore.type:JKS}
-rhq.communications.connector.security.truststore.password=${rhq.communications.connector.security.truststore.password}
-rhq.communications.connector.security.client-auth-mode=${rhq.communications.connector.security.client-auth-mode:none}
-# Client-side SSL Security Configuration (for outgoing messages to agents)
-rhq.server.client.security.secure-socket-protocol=${rhq.server.client.security.secure-socket-protocol:TLS}
-rhq.server.client.security.keystore.file=${rhq.server.client.security.keystore.file}
-rhq.server.client.security.keystore.algorithm=${rhq.server.client.security.keystore.algorithm}
-rhq.server.client.security.keystore.type=${rhq.server.client.security.keystore.type:JKS}
-rhq.server.client.security.keystore.password=${rhq.server.client.security.keystore.password:rhqpwd}
-rhq.server.client.security.keystore.key-password=${rhq.server.client.security.keystore.key-password:rhqpwd}
-rhq.server.client.security.keystore.alias=${rhq.server.client.security.keystore.alias:rhq}
-rhq.server.client.security.truststore.file=${rhq.server.client.security.truststore.file}
-rhq.server.client.security.truststore.algorithm=${rhq.server.client.security.truststore.algorithm}
-rhq.server.client.security.truststore.type=${rhq.server.client.security.truststore.type:JKS}
-rhq.server.client.security.truststore.password=${rhq.server.client.security.truststore.password}
-rhq.server.client.security.server-auth-mode-enabled=${rhq.server.client.security.server-auth-mode-enabled:false}
diff --git a/modules/enterprise/server/sars/services-sar/src/main/resources/server-comm-configuration.xml b/modules/enterprise/server/sars/services-sar/src/main/resources/server-comm-configuration.xml
deleted file mode 100644
index 7f30276..0000000
--- a/modules/enterprise/server/sars/services-sar/src/main/resources/server-comm-configuration.xml
+++ /dev/null
@@ -1,468 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!DOCTYPE preferences SYSTEM 'http://java.sun.com/dtd/preferences.dtd'>
-
-<!--
-==============================================================================
-RHQ Server Communications Configuration
-==============================================================================
--->
-
-<preferences EXTERNAL_XML_VERSION="1.0">
- <root type="user">
- <map />
- <node name="rhq-server">
- <map />
- <node name="default">
- <map>
- <!--
- _______________________________________________________________
- rhq.server.configuration-schema-version
-
- Defines what version of the server configuration schema this
- file conforms to. This is the schema for the rhq.server
- preferences.
- -->
- <entry key="rhq.server.configuration-schema-version" value="1" />
-
- <!--
- _______________________________________________________________
- rhq.server.agent-files-directory
-
- This defines the directory location that contains all the files
- that can be sent remotely to agents. If this is not defined,
- this effectively disables the server's ability to remotely
- send files to agents. If deploying within a JBossAS instance,
- leave this undefined, and set this as a configuration override
- property in the server-comm-service.xml
- deployment configuration file. This will allow you to use the
- ${jboss.server.home.dir} replacement variable expression
- as part of the directory location, for example.
- -->
- <!--
- <entry key="rhq.server.agent-files-directory" value="conf" />
- -->
-
- <!--
- _______________________________________________________________
- rhq.server.client.queue-size
-
- The maximum size of the client command queue - this is the
- maximum number of commands that can be queued for sending to
- an agent. If this is 0, then the queue is unbounded.
- WARNING! Setting this to 0 could lead to resources being used
- up if for some reason commands keep getting queued but are
- not getting sent.
- -->
- <entry key="rhq.server.client.queue-size" value="50000" />
-
- <!--
- _______________________________________________________________
- rhq.server.client.max-concurrent
-
- The maximum number of concurrent commands that can be in the
- process of being sent to an agent at any one time.
- -->
- <entry key="rhq.server.client.max-concurrent" value="1" />
-
- <!--
- _______________________________________________________________
- rhq.server.client.command-timeout-msecs
-
- The time in milliseconds that the client sender will wait
- before aborting a command. This is the amount of time in
- milliseconds that the agent has in order to process commands.
- This value is only the default if a command has not specified
- its own timeout. A command can override this by setting its
- own timeout in the command's configuration, so this value may
- not be used for all commands that are sent. If this value is
- less than or equal to 0, there will be no default timeout
- and commands will therefore be allowed to take as long as they
- need (again, this is the default, individual commands may
- override this and set their own timeout). While this infinite
- timeout default could conceivably cause a thread to hang
- waiting for a rogue command that never finishes, it also reduces
- the amount of short-lived threads created by the system
- and will increase throughput, dramatically in some cases.
- -->
- <entry key="rhq.server.client.command-timeout-msecs" value="600000" />
-
- <!--
- _______________________________________________________________
- rhq.server.client.retry-interval-msecs
-
- This is the minimum amount of time, in milliseconds, the client
- sender will wait before trying to resend a guaranteed command
- that previously failed. This is not a guarantee of when
- a command is retried - all that can be inferred is that a
- command that fails to be sent will not be retried until at
- least this amount of time passes.
- Note: if the sender is currently waiting in this retry pause
- period, the server will not be able to be shutdown until that
- retry period is over. In other words, if the server is asked
- to shutdown, it will wait for those commands waiting in this
- retry interval to wake up. This is to help ensure those
- commands are not lost.
- -->
- <entry key="rhq.server.client.retry-interval-msecs" value="15000" />
-
- <!--
- _______________________________________________________________
- rhq.server.client.max-retries
-
- If a guaranteed delivery message is sent, but the server fails
- to connect to the agent and deliver the message, it will
- always be retried. However, if the error was something other
- than a "cannot connect" error, the command will only be retried
- this amount of times before the command is dropped. When this
- happens, the guaranteed command will never be delivered. This
- will normally happen under very odd and rare circumstances.
- Also, this setting only effects asynchronous messages that
- are sent with guaranteed delivery. This setting has no effect
- on other messages.
- -->
- <entry key="rhq.server.client.max-retries" value="10" />
-
- <!--
- _______________________________________________________________
- rhq.server.client.command-spool-file.name
-
- This defines the name of the command spool file. This
- file must be located in the data directory (if one does not
- exist, it will be created). Note that if you do not define
- this setting, the default is to not spool commands to disk
- and thus implicitly disable guaranteed delivery.
- -->
- <!--
- <entry key="rhq.server.client.command-spool-file.name" value="command-spool.dat" />
- -->
-
- <!--
- _______________________________________________________________
- rhq.server.client.command-spool-file.params
-
- This defines the parameters for the command spool file.
- The spool file is where the server persists commands that
- are flagged for guaranteed delivery and need to be sent.
- The format is defined as "max-file-size:purge-percentage".
- The first number is the size, in bytes, of the maximum file
- size threshold. If the spool file grows larger than this, a
- "purge" will be triggered in order to shrink the file.
- The second number is the purge percentage which indicates how
- large the file is allowed to be after a purge. This is
- specified as a percentage of the first parameter - the max
- file size threshold. For example, if the max file size is
- 100000 (i.e. 100KB) and the purge percentage is 90, then when
- the spool file grows larger than 100KB, a purge will be
- triggered and the file will be shrunk to no more than
- 90% of 100KB - which is 90KB. In effect, 10KB will be freed
- to allow room for new commands to be spooled. When this
- occurs, unused space is freed first and if that does not
- free up enough space, the oldest commands in the spool file
- will be sacrificed in order to make room for the newer
- commands.
- -->
- <entry key="rhq.server.client.command-spool-file.params" value="1000000:75" />
-
- <!--
- _______________________________________________________________
- rhq.server.client.command-spool-file.compressed
-
- If this flag is true, the commands stored in the spool file
- will be compressed. This can potentially save about 30%-40% in
- disk space (give or take), however, it slows down the
- persistence mechanism considerably. Recommended setting for
- this should be false unless something on the server deployment
- box warrants disk-saving over persistence performance.
- -->
- <entry key="rhq.server.client.command-spool-file.compressed" value="false" />
-
- <!--
- _______________________________________________________________
- rhq.server.client.send-throttling
-
- If this setting is defined, it will enable send throttling to
- occur while sending commands to an agent. The format is
- defined as "max-commands:quiet-period-milliseconds"
- where the maximum commands defines the maximum number
- of commands that will be sent before the start of a quiet
- period. The quiet period defines the number of milliseconds
- in which no commands should be sent. After this duration
- expires, commands can again be sent, up to the maximum defined.
- Note that send throttling only affects those commands that
- are "throttle-able". Some commands are sent as soon as
- possible, regardless of the throttling settings.
-
- This affects sending commands synchronously and asynchronously.
- -->
- <!--
- <entry key="rhq.server.client.send-throttling" value="100:1000" />
- -->
-
- <!--
- _______________________________________________________________
- rhq.server.client.queue-throttling
-
- If this setting is defined, it will enable queue throttling to
- occur while sending commands to an agent. The format is
- defined as "max-commands-per-burst:burst-period-milliseconds"
- where the maximum commands per burst defines the maximum number
- of commands that can be dequeued within a burst period. The
- burst period defines the number of milliseconds in which the
- defined maximum number of commands can be dequeued. If more
- than the maximum number of commands are queued within this
- time period, they will wait until the next burst period starts
- before being able to be dequeued.
-
- This does not affect sending commands synchronously. It only
- effects commands queued to be sent asynchronously.
- -->
- <!--
- <entry key="rhq.server.client.queue-throttling" value="50:3000" />
- -->
-
- <!--
- _______________________________________________________________
- rhq.communications.configuration-schema-version
-
- Defines what version of the configuration schema this
- file conforms to. This is the schema for the
- rhq.communications preferences.
- -->
- <entry key="rhq.communications.configuration-schema-version" value="1" />
-
- <!--
- _______________________________________________________________
- rhq.communications.service-container.mbean-server-name
-
- Name of the MBean Server that houses the communications MBean
- services. This is actually the default domain name of the
- MBean Server and if an MBean Server has already been registered
- with this name, it will be used to house the communications
- services. If an MBean Server has not yet been registered with
- this name as its default domain, one will be created.
- If deploying within a JBossAS instance, the JBoss MBeanServer
- will be used, so this value can be left undefined since it
- will be unused.
- -->
- <!--
- <entry key="rhq.communications.service-container.mbean-server-name" value="jboss-on" />
- -->
-
- <!--
- _______________________________________________________________
- rhq.communications.data-directory
-
- The location where the communication services write internal
- data files. If deploying within a JBossAS instance, leave
- this undefined, and set this as a configuration override
- property in the server-comm-service.xml deployment
- configuration file. This will allow you to use the
- ${jboss.server.data.dir} replacement variable as the data
- directory location.
- -->
- <!--
- <entry key="rhq.communications.data-directory" value="data" />
- -->
-
- <!--
- _______________________________________________________________
- rhq.communications.global-concurrency-limit
-
- The maximum number of incoming commands that are allowed to be
- received concurrently. Any extra commands received over this
- amount will be dropped and the client will be asked to
- resend it later.
- -->
- <entry key="rhq.communications.global-concurrency-limit" value="200" />
-
- <!--
- _______________________________________________________________
- rhq.communications.multicast-detector.enabled
- rhq.communications.multicast-detector.multicast-address
- rhq.communications.multicast-detector.bind-address
- rhq.communications.multicast-detector.port
- rhq.communications.multicast-detector.default-time-delay
- rhq.communications.multicast-detector.heartbeat-time-delay
-
- The multicast detector configuration. This is the service that
- listens for new remote servers/agents coming on and going offline
- and is required if you want agent auto-detection. If you do not
- have auto-detection enabled or your network will not
- support multicast traffic, you should disable the multicast
- detector.
-
- The multicast-address is used to broadcast detection messages.
- To be more specific, it is the IP address of the
- multicast group the detector will join. The bind-address
- is the IP that is bound by the network interface.
-
- The detector will send heartbeat messages every X milliseconds
- (this is the heartbeat-time-delay). If external servers'
- detectors do not send their heartbeat messages within the
- default-time-delay, our detector will assume that external
- server has gone down. These settings affect the timeliness
- of our auto-detection mechanism.
- -->
- <entry key="rhq.communications.multicast-detector.enabled" value="false" />
- <entry key="rhq.communications.multicast-detector.multicast-address" value="224.16.16.16" />
- <entry key="rhq.communications.multicast-detector.bind-address" value="0.0.0.0" />
- <entry key="rhq.communications.multicast-detector.port" value="16162" />
- <entry key="rhq.communications.multicast-detector.default-time-delay" value="5000" />
- <entry key="rhq.communications.multicast-detector.heartbeat-time-delay" value="1000" />
-
- <!--
- _______________________________________________________________
- rhq.communications.connector.rhqtype
- rhq.communications.connector.transport
- rhq.communications.connector.bind-port
- rhq.communications.connector.bind-address
- rhq.communications.connector.transport-params
- rhq.communications.connector.lease-period
-
- The server connector configuration. This is the service that
- listens for incoming agent requests and passes them to the
- appropriate server-side components for processing. See the
- JBoss/Remoting documentation for a full list of options
- that can be specified. Note that because this is an XML file,
- you must specify "&" in the transport-params value
- when needing an ampersand to separate the parameters.
- -->
- <entry key="rhq.communications.connector.rhqtype" value="server" />
- <entry key="rhq.communications.connector.transport" value="servlet" />
- <entry key="rhq.communications.connector.bind-port" value="7080" />
- <entry key="rhq.communications.connector.transport-params" value="/jboss-remoting-servlet-invoker/ServerInvokerServlet" />
- <!--
- <entry key="rhq.communications.connector.bind-address" value="127.0.0.1" />
- <entry key="rhq.communications.connector.lease-period" value="5000" />
- -->
-
- <!--
- _______________________________________________________________
- rhq.communications.connector.security.secure-socket-protocol
- rhq.communications.connector.security.keystore.file
- rhq.communications.connector.security.keystore.algorithm
- rhq.communications.connector.security.keystore.type
- rhq.communications.connector.security.keystore.password
- rhq.communications.connector.security.keystore.key-password
- rhq.communications.connector.security.keystore.alias
- rhq.communications.connector.security.truststore.file
- rhq.communications.connector.security.truststore.algorithm
- rhq.communications.connector.security.truststore.type
- rhq.communications.connector.security.truststore.password
- rhq.communications.connector.security.client-auth-mode
-
- rhq.server.client.security.secure-socket-protocol
- rhq.server.client.security.keystore.file
- rhq.server.client.security.keystore.algorithm
- rhq.server.client.security.keystore.type
- rhq.server.client.security.keystore.password
- rhq.server.client.security.keystore.key-password
- rhq.server.client.security.keystore.alias
- rhq.server.client.security.truststore.file
- rhq.server.client.security.truststore.algorithm
- rhq.server.client.security.truststore.type
- rhq.server.client.security.truststore.password
- rhq.server.client.security.server-auth-mode-enabled
-
- These are the settings that are used if SSL is to be used for
- either the server or client communications. These can be left
- unset since the defaults will normally suffice. These
- properties are here just in case some use case occurs that
- require one or more of these settings to be customized.
-
- Note that if client-auth-mode is specified, it must be one of:
- "none", "want", "need". To support Tomcat syntax, "true" can be used
- in place of "need" and "false" can be used in place of "none".
- -->
- <!--
- <entry key="rhq.communications.connector.security.secure-socket-protocol" value="TLS" />
- <entry key="rhq.communications.connector.security.keystore.file" value="data/keystore.dat" />
- <entry key="rhq.communications.connector.security.keystore.algorithm" value="SunX509" />
- <entry key="rhq.communications.connector.security.keystore.type" value="JKS" />
- <entry key="rhq.communications.connector.security.keystore.password" value="rhqpwd" />
- <entry key="rhq.communications.connector.security.keystore.key-password" value="rhqpwd" />
- <entry key="rhq.communications.connector.security.keystore.alias" value="rhq" />
- <entry key="rhq.communications.connector.security.truststore.file" value="data/truststore.dat" />
- <entry key="rhq.communications.connector.security.truststore.algorithm" value="SunX509" />
- <entry key="rhq.communications.connector.security.truststore.type" value="JKS" />
- <entry key="rhq.communications.connector.security.truststore.password" value="" />
- <entry key="rhq.communications.connector.security.client-auth-mode" value="none" />
-
- <entry key="rhq.server.client.security.secure-socket-protocol" value="TLS" />
- <entry key="rhq.server.client.security.keystore.file" value="data/keystore.dat" />
- <entry key="rhq.server.client.security.keystore.algorithm" value="SunX509" />
- <entry key="rhq.server.client.security.keystore.type" value="JKS" />
- <entry key="rhq.server.client.security.keystore.password" value="rhqpwd" />
- <entry key="rhq.server.client.security.keystore.alias" value="rhq" />
- <entry key="rhq.server.client.security.keystore.key-password" value="rhqpwd" />
- <entry key="rhq.server.client.security.truststore.file" value="data/truststore.dat" />
- <entry key="rhq.server.client.security.truststore.algorithm" value="SunX509" />
- <entry key="rhq.server.client.security.truststore.type" value="JKS" />
- <entry key="rhq.server.client.security.truststore.password" value="" />
- <entry key="rhq.server.client.security.server-auth-mode-enabled" value="false" />
- -->
-
- <!--
- _______________________________________________________________
- rhq.communications.remote-stream-max-idle-time-msecs
-
- The maximum amount of milliseconds a remoted stream
- is allowed to be idle before it is automatically closed and
- removed from the server. This means that a client must
- attempt to access the remoted stream every X milliseconds
- (where X is the value of this setting) or that stream will no
- longer be available. Note that this does not mean a client
- must read or write the entire stream in this amount of time,
- it only means a client must make a request on the stream every
- X milliseconds (be it to read or write one byte, see how many
- bytes are available to be read, etc).
- -->
- <entry key="rhq.communications.remote-stream-max-idle-time-msecs" value="300000" />
-
- <!--
- _______________________________________________________________
- rhq.communications.command-service-directory.allow-dynamic-discovery
-
- Flag to allow new command services to be added to the command
- services directory during runtime. If this is false, only
- those services defined in the
- rhq.communications.command-services preference will be available
- during the lifetime of the command service directory.
- -->
- <entry key="rhq.communications.command-service-directory.allow-dynamic-discovery" value="true" />
-
- <!--
- _______________________________________________________________
- rhq.communications.command-services
-
- Command Services that are to be added immediately at startup.
- -->
- <entry key="rhq.communications.command-services" value="org.rhq.enterprise.communications.command.impl.echo.server.EchoCommandService, org.rhq.enterprise.communications.command.impl.identify.server.IdentifyCommandService" />
-
- <!--
- _______________________________________________________________
- rhq.communications.remote-pojos
-
- Objects that are to be created and their remote interfaces
- deployed immediately at startup. The format of the value is
- a comma separated list of implementation/interface names:
- class.to.instantiate.via.noarg.constructor:interface.to.expose
- -->
- <entry key="rhq.communications.remote-pojos"
- value="org.rhq.enterprise.communications.PingImpl:org.rhq.enterprise.communications.Ping,org.rhq.enterprise.server.core.CoreServerServiceImpl:org.rhq.core.clientapi.server.core.CoreServerService,org.rhq.enterprise.server.discovery.DiscoveryServerServiceImpl:org.rhq.core.clientapi.server.discovery.DiscoveryServerService,org.rhq.enterprise.server.measurement.MeasurementServerServiceImpl:org.rhq.core.clientapi.server.measurement.MeasurementServerService,org.rhq.enterprise.server.operation.OperationServerServiceImpl:org.rhq.core.clientapi.server.operation.OperationServerService,org.rhq.enterprise.server.configuration.ConfigurationServerServiceImpl:org.rhq.core.clientapi.server.configuration.ConfigurationServerService,org.rhq.enterprise.server.resource.ResourceFactoryServerServiceImpl:org.rhq.core.clientapi.server.inventory.ResourceFactoryServerService,org.rhq.enterprise.server.content.ContentServerServiceImpl:org.rhq.core.clientapi.server.content.ContentSer
verService,org.rhq.enterprise.server.event.EventServerServiceImpl:org.rhq.core.clientapi.server.event.EventServerService,org.rhq.enterprise.server.bundle.BundleServerServiceImpl:org.rhq.core.clientapi.server.bundle.BundleServerService,org.rhq.enterprise.server.drift.DriftServerServiceImpl:org.rhq.core.clientapi.server.drift.DriftServerService" />
-
- <!--
- _______________________________________________________________
- rhq.communications.command-authenticator
-
- A command authenticator class that will be used to authenticate incoming commands.
- -->
- <entry key="rhq.communications.command-authenticator" value="org.rhq.enterprise.server.core.comm.SecurityTokenCommandAuthenticator" />
-
- </map>
- </node>
- </node>
- </root>
-</preferences>
-
\ No newline at end of file
diff --git a/modules/enterprise/server/startup-subsystem/pom.xml b/modules/enterprise/server/startup-subsystem/pom.xml
index 45d0c15..3b5b2ba 100644
--- a/modules/enterprise/server/startup-subsystem/pom.xml
+++ b/modules/enterprise/server/startup-subsystem/pom.xml
@@ -92,6 +92,11 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-ejb3</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss</groupId>
<artifactId>staxmapper</artifactId>
<scope>provided</scope>
diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java
index 265625a..5cc063b 100644
--- a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java
+++ b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupExtension.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.startup;
@@ -64,7 +64,7 @@ public class StartupExtension implements Extension {
static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);
// the deployments we are managing
- static final String DEPLOYMENT_APP_EAR = "rhq.ear";
+ public static final String DEPLOYMENT_APP_EAR = "rhq.ear";
// our management API version
private static final int API_MAJOR_VERSION = 1;
diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java
index 54d14f4..80515ed 100644
--- a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java
+++ b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/StartupSubsystemAdd.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.startup;
@@ -30,25 +30,37 @@ import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.URL
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
+import java.util.List;
-import org.jboss.as.controller.AbstractAddStepHandler;
+import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.ServiceVerificationHandler;
import org.jboss.as.controller.operations.common.Util;
import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
+import org.jboss.as.server.AbstractDeploymentChainStep;
+import org.jboss.as.server.DeploymentProcessorTarget;
+import org.jboss.as.server.deployment.Phase;
import org.jboss.dmr.ModelNode;
+import org.jboss.logging.Logger;
import org.jboss.modules.Module;
+import org.jboss.msc.service.ServiceController;
+
+import org.rhq.enterprise.startup.deployment.RhqInitializationProcessor;
+import org.rhq.enterprise.startup.deployment.RhqShutdownBeanDependenciesProcessor;
/**
* Handler responsible for adding the subsystem resource to the model
*
* @author John Mazzitelli
*/
-class StartupSubsystemAdd extends AbstractAddStepHandler {
+class StartupSubsystemAdd extends AbstractBoottimeAddStepHandler {
+
+ private static final Logger LOG = Logger.getLogger(StartupSubsystemAdd.class);
static final StartupSubsystemAdd INSTANCE = new StartupSubsystemAdd();
@@ -109,4 +121,20 @@ class StartupSubsystemAdd extends AbstractAddStepHandler {
protected boolean requiresRuntimeVerification() {
return false;
}
+
+ @Override
+ protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model,
+ ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers)
+ throws OperationFailedException {
+ LOG.info("Adding RHQ deploymentUnit processors");
+ context.addStep(new AbstractDeploymentChainStep() {
+ public void execute(DeploymentProcessorTarget processorTarget) {
+ processorTarget.addDeploymentProcessor(StartupExtension.SUBSYSTEM_NAME, Phase.STRUCTURE,
+ Phase.STRUCTURE_EAR + 10, new RhqInitializationProcessor());
+ processorTarget.addDeploymentProcessor(StartupExtension.SUBSYSTEM_NAME, Phase.INSTALL,
+ Phase.INSTALL_DEPENDS_ON_ANNOTATION + 10, new RhqShutdownBeanDependenciesProcessor());
+ }
+ }, OperationContext.Stage.RUNTIME);
+ }
+
}
diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqDeploymentMarker.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqDeploymentMarker.java
new file mode 100644
index 0000000..ff98956
--- /dev/null
+++ b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqDeploymentMarker.java
@@ -0,0 +1,49 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package org.rhq.enterprise.startup.deployment;
+
+import org.jboss.as.server.deployment.AttachmentKey;
+import org.jboss.as.server.deployment.DeploymentUnit;
+
+/**
+ * Marker for RHQ EAR. Deployment Unit Processors will only process RHQ EAR sub deployments.
+ *
+ * @author Thomas Segismont
+ */
+class RhqDeploymentMarker {
+ private static final AttachmentKey<RhqDeploymentMarker> MARKER = AttachmentKey.create(RhqDeploymentMarker.class);
+
+ private RhqDeploymentMarker() {
+ // Defensive
+ }
+
+ static void mark(DeploymentUnit unit) {
+ unit.putAttachment(MARKER, new RhqDeploymentMarker());
+ }
+
+ static boolean isRhqDeployment(DeploymentUnit unit) {
+ DeploymentUnit deploymentUnit = unit;
+ if (deploymentUnit.getParent() != null) {
+ do {
+ deploymentUnit = deploymentUnit.getParent();
+ } while (deploymentUnit.getParent() != null);
+ }
+ return deploymentUnit.hasAttachment(MARKER);
+ }
+}
diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqInitializationProcessor.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqInitializationProcessor.java
new file mode 100644
index 0000000..4e694ae
--- /dev/null
+++ b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqInitializationProcessor.java
@@ -0,0 +1,53 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package org.rhq.enterprise.startup.deployment;
+
+import static org.rhq.enterprise.startup.StartupExtension.DEPLOYMENT_APP_EAR;
+
+import org.jboss.as.ee.structure.DeploymentType;
+import org.jboss.as.ee.structure.DeploymentTypeMarker;
+import org.jboss.as.server.deployment.DeploymentPhaseContext;
+import org.jboss.as.server.deployment.DeploymentUnit;
+import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
+import org.jboss.as.server.deployment.DeploymentUnitProcessor;
+import org.jboss.logging.Logger;
+
+/**
+ * A DUP which detects RHQ EAR deployment.
+ *
+ * @author Thomas Segismont
+ */
+public class RhqInitializationProcessor implements DeploymentUnitProcessor {
+
+ private static final Logger LOG = Logger.getLogger(RhqInitializationProcessor.class);
+
+ @Override
+ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
+ DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
+ if (deploymentUnit.getParent() == null && DEPLOYMENT_APP_EAR.equals(deploymentUnit.getName())
+ && DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
+ LOG.info("Found " + DEPLOYMENT_APP_EAR + " deployment");
+ RhqDeploymentMarker.mark(deploymentUnit);
+ }
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit context) {
+ }
+}
diff --git a/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqShutdownBeanDependenciesProcessor.java b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqShutdownBeanDependenciesProcessor.java
new file mode 100644
index 0000000..2b88268
--- /dev/null
+++ b/modules/enterprise/server/startup-subsystem/src/main/java/org/rhq/enterprise/startup/deployment/RhqShutdownBeanDependenciesProcessor.java
@@ -0,0 +1,94 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+package org.rhq.enterprise.startup.deployment;
+
+import static org.jboss.msc.service.ServiceBuilder.DependencyType.REQUIRED;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import org.jboss.as.ee.component.Attachments;
+import org.jboss.as.ee.component.ComponentDescription;
+import org.jboss.as.ee.component.EEModuleDescription;
+import org.jboss.as.ejb3.component.session.SessionBeanComponentDescription;
+import org.jboss.as.server.deployment.DeploymentPhaseContext;
+import org.jboss.as.server.deployment.DeploymentUnit;
+import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
+import org.jboss.as.server.deployment.DeploymentUnitProcessor;
+
+/**
+ * A DUP which makes the ShutdownListener session bean automatically depend on all other sessions beans.
+ *
+ * @author Thomas Segismont
+ */
+public class RhqShutdownBeanDependenciesProcessor implements DeploymentUnitProcessor {
+
+ public static final String SHUTDOWN_LISTENER_CLASS_NAME = "org.rhq.enterprise.server.core.ShutdownListener";
+
+ @Override
+ public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
+ DeploymentUnit unit = context.getDeploymentUnit();
+ EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
+ Collection<ComponentDescription> componentDescriptions = moduleDescription.getComponentDescriptions();
+
+ if (componentDescriptions == null || componentDescriptions.isEmpty()
+ || !RhqDeploymentMarker.isRhqDeployment(unit)) {
+ // Only process sub deployments of the RHQ EAR
+ return;
+ }
+
+ Collection<SessionBeanComponentDescription> sessionBeanComponentDescriptions = getSessionBeanComponentDescriptions(componentDescriptions);
+
+ SessionBeanComponentDescription shutdownBeanComponentDescription = extractShutdownBeanDescription(sessionBeanComponentDescriptions);
+
+ for (SessionBeanComponentDescription sessionBeanComponentDescription : sessionBeanComponentDescriptions) {
+ shutdownBeanComponentDescription.addDependency(sessionBeanComponentDescription.getStartServiceName(),
+ REQUIRED);
+ }
+ }
+
+ private Collection<SessionBeanComponentDescription> getSessionBeanComponentDescriptions(
+ Collection<ComponentDescription> componentDescriptions) {
+ Collection<SessionBeanComponentDescription> sessionBeanComponentDescriptions = new LinkedList<SessionBeanComponentDescription>();
+ for (ComponentDescription componentDescription : componentDescriptions) {
+ if (componentDescription instanceof SessionBeanComponentDescription) {
+ sessionBeanComponentDescriptions.add((SessionBeanComponentDescription) componentDescription);
+ }
+ }
+ return sessionBeanComponentDescriptions;
+ }
+
+ private SessionBeanComponentDescription extractShutdownBeanDescription(
+ Collection<SessionBeanComponentDescription> sessionBeanComponentDescriptions) {
+ for (Iterator<SessionBeanComponentDescription> iterator = sessionBeanComponentDescriptions.iterator(); iterator
+ .hasNext();) {
+ SessionBeanComponentDescription sessionBeanComponentDescription = iterator.next();
+ if (sessionBeanComponentDescription.getComponentClassName().equals(SHUTDOWN_LISTENER_CLASS_NAME)) {
+ iterator.remove();
+ return sessionBeanComponentDescription;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit context) {
+ }
+}
diff --git a/modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml b/modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml
index 307029d..33069a1 100644
--- a/modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml
+++ b/modules/enterprise/server/startup-subsystem/src/main/resources/module/main/module.xml
@@ -21,6 +21,7 @@
<!-- additional modules that this subsystem depends on -->
<module name="org.jboss.metadata"/>
<module name="org.jboss.as.ee"/>
+ <module name="org.jboss.as.ejb3"/>
<module name="org.jboss.as.web"/>
</dependencies>
diff --git a/pom.xml b/pom.xml
index 401c7ca..220eb30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -392,6 +392,11 @@
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-ejb3</artifactId>
+ <version>${jboss.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
<artifactId>jboss-as-naming</artifactId>
<version>${jboss.version}</version>
</dependency>
@@ -1004,7 +1009,7 @@
</plugin>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
- <version>2.4.2</version>
+ <version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
10 years, 10 months
[rhq] modules/plugins
by Thomas Segismont
modules/plugins/jboss-as-7/pom.xml | 1
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 68 ++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java | 55 +-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ResolveExpression.java | 32 +
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 16
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/BaseComponentMetricReportTest.java | 251 ++++++++++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java | 118 ++++
7 files changed, 491 insertions(+), 50 deletions(-)
New commits:
commit 2b58edfae71b976970e24f1b9a05f258348a1aa1
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Mon Jun 24 10:38:14 2013 +0200
Bug 976291 - [as7] WebConnectorComponent throws ClassCastException when collecting _maxConnections metric on RHQ server
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 3b8d508..c81debb 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -615,6 +615,7 @@
<!--<include>org/rhq/modules/plugins/jbossas7/itest/standalone/StandaloneServerComponentTest.java</include>-->
<!--<include>org/rhq/modules/plugins/jbossas7/itest/standalone/InterruptibleOperationsTest.java</include>-->
<!--<include>org/rhq/modules/plugins/jbossas7/itest/standalone/DeploymentTest.java</include>-->
+ <!--<include>org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java</include>-->
<!--<include>org/rhq/modules/plugins/jbossas7/itest/domain/DomainServerComponentTest.java</include>-->
<!--<include>org/rhq/modules/plugins/jbossas7/itest/domain/ManagedServerTest.java</include>-->
<!--<include>org/rhq/modules/plugins/jbossas7/itest/domain/SecurityModuleOptionsTest.java</include>-->
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
index 2451728..2a60ec3 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.modules.plugins.jbossas7;
@@ -71,6 +71,7 @@ import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
import org.rhq.modules.plugins.jbossas7.json.ReadResource;
import org.rhq.modules.plugins.jbossas7.json.Remove;
+import org.rhq.modules.plugins.jbossas7.json.ResolveExpression;
import org.rhq.modules.plugins.jbossas7.json.Result;
/**
@@ -81,8 +82,12 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
public class BaseComponent<T extends ResourceComponent<?>> implements AS7Component<T>, MeasurementFacet,
ConfigurationFacet, DeleteResourceFacet, CreateChildResourceFacet, OperationFacet {
- private static final String INTERNAL = "_internal:";
- private static final int INTERNAL_SIZE = INTERNAL.length();
+ static final String INTERNAL = "_internal:";
+ static final int INTERNAL_SIZE = INTERNAL.length();
+ static final String EXPRESSION = "_expr:";
+ static final int EXPRESSION_SIZE = EXPRESSION.length();
+ static final String EXPRESSION_VALUE_KEY = "EXPRESSION_VALUE";
+
public static final String MANAGED_SERVER = "Managed Server";
final Log log = LogFactory.getLog(this.getClass());
@@ -170,12 +175,17 @@ public class BaseComponent<T extends ResourceComponent<?>> implements AS7Compone
// Metrics from the application server
String reqName = req.getName();
+ boolean resolveExpression = false;
+ if (reqName.startsWith(EXPRESSION)) {
+ resolveExpression = true;
+ reqName = reqName.substring(EXPRESSION_SIZE);
+ }
- ComplexRequest request = null;
+ ComplexRequest complexRequest = null;
Operation op;
if (reqName.contains(":")) {
- request = ComplexRequest.create(reqName);
- op = new ReadAttribute(address, request.getProp());
+ complexRequest = ComplexRequest.create(reqName);
+ op = new ReadAttribute(address, complexRequest.getProp());
} else {
op = new ReadAttribute(address, reqName); // TODO batching
}
@@ -195,32 +205,60 @@ public class BaseComponent<T extends ResourceComponent<?>> implements AS7Compone
if (val instanceof String && ((String) val).startsWith("JBAS018003")) // AS7 way of saying "no value available"
continue;
try {
- if (request != null) {
+ if (complexRequest != null) {
HashMap<String, Number> myValues = (HashMap<String, Number>) val;
for (String key : myValues.keySet()) {
- String sub = request.getSub();
+ String sub = complexRequest.getSub();
if (key.equals(sub)) {
- addMetric2Report(report, req, myValues.get(key));
+ addMetric2Report(report, req, myValues.get(key), resolveExpression);
}
}
} else {
- addMetric2Report(report, req, val);
+ addMetric2Report(report, req, val, resolveExpression);
}
} catch (NumberFormatException e) {
log.warn("Non numeric input for [" + req.getName() + "] : [" + val + "]");
}
} else if (req.getDataType() == DataType.TRAIT) {
- String realVal = getStringValue(val);
+ if (resolveExpression && val instanceof Map && ((Map) val).containsKey(EXPRESSION_VALUE_KEY)) {
+ String expression = (String) ((Map) val).get(EXPRESSION_VALUE_KEY);
+ ResolveExpression resolveExpressionOperation = new ResolveExpression(expression);
+ Result result = getASConnection().execute(resolveExpressionOperation);
+ if (!result.isSuccess()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Skipping trait [" + req.getName()
+ + "] in measurement report. Could not resolve expression [" + expression
+ + "], failureDescription:" + result.getFailureDescription());
+ continue;
+ }
+ }
+ val = result.getResult();
+ }
- MeasurementDataTrait data = new MeasurementDataTrait(req, realVal);
+ MeasurementDataTrait data = new MeasurementDataTrait(req, getStringValue(val));
report.addData(data);
}
}
}
}
- private void addMetric2Report(MeasurementReport report, MeasurementScheduleRequest req, Object val) {
+ private void addMetric2Report(MeasurementReport report, MeasurementScheduleRequest req, Object val,
+ boolean resolveExpression) {
+ if (resolveExpression && val instanceof Map && ((Map) val).containsKey(EXPRESSION_VALUE_KEY)) {
+ String expression = (String) ((Map) val).get(EXPRESSION_VALUE_KEY);
+ ResolveExpression resolveExpressionOperation = new ResolveExpression(expression);
+ Result result = getASConnection().execute(resolveExpressionOperation);
+ if (!result.isSuccess()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Skipping metric [" + req.getName()
+ + "] in measurement report. Could not resolve expression [" + expression
+ + "], failureDescription:" + result.getFailureDescription());
+ return;
+ }
+ }
+ val = result.getResult();
+ }
Double d = Double.parseDouble(getStringValue(val));
MeasurementDataNumeric data = new MeasurementDataNumeric(req, d);
report.addData(data);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java
index 3af95fd..b3ac181 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebConnectorComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,13 +13,12 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.modules.plugins.jbossas7;
-import java.util.HashSet;
import java.util.Set;
import org.rhq.core.domain.configuration.Configuration;
@@ -37,32 +36,35 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* @author Heiko W. Rupp
*/
public class WebConnectorComponent extends BaseComponent<WebConnectorComponent> implements MeasurementFacet {
+ private static final String MAX_CONNECTIONS_METRIC_NAME = "_expr:max-connections";
+ private static final String MAX_CONNECTIONS_CONFIG_ATTRIBUTE = "max-connections:expr";
@Override
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
- Set<MeasurementScheduleRequest> leftovers = new HashSet<MeasurementScheduleRequest>(metrics.size());
- for (MeasurementScheduleRequest request : metrics) {
- if (request.getName().equals("_maxConnections")) {
- ReadAttribute op = new ReadAttribute(getAddress(), "max-connections");
- Result res = getASConnection().execute(op);
- int val;
- if (res.isSuccess() && res.getResult() != null) {
- Object o = res.getResult(); // If the attribute was written as string, it stays string until :reload
- if (o instanceof String)
- val = Integer.valueOf((String) o);
- else
- val = (Integer) o;
- } else { // this is not set in the server, we need to compute it ourselves
- val = computeMaxConnections();
- }
+ super.getValues(report, metrics);
+ MeasurementScheduleRequest maxConnectionMetricRequest = getMaxConnectionMetricRequest(metrics);
+ if (maxConnectionMetricRequest != null && !hasMaxConnectionMetric(report)) {
+ report.addData(new MeasurementDataNumeric(maxConnectionMetricRequest, Double
+ .valueOf(computeMaxConnections())));
+ }
+ }
+
+ private MeasurementScheduleRequest getMaxConnectionMetricRequest(Set<MeasurementScheduleRequest> metrics) {
+ for (MeasurementScheduleRequest metric : metrics) {
+ if (MAX_CONNECTIONS_METRIC_NAME.equals(metric.getName())) {
+ return metric;
+ }
+ }
+ return null;
+ }
- MeasurementDataNumeric data = new MeasurementDataNumeric(request, (double) val);
- report.addData(data);
- } else {
- leftovers.add(request);
+ private boolean hasMaxConnectionMetric(MeasurementReport report) {
+ for (MeasurementDataNumeric metric : report.getNumericData()) {
+ if (MAX_CONNECTIONS_METRIC_NAME.equals(metric.getName())) {
+ return true;
}
}
- super.getValues(report, leftovers);
+ return false;
}
/**
@@ -74,10 +76,9 @@ public class WebConnectorComponent extends BaseComponent<WebConnectorComponent>
@Override
public Configuration loadResourceConfiguration() throws Exception {
Configuration configuration = super.loadResourceConfiguration();
- PropertySimple maxConnProp = configuration.getSimple("max-connections");
+ PropertySimple maxConnProp = configuration.getSimple(MAX_CONNECTIONS_CONFIG_ATTRIBUTE);
if (maxConnProp.getStringValue() == null) {
- int val = computeMaxConnections();
- maxConnProp.setIntegerValue(val);
+ maxConnProp.setIntegerValue(computeMaxConnections());
}
return configuration;
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ResolveExpression.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ResolveExpression.java
new file mode 100644
index 0000000..427c6d0
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ResolveExpression.java
@@ -0,0 +1,32 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.plugins.jbossas7.json;
+
+/**
+ * @author Thomas Segismont
+ */
+public class ResolveExpression extends Operation {
+
+ public ResolveExpression(String expression) {
+ super("resolve-expression", new Address());
+ addAdditionalProperty("expression", expression);
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index e9449a5..162c3a1 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -2390,7 +2390,7 @@
<metric property="errorCount" measurementType="trendsup" displayType="summary" description="Number of error that occurs when processing requests by the connector."/>
<metric property="maxTime" units="milliseconds" description="Max time spent to process a requests."/>
<metric property="requestCount" measurementType="trendsup" displayType="summary" description="Number of the request processed by the connector."/>
- <metric property="_maxConnections" displayName="Max connections" description="Number of max connections this connector can handle (see configuration to set it)" defaultOn="true" defaultInterval="14400000"/>
+ <metric property="_expr:max-connections" displayName="Max connections" description="Number of max connections this connector can handle (see configuration to set it)" defaultOn="true" defaultInterval="14400000"/>
<resource-configuration>
<c:simple-property name="scheme" required="true" type="string" readOnly="true" description="The web connector scheme.">
@@ -2406,7 +2406,7 @@
<c:simple-property name="enabled" required="false" type="boolean" readOnly="true" defaultValue="true" description="Defines whether the connector should be started on startup. The default value is true."/>
<c:simple-property name="enable-lookups" required="false" type="boolean" readOnly="true" defaultValue="false" description="Enable DNS lookups for Servlet API. The default value is false."/>
<c:simple-property name="executor" required="false" type="string" readOnly="true" description="The name of the executor that should be used for the processing threads of this connector. If undefined defaults to using an internal pool."/>
- <c:simple-property name="max-connections" required="false" type="integer" readOnly="true" description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used and the number of cpu cores (512*cores for HTTP, 32*cores for AJP)."/>
+ <c:simple-property name="max-connections:expr" displayName="Max connections" required="false" type="string" readOnly="true" description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used and the number of cpu cores (512*cores for HTTP, 32*cores for AJP)."/>
<c:simple-property name="max-post-size" required="false" type="integer" readOnly="true" defaultValue="2097152" description="Maximum size in bytes of a POST request that can be parsed by the container. The default value is 2097152."/>
<c:simple-property name="max-save-post-size" required="false" type="integer" readOnly="true" defaultValue="4096" description="Maximum size in bytes of a POST request that will be saved during certain authentication schemes. The default value is 4096."/>
<c:simple-property name="name" required="false" type="string" readOnly="true" description="A unique name for the connector."/>
@@ -2419,7 +2419,7 @@
</c:simple-property>
<c:simple-property name="proxy-name" required="false" type="string" readOnly="true" description="The host name that will be used when sending a redirect. The default value is null."/>
<c:simple-property name="proxy-port" required="false" type="integer" readOnly="true" description="The port that will be used when sending a redirect."/>
- <c:simple-property name="redirect-port" required="false" type="integer" readOnly="true" defaultValue="8433" description="The port for redirection to a secure connector. The default value is 8433."/>
+ <c:simple-property name="redirect-port:expr" displayName="Redirect Port" required="false" type="string" readOnly="true" defaultValue="8433" description="The port for redirection to a secure connector. The default value is 8433."/>
<c:simple-property name="secure" required="false" type="boolean" readOnly="true" defaultValue="false" description="Indicates if content sent or received by the connector is secured from the user perspective. The default value is false."/>
<c:simple-property name="virtual-server" required="false" type="string" readOnly="true" description="The list of virtual servers that can be accessed through this connector. The default is to allow all virtual servers."/>
@@ -5379,7 +5379,7 @@
<c:simple-property name="enabled" required="false" type="boolean" readOnly="false" defaultValue="true" description="Defines whether the connector should be started on startup. The default value is true."/>
<c:simple-property name="enable-lookups" required="false" type="boolean" readOnly="false" defaultValue="false" description="Enable DNS lookups for Servlet API. The default value is false."/>
<c:simple-property name="executor" required="false" type="string" readOnly="false" description="The name of the executor that should be used for the processing threads of this connector. If undefined defaults to using an internal pool."/>
- <c:simple-property name="max-connections" required="false" type="integer" readOnly="false" description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used and the number of cpu cores (512*cores for HTTP, 32*cores for AJP)."/>
+ <c:simple-property name="max-connections:expr" displayName="Max connections" required="false" type="string" readOnly="false" description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used and the number of cpu cores (512*cores for HTTP, 32*cores for AJP)."/>
<c:simple-property name="max-post-size" required="false" type="integer" readOnly="false" defaultValue="2097152" description="Maximum size in bytes of a POST request that can be parsed by the container. The default value is 2097152."/>
<c:simple-property name="max-save-post-size" required="false" type="integer" readOnly="false" defaultValue="4096" description="Maximum size in bytes of a POST request that will be saved during certain authentication schemes. The default value is 4096."/>
<c:simple-property name="name" required="false" type="string" readOnly="true" description="A unique name for the connector."/>
@@ -5393,7 +5393,7 @@
</c:simple-property>
<c:simple-property name="proxy-name" required="false" type="string" readOnly="false" description="The host name that will be used when sending a redirect. The default value is null."/>
<c:simple-property name="proxy-port" required="false" type="integer" readOnly="false" description="The port that will be used when sending a redirect."/>
- <c:simple-property name="redirect-port" required="false" type="integer" readOnly="false" defaultValue="8433" description="The port for redirection to a secure connector. The default value is 8433."/>
+ <c:simple-property name="redirect-port:expr" displayName="Redirect Port" required="false" type="string" readOnly="false" defaultValue="8433" description="The port for redirection to a secure connector. The default value is 8433."/>
<c:simple-property name="secure" required="false" type="boolean" readOnly="false" defaultValue="false" description="Indicates if content sent or received by the connector is secured from the user perspective. The default value is false."/>
<c:simple-property name="virtual-server" required="false" type="string" readOnly="false" description="The list of virtual servers that can be accessed through this connector. The default is to allow all virtual servers."/>
@@ -7416,7 +7416,7 @@
<metric property="errorCount" measurementType="trendsup" displayType="summary" description="Number of error that occurs when processing requests by the connector."/>
<metric property="maxTime" units="milliseconds" description="Max time spent to process a requests."/>
<metric property="requestCount" measurementType="trendsup" displayType="summary" description="Number of the request processed by the connector."/>
- <metric property="_maxConnections" displayName="Max connections" description="Number of max connections this connector can handle (see configuration to set it)" defaultOn="true" defaultInterval="14400000"/>
+ <metric property="_expr:max-connections" displayName="Max connections" description="Number of max connections this connector can handle (see configuration to set it)" defaultOn="true" defaultInterval="14400000"/>
<resource-configuration>
<c:simple-property name="scheme" required="true" type="string" readOnly="false" description="The web connector scheme.">
@@ -7432,7 +7432,7 @@
<c:simple-property name="enabled" required="false" type="boolean" readOnly="false" defaultValue="true" description="Defines whether the connector should be started on startup. The default value is true."/>
<c:simple-property name="enable-lookups" required="false" type="boolean" readOnly="false" defaultValue="false" description="Enable DNS lookups for Servlet API. The default value is false."/>
<c:simple-property name="executor" required="false" type="string" readOnly="false" description="The name of the executor that should be used for the processing threads of this connector. If undefined defaults to using an internal pool."/>
- <c:simple-property name="max-connections" required="false" type="integer" readOnly="false" description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used and the number of cpu cores (512*cores for HTTP, 32*cores for AJP)."/>
+ <c:simple-property name="max-connections:expr" displayName="Max connections" required="false" type="string" readOnly="false" description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used and the number of cpu cores (512*cores for HTTP, 32*cores for AJP)."/>
<c:simple-property name="max-post-size" required="false" type="integer" readOnly="false" defaultValue="2097152" description="Maximum size in bytes of a POST request that can be parsed by the container. The default value is 2097152."/>
<c:simple-property name="max-save-post-size" required="false" type="integer" readOnly="false" defaultValue="4096" description="Maximum size in bytes of a POST request that will be saved during certain authentication schemes. The default value is 4096."/>
<c:simple-property name="name" required="false" type="string" readOnly="true" description="A unique name for the connector."/>
@@ -7446,7 +7446,7 @@
</c:simple-property>
<c:simple-property name="proxy-name" required="false" type="string" readOnly="false" description="The host name that will be used when sending a redirect. The default value is null."/>
<c:simple-property name="proxy-port" required="false" type="integer" readOnly="false" description="The port that will be used when sending a redirect."/>
- <c:simple-property name="redirect-port" required="false" type="integer" readOnly="false" defaultValue="8433" description="The port for redirection to a secure connector. The default value is 8433."/>
+ <c:simple-property name="redirect-port:expr" displayName="Redirect Port" required="false" type="string" readOnly="false" defaultValue="8433" description="The port for redirection to a secure connector. The default value is 8433."/>
<c:simple-property name="secure" required="false" type="boolean" readOnly="false" defaultValue="false" description="Indicates if content sent or received by the connector is secured from the user perspective. The default value is false."/>
<c:simple-property name="virtual-server" required="false" type="string" readOnly="false" description="The list of virtual servers that can be accessed through this connector. The default is to allow all virtual servers."/>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/BaseComponentMetricReportTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/BaseComponentMetricReportTest.java
new file mode 100644
index 0000000..9a48efa
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/BaseComponentMetricReportTest.java
@@ -0,0 +1,251 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.plugins.jbossas7;
+
+import static org.mockito.Matchers.argThat;
+import static org.mockito.Mockito.when;
+import static org.rhq.core.domain.measurement.DataType.MEASUREMENT;
+import static org.rhq.core.domain.measurement.DataType.TRAIT;
+import static org.rhq.modules.plugins.jbossas7.BaseComponent.EXPRESSION;
+import static org.rhq.modules.plugins.jbossas7.BaseComponent.EXPRESSION_VALUE_KEY;
+import static org.rhq.modules.plugins.jbossas7.BaseComponent.INTERNAL;
+import static org.rhq.modules.plugins.jbossas7.json.Result.SUCCESS;
+import static org.testng.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.mockito.ArgumentMatcher;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementDataTrait;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.modules.plugins.jbossas7.json.Address;
+import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
+import org.rhq.modules.plugins.jbossas7.json.ResolveExpression;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * @author Thomas Segismont
+ */
+public class BaseComponentMetricReportTest {
+
+ @Mock
+ private ASConnection asConnection;
+
+ private Address address;
+
+ private MeasurementReport report;
+
+ private Set<MeasurementScheduleRequest> requests;
+
+ private SampleComponent sampleComponent;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ report = new MeasurementReport();
+ requests = new HashSet<MeasurementScheduleRequest>();
+ address = new Address("path");
+ sampleComponent = new SampleComponent();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception {
+
+ }
+
+ @Test
+ public void testInternalMetric() throws Exception {
+ int mgmtRequestsCount = 13;
+ for (int i = 0; i < mgmtRequestsCount; i++) {
+ PluginStats.getInstance().incrementRequestCount();
+ }
+ String requestName = INTERNAL + "mgmtRequests";
+ requests.add(newMeasurementRequest(requestName));
+
+ sampleComponent.getValues(report, requests);
+
+ Set<MeasurementDataNumeric> numericMetrics = report.getNumericData();
+ assertEquals(numericMetrics.size(), 1);
+ MeasurementDataNumeric numericMetric = numericMetrics.iterator().next();
+ assertEquals(numericMetric.getName(), requestName);
+ assertEquals(numericMetric.getValue(), (double) mgmtRequestsCount);
+ }
+
+ @Test
+ public void testSimpleMetric() throws Exception {
+ String requestName = "pipo";
+ requests.add(newMeasurementRequest(requestName));
+ double metricValue = 13d;
+
+ when(asConnection.execute(readAttribute(address, requestName))).thenReturn(result(metricValue));
+ sampleComponent.getValues(report, requests);
+
+ Set<MeasurementDataNumeric> numericMetrics = report.getNumericData();
+ assertEquals(numericMetrics.size(), 1);
+ MeasurementDataNumeric numericMetric = numericMetrics.iterator().next();
+ assertEquals(numericMetric.getName(), requestName);
+ assertEquals(numericMetric.getValue(), metricValue);
+ }
+
+ @Test
+ public void testSimpleMetricWithExpression() throws Exception {
+ String attributeName = "pipo";
+ String requestName = EXPRESSION + attributeName;
+ requests.add(newMeasurementRequest(requestName));
+ double metricValue = 13d;
+ String expressionValue = "${prop:14}";
+
+ when(asConnection.execute(readAttribute(address, attributeName))).thenReturn(
+ result(expression(expressionValue)));
+ when(asConnection.execute(resolveExpression(expressionValue))).thenReturn(result(metricValue));
+ sampleComponent.getValues(report, requests);
+
+ Set<MeasurementDataNumeric> numericMetrics = report.getNumericData();
+ assertEquals(numericMetrics.size(), 1);
+ MeasurementDataNumeric numericMetric = numericMetrics.iterator().next();
+ assertEquals(numericMetric.getName(), requestName);
+ assertEquals(numericMetric.getValue(), metricValue);
+ }
+
+ @Test
+ public void testSimpleTrait() throws Exception {
+ String requestName = "pipo";
+ requests.add(newTraitRequest(requestName));
+ String traitValue = "marseille";
+
+ when(asConnection.execute(readAttribute(address, requestName))).thenReturn(result(traitValue));
+ sampleComponent.getValues(report, requests);
+
+ Set<MeasurementDataTrait> traits = report.getTraitData();
+ assertEquals(traits.size(), 1);
+ MeasurementDataTrait trait = traits.iterator().next();
+ assertEquals(trait.getName(), requestName);
+ assertEquals(trait.getValue(), traitValue);
+ }
+
+ @Test
+ public void testSimpleTraitWithExpression() throws Exception {
+ String attributeName = "pipo";
+ String requestName = EXPRESSION + attributeName;
+ requests.add(newTraitRequest(requestName));
+ String traitValue = "marseille";
+ String expressionValue = "${prop:paris}";
+
+ when(asConnection.execute(readAttribute(address, attributeName))).thenReturn(
+ result(expression(expressionValue)));
+ when(asConnection.execute(resolveExpression(expressionValue))).thenReturn(result(traitValue));
+ sampleComponent.getValues(report, requests);
+
+ Set<MeasurementDataTrait> traits = report.getTraitData();
+ assertEquals(traits.size(), 1);
+ MeasurementDataTrait trait = traits.iterator().next();
+ assertEquals(trait.getName(), requestName);
+ assertEquals(trait.getValue(), traitValue);
+ }
+
+ private class SampleComponent extends BaseComponent {
+
+ private SampleComponent() {
+ }
+
+ @Override
+ public ASConnection getASConnection() {
+ return asConnection;
+ }
+ }
+
+ private static MeasurementScheduleRequest newMeasurementRequest(String requestName) {
+ return new MeasurementScheduleRequest(-1, requestName, -1, true, MEASUREMENT);
+ }
+
+ private static MeasurementScheduleRequest newTraitRequest(String requestName) {
+ return new MeasurementScheduleRequest(-1, requestName, -1, true, TRAIT);
+ }
+
+ private static Result result(Object value) {
+ Result result = new Result();
+ result.setOutcome(SUCCESS);
+ result.setResult(value);
+ return result;
+ }
+
+ private static ReadAttribute readAttribute(Address address, String requestName) {
+ return argThat(new IsReadAttribute(address, requestName));
+ }
+
+ private static Object expression(String expression) {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put(EXPRESSION_VALUE_KEY, expression);
+ return map;
+ }
+
+ private static ResolveExpression resolveExpression(String expressionValue) {
+ return argThat(new IsResolveExpression(expressionValue));
+ }
+
+ private static class IsReadAttribute extends ArgumentMatcher<ReadAttribute> {
+
+ private Address address;
+ private String attributeName;
+
+ private IsReadAttribute(Address address, String attributeName) {
+ this.address = address;
+ this.attributeName = attributeName;
+ }
+
+ @Override
+ public boolean matches(Object argument) {
+ if (!(argument instanceof ReadAttribute)) {
+ return false;
+ }
+ ReadAttribute readAttribute = (ReadAttribute) argument;
+ return address.getPath().equals(readAttribute.getAddress().getPath())
+ && attributeName.equals(readAttribute.getName());
+ }
+ }
+
+ private static class IsResolveExpression extends ArgumentMatcher<ResolveExpression> {
+
+ private String expressionValue;
+
+ private IsResolveExpression(String expressionValue) {
+ this.expressionValue = expressionValue;
+ }
+
+ @Override
+ public boolean matches(Object argument) {
+ if (!(argument instanceof ResolveExpression)) {
+ return false;
+ }
+ ResolveExpression resolveExpression = (ResolveExpression) argument;
+ return expressionValue.equals(resolveExpression.getAdditionalProperties().get("expression"));
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java
new file mode 100644
index 0000000..ca86d5e
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/itest/standalone/WebConnectorComponentTest.java
@@ -0,0 +1,118 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.plugins.jbossas7.itest.standalone;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.rhq.core.domain.resource.ResourceCategory.SERVICE;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.measurement.DataType;
+import org.rhq.core.domain.measurement.MeasurementData;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pc.util.ComponentUtil;
+import org.rhq.core.pc.util.FacetLockType;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.modules.plugins.jbossas7.itest.AbstractJBossAS7PluginTest;
+import org.rhq.test.arquillian.RunDiscovery;
+
+/**
+ * @author Thomas Segismont
+ */
+@Test(groups = { "integration", "pc", "standalone" }, singleThreaded = true)
+public class WebConnectorComponentTest extends AbstractJBossAS7PluginTest {
+ private static final String RESOURCE_TYPE_NAME = "Connector";
+ private static final String MAX_CONNECTIONS_METRIC_NAME = "_expr:max-connections";
+ private static final String MAX_CONNECTIONS_CONFIG_ATTRIBUTE = "max-connections:expr";
+
+ @Test(groups = "discovery")
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void firstDiscovery() throws Exception {
+ Resource platform = pluginContainer.getInventoryManager().getPlatform();
+ assertNotNull(platform);
+ assertEquals(platform.getInventoryStatus(), InventoryStatus.COMMITTED);
+ setMaxDiscoveryDepthOverride(10);
+ }
+
+ @Test(groups = "discovery")
+ @RunDiscovery(discoverServices = true, discoverServers = true)
+ public void secondDiscovery() throws Exception {
+ Set<Resource> webConnectorResources = getWebConnectorResources();
+ assertTrue(webConnectorResources != null && !webConnectorResources.isEmpty(), "Found no resources of type ["
+ + RESOURCE_TYPE_NAME + "]");
+ for (Resource webConnectorResource : webConnectorResources) {
+ assertEquals(webConnectorResource.getInventoryStatus(), InventoryStatus.COMMITTED);
+ }
+ }
+
+ private Set<Resource> getWebConnectorResources() {
+ ResourceType resourceType = new ResourceType(RESOURCE_TYPE_NAME, getPluginName(), SERVICE, null);
+ return pluginContainer.getInventoryManager().getResourcesWithType(resourceType);
+ }
+
+ @Test(dependsOnMethods = { "secondDiscovery" })
+ public void testGetMaxConnectionMetricHasPositiveValue() throws Exception {
+ Set<Resource> webConnectorResources = getWebConnectorResources();
+ for (Resource webConnectorResource : webConnectorResources) {
+ Set<MeasurementScheduleRequest> requests = new HashSet<MeasurementScheduleRequest>();
+ requests.add(newMeasurementRequest(MAX_CONNECTIONS_METRIC_NAME));
+ MeasurementReport report = new MeasurementReport();
+ ComponentUtil.getComponent(webConnectorResource.getId(), MeasurementFacet.class, FacetLockType.READ,
+ SECONDS.toMillis(30), true, false).getValues(report, requests);
+ Set<MeasurementDataNumeric> numericMetrics = report.getNumericData();
+ assertEquals(numericMetrics, 1);
+ MeasurementData measurementData = numericMetrics.iterator().next();
+ assertEquals(measurementData.getName(), MAX_CONNECTIONS_METRIC_NAME);
+ assertTrue(measurementData instanceof MeasurementDataNumeric);
+ MeasurementDataNumeric metric = (MeasurementDataNumeric) measurementData;
+ assertNotNull(metric.getValue());
+ assertTrue(metric.getValue() > 0);
+ }
+ }
+
+ @Test(dependsOnMethods = { "testGetMaxConnectionMetricHasPositiveValue" })
+ public void testMaxConnectionConfigPropertyHasValue() throws Exception {
+ Set<Resource> webConnectorResources = getWebConnectorResources();
+ for (Resource webConnectorResource : webConnectorResources) {
+ Configuration configuration = pluginContainer.getConfigurationManager().loadResourceConfiguration(
+ webConnectorResource.getId());
+ PropertySimple maxConnectionProperty = configuration.getSimple(MAX_CONNECTIONS_CONFIG_ATTRIBUTE);
+ assertNotNull(maxConnectionProperty);
+ assertNotNull(maxConnectionProperty.getStringValue());
+ }
+ }
+
+ private static MeasurementScheduleRequest newMeasurementRequest(String metricName) {
+ return new MeasurementScheduleRequest(-1, metricName, -1, true, DataType.MEASUREMENT);
+ }
+}
10 years, 10 months
[rhq] modules/plugins
by Thomas Segismont
modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java | 64 +++++-----
1 file changed, 33 insertions(+), 31 deletions(-)
New commits:
commit 622b5b19cb8a784a063d61f035d72aefca807695
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Tue Jun 25 10:36:19 2013 +0200
Bug 869834 - ResponseTime metrics are not collected for Apache when SNMP is not being used
diff --git a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
index 6c1ce3e..8a3c36f 100644
--- a/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
+++ b/modules/plugins/apache/src/main/java/org/rhq/plugins/apache/ApacheVirtualHostServiceComponent.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2012 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.plugins.apache;
@@ -73,7 +73,7 @@ import org.rhq.plugins.www.util.WWWUtils;
public class ApacheVirtualHostServiceComponent implements ResourceComponent<ApacheServerComponent>, MeasurementFacet,
ConfigurationFacet, DeleteResourceFacet, CreateChildResourceFacet {
- private static final Log log = LogFactory.getLog(ApacheVirtualHostServiceComponent.class);
+ private static final Log LOG = LogFactory.getLog(ApacheVirtualHostServiceComponent.class);
public static final String URL_CONFIG_PROP = "url";
public static final String MAIN_SERVER_RESOURCE_KEY = "MainServer";
@@ -153,7 +153,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
return snmpSession.ping() ? AvailabilityType.UP : AvailabilityType.DOWN;
} catch (Exception e) {
- log.debug("Determining the availability of the vhost [" + resourceContext.getResourceKey()
+ LOG.debug("Determining the availability of the vhost [" + resourceContext.getResourceKey()
+ "] using SNMP failed.", e);
return AvailabilityType.DOWN;
}
@@ -199,17 +199,17 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
tree.save();
report.setStatus(ConfigurationUpdateStatus.SUCCESS);
- log.info("Apache configuration was updated");
+ LOG.info("Apache configuration was updated");
finishConfigurationUpdate(report);
} catch (Exception e) {
if (tree != null) {
String message = "Augeas failed to save configuration " + tree.summarizeAugeasError();
report.setErrorMessage(message);
- log.error(message);
+ LOG.error(message);
} else {
report.setErrorMessageFromThrowable(e);
- log.error("Augeas failed to save configuration", e);
+ LOG.error("Augeas failed to save configuration", e);
}
report.setStatus(ConfigurationUpdateStatus.FAILURE);
} finally {
@@ -249,18 +249,18 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> schedules) throws Exception {
- int primaryIndex = getWwwServiceIndex();
-
- //bail out quickly if there's no SNMP support
- if (primaryIndex < 0)
- return;
-
- log.debug("Collecting metrics for VirtualHost service #" + primaryIndex + "...");
SNMPSession snmpSession = this.resourceContext.getParentResourceComponent().getSNMPSession();
+ int primaryIndex = getWwwServiceIndex();
+ boolean ping = snmpSession.ping();
+ boolean snmpMetricsSupported = primaryIndex >= 0 && ping;
- if (!snmpSession.ping()) {
- log.debug("Failed to connect to SNMP agent at " + snmpSession + " - aborting metric collection...");
- return;
+ if (LOG.isDebugEnabled()) {
+ if (snmpMetricsSupported) {
+ LOG.debug("SNMP metrics collection supported for VirtualHost service #" + primaryIndex);
+ } else {
+ LOG.debug("SNMP metrics collection unsupported for VirtualHost: primaryIndex[" + primaryIndex
+ + "], session[" + snmpSession + "], ping[" + ping + "]");
+ }
}
for (MeasurementScheduleRequest schedule : schedules) {
@@ -272,25 +272,27 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
this.logParser.parseLog(callTimeData);
report.addData(callTimeData);
} catch (Exception e) {
- log.error("Failed to retrieve HTTP call-time data.", e);
+ LOG.error("Failed to retrieve HTTP call-time data.", e);
}
} else {
- log.error("The '" + RESPONSE_TIME_METRIC + "' metric is enabled for resource '"
+ LOG.error("The '" + RESPONSE_TIME_METRIC + "' metric is enabled for resource '"
+ this.resourceContext.getResourceKey() + "', but no value is defined for the '"
+ RESPONSE_TIME_LOG_FILE_CONFIG_PROP + "' connection property.");
// TODO: Communicate this error back to the server for display in the GUI.
}
} else {
- // Assume anything else is an SNMP metric.
- try {
- collectSnmpMetric(report, primaryIndex, snmpSession, schedule);
- } catch (SNMPException e) {
- log.error("An error occurred while attempting to collect an SNMP metric.", e);
+ if (snmpMetricsSupported) {
+ // Assume anything else is an SNMP metric.
+ try {
+ collectSnmpMetric(report, primaryIndex, snmpSession, schedule);
+ } catch (SNMPException e) {
+ LOG.error("An error occurred while attempting to collect an SNMP metric.", e);
+ }
}
}
}
- log.info("Collected " + report.getDataCount() + " metrics for VirtualHost "
+ LOG.info("Collected " + report.getDataCount() + " metrics for VirtualHost "
+ this.resourceContext.getResourceKey() + ".");
}
@@ -379,7 +381,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
resourceContext.getParentResourceComponent().finishChildResourceCreate(report);
} catch (Exception e) {
- log.error("Could not create httpd virtual host child resource.", e);
+ LOG.error("Could not create httpd virtual host child resource.", e);
report.setException(e);
report.setStatus(CreateResourceStatus.FAILURE);
}
@@ -507,13 +509,13 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
if (!found) {
- log.error("Entry '" + oid + "' not found for " + mibName + "[" + primaryIndex + "].");
- log.error("Table:\n" + table);
+ LOG.error("Entry '" + oid + "' not found for " + mibName + "[" + primaryIndex + "].");
+ LOG.error("Table:\n" + table);
return;
}
}
- log.debug("Collected SNMP metric [" + metricName + "], value = " + snmpValue);
+ LOG.debug("Collected SNMP metric [" + metricName + "], value = " + snmpValue);
boolean valueIsTimestamp = false;
ApacheServerComponent.addSnmpMetricValueToReport(report, schedule, snmpValue, valueIsTimestamp);
@@ -584,7 +586,7 @@ public class ApacheVirtualHostServiceComponent implements ResourceComponent<Apac
}
if (foundIdx == vhosts.size()) {
- log.debug("The virtual host with resource key [" + resourceKey
+ LOG.debug("The virtual host with resource key [" + resourceKey
+ "] doesn't seem to be present in the apache configuration anymore.");
return -1;
} else {
10 years, 10 months
[rhq] modules/core modules/plugins
by Thomas Segismont
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ResponseTimeLogFinder.java | 73 +++
modules/core/plugin-api/src/test/java/org/rhq/core/pluginapi/util/ResponseTimeLogFinderTest.java | 149 ++++++
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java | 34 +
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextDiscoveryComponent.java | 53 +-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 9
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebRuntimeDiscoveryComponent.java | 133 ++++++
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 21
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/WebRuntimeDiscoveryComponentTest.java | 221 ++++++++++
8 files changed, 668 insertions(+), 25 deletions(-)
New commits:
commit 488e304c2222eeaac300e5efda770531bf2d1a19
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu Jun 20 10:51:52 2013 +0200
Bug 822247 - Web Application Response Time Log File not being imported
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ResponseTimeLogFinder.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ResponseTimeLogFinder.java
new file mode 100644
index 0000000..ea6551f
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ResponseTimeLogFinder.java
@@ -0,0 +1,73 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.core.pluginapi.util;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * Helps to find a response time filter log file.
+ *
+ * @author Thomas Segismont
+ */
+public class ResponseTimeLogFinder {
+ public static final File FALLBACK_RESPONSE_TIME_LOG_FILE_DIRECTORY = new File(System.getProperty("java.io.tmpdir")
+ + File.separator + "rhq" + File.separator + "rt");
+
+ private ResponseTimeLogFinder() {
+ // Utility class
+ }
+
+ /**
+ * @param contextPath context path of the monitored web application
+ * @param responseTimeLogFileDirectory Where to search for the response time log file of the web application.
+ * @return the absolute file path of the response time log file or null if not found or responseTimeLogFileDirectory
+ * does not exist or is not a directory.
+ * @throws IllegalArgumentException if context path is null or does not start with a slash, or if
+ * responseTimeLogFileDirectory is null
+ */
+ public static String findResponseTimeLogFileInDirectory(String contextPath, File responseTimeLogFileDirectory) {
+ if (contextPath == null) {
+ throw new IllegalArgumentException("contextPath is null");
+ }
+ if (!contextPath.startsWith("/")) {
+ throw new IllegalArgumentException("contextPath does not start with '/': " + contextPath);
+ }
+ if (responseTimeLogFileDirectory == null) {
+ throw new IllegalArgumentException("responseTimeLogFileDirectory is null");
+ }
+ if (responseTimeLogFileDirectory.exists() && responseTimeLogFileDirectory.isDirectory()) {
+ // Handle the root context path
+ // Remove leading slash and convert slashes to underscores
+ final String rtFileSuffix = (contextPath.equals("/") ? "ROOT" : contextPath).substring(1).replace('/', '_')
+ + "_rt.log";
+ File[] files = responseTimeLogFileDirectory.listFiles(new FilenameFilter() {
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.endsWith(rtFileSuffix);
+ }
+ });
+ if (files != null && files.length == 1) {
+ return files[0].getAbsolutePath();
+ }
+ }
+ return null;
+ }
+}
diff --git a/modules/core/plugin-api/src/test/java/org/rhq/core/pluginapi/util/ResponseTimeLogFinderTest.java b/modules/core/plugin-api/src/test/java/org/rhq/core/pluginapi/util/ResponseTimeLogFinderTest.java
new file mode 100644
index 0000000..c64e710
--- /dev/null
+++ b/modules/core/plugin-api/src/test/java/org/rhq/core/pluginapi/util/ResponseTimeLogFinderTest.java
@@ -0,0 +1,149 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.core.pluginapi.util;
+
+import static org.rhq.core.pluginapi.util.ResponseTimeLogFinder.findResponseTimeLogFileInDirectory;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.File;
+
+import org.testng.annotations.Test;
+
+/**
+ * @author Thomas Segismont
+ */
+public class ResponseTimeLogFinderTest {
+
+ private static final File TMP_DIR = new File(System.getProperty("java.io.tmpdir"));
+
+ @Test
+ public void shouldThrowIllegalArgumentExceptionForInvalidParameters() {
+ assertThrowsIllegalArgumentException(new Runnable() {
+ @Override
+ public void run() {
+ findResponseTimeLogFileInDirectory(null, null);
+ }
+ }, "Should fail when args are null");
+ assertThrowsIllegalArgumentException(new Runnable() {
+ @Override
+ public void run() {
+ findResponseTimeLogFileInDirectory("/pipo", null);
+ }
+ }, "Should fail when directory arg is null");
+ assertThrowsIllegalArgumentException(new Runnable() {
+ @Override
+ public void run() {
+ findResponseTimeLogFileInDirectory(null, new File(""));
+ }
+ }, "Should fail when context arg is null");
+ assertThrowsIllegalArgumentException(new Runnable() {
+ @Override
+ public void run() {
+ findResponseTimeLogFileInDirectory("pipo", new File(""));
+ }
+ }, "Should fail when context arg does not start with a slash");
+ }
+
+ private void assertThrowsIllegalArgumentException(Runnable runnable, String failureMessage) {
+ try {
+ runnable.run();
+ fail(failureMessage);
+ } catch (Exception e) {
+ assertTrue(e instanceof IllegalArgumentException, "Expected instance of IllegalArgumentException but got "
+ + e.getClass().getSimpleName());
+ }
+ }
+
+ @Test
+ public void shouldReturnNullWhenDirectoryArgDoesNotExist() {
+ File notExistingFile = null;
+ for (int i = 0; i < 2000; i++) {
+ File f = new File(TMP_DIR, "pipo" + i);
+ if (!f.exists()) {
+ notExistingFile = f;
+ break;
+ }
+ }
+ if (notExistingFile == null) {
+ fail("Could not denote a non existing file");
+ }
+ assertNull(findResponseTimeLogFileInDirectory("/pipo", notExistingFile));
+ }
+
+ @Test
+ public void shouldReturnNullWhenDirectoryArgIsNotADirectory() throws Exception {
+ File tempFile = File.createTempFile("pipo-", ".tmp");
+ tempFile.deleteOnExit();
+ assertNull(findResponseTimeLogFileInDirectory("/pipo", tempFile));
+ }
+
+ @Test
+ public void shouldReturnNullWhenNoFileWasFound() throws Exception {
+ File logFileDir = createLogFileDir();
+ assertNull(findResponseTimeLogFileInDirectory("/pipo", logFileDir));
+ }
+
+ @Test
+ public void shouldReturnFoundFile() throws Exception {
+ File logFileDir = createLogFileDir();
+ File logFile = File.createTempFile("log", "pipo_rt.log", logFileDir);
+ logFile.deleteOnExit();
+ assertNotNull(findResponseTimeLogFileInDirectory("/pipo", logFileDir));
+ }
+
+ @Test
+ public void shouldReturnNullIfFoundMoreThanOneFile() throws Exception {
+ File logFileDir = createLogFileDir();
+ File logFile1 = File.createTempFile("log", "pipo_rt.log", logFileDir);
+ logFile1.deleteOnExit();
+ File logFile2 = File.createTempFile("log", "pipo_rt.log", logFileDir);
+ logFile2.deleteOnExit();
+ assertNull(findResponseTimeLogFileInDirectory("/pipo", logFileDir));
+ }
+
+ @Test
+ public void shouldReturnFoundFileForRootContext() throws Exception {
+ File logFileDir = createLogFileDir();
+ File logFile = File.createTempFile("log", "ROOT_rt.log", logFileDir);
+ logFile.deleteOnExit();
+ assertNotNull(findResponseTimeLogFileInDirectory("/", logFileDir));
+ }
+
+ @Test
+ public void shouldReturnFoundFileForSubContexts() throws Exception {
+ File logFileDir = createLogFileDir();
+ File logFile = File.createTempFile("log", "pipo_molo_molette_rt.log", logFileDir);
+ logFile.deleteOnExit();
+ assertNotNull(findResponseTimeLogFileInDirectory("/pipo/molo/molette", logFileDir));
+ }
+
+ private static File createLogFileDir() throws Exception {
+ // Java 1.6 has no temp dir creation util
+ File tempDir = File.createTempFile("pipo-", ".tmp");
+ if (tempDir.delete() && tempDir.mkdir()) {
+ tempDir.deleteOnExit();
+ return tempDir;
+ }
+ throw new RuntimeException("Could not create temp directory");
+ }
+}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
index d0839a8..0d45594 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerComponent.java
@@ -1,25 +1,22 @@
/*
- * Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program 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 General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
+
package org.rhq.plugins.jbossas5;
import java.io.File;
@@ -564,4 +561,19 @@ public class ApplicationServerComponent<T extends ResourceComponent<?>> implemen
return ManagedComponentUtils.getSimplePropertyValue(component, propertyName);
}
+
+ /**
+ * Find the parent {@link ApplicationServerComponent} of the specified {@link ProfileServiceComponent}.
+ *
+ * @param profileServiceComponent
+ * @return the parent {@link ApplicationServerComponent} or null
+ */
+ public static ApplicationServerComponent<?> findApplicationServerComponent(ProfileServiceComponent profileServiceComponent) {
+ ProfileServiceComponent component = profileServiceComponent;
+ while (component != null && !(component instanceof ApplicationServerComponent)) {
+ ResourceComponent parent = component.getResourceContext().getParentResourceComponent();
+ component = (parent instanceof ProfileServiceComponent) ? (ProfileServiceComponent) parent : null;
+ }
+ return (ApplicationServerComponent<?>) component;
+ }
}
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextDiscoveryComponent.java
index 08f750c..ee706f4 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextDiscoveryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/WebApplicationContextDiscoveryComponent.java
@@ -1,27 +1,30 @@
/*
- * Jopr Management Platform
- * Copyright (C) 2005-2009 Red Hat, Inc.
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License, version 2, as
- * published by the Free Software Foundation, and/or the GNU Lesser
- * General Public License, version 2.1, also as published by the Free
- * Software Foundation.
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
*
* This program 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 General Public License and the GNU Lesser General Public License
- * for more details.
+ * GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * and the GNU Lesser General Public License along with this program;
- * if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
+
package org.rhq.plugins.jbossas5;
+import static org.rhq.core.pluginapi.util.ResponseTimeConfiguration.RESPONSE_TIME_LOG_FILE_CONFIG_PROP;
+import static org.rhq.core.pluginapi.util.ResponseTimeLogFinder.FALLBACK_RESPONSE_TIME_LOG_FILE_DIRECTORY;
+import static org.rhq.core.pluginapi.util.ResponseTimeLogFinder.findResponseTimeLogFileInDirectory;
+import static org.rhq.plugins.jbossas5.ApplicationServerPluginConfigurationProperties.SERVER_HOME_DIR;
+
+import java.io.File;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -46,6 +49,7 @@ import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.util.StringUtil;
import org.rhq.plugins.jbossas5.helper.MoreKnownComponentTypes;
import org.rhq.plugins.jbossas5.util.ManagedComponentUtils;
import org.rhq.plugins.jbossas5.util.RegularExpressionNameMatcher;
@@ -107,6 +111,8 @@ public class WebApplicationContextDiscoveryComponent implements
pluginConfig.put(new PropertySimple(ManagedComponentComponent.Config.COMPONENT_NAME,
webApplicationManagerComponentName));
+ discoverResponseTimeLogFile(parentWarComponent, contextPath, pluginConfig);
+
DiscoveredResourceDetails resource = new DiscoveredResourceDetails(resourceType, resourceKey, resourceName,
resourceVersion, resourceType.getDescription(), pluginConfig, null);
@@ -117,6 +123,29 @@ public class WebApplicationContextDiscoveryComponent implements
return discoveredResources;
}
+ private void discoverResponseTimeLogFile(AbstractManagedDeploymentComponent parentWarComponent, String contextPath,
+ Configuration pluginConfig) {
+ String rtFilePath = null;
+ // First search in SERVER_HOME_DIR/log/rt directory
+ ApplicationServerComponent applicationServerComponent = ApplicationServerComponent
+ .findApplicationServerComponent(parentWarComponent);
+ if (applicationServerComponent != null) {
+ String serverHomeDir = applicationServerComponent.getResourceContext().getPluginConfiguration()
+ .getSimpleValue(SERVER_HOME_DIR);
+ if (StringUtil.isNotBlank(serverHomeDir)) {
+ File rtDirectory = new File(serverHomeDir + File.separator + "log" + File.separator + "rt");
+ rtFilePath = findResponseTimeLogFileInDirectory(contextPath, rtDirectory);
+ }
+ }
+ if (rtFilePath == null) {
+ // Search again in FALLBACK_RESPONSE_TIME_LOG_FILE_DIRECTORY
+ rtFilePath = findResponseTimeLogFileInDirectory(contextPath, FALLBACK_RESPONSE_TIME_LOG_FILE_DIRECTORY);
+ }
+ if (rtFilePath != null) {
+ pluginConfig.setSimpleValue(RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtFilePath);
+ }
+ }
+
/**
* Returns the parent WAR's context path (e.g. "/jmx-console"), or <code>null</code> if the WAR is currently
* stopped, since stopped WARs are not associated with any contexts.
@@ -177,4 +206,4 @@ public class WebApplicationContextDiscoveryComponent implements
hostName = hostName.substring(0, hostName.indexOf("/"));
return hostName;
}
-}
\ No newline at end of file
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 5d540fd..13e1b75 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -411,8 +411,15 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
return operationResult;
}
- private boolean isManuallyAddedServer(OperationResult operationResult, String operation) {
+ public boolean isManuallyAddedServer() {
if (pluginConfiguration.get("manuallyAdded") != null) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isManuallyAddedServer(OperationResult operationResult, String operation) {
+ if (isManuallyAddedServer()) {
operationResult.setErrorMessage(operation + " is not enabled for manually added servers");
return true;
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebRuntimeDiscoveryComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebRuntimeDiscoveryComponent.java
new file mode 100644
index 0000000..31af277
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WebRuntimeDiscoveryComponent.java
@@ -0,0 +1,133 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.plugins.jbossas7;
+
+import static org.rhq.core.pluginapi.util.ResponseTimeConfiguration.RESPONSE_TIME_LOG_FILE_CONFIG_PROP;
+import static org.rhq.core.pluginapi.util.ResponseTimeLogFinder.FALLBACK_RESPONSE_TIME_LOG_FILE_DIRECTORY;
+import static org.rhq.core.pluginapi.util.ResponseTimeLogFinder.findResponseTimeLogFileInDirectory;
+
+import java.io.File;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.util.StringUtil;
+import org.rhq.modules.plugins.jbossas7.json.Address;
+import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * @author Thomas Segismont
+ */
+public class WebRuntimeDiscoveryComponent extends SubsystemDiscovery {
+ private static final Log LOG = LogFactory.getLog(WebRuntimeDiscoveryComponent.class);
+
+ private static final String CONTEXT_ROOT_ATTRIBUTE = "context-root";
+ private static final String PATH_ATTRIBUTE = "path";
+ private static final String PATH_DELIM = ",";
+ private static final String SERVER_PREFIX = "server=";
+
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent<?>> context)
+ throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = super.discoverResources(context);
+ if (discoveredResources.isEmpty()) {
+ return discoveredResources;
+ }
+ if (discoveredResources.size() != 1) {
+ throw new IllegalStateException("Discovered multiple instances of a singleton resource type");
+ }
+
+ BaseComponent<?> parentResourceComponent = context.getParentResourceComponent();
+ BaseServerComponent serverComponent = parentResourceComponent.getServerComponent();
+ DiscoveredResourceDetails resourceDetails = discoveredResources.iterator().next();
+ Configuration pluginConfig = resourceDetails.getPluginConfiguration();
+ String nodePath = pluginConfig.getSimpleValue(PATH_ATTRIBUTE);
+ String contextRoot = getContextRootAttribute(new Address(nodePath), parentResourceComponent.getASConnection());
+
+ discoverResponseTimeLogFile(serverComponent, pluginConfig, nodePath, contextRoot);
+
+ return discoveredResources;
+ }
+
+ private void discoverResponseTimeLogFile(BaseServerComponent serverComponent, Configuration pluginConfig,
+ String nodePath, String contextRoot) {
+ if (serverComponent.isManuallyAddedServer()) {
+ return;
+ }
+ String rtFilePath = null;
+ // First search in server log directory
+ if (serverComponent instanceof StandaloneASComponent) {
+ File serverLogDir = serverComponent.getServerPluginConfiguration().getLogDir();
+ if (serverLogDir != null) {
+ File rtDirectory = new File(serverLogDir, "rt");
+ rtFilePath = findResponseTimeLogFileInDirectory(contextRoot, rtDirectory);
+ }
+ } else if (serverComponent instanceof HostControllerComponent) {
+ File hostControllerBaseDir = serverComponent.getServerPluginConfiguration().getBaseDir();
+ String managedServerName = getManagedServerNameFromPathAttribute(nodePath);
+ if (hostControllerBaseDir != null) {
+ File rtDirectory = new File(hostControllerBaseDir, "servers" + File.separator + managedServerName
+ + File.separator + "log" + File.separator + "rt");
+ rtFilePath = findResponseTimeLogFileInDirectory(contextRoot, rtDirectory);
+ }
+ } else {
+ if (LOG.isWarnEnabled()) {
+ LOG.warn("Unknown BaseServerComponent class: " + serverComponent.getClass().getName());
+ }
+ }
+ if (rtFilePath == null) {
+ // Search again in FALLBACK_RESPONSE_TIME_LOG_FILE_DIRECTORY
+ rtFilePath = findResponseTimeLogFileInDirectory(contextRoot, FALLBACK_RESPONSE_TIME_LOG_FILE_DIRECTORY);
+ }
+ if (rtFilePath != null) {
+ pluginConfig.setSimpleValue(RESPONSE_TIME_LOG_FILE_CONFIG_PROP, rtFilePath);
+ }
+ }
+
+ private String getContextRootAttribute(Address address, ASConnection asConnection) {
+ ReadAttribute readAttribute = new ReadAttribute(address, CONTEXT_ROOT_ATTRIBUTE);
+ Result readAttributeResult = asConnection.execute(readAttribute);
+ if (!readAttributeResult.isSuccess()) {
+ throw new RuntimeException("Could not read [" + CONTEXT_ROOT_ATTRIBUTE + "] attribute of node ["
+ + address.getPath() + "]: " + readAttributeResult.getFailureDescription());
+ }
+ return (String) readAttributeResult.getResult();
+ }
+
+ private String getManagedServerNameFromPathAttribute(String nodePath) {
+ for (StringTokenizer tokenizer = new StringTokenizer(nodePath, PATH_DELIM); tokenizer.hasMoreTokens();) {
+ String token = tokenizer.nextToken();
+ if (token.startsWith(SERVER_PREFIX)) {
+ String managedServerName = token.substring(SERVER_PREFIX.length());
+ if (StringUtil.isBlank(managedServerName)) {
+ throw new RuntimeException("Blank managed server name in path [" + nodePath + "]");
+ }
+ return managedServerName;
+ }
+ }
+ throw new RuntimeException("Could not determine managed server name from path [" + nodePath + "]");
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 6555008..e9449a5 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -1,5 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ RHQ Management Platform
+ ~ Copyright (C) 2005-2013 Red Hat, Inc.
+ ~ All rights reserved.
+ ~
+ ~ This program is free software; you can redistribute it and/or modify
+ ~ it under the terms of the GNU General Public License as published by
+ ~ the Free Software Foundation version 2 of the License.
+ ~
+ ~ This program 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 General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License
+ ~ along with this program; if not, write to the Free Software Foundation, Inc.,
+ ~ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ -->
+
<!DOCTYPE plugin [
<!ENTITY pluginName 'JBossAS7'>
@@ -8864,7 +8883,7 @@
<service name="Web Runtime"
class="WebRuntimeComponent"
- discovery="SubsystemDiscovery"
+ discovery="WebRuntimeDiscoveryComponent"
description="Runtime resources exposed by web components in the deployment."
singleton="true">
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/WebRuntimeDiscoveryComponentTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/WebRuntimeDiscoveryComponentTest.java
new file mode 100644
index 0000000..e9f6476
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/WebRuntimeDiscoveryComponentTest.java
@@ -0,0 +1,221 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.plugins.jbossas7;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.rhq.modules.plugins.jbossas7.json.Result.SUCCESS;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Set;
+
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.pluginapi.util.ResponseTimeConfiguration;
+import org.rhq.modules.plugins.jbossas7.helper.ServerPluginConfiguration;
+import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
+import org.rhq.modules.plugins.jbossas7.json.ReadResource;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * @author Thomas Segismont
+ */
+public class WebRuntimeDiscoveryComponentTest {
+ private static final String WEBAPP = "coregui";
+ private static final String PATH_ATTRIBUTE = "path";
+ private static final String PARENT_COMPONENT_PATH_IN_STANDALONE_SERVER = "subdeployment=" + WEBAPP + ".war";
+ private static final String MANAGED_SERVER_NAME = "server-one";
+ private static final String PARENT_COMPONENT_PATH_IN_MANAGED_SERVER = "server=" + MANAGED_SERVER_NAME
+ + ",subdeployment=" + WEBAPP + ".war";
+ private static final String CONF_PATH = "subsystem=web";
+
+ private WebRuntimeDiscoveryComponent discoveryComponent;
+
+ @Mock
+ private ResourceDiscoveryContext discoveryContext;
+
+ @Mock
+ private BaseComponent parentResourceComponent;
+
+ @Mock
+ private ASConnection asConnection;
+
+ @Mock
+ private ResourceType resourceType;
+
+ @Mock
+ private StandaloneASComponent standaloneASComponent;
+
+ @Mock
+ private HostControllerComponent hostControllerComponent;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setup() throws Exception {
+ discoveryComponent = new WebRuntimeDiscoveryComponent();
+ MockitoAnnotations.initMocks(this);
+ when(discoveryContext.getParentResourceComponent()).thenReturn(parentResourceComponent);
+ when(parentResourceComponent.getASConnection()).thenReturn(asConnection);
+ when(discoveryContext.getDefaultPluginConfiguration()).thenReturn(createDefaultPluginConfig());
+ when(asConnection.execute(any(ReadResource.class))).thenReturn(createReadResourceResult());
+ when(discoveryContext.getResourceType()).thenReturn(resourceType);
+ when(resourceType.getDescription()).thenReturn("Description");
+ when(asConnection.execute(any(ReadAttribute.class))).thenReturn(createReadAttributeResult());
+ }
+
+ private Configuration createDefaultPluginConfig() {
+ Configuration configuration = new Configuration();
+ configuration.setSimpleValue(PATH_ATTRIBUTE, CONF_PATH);
+ return configuration;
+ }
+
+ private Result createReadResourceResult() {
+ Result result = new Result();
+ result.setOutcome(SUCCESS);
+ return result;
+ }
+
+ private Result createReadAttributeResult() {
+ Result result = new Result();
+ result.setOutcome(SUCCESS);
+ result.setResult("/" + WEBAPP);
+ return result;
+ }
+
+ @Test
+ public void shouldFindResponseTimeFilterLogInStandaloneServer() throws Exception {
+ when(parentResourceComponent.getPath()).thenReturn(PARENT_COMPONENT_PATH_IN_STANDALONE_SERVER);
+ when(parentResourceComponent.getServerComponent()).thenReturn(standaloneASComponent);
+ when(standaloneASComponent.isManuallyAddedServer()).thenReturn(Boolean.FALSE);
+ ServerPluginConfiguration standaloneServerPluginConfig = createStandaloneServerPluginConfig();
+ when(standaloneASComponent.getServerPluginConfiguration()).thenReturn(standaloneServerPluginConfig);
+ File standaloneResponseTimeLogFile = createStandaloneServerResponseTimeLogFile(standaloneServerPluginConfig);
+
+ Set<DiscoveredResourceDetails> details = discoveryComponent.discoverResources(discoveryContext);
+ assertNotNull(details);
+ assertEquals(details.size(), 1);
+ DiscoveredResourceDetails discoveredResourceDetails = details.iterator().next();
+ String rtFilePath = discoveredResourceDetails.getPluginConfiguration().getSimpleValue(
+ ResponseTimeConfiguration.RESPONSE_TIME_LOG_FILE_CONFIG_PROP);
+ assertNotNull(rtFilePath);
+ assertEquals(rtFilePath, standaloneResponseTimeLogFile.getAbsolutePath());
+ }
+
+ private ServerPluginConfiguration createStandaloneServerPluginConfig() throws Exception {
+ ServerPluginConfiguration mock = mock(ServerPluginConfiguration.class);
+ when(mock.getLogDir()).thenReturn(createTempDir());
+ return mock;
+ }
+
+ private File createStandaloneServerResponseTimeLogFile(ServerPluginConfiguration standaloneServerPluginConfig)
+ throws IOException {
+ File rtDir = new File(standaloneServerPluginConfig.getLogDir(), "rt");
+ rtDir.mkdir();
+ File logFile = new File(rtDir, WEBAPP + "_rt.log");
+ logFile.createNewFile();
+ return logFile;
+ }
+
+ @Test
+ public void shouldNotFindResponseTimeFilterLogInManuallyAddedStandaloneServer() throws Exception {
+ when(parentResourceComponent.getPath()).thenReturn(PARENT_COMPONENT_PATH_IN_STANDALONE_SERVER);
+ when(parentResourceComponent.getServerComponent()).thenReturn(standaloneASComponent);
+ when(standaloneASComponent.isManuallyAddedServer()).thenReturn(Boolean.TRUE);
+
+ Set<DiscoveredResourceDetails> details = discoveryComponent.discoverResources(discoveryContext);
+ assertNotNull(details);
+ assertEquals(details.size(), 1);
+ DiscoveredResourceDetails discoveredResourceDetails = details.iterator().next();
+ String rtFilePath = discoveredResourceDetails.getPluginConfiguration().getSimpleValue(
+ ResponseTimeConfiguration.RESPONSE_TIME_LOG_FILE_CONFIG_PROP);
+ assertNull(rtFilePath);
+ }
+
+ @Test
+ public void shouldFindResponseTimeFilterLogInManagedServer() throws Exception {
+ when(parentResourceComponent.getPath()).thenReturn(PARENT_COMPONENT_PATH_IN_MANAGED_SERVER);
+ when(parentResourceComponent.getServerComponent()).thenReturn(hostControllerComponent);
+ when(hostControllerComponent.isManuallyAddedServer()).thenReturn(Boolean.FALSE);
+ ServerPluginConfiguration hostControllerServerPluginConfig = createHostControllerServerPluginConfig();
+ when(hostControllerComponent.getServerPluginConfiguration()).thenReturn(hostControllerServerPluginConfig);
+ File managedServerResponseTimeLogFile = createManagedServerResponseTimeLogFile(hostControllerServerPluginConfig);
+
+ Set<DiscoveredResourceDetails> details = discoveryComponent.discoverResources(discoveryContext);
+ assertNotNull(details);
+ assertEquals(details.size(), 1);
+ DiscoveredResourceDetails discoveredResourceDetails = details.iterator().next();
+ String rtFilePath = discoveredResourceDetails.getPluginConfiguration().getSimpleValue(
+ ResponseTimeConfiguration.RESPONSE_TIME_LOG_FILE_CONFIG_PROP);
+ assertNotNull(rtFilePath);
+ assertEquals(rtFilePath, managedServerResponseTimeLogFile.getAbsolutePath());
+ }
+
+ private ServerPluginConfiguration createHostControllerServerPluginConfig() throws Exception {
+ ServerPluginConfiguration mock = mock(ServerPluginConfiguration.class);
+ when(mock.getBaseDir()).thenReturn(createTempDir());
+ return mock;
+ }
+
+ private File createManagedServerResponseTimeLogFile(ServerPluginConfiguration hostControllerServerPluginConfig)
+ throws IOException {
+ File rtDir = new File(hostControllerServerPluginConfig.getBaseDir(), "servers" + File.separator
+ + MANAGED_SERVER_NAME + File.separator + "log" + File.separator + "rt");
+ rtDir.mkdirs();
+ File logFile = new File(rtDir, WEBAPP + "_rt.log");
+ logFile.createNewFile();
+ return logFile;
+ }
+
+ @Test
+ public void shouldNotFindResponseTimeFilterLogInManuallyAddedManagedServer() throws Exception {
+ when(parentResourceComponent.getPath()).thenReturn(PARENT_COMPONENT_PATH_IN_MANAGED_SERVER);
+ when(parentResourceComponent.getServerComponent()).thenReturn(hostControllerComponent);
+ when(hostControllerComponent.isManuallyAddedServer()).thenReturn(Boolean.TRUE);
+
+ Set<DiscoveredResourceDetails> details = discoveryComponent.discoverResources(discoveryContext);
+ assertNotNull(details);
+ assertEquals(details.size(), 1);
+ DiscoveredResourceDetails discoveredResourceDetails = details.iterator().next();
+ String rtFilePath = discoveredResourceDetails.getPluginConfiguration().getSimpleValue(
+ ResponseTimeConfiguration.RESPONSE_TIME_LOG_FILE_CONFIG_PROP);
+ assertNull(rtFilePath);
+ }
+
+ private static File createTempDir() throws Exception {
+ // Java 1.6 has no temp dir creation util
+ File tempDir = File.createTempFile("pipo-", ".tmp");
+ if (tempDir.delete() && tempDir.mkdir()) {
+ tempDir.deleteOnExit();
+ return tempDir;
+ }
+ throw new RuntimeException("Could not create temp directory");
+ }
+}
10 years, 10 months
[rhq] modules/enterprise
by Thomas Segismont
modules/enterprise/agent/src/etc/rhq-agent.sh | 6 ++++++
1 file changed, 6 insertions(+)
New commits:
commit e0ff57671c03264969d0870a6ba67efb41f8f218
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Mon Jun 24 17:44:33 2013 +0200
Bug 819116 - Attach API only works with RHQ_AGENT_JAVA_HOME
diff --git a/modules/enterprise/agent/src/etc/rhq-agent.sh b/modules/enterprise/agent/src/etc/rhq-agent.sh
index 9e8de03..be30134 100755
--- a/modules/enterprise/agent/src/etc/rhq-agent.sh
+++ b/modules/enterprise/agent/src/etc/rhq-agent.sh
@@ -126,6 +126,12 @@ if [ -z "$RHQ_AGENT_JAVA_EXE_FILE_PATH" ]; then
fi
debug_msg "RHQ_AGENT_JAVA_HOME: $RHQ_AGENT_JAVA_HOME"
RHQ_AGENT_JAVA_EXE_FILE_PATH="${RHQ_AGENT_JAVA_HOME}/bin/java"
+else
+ # Infer RHQ_AGENT_JAVA_HOME from RHQ_AGENT_JAVA_EXE_FILE_PATH
+ # RHQ_AGENT_JAVA_HOME will be used later to find JDK's tools.jar if available
+ _RHQ_AGENT_JAVA_BIN_DIR=`dirname "$RHQ_AGENT_JAVA_EXE_FILE_PATH"`
+ RHQ_AGENT_JAVA_HOME=`dirname "$_RHQ_AGENT_JAVA_BIN_DIR"`
+ debug_msg "RHQ_AGENT_JAVA_HOME (inferred from RHQ_AGENT_JAVA_EXE_FILE_PATH): $RHQ_AGENT_JAVA_HOME"
fi
debug_msg "RHQ_AGENT_JAVA_EXE_FILE_PATH: $RHQ_AGENT_JAVA_EXE_FILE_PATH"
10 years, 10 months