[rhq] modules/enterprise
by snegrea
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml | 2 +-
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml | 2 +-
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
New commits:
commit f3a39fd7c84e203b90c3a0b6e35bc0e0fc8c4c9b
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 13:43:36 2011 -0500
Fix dbunit setup failures after a new table was added to the schema.
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
index 290ad18..51e689e 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
@@ -10,8 +10,8 @@
mtime="123456"/>
<rhq_config_def/>
- <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
index 306297c..0cfe2f1 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
@@ -1,7 +1,7 @@
<dataset>
<rhq_config_def/>
- <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
index d584809..29351c4 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/resource/metadata/MetadataTest.xml
@@ -2,6 +2,7 @@
<rhq_config_def/>
<rhq_config_prop_grp_def/>
<rhq_config_prop_def/>
+ <rhq_config_pd_osrc/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
<rhq_config/>
12 years, 10 months
[rhq] Branch 'drift' - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java | 22 -
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java | 5
modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java | 8
modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java | 10
modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java | 143 ++++-----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java | 45 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java | 105 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java | 125 ++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardConfigStep.java | 72 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java | 149 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java | 10
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java | 37 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java | 12
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 10
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 10
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 12
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 12
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 56 +++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java | 13
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java | 3
25 files changed, 732 insertions(+), 159 deletions(-)
New commits:
commit c1f5d145351bd748665ad2dbdd6c6e41b89e6fe8
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Jun 28 12:30:44 2011 -0400
Drift AddConfig Wizard Work (not fully functional)
- Remove use of ConfigurationManagerLocal.getConfiguration() for security reasons
- add DriftManagerLocal.getDriftConfiguration() as an alternative
- Launch wizard from Add button in Drift->Configuration subtab
- Add new resource perm MANAGE_DRIFT infrastructure
- Add ResourceTypeCriteria.fetchDriftConfigurationTemplates
-
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
index 3b15d0f..16f60dc 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/authz/Permission.java
@@ -53,7 +53,6 @@ public enum Permission {
*/
MANAGE_SETTINGS(Target.GLOBAL), // 2
-
/* ========= Resource Permissions ========= */
/**
@@ -126,8 +125,13 @@ public enum Permission {
* Can C/U/D repositories and content sources
*/
// NOTE: This is a GLOBAL permission but defined here to maintain the ordinal indexes
- MANAGE_REPOSITORIES(Target.GLOBAL) // 15
-
+ MANAGE_REPOSITORIES(Target.GLOBAL), // 15
+
+ /**
+ * Can C/U/D drift related entities
+ */
+ MANAGE_DRIFT(Target.RESOURCE) // 16
+
;
/**
@@ -161,12 +165,12 @@ public enum Permission {
static {
for (Permission permission : Permission.values()) {
switch (permission.getTarget()) {
- case GLOBAL:
- GLOBAL_ALL.add(permission);
- break;
- case RESOURCE:
- RESOURCE_ALL.add(permission);
- break;
+ case GLOBAL:
+ GLOBAL_ALL.add(permission);
+ break;
+ case RESOURCE:
+ RESOURCE_ALL.add(permission);
+ break;
}
}
}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
index 6510989..719fc93 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceTypeCriteria.java
@@ -74,6 +74,7 @@ public class ResourceTypeCriteria extends Criteria {
private boolean fetchProductVersions;
private boolean fetchBundleType;
private boolean fetchResources;
+ private boolean fetchDriftConfigurationTemplates;
private PageOrdering sortName;
private PageOrdering sortCategory;
@@ -202,6 +203,10 @@ public class ResourceTypeCriteria extends Criteria {
this.fetchResources = fetchResources;
}
+ public void fetchDriftConfigurationTemplates(boolean fetchDriftConfigurationTemplates) {
+ this.fetchDriftConfigurationTemplates = fetchDriftConfigurationTemplates;
+ }
+
public void addSortName(PageOrdering sortName) {
addSortField("name");
this.sortName = sortName;
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
index 25c8113..6067474 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/Resource.java
@@ -589,7 +589,8 @@ import org.rhq.core.domain.util.Summary;
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 11), " // we want CONFIGURE_WRITE, 11
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 9), " // we want MANAGE_CONTENT, 9
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 6), " // we want CREATE_CHILD_RESOURCES, 6
- + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 5)) " // we want DELETE_RESOURCES, 5
+ + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 5), " // we want DELETE_RESOURCES, 5
+ + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 16)) " // we want MANAGE_DRIFT, 16
+ "FROM Resource res " //
+ " LEFT JOIN res.currentAvailability a " //
+ "WHERE res.id IN (SELECT rr.id FROM Resource rr JOIN rr.implicitGroups g JOIN g.roles r JOIN r.subjects s WHERE s = :subject)"
@@ -612,7 +613,8 @@ import org.rhq.core.domain.util.Summary;
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 11), " // we want CONFIGURE_WRITE, 11
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 9), " // we want MANAGE_CONTENT, 9
+ " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 6), " // we want CREATE_CHILD_RESOURCES, 6
- + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 5)) " // we want DELETE_RESOURCES, 5
+ + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 5), " // we want DELETE_RESOURCES, 5
+ + " (SELECT count(p) FROM res.implicitGroups g JOIN g.roles r JOIN r.subjects s JOIN r.permissions p WHERE s = :subject AND p = 16)) " // we want MANAGE_DRIFT, 16
+ "FROM Resource res " //
+ " LEFT JOIN res.parentResource parent " //
+ " LEFT JOIN res.currentAvailability a " //
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java
index c89a0e6..94de345 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourceComposite.java
@@ -75,11 +75,11 @@ public class ResourceComposite implements Serializable {
*/
public ResourceComposite(Resource resource, AvailabilityType availability, Number measure, Number inventory,
Number control, Number alert, Number event, Number configureRead, Number configureWrite, Number content,
- Number createChildResources, Number deleteResources) {
+ Number createChildResources, Number deleteResources, Number drift) {
this(resource, null, availability, new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0,
control.intValue() > 0, alert.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0,
configureWrite.intValue() > 0, content.intValue() > 0, createChildResources.intValue() > 0, deleteResources
- .intValue() > 0));
+ .intValue() > 0, drift.intValue() > 0));
}
/**
@@ -87,11 +87,11 @@ public class ResourceComposite implements Serializable {
*/
public ResourceComposite(Resource resource, Resource parent, AvailabilityType availability, Number measure,
Number inventory, Number control, Number alert, Number event, Number configureRead, Number configureWrite,
- Number content, Number createChildResources, Number deleteResources) {
+ Number content, Number createChildResources, Number deleteResources, Number drift) {
this(resource, parent, availability, new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0,
control.intValue() > 0, alert.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0,
configureWrite.intValue() > 0, content.intValue() > 0, createChildResources.intValue() > 0, deleteResources
- .intValue() > 0));
+ .intValue() > 0, drift.intValue() > 0));
}
// Private constructor that all public constructors delegate to
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java
index cd7a058..5f53af5 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/composite/ResourcePermission.java
@@ -59,7 +59,7 @@ public class ResourcePermission implements Serializable {
boolean configureWrite, //
boolean content, //
boolean createChildResources,//
- boolean deleteResource) {
+ boolean deleteResource, boolean drift) {
this.permissions = new HashSet<Permission>();
@@ -93,8 +93,12 @@ public class ResourcePermission implements Serializable {
if (deleteResource) {
this.permissions.add(Permission.DELETE_RESOURCE);
}
+ if (drift) {
+ this.permissions.add(Permission.MANAGE_DRIFT);
+ }
}
+ @SuppressWarnings("unchecked")
public ResourcePermission(Set<Permission> permissions) {
if (permissions instanceof EnumSet) {
throw new IllegalArgumentException("EnumSet is not allowed due to GWT Serialization issues");
@@ -119,10 +123,8 @@ public class ResourcePermission implements Serializable {
return this.permissions.contains(Permission.MANAGE_ALERTS);
}
- // TODO geta real resource perm
public boolean isDrift() {
- return true;
- //return this.permissions.contains(Permission.MANAGE_DRIFT);
+ return this.permissions.contains(Permission.MANAGE_DRIFT);
}
public boolean isEvent() {
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
index 91b7ffa..be3676a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/resource/group/composite/ResourceGroupComposite.java
@@ -79,11 +79,12 @@ public class ResourceGroupComposite implements Serializable {
public ResourceGroupComposite(Long explicitCount, Double explicitAvailability, Long implicitCount,
Double implicitAvailability, ResourceGroup resourceGroup, Number measure, Number inventory, Number control,
Number alert, Number event, Number configureRead, Number configureWrite, Number content,
- Number createChildResources, Number deleteResources) {
+ Number createChildResources, Number deleteResources, Number drift) {
this(explicitCount, explicitAvailability, implicitCount, implicitAvailability, resourceGroup, null,
new ResourcePermission(measure.intValue() > 0, inventory.intValue() > 0, control.intValue() > 0, alert
.intValue() > 0, event.intValue() > 0, configureRead.intValue() > 0, configureWrite.intValue() > 0,
- content.intValue() > 0, createChildResources.intValue() > 0, deleteResources.intValue() > 0));
+ content.intValue() > 0, createChildResources.intValue() > 0, deleteResources.intValue() > 0, drift
+ .intValue() > 0));
}
public ResourceGroupComposite(Long explicitCount, Double explicitAvailability, Long implicitCount,
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
index 29eb9c7..c2b33eb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/admin/roles/PermissionsEditor.java
@@ -77,7 +77,7 @@ public class PermissionsEditor extends LocatableVStack {
setWidth("95%");
setHeight100();
-
+
VLayout spacer = createVerticalSpacer(13);
addMember(spacer);
@@ -138,7 +138,7 @@ public class PermissionsEditor extends LocatableVStack {
if (this.originalValue == null) {
this.originalValue = nativeArray;
}
- ListGridRecord[] permissionRecords = convertToListGridRecordArray((JavaScriptObject)nativeArray);
+ ListGridRecord[] permissionRecords = convertToListGridRecordArray((JavaScriptObject) nativeArray);
return RolesDataSource.toPermissionSet(permissionRecords);
}
@@ -154,34 +154,33 @@ public class PermissionsEditor extends LocatableVStack {
ListGridField descriptionField = new ListGridField("description", MSG.common_title_description());
descriptionField.setWrap(true);
- final ListGridField authorizedField = createAuthorizedField("authorized",
- MSG.view_adminRoles_permissions_isAuthorized(), "name", grid);
+ final ListGridField authorizedField = createAuthorizedField("authorized", MSG
+ .view_adminRoles_permissions_isAuthorized(), "name", grid);
grid.setFields(iconField, displayNameField, authorizedField, descriptionField);
List<ListGridRecord> records = new ArrayList<ListGridRecord>();
ListGridRecord record = createGlobalPermissionRecord(MSG.view_adminRoles_permissions_perm_manageSecurity(),
- "global/Locked", Permission.MANAGE_SECURITY,
- MSG.view_adminRoles_permissions_permDesc_manageSecurity());
+ "global/Locked", Permission.MANAGE_SECURITY, MSG.view_adminRoles_permissions_permDesc_manageSecurity());
records.add(record);
record = createGlobalPermissionRecord(MSG.view_adminRoles_permissions_perm_manageInventory(),
- "subsystems/inventory/Inventory", Permission.MANAGE_INVENTORY,
- MSG.view_adminRoles_permissions_permDesc_manageInventory());
+ "subsystems/inventory/Inventory", Permission.MANAGE_INVENTORY, MSG
+ .view_adminRoles_permissions_permDesc_manageInventory());
records.add(record);
record = createGlobalPermissionRecord(MSG.view_adminRoles_permissions_perm_manageSettings(),
- "subsystems/configure/Configure", Permission.MANAGE_SETTINGS,
- MSG.view_adminRoles_permissions_permDesc_manageSettings());
+ "subsystems/configure/Configure", Permission.MANAGE_SETTINGS, MSG
+ .view_adminRoles_permissions_permDesc_manageSettings());
records.add(record);
record = createGlobalPermissionRecord(MSG.view_adminRoles_permissions_perm_manageBundles(),
- "subsystems/bundle/Bundle", Permission.MANAGE_BUNDLE,
- MSG.view_adminRoles_permissions_permDesc_manageBundles());
+ "subsystems/bundle/Bundle", Permission.MANAGE_BUNDLE, MSG
+ .view_adminRoles_permissions_permDesc_manageBundles());
records.add(record);
record = createGlobalPermissionRecord(MSG.view_adminRoles_permissions_perm_manageRepositories(),
- "subsystems/content/Content", Permission.MANAGE_REPOSITORIES,
- MSG.view_adminRoles_permissions_permDesc_manageRepositories());
+ "subsystems/content/Content", Permission.MANAGE_REPOSITORIES, MSG
+ .view_adminRoles_permissions_permDesc_manageRepositories());
records.add(record);
-
+
grid.setData(records.toArray(new ListGridRecord[records.size()]));
return grid;
@@ -208,75 +207,63 @@ public class PermissionsEditor extends LocatableVStack {
List<ListGridRecord> records = new ArrayList<ListGridRecord>();
ListGridRecord record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_inventory(),
- "subsystems/inventory/Inventory",
- Permission.VIEW_RESOURCE,
- MSG.view_adminRoles_permissions_permReadDesc_inventory(),
- Permission.MODIFY_RESOURCE,
- MSG.view_adminRoles_permissions_permWriteDesc_inventory());
+ "subsystems/inventory/Inventory", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_inventory(), Permission.MODIFY_RESOURCE, MSG
+ .view_adminRoles_permissions_permWriteDesc_inventory());
records.add(record);
record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_manageMeasurements(),
- "subsystems/monitor/Monitor",
- Permission.VIEW_RESOURCE,
- MSG.view_adminRoles_permissions_permReadDesc_manageMeasurements(),
- Permission.MANAGE_MEASUREMENTS,
- MSG.view_adminRoles_permissions_permWriteDesc_manageMeasurements());
+ "subsystems/monitor/Monitor", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_manageMeasurements(), Permission.MANAGE_MEASUREMENTS, MSG
+ .view_adminRoles_permissions_permWriteDesc_manageMeasurements());
records.add(record);
record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_manageAlerts(),
- "subsystems/alert/Alerts",
- Permission.VIEW_RESOURCE,
- MSG.view_adminRoles_permissions_permReadDesc_manageAlerts(),
- Permission.MANAGE_ALERTS,
- MSG.view_adminRoles_permissions_permWriteDesc_manageAlerts());
+ "subsystems/alert/Alerts", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_manageAlerts(), Permission.MANAGE_ALERTS, MSG
+ .view_adminRoles_permissions_permWriteDesc_manageAlerts());
records.add(record);
record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_configure(),
- "subsystems/configure/Configure",
- Permission.CONFIGURE_READ,
- MSG.view_adminRoles_permissions_permReadDesc_configure(),
- Permission.CONFIGURE_WRITE,
- MSG.view_adminRoles_permissions_permWriteDesc_configure());
+ "subsystems/configure/Configure", Permission.CONFIGURE_READ, MSG
+ .view_adminRoles_permissions_permReadDesc_configure(), Permission.CONFIGURE_WRITE, MSG
+ .view_adminRoles_permissions_permWriteDesc_configure());
records.add(record);
record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_control(),
- "subsystems/control/Operation",
- Permission.VIEW_RESOURCE,
- MSG.view_adminRoles_permissions_permReadDesc_control(),
- Permission.CONTROL,
- MSG.view_adminRoles_permissions_permWriteDesc_control());
+ "subsystems/control/Operation", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_control(), Permission.CONTROL, MSG
+ .view_adminRoles_permissions_permWriteDesc_control());
records.add(record);
record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_manageEvents(),
- "subsystems/event/Events",
- Permission.VIEW_RESOURCE,
- MSG.view_adminRoles_permissions_permReadDesc_manageEvents(),
- Permission.MANAGE_EVENTS,
- MSG.view_adminRoles_permissions_permWriteDesc_manageEvents());
+ "subsystems/event/Events", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_manageEvents(), Permission.MANAGE_EVENTS, MSG
+ .view_adminRoles_permissions_permWriteDesc_manageEvents());
records.add(record);
record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_manageContent(),
- "subsystems/content/Content",
- Permission.VIEW_RESOURCE,
- MSG.view_adminRoles_permissions_permReadDesc_manageContent(),
- Permission.MANAGE_CONTENT,
- MSG.view_adminRoles_permissions_permWriteDesc_manageContent());
+ "subsystems/content/Content", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_manageContent(), Permission.MANAGE_CONTENT, MSG
+ .view_adminRoles_permissions_permWriteDesc_manageContent());
records.add(record);
record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_createChildResources(),
- "subsystems/inventory/Inventory",
- Permission.VIEW_RESOURCE,
- MSG.view_adminRoles_permissions_permReadDesc_createChildResources(),
- Permission.CREATE_CHILD_RESOURCES,
+ "subsystems/inventory/Inventory", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_createChildResources(), Permission.CREATE_CHILD_RESOURCES,
MSG.view_adminRoles_permissions_permWriteDesc_createChildResources());
records.add(record);
record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_deleteChildResources(),
- "subsystems/inventory/Inventory",
- Permission.VIEW_RESOURCE,
- MSG.view_adminRoles_permissions_permReadDesc_deleteChildResources(),
- Permission.DELETE_RESOURCE,
- MSG.view_adminRoles_permissions_permWriteDesc_deleteChildResources());
+ "subsystems/inventory/Inventory", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_deleteChildResources(), Permission.DELETE_RESOURCE, MSG
+ .view_adminRoles_permissions_permWriteDesc_deleteChildResources());
+ records.add(record);
+
+ record = createResourcePermissionRecord(MSG.view_adminRoles_permissions_perm_manageDrift(),
+ "subsystems/drift/Drift", Permission.VIEW_RESOURCE, MSG
+ .view_adminRoles_permissions_permReadDesc_manageDrift(), Permission.MANAGE_DRIFT, MSG
+ .view_adminRoles_permissions_permWriteDesc_manageDrift());
records.add(record);
grid.setData(records.toArray(new ListGridRecord[records.size()]));
@@ -301,11 +288,11 @@ public class PermissionsEditor extends LocatableVStack {
grid.setAutoFitData(Autofit.BOTH);
grid.setWrapCells(true);
- grid.setFixedRecordHeights(false);
+ grid.setFixedRecordHeights(false);
return grid;
}
-
+
private ListGridField createAuthorizedField(String name, String title, final String nameField, final ListGrid grid) {
final ListGridField authorizedField = new ListGridField(name, title, 65);
@@ -322,7 +309,7 @@ public class PermissionsEditor extends LocatableVStack {
grid.setEditEvent(ListGridEditEvent.CLICK);
CheckboxItem editor = new CheckboxItem();
authorizedField.setEditorType(editor);
- final Record[] recordBeingEdited = {null};
+ final Record[] recordBeingEdited = { null };
authorizedField.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(RecordClickEvent event) {
recordBeingEdited[0] = event.getRecord();
@@ -330,7 +317,7 @@ public class PermissionsEditor extends LocatableVStack {
});
authorizedField.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
- Boolean authorized = (Boolean)event.getValue();
+ Boolean authorized = (Boolean) event.getValue();
int recordNum = event.getRowNum();
ListGridRecord record = grid.getRecord(recordNum);
String permissionName = record.getAttribute(nameField);
@@ -339,17 +326,20 @@ public class PermissionsEditor extends LocatableVStack {
if (permission == Permission.VIEW_RESOURCE) {
String messageString = MSG.view_adminRoles_permissions_readAccessImplied(permissionDisplayName);
handleIllegalPermissionSelection(event, messageString);
- } else if (!authorized && selectedPermissions.contains(Permission.MANAGE_SECURITY) &&
- permission != Permission.MANAGE_SECURITY) {
- String messageString = MSG.view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection(permissionDisplayName);
+ } else if (!authorized && selectedPermissions.contains(Permission.MANAGE_SECURITY)
+ && permission != Permission.MANAGE_SECURITY) {
+ String messageString = MSG
+ .view_adminRoles_permissions_illegalDeselectionDueToManageSecuritySelection(permissionDisplayName);
handleIllegalPermissionSelection(event, messageString);
- } else if (!authorized && selectedPermissions.contains(Permission.MANAGE_INVENTORY) &&
- permission.getTarget() == Permission.Target.RESOURCE) {
- String messageString = MSG.view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection(permissionDisplayName);
+ } else if (!authorized && selectedPermissions.contains(Permission.MANAGE_INVENTORY)
+ && permission.getTarget() == Permission.Target.RESOURCE) {
+ String messageString = MSG
+ .view_adminRoles_permissions_illegalDeselectionDueToManageInventorySelection(permissionDisplayName);
handleIllegalPermissionSelection(event, messageString);
- } else if (!authorized && selectedPermissions.contains(Permission.CONFIGURE_WRITE) &&
- permission == Permission.CONFIGURE_READ) {
- String messageString = MSG.view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection(permissionDisplayName);
+ } else if (!authorized && selectedPermissions.contains(Permission.CONFIGURE_WRITE)
+ && permission == Permission.CONFIGURE_READ) {
+ String messageString = MSG
+ .view_adminRoles_permissions_illegalDeselectionDueToCorrespondingWritePermSelection(permissionDisplayName);
handleIllegalPermissionSelection(event, messageString);
} else {
updatePermissions(authorized, permission);
@@ -359,7 +349,7 @@ public class PermissionsEditor extends LocatableVStack {
PermissionsEditor.this.roleEditView.onItemChanged();
}
}
- });
+ });
}
return authorizedField;
@@ -394,7 +384,7 @@ public class PermissionsEditor extends LocatableVStack {
messageString = MSG.view_adminRoles_permissions_autoselecting_configureWrite_implied();
redrawRequired = true;
}
- }
+ }
} else {
this.selectedPermissions.remove(permission);
}
@@ -413,7 +403,7 @@ public class PermissionsEditor extends LocatableVStack {
}
private ListGridRecord createGlobalPermissionRecord(String displayName, String icon, Permission globalPermission,
- String description) {
+ String description) {
ListGridRecord record = new ListGridRecord();
record.setAttribute("displayName", displayName);
record.setAttribute("icon", icon);
@@ -425,8 +415,7 @@ public class PermissionsEditor extends LocatableVStack {
}
private ListGridRecord createResourcePermissionRecord(String displayName, String icon, Permission readPermission,
- String readDescription, Permission writePermission,
- String writeDescription) {
+ String readDescription, Permission writePermission, String writeDescription) {
ListGridRecord record = new ListGridRecord();
record.setAttribute("displayName", displayName);
record.setAttribute("icon", icon);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java
index 3b236c8..432d9b3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationEditView.java
@@ -113,29 +113,30 @@ public class DriftConfigurationEditView extends LocatableVLayout implements Prop
removeMember(editor);
}
- GWTServiceLookup.getConfigurationService().getConfiguration(driftConfigId, new AsyncCallback<Configuration>() {
- @Override
- public void onSuccess(final Configuration result) {
-
- editor = new ConfigurationEditor(extendLocatorId("Editor"), DriftConfigurationDefinition.getInstance(),
- result);
- editor.setOverflow(Overflow.AUTO);
- editor.addPropertyValueChangeListener(DriftConfigurationEditView.this);
- editor.setReadOnly(!hasWriteAccess);
- addMember(editor);
-
- saveButton.disable();
- buttonbar.setVisible(true);
- markForRedraw();
- refreshing = false;
- }
+ GWTServiceLookup.getDriftService().getDriftConfiguration(context, driftConfigId,
+ new AsyncCallback<DriftConfiguration>() {
+ @Override
+ public void onSuccess(final DriftConfiguration result) {
+
+ editor = new ConfigurationEditor(extendLocatorId("Editor"), DriftConfigurationDefinition
+ .getInstance(), result.getConfiguration());
+ editor.setOverflow(Overflow.AUTO);
+ editor.addPropertyValueChangeListener(DriftConfigurationEditView.this);
+ editor.setReadOnly(!hasWriteAccess);
+ addMember(editor);
+
+ saveButton.disable();
+ buttonbar.setVisible(true);
+ markForRedraw();
+ refreshing = false;
+ }
- @Override
- public void onFailure(Throwable caught) {
- refreshing = false;
- CoreGUI.getErrorHandler().handleError("Failed to load configuration.", caught);
- }
- });
+ @Override
+ public void onFailure(Throwable caught) {
+ refreshing = false;
+ CoreGUI.getErrorHandler().handleError("Failed to load configuration.", caught);
+ }
+ });
}
private void save() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
index 13e5c73..b217d5b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/DriftConfigurationView.java
@@ -43,6 +43,7 @@ import org.rhq.enterprise.gui.coregui.client.components.table.TableActionEnablem
import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
import org.rhq.enterprise.gui.coregui.client.components.table.TimestampCellFormatter;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.drift.wizard.DriftAddConfigWizard;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -149,9 +150,7 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
addTableAction("Add", MSG.common_button_add(), null, new TableAction() {
public boolean isEnabled(ListGridRecord[] selection) {
- ListGrid grid = getListGrid();
- ResultSet resultSet = (null != grid) ? grid.getResultSet() : null;
- return (hasWriteAccess && grid != null && resultSet != null && !resultSet.isEmpty());
+ return hasWriteAccess;
}
public void executeAction(ListGridRecord[] selection, Object actionValue) {
@@ -181,7 +180,7 @@ public class DriftConfigurationView extends TableSection<DriftConfigurationDataS
}
void add() {
- // TODO: kick off wizard to add new drift config
+ DriftAddConfigWizard.showWizard(context);
}
void delete(ListGridRecord[] records) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java
new file mode 100644
index 0000000..0b6bca4
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/AbstractDriftAddConfigWizard.java
@@ -0,0 +1,105 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift.wizard;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardView;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public abstract class AbstractDriftAddConfigWizard extends AbstractWizard {
+
+ private EntityContext context;
+ private ResourceType type;
+
+ private String newConfigName;
+ private String newConfigInterval;
+ private Configuration newStartingConfiguration;
+ private Configuration newDriftConfiguration;
+
+ private WizardView view;
+
+ public AbstractDriftAddConfigWizard(final EntityContext context, ResourceType type) {
+ this.context = context;
+ assert context != null;
+
+ this.type = type;
+ assert type != null;
+ }
+
+ public String getSubtitle() {
+ return null;
+ }
+
+ abstract public void execute();
+
+ public void display() {
+ view = new WizardView(this);
+ view.displayDialog();
+ }
+
+ public EntityContext getEntityContext() {
+ return context;
+ }
+
+ public ResourceType getType() {
+ return type;
+ }
+
+ public String getNewConfigName() {
+ return newConfigName;
+ }
+
+ public void setNewConfigName(String newConfigName) {
+ this.newConfigName = newConfigName;
+ }
+
+ public String getNewConfigInterval() {
+ return newConfigInterval;
+ }
+
+ public void setNewConfigInterval(String newConfigInterval) {
+ this.newConfigInterval = newConfigInterval;
+ }
+
+ public Configuration getNewStartingConfiguration() {
+ return newStartingConfiguration;
+ }
+
+ public void setNewStartingConfiguration(Configuration newStartingConfiguration) {
+ this.newStartingConfiguration = newStartingConfiguration;
+ }
+
+ public Configuration getNewDriftConfiguration() {
+ return newDriftConfiguration;
+ }
+
+ public void setNewConfiguration(Configuration newDriftConfiguration) {
+ this.newDriftConfiguration = newDriftConfiguration;
+ }
+
+ public void cancel() {
+ // nothing to do
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java
new file mode 100644
index 0000000..4fcb61f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizard.java
@@ -0,0 +1,125 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift.wizard;
+
+import java.util.ArrayList;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import org.rhq.core.domain.common.EntityContext;
+import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.ResourceTypeCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class DriftAddConfigWizard extends AbstractDriftAddConfigWizard {
+
+ public DriftAddConfigWizard(EntityContext context, ResourceType type) {
+
+ super(context, type);
+
+ final ArrayList<WizardStep> steps = new ArrayList<WizardStep>();
+
+ steps.add(new DriftAddConfigWizardInfoStep(DriftAddConfigWizard.this));
+ steps.add(new DriftAddConfigWizardConfigStep(DriftAddConfigWizard.this));
+
+ setSteps(steps);
+ }
+
+ public String getWindowTitle() {
+ return MSG.view_drift_wizard_addConfig_windowTitle();
+ }
+
+ public String getTitle() {
+ return MSG.view_drift_wizard_addConfig_title(getType().getName());
+ }
+
+ public String getSubtitle() {
+ return null;
+ }
+
+ public void execute() {
+ // TODO
+ }
+
+ public static void showWizard(final EntityContext context) {
+ assert context != null;
+
+ switch (context.getType()) {
+ case Resource:
+ ResourceCriteria rc = new ResourceCriteria();
+ rc.addFilterId(context.getResourceId());
+ rc.fetchResourceType(true);
+ GWTServiceLookup.getResourceService().findResourcesByCriteria(rc, new AsyncCallback<PageList<Resource>>() {
+ public void onSuccess(PageList<Resource> result) {
+ if (result.isEmpty()) {
+ throw new IllegalArgumentException("Entity not found [" + context + "]");
+ }
+
+ final Resource resource = result.get(0);
+
+ // bypass type cache because this is infrequent an we don't need to cache the
+ // drift config templates
+ ResourceTypeCriteria rtc = new ResourceTypeCriteria();
+ rtc.addFilterId(resource.getResourceType().getId());
+ rtc.fetchDriftConfigurationTemplates(true);
+ GWTServiceLookup.getResourceTypeGWTService().findResourceTypesByCriteria(rtc,
+ new AsyncCallback<PageList<ResourceType>>() {
+ public void onSuccess(PageList<ResourceType> result) {
+ if (result.isEmpty()) {
+ throw new IllegalArgumentException("Resource Type not found ["
+ + resource.getResourceType().getId() + "]");
+ }
+
+ DriftAddConfigWizard wizard = new DriftAddConfigWizard(context, result.get(0));
+ wizard.startWizard();
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.widget_typeTree_loadFail(), caught);
+ }
+ });
+
+ }
+
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_inventory_resources_loadFailed(), caught);
+ }
+ });
+
+ break;
+
+ default:
+ throw new IllegalArgumentException("Entity Context Type not supported [" + context + "]");
+ }
+ }
+
+ @Override
+ public void cancel() {
+ super.cancel();
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardConfigStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardConfigStep.java
new file mode 100644
index 0000000..0d8b6e0
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardConfigStep.java
@@ -0,0 +1,72 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift.wizard;
+
+import com.smartgwt.client.widgets.Canvas;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class DriftAddConfigWizardConfigStep extends AbstractWizardStep {
+
+ private LocatableVLayout vLayout;
+ private ConfigurationEditor editor;
+ AbstractDriftAddConfigWizard wizard;
+
+ public DriftAddConfigWizardConfigStep(AbstractDriftAddConfigWizard wizard) {
+ this.wizard = wizard;
+ }
+
+ public Canvas getCanvas(Locatable parent) {
+ // This VLayout isn't really necessary at the moment, but provides for easier expansion if we add more items
+ if (vLayout == null) {
+ String locatorId = (null == parent) ? "DriftConfig" : parent.extendLocatorId("DriftConfig");
+ vLayout = new LocatableVLayout(locatorId);
+
+ ConfigurationDefinition def = DriftConfigurationDefinition.getInstance();
+ Configuration startingConfig = wizard.getNewStartingConfiguration();
+ editor = new ConfigurationEditor(vLayout.extendLocatorId("Editor"), def, startingConfig);
+ vLayout.addMember(editor);
+ }
+
+ return vLayout;
+ }
+
+ public boolean nextPage() {
+ if (editor != null && editor.validate()) {
+ wizard.setNewConfiguration(editor.getConfiguration());
+ wizard.execute();
+ return true;
+ }
+
+ return false;
+ }
+
+ public String getName() {
+ return MSG.widget_resourceFactoryWizard_editConfigStepName();
+ }
+}
\ No newline at end of file
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java
new file mode 100644
index 0000000..2d0932b
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/drift/wizard/DriftAddConfigWizardInfoStep.java
@@ -0,0 +1,149 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.drift.wizard;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.TitleOrientation;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationTemplate;
+import org.rhq.core.domain.drift.DriftConfigurationDefinition;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
+import org.rhq.enterprise.gui.coregui.client.util.FormUtility;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.Locatable;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * @author Jay Shaughnessy
+ */
+public class DriftAddConfigWizardInfoStep extends AbstractWizardStep {
+
+ private LocatableDynamicForm form;
+ private AbstractDriftAddConfigWizard wizard;
+ private Map<String, ConfigurationTemplate> templates;
+
+ public DriftAddConfigWizardInfoStep(AbstractDriftAddConfigWizard wizard) {
+ this.wizard = wizard;
+ }
+
+ public Canvas getCanvas(Locatable parent) {
+ if (form == null) {
+
+ if (parent != null) {
+ form = new LocatableDynamicForm(parent.extendLocatorId("DriftAddConfigInfo"));
+ } else {
+ form = new LocatableDynamicForm("DriftAddConfigInfo");
+ }
+ form.setNumCols(1);
+ List<FormItem> formItems = new ArrayList<FormItem>(2);
+
+ TextItem nameItem = new TextItem("configName", MSG.view_drift_wizard_addConfig_namePrompt());
+ nameItem.setRequired(true);
+ nameItem.setTitleOrientation(TitleOrientation.TOP);
+ nameItem.setAlign(Alignment.LEFT);
+ nameItem.setWidth(300);
+ FormUtility.addContextualHelp(nameItem, MSG.view_drift_wizard_addConfig_nameHelp());
+
+ nameItem.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ Object value = event.getValue();
+ if (value == null) {
+ value = "";
+ }
+ wizard.setNewConfigName(value.toString());
+ }
+ });
+ formItems.add(nameItem);
+
+ SelectItem templateSelect = new SelectItem("template", MSG.view_drift_wizard_addConfig_templatePrompt());
+ templateSelect.setTitleOrientation(TitleOrientation.TOP);
+ templateSelect.setAlign(Alignment.LEFT);
+ templateSelect.setWidth(300);
+ templateSelect.setRequired(true);
+ FormUtility.addContextualHelp(templateSelect, MSG.view_drift_wizard_addConfig_templateHelp());
+
+ Set<ConfigurationTemplate> templates = wizard.getType().getDriftConfigurationTemplates();
+ final HashMap<String, ConfigurationTemplate> templatesMap = new HashMap<String, ConfigurationTemplate>(
+ templates.size() + 1);
+ if (!templates.isEmpty()) {
+ for (ConfigurationTemplate template : templates) {
+ templatesMap.put(template.getName(), template);
+ }
+ } else {
+ // TODO this should throw an error as there should be at least one template (can remove the +1 sizing above when changing)
+ // throw new IllegalStateException( "At least one srift configuration template should exist for the resource type" );
+ ConfigurationTemplate test = new ConfigurationTemplate("Test", "Test");
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("name", "Test"));
+ config.put(new PropertySimple("basedir", "/TestDir"));
+ config.put(new PropertySimple("interval", "1200"));
+ test.setConfiguration(config);
+ test.setConfigurationDefinition(DriftConfigurationDefinition.getInstance());
+ templatesMap.put("TestOnly", test);
+ }
+
+ templateSelect.setValueMap(templatesMap.keySet().toArray(new String[templatesMap.size()]));
+ templateSelect.addChangedHandler(new ChangedHandler() {
+ public void onChanged(ChangedEvent event) {
+ Object value = event.getValue();
+ if (value == null) {
+ value = "";
+ }
+ wizard.setNewStartingConfiguration(templatesMap.get(value).createConfiguration());
+ }
+ });
+
+ formItems.add(templateSelect);
+
+ form.setItems(formItems.toArray(new FormItem[formItems.size()]));
+ }
+
+ return form;
+ }
+
+ public boolean nextPage() {
+ return form.validate();
+ }
+
+ public String getName() {
+ return MSG.view_drift_wizard_addConfig_infoStepName();
+ }
+
+ public String getConfigName() {
+ return form.getValueAsString("configName");
+ }
+
+ public Configuration getStartingConfiguration() {
+ String template = form.getValueAsString("template");
+ return templates.get(template).createConfiguration();
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
index 5a649fc..5feab0a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/ConfigurationGWTService.java
@@ -88,7 +88,5 @@ public interface ConfigurationGWTService extends RemoteService {
void deleteGroupResourceConfigurationUpdate(Integer groupId, Integer[] groupResourceConfigUpdateIds)
throws RuntimeException;
- Configuration getConfiguration(int configurationId);
-
ConfigurationDefinition getOptionValuesForConfigDefinition(ConfigurationDefinition definition);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
index 56f855f..b72f9cc 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/DriftGWTService.java
@@ -104,6 +104,16 @@ public interface DriftGWTService extends RemoteService {
PageList<Drift> findDriftsByCriteria(DriftCriteria criteria) throws RuntimeException;
/**
+ * Get the specified drift configuration for the specified context.
+ *
+ * @param entityContext
+ * @param driftConfigId
+ * @return
+ * @throws RuntimeException
+ */
+ DriftConfiguration getDriftConfiguration(EntityContext entityContext, int driftConfigId) throws RuntimeException;
+
+ /**
* Update the provided driftConfig (identified by name) on the specified EntityContext. If it exists it will be replaced. If not it will
* be added. Agents, if available, will be notified of the change.
*
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
index 77652ed..04bfdcb 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/ConfigurationGWTServiceImpl.java
@@ -48,7 +48,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
throws RuntimeException {
try {
configurationManager.purgeResourceConfigurationUpdates(getSessionSubject(), configUpdateIds,
- purgeInProgress);
+ purgeInProgress);
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
@@ -87,7 +87,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
public PluginConfigurationUpdate getLatestPluginConfigurationUpdate(int resourceId) throws RuntimeException {
try {
PluginConfigurationUpdate update = configurationManager.getLatestPluginConfigurationUpdate(
- getSessionSubject(), resourceId);
+ getSessionSubject(), resourceId);
return SerialUtility.prepare(update, "ConfigurationService.getLatestPluginConfigurationUpdate");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
@@ -108,7 +108,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
public ConfigurationDefinition getPluginConfigurationDefinition(int resourceTypeId) throws RuntimeException {
try {
ConfigurationDefinition definition = configurationManager.getPluginConfigurationDefinitionForResourceType(
- getSessionSubject(), resourceTypeId);
+ getSessionSubject(), resourceTypeId);
return SerialUtility.prepare(definition, "ConfigurationService.getPluginConfigDefinition");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
@@ -142,7 +142,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
Long endDate, boolean suppressOldest, PageControl pc) throws RuntimeException {
try {
PageList<ResourceConfigurationUpdate> updates = configurationManager.findResourceConfigurationUpdates(
- getSessionSubject(), resourceId, beginDate, endDate, suppressOldest, pc);
+ getSessionSubject(), resourceId, beginDate, endDate, suppressOldest, pc);
if (!updates.isEmpty()) {
List<Resource> resources = new ArrayList<Resource>(updates.size());
for (ResourceConfigurationUpdate update : updates) {
@@ -165,7 +165,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
throws RuntimeException {
try {
ResourceConfigurationUpdate update = configurationManager.updateResourceConfiguration(getSessionSubject(),
- resourceId, configuration);
+ resourceId, configuration);
return SerialUtility.prepare(update, "ConfigurationService.updateResourceConfiguration");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
@@ -177,7 +177,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
throws RuntimeException {
try {
PluginConfigurationUpdate update = configurationManager.updatePluginConfiguration(getSessionSubject(),
- resourceId, configuration);
+ resourceId, configuration);
return SerialUtility.prepare(update, "ConfigurationService.updatePluginConfiguration");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
@@ -323,7 +323,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
try {
Map<Integer, Configuration> configurations = convertToMap(pluginConfigurations);
this.configurationManager.scheduleGroupPluginConfigurationUpdate(getSessionSubject(), groupId,
- configurations);
+ configurations);
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
@@ -334,7 +334,7 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
throws RuntimeException {
try {
this.configurationManager.deleteGroupPluginConfigurationUpdates(getSessionSubject(), groupId,
- groupPluginConfigUpdateIds);
+ groupPluginConfigUpdateIds);
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
@@ -345,18 +345,19 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
throws RuntimeException {
try {
this.configurationManager.deleteGroupResourceConfigurationUpdates(getSessionSubject(), groupId,
- groupResourceConfigUpdateIds);
+ groupResourceConfigUpdateIds);
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
}
@Override
- public ConfigurationDefinition getOptionValuesForConfigDefinition(
- ConfigurationDefinition definition) throws RuntimeException {
+ public ConfigurationDefinition getOptionValuesForConfigDefinition(ConfigurationDefinition definition)
+ throws RuntimeException {
try {
- ConfigurationDefinition def = configurationManager.getOptionsForConfigurationDefinition(getSessionSubject(), definition);
- return SerialUtility.prepare(def,"ConfigurationService.getOptionValuesForPropertySimple");
+ ConfigurationDefinition def = configurationManager.getOptionsForConfigurationDefinition(
+ getSessionSubject(), definition);
+ return SerialUtility.prepare(def, "ConfigurationService.getOptionValuesForPropertySimple");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
@@ -376,14 +377,4 @@ public class ConfigurationGWTServiceImpl extends AbstractGWTServiceImpl implemen
}
}
- @Override
- public Configuration getConfiguration(int configurationId) throws RuntimeException {
- try {
- Configuration configuration = configurationManager.getConfiguration(getSessionSubject(), configurationId);
- return SerialUtility.prepare(configuration, "ConfigurationService.getConfiguration");
- } catch (Throwable t) {
- throw getExceptionToThrowToClient(t);
- }
- }
-
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
index 714a68a..92f12cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/DriftGWTServiceImpl.java
@@ -105,6 +105,18 @@ public class DriftGWTServiceImpl extends AbstractGWTServiceImpl implements Drift
}
@Override
+ public DriftConfiguration getDriftConfiguration(EntityContext entityContext, int driftConfigId)
+ throws RuntimeException {
+ try {
+ DriftConfiguration driftConfig = driftManager.getDriftConfiguration(getSessionSubject(), entityContext,
+ driftConfigId);
+ return SerialUtility.prepare(driftConfig, "DriftService.getDriftConfiguration");
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
public void updateDriftConfiguration(EntityContext entityContext, DriftConfiguration driftConfig) {
try {
this.driftManager.updateDriftConfiguration(getSessionSubject(), entityContext, driftConfig);
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 6207048..d171188 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -432,6 +432,7 @@ view_adminRoles_permissions_permReadDesc_deleteChildResources = (IMPLIED) view c
view_adminRoles_permissions_permReadDesc_inventory = (IMPLIED) view Resource properties (name, description, version, etc.), connection settings, and connection settings history
view_adminRoles_permissions_permReadDesc_manageAlerts = (IMPLIED) view alert definitions and alert history
view_adminRoles_permissions_permReadDesc_manageContent = (IMPLIED) view installed and available packages; view package installation history
+view_adminRoles_permissions_permReadDesc_manageDrift = (IMPLIED) view drift configurations and drift history
view_adminRoles_permissions_permReadDesc_manageEvents = (IMPLIED) view events
view_adminRoles_permissions_permReadDesc_manageMeasurements = (IMPLIED) view metric data and collection schedules
view_adminRoles_permissions_permWriteDesc_configure = update Resource configuration; delete Resource configuration revision history items
@@ -441,6 +442,7 @@ view_adminRoles_permissions_permWriteDesc_deleteChildResources = uninventory res
view_adminRoles_permissions_permWriteDesc_inventory = update Resource name, version, description, and connection settings; delete connection settings history items
view_adminRoles_permissions_permWriteDesc_manageAlerts = create, update, and delete alert definitions; acknowledge and delete alert history items
view_adminRoles_permissions_permWriteDesc_manageContent = subscribe to content sources; install and uninstall packages
+view_adminRoles_permissions_permWriteDesc_manageDrift = create, update, and delete drift configurations; acknowledge and delete drift history items
view_adminRoles_permissions_permWriteDesc_manageEvents = delete events
view_adminRoles_permissions_permWriteDesc_manageMeasurements = update metric collection schedules
view_adminRoles_permissions_perm_configure = Configure
@@ -451,6 +453,7 @@ view_adminRoles_permissions_perm_inventory = Inventory
view_adminRoles_permissions_perm_manageAlerts = Manage Alerts
view_adminRoles_permissions_perm_manageBundles = Manage Bundles
view_adminRoles_permissions_perm_manageContent = Manage Content
+view_adminRoles_permissions_perm_manageDrift = Manage Drift
view_adminRoles_permissions_perm_manageEvents = Manage Events
view_adminRoles_permissions_perm_manageInventory = Manage Inventory
view_adminRoles_permissions_perm_manageMeasurements = Manage Measurements
@@ -1123,6 +1126,13 @@ view_drift_table_newFile = New File
view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
view_drift_table_resourceHistory = Resource Drift History
+view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
+view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
+view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
+view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
+view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
+view_drift_wizard_addConfig_windowTitle = Drift Add Configuration Wizard
view_dynagroup_children = DynaGroup Children
view_dynagroup_compatible = Compatible
view_dynagroup_definitionAlreadyExists = A group definition already exists with this name
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index eb042a5..52389a9 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -398,6 +398,7 @@ view_adminRoles_permissions_permReadDesc_deleteChildResources = (IMPLIZIT) Ansic
view_adminRoles_permissions_permReadDesc_inventory = (IMPLIZIT) Ansehen der Eigenschaft einer Ressource (Name, Beschreibung, Version etc.), Verbindungseinstellungen, Verlauf derselben
view_adminRoles_permissions_permReadDesc_manageAlerts = (IMPLIZIT) Ansehen von Alarm-Definitionen und ausgelösten Alarmen
view_adminRoles_permissions_permReadDesc_manageContent = (IMPLIZIT) Installierte und verfügbare Pakete ansehen; Verlauf der Installation von Paketen ansehen
+##view_adminRoles_permissions_permReadDesc_manageDrift = (IMPLIED) view drift configurations and drift history
view_adminRoles_permissions_permReadDesc_manageEvents = (IMPLIZIT) Ereignisse ansehen
view_adminRoles_permissions_permReadDesc_manageMeasurements = (IMPLIZIT) Monitoringdaten und -zeitplan ansehen
view_adminRoles_permissions_permWriteDesc_configure = Bearbeiten der Ressourcen-Konfiguration; Löschen einzelner Einträge im Verlauf der Ressourcen-Konfiguration
@@ -407,6 +408,7 @@ view_adminRoles_permissions_permWriteDesc_deleteChildResources = Löschen von Ki
view_adminRoles_permissions_permWriteDesc_inventory = Aktualisieren von Ressourcename, Beschreibung und Verbindungseinstellungen. Löschen einzelner Einträge des Verlaufs der Verbindungseinstellungen.
view_adminRoles_permissions_permWriteDesc_manageAlerts = Anlegen, Bearbeiten und Löschen von Alarm-Definitionen. Bestätigen und Löschen von ausgelösten Alarmen.
view_adminRoles_permissions_permWriteDesc_manageContent = Abonnieren von Content-Quellen; Pakete installieren und deinstallieren
+##view_adminRoles_permissions_permWriteDesc_manageDrift = create, update, and delete alert definitions; acknowledge and delete alert history items
view_adminRoles_permissions_permWriteDesc_manageEvents = Ereignisse löschen
view_adminRoles_permissions_permWriteDesc_manageMeasurements = Zeitplan für das Monitoring bearbeiten
view_adminRoles_permissions_perm_configure = Konfiguration
@@ -417,6 +419,7 @@ view_adminRoles_permissions_perm_inventory = Inventar
view_adminRoles_permissions_perm_manageAlerts = Alarme verwalten
view_adminRoles_permissions_perm_manageBundles = Bundles verwalten
view_adminRoles_permissions_perm_manageContent = Content verwalten
+##view_adminRoles_permissions_perm_manageDrift = Manage Drift
view_adminRoles_permissions_perm_manageEvents = Ereignisse verwalten
view_adminRoles_permissions_perm_manageInventory = Inventar verwalten
view_adminRoles_permissions_perm_manageMeasurements = Monitoring verwalten
@@ -947,6 +950,13 @@ view_dashboards_title = Dashboard
##view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
+##view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
+##view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
+##view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+##view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
+##view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
+##view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
+##view_drift_wizard_addConfig_windowTitle = Drift Add Configuration Wizard
view_dynagroup_children = DynaGroup Children~
view_dynagroup_compatible = Kompatible
view_dynagroup_definitionAlreadyExists = A group definition already exists with this name~
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index d814f25..134a22f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -433,6 +433,7 @@ view_adminRoles_permissions_permReadDesc_deleteChildResources = (IMPLIED) view c
view_adminRoles_permissions_permReadDesc_inventory = (IMPLIED) view Resource properties (name, description, version, etc.), connection settings, and connection settings history
view_adminRoles_permissions_permReadDesc_manageAlerts = (IMPLIED) view alert definitions and alert history
view_adminRoles_permissions_permReadDesc_manageContent = (IMPLIED) view installed and available packages; view package installation history
+##view_adminRoles_permissions_permReadDesc_manageDrift = (IMPLIED) view drift configurations and drift history
view_adminRoles_permissions_permReadDesc_manageEvents = (IMPLIED) view events
view_adminRoles_permissions_permReadDesc_manageMeasurements = (IMPLIED) view metric data and collection schedules
view_adminRoles_permissions_permWriteDesc_configure = update Resource configuration; delete Resource configuration revision history items
@@ -440,8 +441,9 @@ view_adminRoles_permissions_permWriteDesc_control = execute operations; delete o
view_adminRoles_permissions_permWriteDesc_createChildResources = create new child Resources (for child Resources of types that are creatable)
view_adminRoles_permissions_permWriteDesc_deleteChildResources = uninventory resources; delete Resources (for Resources of types that are deletable)
view_adminRoles_permissions_permWriteDesc_inventory = update Resource name, version, description, and connection settings; delete connection settings history items
-view_adminRoles_permissions_permWriteDesc_manageAlerts = create, update, and delete alert definitions; acknowledge and delete alert history items
+##view_adminRoles_permissions_permWriteDesc_manageAlerts = create, update, and delete alert definitions; acknowledge and delete alert history items
view_adminRoles_permissions_permWriteDesc_manageContent = subscribe to content sources; install and uninstall packages
+##view_adminRoles_permissions_permWriteDesc_manageDrift = create, update, and delete alert definitions; acknowledge and delete alert history items
view_adminRoles_permissions_permWriteDesc_manageEvents = delete events
view_adminRoles_permissions_permWriteDesc_manageMeasurements = update metric collection schedules
view_adminRoles_permissions_perm_configure = Configure
@@ -452,6 +454,7 @@ view_adminRoles_permissions_perm_inventory = Inventory
view_adminRoles_permissions_perm_manageAlerts = Manage Alerts
view_adminRoles_permissions_perm_manageBundles = Manage Bundles
view_adminRoles_permissions_perm_manageContent = Manage Content
+##view_adminRoles_permissions_perm_manageDrift = Manage Drift
view_adminRoles_permissions_perm_manageEvents = Manage Events
view_adminRoles_permissions_perm_manageInventory = Manage Inventory
view_adminRoles_permissions_perm_manageMeasurements = Manage Measurements
@@ -1124,6 +1127,13 @@ view_dashboards_title = ダッシュボード
##view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
+##view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
+##view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
+##view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+##view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
+##view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
+##view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
+##view_drift_wizard_addConfig_windowTitle = Drift Add Configuration Wizard
view_dynagroup_children = DynaGroup Children
view_dynagroup_compatible = Compatible
view_dynagroup_definitionAlreadyExists = A group definition already exists with this name
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 28585bd..88273e4 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -445,6 +445,7 @@ view_adminRoles_permissions_permReadDesc_deleteChildResources = (IMPLIED) view c
view_adminRoles_permissions_permReadDesc_inventory = (IMPLIED) view Resource properties (name, description, version, etc.), connection settings, and connection settings history
view_adminRoles_permissions_permReadDesc_manageAlerts = (IMPLIED) view alert definitions and alert history
view_adminRoles_permissions_permReadDesc_manageContent = (IMPLIED) view installed and available packages; view package installation history
+##view_adminRoles_permissions_permReadDesc_manageDrift = (IMPLIED) view drift configurations and drift history
view_adminRoles_permissions_permReadDesc_manageEvents = (IMPLIED) view events
view_adminRoles_permissions_permReadDesc_manageMeasurements = (IMPLIED) view metric data and collection schedules
view_adminRoles_permissions_permWriteDesc_configure = update Resource configuration; delete Resource configuration revision history items
@@ -452,8 +453,9 @@ view_adminRoles_permissions_permWriteDesc_control = execute operations; delete o
view_adminRoles_permissions_permWriteDesc_createChildResources = create new child Resources (for child Resources of types that are creatable)
view_adminRoles_permissions_permWriteDesc_deleteChildResources = uninventory resources; delete Resources (for Resources of types that are deletable)
view_adminRoles_permissions_permWriteDesc_inventory = update Resource name, version, description, and connection settings; delete connection settings history items
-view_adminRoles_permissions_permWriteDesc_manageAlerts = create, update, and delete alert definitions; acknowledge and delete alert history items
+##view_adminRoles_permissions_permWriteDesc_manageAlerts = create, update, and delete alert definitions; acknowledge and delete alert history items
view_adminRoles_permissions_permWriteDesc_manageContent = subscribe to content sources; install and uninstall packages
+##view_adminRoles_permissions_permWriteDesc_manageDrift = create, update, and delete alert definitions; acknowledge and delete alert history items
view_adminRoles_permissions_permWriteDesc_manageEvents = delete events
view_adminRoles_permissions_permWriteDesc_manageMeasurements = update metric collection schedules
view_adminRoles_permissions_perm_configure = Configurar
@@ -464,6 +466,7 @@ view_adminRoles_permissions_perm_inventory = Invent\u00E1rio
view_adminRoles_permissions_perm_manageAlerts = Gerenciar Alertas
view_adminRoles_permissions_perm_manageBundles = Gerenciar Bundles
view_adminRoles_permissions_perm_manageContent = Gerenciar Conte\u00FAdo
+##view_adminRoles_permissions_perm_manageDrift = Manage Drift
view_adminRoles_permissions_perm_manageEvents = Gerenciar Eventos
view_adminRoles_permissions_perm_manageInventory = Gerenciar Invent\u00E1rio
view_adminRoles_permissions_perm_manageMeasurements = Gerenciar M\u00E9tricas
@@ -1147,6 +1150,13 @@ view_dashboards_title = Dashboard~
##view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
+##view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
+##view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
+##view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+##view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
+##view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
+##view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
+##view_drift_wizard_addConfig_windowTitle = Drift Add Configuration Wizard
view_dynagroup_children = DynaGroup Children~
view_dynagroup_compatible = Compatible
view_dynagroup_definitionAlreadyExists = A group definition already exists with this name~
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index b939c99..9ff3634 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -432,6 +432,7 @@ view_adminRoles_permissions_permReadDesc_deleteChildResources = (IMPLIED) \u67E5
view_adminRoles_permissions_permReadDesc_inventory = (IMPLIED) view Resource properties (name, description, version, etc.), connection settings, and connection settings history
view_adminRoles_permissions_permReadDesc_manageAlerts = (IMPLIED) \u67E5\u770B\u544A\u8B66\u5B9A\u4E49\u548C\u544A\u8B66\u5386\u53F2
view_adminRoles_permissions_permReadDesc_manageContent = (IMPLIED) \u67E5\u770B\u5B89\u88C5\u7684\u548C\u53EF\u7528\u7684\u5305; \u67E5\u770B\u5305\u5B89\u88C5\u5386\u53F2
+##view_adminRoles_permissions_permReadDesc_manageDrift = (IMPLIED) view drift configurations and drift history
view_adminRoles_permissions_permReadDesc_manageEvents = (IMPLIED)\u67E5\u770B\u4E8B\u4EF6
view_adminRoles_permissions_permReadDesc_manageMeasurements = (IMPLIED) view metric data and collection schedules
view_adminRoles_permissions_permWriteDesc_configure = \u66F4\u65B0\u8D44\u6E90\u914D\u7F6E; delete Resource configuration revision history items
@@ -439,8 +440,9 @@ view_adminRoles_permissions_permWriteDesc_control = \u6267\u884C\u64CD\u4F5C; \u
view_adminRoles_permissions_permWriteDesc_createChildResources = \u521B\u5EFA\u65B0\u7684\u5B50\u8D44\u6E90 (for child Resources of types that are creatable)
view_adminRoles_permissions_permWriteDesc_deleteChildResources = uninventory resources; delete Resources (for Resources of types that are deletable)
view_adminRoles_permissions_permWriteDesc_inventory = update Resource name, version, description, and connection settings; delete connection settings history items
-view_adminRoles_permissions_permWriteDesc_manageAlerts = create, update, and delete alert definitions; acknowledge and delete alert history items
+##view_adminRoles_permissions_permWriteDesc_manageAlerts = create, update, and delete alert definitions; acknowledge and delete alert history items
view_adminRoles_permissions_permWriteDesc_manageContent = subscribe to content sources; install and uninstall packages
+##view_adminRoles_permissions_permWriteDesc_manageDrift = create, update, and delete alert definitions; acknowledge and delete alert history items
view_adminRoles_permissions_permWriteDesc_manageEvents = \u5220\u9664\u4E8B\u4EF6
view_adminRoles_permissions_permWriteDesc_manageMeasurements = update metric collection schedules
view_adminRoles_permissions_perm_configure = \u914D\u7F6E
@@ -451,6 +453,7 @@ view_adminRoles_permissions_perm_inventory = \u6E05\u5355
view_adminRoles_permissions_perm_manageAlerts = \u7BA1\u7406\u544A\u8B66
view_adminRoles_permissions_perm_manageBundles = \u7BA1\u7406Bundles
view_adminRoles_permissions_perm_manageContent = \u7BA1\u7406Content
+##view_adminRoles_permissions_perm_manageDrift = Manage Drift
view_adminRoles_permissions_perm_manageEvents = \u7BA1\u7406\u4E8B\u4EF6
view_adminRoles_permissions_perm_manageInventory = \u7BA1\u7406\u6E05\u5355
view_adminRoles_permissions_perm_manageMeasurements = \u7BA1\u7406\u6307\u6807
@@ -1123,6 +1126,13 @@ view_dashboards_title = \u7EDF\u8BA1\u8868\u76D8
##view_drift_table_oldFile = Old File
view_drift_table_resourceConfig = Resource Drift Configuration
##view_drift_table_resourceHistory = Resource Drift History
+##view_drift_wizard_addConfig_infoStepName = Provide Drift Detection Information
+##view_drift_wizard_addConfig_nameHelp = A textual name briefly describing the purpose of this drift detection configuration. Drift configuration names must be unique for a resource.
+##view_drift_wizard_addConfig_namePrompt = New Drift Configuration Name
+##view_drift_wizard_addConfig_templateHelp = Each drift configuration describes a set of files for which drift detection can be performed. The configuration can be enabled and disabled, defines the detection interval, and specifies a base directory and optional file filters. For each resource type offering drift detection there will be one or more predefined templates to use a starting configuration, which can then be edited.
+##view_drift_wizard_addConfig_templatePrompt = Drift Configuration Templates
+##view_drift_wizard_addConfig_title = Add Drift Configuration for Resource of Type [{0}]
+##view_drift_wizard_addConfig_windowTitle = Drift Add Configuration Wizard
view_dynagroup_children = \u5B50\u52A8\u6001\u7EC4
view_dynagroup_compatible = \u517C\u5BB9\u6027
view_dynagroup_definitionAlreadyExists = \u5DF2\u7ECF\u5B58\u5728\u4EE5\u8BE5\u540D\u79F0\u547D\u540D\u7684\u7EC4\u5B9A\u4E49
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index 089eb36..ba94b08 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -126,7 +126,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
public void storeChangeSet(final int resourceId, File changeSetZip) throws Exception {
Resource resource = entityManager.find(Resource.class, resourceId);
if (null == resource) {
- throw new IllegalArgumentException("Resource not found: " + resourceId);
+ throw new IllegalArgumentException("Resource not found [" + resourceId + "]");
}
try {
@@ -189,7 +189,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
}
} catch (Exception e) {
- String msg = "Failed to store drift changeset: " + driftChangeSet;
+ String msg = "Failed to store drift changeset [" + driftChangeSet + "]";
log.error(msg, e);
return false;
}
@@ -244,7 +244,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
DriftFileContent df = entityManager.find(DriftFileContent.class, driftFile.getHashId());
if (null == df) {
- throw new IllegalArgumentException("DriftFile not found: " + driftFile.getHashId());
+ throw new IllegalArgumentException("DriftFile not found [" + driftFile.getHashId() + "]");
}
df.setData(Hibernate.createBlob(new BufferedInputStream(data)));
df.setStatus(DriftFileStatus.LOADED);
@@ -289,7 +289,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
int resourceId = entityContext.getResourceId();
Resource resource = entityManager.find(Resource.class, resourceId);
if (null == resource) {
- throw new IllegalArgumentException("Resource not found: " + resourceId);
+ throw new IllegalArgumentException("Entity not found [" + entityContext + "]");
}
for (Iterator<Configuration> i = resource.getDriftConfigurations().iterator(); i.hasNext();) {
@@ -309,6 +309,11 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
break;
}
}
+
+ break;
+
+ default:
+ throw new IllegalArgumentException("Entity Context Type not supported [" + entityContext + "]");
}
}
@@ -319,7 +324,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
int resourceId = entityContext.getResourceId();
Resource resource = entityManager.find(Resource.class, resourceId);
if (null == resource) {
- throw new IllegalArgumentException("Resource not found: " + resourceId);
+ throw new IllegalArgumentException("Entity not found [" + entityContext + "]");
}
for (Iterator<Configuration> i = resource.getDriftConfigurations().iterator(); i.hasNext();) {
@@ -340,6 +345,11 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
} catch (Exception e) {
log.warn(" Unable to inform agent of unscheduled drift detection [" + driftConfig + "]", e);
}
+
+ break;
+
+ default:
+ throw new IllegalArgumentException("Entity Context Type not supported [" + entityContext + "]");
}
}
@@ -363,6 +373,40 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
}
@Override
+ public DriftConfiguration getDriftConfiguration(Subject subject, EntityContext entityContext, int driftConfigId)
+ throws RuntimeException {
+
+ DriftConfiguration result = null;
+
+ switch (entityContext.getType()) {
+ case Resource:
+ Resource resource = entityManager.find(Resource.class, entityContext.getResourceId());
+ if (null == resource) {
+ throw new IllegalArgumentException("Entity not found [" + entityContext + "]");
+ }
+
+ for (Configuration config : resource.getDriftConfigurations()) {
+ if (config.getId() == driftConfigId) {
+ result = new DriftConfiguration(config);
+ break;
+ }
+ }
+
+ break;
+
+ default:
+ throw new IllegalArgumentException("Entity Context Type not supported [" + entityContext + "]");
+ }
+
+ if (null == result) {
+ throw new IllegalArgumentException("Drift Configuration Id [" + driftConfigId
+ + "] not found for entityContext [" + entityContext + "]");
+ }
+
+ return result;
+ }
+
+ @Override
public DriftFile getDriftFile(Subject subject, String sha256) {
DriftFile result = entityManager.find(DriftFile.class, sha256);
return result;
@@ -373,7 +417,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
Resource resource = entityManager.find(Resource.class, resourceId);
if (null == resource) {
- throw new IllegalArgumentException("Resource not found: " + resourceId);
+ throw new IllegalArgumentException("Resource not found [" + resourceId + "]");
}
AgentClient agentClient = agentManager.getAgentClient(subjectManager.getOverlord(), resourceId);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
index 708ef3b..3184e79 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerLocal.java
@@ -94,6 +94,17 @@ public interface DriftManagerLocal extends DriftManagerRemote {
PageList<Drift> findDriftsByCriteria(Subject subject, DriftCriteria criteria);
/**
+ * Get the specified drift configuration for the specified context.
+ *
+ * @param entityContext
+ * @param driftConfigId
+ * @return The drift configuration
+ * @throws RuntimeException, IllegalArgumentException if entity or driftConfig not found.
+ */
+ DriftConfiguration getDriftConfiguration(Subject subject, EntityContext entityContext, int driftConfigId)
+ throws RuntimeException;
+
+ /**
* This method stores the provided change-set file for the resource. The version will be incremented based
* on the max version of existing change-sets for the resource. The change-set will be processed generating
* requests for drift file content and/or drift instances as required.
@@ -123,6 +134,8 @@ public interface DriftManagerLocal extends DriftManagerRemote {
*/
void updateDriftConfiguration(Subject subject, EntityContext entityContext, DriftConfiguration driftConfig);
+ // TODO, the stuff below is very preliminary and will change
+
/**
* SUPPORTS DRIFT RHQ SERVER PLUGIN
* @param driftFile
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
index f4eb0b5..b88f9ae 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/resource/group/ResourceGroupManagerBean.java
@@ -1505,7 +1505,8 @@ public class ResourceGroupManagerBean implements ResourceGroupManagerLocal, Reso
+ " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 11 ), " // CONFIGURE_WRITE
+ " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 9 ), " // MANAGE_CONTENT
+ " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 6 ), " // CREATE_CHILD_RESOURCES
- + " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 5 ))"; // DELETE_RESOURCES
+ + " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 5 ), " // DELETE_RESOURCES
+ + " ( SELECT count(p) FROM %permAlias%.roles r JOIN r.subjects s JOIN r.permissions p WHERE s.id = %subjectId% AND p = 16 ))"; // MANAGE_DRIFT
compositeProjection = compositeProjection.replace("%subjectId%", String.valueOf(subject.getId()));
break;
default:
12 years, 10 months
[rhq] modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 2 +-
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 50fb5956ca8b06cc826766bd2a9d84806d79cda2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 17:30:10 2011 +0200
/domain-api got renamed to /management.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index c51f275..f2bb47f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -52,7 +52,7 @@ public class ASConnection {
public ASConnection(String host, int port) {
try {
- url = new URL("http",host,port,"/domain-api");
+ url = new URL("http",host,port,"/management");
urlString = url.toString();
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e.getMessage());
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index 80e8ea4..d876c80 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -51,7 +51,7 @@ public class ASUploadConnection {
private static final String POST_REQUEST_METHOD = "POST";
- private static final String UPLOAD_URL_PATH = "/domain-api/add-content";
+ private static final String UPLOAD_URL_PATH = "/management/add-content";
private final Log log = LogFactory.getLog(ASUploadConnection.class);
12 years, 10 months
[rhq] modules/enterprise
by snegrea
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml | 1 +
modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml | 1 +
2 files changed, 2 insertions(+)
New commits:
commit c4bc8030a89861799fc79ff1611fa7cfc0009168
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Tue Jun 28 09:58:25 2011 -0500
Attempt to correct the dbunit setup failures after a new table was added to the schema.
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
index 79ba415..290ad18 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/discovery/DiscoveryBossBeanTest.xml
@@ -10,6 +10,7 @@
mtime="123456"/>
<rhq_config_def/>
+ <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
diff --git a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
index 7e6ae2a..306297c 100644
--- a/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
+++ b/modules/enterprise/server/jar/src/test/resources/org/rhq/enterprise/server/inventory/InventoryManagerBeanTest.xml
@@ -1,5 +1,6 @@
<dataset>
<rhq_config_def/>
+ <rhq_config_pd_osrc/>
<rhq_config_prop_def/>
<rhq_conf_prop_def_enum/>
<rhq_config_prop_constr/>
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
New commits:
commit ad48deb95733f8d06dd5a1ab55a8d223bf9e78f1
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jun 28 10:53:55 2011 -0400
fixing failing test
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
index c7e14ed..997e65f 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
@@ -45,7 +45,6 @@ public class ChangeSetManagerImplTest {
@Test
public void returnReaderForRequestedChangeSet() throws Exception {
int resourceId = 1;
- DriftConfiguration drfitConfig = driftConfiguration("test-1", "server");
File resourceDir = new File(changeSetsDir, Integer.toString(resourceId));
File changeSetDir = new File(resourceDir, "test-1");
@@ -53,6 +52,9 @@ public class ChangeSetManagerImplTest {
assertTrue(changeSetDir.mkdirs(), "Failed to create change set directory: " + changeSetDir.getAbsolutePath());
List<String> changeSet = asList(
+ "test-1",
+ "server",
+ "D",
"server/conf 1",
"8f26ac3d 0 myconf.conf A"
);
12 years, 10 months
[rhq] Branch 'drift' - modules/common modules/core modules/enterprise
by John Sanda
modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java | 2 -
modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java | 12 +++++-----
modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java | 12 +++++-----
modules/core/client-api/pom.xml | 6 +++++
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/drift/DriftAgentService.java | 3 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java | 5 ----
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java | 3 +-
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java | 3 +-
8 files changed, 26 insertions(+), 20 deletions(-)
New commits:
commit a404bd5fc6ffb3cb5c9b0070f831aff20a23a8b1
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jun 28 10:32:33 2011 -0400
Refactoring ChangeSetWriterImpl to take a Headers object
Changing the args for DriftAgentService.requestDriftFiles to take a
Headers object. The headers contain the info needed to locate the drift
files on the agent.
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java
index bcf14da..25a973a8 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java
@@ -22,7 +22,7 @@ import java.io.IOException;
* <ul>
* <li>drift configuration name</li>
* <li>drift configuration base directory</li>
- * <li>flag indicating whether or not this is a coverage changeset</li>
+ * <li>change set type flag indicating whether this is a coverage or drift changeset</li>
* </ul>
* <br/>
* and where DRIFT_ENTRY has two field that are space delimited. The first is the directory path
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
index c77a54c..4244fac 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
@@ -15,19 +15,19 @@ public class ChangeSetWriterImpl implements ChangeSetWriter {
private File changeSetFile;
- public ChangeSetWriterImpl(File changeSetFile, DriftConfiguration driftConfig, DriftChangeSetCategory type)
+ public ChangeSetWriterImpl(File changeSetFile, Headers headers)
throws IOException {
this.changeSetFile = changeSetFile;
writer = new BufferedWriter(new FileWriter(this.changeSetFile));
- writeHeader(driftConfig, type);
+ writeHeaders(headers);
}
- private void writeHeader(DriftConfiguration driftConfig, DriftChangeSetCategory type) throws IOException {
- writer.write(driftConfig.getName() + "\n");
- writer.write(driftConfig.getBasedir() + "\n");
- writer.write(type.code() + "\n");
+ private void writeHeaders(Headers headers) throws IOException {
+ writer.write(headers.getDriftConfigurationName() + "\n");
+ writer.write(headers.getBasedir() + "\n");
+ writer.write(headers.getType().code() + "\n");
}
public void writeDirectoryEntry(DirectoryEntry dirEntry) throws IOException {
diff --git a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
index 0e6786a..3f4efda 100644
--- a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
+++ b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
@@ -36,9 +36,9 @@ public class ChangeSetWriterImplTest {
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithAddedFile() throws Exception {
File changeSetFile = new File(changeSetsDir, "added-file-test");
- DriftConfiguration driftConfig = driftConfiguration("added-file-test", "myresource");
+ Headers headers = new Headers("added-file-test", "myresource", COVERAGE);
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, COVERAGE);
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
addedFileEntry("myconf.conf", "a34ef6")));
@@ -62,9 +62,9 @@ public class ChangeSetWriterImplTest {
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithRemovedFile() throws Exception {
File changeSetFile = new File(changeSetsDir, "removed-file-test");
- DriftConfiguration driftConfig = driftConfiguration("removed-file-test", "myresource");
+ Headers headers = new Headers("removed-file-test", "myresource", COVERAGE);
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, COVERAGE);
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
removedFileEntry("myconf.conf", "a34ef6")));
@@ -88,9 +88,9 @@ public class ChangeSetWriterImplTest {
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithChangedFile() throws Exception {
File changeSetFile = new File(changeSetsDir, "changed-file-test");
- DriftConfiguration driftConfig = driftConfiguration("changed-file-test", "myresource");
+ Headers headers = new Headers("changed-file-test", "myresource", COVERAGE);
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, COVERAGE);
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, headers);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
changedFileEntry("myconf.conf", "a34ef6", "c2d55f")));
diff --git a/modules/core/client-api/pom.xml b/modules/core/client-api/pom.xml
index 42819ca..9fed074 100644
--- a/modules/core/client-api/pom.xml
+++ b/modules/core/client-api/pom.xml
@@ -31,6 +31,12 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-common-drift</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- TODO: This is a fix for the Javac bug requiring annotations to be
available when compiling dependent classes; it is fixed in JDK 6. -->
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/drift/DriftAgentService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/drift/DriftAgentService.java
index 3442b67..c269e5a 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/drift/DriftAgentService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/drift/DriftAgentService.java
@@ -21,6 +21,7 @@ package org.rhq.core.clientapi.agent.drift;
import java.util.List;
+import org.rhq.common.drift.Headers;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.domain.drift.DriftFile;
@@ -39,7 +40,7 @@ public interface DriftAgentService {
* @param driftFiles
* @return the results of the immediate scheduling
*/
- boolean requestDriftFiles(int resourceId, String driftConfigurationName, List<DriftFile> driftFiles);
+ boolean requestDriftFiles(int resourceId, Headers headers, List<DriftFile> driftFiles);
/**
* Execute drift detection immediately. If any drift is found, the agent will send the
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
index e88425d..089eb36 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/DriftManagerBean.java
@@ -43,8 +43,6 @@ import javax.jms.Session;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
-import com.sun.net.httpserver.Headers;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.Hibernate;
@@ -181,8 +179,7 @@ public class DriftManagerBean implements DriftManagerLocal, DriftManagerRemote {
resourceId);
DriftAgentService service = agentClient.getDriftAgentService();
try {
- if (service.requestDriftFiles(resourceId,
- reader.getHeaders().getDriftConfigurationName(), emptyDriftFiles)) {
+ if (service.requestDriftFiles(resourceId, reader.getHeaders(), emptyDriftFiles)) {
for (DriftFile driftFile : emptyDriftFiles) {
driftFile.setStatus(DriftFileStatus.REQUESTED);
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
index 58f4ba2..ba3c4ec 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/drift/DriftManagerBeanTest.java
@@ -32,6 +32,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.rhq.common.drift.Headers;
import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.clientapi.server.drift.DriftServerService;
import org.rhq.core.domain.auth.Subject;
@@ -342,7 +343,7 @@ public class DriftManagerBeanTest extends AbstractEJB3Test {
private class TestConfigService implements DriftAgentService {
@Override
- public boolean requestDriftFiles(int resourceId, String driftConfigurationName, List<DriftFile> driftFiles) {
+ public boolean requestDriftFiles(int resourceId, Headers headers, List<DriftFile> driftFiles) {
return false;
}
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
index 68b940c..8d39917 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/TestAgentClient.java
@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.rhq.common.drift.Headers;
import org.rhq.core.clientapi.agent.PluginContainerException;
import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
import org.rhq.core.clientapi.agent.bundle.BundlePurgeRequest;
@@ -330,7 +331,7 @@ public class TestAgentClient implements AgentClient, BundleAgentService, DriftAg
}
@Override
- public boolean requestDriftFiles(int resourceId, String driftConfigurationName, List<DriftFile> driftFiles) {
+ public boolean requestDriftFiles(int resourceId, Headers headers, List<DriftFile> driftFiles) {
return false;
}
12 years, 10 months
[rhq] Branch 'drift' - modules/core
by John Sanda
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java | 14 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java | 20 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 4
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java | 5
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java | 4
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 105 ----------
6 files changed, 26 insertions(+), 126 deletions(-)
New commits:
commit 79e94f05ae84b852f1dd2c1b8d2df77d34f34a28
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jun 28 10:26:05 2011 -0400
Changing DriftAgentService.requestDriftFile to take a Headers arg
The headers from the change set meta data file is what is really needed
to locate the drift files. Like the drift config, it contains the drift
config name and basedir, but it will also contain a version number that
may be needed. That version number is not stored in the drift config.
Refactoring ChangeSetManager APIs to only require what is needed for
arguments.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
index 154d2cd..06af0ae 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
@@ -5,6 +5,7 @@ import java.io.IOException;
import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetWriter;
+import org.rhq.common.drift.Headers;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
@@ -14,11 +15,12 @@ public interface ChangeSetManager {
* Locates the latest change set for the specified resource id and drift configuration.
*
* @param resourceId The id of the resource to which the change set belongs
- * @param driftConfiguration The drift configuration for which the change set was generated
+ * @param driftConfigurationName The name of the drift configuration for which the
+ * change set was generated
* @return The change set file or null if it is not found
* @throws IOException
*/
- File findChangeSet(int resourceId, DriftConfiguration driftConfiguration) throws IOException;
+ File findChangeSet(int resourceId, String driftConfigurationName) throws IOException;
/**
* Locates the latest change set for the given resource and drift configuration and
@@ -27,15 +29,15 @@ public interface ChangeSetManager {
* are required to uniquely identify a particular change set.
*
* @param resourceId The id of the resource to which the change set belongs
- * @param driftConfiguration The drift configuration for which the change set was generated
+ * @param driftConfigurationName The name of the drift configuration for which the
+ * change set was generated
* @return A ChangeSetReader that is open on the change set identified by resourceId
* and driftConfiguration. Returns null if no change set has previously been generated.
* @see ChangeSetReader
*/
- ChangeSetReader getChangeSetReader(int resourceId, DriftConfiguration driftConfiguration) throws IOException;
+ ChangeSetReader getChangeSetReader(int resourceId, String driftConfigurationName) throws IOException;
- ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration driftConfiguration,
- DriftChangeSetCategory type) throws IOException;
+ ChangeSetWriter getChangeSetWriter(int resourceId, Headers headers) throws IOException;
void addFileToChangeSet(int resourceId, DriftConfiguration driftConfiguration, File file);
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
index 33be5bb..aae887d 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
@@ -9,6 +9,7 @@ import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetReaderImpl;
import org.rhq.common.drift.ChangeSetWriter;
import org.rhq.common.drift.ChangeSetWriterImpl;
+import org.rhq.common.drift.Headers;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
@@ -23,8 +24,8 @@ public class ChangeSetManagerImpl implements ChangeSetManager {
}
@Override
- public File findChangeSet(int resourceId, DriftConfiguration driftConfiguration) throws IOException {
- File changeSetDir = findChangeSetDir(resourceId, driftConfiguration);
+ public File findChangeSet(int resourceId, String driftConfigurationName) throws IOException {
+ File changeSetDir = findChangeSetDir(resourceId, driftConfigurationName);
File changeSetFile = new File(changeSetDir, "changeset.txt");
if (changeSetFile.exists()) {
@@ -35,9 +36,9 @@ public class ChangeSetManagerImpl implements ChangeSetManager {
}
@Override
- public ChangeSetReader getChangeSetReader(int resourceId, DriftConfiguration driftConfiguration)
+ public ChangeSetReader getChangeSetReader(int resourceId, String driftConfigurationName)
throws IOException {
- File changeSetFile = findChangeSet(resourceId, driftConfiguration);
+ File changeSetFile = findChangeSet(resourceId, driftConfigurationName);
if (changeSetFile == null) {
return null;
@@ -47,29 +48,28 @@ public class ChangeSetManagerImpl implements ChangeSetManager {
}
@Override
- public ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration driftConfiguration,
- DriftChangeSetCategory type) throws IOException {
+ public ChangeSetWriter getChangeSetWriter(int resourceId, Headers headers) throws IOException {
File resourceDir = new File(changeSetsDir, Integer.toString(resourceId));
- File changeSetDir = new File(resourceDir, driftConfiguration.getName());
+ File changeSetDir = new File(resourceDir, headers.getDriftConfigurationName());
if (!changeSetDir.exists()) {
changeSetDir.mkdirs();
}
- return new ChangeSetWriterImpl(new File(changeSetDir, "changeset.txt"), driftConfiguration, type);
+ return new ChangeSetWriterImpl(new File(changeSetDir, "changeset.txt"), headers);
}
@Override
public void addFileToChangeSet(int resourceId, DriftConfiguration driftConfiguration, File file) {
}
- private File findChangeSetDir(int resourceId, DriftConfiguration driftConfiguration) {
+ private File findChangeSetDir(int resourceId, String driftConfigurationName) {
File resourceDir = new File(changeSetsDir, Integer.toString(resourceId));
if (!resourceDir.exists()) {
return null;
}
- return new File(resourceDir, driftConfiguration.getName());
+ return new File(resourceDir, driftConfigurationName);
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index 244ea54..40524ed 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -13,6 +13,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.common.drift.ChangeSetWriter;
import org.rhq.common.drift.DirectoryEntry;
import org.rhq.common.drift.FileEntry;
+import org.rhq.common.drift.Headers;
import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.util.MessageDigestGenerator;
@@ -56,7 +57,8 @@ public class DriftDetector implements Runnable {
// if there is no previous changeset then we need to generate the initial
// coverage changeset
ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
- schedule.getDriftConfiguration(), COVERAGE);
+ new Headers(schedule.getDriftConfiguration().getName(), schedule.getDriftConfiguration().getBasedir(),
+ COVERAGE));
DirectoryScanner scanner = new DirectoryScanner(schedule.getDriftConfiguration(), writer);
scanner.scan();
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
index cfe9137..2560147 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftManager.java
@@ -13,6 +13,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.common.drift.Headers;
import org.rhq.core.clientapi.agent.drift.DriftAgentService;
import org.rhq.core.clientapi.server.drift.DriftServerService;
import org.rhq.core.domain.drift.DriftConfiguration;
@@ -72,7 +73,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Con
public void sendChangeSetToServer(int resourceId, DriftConfiguration driftConfiguration) {
try {
- File changeSetFile = changeSetMgr.findChangeSet(resourceId, driftConfiguration);
+ File changeSetFile = changeSetMgr.findChangeSet(resourceId, driftConfiguration.getName());
if (changeSetFile == null) {
log
.warn("changeset[resourceId: " + resourceId + ", driftConfiguration: "
@@ -142,7 +143,7 @@ public class DriftManager extends AgentService implements DriftAgentService, Con
}
@Override
- public boolean requestDriftFiles(int resourceId, String driftConfigurationName, List<DriftFile> driftFiles) {
+ public boolean requestDriftFiles(int resourceId, Headers headers, List<DriftFile> driftFiles) {
return false;
}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
index f839eb2..c7e14ed 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/ChangeSetManagerImplTest.java
@@ -37,7 +37,7 @@ public class ChangeSetManagerImplTest {
public void returnNullReaderWhenNoChangeSetExists() throws Exception {
int resourceId = -1;
ChangeSetManager changeSetMgr = new ChangeSetManagerImpl(changeSetsDir);
- ChangeSetReader reader = changeSetMgr.getChangeSetReader(resourceId, driftConfiguration("test", "server"));
+ ChangeSetReader reader = changeSetMgr.getChangeSetReader(resourceId, "test");
assertNull(reader, "Expect null for the reader when no change set exists for the drift configuration.");
}
@@ -59,7 +59,7 @@ public class ChangeSetManagerImplTest {
writeLines(new File(changeSetDir, "changeset.txt"), changeSet);
ChangeSetManager changeSetMgr = new ChangeSetManagerImpl(changeSetsDir);
- ChangeSetReader reader = changeSetMgr.getChangeSetReader(resourceId, drfitConfig);
+ ChangeSetReader reader = changeSetMgr.getChangeSetReader(resourceId, "test-1");
assertNotNull(reader, "Expected to get a change set reader when change set exists");
assertReaderOpenedOnChangeSet(reader, asList("server/conf", "1"));
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
deleted file mode 100644
index e96c1e9..0000000
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package org.rhq.core.pc.drift;
-
-import java.io.File;
-
-import org.jmock.Expectations;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import org.rhq.common.drift.ChangeSetWriterImpl;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.drift.DriftChangeSetCategory;
-import org.rhq.core.domain.drift.DriftConfiguration;
-import org.rhq.test.JMockTest;
-
-import static org.apache.commons.io.FileUtils.touch;
-import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
-import static org.testng.Assert.*;
-import static org.apache.commons.io.FileUtils.deleteDirectory;
-
-public class DriftDetectorTest extends JMockTest {
-
- File resourcesDir;
-
- File changeSetsDir;
-
- ScheduleQueue queue;
-
- ChangeSetManager changeSetMgr;
-
- @BeforeClass
- public void resetDataDir() throws Exception {
- File basedir = new File("target", getClass().getSimpleName());
- deleteDirectory(basedir);
-
- resourcesDir = new File(basedir, "resources");
- changeSetsDir = new File(basedir, "changesets");
-
- assertTrue(resourcesDir.mkdirs(), "Failed to create " + resourcesDir.getAbsolutePath());
- assertTrue(changeSetsDir.mkdirs(), "Failed to create " + changeSetsDir.getAbsolutePath());
- }
-
- @BeforeMethod
- public void initTest() {
- queue = context.mock(ScheduleQueue.class);
- changeSetMgr = context.mock(ChangeSetManager.class);
- }
-
- @Test(enabled = false)
- public void generateInitialChangeSet() throws Exception {
- File server = new File(resourcesDir, "server");
- File lib = new File(server, "lib");
- lib.mkdirs();
-
- touch(new File(lib, "mylib1.jar"));
- touch(new File(lib, "mylib2.jar"));
-
- File nativeLib = new File(lib, "native");
- nativeLib.mkdir();
- touch(new File(nativeLib, "my-native-lib-1.so"));
- touch(new File(nativeLib, "my-native-lib-2.so"));
-
- final DriftConfiguration driftConfig = driftConfiguration("test", server.getPath());
-
- final File changeSetDir = new File(changeSetsDir, "1-test");
- changeSetDir.mkdir();
-
- // Note that absence of meta data is not sufficient for determining that
- // no change sets have previously been generated. The user could have just
- // deleted the data directory. We need to track what the current change set
- // is. That probably needs to hang off of the resource so it is obtained
- // during inventory sync when the agent starts up.
-
- final DriftDetectionSchedule schedule = new DriftDetectionSchedule(1, driftConfig);
-
- context.checking(new Expectations() {{
- allowing(queue).dequeue(); will(returnValue(schedule));
-
- allowing(queue).enqueue(with(any(DriftDetectionSchedule.class)));
-
- allowing(changeSetMgr).getChangeSetReader(schedule.getResourceId(), schedule.getDriftConfiguration());
- will(returnValue(new DriftDetectionSchedule(1, driftConfig)));
-
- allowing(changeSetMgr).getChangeSetWriter(1, schedule.getDriftConfiguration(), COVERAGE);
- will(returnValue(new ChangeSetWriterImpl(new File(changeSetDir, "test"),
- schedule.getDriftConfiguration(), COVERAGE)));
- }});
-
- DriftDetector driftDetector = new DriftDetector();
- driftDetector.setScheduleQueue(queue);
- driftDetector.setChangeSetManager(changeSetMgr);
-
- driftDetector.run();
- }
-
- DriftConfiguration driftConfiguration(String name, String basedir) {
- Configuration config = new Configuration();
- config.put(new PropertySimple("name", name));
- config.put(new PropertySimple("basedir", basedir));
-
- return new DriftConfiguration(config);
- }
-
-}
12 years, 10 months
[rhq] Branch 'drift' - modules/common modules/core
by John Sanda
modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java | 6 +-
modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java | 9 ++-
modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java | 14 +++--
modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java | 17 ++++---
modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java | 24 +++++-----
modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java | 23 ++++++++-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java | 3 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java | 6 +-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java | 4 +
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java | 16 ++++++
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java | 6 +-
11 files changed, 88 insertions(+), 40 deletions(-)
New commits:
commit b3a6b12ea9bafc9738bbaa67703179d9e4873f3e
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jun 28 09:13:00 2011 -0400
Changing headers to use DriftChangeSetCategory code for 3rd header
Initially the third header was using a boolean flag but reader/writer
code has been refactored to use the enum.
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
index 9cb3392..7ebaabc 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
@@ -12,6 +12,8 @@ import java.util.regex.Pattern;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+
public class ChangeSetReaderImpl implements ChangeSetReader {
private Pattern DIRECTORY_PATTERN = Pattern.compile("^\\s*(.*?)\\s+(\\d+)\\s*$");
@@ -35,9 +37,9 @@ public class ChangeSetReaderImpl implements ChangeSetReader {
private void readHeaders() throws IOException {
String name = reader.readLine();
String basedir = reader.readLine();
- boolean coverageChangeSet = Boolean.valueOf(reader.readLine());
+ DriftChangeSetCategory type = DriftChangeSetCategory.fromCode(reader.readLine());
- headers = new Headers(name, basedir, coverageChangeSet);
+ headers = new Headers(name, basedir, type);
}
@Override
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
index 1b68506..c77a54c 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
@@ -6,6 +6,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
public class ChangeSetWriterImpl implements ChangeSetWriter {
@@ -14,19 +15,19 @@ public class ChangeSetWriterImpl implements ChangeSetWriter {
private File changeSetFile;
- public ChangeSetWriterImpl(File changeSetFile, DriftConfiguration driftConfig, boolean coverageChangeSet)
+ public ChangeSetWriterImpl(File changeSetFile, DriftConfiguration driftConfig, DriftChangeSetCategory type)
throws IOException {
this.changeSetFile = changeSetFile;
writer = new BufferedWriter(new FileWriter(this.changeSetFile));
- writeHeader(driftConfig, coverageChangeSet);
+ writeHeader(driftConfig, type);
}
- private void writeHeader(DriftConfiguration driftConfig, boolean initialChangeSet) throws IOException {
+ private void writeHeader(DriftConfiguration driftConfig, DriftChangeSetCategory type) throws IOException {
writer.write(driftConfig.getName() + "\n");
writer.write(driftConfig.getBasedir() + "\n");
- writer.write(initialChangeSet + "\n");
+ writer.write(type.code() + "\n");
}
public void writeDirectoryEntry(DirectoryEntry dirEntry) throws IOException {
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java b/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
index 7263f96..acfdaf1 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
@@ -1,17 +1,20 @@
package org.rhq.common.drift;
+import org.rhq.core.domain.drift.DriftChangeSet;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+
public class Headers {
private String driftConfigurationName;
private String basedir;
- private boolean coverageChangeSet;
+ private DriftChangeSetCategory type;
- public Headers(String driftConfigurationName, String basedir, boolean coverageChangeSet) {
+ public Headers(String driftConfigurationName, String basedir, DriftChangeSetCategory type) {
this.driftConfigurationName = driftConfigurationName;
this.basedir = basedir;
- this.coverageChangeSet = coverageChangeSet;
+ this.type = type;
}
public String getDriftConfigurationName() {
@@ -22,7 +25,8 @@ public class Headers {
return basedir;
}
- public boolean isCoverageChangeSet() {
- return coverageChangeSet;
+ public DriftChangeSetCategory getType() {
+ return type;
}
+
}
diff --git a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java
index e642063..d56c3c7 100644
--- a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java
+++ b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java
@@ -4,6 +4,9 @@ import java.io.StringReader;
import org.testng.annotations.Test;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
+
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.testng.Assert.*;
public class ChangeSetReaderImplTest {
@@ -12,14 +15,14 @@ public class ChangeSetReaderImplTest {
public void readDirectoryEntryWithFileAdded() throws Exception {
String changeset = "file-added-test\n" +
"myresource\n" +
- "true\n" +
+ "C\n" +
"myresource/conf 1\n" +
"a34ef6 0 myconf.conf A";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset));
Headers actualHeaders = reader.getHeaders();
- Headers expectedHeaders = new Headers("file-added-test", "myresource", true);
+ Headers expectedHeaders = new Headers("file-added-test", "myresource", COVERAGE);
assertHeadersEquals(actualHeaders, expectedHeaders);
@@ -39,14 +42,14 @@ public class ChangeSetReaderImplTest {
public void readDirectoryEntryWithFileRemoved() throws Exception {
String changeset = "file-removed-test\n" +
"myresource\n" +
- "true\n" +
+ "C\n" +
"myresource/conf 1\n" +
"0 a34ef6 myconf.conf R";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset));
Headers actualHeaders = reader.getHeaders();
- Headers expectedHeaders = new Headers("file-removed-test", "myresource", true);
+ Headers expectedHeaders = new Headers("file-removed-test", "myresource", COVERAGE);
assertHeadersEquals(actualHeaders, expectedHeaders);
@@ -66,14 +69,14 @@ public class ChangeSetReaderImplTest {
public void readDirectoryEntryWithFileChanged() throws Exception {
String changeset = "file-changed-test\n" +
"myresource\n" +
- "true\n" +
+ "C\n" +
"myresource/conf 1\n" +
"a34ef6 c41b8 myconf.conf C";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new StringReader(changeset));
Headers actualHeaders = reader.getHeaders();
- Headers expectedHeaders = new Headers("file-changed-test", "myresource", true);
+ Headers expectedHeaders = new Headers("file-changed-test", "myresource", COVERAGE);
assertHeadersEquals(actualHeaders, expectedHeaders);
@@ -93,7 +96,7 @@ public class ChangeSetReaderImplTest {
"The drift configuration name, which should be the first header, is wrong.");
assertEquals(actual.getBasedir(), expected.getBasedir(), "The drift configuration base directory, which " +
"should be the second header, is wrong.");
- assertEquals(actual.isCoverageChangeSet(), expected.isCoverageChangeSet(), "The coverage change set flag, " +
+ assertEquals(actual.getType(), expected.getType(), "The change set type flag, " +
"which should be the third header, is wrong.");
}
diff --git a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
index 6c9a475..0e6786a 100644
--- a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
+++ b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
@@ -9,6 +9,7 @@ import org.testng.annotations.Test;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import static org.apache.commons.io.FileUtils.deleteDirectory;
@@ -17,6 +18,7 @@ import static org.apache.commons.io.IOUtils.readLines;
import static org.rhq.common.drift.FileEntry.addedFileEntry;
import static org.rhq.common.drift.FileEntry.changedFileEntry;
import static org.rhq.common.drift.FileEntry.removedFileEntry;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
@@ -35,9 +37,8 @@ public class ChangeSetWriterImplTest {
public void writeDirectoryEntryWithAddedFile() throws Exception {
File changeSetFile = new File(changeSetsDir, "added-file-test");
DriftConfiguration driftConfig = driftConfiguration("added-file-test", "myresource");
- boolean coverageChangeSet = true;
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, coverageChangeSet);
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, COVERAGE);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
addedFileEntry("myconf.conf", "a34ef6")));
@@ -49,7 +50,7 @@ public class ChangeSetWriterImplTest {
assertEquals(lines.size(), 6, "Expected to find six lines in " + metaDataFile.getPath() +
" - three for the header followed by three for a directory entry.");
- assertHeaderEquals(lines, "added-file-test", "myresource", "true");
+ assertHeaderEquals(lines, "added-file-test", "myresource", "C");
assertEquals(lines.get(3), "myresource/conf 1", "The first line for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
@@ -62,9 +63,8 @@ public class ChangeSetWriterImplTest {
public void writeDirectoryEntryWithRemovedFile() throws Exception {
File changeSetFile = new File(changeSetsDir, "removed-file-test");
DriftConfiguration driftConfig = driftConfiguration("removed-file-test", "myresource");
- boolean coverageChangeSet = true;
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, coverageChangeSet);
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, COVERAGE);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
removedFileEntry("myconf.conf", "a34ef6")));
@@ -76,7 +76,7 @@ public class ChangeSetWriterImplTest {
assertEquals(lines.size(), 6, "Expected to find six lines in " + metaDataFile.getPath() +
" - three for the header followed by three for a directory entry.");
- assertHeaderEquals(lines, "removed-file-test", "myresource", "true");
+ assertHeaderEquals(lines, "removed-file-test", "myresource", "C");
assertEquals(lines.get(3), "myresource/conf 1", "The first line for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
@@ -89,9 +89,8 @@ public class ChangeSetWriterImplTest {
public void writeDirectoryEntryWithChangedFile() throws Exception {
File changeSetFile = new File(changeSetsDir, "changed-file-test");
DriftConfiguration driftConfig = driftConfiguration("changed-file-test", "myresource");
- boolean coverageChangeSet = true;
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, coverageChangeSet);
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig, COVERAGE);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
changedFileEntry("myconf.conf", "a34ef6", "c2d55f")));
@@ -103,7 +102,7 @@ public class ChangeSetWriterImplTest {
assertEquals(lines.size(), 6, "Expected to find six lines in " + metaDataFile.getPath() +
" - three for the header followed by three for a directory entry.");
- assertHeaderEquals(lines, "changed-file-test", "myresource", "true");
+ assertHeaderEquals(lines, "changed-file-test", "myresource", "C");
assertEquals(lines.get(3), "myresource/conf 1", "The first line for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
@@ -120,7 +119,8 @@ public class ChangeSetWriterImplTest {
* <ul>
* <li>drift configuration name</li>
* <li>drift configuration base directory</li>
- * <li>boolean flag indicating whether or not this is an initial changeset</li>
+ * <li>Flag indicating whether or not this is an initial changeset. The flag is a
+ * single letter code code from {@link DriftChangeSetCategory}</li>
* </ul>
* @param lines
* @param expected
@@ -128,8 +128,8 @@ public class ChangeSetWriterImplTest {
void assertHeaderEquals(List<String> lines, String... expected) {
assertEquals(lines.get(0), expected[0], "The first header entry should be the drift configuration name.");
assertEquals(lines.get(1), expected[1], "The second header entry should be the base directory.");
- assertEquals(lines.get(2), expected[2], "The second header entry should be a flag indicating whether or not " +
- "this is a coverage change set");
+ assertEquals(lines.get(2), expected[2], "The third header entry should be a flag indicating the change set " +
+ "type.");
}
/**
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java
index bc04c31..5c3e436 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/drift/DriftChangeSetCategory.java
@@ -28,9 +28,26 @@ package org.rhq.core.domain.drift;
* @author Jay Shaughnesssy
*/
public enum DriftChangeSetCategory {
- COVERAGE, // Reports only on files being covered by a drift configuration.
- DRIFT; // Reports on actual drift.
+ COVERAGE("C"), // Reports only on files being covered by a drift configuration.
+ DRIFT("D"); // Reports on actual drift.
- DriftChangeSetCategory() {
+ private final String code;
+
+ DriftChangeSetCategory(String code) {
+ this.code = code;
+ }
+
+ public String code() {
+ return code;
}
+
+ public static DriftChangeSetCategory fromCode(String code) {
+ for (DriftChangeSetCategory type : DriftChangeSetCategory.values()) {
+ if (type.code.equals(code)) {
+ return type;
+ }
+ }
+ throw new IllegalArgumentException(code + " is not a DriftChangeSetCategory code");
+ }
+
}
\ No newline at end of file
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
index 962299b..154d2cd 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
@@ -5,6 +5,7 @@ import java.io.IOException;
import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetWriter;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
public interface ChangeSetManager {
@@ -34,7 +35,7 @@ public interface ChangeSetManager {
ChangeSetReader getChangeSetReader(int resourceId, DriftConfiguration driftConfiguration) throws IOException;
ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration driftConfiguration,
- boolean coverageChangeSet) throws IOException;
+ DriftChangeSetCategory type) throws IOException;
void addFileToChangeSet(int resourceId, DriftConfiguration driftConfiguration, File file);
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
index baea20c..33be5bb 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
@@ -9,6 +9,7 @@ import org.rhq.common.drift.ChangeSetReader;
import org.rhq.common.drift.ChangeSetReaderImpl;
import org.rhq.common.drift.ChangeSetWriter;
import org.rhq.common.drift.ChangeSetWriterImpl;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import static java.io.File.separator;
@@ -47,7 +48,7 @@ public class ChangeSetManagerImpl implements ChangeSetManager {
@Override
public ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration driftConfiguration,
- boolean coverageChangeSet) throws IOException {
+ DriftChangeSetCategory type) throws IOException {
File resourceDir = new File(changeSetsDir, Integer.toString(resourceId));
File changeSetDir = new File(resourceDir, driftConfiguration.getName());
@@ -55,12 +56,11 @@ public class ChangeSetManagerImpl implements ChangeSetManager {
changeSetDir.mkdirs();
}
- return new ChangeSetWriterImpl(new File(changeSetDir, "changeset.txt"), driftConfiguration, coverageChangeSet);
+ return new ChangeSetWriterImpl(new File(changeSetDir, "changeset.txt"), driftConfiguration, type);
}
@Override
public void addFileToChangeSet(int resourceId, DriftConfiguration driftConfiguration, File file) {
- //To change body of implemented methods use File | Settings | File Templates.
}
private File findChangeSetDir(int resourceId, DriftConfiguration driftConfiguration) {
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index ad8b0c1..244ea54 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -13,11 +13,13 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.common.drift.ChangeSetWriter;
import org.rhq.common.drift.DirectoryEntry;
import org.rhq.common.drift.FileEntry;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.core.util.MessageDigestGenerator;
import static java.io.File.separator;
import static java.util.Collections.EMPTY_LIST;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
public class DriftDetector implements Runnable {
private Log log = LogFactory.getLog(DriftDetector.class);
@@ -54,7 +56,7 @@ public class DriftDetector implements Runnable {
// if there is no previous changeset then we need to generate the initial
// coverage changeset
ChangeSetWriter writer = changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
- schedule.getDriftConfiguration(), true);
+ schedule.getDriftConfiguration(), COVERAGE);
DirectoryScanner scanner = new DirectoryScanner(schedule.getDriftConfiguration(), writer);
scanner.scan();
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java
new file mode 100644
index 0000000..a6ec604
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftFilesSender.java
@@ -0,0 +1,16 @@
+package org.rhq.core.pc.drift;
+
+import java.util.List;
+
+import org.rhq.core.domain.drift.DriftFile;
+
+public class DriftFilesSender implements Runnable {
+
+ public DriftFilesSender(int resourceId, String driftConfigurationName, List<DriftFile> driftFiles) {
+
+ }
+
+ @Override
+ public void run() {
+ }
+}
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
index 80f16b1..e96c1e9 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
@@ -10,10 +10,12 @@ import org.testng.annotations.Test;
import org.rhq.common.drift.ChangeSetWriterImpl;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.drift.DriftChangeSetCategory;
import org.rhq.core.domain.drift.DriftConfiguration;
import org.rhq.test.JMockTest;
import static org.apache.commons.io.FileUtils.touch;
+import static org.rhq.core.domain.drift.DriftChangeSetCategory.COVERAGE;
import static org.testng.Assert.*;
import static org.apache.commons.io.FileUtils.deleteDirectory;
@@ -80,9 +82,9 @@ public class DriftDetectorTest extends JMockTest {
allowing(changeSetMgr).getChangeSetReader(schedule.getResourceId(), schedule.getDriftConfiguration());
will(returnValue(new DriftDetectionSchedule(1, driftConfig)));
- allowing(changeSetMgr).getChangeSetWriter(1, schedule.getDriftConfiguration(), true);
+ allowing(changeSetMgr).getChangeSetWriter(1, schedule.getDriftConfiguration(), COVERAGE);
will(returnValue(new ChangeSetWriterImpl(new File(changeSetDir, "test"),
- schedule.getDriftConfiguration(), true)));
+ schedule.getDriftConfiguration(), COVERAGE)));
}});
DriftDetector driftDetector = new DriftDetector();
12 years, 10 months
[rhq] Branch 'dependent-values' - 121 commits - modules/core modules/enterprise modules/plugins pom.xml
by Heiko W. Rupp
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 11
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java | 4
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java | 6
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 12
modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java | 160
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java | 38
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java | 140
modules/plugins/hudson/pom.xml | 4
modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml | 11
modules/plugins/jboss-as-7/pom.xml | 231 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java | 230 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java | 178
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java | 239 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java | 504 ++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 216 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java | 323 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java | 44
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java | 65
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java | 429 ++
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java | 71
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java | 127
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/LoggerComponent.java | 69
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java | 246 +
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/PluginStats.java | 61
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java | 179
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java | 195
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WarComponent.java | 58
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WarDiscovery.java | 45
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Attribute.java | 86
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ComplexResult.java | 40
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/CompositeOperation.java | 64
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Domain.java | 53
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java | 40
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NetworkInterface.java | 45
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java | 141
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/OperationDescription.java | 80
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java | 69
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadAttribute.java | 32
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java | 37
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenResources.java | 37
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java | 38
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java | 86
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/SocketBindingGroup.java | 47
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java | 67
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Tuple.java | 35
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Type.java | 50
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/TypeModelValue.java | 39
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java | 53
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java | 45
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 1421 ++++++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/CompositeOperationTest.java | 108
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationTest.java | 515 ++
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java | 295 +
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java | 106
modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java | 320 +
modules/plugins/jboss-as-7/src/test/resources/complexInterface.json | 14
modules/plugins/jboss-as-7/src/test/resources/connector.json | 10
modules/plugins/jboss-as-7/src/test/resources/domain-result.json | 2113 ++++++++++
modules/plugins/jboss-as-7/src/test/resources/extensions.json | 93
modules/plugins/jboss-as-7/src/test/resources/interfaces.json | 8
modules/plugins/jboss-as-7/src/test/resources/logging.json | 15
modules/plugins/jboss-as-7/src/test/resources/loopback.json | 10
modules/plugins/jboss-as-7/src/test/resources/schema-locations.json | 50
modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml | 92
modules/plugins/jboss-as-7/src/test/resources/test-simple.war |binary
modules/plugins/jboss-as-7/src/test/resources/threadpool.json | 25
modules/plugins/pom.xml | 1
pom.xml | 1
71 files changed, 10183 insertions(+), 100 deletions(-)
New commits:
commit 04f686144727920a5a25954962d84edf225efc9a
Merge: 2e85dca 1553673
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 13:51:58 2011 +0200
Merge branch 'master' into dependent-values
commit 2e85dca3f15e8702a073d1f0e06105042e126781
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 28 13:51:40 2011 +0200
First cut at handling target=configuration and using DV in the resource config editor.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
index 2df653a..8f1a058 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/ResourceConfigurationEditView.java
@@ -30,6 +30,7 @@ import com.smartgwt.client.widgets.toolbar.ToolStrip;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.composite.ResourceComposite;
@@ -40,6 +41,7 @@ import org.rhq.enterprise.gui.coregui.client.RefreshableView;
import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeEvent;
import org.rhq.enterprise.gui.coregui.client.components.configuration.PropertyValueChangeListener;
+import org.rhq.enterprise.gui.coregui.client.gwt.ConfigurationGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceDetailView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
@@ -127,19 +129,31 @@ public class ResourceConfigurationEditView extends LocatableVLayout implements P
@Override
public void onTypesLoaded(ResourceType type) {
- editor = new ConfigurationEditor(extendLocatorId("Editor"), type
- .getResourceConfigurationDefinition(), result.getConfiguration());
- editor.setOverflow(Overflow.AUTO);
- editor.addPropertyValueChangeListener(ResourceConfigurationEditView.this);
- editor.setReadOnly(!resourcePermission.isConfigureWrite());
- addMember(editor);
-
- saveButton.disable();
- buttonbar.setVisible(true);
- markForRedraw();
- refreshing = false;
+ ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
+ configurationService.getOptionValuesForConfigDefinition(type.getResourceConfigurationDefinition(),new AsyncCallback<ConfigurationDefinition>(){
+ @Override
+ public void onFailure(Throwable throwable) {
+ refreshing = false;
+ CoreGUI.getErrorHandler().handleError("Failed to load configuration.", throwable);
+ }
+
+ @Override
+ public void onSuccess(ConfigurationDefinition configurationDefinition) {
+
+ editor = new ConfigurationEditor(extendLocatorId("Editor"), configurationDefinition, result.getConfiguration());
+ editor.setOverflow(Overflow.AUTO);
+ editor.addPropertyValueChangeListener(ResourceConfigurationEditView.this);
+ editor.setReadOnly(!resourcePermission.isConfigureWrite());
+ addMember(editor);
+
+ saveButton.disable();
+ buttonbar.setVisible(true);
+ markForRedraw();
+ refreshing = false;
+ }
+ });
}
- });
+ });
}
@Override
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
index f810129..8463123 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/ConfigurationManagerBean.java
@@ -59,6 +59,9 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.RawConfiguration;
import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
import org.rhq.core.domain.configuration.composite.ConfigurationUpdateComposite;
@@ -77,6 +80,7 @@ import org.rhq.core.domain.criteria.GroupResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.PluginConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria;
import org.rhq.core.domain.criteria.ResourceCriteria;
+import org.rhq.core.domain.criteria.ResourceGroupCriteria;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
@@ -87,8 +91,6 @@ import org.rhq.core.domain.resource.composite.ResourceComposite;
import org.rhq.core.domain.resource.group.GroupCategory;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.resource.group.composite.ResourceGroupComposite;
-import org.rhq.core.domain.search.SearchSubsystem;
-import org.rhq.core.domain.search.SearchSuggestion;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
@@ -118,7 +120,6 @@ import org.rhq.enterprise.server.resource.group.ResourceGroupManagerLocal;
import org.rhq.enterprise.server.resource.group.ResourceGroupNotFoundException;
import org.rhq.enterprise.server.resource.group.ResourceGroupUpdateException;
import org.rhq.enterprise.server.scheduler.SchedulerLocal;
-import org.rhq.enterprise.server.search.execution.SearchAssistManager;
import org.rhq.enterprise.server.system.ServerVersion;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
@@ -2412,21 +2413,136 @@ public class ConfigurationManagerBean implements ConfigurationManagerLocal, Conf
if (pds.getOptionsSource()!=null) {
// evaluate the source parameters
PropertyOptionsSource pos = pds.getOptionsSource();
- ResourceCriteria criteria = new ResourceCriteria();
- criteria.setSearchExpression(pos.getExpression());
- // TODO for groups we need to talk to the group manager
- List<ResourceComposite> composites = resourceManager.findResourceCompositesByCriteria(subject,criteria);
- for (ResourceComposite composite : composites) {
+ PropertyOptionsSource.TargetType tt = pos.getTargetType();
+ String expression = pos.getExpression();
+ if (tt== PropertyOptionsSource.TargetType.RESOURCE || tt== PropertyOptionsSource.TargetType.CONFIGURATION) {
+ ResourceCriteria criteria = new ResourceCriteria();
+
+
+ if (tt==PropertyOptionsSource.TargetType.CONFIGURATION) {
+ // split out expression part for target=configuration
+ // return if no property specifier is given
+ String expr = expression;
+ if (!expr.contains(":")) {
+ log.warn("Option source expression for property " + pds.getName() + " and target configuration contains no ':'");
+ return;
+ }
+ }
+ else {
+ criteria.setSearchExpression(expression);
+ }
+
+
+ List<ResourceComposite> composites = resourceManager.findResourceCompositesByCriteria(subject,criteria);
+ for (ResourceComposite composite : composites) {
+
+ if (tt== PropertyOptionsSource.TargetType.RESOURCE) {
+
+ PropertyDefinitionEnumeration pde = new PropertyDefinitionEnumeration(composite.getResource().getName(),""+composite.getResource().getId());
+ // TODO filter -- or leave up to search expression??
+ pds.getEnumeratedValues().add(pde);
+ }
+ else if (tt== PropertyOptionsSource.TargetType.CONFIGURATION) {
+ // for configuration we need to drill down into the resource configuration
+ if (!handleConfigurationTarget(pds, expression, composite.getResource())) return;
+
+ }
+ }
+ }
+ else if (tt == PropertyOptionsSource.TargetType.GROUP) {
+ // for groups we need to talk to the group manager
+ ResourceGroupCriteria criteria = new ResourceGroupCriteria();
+ criteria.setSearchExpression(expression);
+
+ resourceGroupManager.findResourceGroupCompositesByCriteria(subject,criteria);
+ }
+ // TODO plugin and resourceType
+ }
- // TODO for configuration we need to drill down into the resource configuration
- PropertyDefinitionEnumeration pde = new PropertyDefinitionEnumeration(composite.getResource().getName(),""+composite.getResource().getId());
+ }
- // TODO filter -- or leave up to search expression??
+ /**
+ * Drill down in the case the user set up a target of "configuration". We need to check
+ * that the target property actually exiists and that it has a format we understand
+ * @param pds Propertydefinition to examine
+ * @param expression The whole expression starting with identifier: for the configuration
+ * identifier. This looks like <i>listname</i> for list of
+ * property simple or <i>mapname=mapkey</i> for a map with simple properties
+ * @param resource the
+ * @return false if the property can not be resolved, true otherwise
+ */
+ private boolean handleConfigurationTarget(PropertyDefinitionSimple pds, String expression,
+ Resource resource) {
+ Configuration configuration = resource.getResourceConfiguration();
+ Property p;
+ String propName = expression.substring(0, expression.indexOf(":"));
+ boolean isMap = expression.contains("=");
+
+ if (isMap) {
+ String mapPropName = propName.substring(0, propName.indexOf("="));
+ p = configuration.get(mapPropName);
+ } else
+ p = configuration.get(propName);
+
+ if (p == null) {
+ log.warn("Option source expression for property " + pds.getName() + " and target configuration not found");
+ return false;
+ }
+ if (!(p instanceof PropertyList)) {
+ log.warn("Option source expression for property " + pds.getName() + " and target configuration does not point to a list");
+ return false;
+ }
+ PropertyList pl = (PropertyList) p;
+ List<Property> propertyList = pl.getList();
+ if (propertyList.size()==0)
+ return false;
+
+ // Now List of simple or list of maps (of simple) ?
+
+ if (propertyList.get(0) instanceof PropertySimple) {
+ if (isMap) {
+ log.warn(" expected a List of Maps, but got a list of simple");
+ return false;
+ }
- pds.getEnumeratedValues().add(pde);
+ for (Property tmp : propertyList) {
+ PropertySimple ps= (PropertySimple) tmp;
+ String name = ps.getStringValue();
+ if (name!=null) {
+ PropertyDefinitionEnumeration pde = new PropertyDefinitionEnumeration(name, name);
+ pds.getEnumeratedValues().add(pde);
+ }
+ }
+ } else if (propertyList.get(0) instanceof PropertyMap) {
+ if (!isMap) {
+ log.warn(" expected a List of simple, but got a list of Maps");
+ return false;
+ }
+ String subPropName ;
+ subPropName = propName.substring(propName.indexOf("=") + 1);
+
+ for (Property tmp : propertyList) {
+ PropertyMap pm = (PropertyMap) tmp;
+ Property ps = pm.get(subPropName);
+ if (ps==null) {
+ log.warn("Option source expression for property " + pds.getName() + " and target configuration does not have a map element " + subPropName);
+ return false;
+ }
+ if (!(ps instanceof PropertySimple)) {
+ log.warn("ListOfMapOf!Simple are not supported");
+ return false;
+ }
+ PropertySimple propertySimple = (PropertySimple) ps;
+ String name = propertySimple.getStringValue();
+ if (name!=null) {
+ PropertyDefinitionEnumeration pde = new PropertyDefinitionEnumeration(name, name);
+ pds.getEnumeratedValues().add(pde);
+ }
}
}
+
+ return true;
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
commit 2c40f40c0e5c7d7fc37bab92cf71f2929d479db6
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 27 21:53:06 2011 +0200
Prevent a possible NPE later on if value is null.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java
index a6f76b8..0592390 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/util/ObjectUtil.java
@@ -145,6 +145,10 @@ public class ObjectUtil {
* @return the value read from the object's property path
*/
public static Object lookupDeepAttributeProperty(Object value, String propertyPath) {
+
+ if (value==null)
+ return null;
+
String[] ps = propertyPath.split("\\.", 2);
String searchProperty = ps[0];
@@ -181,4 +185,4 @@ public class ObjectUtil {
// Prevent instantiation of this class.
private ObjectUtil() {
}
- }
\ No newline at end of file
+ }
commit 1553673802ec3f30d6582d6f0a8df3707cc5d6a1
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 27 17:55:59 2011 +0200
Fix a possible NPE that prevents config rendering.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
index f66cefd..ae8e5d9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
@@ -219,6 +219,9 @@ public class ConfigurationDelegate implements ConfigurationFacet {
* @return the populated map
*/
PropertyMap handlePropertyMap(PropertyDefinitionMap propDef, Object valueObject) {
+ if (valueObject==null)
+ return null;
+
PropertyMap propertyMap = new PropertyMap(propDef.getName());
Map<String, PropertyDefinition> memberDefMap = propDef.getPropertyDefinitions();
commit c57ee650b5c77aeb10df19ed3da12c6ad0c20ef5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 27 10:59:47 2011 +0200
Fix table and sequence names for dependent values
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index a368986..39f0798 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.110</db.schema.version>
+ <db.schema.version>2.111</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
index c5155ab..07f101d 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/config-schema.xml
@@ -58,7 +58,7 @@
<column name="PROPERTY_DEF_ID" type="INTEGER" required="false" references="RHQ_CONFIG_PROP_DEF"/>
</table>
- <table name="RHQ_PROP_DEF_OPT_SRC">
+ <table name="RHQ_CONFIG_PD_OSRC">
<column name="ID" type="INTEGER" required="true" default="sequence-only" initial="10001" primarykey="true"/>
<column name="LINK_TO_TARGET" type="BOOLEAN" required="false"/>
<column name="FILTER" type="VARCHAR2" required="false" size="40"/>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 4d66b02..9950e58 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3444,6 +3444,17 @@
</schema-directSQL>
<schema-createSequence name="rhq_config_prop_def_opt_src_id_seq" initial="10001" />
</schemaSpec>
+ <schemaSpec version="2.111">
+ <schema-directSQL>
+ <statement desc="rename to correct name">
+ ALTER TABLE RHQ_PROP_DEF_OPT_SRC
+ RENAME TO RHQ_CONFIG_PD_OSRC
+ </statement>
+ <statement desc="rename sequence">
+ ALTER TABLE rhq_config_prop_def_opt_src_id_seq RENAME TO rhq_config_pd_osrc_id_seq
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
</dbupgrade>
</target>
</project>
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java
index 1af0bf4..9755bdd 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyOptionsSource.java
@@ -45,8 +45,8 @@ import javax.xml.bind.annotation.XmlAccessorType;
* @author Heiko W. Rupp
*/
@Entity
-@Table(name="RHQ_PROP_DEF_OPT_SRC")
-@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONFIG_PROP_DEF_OPT_SRC_ID_SEQ")
+@Table(name="RHQ_CONFIG_PD_OSRC")
+@SequenceGenerator(name = "SEQ", sequenceName = "RHQ_CONFIG_PD_OSRC_ID_SEQ")
@XmlAccessorType(XmlAccessType.FIELD)
public class PropertyOptionsSource implements Serializable{
commit c1539ab2b81270985ba026be2725f8195d9d4917
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 23 11:57:01 2011 -0400
BZ 644328 - abort the bundle deployment if we cannot determine where to put the bundle,
that is, if we don't have an absolute path. We need to do this for those cases
where, for example, a resource doesn't store an absolute path in its plugin config,
resource source or trait - rather it stores a relative path. In this case, we can't
pin that relative path to anything absolute, so we don't know where to put
the bundle.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index b0cd714..29afab5 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -507,7 +507,17 @@ public class BundleManager extends AgentService implements BundleAgentService, B
}
}
- return new File(baseLocation, relativeDeployDir);
+ File destDir = new File(baseLocation, relativeDeployDir);
+
+ if (!destDir.isAbsolute()) {
+ throw new IllegalArgumentException("The base location path specified by [" + destBaseDirValueName
+ + "] in the context [" + bundleDestBaseDir.getValueContext()
+ + "] along with the destination directory of [" + relativeDeployDir
+ + "] did not resolve to an absolute path [" + destDir.getPath()
+ + "] so there is no way to know where to put the bundle.");
+ }
+
+ return destDir;
}
/**
commit 44d0542ab1bf78b8953dc69f805f55fa15420509
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jun 23 11:43:28 2011 -0400
BZ 644328 - enable bundle deployments to jboss-as-5 plugin
diff --git a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
index 40e2441..21161fe 100644
--- a/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-5/src/main/resources/META-INF/rhq-plugin.xml
@@ -1191,6 +1191,17 @@
</configuration>
</content>
+ <bundle-target>
+ <destination-base-dir name="Install Directory" description="The top directory where the JBossAS Server is installed. (i.e. the value found in the 'JBoss Home Directory' connection property)">
+ <value-context>pluginConfiguration</value-context>
+ <value-name>homeDir</value-name>
+ </destination-base-dir>
+ <destination-base-dir name="Profile Directory" description="The profile configuration directory such as 'default', 'minimal', 'production' or similar location. (i.e. the value found in the 'Server Home Dir' connection property)">
+ <value-context>pluginConfiguration</value-context>
+ <value-name>serverHomeDir</value-name>
+ </destination-base-dir>
+ </bundle-target>
+
<server name="JBoss AS JVM"
description="JVM of the JBossAS"
sourcePlugin="JMX"
commit d6718f1139ed78493364cbd25e19ebec436822e7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 22 20:53:15 2011 +0200
Disable the individual test methods, as the class one did not work.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index 2c9f546..dfa9fd9 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -49,7 +49,7 @@ public class UploadAndDeployTest {
private static final String DC_HOST = "localhost";
private static final int DC_HTTP_PORT = 9990;
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L, enabled=false)
public void testUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -61,7 +61,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L, enabled=false)
public void testDoubleUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -74,7 +74,7 @@ public class UploadAndDeployTest {
assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L,enabled=false)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -154,7 +154,7 @@ public class UploadAndDeployTest {
}
// Test for AS7-853
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L,enabled = false)
public void testUploadIndividualSteps2() throws Exception {
String bytes_value = prepare();
@@ -228,7 +228,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L,enabled = false)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
commit 2906b2db5c170ef6d80dad8e74a1a1a956bb4ba0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 22 20:26:16 2011 +0200
Disable the test, as it needs a running as7
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index 57ec4f3..2c9f546 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -41,7 +41,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
* the UPLOAD_FILE must point to a valid archive in the resources directory.
* @author Heiko W. Rupp
*/
-@Test
+@Test(enabled = false) // TODO add an "integration test profile" that is able to fire the server before running the test
public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
@@ -49,7 +49,7 @@ public class UploadAndDeployTest {
private static final String DC_HOST = "localhost";
private static final int DC_HTTP_PORT = 9990;
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -61,7 +61,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testDoubleUploadOnly() throws Exception {
String bytes_value = prepare();
@@ -74,7 +74,7 @@ public class UploadAndDeployTest {
assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -154,7 +154,7 @@ public class UploadAndDeployTest {
}
// Test for AS7-853
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testUploadIndividualSteps2() throws Exception {
String bytes_value = prepare();
@@ -228,7 +228,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L, enabled = true)
+ @Test(timeOut = 60*1000L)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
commit 28432d866fba7a7cae80e7efc9bd7e84314e113e
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jun 22 10:43:30 2011 -0400
BZ 644328 - when someone creates a new group from within the bundle deploy wizard, prepopulate the
bundle deploy wizard's group selector, but only if the new group supports bundles.
This also clears the radio button options whenever the user starts typing in the
drop down group selector because once you change the group (or start changing the group)
the radio options probably are not valid (we will refresh the options once a valid
group has been selected)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
index 54f6f15..7459562 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/GetDestinationStep.java
@@ -21,6 +21,7 @@ package org.rhq.enterprise.gui.coregui.client.bundle.deploy;
import java.util.LinkedHashMap;
import java.util.Set;
+import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.form.DynamicForm;
@@ -31,6 +32,8 @@ import com.smartgwt.client.widgets.form.fields.TextAreaItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.DataArrivedEvent;
+import com.smartgwt.client.widgets.form.fields.events.DataArrivedHandler;
import com.smartgwt.client.widgets.form.fields.events.IconClickEvent;
import com.smartgwt.client.widgets.form.fields.events.IconClickHandler;
import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
@@ -61,8 +64,9 @@ public class GetDestinationStep extends AbstractWizardStep {
private VLayout form;
DynamicForm valForm = new LocatableDynamicForm("GetDestinationStepValForm");
private SingleCompatibleResourceGroupSelector selector;
- private BundleDestination dest = new BundleDestination();
+ private BundleDestination destination = new BundleDestination();
private boolean createInProgress = false;
+ private RadioGroupItem destBaseDirItem;
public GetDestinationStep(BundleDeployWizard wizard) {
this.wizard = wizard;
@@ -94,7 +98,7 @@ public class GetDestinationStep extends AbstractWizardStep {
value = "";
}
wizard.setSubtitle(value.toString());
- dest.setName(value.toString());
+ destination.setName(value.toString());
}
});
FormUtility.addContextualHelp(nameTextItem, MSG.view_bundle_deployWizard_getDest_name_help());
@@ -108,7 +112,7 @@ public class GetDestinationStep extends AbstractWizardStep {
if (value == null) {
value = "";
}
- dest.setDescription(value.toString());
+ destination.setDescription(value.toString());
}
});
@@ -122,23 +126,23 @@ public class GetDestinationStep extends AbstractWizardStep {
if (value == null) {
value = "";
}
- dest.setDeployDir(value.toString());
+ destination.setDeployDir(value.toString());
}
});
FormUtility.addContextualHelp(deployDirTextItem, MSG.view_bundle_deployWizard_getDest_deployDir_help());
- final RadioGroupItem destBaseDirItem = new RadioGroupItem("destBaseDir", MSG
+ this.destBaseDirItem = new RadioGroupItem("destBaseDir", MSG
.view_bundle_deployWizard_getDest_destBaseDirName());
- destBaseDirItem.setWidth(300);
- destBaseDirItem.setRequired(true);
- destBaseDirItem.setDisabled(true);
- destBaseDirItem.addChangedHandler(new ChangedHandler() {
+ this.destBaseDirItem.setWidth(300);
+ this.destBaseDirItem.setRequired(true);
+ this.destBaseDirItem.setDisabled(true);
+ this.destBaseDirItem.addChangedHandler(new ChangedHandler() {
public void onChanged(ChangedEvent event) {
Object value = event.getValue();
if (value != null && value.toString().length() > 0) {
- dest.setDestinationBaseDirectoryName(value.toString());
+ destination.setDestinationBaseDirectoryName(value.toString());
} else {
- dest.setDestinationBaseDirectoryName(null);
+ destination.setDestinationBaseDirectoryName(null);
}
}
});
@@ -152,62 +156,16 @@ public class GetDestinationStep extends AbstractWizardStep {
this.selector.addChangedHandler(new ChangedHandler() {
@Override
public void onChanged(ChangedEvent event) {
- Integer selectedGroupId = null;
-
// if the user is typing in the name of the group, and is only partially
// done, the event value will be the String of the partial group name.
// If the selection is an actual group name, the event value will be
// an integer (the group ID) and that is our indication that the selection
// of an actual group has been made
+ Integer selectedGroupId = null;
if (event.getValue() instanceof Integer) {
selectedGroupId = (Integer) event.getValue();
}
-
- // new group is, or is in the process of being, selected so forget what the base location was before
- dest.setDestinationBaseDirectoryName(null);
- destBaseDirItem.clearValue();
-
- if (selectedGroupId != null) {
- bundleServer.getResourceTypeBundleConfiguration(selectedGroupId.intValue(),
- new AsyncCallback<ResourceTypeBundleConfiguration>() {
- public void onSuccess(ResourceTypeBundleConfiguration result) {
- // populate the base location drop down with all the possible dest base directories
- LinkedHashMap<String, String> menuItems = null;
- if (result != null) {
- Set<BundleDestinationBaseDirectory> baseDirs;
- baseDirs = result.getBundleDestinationBaseDirectories();
- if (baseDirs != null && baseDirs.size() > 0) {
- String defaultSelectedItem = null;
- menuItems = new LinkedHashMap<String, String>(baseDirs.size());
- for (BundleDestinationBaseDirectory baseDir : baseDirs) {
- if (baseDir.getDescription() != null) {
- menuItems.put(baseDir.getName(), "<b>" + baseDir.getName()
- + "</b>: " + baseDir.getDescription());
- } else {
- menuItems.put(baseDir.getName(), baseDir.getName());
- }
- if (defaultSelectedItem == null) {
- defaultSelectedItem = baseDir.getName();
- }
- }
- destBaseDirItem.setValueMap(menuItems);
- destBaseDirItem.setValue(defaultSelectedItem);
- dest.setDestinationBaseDirectoryName(defaultSelectedItem);
- }
- }
-
- destBaseDirItem.setDisabled(menuItems == null);
- }
-
- public void onFailure(Throwable caught) {
- destBaseDirItem.setDisabled(true);
- CoreGUI.getErrorHandler().handleError(
- MSG.view_bundle_deployWizard_error_noBundleConfig(), caught);
- }
- });
- } else {
- destBaseDirItem.setDisabled(true);
- }
+ groupSelectionChanged(selectedGroupId);
}
});
final FormItemIcon newGroupIcon = new FormItemIcon();
@@ -223,7 +181,7 @@ public class GetDestinationStep extends AbstractWizardStep {
FormUtility.addContextualHelp(this.selector, MSG.view_bundle_deployWizard_getDest_group_help(),
newGroupIcon);
- this.valForm.setItems(nameTextItem, descriptionTextAreaItem, this.selector, destBaseDirItem,
+ this.valForm.setItems(nameTextItem, descriptionTextAreaItem, this.selector, this.destBaseDirItem,
deployDirTextItem);
CanvasItem ci1 = new CanvasItem();
ci1.setShowTitle(false);
@@ -271,8 +229,8 @@ public class GetDestinationStep extends AbstractWizardStep {
private void createDestination() {
int selectedGroup = (Integer) this.valForm.getValue("group");
- bundleServer.createBundleDestination(wizard.getBundleId(), dest.getName(), dest.getDescription(), dest
- .getDestinationBaseDirectoryName(), dest.getDeployDir(), selectedGroup, //
+ bundleServer.createBundleDestination(wizard.getBundleId(), destination.getName(), destination.getDescription(),
+ destination.getDestinationBaseDirectoryName(), destination.getDeployDir(), selectedGroup, //
new AsyncCallback<BundleDestination>() {
public void onSuccess(BundleDestination result) {
wizard.setDestination(result);
@@ -295,16 +253,84 @@ public class GetDestinationStep extends AbstractWizardStep {
});
}
+ private void groupSelectionChanged(Integer selectedGroupId) {
+ // new group is, or is in the process of being, selected so forget what the base location was before
+ destination.setDestinationBaseDirectoryName(null);
+ destBaseDirItem.clearValue();
+ destBaseDirItem.setValueMap((String[]) null);
+
+ // this will be null if there is no true group actually selected (e.g. user is typing a partial name to search)
+ if (selectedGroupId != null) {
+ bundleServer.getResourceTypeBundleConfiguration(selectedGroupId.intValue(),
+ new AsyncCallback<ResourceTypeBundleConfiguration>() {
+ public void onSuccess(ResourceTypeBundleConfiguration result) {
+ // populate the base location drop down with all the possible dest base directories
+ LinkedHashMap<String, String> menuItems = null;
+ if (result != null) {
+ Set<BundleDestinationBaseDirectory> baseDirs;
+ baseDirs = result.getBundleDestinationBaseDirectories();
+ if (baseDirs != null && baseDirs.size() > 0) {
+ String defaultSelectedItem = null;
+ menuItems = new LinkedHashMap<String, String>(baseDirs.size());
+ for (BundleDestinationBaseDirectory baseDir : baseDirs) {
+ if (baseDir.getDescription() != null) {
+ menuItems.put(baseDir.getName(), "<b>" + baseDir.getName() + "</b>: "
+ + baseDir.getDescription());
+ } else {
+ menuItems.put(baseDir.getName(), baseDir.getName());
+ }
+ if (defaultSelectedItem == null) {
+ defaultSelectedItem = baseDir.getName();
+ }
+ }
+ destBaseDirItem.setValueMap(menuItems);
+ destBaseDirItem.setValue(defaultSelectedItem);
+ destination.setDestinationBaseDirectoryName(defaultSelectedItem);
+ }
+ }
+
+ destBaseDirItem.setDisabled(menuItems == null);
+ }
+
+ public void onFailure(Throwable caught) {
+ destBaseDirItem.setDisabled(true);
+ CoreGUI.getErrorHandler().handleError(MSG.view_bundle_deployWizard_error_noBundleConfig(),
+ caught);
+ }
+ });
+ } else {
+ destBaseDirItem.setDisabled(true);
+ }
+ }
+
private class QuickGroupCreateWizard extends AbstractGroupCreateWizard {
- private SingleCompatibleResourceGroupSelector selector;
+ private SingleCompatibleResourceGroupSelector groupSelector;
+ private HandlerRegistration handlerRegistrar;
- public QuickGroupCreateWizard(SingleCompatibleResourceGroupSelector selector) {
+ public QuickGroupCreateWizard(SingleCompatibleResourceGroupSelector theSelector) {
super();
- this.selector = selector;
+ this.groupSelector = theSelector;
}
- public void groupCreateCallback(ResourceGroup group) {
- selector.fetchData();
+ public void groupCreateCallback(final ResourceGroup group) {
+ // note: "group" is essentially a flyweight - it doesn't have much other than ID
+ this.groupSelector.setValue(group.getId());
+
+ this.handlerRegistrar = this.groupSelector.addDataArrivedHandler(new DataArrivedHandler() {
+ public void onDataArrived(DataArrivedEvent event) {
+ handlerRegistrar.removeHandler(); // this handler is only needed once, when group wizard is finished with and we created our group
+ if (groupSelector.getSelectedRecord() == null) {
+ // it appears that the user created a group that cannot be a bundle target.
+ groupSelector.clearValue();
+ groupSelectionChanged(null);
+ } else {
+ groupSelectionChanged(group.getId());
+ }
+ }
+ });
+
+ // order is important - we set the value first above, add dataArrivedHandler, then fetch, which triggers our handler
+ this.groupSelector.fetchData();
}
}
commit d010ed0ad32d363421fca16baf8287a90d182b73
Merge: b06ec2e 02c3770
Author: Heiko W. Rupp <hrupp(a)pintsize.home.pilhuhn.de>
Date: Wed Jun 22 16:22:58 2011 +0200
Merge branch 'master' into as7plugin
commit b06ec2e2753e497bc08041a13d5d5c728a1ffecf
Merge: 3434b60 04f721e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 20 12:54:06 2011 +0200
Merge branch 'master' into as7plugin
commit 3434b60637c8024e83569c50acad52f8e74176da
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jun 17 20:06:44 2011 +0200
Fix some option source
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 1b83106..0ccacf6 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
@@ -108,16 +108,18 @@
<operation name="server-group:remove" displayName="Remove ServerGroup" description="Remove a server group from the Domain.">
<parameters>
<c:simple-property name="name" description="Name of Group to remove">
- <c:option-source target="resource" expression="type=server-group"/>
+ <c:option-source target="resource" expression="type=ServerGroup"/>
</c:simple-property>
</parameters>
</operation>
<operation name="managed-server:add" displayName="Add managed server" description="Add a new managed server">
<parameters>
<c:simple-property name="servername" displayName="Name of the new server" required="true"/>
- <c:simple-property name="hostname" displayName="Name of the host to put the server on" required="true"/>
+ <c:simple-property name="hostname" displayName="Name of the host to put the server on" required="true">
+ <c:option-source target="resource" expression="type=Host plugin=jboss-as-7"/>
+ </c:simple-property>
<c:simple-property name="server-group" displayName="Server group to add to" required="true">
- <c:option-source target="resource" expression="type=server-group"/>
+ <c:option-source target="resource" expression="type=ServerGroup"/>
</c:simple-property>
<c:simple-property name="socket-bindings" displayName="Socket bindings to base upon" default="standard-sockets" description="Socket bindings to base upon"/>
<c:simple-property name="port-offset" displayName="Port offset" default="0" type="integer" />
commit fabdf620c756d90fd7fccd4af816f01a679e3a25
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jun 17 16:08:18 2011 +0200
Add more option-sources.
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 b63bdbc..1b83106 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
@@ -107,7 +107,9 @@
</operation>
<operation name="server-group:remove" displayName="Remove ServerGroup" description="Remove a server group from the Domain.">
<parameters>
- <c:simple-property name="name" description="Name of Group to add"/>
+ <c:simple-property name="name" description="Name of Group to remove">
+ <c:option-source target="resource" expression="type=server-group"/>
+ </c:simple-property>
</parameters>
</operation>
<operation name="managed-server:add" displayName="Add managed server" description="Add a new managed server">
@@ -128,7 +130,9 @@
<operation name="managed-server:remove" displayName="Remove managed server" description="Remove a managed server">
<parameters>
<c:simple-property name="servername" displayName="Name of the server to remove" required="true"/>
- <c:simple-property name="hostname" displayName="Name of the host where the server is on" required="true"/>
+ <c:simple-property name="hostname" displayName="Name of the host where the server is on" required="true">
+ <c:option-source target="resource" expression="type=JBossAS-Managed"/>
+ </c:simple-property>
</parameters>
<results>
<c:simple-property name="result" description="Outcome of the remove server operation"/>
commit 26f07e6d14a978989354631f032bac5bddc45c8e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Jun 17 15:16:00 2011 +0200
Use the new option-source
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 7851d73..b63bdbc 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
@@ -114,7 +114,9 @@
<parameters>
<c:simple-property name="servername" displayName="Name of the new server" required="true"/>
<c:simple-property name="hostname" displayName="Name of the host to put the server on" required="true"/>
- <c:simple-property name="server-group" displayName="Server group to add to" required="true"/>
+ <c:simple-property name="server-group" displayName="Server group to add to" required="true">
+ <c:option-source target="resource" expression="type=server-group"/>
+ </c:simple-property>
<c:simple-property name="socket-bindings" displayName="Socket bindings to base upon" default="standard-sockets" description="Socket bindings to base upon"/>
<c:simple-property name="port-offset" displayName="Port offset" default="0" type="integer" />
<c:simple-property name="auto-start" displayName="Autostart" default="false" type="boolean" />
commit 7ec84d637cb242713cfdefebbaa0100b92357057
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 7 21:01:52 2011 +0200
Runtime name is optional for now.
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 81b702f..7851d73 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
@@ -239,7 +239,7 @@
<content name="file" category="deployable" isCreationType="true" description="Deployments on this domain">
<configuration>
<c:group name="deployment" displayName="Deployment Options">
- <c:simple-property name="runtimeName" required="true"/>
+ <c:simple-property name="runtimeName" required="false"/>
</c:group>
</configuration>
</content>
commit 37f293f248ebd6a3e9c09ea7b7658902444826a0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 7 13:37:28 2011 +0200
BZ 708327 Deploy a domain deployment to a server group.
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 779e733..a51a96a 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
@@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -361,11 +362,13 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
else {
+/*
List<PROPERTY_VALUE> address = step1.getAddress();
Operation step3 = new Operation("deploy",address);
cop.addStep(step3);
+*/
- resourceKey = addressToPath(address);
+ resourceKey = addressToPath(step1.getAddress());
}
JsonNode result = connection.executeRaw(cop);
@@ -465,6 +468,20 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
operation = new Operation(op,address,props);
} else if (what.equals("domain")) {
operation = new Operation(op,Collections.<PROPERTY_VALUE>emptyList());
+ } else if (what.equals("domain-deployment")) {
+ if (op.equals("promote")) {
+ String serverGroup = parameters.getSimpleValue("server-group","-not set-");
+ PropertySimple simple = parameters.getSimple("enabled");
+ Boolean enabled = false;
+ if (simple!=null && simple.getBooleanValue()!=null)
+ enabled= simple.getBooleanValue();
+ address.add(new PROPERTY_VALUE("server-group",serverGroup));
+ String resourceKey = context.getResourceKey();
+ resourceKey = resourceKey.substring(resourceKey.indexOf("=")+1);
+ address.add(new PROPERTY_VALUE("deployment", resourceKey));
+ operation = new Operation("add",address,"enabled",enabled);
+
+ }
}
OperationResult operationResult = new OperationResult();
@@ -479,7 +496,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
}
else {
- operationResult.setErrorMessage("No valid operation was given");
+ operationResult.setErrorMessage("No valid operation was given for input [" + name + "]");
}
// TODO throw an exception if the operation failed?
return operationResult;
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 6aa6dd5..81b702f 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
@@ -226,6 +226,16 @@
<c:simple-property name="path" default="deployment" readOnly="true"/>
</plugin-configuration>
+ <operation name="domain-deployment:promote" displayName="Deploy to Server-Group" description="Deploy this deployment to a server group">
+ <parameters>
+ <c:simple-property name="server-group" required="true" description="Server group to deploy to" type="string"/>
+ <c:simple-property name="enabled" required="true" default="true" description="Should the deployment be enabled on the server group?" type="boolean"/>
+ </parameters>
+ <results>
+ <c:simple-property name="result" description="Outcome of the delete server operation"/>
+ </results>
+ </operation>
+
<content name="file" category="deployable" isCreationType="true" description="Deployments on this domain">
<configuration>
<c:group name="deployment" displayName="Deployment Options">
commit 0d7b698a5ecf597aef64044513069916f3792c3c
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Jun 7 13:33:50 2011 +0200
Improve the help message
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java
index aa91e22..c992000 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/standaloneContainer/Command.java
@@ -36,7 +36,7 @@ public enum Command {
FIND("find", "r | t | rt <name>", 2,
"Searches a (r)esource, resource (t)ype or resources of (rt)ype. Use * as wildcard.\n"
+ " Will set $r for the last resource shown."), HELP("h", "", 0, "Shows this help"), //
- INVOKE("i", "operation [params]", 1, "Triggers running an operation. If operation is '-list' it shows available operations"), //
+ INVOKE("i", "operation [params]", 1, "Triggers running an operation. If operation is '-list' it shows available operations.\n Parameters are given as key=value; key-value-pairs are separated by ||"), //
MEASURE("m", "datatype property+", 1, "Triggers getting metric values. All need to be of the same data type. If datatype is '-list' it shows the defined metrics"), //
NATIVE("n", "e | d | s", 1, "Enables/disables native system or shows native status"), //
QUIT("quit", "", 0, "Terminates the application"), //
commit f89377c912c1e18beaf1972e1b356dfeea6d2e01
Merge: 8c3c91b 3c3dae0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 1 14:16:41 2011 +0200
Merge branch 'master' into as7plugin
commit 8c3c91b3f8ec9bf187f77dd2ba1e5e67d6572eaa
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Jun 1 14:13:49 2011 +0200
BZ 708956 - (re)implement configuration reading
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
index 93f4c6e..f66cefd 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
@@ -18,6 +18,8 @@
*/
package org.rhq.modules.plugins.jbossas7;
+import java.io.IOException;
+import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -27,6 +29,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
+import org.omg.CORBA.portable.ValueInputStream;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -39,247 +42,265 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertyGroupDefinition;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
+import org.rhq.modules.plugins.jbossas7.json.ReadChildrenResources;
import org.rhq.modules.plugins.jbossas7.json.ReadResource;
+import org.rhq.modules.plugins.jbossas7.json.Result;
public class ConfigurationDelegate implements ConfigurationFacet {
+ private static final String SUB_PATH = "_subPath";
+
final Log log = LogFactory.getLog(this.getClass());
+
private List<PROPERTY_VALUE> address;
private ASConnection connection;
private ConfigurationDefinition configurationDefinition;
+ /**
+ * Create a new configuration delegate, that reads the attributes for the resource at address.
+ * @param configDef Configuration definition for the configuration
+ * @param connection asConnection to use
+ * @param address address of the resource.
+ */
public ConfigurationDelegate(ConfigurationDefinition configDef,ASConnection connection, List<PROPERTY_VALUE> address) {
this.configurationDefinition = configDef;
this.connection = connection;
this.address = address;
}
+ /**
+ * Trigger loading of a configuration by talking to the remote resource.
+ * @return The initialized configuration
+ * @throws Exception If anything goes wrong.
+ */
public Configuration loadResourceConfiguration() throws Exception {
+ Configuration config = new Configuration();
- Operation op = new ReadResource(address); // TODO set recursive flag? --> try to narrow it down
+ /*
+ * Grouped definitions get a special treatment, as they may have a special property
+ * that will be evaluated to look at a child resource or a special attribute or such
+ */
+ List<PropertyGroupDefinition> gdef = configurationDefinition.getGroupDefinitions();
+ for (PropertyGroupDefinition pgDef : gdef) {
+ handleGroup(config,pgDef);
+ }
+ /*
+ * Now handle the non-grouped properties
+ */
+ List<PropertyDefinition> nonGroupdedDefs = configurationDefinition.getNonGroupedProperties();
+ Operation op = new ReadResource(address);
op.addAdditionalProperty("recursive", "true");
- JsonNode json = connection.executeRaw(op);
+ handleProperties(config,nonGroupdedDefs,op);
+
+ return config;
+ }
+
+ /**
+ * Handle a set of grouped properties. The name of the group tells us how to deal with it:
+ * <ul>
+ * <li>attribute: read the passed attribute of the resource</li>
+ * <li>children: read the children of the given child-type</li>
+ * </ul>
+ * @param config Configuration to return
+ * @param groupDefinition Definition of this group
+ * @throws Exception If anything goes wrong
+ */
+ private void handleGroup(Configuration config, PropertyGroupDefinition groupDefinition) throws Exception{
+ Operation operation = null;
+ String groupName = groupDefinition.getName();
+ if (groupName.startsWith("attribute:")) {
+ String attr = groupName.substring("attribute:".length());
+ operation = new ReadAttribute(address,attr);
+ }
+ else if (groupName.startsWith("children:")) {
+ String type = groupName.substring("children:".length());
+ operation = new ReadChildrenResources(address,type);
+ operation.addAdditionalProperty("recursive", "true");
+ }
+ else {
+ throw new IllegalArgumentException("Unknown operation in group name [" + groupName + "]");
+ }
+ List<PropertyDefinition> listedDefs = configurationDefinition.getPropertiesInGroup(groupName);
+ handleProperties(config,listedDefs,operation);
+
+ }
- Configuration ret = new Configuration();
- ObjectMapper mapper = new ObjectMapper();
- Set<Map.Entry<String, PropertyDefinition>> entrySet = configurationDefinition.getPropertyDefinitions().entrySet();
- for (Map.Entry<String, PropertyDefinition> propDefEntry : entrySet) {
- PropertyDefinition propDef = propDefEntry.getValue();
- JsonNode sub = json.findValue(propDef.getName());
- if (sub == null) {
+ private void handleProperties(Configuration config, List<PropertyDefinition> definitions, Operation op) throws Exception {
+ if (definitions.size()==0)
+ return;
+
+ Result operationResult = connection.execute(op);
+ if (!operationResult.isSuccess()) {
+ throw new IOException("Operation " + op + " failed: " + operationResult.getFailureDescription());
+ }
+
+
+ if (operationResult.getResult() instanceof List) {
+ PropertyList propertyList = handlePropertyList((PropertyDefinitionList) definitions.get(0),operationResult.getResult());
+
+ if (propertyList!=null)
+ config.put(propertyList);
+ return;
+ }
+
+ Map<String,Object> results = (Map<String, Object>) operationResult.getResult();
+
+
+ for (PropertyDefinition propDef :definitions ) {
+ String propertyName = propDef.getName();
+/*
+ if (!results.containsKey(propertyName)) {
log.warn(
- "No value for property [" + propDef.getName() + "] found - check the descriptor (may be valid, \n"+
+ "No value for property [" + propertyName + "] found - check the descriptor (may be valid, \n"+
"as some attributes are different in domain vs standalone mode");
continue;
}
+*/
+ Object valueObject = results.get(propertyName);
+
if (propDef instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple;
-
- if (sub != null) {
- // Property is non-null -> return it.
- propertySimple = new PropertySimple(propDef.getName(), sub.getValueAsText());
- ret.put(propertySimple);
- } else {
- // property is null? Check if it is required
- if (propDef.isRequired()) {
- String defaultValue = ((PropertyDefinitionSimple) propDef).getDefaultValue();
- propertySimple = new PropertySimple(propDef.getName(), defaultValue);
- ret.put(propertySimple);
- }
- }
- } else if (propDef instanceof PropertyDefinitionList) {
- PropertyList propertyList = new PropertyList(propDef.getName());
- PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
- if (memberDefinition == null) {
- if (sub.isObject()) {
- Iterator<String> fields = sub.getFieldNames();
- while (fields.hasNext()) {
- String fieldName = fields.next();
- JsonNode subNode = sub.get(fieldName);
- PropertySimple propertySimple = new PropertySimple(propDef.getName(), fieldName);
- propertyList.add(propertySimple);
- }
- } else {
- System.out.println("===Sub not object==="); // TODO evaluate this branch again
- Iterator<JsonNode> values = sub.getElements();
- while (values.hasNext()) {
- JsonNode node = values.next();
- String value = node.getTextValue();
- PropertySimple propertySimple = new PropertySimple(propDef.getName(), value);
- propertyList.add(propertySimple);
- }
- }
- } else if (memberDefinition instanceof PropertyDefinitionMap) {
- PropertySimple propertySimple;
-
- if (sub.isArray()) {
- Iterator<JsonNode> entries = sub.getElements();
- while (entries.hasNext()) {
- JsonNode entry = entries.next(); // -> one row in the list i.e. one map
-
- // Distinguish here?
-
- PropertyMap map = new PropertyMap(
- memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
- Iterator<JsonNode> fields = entry.getElements(); // TODO loop over fields from map and not from json
- while (fields.hasNext()) {
- JsonNode field = fields.next();
- if (field.isObject()) {
- // TODO only works for tuples at the moment - migrate to some different kind of parsing!
- PROPERTY_VALUE prop = mapper.readValue(field, PROPERTY_VALUE.class);
- // now need to find the names of the properties
- List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
- if (defList.isEmpty())
- throw new IllegalArgumentException(
- "Map " + memberDefinition.getName() + " has no members");
- String key = defList.get(0).getName();
- String value = prop.getKey();
- propertySimple = new PropertySimple(key, value);
- map.put(propertySimple);
- if (defList.size() > 1) {
- key = defList.get(1).getName();
- value = prop.getValue();
- propertySimple = new PropertySimple(key, value);
- map.put(propertySimple);
-
- }
- } else { // TODO reached?
- String key = field.getValueAsText();
- if (key.equals(
- "PROPERTY_VALUE")) { // TODO this may change in the future in the AS implementation
- JsonNode pv = entry.findValue(key);
- String k = pv.toString();
- String v = pv.getValueAsText();
- propertySimple = new PropertySimple(k, v);
- map.put(propertySimple);
-
- } else {
- JsonNode value = entry.findValue(key);
- if (value != null) {
- propertySimple = new PropertySimple(key, value.getValueAsText());
- map.put(propertySimple);
- }
-
- }
- }
- }
- propertyList.add(map);
- }
- } else if (sub.isObject()) {
- Iterator<String> keys = sub.getFieldNames();
- while (keys.hasNext()) {
- String entryKey = keys.next();
-
- JsonNode node = sub.findPath(entryKey);
- PropertyMap map = new PropertyMap(
- memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
- if (node.isObject()) {
- Iterator<String> fields = node.getFieldNames(); // TODO loop over fields from map and not from json
- while (fields.hasNext()) {
- String key = fields.next();
-
- propertySimple = new PropertySimple(key, node.findValue(key).getValueAsText());
- map.put(propertySimple);
- }
- propertyList.add(map);
- } else if (sub.isNull()) {
- List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
- String key = defList.get(0).getName();
- propertySimple = new PropertySimple(key, entryKey);
- map.put(propertySimple);
- }
- }
-
- }
- } else if (memberDefinition instanceof PropertyDefinitionSimple) {
- String name = memberDefinition.getName();
- Iterator<JsonNode> keys = sub.getElements();
- while (keys.hasNext()) {
- JsonNode entry = keys.next();
-
- PropertySimple propertySimple = new PropertySimple(name, entry.getTextValue());
- propertyList.add(propertySimple);
- }
- }
- ret.put(propertyList);
- } // end List of ..
+
+ PropertySimple value = handlePropertySimple((PropertyDefinitionSimple) propDef, valueObject);
+ if (value!=null)
+ config.put(value);
+ }
+
+ else if (propDef instanceof PropertyDefinitionList) {
+ PropertyList propertyList = handlePropertyList((PropertyDefinitionList) propDef,valueObject);
+
+ if (propertyList!=null)
+ config.put(propertyList);
+ }
else if (propDef instanceof PropertyDefinitionMap) {
- PropertyDefinitionMap mapDef = (PropertyDefinitionMap) propDef;
- PropertyMap pm = new PropertyMap(mapDef.getName());
-
- Map<String, PropertyDefinition> memberDefMap = mapDef.getPropertyDefinitions();
- for (Map.Entry<String, PropertyDefinition> maEntry : memberDefMap.entrySet()) {
- JsonNode valueNode = json.findValue(maEntry.getKey());
- Property p;
- if (maEntry.getValue() instanceof PropertyDefinitionSimple) {
- p = putProperty(valueNode, maEntry.getValue());
- pm.put(p);
- } else if (maEntry.getValue() instanceof PropertyDefinitionMap) { // TODO make this recursive?
-
- PropertyDefinitionMap pdm = (PropertyDefinitionMap) maEntry.getValue();
- Map<String, PropertyDefinition> mmDefMap = pdm.getPropertyDefinitions();
- for (Map.Entry<String, PropertyDefinition> mmDefEntry : mmDefMap.entrySet()) {
- if (valueNode != null) {
- JsonNode node2 = valueNode.findValue(mmDefEntry.getKey());
- System.err.println("Map not yet implemented " + node2.toString());
- } else
- System.err.println("Value node was null ");
- }
- } else { // PropDefList
- System.err.println("List not yet implemented");
- }
-
-// pm.put(p);
- }
- ret.put(pm);
+ PropertyMap propertyMap = handlePropertyMap((PropertyDefinitionMap) propDef,valueObject);
+
+ if (propertyMap!=null)
+ config.put(propertyMap);
+ }
+ }
+ }
+
+ PropertySimple handlePropertySimple(PropertyDefinitionSimple propDef, Object valueObject) {
+ PropertySimple propertySimple;
+
+ String name = propDef.getName();
+ if (valueObject != null) {
+ // Property is non-null -> return it.
+ propertySimple = new PropertySimple(name, valueObject);
+ } else {
+ // property is null? Check if it is required
+ if (propDef.isRequired()) {
+ String defaultValue = ((PropertyDefinitionSimple) propDef).getDefaultValue();
+ propertySimple = new PropertySimple(name, defaultValue);
+ }
+ else { // Not required and null -> return null
+ propertySimple = new PropertySimple(name,null);
}
}
+ return propertySimple;
- return ret;
}
- PropertySimple putProperty(JsonNode value, PropertyDefinition def) {
- String name = def.getName();
- PropertySimple ps;
+ /**
+ * Handle a Map of ...
+ * @param propDef Definition of the map
+ * @param valueObject the objects to put into the map
+ * @return the populated map
+ */
+ PropertyMap handlePropertyMap(PropertyDefinitionMap propDef, Object valueObject) {
+ PropertyMap propertyMap = new PropertyMap(propDef.getName());
+
+ Map<String, PropertyDefinition> memberDefMap = propDef.getPropertyDefinitions();
+ Map<String,Object> objects = (Map<String, Object>) valueObject;
+ for (Map.Entry<String, PropertyDefinition> maEntry : memberDefMap.entrySet()) {
+ String key = maEntry.getKey();
+ // special case: if the key is "*", we just pick the first element
+ Object o ;
+ if (key.equals("*"))
+ o = objects.entrySet().iterator().next().getValue();
+ else
+ o = objects.get(key);
+ Property property;
+ PropertyDefinition value = maEntry.getValue();
+ if (value instanceof PropertyDefinitionSimple)
+ property = handlePropertySimple((PropertyDefinitionSimple) value,o);
+ else if (value instanceof PropertyDefinitionList)
+ property = handlePropertyList((PropertyDefinitionList) value,o);
+ else if (value instanceof PropertyDefinitionMap)
+ property = handlePropertyMap((PropertyDefinitionMap) value,o);
+ else
+ throw new IllegalArgumentException("Unknown property type in map property [" + propDef.getName() +"]");
+
+ if (property!=null)
+ propertyMap.put(property);
+ else
+ System.out.println("Property " + key + " was null");
- if (value == null) {
- if (def instanceof PropertyDefinitionSimple) {
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) def;
- return new PropertySimple(name, pds.getDefaultValue());
- } else
- return new PropertySimple(name, null);
}
- PropertySimpleType type = ((PropertyDefinitionSimple) def).getType();
-
- switch (type) {
- case BOOLEAN:
- ps = new PropertySimple(name, value.getBooleanValue());
- break;
- case FLOAT:
- case DOUBLE:
- ps = new PropertySimple(name, value.getDoubleValue());
- break;
- case INTEGER:
- ps = new PropertySimple(name, value.getIntValue());
- break;
- case LONG:
- ps = new PropertySimple(name, value.getLongValue());
- break;
- default:
- ps = new PropertySimple(name, value.getTextValue());
+
+ return propertyMap;
+ }
+
+ /**
+ * Handle a List of ...
+ * @param propDef Definition of this list
+ * @param valueObject The objects to put into the list
+ * @return the property that describes the list.
+ */
+ PropertyList handlePropertyList(PropertyDefinitionList propDef,Object valueObject) {
+ String propertyName = propDef.getName();
+ PropertyList propertyList = new PropertyList(propertyName);
+ PropertyDefinition memberDefinition = propDef.getMemberDefinition();
+ if (memberDefinition==null)
+ throw new IllegalArgumentException("Member definition for property [" + propertyName + "] was null");
+
+ if (valueObject==null) {
+// System.out.println("vo null");
+ return null;
}
- return ps;
+ Collection<Object> objects;
+ if (valueObject instanceof List)
+ objects = (List<Object>) valueObject;
+ else /*if (valueObject instanceof Map)*/ {
+ objects = ((Map)valueObject).values();
+ }
+
+ if (memberDefinition instanceof PropertyDefinitionSimple) {
+ for (Object obj : objects) {
+ PropertySimple property = handlePropertySimple((PropertyDefinitionSimple) memberDefinition,
+ obj);
+ if (property!=null)
+ propertyList.add(property);
+ }
+ }
+ else if (memberDefinition instanceof PropertyDefinitionMap) {
+ for (Object obj : objects) {
+ Map<String,Object> map = (Map<String, Object>) obj;
+
+ PropertyMap propertyMap = handlePropertyMap(
+ (PropertyDefinitionMap) propDef.getMemberDefinition(),map);
+ if (propertyMap!=null)
+ propertyList.add(propertyMap);
+ }
+ }
+ // TODO List of lists ?
+ return propertyList;
}
+
+
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
Configuration conf = report.getConfiguration();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
index 23d10bb..e521e83 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
@@ -21,7 +21,7 @@ package org.rhq.modules.plugins.jbossas7.json;
import java.util.List;
/**
- * Operation that reads children of a given type from an address
+ * Operation that reads names of children of a given type from an address
* @author Heiko W. Rupp
*/
public class ReadChildrenNames extends Operation {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenResources.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenResources.java
new file mode 100644
index 0000000..543c15b
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenResources.java
@@ -0,0 +1,37 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.List;
+
+/**
+ * Operation that reads children of a given type from an address
+ * @author Heiko W. Rupp
+ */
+public class ReadChildrenResources extends Operation {
+
+ /**
+ * Read children names of a given type below a given address
+ * @param address Address to look at e.g. /profile/default/subsystem/messaging
+ * @param childType e.g. queue
+ */
+ public ReadChildrenResources(List<PROPERTY_VALUE> address, String childType) {
+ super("read-children-resources",address,"child-type",childType);
+ }
+}
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 45fa342..6aa6dd5 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
@@ -274,15 +274,24 @@
<resource-configuration>
- <c:list-property name="schema-locations" displayName="Schema locations">
- <c:map-property name="location">
- <c:simple-property name="urn" readOnly="true"/>
- <c:simple-property name="location" readOnly="true"/>
- </c:map-property>
- </c:list-property>
- <c:list-property name="extension" displayName="Installed extensions">
- <c:simple-property name="name" readOnly="true"/>
- </c:list-property>
+
+ <c:group name="attribute:schema-locations">
+
+ <c:list-property name="schema-locations" displayName="Schema locations">
+ <c:map-property name="*">
+ <c:simple-property name="*" readOnly="true" displayName="Schema name"/>
+ </c:map-property>
+ </c:list-property>
+ </c:group>
+
+ <c:group name="children:extension" displayName="Installed extensions">
+
+ <c:list-property name="extension" displayName="Installed extensions">
+ <c:map-property name="*" displayName="Name">
+ <c:simple-property name="module" displayName="Module name"/>
+ </c:map-property>
+ </c:list-property>
+ </c:group>
</resource-configuration>
@@ -649,13 +658,13 @@
<c:simple-property name="bean-validation-enabled" required="true" type="boolean" readOnly="true"
description="Specify whether bean validation is enabled"/>
<c:simple-property name="archive-validation-enabled" type="boolean" readOnly="true" description="Enabling the validation"/>
- <c:simple-property name="archive-validation-fail-on-error" type="boolean" readOnly="true" default="true"
+ <c:simple-property name="archive-validation-fail-on-error" type="boolean" readOnly="true" defaultValue="true"
description="Should an archive validation error report fail the deployment. Default: true"/>
- <c:simple-property name="archive-validation-fail-on-warn" type="boolean" readOnly="true" default="false"
+ <c:simple-property name="archive-validation-fail-on-warn" type="boolean" readOnly="true" defaultValue="false"
description="Should an archive validation warning report fail the deployment. Default: false"/>
- <c:simple-property name="cached-connection-manager-debug" type="boolean" readOnly="true" default="false"
+ <c:simple-property name="cached-connection-manager-debug" type="boolean" readOnly="true" defaultValue="false"
description="enable/disable debug information logging for cached connection manager"/>
- <c:simple-property name="cached-connection-manager-error" type="boolean" readOnly="true" default="false"
+ <c:simple-property name="cached-connection-manager-error" type="boolean" readOnly="true" defaultValue="false"
description="enable/disable error information logging for cached connection manager"/>
</resource-configuration>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationTest.java
index afd6a7f..6f3a260 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationTest.java
@@ -18,6 +18,9 @@
*/
package org.rhq.modules.plugins.jbossas7;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
import java.util.List;
import java.util.Map;
@@ -51,6 +54,7 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
/**
* Tests loading and writing configurations
@@ -76,7 +80,7 @@ public class ConfigurationTest {
definition.put(new PropertyDefinitionSimple("access-log", "Access-Log", false,
PropertySimpleType.STRING));
definition.put(new PropertyDefinitionSimple("rewrite", "Rewrite", false,
- PropertySimpleType.STRING));
+ PropertySimpleType.BOOLEAN));
definition.put(new PropertyDefinitionSimple("notThere", "NotThere", false,
PropertySimpleType.STRING));
@@ -86,7 +90,7 @@ public class ConfigurationTest {
String resultString = " {\"outcome\" : \"success\", \"result\" : {\"alias\" : [\"example.com\",\"example2.com\"],"+
- " \"access-log\" : null, \"rewrite\" : null}, \"compensating-operation\" : null}";
+ " \"access-log\" : \"my.log\", \"rewrite\" : true}, \"compensating-operation\" : null}";
ObjectMapper mapper = new ObjectMapper();
ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
@@ -102,7 +106,27 @@ public class ConfigurationTest {
PropertyList aliases = (PropertyList) config.get("alias");
List<Property> list = aliases.getList();
assert list.size()==2;
- assert config.get("notThere")==null;
+ int count=2;
+ for (Property p: list) {
+ PropertySimple ps = (PropertySimple) p;
+ if (ps.getStringValue().equals("example.com"))
+ count--;
+ if (ps.getStringValue().equals("example2.com"))
+ count--;
+ }
+ assert count==0 : "Did not find all needed aliases";
+
+ Property notThere = config.get("notThere");
+ assert notThere !=null;
+ assert ((PropertySimple)notThere).getStringValue()==null;
+
+ PropertySimple property = (PropertySimple) config.get("rewrite");
+ assert property!=null;
+ assert property.getBooleanValue();
+
+ property = (PropertySimple) config.get("access-log");
+ assert property!=null && property.getStringValue()!=null;
+ assert property.getStringValue().equals("my.log");
}
public void test2() throws Exception {
@@ -247,10 +271,165 @@ public class ConfigurationTest {
assert ((PropertySimple)map2.get("multicast-port")).getIntegerValue()==18447;
}
}
+ }
+
+
+ public void test4() throws Exception {
+
+ String resultString = loadJsonFromFile("extensions.json");
+
+ ConfigurationDefinition definition = loadDescriptor("test4");
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ FakeConnection connection = new FakeConnection();
+ connection.setContent(json);
+
+ ConfigurationDelegate delegate = new ConfigurationDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+
+ assert config != null;
+ PropertyList extensions = (PropertyList) config.get("extension");
+ assert extensions !=null;
+ List<Property> extensionList = extensions.getList();
+ assert extensionList.size()==22 : "Expected 22 extensions, got " + extensionList.size();
+ PropertyMap propertyMap = (PropertyMap) extensionList.get(0);
+ assert propertyMap != null;
+ PropertyMap starMap = (PropertyMap) propertyMap.get("*");
+ assert starMap!=null;
+ PropertySimple module = (PropertySimple) starMap.get("module");
+ assert module!=null : "Module was null, but should not";
+ String stringValue = module.getStringValue();
+ assert stringValue!=null : "module property has no value";
+ assert stringValue.equals("org.jboss.as.arquillian.service");
+
}
+ public void test5() throws Exception {
+
+ String resultString = loadJsonFromFile("schema-locations.json");
+
+ ConfigurationDefinition definition = loadDescriptor("test5");
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ FakeConnection connection = new FakeConnection();
+ connection.setContent(json);
+
+ ConfigurationDelegate delegate = new ConfigurationDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+
+ assert config != null;
+ PropertyList locations = (PropertyList) config.get("schema-locations");
+ assert locations!=null;
+ List<Property> list = locations.getList();
+ assert list.size()==21 : "List does not contain 21 entries, but " + list.size();
+ PropertyMap propertyMap = (PropertyMap) list.get(0);
+ assert propertyMap !=null;
+ Map<String,Property> map = propertyMap.getMap();
+ assert map.size()==1;
+ PropertySimple urnProp = (PropertySimple) map.get("*");
+ String stringValue = urnProp.getStringValue();
+ assert stringValue!=null : "Location property has no value";
+ assert stringValue.endsWith(".xsd");
+
+ }
+
+ public void test6() throws Exception {
+
+ String resultString = loadJsonFromFile("loopback.json");
+
+ ConfigurationDefinition definition = loadDescriptor("test6and7");
+
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ FakeConnection connection = new FakeConnection();
+ connection.setContent(json);
+
+ ConfigurationDelegate delegate = new ConfigurationDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+
+ assert config != null;
+ PropertySimple nameProperty = (PropertySimple) config.get("name");
+ assert nameProperty !=null;
+ String stringValue = nameProperty.getStringValue();
+ assert stringValue!=null;
+ assert stringValue.equals("default");
+
+ Property criteria = config.get("criteria");
+ assert criteria !=null;
+ PropertySimple critProp = (PropertySimple) criteria;
+ stringValue = critProp.getStringValue();
+ assert stringValue!=null;
+
+ }
+
+ public void test7() throws Exception {
+
+ String resultString = loadJsonFromFile("interfaces.json");
+
+ ConfigurationDefinition definition = loadDescriptor("test6and7");
+
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ FakeConnection connection = new FakeConnection();
+ connection.setContent(json);
+
+ ConfigurationDelegate delegate = new ConfigurationDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+
+ assert config != null;
+ PropertySimple nameProperty = (PropertySimple) config.get("name");
+ assert nameProperty !=null;
+ String stringValue = nameProperty.getStringValue();
+ assert stringValue!=null;
+ assert stringValue.equals("public");
+
+ Property criteria = config.get("criteria");
+ assert criteria !=null;
+ PropertySimple critProp = (PropertySimple) criteria;
+ stringValue = critProp.getStringValue();
+ assert stringValue!=null;
+ assert stringValue.equals("any-ipv4-address");
+
+ }
+
+ public void test8() throws Exception {
+
+ String resultString = loadJsonFromFile("connector.json");
+
+ ConfigurationDefinition definition = loadDescriptor("test8");
+
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ FakeConnection connection = new FakeConnection();
+ connection.setContent(json);
+
+ ConfigurationDelegate delegate = new ConfigurationDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+ assert config!=null;
+ assert config.getAllProperties().size()==8 : "Did not find 8 properties, but " + config.getAllProperties().size();
+ Property prop = config.get("bean-validation-enabled");
+ assert prop != null;
+ PropertySimple ps = (PropertySimple) prop;
+ assert ps.getBooleanValue();
+ prop = config.get("cached-connection-manager-error");
+ assert prop!=null;
+ ps = (PropertySimple) prop;
+ assert ps.getBooleanValue()==false;
+
+ }
@BeforeSuite
private void loadPluginDescriptor() throws Exception {
@@ -291,6 +470,22 @@ public class ConfigurationTest {
return null;
}
+ private String loadJsonFromFile(String fileName) throws Exception {
+ InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(fileName);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ try {
+ StringBuilder builder = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ builder.append(line);
+ }
+ return builder.toString();
+ }
+ finally {
+ reader.close();
+ }
+ }
+
/**
diff --git a/modules/plugins/jboss-as-7/src/test/resources/complexInterface.json b/modules/plugins/jboss-as-7/src/test/resources/complexInterface.json
new file mode 100644
index 0000000..bd048db
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/complexInterface.json
@@ -0,0 +1,14 @@
+{
+ "outcome" : "success",
+ "result" : {
+ "name" : "complex",
+ "criteria" : [ {
+ "any" : [ {
+ "subnet-match" : "192.168.0.0/16"
+ }, "public-address" ]
+ }, {
+ "not" : [ "site-local-address" ]
+ }, "up", "multicast" ]
+ },
+ "compensating-operation" : null
+}
\ No newline at end of file
diff --git a/modules/plugins/jboss-as-7/src/test/resources/connector.json b/modules/plugins/jboss-as-7/src/test/resources/connector.json
new file mode 100644
index 0000000..78d6850
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/connector.json
@@ -0,0 +1,10 @@
+{
+ "outcome" : "success",
+ "result" : {
+ "default-workmanager-short-running-thread-pool" : "jca-short-running",
+ "default-workmanager-long-running-thread-pool" : "jca-long-running",
+ "bean-validation-enabled" : true,
+ "archive-validation-enabled" : true
+ },
+ "compensating-operation" : null
+}
\ No newline at end of file
diff --git a/modules/plugins/jboss-as-7/src/test/resources/domain-result.json b/modules/plugins/jboss-as-7/src/test/resources/domain-result.json
new file mode 100644
index 0000000..9312a97
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/domain-result.json
@@ -0,0 +1,2113 @@
+{
+ "outcome" : "success",
+ "result" : {
+ "host" : {
+ "local" : {
+ "name" : "local",
+ "namespaces" : [ {
+ "xsi" : "http://www.w3.org/2001/XMLSchema-instance"
+ } ],
+ "schema-locations" : [ {
+ "urn:jboss:domain:1.0" : "jboss_7_0.xsd"
+ } ],
+ "extension" : null,
+ "system-property" : null,
+ "path" : null,
+ "management" : {
+ "security-realms" : {
+ "security-realm" : null
+ },
+ "connections" : {
+ "connection" : null
+ }
+ },
+ "management-interface" : {
+ "native-interface" : {
+ "interface" : "public",
+ "port" : 9999
+ },
+ "http-interface" : {
+ "interface" : "public",
+ "port" : 9990
+ }
+ },
+ "server-config" : {
+ "server-one" : {
+ "path" : null,
+ "system-property" : null,
+ "interface" : null,
+ "jvm" : {
+ "default" : {
+ "type" : null,
+ "agent-lib" : null,
+ "agent-path" : null,
+ "env-classpath-ignored" : null,
+ "environment-variables" : null,
+ "heap-size" : null,
+ "max-heap-size" : null,
+ "java-agent" : null,
+ "java-home" : null,
+ "jvm-options" : null,
+ "permgen-size" : null,
+ "max-permgen-size" : null,
+ "stack-size" : null
+ }
+ },
+ "socket-binding-group" : null,
+ "socket-binding-port-offset" : null,
+ "name" : "server-one",
+ "group" : "main-server-group",
+ "auto-start" : true
+ },
+ "server-two" : {
+ "path" : null,
+ "system-property" : null,
+ "interface" : null,
+ "jvm" : {
+ "default" : {
+ "type" : null,
+ "agent-lib" : null,
+ "agent-path" : null,
+ "env-classpath-ignored" : null,
+ "environment-variables" : null,
+ "heap-size" : "64m",
+ "max-heap-size" : "256m",
+ "java-agent" : null,
+ "java-home" : null,
+ "jvm-options" : null,
+ "permgen-size" : null,
+ "max-permgen-size" : null,
+ "stack-size" : null
+ }
+ },
+ "socket-binding-group" : "standard-sockets",
+ "socket-binding-port-offset" : 150,
+ "name" : "server-two",
+ "group" : "main-server-group",
+ "auto-start" : true
+ },
+ "server-three" : {
+ "path" : null,
+ "system-property" : null,
+ "interface" : null,
+ "jvm" : null,
+ "socket-binding-group" : "standard-sockets",
+ "socket-binding-port-offset" : 250,
+ "name" : "server-three",
+ "group" : "other-server-group",
+ "auto-start" : false
+ }
+ },
+ "domain-controller" : {
+ "local" : {
+ }
+ },
+ "interface" : {
+ "loopback" : {
+ "name" : "loopback",
+ "criteria" : [ {
+ "inet-address" : "127.0.0.1"
+ } ]
+ },
+ "public" : {
+ "name" : "public",
+ "criteria" : "any-ipv4-address"
+ }
+ },
+ "jvm" : {
+ "default" : {
+ "type" : null,
+ "agent-lib" : null,
+ "agent-path" : null,
+ "env-classpath-ignored" : null,
+ "environment-variables" : null,
+ "heap-size" : "64m",
+ "max-heap-size" : "128m",
+ "java-agent" : null,
+ "java-home" : null,
+ "jvm-options" : null,
+ "permgen-size" : null,
+ "max-permgen-size" : null,
+ "stack-size" : null
+ }
+ },
+ "server" : {
+ "server-one" : {
+ "namespaces" : [ {
+ "xsi" : "http://www.w3.org/2001/XMLSchema-instance"
+ } ],
+ "schema-locations" : [ {
+ "urn:jboss:domain:1.0" : "jboss_7_0.xsd"
+ }, {
+ "urn:jboss:domain:arquillian:1.0" : "jboss-arquillian.xsd"
+ }, {
+ "urn:jboss:domain:connector:1.0" : "jboss-connector.xsd"
+ }, {
+ "urn:jboss:domain:datasources:1.0" : "jboss-datasources.xsd"
+ }, {
+ "urn:jboss:domain:ejb3:1.0" : "jboss-ejb3.xsd"
+ }, {
+ "urn:jboss:domain:ee:1.0" : "jboss-ee.xsd"
+ }, {
+ "urn:jboss:domain:jaxrs:1.0" : "jboss-jaxrs.xsd"
+ }, {
+ "urn:jboss:domain:jmx:1.0" : "jboss-jmx.xsd"
+ }, {
+ "urn:jboss:domain:jpa:1.0" : "jboss-jpa.xsd"
+ }, {
+ "urn:jboss:domain:messaging:1.0" : "jboss-messaging.xsd"
+ }, {
+ "urn:jboss:domain:naming:1.0" : "jboss-naming.xsd"
+ }, {
+ "urn:jboss:domain:osgi:1.0" : "jboss-osgi.xsd"
+ }, {
+ "urn:jboss:domain:remoting:1.0" : "jboss-remoting.xsd"
+ }, {
+ "urn:jboss:domain:resourceadapters:1.0" : "jboss-resource-adapters.xsd"
+ }, {
+ "urn:jboss:domain:sar:1.0" : "jboss-sar.xsd"
+ }, {
+ "urn:jboss:domain:threads:1.0" : "jboss-threads.xsd"
+ }, {
+ "urn:jboss:domain:transactions:1.0" : "jboss-txn.xsd"
+ }, {
+ "urn:jboss:domain:web:1.0" : "jboss-web.xsd"
+ }, {
+ "urn:jboss:domain:security:1.0" : "jboss-security.xsd"
+ }, {
+ "urn:jboss:domain:webservices:1.0" : "jboss-webservices.xsd"
+ }, {
+ "urn:jboss:domain:weld:1.0" : "jboss-weld.xsd"
+ } ],
+ "name" : "server-one",
+ "management" : {
+ "security-realms" : {
+ "security-realm" : null
+ },
+ "connections" : {
+ "connection" : null
+ }
+ },
+ "management-interface" : null,
+ "profile-name" : null,
+ "extension" : {
+ "org.jboss.as.arquillian.service" : {
+ "module" : "org.jboss.as.arquillian.service"
+ },
+ "org.jboss.as.connector" : {
+ "module" : "org.jboss.as.connector"
+ },
+ "org.jboss.as.jmx" : {
+ "module" : "org.jboss.as.jmx"
+ },
+ "org.jboss.as.jpa" : {
+ "module" : "org.jboss.as.jpa"
+ },
+ "org.jboss.as.logging" : {
+ "module" : "org.jboss.as.logging"
+ },
+ "org.jboss.as.ee" : {
+ "module" : "org.jboss.as.ee"
+ },
+ "org.jboss.as.ejb3" : {
+ "module" : "org.jboss.as.ejb3"
+ },
+ "org.jboss.as.jaxrs" : {
+ "module" : "org.jboss.as.jaxrs"
+ },
+ "org.jboss.as.messaging" : {
+ "module" : "org.jboss.as.messaging"
+ },
+ "org.jboss.as.naming" : {
+ "module" : "org.jboss.as.naming"
+ },
+ "org.jboss.as.osgi" : {
+ "module" : "org.jboss.as.osgi"
+ },
+ "org.jboss.as.remoting" : {
+ "module" : "org.jboss.as.remoting"
+ },
+ "org.jboss.as.sar" : {
+ "module" : "org.jboss.as.sar"
+ },
+ "org.jboss.as.security" : {
+ "module" : "org.jboss.as.security"
+ },
+ "org.jboss.as.threads" : {
+ "module" : "org.jboss.as.threads"
+ },
+ "org.jboss.as.transactions" : {
+ "module" : "org.jboss.as.transactions"
+ },
+ "org.jboss.as.web" : {
+ "module" : "org.jboss.as.web"
+ },
+ "org.jboss.as.weld" : {
+ "module" : "org.jboss.as.weld"
+ },
+ "org.jboss.as.webservices" : {
+ "module" : "org.jboss.as.webservices"
+ }
+ },
+ "system-property" : {
+ "java.net.preferIPv4Stack" : {
+ "value" : "true"
+ }
+ },
+ "path" : null,
+ "subsystem" : {
+ "logging" : {
+ "logger" : {
+ },
+ "async-handler" : {
+ },
+ "console-handler" : {
+ "CONSOLE" : {
+ "autoflush" : true,
+ "encoding" : null,
+ "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
+ "level" : "INFO",
+ "queue-length" : null
+ }
+ },
+ "file-handler" : {
+ },
+ "periodic-rotating-file-handler" : {
+ "FILE" : {
+ "autoflush" : true,
+ "encoding" : null,
+ "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
+ "level" : "INFO",
+ "file" : {
+ "path" : "server.log",
+ "relative-to" : "jboss.server.log.dir"
+ },
+ "suffix" : ".yyyy-MM-dd"
+ }
+ },
+ "size-rotating-file-handler" : {
+ },
+ "root-logger" : {
+ "level" : "INFO",
+ "handlers" : [ "CONSOLE", "FILE" ]
+ }
+ },
+ "threads" : {
+ "bounded-queue-thread-pool" : {
+ "jca-short-running" : {
+ "name" : "jca-short-running",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ },
+ "jca-long-running" : {
+ "name" : "jca-long-running",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ },
+ "ejb3-async" : {
+ "name" : "ejb3-async",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ }
+ },
+ "queueless-thread-pool" : {
+ },
+ "scheduled-thread-pool" : {
+ "remoting" : {
+ "name" : "remoting",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ }
+ }
+ },
+ "thread-factory" : {
+ },
+ "unbounded-queue-thread-pool" : {
+ }
+ },
+ "arquillian" : {
+ },
+ "ee" : null,
+ "ejb3" : {
+ },
+ "naming" : {
+ },
+ "security" : {
+ "security-domain" : {
+ "other" : {
+ "authentication" : [ {
+ "code" : "UsersRoles",
+ "flag" : "required"
+ } ]
+ }
+ }
+ },
+ "transactions" : {
+ "core-environment" : {
+ "process-id" : {
+ "uuid" : "uuid"
+ },
+ "node-identifier" : null,
+ "relative-to" : null,
+ "path" : null
+ },
+ "recovery-environment" : {
+ "socket-binding" : "txn-recovery-environment",
+ "status-socket-binding" : "txn-status-manager"
+ },
+ "coordinator-environment" : {
+ "enable-statistics" : null,
+ "default-timeout" : null
+ },
+ "object-store" : {
+ "relative-to" : null,
+ "path" : null
+ }
+ },
+ "remoting" : {
+ "thread-pool" : "remoting",
+ "connector" : {
+ }
+ },
+ "jmx" : {
+ "server-binding" : "jmx-connector-server",
+ "registry-binding" : "jmx-connector-registry"
+ },
+ "jpa" : {
+ "default-datasource" : ""
+ },
+ "sar" : {
+ },
+ "weld" : {
+ },
+ "connector" : {
+ "default-workmanager-short-running-thread-pool" : "jca-short-running",
+ "default-workmanager-long-running-thread-pool" : "jca-long-running",
+ "bean-validation-enabled" : true,
+ "archive-validation-enabled" : true
+ },
+ "datasources" : {
+ "data-source" : {
+ "java:/H2DS" : {
+ "connection-url" : "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1",
+ "jndi-name" : "java:/H2DS",
+ "driver-name" : "h2",
+ "pool-name" : "H2DS",
+ "use-java-context" : true,
+ "enabled" : true,
+ "pool-prefill" : false,
+ "pool-use-strict-min" : false,
+ "user-name" : "sa",
+ "password" : "sa",
+ "background-validation" : false,
+ "use-fast-fail" : false,
+ "validate-on-match" : false
+ }
+ },
+ "xa-data-source" : null,
+ "jdbc-driver" : {
+ "h2" : {
+ "driver-name" : "h2",
+ "driver-module-name" : "com.h2database.h2",
+ "driver-xa-datasource-class-name" : "org.h2.jdbcx.JdbcDataSource"
+ }
+ }
+ },
+ "resource-adapters" : {
+ "resource-adapter" : null
+ },
+ "osgi" : {
+ "activation" : "lazy",
+ "configuration" : {
+ "pid" : "org.apache.felix.webconsole.internal.servlet.OsgiManager",
+ "configuration_properties" : {
+ "manager.root" : "jboss-osgi"
+ }
+ },
+ "properties" : {
+ "org.jboss.osgi.system.modules" : "org.apache.commons.logging,\n org.apache.log4j,\n org.jboss.as.osgi,\n org.slf4j,",
+ "org.osgi.framework.system.packages.extra" : "org.apache.commons.logging;version=1.1.1,\n org.apache.log4j;version=1.2,\n org.jboss.as.osgi.service;version=7.0,\n org.jboss.osgi.deployment.interceptor;version=1.0,\n org.jboss.osgi.spi.capability;version=1.0,\n org.jboss.osgi.spi.util;version=1.0,\n org.jboss.osgi.testing;version=1.0,\n org.jboss.osgi.vfs;version=1.0,\n org.slf4j;version=1.5.10,",
+ "org.osgi.framework.startlevel.beginning" : "1"
+ },
+ "modules" : {
+ "javaee.api" : null,
+ "org.jboss.as.arquillian.aggregate" : null,
+ "org.jboss.logging" : null,
+ "org.apache.aries.util" : null,
+ "org.jboss.osgi.webconsole" : null,
+ "org.osgi.compendium" : null,
+ "org.apache.felix.log" : {
+ "start" : "1"
+ },
+ "org.jboss.osgi.logging" : {
+ "start" : "1"
+ },
+ "org.apache.aries.jmx" : {
+ "start" : "2"
+ },
+ "org.apache.felix.configadmin" : {
+ "start" : "2"
+ },
+ "org.apache.felix.eventadmin" : {
+ "start" : "2"
+ },
+ "org.apache.felix.metatype" : {
+ "start" : "2"
+ },
+ "org.apache.felix.webconsole" : {
+ "start" : "2"
+ },
+ "org.jboss.as.osgi.configadmin" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.jmx" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.http" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.blueprint" : {
+ "start" : "3"
+ },
+ "org.jboss.osgi.webapp" : {
+ "start" : "3"
+ },
+ "org.jboss.osgi.xerces" : {
+ "start" : "3"
+ }
+ }
+ },
+ "messaging" : {
+ "acceptor" : {
+ "in-vm" : {
+ "type" : "InVM",
+ "server-id" : 0,
+ "param" : null
+ },
+ "netty" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging",
+ "param" : null
+ },
+ "netty-throughput" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging-throughput",
+ "param" : [ {
+ "batch-delay" : "50"
+ }, {
+ "direct-deliver" : "false"
+ } ]
+ }
+ },
+ "address-setting" : {
+ "#" : {
+ "dead-letter-address" : "jms.queue.DLQ",
+ "expiry-address" : "jms.queue.ExpiryQueue",
+ "redelivery-delay" : "0",
+ "max-size-bytes" : "10485760",
+ "message-counter-history-day-limit" : "10",
+ "address-full-policy" : "BLOCK"
+ }
+ },
+ "connector" : {
+ "in-vm" : {
+ "type" : "InVM",
+ "server-id" : 0,
+ "param" : null
+ },
+ "netty" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging",
+ "param" : null
+ },
+ "netty-throughput" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging-throughput",
+ "param" : [ {
+ "batch-delay" : "50"
+ } ]
+ }
+ },
+ "journal-min-files" : "2",
+ "journal-type" : "NIO",
+ "journal-file-size" : "102400",
+ "persistence-enabled" : false,
+ "security-setting" : {
+ "#" : {
+ "guest" : {
+ "send" : true,
+ "consume" : true,
+ "createDurableQueue" : false,
+ "deleteDurableQueue" : false,
+ "createNonDurableQueue" : true,
+ "deleteNonDurableQueue" : true,
+ "manage" : false
+ }
+ }
+ },
+ "queue" : null
+ },
+ "jaxrs" : {
+ },
+ "jms" : {
+ "connection-factory" : {
+ "InVmConnectionFactory" : {
+ "connector" : {
+ "in-vm" : {
+ "backup-connector-name" : "netty"
+ }
+ },
+ "entries" : [ "java:/ConnectionFactory" ]
+ },
+ "RemoteConnectionFactory" : {
+ "connector" : {
+ "netty" : {
+ "backup-connector-name" : "in-vm"
+ }
+ },
+ "entries" : [ "RemoteConnectionFactory" ]
+ }
+ },
+ "queue" : {
+ "testQueue" : {
+ "entries" : [ "queue/test" ]
+ }
+ },
+ "topic" : {
+ "testTopic" : {
+ "entries" : [ "topic/test" ]
+ }
+ }
+ },
+ "web" : {
+ "configuration" : null,
+ "connector" : {
+ "http" : {
+ "protocol" : "HTTP/1.1",
+ "socket-binding" : "http",
+ "scheme" : "http",
+ "virtual-server" : null,
+ "ssl" : null
+ }
+ },
+ "virtual-server" : {
+ "localhost" : {
+ "alias" : [ "example.com" ],
+ "access-log" : null,
+ "rewrite" : null,
+ "default-web-module" : null,
+ "enable-welcome-root" : false
+ }
+ }
+ },
+ "webservices" : {
+ "modify-wsdl-address" : true,
+ "wsdl-host" : "localhost",
+ "endpoint" : {
+ }
+ }
+ },
+ "interface" : {
+ "loopback" : {
+ "name" : "loopback",
+ "criteria" : [ {
+ "inet-address" : "127.0.0.1"
+ } ]
+ },
+ "external" : {
+ "name" : "external",
+ "criteria" : "any-ipv4-address"
+ },
+ "public" : {
+ "name" : "public",
+ "criteria" : "any-ipv4-address"
+ }
+ },
+ "socket-binding-group" : {
+ "standard-sockets" : {
+ "name" : "standard-sockets",
+ "default-interface" : "external",
+ "port-offset" : 0,
+ "socket-binding" : {
+ "jmx-connector-registry" : {
+ "name" : "jmx-connector-registry",
+ "interface" : null,
+ "port" : 1090,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "jmx-connector-server" : {
+ "name" : "jmx-connector-server",
+ "interface" : null,
+ "port" : 1091,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "jndi" : {
+ "name" : "jndi",
+ "interface" : null,
+ "port" : 1099,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "http" : {
+ "name" : "http",
+ "interface" : null,
+ "port" : 8080,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "https" : {
+ "name" : "https",
+ "interface" : null,
+ "port" : 8447,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "osgi-http" : {
+ "name" : "osgi-http",
+ "interface" : null,
+ "port" : 8090,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "remoting" : {
+ "name" : "remoting",
+ "interface" : null,
+ "port" : 4447,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "txn-recovery-environment" : {
+ "name" : "txn-recovery-environment",
+ "interface" : null,
+ "port" : 4712,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "txn-status-manager" : {
+ "name" : "txn-status-manager",
+ "interface" : null,
+ "port" : 4713,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "messaging" : {
+ "name" : "messaging",
+ "interface" : null,
+ "port" : 5445,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "messaging-throughput" : {
+ "name" : "messaging-throughput",
+ "interface" : null,
+ "port" : 5455,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ }
+ }
+ }
+ },
+ "deployment" : null
+ },
+ "server-two" : {
+ "namespaces" : [ {
+ "xsi" : "http://www.w3.org/2001/XMLSchema-instance"
+ } ],
+ "schema-locations" : [ {
+ "urn:jboss:domain:1.0" : "jboss_7_0.xsd"
+ }, {
+ "urn:jboss:domain:arquillian:1.0" : "jboss-arquillian.xsd"
+ }, {
+ "urn:jboss:domain:connector:1.0" : "jboss-connector.xsd"
+ }, {
+ "urn:jboss:domain:datasources:1.0" : "jboss-datasources.xsd"
+ }, {
+ "urn:jboss:domain:ejb3:1.0" : "jboss-ejb3.xsd"
+ }, {
+ "urn:jboss:domain:ee:1.0" : "jboss-ee.xsd"
+ }, {
+ "urn:jboss:domain:jaxrs:1.0" : "jboss-jaxrs.xsd"
+ }, {
+ "urn:jboss:domain:jmx:1.0" : "jboss-jmx.xsd"
+ }, {
+ "urn:jboss:domain:jpa:1.0" : "jboss-jpa.xsd"
+ }, {
+ "urn:jboss:domain:messaging:1.0" : "jboss-messaging.xsd"
+ }, {
+ "urn:jboss:domain:naming:1.0" : "jboss-naming.xsd"
+ }, {
+ "urn:jboss:domain:osgi:1.0" : "jboss-osgi.xsd"
+ }, {
+ "urn:jboss:domain:remoting:1.0" : "jboss-remoting.xsd"
+ }, {
+ "urn:jboss:domain:resourceadapters:1.0" : "jboss-resource-adapters.xsd"
+ }, {
+ "urn:jboss:domain:sar:1.0" : "jboss-sar.xsd"
+ }, {
+ "urn:jboss:domain:threads:1.0" : "jboss-threads.xsd"
+ }, {
+ "urn:jboss:domain:transactions:1.0" : "jboss-txn.xsd"
+ }, {
+ "urn:jboss:domain:web:1.0" : "jboss-web.xsd"
+ }, {
+ "urn:jboss:domain:security:1.0" : "jboss-security.xsd"
+ }, {
+ "urn:jboss:domain:webservices:1.0" : "jboss-webservices.xsd"
+ }, {
+ "urn:jboss:domain:weld:1.0" : "jboss-weld.xsd"
+ } ],
+ "name" : "server-two",
+ "management" : {
+ "security-realms" : {
+ "security-realm" : null
+ },
+ "connections" : {
+ "connection" : null
+ }
+ },
+ "management-interface" : null,
+ "profile-name" : null,
+ "extension" : {
+ "org.jboss.as.arquillian.service" : {
+ "module" : "org.jboss.as.arquillian.service"
+ },
+ "org.jboss.as.connector" : {
+ "module" : "org.jboss.as.connector"
+ },
+ "org.jboss.as.jmx" : {
+ "module" : "org.jboss.as.jmx"
+ },
+ "org.jboss.as.jpa" : {
+ "module" : "org.jboss.as.jpa"
+ },
+ "org.jboss.as.logging" : {
+ "module" : "org.jboss.as.logging"
+ },
+ "org.jboss.as.ee" : {
+ "module" : "org.jboss.as.ee"
+ },
+ "org.jboss.as.ejb3" : {
+ "module" : "org.jboss.as.ejb3"
+ },
+ "org.jboss.as.jaxrs" : {
+ "module" : "org.jboss.as.jaxrs"
+ },
+ "org.jboss.as.messaging" : {
+ "module" : "org.jboss.as.messaging"
+ },
+ "org.jboss.as.naming" : {
+ "module" : "org.jboss.as.naming"
+ },
+ "org.jboss.as.osgi" : {
+ "module" : "org.jboss.as.osgi"
+ },
+ "org.jboss.as.remoting" : {
+ "module" : "org.jboss.as.remoting"
+ },
+ "org.jboss.as.sar" : {
+ "module" : "org.jboss.as.sar"
+ },
+ "org.jboss.as.security" : {
+ "module" : "org.jboss.as.security"
+ },
+ "org.jboss.as.threads" : {
+ "module" : "org.jboss.as.threads"
+ },
+ "org.jboss.as.transactions" : {
+ "module" : "org.jboss.as.transactions"
+ },
+ "org.jboss.as.web" : {
+ "module" : "org.jboss.as.web"
+ },
+ "org.jboss.as.weld" : {
+ "module" : "org.jboss.as.weld"
+ },
+ "org.jboss.as.webservices" : {
+ "module" : "org.jboss.as.webservices"
+ }
+ },
+ "system-property" : {
+ "java.net.preferIPv4Stack" : {
+ "value" : "true"
+ }
+ },
+ "path" : null,
+ "subsystem" : {
+ "logging" : {
+ "logger" : {
+ },
+ "async-handler" : {
+ },
+ "console-handler" : {
+ "CONSOLE" : {
+ "autoflush" : true,
+ "encoding" : null,
+ "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
+ "level" : "INFO",
+ "queue-length" : null
+ }
+ },
+ "file-handler" : {
+ },
+ "periodic-rotating-file-handler" : {
+ "FILE" : {
+ "autoflush" : true,
+ "encoding" : null,
+ "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
+ "level" : "INFO",
+ "file" : {
+ "path" : "server.log",
+ "relative-to" : "jboss.server.log.dir"
+ },
+ "suffix" : ".yyyy-MM-dd"
+ }
+ },
+ "size-rotating-file-handler" : {
+ },
+ "root-logger" : {
+ "level" : "INFO",
+ "handlers" : [ "CONSOLE", "FILE" ]
+ }
+ },
+ "threads" : {
+ "bounded-queue-thread-pool" : {
+ "jca-short-running" : {
+ "name" : "jca-short-running",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ },
+ "jca-long-running" : {
+ "name" : "jca-long-running",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ },
+ "ejb3-async" : {
+ "name" : "ejb3-async",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ }
+ },
+ "queueless-thread-pool" : {
+ },
+ "scheduled-thread-pool" : {
+ "remoting" : {
+ "name" : "remoting",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ }
+ }
+ },
+ "thread-factory" : {
+ },
+ "unbounded-queue-thread-pool" : {
+ }
+ },
+ "arquillian" : {
+ },
+ "ee" : null,
+ "ejb3" : {
+ },
+ "naming" : {
+ },
+ "security" : {
+ "security-domain" : {
+ "other" : {
+ "authentication" : [ {
+ "code" : "UsersRoles",
+ "flag" : "required"
+ } ]
+ }
+ }
+ },
+ "transactions" : {
+ "core-environment" : {
+ "process-id" : {
+ "uuid" : "uuid"
+ },
+ "node-identifier" : null,
+ "relative-to" : null,
+ "path" : null
+ },
+ "recovery-environment" : {
+ "socket-binding" : "txn-recovery-environment",
+ "status-socket-binding" : "txn-status-manager"
+ },
+ "coordinator-environment" : {
+ "enable-statistics" : null,
+ "default-timeout" : null
+ },
+ "object-store" : {
+ "relative-to" : null,
+ "path" : null
+ }
+ },
+ "remoting" : {
+ "thread-pool" : "remoting",
+ "connector" : {
+ }
+ },
+ "jmx" : {
+ "server-binding" : "jmx-connector-server",
+ "registry-binding" : "jmx-connector-registry"
+ },
+ "jpa" : {
+ "default-datasource" : ""
+ },
+ "sar" : {
+ },
+ "weld" : {
+ },
+ "connector" : {
+ "default-workmanager-short-running-thread-pool" : "jca-short-running",
+ "default-workmanager-long-running-thread-pool" : "jca-long-running",
+ "bean-validation-enabled" : true,
+ "archive-validation-enabled" : true
+ },
+ "datasources" : {
+ "data-source" : {
+ "java:/H2DS" : {
+ "connection-url" : "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1",
+ "jndi-name" : "java:/H2DS",
+ "driver-name" : "h2",
+ "pool-name" : "H2DS",
+ "use-java-context" : true,
+ "enabled" : true,
+ "pool-prefill" : false,
+ "pool-use-strict-min" : false,
+ "user-name" : "sa",
+ "password" : "sa",
+ "background-validation" : false,
+ "use-fast-fail" : false,
+ "validate-on-match" : false
+ }
+ },
+ "xa-data-source" : null,
+ "jdbc-driver" : {
+ "h2" : {
+ "driver-name" : "h2",
+ "driver-module-name" : "com.h2database.h2",
+ "driver-xa-datasource-class-name" : "org.h2.jdbcx.JdbcDataSource"
+ }
+ }
+ },
+ "resource-adapters" : {
+ "resource-adapter" : null
+ },
+ "osgi" : {
+ "activation" : "lazy",
+ "configuration" : {
+ "pid" : "org.apache.felix.webconsole.internal.servlet.OsgiManager",
+ "configuration_properties" : {
+ "manager.root" : "jboss-osgi"
+ }
+ },
+ "properties" : {
+ "org.jboss.osgi.system.modules" : "org.apache.commons.logging,\n org.apache.log4j,\n org.jboss.as.osgi,\n org.slf4j,",
+ "org.osgi.framework.system.packages.extra" : "org.apache.commons.logging;version=1.1.1,\n org.apache.log4j;version=1.2,\n org.jboss.as.osgi.service;version=7.0,\n org.jboss.osgi.deployment.interceptor;version=1.0,\n org.jboss.osgi.spi.capability;version=1.0,\n org.jboss.osgi.spi.util;version=1.0,\n org.jboss.osgi.testing;version=1.0,\n org.jboss.osgi.vfs;version=1.0,\n org.slf4j;version=1.5.10,",
+ "org.osgi.framework.startlevel.beginning" : "1"
+ },
+ "modules" : {
+ "javaee.api" : null,
+ "org.jboss.as.arquillian.aggregate" : null,
+ "org.jboss.logging" : null,
+ "org.apache.aries.util" : null,
+ "org.jboss.osgi.webconsole" : null,
+ "org.osgi.compendium" : null,
+ "org.apache.felix.log" : {
+ "start" : "1"
+ },
+ "org.jboss.osgi.logging" : {
+ "start" : "1"
+ },
+ "org.apache.aries.jmx" : {
+ "start" : "2"
+ },
+ "org.apache.felix.configadmin" : {
+ "start" : "2"
+ },
+ "org.apache.felix.eventadmin" : {
+ "start" : "2"
+ },
+ "org.apache.felix.metatype" : {
+ "start" : "2"
+ },
+ "org.apache.felix.webconsole" : {
+ "start" : "2"
+ },
+ "org.jboss.as.osgi.configadmin" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.jmx" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.http" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.blueprint" : {
+ "start" : "3"
+ },
+ "org.jboss.osgi.webapp" : {
+ "start" : "3"
+ },
+ "org.jboss.osgi.xerces" : {
+ "start" : "3"
+ }
+ }
+ },
+ "messaging" : {
+ "acceptor" : {
+ "in-vm" : {
+ "type" : "InVM",
+ "server-id" : 0,
+ "param" : null
+ },
+ "netty" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging",
+ "param" : null
+ },
+ "netty-throughput" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging-throughput",
+ "param" : [ {
+ "batch-delay" : "50"
+ }, {
+ "direct-deliver" : "false"
+ } ]
+ }
+ },
+ "address-setting" : {
+ "#" : {
+ "dead-letter-address" : "jms.queue.DLQ",
+ "expiry-address" : "jms.queue.ExpiryQueue",
+ "redelivery-delay" : "0",
+ "max-size-bytes" : "10485760",
+ "message-counter-history-day-limit" : "10",
+ "address-full-policy" : "BLOCK"
+ }
+ },
+ "connector" : {
+ "in-vm" : {
+ "type" : "InVM",
+ "server-id" : 0,
+ "param" : null
+ },
+ "netty" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging",
+ "param" : null
+ },
+ "netty-throughput" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging-throughput",
+ "param" : [ {
+ "batch-delay" : "50"
+ } ]
+ }
+ },
+ "journal-min-files" : "2",
+ "journal-type" : "NIO",
+ "journal-file-size" : "102400",
+ "persistence-enabled" : false,
+ "security-setting" : {
+ "#" : {
+ "guest" : {
+ "send" : true,
+ "consume" : true,
+ "createDurableQueue" : false,
+ "deleteDurableQueue" : false,
+ "createNonDurableQueue" : true,
+ "deleteNonDurableQueue" : true,
+ "manage" : false
+ }
+ }
+ },
+ "queue" : null
+ },
+ "jaxrs" : {
+ },
+ "jms" : {
+ "connection-factory" : {
+ "InVmConnectionFactory" : {
+ "connector" : {
+ "in-vm" : {
+ "backup-connector-name" : "netty"
+ }
+ },
+ "entries" : [ "java:/ConnectionFactory" ]
+ },
+ "RemoteConnectionFactory" : {
+ "connector" : {
+ "netty" : {
+ "backup-connector-name" : "in-vm"
+ }
+ },
+ "entries" : [ "RemoteConnectionFactory" ]
+ }
+ },
+ "queue" : {
+ "testQueue" : {
+ "entries" : [ "queue/test" ]
+ }
+ },
+ "topic" : {
+ "testTopic" : {
+ "entries" : [ "topic/test" ]
+ }
+ }
+ },
+ "web" : {
+ "configuration" : null,
+ "connector" : {
+ "http" : {
+ "protocol" : "HTTP/1.1",
+ "socket-binding" : "http",
+ "scheme" : "http",
+ "virtual-server" : null,
+ "ssl" : null
+ }
+ },
+ "virtual-server" : {
+ "localhost" : {
+ "alias" : [ "example.com" ],
+ "access-log" : null,
+ "rewrite" : null,
+ "default-web-module" : null,
+ "enable-welcome-root" : false
+ }
+ }
+ },
+ "webservices" : {
+ "modify-wsdl-address" : true,
+ "wsdl-host" : "localhost",
+ "endpoint" : {
+ }
+ }
+ },
+ "interface" : {
+ "loopback" : {
+ "name" : "loopback",
+ "criteria" : [ {
+ "inet-address" : "127.0.0.1"
+ } ]
+ },
+ "external" : {
+ "name" : "external",
+ "criteria" : "any-ipv4-address"
+ },
+ "public" : {
+ "name" : "public",
+ "criteria" : "any-ipv4-address"
+ }
+ },
+ "socket-binding-group" : {
+ "standard-sockets" : {
+ "name" : "standard-sockets",
+ "default-interface" : "external",
+ "port-offset" : 150,
+ "socket-binding" : {
+ "jmx-connector-registry" : {
+ "name" : "jmx-connector-registry",
+ "interface" : null,
+ "port" : 1090,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "jmx-connector-server" : {
+ "name" : "jmx-connector-server",
+ "interface" : null,
+ "port" : 1091,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "jndi" : {
+ "name" : "jndi",
+ "interface" : null,
+ "port" : 1099,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "http" : {
+ "name" : "http",
+ "interface" : null,
+ "port" : 8080,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "https" : {
+ "name" : "https",
+ "interface" : null,
+ "port" : 8447,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "osgi-http" : {
+ "name" : "osgi-http",
+ "interface" : null,
+ "port" : 8090,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "remoting" : {
+ "name" : "remoting",
+ "interface" : null,
+ "port" : 4447,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "txn-recovery-environment" : {
+ "name" : "txn-recovery-environment",
+ "interface" : null,
+ "port" : 4712,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "txn-status-manager" : {
+ "name" : "txn-status-manager",
+ "interface" : null,
+ "port" : 4713,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "messaging" : {
+ "name" : "messaging",
+ "interface" : null,
+ "port" : 5445,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "messaging-throughput" : {
+ "name" : "messaging-throughput",
+ "interface" : null,
+ "port" : 5455,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ }
+ }
+ }
+ },
+ "deployment" : null
+ }
+ }
+ }
+ },
+ "namespaces" : [ {
+ "xsi" : "http://www.w3.org/2001/XMLSchema-instance"
+ } ],
+ "schema-locations" : [ {
+ "urn:jboss:domain:1.0" : "jboss_7_0.xsd"
+ }, {
+ "urn:jboss:domain:arquillian:1.0" : "jboss-arquillian.xsd"
+ }, {
+ "urn:jboss:domain:connector:1.0" : "jboss-connector.xsd"
+ }, {
+ "urn:jboss:domain:datasources:1.0" : "jboss-datasources.xsd"
+ }, {
+ "urn:jboss:domain:ejb3:1.0" : "jboss-ejb3.xsd"
+ }, {
+ "urn:jboss:domain:ee:1.0" : "jboss-ee.xsd"
+ }, {
+ "urn:jboss:domain:jaxrs:1.0" : "jboss-jaxrs.xsd"
+ }, {
+ "urn:jboss:domain:jmx:1.0" : "jboss-jmx.xsd"
+ }, {
+ "urn:jboss:domain:jpa:1.0" : "jboss-jpa.xsd"
+ }, {
+ "urn:jboss:domain:messaging:1.0" : "jboss-messaging.xsd"
+ }, {
+ "urn:jboss:domain:naming:1.0" : "jboss-naming.xsd"
+ }, {
+ "urn:jboss:domain:osgi:1.0" : "jboss-osgi.xsd"
+ }, {
+ "urn:jboss:domain:remoting:1.0" : "jboss-remoting.xsd"
+ }, {
+ "urn:jboss:domain:resourceadapters:1.0" : "jboss-resource-adapters.xsd"
+ }, {
+ "urn:jboss:domain:sar:1.0" : "jboss-sar.xsd"
+ }, {
+ "urn:jboss:domain:threads:1.0" : "jboss-threads.xsd"
+ }, {
+ "urn:jboss:domain:transactions:1.0" : "jboss-txn.xsd"
+ }, {
+ "urn:jboss:domain:web:1.0" : "jboss-web.xsd"
+ }, {
+ "urn:jboss:domain:security:1.0" : "jboss-security.xsd"
+ }, {
+ "urn:jboss:domain:webservices:1.0" : "jboss-webservices.xsd"
+ }, {
+ "urn:jboss:domain:weld:1.0" : "jboss-weld.xsd"
+ } ],
+ "extension" : {
+ "org.jboss.as.arquillian.service" : {
+ "module" : "org.jboss.as.arquillian.service"
+ },
+ "org.jboss.as.connector" : {
+ "module" : "org.jboss.as.connector"
+ },
+ "org.jboss.as.jmx" : {
+ "module" : "org.jboss.as.jmx"
+ },
+ "org.jboss.as.jpa" : {
+ "module" : "org.jboss.as.jpa"
+ },
+ "org.jboss.as.logging" : {
+ "module" : "org.jboss.as.logging"
+ },
+ "org.jboss.as.ee" : {
+ "module" : "org.jboss.as.ee"
+ },
+ "org.jboss.as.ejb3" : {
+ "module" : "org.jboss.as.ejb3"
+ },
+ "org.jboss.as.jaxrs" : {
+ "module" : "org.jboss.as.jaxrs"
+ },
+ "org.jboss.as.messaging" : {
+ "module" : "org.jboss.as.messaging"
+ },
+ "org.jboss.as.naming" : {
+ "module" : "org.jboss.as.naming"
+ },
+ "org.jboss.as.osgi" : {
+ "module" : "org.jboss.as.osgi"
+ },
+ "org.jboss.as.remoting" : {
+ "module" : "org.jboss.as.remoting"
+ },
+ "org.jboss.as.sar" : {
+ "module" : "org.jboss.as.sar"
+ },
+ "org.jboss.as.security" : {
+ "module" : "org.jboss.as.security"
+ },
+ "org.jboss.as.threads" : {
+ "module" : "org.jboss.as.threads"
+ },
+ "org.jboss.as.transactions" : {
+ "module" : "org.jboss.as.transactions"
+ },
+ "org.jboss.as.web" : {
+ "module" : "org.jboss.as.web"
+ },
+ "org.jboss.as.weld" : {
+ "module" : "org.jboss.as.weld"
+ },
+ "org.jboss.as.webservices" : {
+ "module" : "org.jboss.as.webservices"
+ }
+ },
+ "path" : null,
+ "system-property" : {
+ "java.net.preferIPv4Stack" : {
+ "value" : "true",
+ "boot-time" : true
+ }
+ },
+ "profile" : {
+ "default" : {
+ "includes" : null,
+ "subsystem" : {
+ "logging" : {
+ "logger" : {
+ },
+ "async-handler" : {
+ },
+ "console-handler" : {
+ "CONSOLE" : {
+ "autoflush" : true,
+ "encoding" : null,
+ "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
+ "level" : "INFO",
+ "queue-length" : null
+ }
+ },
+ "file-handler" : {
+ },
+ "periodic-rotating-file-handler" : {
+ "FILE" : {
+ "autoflush" : true,
+ "encoding" : null,
+ "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
+ "level" : "INFO",
+ "file" : {
+ "path" : "server.log",
+ "relative-to" : "jboss.server.log.dir"
+ },
+ "suffix" : ".yyyy-MM-dd"
+ }
+ },
+ "size-rotating-file-handler" : {
+ },
+ "root-logger" : {
+ "level" : "INFO",
+ "handlers" : [ "CONSOLE", "FILE" ]
+ }
+ },
+ "threads" : {
+ "bounded-queue-thread-pool" : {
+ "jca-short-running" : {
+ "name" : "jca-short-running",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ },
+ "jca-long-running" : {
+ "name" : "jca-long-running",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ },
+ "ejb3-async" : {
+ "name" : "ejb3-async",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ }
+ },
+ "queueless-thread-pool" : {
+ },
+ "scheduled-thread-pool" : {
+ "remoting" : {
+ "name" : "remoting",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ }
+ }
+ },
+ "thread-factory" : {
+ },
+ "unbounded-queue-thread-pool" : {
+ }
+ },
+ "arquillian" : {
+ },
+ "ee" : null,
+ "ejb3" : {
+ },
+ "naming" : {
+ },
+ "security" : {
+ "security-domain" : {
+ "other" : {
+ "authentication" : [ {
+ "code" : "UsersRoles",
+ "flag" : "required"
+ } ]
+ }
+ }
+ },
+ "transactions" : {
+ "core-environment" : {
+ "process-id" : {
+ "uuid" : "uuid"
+ },
+ "node-identifier" : null,
+ "relative-to" : null,
+ "path" : null
+ },
+ "recovery-environment" : {
+ "socket-binding" : "txn-recovery-environment",
+ "status-socket-binding" : "txn-status-manager"
+ },
+ "coordinator-environment" : {
+ "enable-statistics" : null,
+ "default-timeout" : null
+ },
+ "object-store" : {
+ "relative-to" : null,
+ "path" : null
+ }
+ },
+ "remoting" : {
+ "thread-pool" : "remoting",
+ "connector" : {
+ }
+ },
+ "jmx" : {
+ "server-binding" : "jmx-connector-server",
+ "registry-binding" : "jmx-connector-registry"
+ },
+ "jpa" : {
+ "default-datasource" : ""
+ },
+ "sar" : {
+ },
+ "weld" : {
+ },
+ "connector" : {
+ "default-workmanager-short-running-thread-pool" : "jca-short-running",
+ "default-workmanager-long-running-thread-pool" : "jca-long-running",
+ "bean-validation-enabled" : true,
+ "archive-validation-enabled" : true
+ },
+ "datasources" : {
+ "data-source" : {
+ "java:/H2DS" : {
+ "connection-url" : "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1",
+ "jndi-name" : "java:/H2DS",
+ "driver-name" : "h2",
+ "pool-name" : "H2DS",
+ "use-java-context" : true,
+ "enabled" : true,
+ "pool-prefill" : false,
+ "pool-use-strict-min" : false,
+ "user-name" : "sa",
+ "password" : "sa",
+ "background-validation" : false,
+ "use-fast-fail" : false,
+ "validate-on-match" : false
+ }
+ },
+ "xa-data-source" : null,
+ "jdbc-driver" : {
+ "h2" : {
+ "driver-name" : "h2",
+ "driver-module-name" : "com.h2database.h2",
+ "driver-xa-datasource-class-name" : "org.h2.jdbcx.JdbcDataSource"
+ }
+ }
+ },
+ "resource-adapters" : {
+ "resource-adapter" : null
+ },
+ "osgi" : {
+ "activation" : "lazy",
+ "configuration" : {
+ "pid" : "org.apache.felix.webconsole.internal.servlet.OsgiManager",
+ "configuration_properties" : {
+ "manager.root" : "jboss-osgi"
+ }
+ },
+ "properties" : {
+ "org.jboss.osgi.system.modules" : "org.apache.commons.logging,\n org.apache.log4j,\n org.jboss.as.osgi,\n org.slf4j,",
+ "org.osgi.framework.system.packages.extra" : "org.apache.commons.logging;version=1.1.1,\n org.apache.log4j;version=1.2,\n org.jboss.as.osgi.service;version=7.0,\n org.jboss.osgi.deployment.interceptor;version=1.0,\n org.jboss.osgi.spi.capability;version=1.0,\n org.jboss.osgi.spi.util;version=1.0,\n org.jboss.osgi.testing;version=1.0,\n org.jboss.osgi.vfs;version=1.0,\n org.slf4j;version=1.5.10,",
+ "org.osgi.framework.startlevel.beginning" : "1"
+ },
+ "modules" : {
+ "javaee.api" : null,
+ "org.jboss.as.arquillian.aggregate" : null,
+ "org.jboss.logging" : null,
+ "org.apache.aries.util" : null,
+ "org.jboss.osgi.webconsole" : null,
+ "org.osgi.compendium" : null,
+ "org.apache.felix.log" : {
+ "start" : "1"
+ },
+ "org.jboss.osgi.logging" : {
+ "start" : "1"
+ },
+ "org.apache.aries.jmx" : {
+ "start" : "2"
+ },
+ "org.apache.felix.configadmin" : {
+ "start" : "2"
+ },
+ "org.apache.felix.eventadmin" : {
+ "start" : "2"
+ },
+ "org.apache.felix.metatype" : {
+ "start" : "2"
+ },
+ "org.apache.felix.webconsole" : {
+ "start" : "2"
+ },
+ "org.jboss.as.osgi.configadmin" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.jmx" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.http" : {
+ "start" : "2"
+ },
+ "org.jboss.osgi.blueprint" : {
+ "start" : "3"
+ },
+ "org.jboss.osgi.webapp" : {
+ "start" : "3"
+ },
+ "org.jboss.osgi.xerces" : {
+ "start" : "3"
+ }
+ }
+ },
+ "messaging" : {
+ "acceptor" : {
+ "in-vm" : {
+ "type" : "InVM",
+ "server-id" : 0,
+ "param" : null
+ },
+ "netty" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging",
+ "param" : null
+ },
+ "netty-throughput" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging-throughput",
+ "param" : [ {
+ "batch-delay" : "50"
+ }, {
+ "direct-deliver" : "false"
+ } ]
+ }
+ },
+ "address-setting" : {
+ "#" : {
+ "dead-letter-address" : "jms.queue.DLQ",
+ "expiry-address" : "jms.queue.ExpiryQueue",
+ "redelivery-delay" : "0",
+ "max-size-bytes" : "10485760",
+ "message-counter-history-day-limit" : "10",
+ "address-full-policy" : "BLOCK"
+ }
+ },
+ "connector" : {
+ "in-vm" : {
+ "type" : "InVM",
+ "server-id" : 0,
+ "param" : null
+ },
+ "netty" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging",
+ "param" : null
+ },
+ "netty-throughput" : {
+ "type" : "Remote",
+ "socket-binding" : "messaging-throughput",
+ "param" : [ {
+ "batch-delay" : "50"
+ } ]
+ }
+ },
+ "journal-min-files" : "2",
+ "journal-type" : "NIO",
+ "journal-file-size" : "102400",
+ "persistence-enabled" : false,
+ "security-setting" : {
+ "#" : {
+ "guest" : {
+ "send" : true,
+ "consume" : true,
+ "createDurableQueue" : false,
+ "deleteDurableQueue" : false,
+ "createNonDurableQueue" : true,
+ "deleteNonDurableQueue" : true,
+ "manage" : false
+ }
+ }
+ },
+ "queue" : null
+ },
+ "jaxrs" : {
+ },
+ "jms" : {
+ "connection-factory" : {
+ "InVmConnectionFactory" : {
+ "connector" : {
+ "in-vm" : {
+ "backup-connector-name" : "netty"
+ }
+ },
+ "entries" : [ "java:/ConnectionFactory" ]
+ },
+ "RemoteConnectionFactory" : {
+ "connector" : {
+ "netty" : {
+ "backup-connector-name" : "in-vm"
+ }
+ },
+ "entries" : [ "RemoteConnectionFactory" ]
+ }
+ },
+ "queue" : {
+ "testQueue" : {
+ "entries" : [ "queue/test" ]
+ }
+ },
+ "topic" : {
+ "testTopic" : {
+ "entries" : [ "topic/test" ]
+ }
+ }
+ },
+ "web" : {
+ "configuration" : null,
+ "connector" : {
+ "http" : {
+ "protocol" : "HTTP/1.1",
+ "socket-binding" : "http",
+ "scheme" : "http",
+ "virtual-server" : null,
+ "ssl" : null
+ }
+ },
+ "virtual-server" : {
+ "localhost" : {
+ "alias" : [ "example.com" ],
+ "access-log" : null,
+ "rewrite" : null,
+ "default-web-module" : null,
+ "enable-welcome-root" : false
+ }
+ }
+ },
+ "webservices" : {
+ "modify-wsdl-address" : true,
+ "wsdl-host" : "localhost",
+ "endpoint" : {
+ }
+ }
+ }
+ }
+ },
+ "interface" : {
+ "loopback" : {
+ "name" : "loopback",
+ "criteria" : [ {
+ "inet-address" : "127.0.0.1"
+ } ]
+ },
+ "external" : {
+ "name" : "external",
+ "criteria" : "any-ipv4-address"
+ }
+ },
+ "socket-binding-group" : {
+ "standard-sockets" : {
+ "name" : "standard-sockets",
+ "default-interface" : "external",
+ "includes" : [ "messaging-sockets" ],
+ "socket-binding" : {
+ "jmx-connector-registry" : {
+ "name" : "jmx-connector-registry",
+ "interface" : null,
+ "port" : 1090,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "jmx-connector-server" : {
+ "name" : "jmx-connector-server",
+ "interface" : null,
+ "port" : 1091,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "jndi" : {
+ "name" : "jndi",
+ "interface" : null,
+ "port" : 1099,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "http" : {
+ "name" : "http",
+ "interface" : null,
+ "port" : 8080,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "https" : {
+ "name" : "https",
+ "interface" : null,
+ "port" : 8447,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "osgi-http" : {
+ "name" : "osgi-http",
+ "interface" : null,
+ "port" : 8090,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "remoting" : {
+ "name" : "remoting",
+ "interface" : null,
+ "port" : 4447,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "txn-recovery-environment" : {
+ "name" : "txn-recovery-environment",
+ "interface" : null,
+ "port" : 4712,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "txn-status-manager" : {
+ "name" : "txn-status-manager",
+ "interface" : null,
+ "port" : 4713,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ }
+ }
+ },
+ "messaging-sockets" : {
+ "name" : "messaging-sockets",
+ "default-interface" : "external",
+ "includes" : [ ],
+ "socket-binding" : {
+ "messaging" : {
+ "name" : "messaging",
+ "interface" : null,
+ "port" : 5445,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ },
+ "messaging-throughput" : {
+ "name" : "messaging-throughput",
+ "interface" : null,
+ "port" : 5455,
+ "fixed-port" : null,
+ "multicast-address" : null,
+ "multicast-port" : null
+ }
+ }
+ }
+ },
+ "deployment" : null,
+ "server-group" : {
+ "main-server-group" : {
+ "profile" : "default",
+ "jvm" : {
+ "default" : {
+ "type" : null,
+ "agent-lib" : null,
+ "agent-path" : null,
+ "env-classpath-ignored" : null,
+ "environment-variables" : null,
+ "heap-size" : "64m",
+ "max-heap-size" : "512m",
+ "java-agent" : null,
+ "java-home" : null,
+ "jvm-options" : null,
+ "permgen-size" : null,
+ "max-permgen-size" : null,
+ "stack-size" : null
+ }
+ },
+ "system-property" : null,
+ "deployment" : null,
+ "socket-binding-group" : "standard-sockets"
+ },
+ "other-server-group" : {
+ "profile" : "default",
+ "jvm" : {
+ "default" : {
+ "type" : null,
+ "agent-lib" : null,
+ "agent-path" : null,
+ "env-classpath-ignored" : null,
+ "environment-variables" : null,
+ "heap-size" : "64m",
+ "max-heap-size" : "512m",
+ "java-agent" : null,
+ "java-home" : null,
+ "jvm-options" : null,
+ "permgen-size" : null,
+ "max-permgen-size" : null,
+ "stack-size" : null
+ }
+ },
+ "system-property" : null,
+ "deployment" : null,
+ "socket-binding-group" : "standard-sockets"
+ }
+ }
+ },
+ "compensating-operation" : null
+}
diff --git a/modules/plugins/jboss-as-7/src/test/resources/extensions.json b/modules/plugins/jboss-as-7/src/test/resources/extensions.json
new file mode 100644
index 0000000..0ba5ccd
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/extensions.json
@@ -0,0 +1,93 @@
+{
+ "outcome" : "success",
+ "result" : [ {
+ "org.jboss.as.arquillian.service" : {
+ "module" : "org.jboss.as.arquillian.service"
+ }
+ }, {
+ "org.jboss.as.clustering" : {
+ "module" : "org.jboss.as.clustering"
+ }
+ }, {
+ "org.jboss.as.connector" : {
+ "module" : "org.jboss.as.connector"
+ }
+ }, {
+ "org.jboss.as.deployment-scanner" : {
+ "module" : "org.jboss.as.deployment-scanner"
+ }
+ }, {
+ "org.jboss.as.ee" : {
+ "module" : "org.jboss.as.ee"
+ }
+ }, {
+ "org.jboss.as.ejb3" : {
+ "module" : "org.jboss.as.ejb3"
+ }
+ }, {
+ "org.jboss.as.jaxrs" : {
+ "module" : "org.jboss.as.jaxrs"
+ }
+ }, {
+ "org.jboss.as.jmx" : {
+ "module" : "org.jboss.as.jmx"
+ }
+ }, {
+ "org.jboss.as.jpa" : {
+ "module" : "org.jboss.as.jpa"
+ }
+ }, {
+ "org.jboss.as.logging" : {
+ "module" : "org.jboss.as.logging"
+ }
+ }, {
+ "org.jboss.as.messaging" : {
+ "module" : "org.jboss.as.messaging"
+ }
+ }, {
+ "org.jboss.as.modcluster" : {
+ "module" : "org.jboss.as.modcluster"
+ }
+ }, {
+ "org.jboss.as.naming" : {
+ "module" : "org.jboss.as.naming"
+ }
+ }, {
+ "org.jboss.as.osgi" : {
+ "module" : "org.jboss.as.osgi"
+ }
+ }, {
+ "org.jboss.as.remoting" : {
+ "module" : "org.jboss.as.remoting"
+ }
+ }, {
+ "org.jboss.as.sar" : {
+ "module" : "org.jboss.as.sar"
+ }
+ }, {
+ "org.jboss.as.security" : {
+ "module" : "org.jboss.as.security"
+ }
+ }, {
+ "org.jboss.as.threads" : {
+ "module" : "org.jboss.as.threads"
+ }
+ }, {
+ "org.jboss.as.transactions" : {
+ "module" : "org.jboss.as.transactions"
+ }
+ }, {
+ "org.jboss.as.web" : {
+ "module" : "org.jboss.as.web"
+ }
+ }, {
+ "org.jboss.as.webservices" : {
+ "module" : "org.jboss.as.webservices"
+ }
+ }, {
+ "org.jboss.as.weld" : {
+ "module" : "org.jboss.as.weld"
+ }
+ } ],
+ "compensating-operation" : null
+}
\ No newline at end of file
diff --git a/modules/plugins/jboss-as-7/src/test/resources/interfaces.json b/modules/plugins/jboss-as-7/src/test/resources/interfaces.json
new file mode 100644
index 0000000..d7d8461
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/interfaces.json
@@ -0,0 +1,8 @@
+{
+ "outcome" : "success",
+ "result" : {
+ "name" : "public",
+ "criteria" : "any-ipv4-address"
+ },
+ "compensating-operation" : null
+}
\ No newline at end of file
diff --git a/modules/plugins/jboss-as-7/src/test/resources/logging.json b/modules/plugins/jboss-as-7/src/test/resources/logging.json
new file mode 100644
index 0000000..aac32df
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/logging.json
@@ -0,0 +1,15 @@
+{
+ "outcome" : "success",
+ "result" : {
+ "autoflush" : true,
+ "encoding" : null,
+ "formatter" : "%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n",
+ "level" : "INFO",
+ "file" : {
+ "path" : "server.log",
+ "relative-to" : "jboss.server.log.dir"
+ },
+ "suffix" : ".yyyy-MM-dd"
+ },
+ "compensating-operation" : null
+}
\ No newline at end of file
diff --git a/modules/plugins/jboss-as-7/src/test/resources/loopback.json b/modules/plugins/jboss-as-7/src/test/resources/loopback.json
new file mode 100644
index 0000000..4aec543
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/loopback.json
@@ -0,0 +1,10 @@
+{
+ "outcome" : "success",
+ "result" : {
+ "name" : "default",
+ "criteria" : [ {
+ "inet-address" : "127.0.0.1"
+ } ]
+ },
+ "compensating-operation" : null
+}
\ No newline at end of file
diff --git a/modules/plugins/jboss-as-7/src/test/resources/schema-locations.json b/modules/plugins/jboss-as-7/src/test/resources/schema-locations.json
new file mode 100644
index 0000000..e9bf229
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/schema-locations.json
@@ -0,0 +1,50 @@
+{
+ "outcome" : "success",
+ "result" : {
+ "schema-locations" : [
+ {
+ "urn:jboss:domain:1.0" : "jboss_7_0.xsd"
+ }, {
+ "urn:jboss:domain:arquillian:1.0" : "jboss-arquillian.xsd"
+ }, {
+ "urn:jboss:domain:connector:1.0" : "jboss-connector.xsd"
+ }, {
+ "urn:jboss:domain:datasources:1.0" : "jboss-datasources.xsd"
+ }, {
+ "urn:jboss:domain:ejb3:1.0" : "jboss-ejb3.xsd"
+ }, {
+ "urn:jboss:domain:ee:1.0" : "jboss-ee.xsd"
+ }, {
+ "urn:jboss:domain:jaxrs:1.0" : "jboss-jaxrs.xsd"
+ }, {
+ "urn:jboss:domain:jmx:1.0" : "jboss-jmx.xsd"
+ }, {
+ "urn:jboss:domain:jpa:1.0" : "jboss-jpa.xsd"
+ }, {
+ "urn:jboss:domain:messaging:1.0" : "jboss-messaging.xsd"
+ }, {
+ "urn:jboss:domain:naming:1.0" : "jboss-naming.xsd"
+ }, {
+ "urn:jboss:domain:osgi:1.0" : "jboss-osgi.xsd"
+ }, {
+ "urn:jboss:domain:remoting:1.0" : "jboss-remoting.xsd"
+ }, {
+ "urn:jboss:domain:resourceadapters:1.0" : "jboss-resource-adapters.xsd"
+ }, {
+ "urn:jboss:domain:sar:1.0" : "jboss-sar.xsd"
+ }, {
+ "urn:jboss:domain:threads:1.0" : "jboss-threads.xsd"
+ }, {
+ "urn:jboss:domain:transactions:1.0" : "jboss-txn.xsd"
+ }, {
+ "urn:jboss:domain:web:1.0" : "jboss-web.xsd"
+ }, {
+ "urn:jboss:domain:security:1.0" : "jboss-security.xsd"
+ }, {
+ "urn:jboss:domain:webservices:1.0" : "jboss-webservices.xsd"
+ }, {
+ "urn:jboss:domain:weld:1.0" : "jboss-weld.xsd"
+ } ]
+ },
+ "compensating-operation" : null
+}
diff --git a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
index 4d3a106..fb06f1b 100644
--- a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
@@ -30,4 +30,63 @@
</server>
+ <server class="foo" discovery="foo" name="test4">
+ <resource-configuration>
+ <c:group name="children:extension" displayName="Installed extensions">
+
+ <c:list-property name="extension" displayName="Installed extensions">
+ <c:map-property name="name">
+ <c:map-property name="*">
+ <c:simple-property name="module"/>
+ </c:map-property>
+ </c:map-property>
+ </c:list-property>
+ </c:group>
+ </resource-configuration>
+ </server>
+
+ <server class="foo" discovery="foo" name="test5">
+ <resource-configuration>
+ <c:group name="attribute:schema-locations" displayName="Schema-locations">
+
+ <c:list-property name="schema-locations" displayName="Schema locations">
+ <c:map-property name="*">
+ <c:simple-property name="*" readOnly="true"/>
+ <!--<c:simple-property name="location" readOnly="true"/>-->
+ </c:map-property>
+ </c:list-property>
+ </c:group>
+ </resource-configuration>
+ </server>
+
+ <server class="foo" discovery="foo" name="test6and7">
+ <resource-configuration>
+
+ <c:simple-property name="name" />
+ <c:simple-property name="criteria"/>
+
+ </resource-configuration>
+ </server>
+
+ <server class="foo" discovery="foo" name="test8">
+ <resource-configuration>
+ <c:simple-property name="default-workmanager-short-running-thread-pool" required="true" type="string" readOnly="true"
+ description="Specify the name of short running thread pool"/>
+ <c:simple-property name="default-workmanager-long-running-thread-pool" required="true" type="string" readOnly="true"
+ description="Specify the name of long running thread pool"/>
+ <c:simple-property name="bean-validation-enabled" required="true" type="boolean" readOnly="true"
+ description="Specify whether bean validation is enabled"/>
+ <c:simple-property name="archive-validation-enabled" type="boolean" readOnly="true" description="Enabling the validation"/>
+ <c:simple-property name="archive-validation-fail-on-error" type="boolean" readOnly="true" defaultValue="true"
+ description="Should an archive validation error report fail the deployment. Default: true"/>
+ <c:simple-property name="archive-validation-fail-on-warn" type="boolean" readOnly="true" defaultValue="false"
+ description="Should an archive validation warning report fail the deployment. Default: false"/>
+ <c:simple-property name="cached-connection-manager-debug" type="boolean" readOnly="true" defaultValue="false"
+ description="enable/disable debug information logging for cached connection manager"/>
+ <c:simple-property name="cached-connection-manager-error" type="boolean" readOnly="true" defaultValue="false"
+ description="enable/disable error information logging for cached connection manager"/>
+ </resource-configuration>
+
+ </server>
+
</plugin>
\ No newline at end of file
diff --git a/modules/plugins/jboss-as-7/src/test/resources/threadpool.json b/modules/plugins/jboss-as-7/src/test/resources/threadpool.json
new file mode 100644
index 0000000..8107e9a
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/threadpool.json
@@ -0,0 +1,25 @@
+{
+ "outcome" : "success",
+ "result" : {
+ "name" : "ejb3-async",
+ "max-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "keepalive-time" : {
+ "time" : 10,
+ "unit" : "SECONDS"
+ },
+ "blocking" : true,
+ "allow-core-timeout" : false,
+ "queue-length" : {
+ "count" : 10,
+ "per-cpu" : 20
+ },
+ "core-threads" : {
+ "count" : 10,
+ "per-cpu" : 20
+ }
+ },
+ "compensating-operation" : null
+}
\ No newline at end of file
commit b349cdfe6aae9b8e25a466956d607b9bb901c2b7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon May 30 13:27:11 2011 +0200
Start adding unit tests for the configuration reading.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 7593f18..8611a15 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -218,6 +218,12 @@
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <version>${testng.version}</version>
+ <scope>test</scope>
+ </dependency>
<!-- TODO add your dependencies here -->
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 6cbe91b..c51f275 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -31,6 +31,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
@@ -46,6 +47,7 @@ public class ASConnection {
URL url;
String urlString;
private ObjectMapper mapper;
+ boolean verbose = true; // This is a variable on purpose, so devs can switch it on in the debugger
public ASConnection(String host, int port) {
@@ -74,7 +76,6 @@ public class ASConnection {
JsonNode reasonNode = in.findValue("failure-description");
String reason = reasonNode.getTextValue();
-// log.info(reason);
return true;
}
@@ -105,8 +106,10 @@ public class ASConnection {
OutputStream out = conn.getOutputStream();
String result = mapper.writeValueAsString(operation);
- System.out.println("Json to send: " + result);
- System.out.flush();
+ if (verbose) {
+ System.out.println("Json to send: " + result);
+ System.out.flush();
+ }
mapper.writeValue(out, operation);
out.flush();
@@ -134,6 +137,13 @@ public class ASConnection {
if (builder !=null) {
outcome= builder.toString();
operationResult = mapper.readTree(outcome);
+ if (verbose) {
+ ObjectMapper om2 = new ObjectMapper();
+ om2.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
+ String tmp = om2.writeValueAsString(operationResult);
+ System.out.println(tmp);
+ System.out.flush();
+ }
}
else {
outcome="- no response from server -";
@@ -146,6 +156,8 @@ public class ASConnection {
}
else {
log.error("IS was null and code was " + responseCode);
+ if (verbose)
+ System.err.println("IS was null and code was " + responseCode);
}
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 2911e85..779e733 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
@@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
@@ -209,7 +210,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
List<PROPERTY_VALUE> address = pathToAddress(path);
- ConfigurationDelegate delegate = new ConfigurationDelegate(context,connection,address);
+ ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
+ ConfigurationDelegate delegate = new ConfigurationDelegate(configDef,connection,address);
return delegate.loadResourceConfiguration();
}
@@ -217,7 +219,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
List<PROPERTY_VALUE> address = pathToAddress(path);
- ConfigurationDelegate delegate = new ConfigurationDelegate(context,connection,address);
+ ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
+ ConfigurationDelegate delegate = new ConfigurationDelegate(configDef,connection,address);
delegate.updateResourceConfiguration(report);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
index 832fd11..93f4c6e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
@@ -42,7 +42,6 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -51,18 +50,17 @@ import org.rhq.modules.plugins.jbossas7.json.ReadResource;
public class ConfigurationDelegate implements ConfigurationFacet {
final Log log = LogFactory.getLog(this.getClass());
- ResourceContext context;
private List<PROPERTY_VALUE> address;
private ASConnection connection;
+ private ConfigurationDefinition configurationDefinition;
- public ConfigurationDelegate(ResourceContext context,ASConnection connection, List<PROPERTY_VALUE> address) {
- this.context = context;
+ public ConfigurationDelegate(ConfigurationDefinition configDef,ASConnection connection, List<PROPERTY_VALUE> address) {
+ this.configurationDefinition = configDef;
this.connection = connection;
this.address = address;
}
public Configuration loadResourceConfiguration() throws Exception {
- ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
Operation op = new ReadResource(address); // TODO set recursive flag? --> try to narrow it down
@@ -72,13 +70,14 @@ public class ConfigurationDelegate implements ConfigurationFacet {
Configuration ret = new Configuration();
ObjectMapper mapper = new ObjectMapper();
- Set<Map.Entry<String, PropertyDefinition>> entrySet = configDef.getPropertyDefinitions().entrySet();
+ Set<Map.Entry<String, PropertyDefinition>> entrySet = configurationDefinition.getPropertyDefinitions().entrySet();
for (Map.Entry<String, PropertyDefinition> propDefEntry : entrySet) {
PropertyDefinition propDef = propDefEntry.getValue();
JsonNode sub = json.findValue(propDef.getName());
if (sub == null) {
- log.error(
- "No value for property [" + propDef.getName() + "] found - check the descriptor");
+ log.warn(
+ "No value for property [" + propDef.getName() + "] found - check the descriptor (may be valid, \n"+
+ "as some attributes are different in domain vs standalone mode");
continue;
}
if (propDef instanceof PropertyDefinitionSimple) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index c7a983e..a5583b7 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -31,6 +31,7 @@ import org.codehaus.jackson.annotate.JsonProperty;
*/
public class Result {
+ public static final String SUCCESS = "success";
private String outcome;
private Object result;
@JsonProperty("compensating-operation")
@@ -50,7 +51,7 @@ public class Result {
public void setOutcome(String outcome) {
this.outcome = outcome;
- if (outcome.equalsIgnoreCase("success"))
+ if (outcome.equalsIgnoreCase(SUCCESS))
success = true;
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationTest.java
new file mode 100644
index 0000000..afd6a7f
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/ConfigurationTest.java
@@ -0,0 +1,320 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.util.ValidationEventCollector;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+import org.rhq.core.clientapi.agent.metadata.ConfigurationMetadataParser;
+import org.rhq.core.clientapi.agent.metadata.InvalidPluginDescriptorException;
+import org.rhq.core.clientapi.descriptor.DescriptorPackages;
+import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.ConfigurationFormat;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+
+/**
+ * Tests loading and writing configurations
+ * @author Heiko W. Rupp
+ */
+@Test
+public class ConfigurationTest {
+
+ private static final String DESCRIPTOR_FILENAME = "test-plugin.xml";
+ private Log log = LogFactory.getLog(getClass());
+
+ private PluginDescriptor pluginDescriptor;
+
+
+
+ public void test1() throws Exception {
+ FakeConnection connection = new FakeConnection();
+
+ ConfigurationDefinition definition = new ConfigurationDefinition("foo","Test1");
+
+
+ definition.setConfigurationFormat(ConfigurationFormat.STRUCTURED);
+ definition.put(new PropertyDefinitionSimple("access-log", "Access-Log", false,
+ PropertySimpleType.STRING));
+ definition.put(new PropertyDefinitionSimple("rewrite", "Rewrite", false,
+ PropertySimpleType.STRING));
+ definition.put(new PropertyDefinitionSimple("notThere", "NotThere", false,
+ PropertySimpleType.STRING));
+
+ definition.put(new PropertyDefinitionList("alias", "Alias", true, new PropertyDefinitionSimple(
+ "alias", "alias", true, PropertySimpleType.STRING)));
+
+
+
+ String resultString = " {\"outcome\" : \"success\", \"result\" : {\"alias\" : [\"example.com\",\"example2.com\"],"+
+ " \"access-log\" : null, \"rewrite\" : null}, \"compensating-operation\" : null}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ connection.setContent(json);
+
+ ConfigurationDelegate delegate = new ConfigurationDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+
+ assert config.get("alias")!=null;
+ assert config.get("alias") instanceof PropertyList;
+ PropertyList aliases = (PropertyList) config.get("alias");
+ List<Property> list = aliases.getList();
+ assert list.size()==2;
+ assert config.get("notThere")==null;
+ }
+
+ public void test2() throws Exception {
+ String resultString = "{\n" +
+ " \"outcome\" : \"success\",\n" +
+ " \"result\" : {\n" +
+ " \"autoflush\" : true,\n" +
+ " \"encoding\" : null,\n" +
+ " \"formatter\" : \"%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n\",\n" +
+ " \"level\" : \"INFO\",\n" +
+ " \"file\" : {\n" +
+ " \"path\" : \"server.log\",\n" +
+ " \"relative-to\" : \"jboss.server.log.dir\"\n" +
+ " },\n" +
+ " \"suffix\" : \".yyyy-MM-dd\"\n" +
+ " },\n" +
+ " \"compensating-operation\" : null\n" +
+ "}";
+
+ FakeConnection connection = new FakeConnection();
+
+ ConfigurationDefinition definition = new ConfigurationDefinition("foo","Test1");
+
+ PropertyDefinitionSimple propertyDefinition = new PropertyDefinitionSimple("autoflush", "Autoflush", false,
+ PropertySimpleType.BOOLEAN);
+ propertyDefinition.setDefaultValue("true");
+ definition.put(propertyDefinition);
+ propertyDefinition = new PropertyDefinitionSimple("encoding", "Encoding", false,
+ PropertySimpleType.STRING);
+ propertyDefinition.setDefaultValue("HelloWorld");
+ definition.put(propertyDefinition);
+ PropertyDefinitionSimple pathProperty = new PropertyDefinitionSimple("path","File path",true,PropertySimpleType.STRING);
+ PropertyDefinitionSimple relativeToProperty = new PropertyDefinitionSimple("relative-to","Relative-To",true,PropertySimpleType.STRING);
+ PropertyDefinitionMap fileMapDef = new PropertyDefinitionMap("file","Log file",true,pathProperty,relativeToProperty);
+ definition.put(fileMapDef);
+
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ connection.setContent(json);
+
+ ConfigurationDelegate delegate = new ConfigurationDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+
+ assert config!=null;
+ assert config.get("autoflush")!=null : "Autoflush was null";
+ assert config.getSimple("autoflush").getBooleanValue() : "Autoflush was false";
+ PropertyMap fileMap = (PropertyMap) config.get("file");
+ assert fileMap!=null : "File Map was null";
+ PropertySimple path = (PropertySimple) fileMap.get("path");
+ assert path!=null : "File->path was null";
+ assert path.getStringValue().equals("server.log") : "File->path wrong";
+
+
+ }
+
+
+ public void test3() throws Exception {
+
+ String resultString = "{\n" +
+ " \"outcome\" : \"success\",\n" +
+ " \"result\" : {\n" +
+ " \"name\" : \"standard-sockets\",\n" +
+ " \"default-interface\" : \"default\",\n" +
+ " \"port-offset\" : \"0\",\n" +
+ " \"socket-binding\" : {\n" +
+ " \"jndi\" : {\n" +
+ " \"name\" : \"jndi\",\n" +
+ " \"interface\" : null,\n" +
+ " \"port\" : 1099,\n" +
+ " \"fixed-port\" : null,\n" +
+ " \"multicast-address\" : null,\n" +
+ " \"multicast-port\" : null\n" +
+ " },\n" +
+ " \"jmx-connector-registry\" : {\n" +
+ " \"name\" : \"jmx-connector-registry\",\n" +
+ " \"interface\" : null,\n" +
+ " \"port\" : 1090,\n" +
+ " \"fixed-port\" : null,\n" +
+ " \"multicast-address\" : null,\n" +
+ " \"multicast-port\" : null\n" +
+ " },\n" +
+ " \"jmx-connector-server\" : {\n" +
+ " \"name\" : \"jmx-connector-server\",\n" +
+ " \"interface\" : null,\n" +
+ " \"port\" : 1091,\n" +
+ " \"fixed-port\" : null,\n" +
+ " \"multicast-address\" : null,\n" +
+ " \"multicast-port\" : null\n" +
+ " },\n" +
+ " \"http\" : {\n" +
+ " \"name\" : \"http\",\n" +
+ " \"interface\" : null,\n" +
+ " \"port\" : 8080,\n" +
+ " \"fixed-port\" : null,\n" +
+ " \"multicast-address\" : null,\n" +
+ " \"multicast-port\" : null\n" +
+ " },\n" +
+ " \"https\" : {\n" +
+ " \"name\" : \"https\",\n" +
+ " \"interface\" : null,\n" +
+ " \"port\" : 8447,\n" +
+ " \"fixed-port\" : null,\n" +
+ " \"multicast-address\" : \"224.1.2.3\",\n" +
+ " \"multicast-port\" : 18447\n" +
+ " }"+
+ " }\n" +
+ " },\n" +
+ " \"compensating-operation\" : null\n" +
+ "}";
+
+ ConfigurationDefinition definition = loadDescriptor("socketBinding");
+
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ JsonNode json = mapper.valueToTree(result);
+
+ FakeConnection connection = new FakeConnection();
+ connection.setContent(json);
+
+ ConfigurationDelegate delegate = new ConfigurationDelegate(definition,connection,null);
+ Configuration config = delegate.loadResourceConfiguration();
+
+
+ assert config != null;
+ PropertyList propertyList = (PropertyList) config.get("socket-binding");
+ assert propertyList!=null;
+ List<Property> list = propertyList.getList();
+ assert list.size()==5;
+ for (Property prop : list) {
+ PropertyMap propMap2 = (PropertyMap) prop;
+ Map<String,Property> map2 = propMap2.getMap();
+ assert map2.size()==6;
+
+ assert map2.containsKey("port");
+ assert map2.containsKey("multicast-port");
+ assert map2.containsKey("multicast-address");
+
+ if (((PropertySimple)map2.get("name")).getStringValue().equals("https")) {
+ assert ((PropertySimple)map2.get("port")).getIntegerValue()==8447;
+ assert ((PropertySimple)map2.get("multicast-port")).getIntegerValue()==18447;
+ }
+ }
+
+ }
+
+
+
+ @BeforeSuite
+ private void loadPluginDescriptor() throws Exception {
+ try {
+ URL descriptorUrl = this.getClass().getClassLoader().getResource(DESCRIPTOR_FILENAME);
+ log.info("Loading plugin descriptor at: " + descriptorUrl);
+
+ JAXBContext jaxbContext = JAXBContext.newInstance(DescriptorPackages.PC_PLUGIN);
+
+ Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+ ValidationEventCollector vec = new ValidationEventCollector();
+ unmarshaller.setEventHandler(vec);
+ pluginDescriptor = (PluginDescriptor) unmarshaller.unmarshal(descriptorUrl.openStream());
+ } catch (Throwable t) {
+ // Catch RuntimeExceptions and Errors and dump their stack trace, because Surefire will completely swallow them
+ // and throw a cryptic NPE (see http://jira.codehaus.org/browse/SUREFIRE-157)!
+ t.printStackTrace();
+ throw new RuntimeException(t);
+ }
+ }
+
+ private ConfigurationDefinition loadDescriptor(String serverName) throws InvalidPluginDescriptorException {
+ List<ServerDescriptor> servers = pluginDescriptor.getServers();
+
+ ServerDescriptor serverDescriptor = findServer(serverName, servers);
+ assert serverDescriptor != null : "Server descriptor not found in test plugin descriptor";
+
+ return ConfigurationMetadataParser.parse("null", serverDescriptor.getResourceConfiguration());
+ }
+
+ private ServerDescriptor findServer(String name, List<ServerDescriptor> servers) {
+ for (ServerDescriptor server : servers) {
+ if (server.getName().equals(name)) {
+ return server;
+ }
+ }
+
+ return null;
+ }
+
+
+
+ /**
+ * Provide a fake connection, that will return the
+ * content we provide via #setContent
+ *
+ */
+ private class FakeConnection extends ASConnection {
+
+ JsonNode content;
+
+ public FakeConnection() {
+ super("localhost", 1234);
+ }
+
+ public void setContent(JsonNode content) {
+ this.content = content;
+ }
+
+ @Override
+ public JsonNode executeRaw(Operation operation) {
+ if (content==null)
+ throw new IllegalStateException("Content not yet set");
+ return content;
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
new file mode 100644
index 0000000..4d3a106
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/resources/test-plugin.xml
@@ -0,0 +1,33 @@
+<plugin name="jboss-as-7"
+ displayName="JBoss-AS-7-Plugin"
+ description="Management of JBossAS 7"
+ package="org.rhq.modules.plugins.jbossas7"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration"
+ version="4.0.0-SNAPSHOT"
+ >
+
+ <server class="foo" discovery="foo" name="socketBinding">
+ <resource-configuration>
+ <c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" />
+ <!-- note: at domain level there is no port-offset -->
+ <c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" required="false"/>
+ <c:list-property name="includes">
+ <c:simple-property name="includes" displayName="Included bindings" />
+ </c:list-property>
+ <c:list-property name="socket-binding">
+ <c:map-property name="binding">
+ <c:simple-property name="name" />
+ <c:simple-property name="interface" required="false"/>
+ <c:simple-property name="port" type="integer"/>
+ <c:simple-property name="fixed-port" type="boolean"/>
+ <c:simple-property name="multicast-address" />
+ <c:simple-property name="multicast-port" type="integer"/>
+ </c:map-property>
+ </c:list-property>
+ </resource-configuration>
+
+ </server>
+
+</plugin>
\ No newline at end of file
commit 757c9713212073198d9263a929367adf49dfa0eb
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 27 17:28:12 2011 +0200
Forgot the header
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
index f46ee38..832fd11 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
@@ -1,3 +1,21 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.modules.plugins.jbossas7;
import java.util.Iterator;
commit bee42224064975a937672a2bc4b9d3042c6e72bf
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 27 17:27:10 2011 +0200
Factor out configuration handling.
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 de53386..2911e85 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
@@ -21,20 +21,8 @@ package org.rhq.modules.plugins.jbossas7;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
-import org.rhq.core.domain.configuration.Property;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinition;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
-import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
-import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
@@ -58,7 +46,6 @@ import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
-import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
@@ -79,6 +66,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
{
private static final String INTERNAL = "_internal:";
private static final int INTERNAL_SIZE = INTERNAL.length();
+ private static final String LOCALHOST = "localhost";
+ private static final String DEFAULT_HTTP_MANAGEMENT_PORT = "9990";
final Log log = LogFactory.getLog(this.getClass());
ResourceContext context;
@@ -110,20 +99,17 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
this.context = context;
conf = context.getPluginConfiguration();
- // TODO add code to start the resource / connection to it
String typeName = context.getResourceType().getName();
- host = conf.getSimpleValue("hostname","localhost");
- String portString = conf.getSimpleValue("port","9990");
+ // TODO can we use parent's connection and only set this up for top level base component?
+ host = conf.getSimpleValue("hostname", LOCALHOST);
+ String portString = conf.getSimpleValue("port", DEFAULT_HTTP_MANAGEMENT_PORT);
port = Integer.parseInt(portString);
connection = new ASConnection(host,port);
path = conf.getSimpleValue("path", null);
key = context.getResourceKey();
-
-
-
myServerName = context.getResourceKey().substring(context.getResourceKey().lastIndexOf("/")+1);
@@ -157,7 +143,6 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
// Metrics from the application server
Operation op = new ReadAttribute(pathToAddress(path),req.getName()); // TODO batching
- //JsonNode obj = connection.executeRaw(op);
Result res = connection.execute(op, false);
if (!res.isSuccess())
continue;
@@ -221,266 +206,19 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
protected String getPath() { return path; }
- // TODO this needs completeion and a big fat refactoring
public Configuration loadResourceConfiguration() throws Exception {
- ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
-// String myPath = getResultingPath();
List<PROPERTY_VALUE> address = pathToAddress(path);
- Operation op = new ReadResource(address); // TOTO set recursive flag?
- op.addAdditionalProperty("recursive","true");
- JsonNode json = connection.executeRaw(op);
-
- Configuration ret = new Configuration();
- ObjectMapper mapper = new ObjectMapper();
-
- Set<Map.Entry<String, PropertyDefinition>> entrySet = configDef.getPropertyDefinitions().entrySet();
- for (Map.Entry<String,PropertyDefinition> propDefEntry: entrySet) {
- PropertyDefinition propDef = propDefEntry.getValue();
- JsonNode sub = json.findValue(propDef.getName());
- if (sub==null) {
- log.error("No value for property [" + propDef.getName() + "] found - check the descriptor");
- continue;
- }
- if (propDef instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple;
-
- if (sub!=null) {
- // Property is non-null -> return it.
- propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
- ret.put(propertySimple);
- }
- else {
- // property is null? Check if it is required
- if (propDef.isRequired()) {
- String defaultValue = ((PropertyDefinitionSimple) propDef).getDefaultValue();
- propertySimple = new PropertySimple(propDef.getName(),defaultValue);
- ret.put(propertySimple);
- }
- }
- } else if (propDef instanceof PropertyDefinitionList) {
- PropertyList propertyList = new PropertyList(propDef.getName());
- PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
- if (memberDefinition ==null) {
- if (sub.isObject()) {
- Iterator<String> fields = sub.getFieldNames();
- while(fields.hasNext()) {
- String fieldName = fields.next();
- JsonNode subNode = sub.get(fieldName);
- PropertySimple propertySimple = new PropertySimple(propDef.getName(),fieldName);
- propertyList.add(propertySimple);
- }
- } else {
- System.out.println("===Sub not object==="); // TODO evaluate this branch again
- Iterator<JsonNode> values = sub.getElements();
- while (values.hasNext()) {
- JsonNode node = values.next();
- String value = node.getTextValue();
- PropertySimple propertySimple = new PropertySimple(propDef.getName(),value);
- propertyList.add(propertySimple);
- }
- }
- }
- else if (memberDefinition instanceof PropertyDefinitionMap) {
- PropertySimple propertySimple;
-
- if (sub.isArray()) {
- Iterator<JsonNode> entries = sub.getElements();
- while (entries.hasNext()) {
- JsonNode entry = entries.next(); // -> one row in the list i.e. one map
-
- // Distinguish here?
-
- PropertyMap map = new PropertyMap(memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
- Iterator<JsonNode> fields = entry.getElements(); // TODO loop over fields from map and not from json
- while (fields.hasNext()) {
- JsonNode field = fields.next();
- if (field.isObject()) {
- // TODO only works for tuples at the moment - migrate to some different kind of parsing!
- PROPERTY_VALUE prop = mapper.readValue(field,PROPERTY_VALUE.class);
- // now need to find the names of the properties
- List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
- if (defList.isEmpty())
- throw new IllegalArgumentException("Map " + memberDefinition.getName() + " has no members");
- String key = defList.get(0).getName();
- String value = prop.getKey();
- propertySimple = new PropertySimple(key,value);
- map.put(propertySimple);
- if (defList.size()>1) {
- key = defList.get(1).getName();
- value = prop.getValue();
- propertySimple = new PropertySimple(key,value);
- map.put(propertySimple);
-
- }
- } else { // TODO reached?
- String key = field.getValueAsText();
- if (key.equals("PROPERTY_VALUE")) { // TODO this may change in the future in the AS implementation
- JsonNode pv = entry.findValue(key);
- String k = pv.toString();
- String v = pv.getValueAsText();
- propertySimple = new PropertySimple(k,v);
- map.put(propertySimple);
-
- }
- else {
- JsonNode value = entry.findValue(key);
- if (value!=null){
- propertySimple = new PropertySimple(key, value.getValueAsText());
- map.put(propertySimple);
- }
-
- }
- }
- }
- propertyList.add(map);
- }
- }
- else if (sub.isObject()) {
- Iterator<String> keys = sub.getFieldNames();
- while(keys.hasNext()) {
- String entryKey = keys.next();
-
- JsonNode node = sub.findPath(entryKey);
- PropertyMap map = new PropertyMap(memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
- if (node.isObject()) {
- Iterator<String> fields = node.getFieldNames(); // TODO loop over fields from map and not from json
- while (fields.hasNext()) {
- String key = fields.next();
-
- propertySimple = new PropertySimple(key,node.findValue(key).getValueAsText());
- map.put(propertySimple);
- }
- propertyList.add(map);
- } else if (sub.isNull()) {
- List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
- String key = defList.get(0).getName();
- propertySimple = new PropertySimple(key,entryKey);
- map.put(propertySimple);
- }
- }
-
- }
- }
- else if (memberDefinition instanceof PropertyDefinitionSimple) {
- String name = memberDefinition.getName();
- Iterator<JsonNode> keys = sub.getElements();
- while(keys.hasNext()) {
- JsonNode entry = keys.next();
-
- PropertySimple propertySimple = new PropertySimple(name,entry.getTextValue());
- propertyList.add(propertySimple);
- }
- }
- ret.put(propertyList);
- } // end List of ..
- else if (propDef instanceof PropertyDefinitionMap) {
- PropertyDefinitionMap mapDef = (PropertyDefinitionMap) propDef;
- PropertyMap pm = new PropertyMap(mapDef.getName());
-
- Map<String,PropertyDefinition> memberDefMap = mapDef.getPropertyDefinitions();
- for (Map.Entry<String,PropertyDefinition> maEntry : memberDefMap.entrySet()) {
- JsonNode valueNode = json.findValue(maEntry.getKey());
- Property p;
- if (maEntry.getValue() instanceof PropertyDefinitionSimple) {
- p = putProperty(valueNode, maEntry.getValue());
- pm.put(p);
- }
- else if (maEntry.getValue() instanceof PropertyDefinitionMap) { // TODO make this recursive?
-
- PropertyDefinitionMap pdm = (PropertyDefinitionMap) maEntry.getValue();
- Map<String,PropertyDefinition> mmDefMap = pdm.getPropertyDefinitions();
- for (Map.Entry<String,PropertyDefinition> mmDefEntry : mmDefMap.entrySet()) {
- if (valueNode!=null) {
- JsonNode node2 = valueNode.findValue(mmDefEntry.getKey());
- System.err.println("Map not yet implemented " + node2.toString());
- }
- else
- System.err.println("Value node was null " );
- }
- }
- else { // PropDefList
- System.err.println("List not yet implemented");
- }
-
-// pm.put(p);
- }
- ret.put(pm);
- }
- }
-
-
- return ret;
- }
-
-
- PropertySimple putProperty(JsonNode value, PropertyDefinition def) {
- String name = def.getName();
- PropertySimple ps;
-
- if (value==null) {
- if (def instanceof PropertyDefinitionSimple) {
- PropertyDefinitionSimple pds = (PropertyDefinitionSimple) def;
- return new PropertySimple(name,pds.getDefaultValue());
- }
- else
- return new PropertySimple(name,null);
- }
- PropertySimpleType type = ((PropertyDefinitionSimple) def).getType();
-
- switch (type) {
- case BOOLEAN:
- ps = new PropertySimple(name,value.getBooleanValue());
- break;
- case FLOAT:
- case DOUBLE:
- ps = new PropertySimple(name,value.getDoubleValue());
- break;
- case INTEGER:
- ps = new PropertySimple(name,value.getIntValue());
- break;
- case LONG:
- ps = new PropertySimple(name,value.getLongValue());
- break;
- default:
- ps = new PropertySimple(name,value.getTextValue());
- }
-
- return ps;
+ ConfigurationDelegate delegate = new ConfigurationDelegate(context,connection,address);
+ return delegate.loadResourceConfiguration();
}
- protected String getResultingPath() {
- ResourceComponent parentResourceComponent = context.getParentResourceComponent();
- String parentPath =null;
- String myPath;
- if (parentResourceComponent instanceof BaseComponent) {
- BaseComponent parentComponent = (BaseComponent) parentResourceComponent;
- parentPath = parentComponent.getPath();
- }
-
- if (parentPath!=null) {
- myPath = parentPath + "," + path;
- }
- else
- myPath = path;
- return myPath;
- }
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
-
- Configuration conf = report.getConfiguration();
- for (Map.Entry<String, PropertySimple> entry : conf.getSimpleProperties().entrySet()) {
-
- NameValuePair nvp = new NameValuePair(entry.getKey(),entry.getValue().getStringValue());
- Operation writeAttribute = new Operation("write-attribute",pathToAddress(getResultingPath()),nvp);
- JsonNode result= connection.executeRaw(writeAttribute);
- if(ASConnection.isErrorReply(result)) {
- report.setStatus(ConfigurationUpdateStatus.FAILURE);
- report.setErrorMessage(ASConnection.getFailureDescription(result));
- }
- }
-
+ List<PROPERTY_VALUE> address = pathToAddress(path);
+ ConfigurationDelegate delegate = new ConfigurationDelegate(context,connection,address);
+ delegate.updateResourceConfiguration(report);
}
/**
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
new file mode 100644
index 0000000..f46ee38
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
@@ -0,0 +1,282 @@
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.ReadResource;
+
+public class ConfigurationDelegate implements ConfigurationFacet {
+
+ final Log log = LogFactory.getLog(this.getClass());
+ ResourceContext context;
+ private List<PROPERTY_VALUE> address;
+ private ASConnection connection;
+
+ public ConfigurationDelegate(ResourceContext context,ASConnection connection, List<PROPERTY_VALUE> address) {
+ this.context = context;
+ this.connection = connection;
+ this.address = address;
+ }
+
+ public Configuration loadResourceConfiguration() throws Exception {
+ ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
+
+
+ Operation op = new ReadResource(address); // TODO set recursive flag? --> try to narrow it down
+ op.addAdditionalProperty("recursive", "true");
+ JsonNode json = connection.executeRaw(op);
+
+ Configuration ret = new Configuration();
+ ObjectMapper mapper = new ObjectMapper();
+
+ Set<Map.Entry<String, PropertyDefinition>> entrySet = configDef.getPropertyDefinitions().entrySet();
+ for (Map.Entry<String, PropertyDefinition> propDefEntry : entrySet) {
+ PropertyDefinition propDef = propDefEntry.getValue();
+ JsonNode sub = json.findValue(propDef.getName());
+ if (sub == null) {
+ log.error(
+ "No value for property [" + propDef.getName() + "] found - check the descriptor");
+ continue;
+ }
+ if (propDef instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple;
+
+ if (sub != null) {
+ // Property is non-null -> return it.
+ propertySimple = new PropertySimple(propDef.getName(), sub.getValueAsText());
+ ret.put(propertySimple);
+ } else {
+ // property is null? Check if it is required
+ if (propDef.isRequired()) {
+ String defaultValue = ((PropertyDefinitionSimple) propDef).getDefaultValue();
+ propertySimple = new PropertySimple(propDef.getName(), defaultValue);
+ ret.put(propertySimple);
+ }
+ }
+ } else if (propDef instanceof PropertyDefinitionList) {
+ PropertyList propertyList = new PropertyList(propDef.getName());
+ PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
+ if (memberDefinition == null) {
+ if (sub.isObject()) {
+ Iterator<String> fields = sub.getFieldNames();
+ while (fields.hasNext()) {
+ String fieldName = fields.next();
+ JsonNode subNode = sub.get(fieldName);
+ PropertySimple propertySimple = new PropertySimple(propDef.getName(), fieldName);
+ propertyList.add(propertySimple);
+ }
+ } else {
+ System.out.println("===Sub not object==="); // TODO evaluate this branch again
+ Iterator<JsonNode> values = sub.getElements();
+ while (values.hasNext()) {
+ JsonNode node = values.next();
+ String value = node.getTextValue();
+ PropertySimple propertySimple = new PropertySimple(propDef.getName(), value);
+ propertyList.add(propertySimple);
+ }
+ }
+ } else if (memberDefinition instanceof PropertyDefinitionMap) {
+ PropertySimple propertySimple;
+
+ if (sub.isArray()) {
+ Iterator<JsonNode> entries = sub.getElements();
+ while (entries.hasNext()) {
+ JsonNode entry = entries.next(); // -> one row in the list i.e. one map
+
+ // Distinguish here?
+
+ PropertyMap map = new PropertyMap(
+ memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
+ Iterator<JsonNode> fields = entry.getElements(); // TODO loop over fields from map and not from json
+ while (fields.hasNext()) {
+ JsonNode field = fields.next();
+ if (field.isObject()) {
+ // TODO only works for tuples at the moment - migrate to some different kind of parsing!
+ PROPERTY_VALUE prop = mapper.readValue(field, PROPERTY_VALUE.class);
+ // now need to find the names of the properties
+ List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
+ if (defList.isEmpty())
+ throw new IllegalArgumentException(
+ "Map " + memberDefinition.getName() + " has no members");
+ String key = defList.get(0).getName();
+ String value = prop.getKey();
+ propertySimple = new PropertySimple(key, value);
+ map.put(propertySimple);
+ if (defList.size() > 1) {
+ key = defList.get(1).getName();
+ value = prop.getValue();
+ propertySimple = new PropertySimple(key, value);
+ map.put(propertySimple);
+
+ }
+ } else { // TODO reached?
+ String key = field.getValueAsText();
+ if (key.equals(
+ "PROPERTY_VALUE")) { // TODO this may change in the future in the AS implementation
+ JsonNode pv = entry.findValue(key);
+ String k = pv.toString();
+ String v = pv.getValueAsText();
+ propertySimple = new PropertySimple(k, v);
+ map.put(propertySimple);
+
+ } else {
+ JsonNode value = entry.findValue(key);
+ if (value != null) {
+ propertySimple = new PropertySimple(key, value.getValueAsText());
+ map.put(propertySimple);
+ }
+
+ }
+ }
+ }
+ propertyList.add(map);
+ }
+ } else if (sub.isObject()) {
+ Iterator<String> keys = sub.getFieldNames();
+ while (keys.hasNext()) {
+ String entryKey = keys.next();
+
+ JsonNode node = sub.findPath(entryKey);
+ PropertyMap map = new PropertyMap(
+ memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
+ if (node.isObject()) {
+ Iterator<String> fields = node.getFieldNames(); // TODO loop over fields from map and not from json
+ while (fields.hasNext()) {
+ String key = fields.next();
+
+ propertySimple = new PropertySimple(key, node.findValue(key).getValueAsText());
+ map.put(propertySimple);
+ }
+ propertyList.add(map);
+ } else if (sub.isNull()) {
+ List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
+ String key = defList.get(0).getName();
+ propertySimple = new PropertySimple(key, entryKey);
+ map.put(propertySimple);
+ }
+ }
+
+ }
+ } else if (memberDefinition instanceof PropertyDefinitionSimple) {
+ String name = memberDefinition.getName();
+ Iterator<JsonNode> keys = sub.getElements();
+ while (keys.hasNext()) {
+ JsonNode entry = keys.next();
+
+ PropertySimple propertySimple = new PropertySimple(name, entry.getTextValue());
+ propertyList.add(propertySimple);
+ }
+ }
+ ret.put(propertyList);
+ } // end List of ..
+ else if (propDef instanceof PropertyDefinitionMap) {
+ PropertyDefinitionMap mapDef = (PropertyDefinitionMap) propDef;
+ PropertyMap pm = new PropertyMap(mapDef.getName());
+
+ Map<String, PropertyDefinition> memberDefMap = mapDef.getPropertyDefinitions();
+ for (Map.Entry<String, PropertyDefinition> maEntry : memberDefMap.entrySet()) {
+ JsonNode valueNode = json.findValue(maEntry.getKey());
+ Property p;
+ if (maEntry.getValue() instanceof PropertyDefinitionSimple) {
+ p = putProperty(valueNode, maEntry.getValue());
+ pm.put(p);
+ } else if (maEntry.getValue() instanceof PropertyDefinitionMap) { // TODO make this recursive?
+
+ PropertyDefinitionMap pdm = (PropertyDefinitionMap) maEntry.getValue();
+ Map<String, PropertyDefinition> mmDefMap = pdm.getPropertyDefinitions();
+ for (Map.Entry<String, PropertyDefinition> mmDefEntry : mmDefMap.entrySet()) {
+ if (valueNode != null) {
+ JsonNode node2 = valueNode.findValue(mmDefEntry.getKey());
+ System.err.println("Map not yet implemented " + node2.toString());
+ } else
+ System.err.println("Value node was null ");
+ }
+ } else { // PropDefList
+ System.err.println("List not yet implemented");
+ }
+
+// pm.put(p);
+ }
+ ret.put(pm);
+ }
+ }
+
+ return ret;
+ }
+
+ PropertySimple putProperty(JsonNode value, PropertyDefinition def) {
+ String name = def.getName();
+ PropertySimple ps;
+
+ if (value == null) {
+ if (def instanceof PropertyDefinitionSimple) {
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) def;
+ return new PropertySimple(name, pds.getDefaultValue());
+ } else
+ return new PropertySimple(name, null);
+ }
+ PropertySimpleType type = ((PropertyDefinitionSimple) def).getType();
+
+ switch (type) {
+ case BOOLEAN:
+ ps = new PropertySimple(name, value.getBooleanValue());
+ break;
+ case FLOAT:
+ case DOUBLE:
+ ps = new PropertySimple(name, value.getDoubleValue());
+ break;
+ case INTEGER:
+ ps = new PropertySimple(name, value.getIntValue());
+ break;
+ case LONG:
+ ps = new PropertySimple(name, value.getLongValue());
+ break;
+ default:
+ ps = new PropertySimple(name, value.getTextValue());
+ }
+
+ return ps;
+ }
+
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+
+ Configuration conf = report.getConfiguration();
+ for (Map.Entry<String, PropertySimple> entry : conf.getSimpleProperties().entrySet()) {
+
+ NameValuePair nvp = new NameValuePair(entry.getKey(), entry.getValue().getStringValue());
+ Operation writeAttribute = new Operation("write-attribute",
+ address, nvp); // TODO test path
+ JsonNode result = connection.executeRaw(writeAttribute);
+ if (ASConnection.isErrorReply(result)) {
+ report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ report.setErrorMessage(ASConnection.getFailureDescription(result));
+ }
+ }
+
+ }
+}
\ No newline at end of file
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 64251bc..45fa342 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
@@ -147,6 +147,19 @@
displayName="Maximum request time"/>
+ <resource-configuration>
+ <c:list-property name="schema-locations" displayName="Schema locations">
+ <c:map-property name="location">
+ <c:simple-property name="urn" readOnly="true"/>
+ <c:simple-property name="location" readOnly="true"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property name="extension" displayName="Installed extensions">
+ <c:simple-property name="name" readOnly="true"/>
+ </c:list-property>
+ </resource-configuration>
+
+
<server name="Profile"
description="One profile in a domain"
discovery="SubsystemDiscovery"
@@ -1334,7 +1347,7 @@ working area for individual server instances</li></ul>"/>
<resource-configuration>
<c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition" required="false"/>
<!-- note: at domain level there is no port-offset -->
- <c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group" required="false"/>
+ <c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group (Only relevant in standalone mode)" required="false"/>
<c:list-property name="includes">
<c:simple-property name="includes" displayName="Included bindings" description="Other bindings that are included in this one"/>
</c:list-property>
commit 9f451a121d42096a317bf4b645d740010d811af4
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 27 14:45:01 2011 +0200
Improve connection and (failure) result handling.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 5f350c0..6cbe91b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -87,7 +87,8 @@ public class ASConnection {
}
/**
- * Execute an operation against the domain api
+ * Execute an operation against the domain api. This method is doing the
+ * real work by talking to the remote server.
* @return JsonNode that describes the result
* @param operation an Operation that should be run on the domain controller
*/
@@ -136,6 +137,10 @@ public class ASConnection {
}
else {
outcome="- no response from server -";
+ Result noResult = new Result();
+ noResult.setFailureDescription(outcome);
+ noResult.setOutcome("failure");
+ operationResult = mapper.valueToTree(noResult);
}
return operationResult;
}
@@ -146,6 +151,14 @@ public class ASConnection {
} catch (IOException e) {
log.error("Failed to get data: " + e.getMessage() );
+
+ Result failure = new Result();
+ failure.setFailureDescription(e.getMessage());
+ failure.setOutcome("failure");
+
+ JsonNode ret = mapper.valueToTree(failure);
+ return ret;
+
} finally {
if (br!=null)
try {
@@ -189,29 +202,6 @@ public class ASConnection {
}
- private URL getBaseUrl(String base, String ops) throws MalformedURLException {
- String spec;
- URL url2;
- if (base!=null && !base.isEmpty()) {
- if (!base.startsWith("/")) {
- spec = urlString + "/" + base;
- }
- else {
- spec = urlString + base;
- }
- if (ops!=null) {
- if (!ops.startsWith("?"))
- ops = "?" + ops;
- spec += ops;
- }
-
- url2 = new URL(spec);
- }
- else
- url2 = url;
- return url2;
- }
-
public static String getFailureDescription(JsonNode jsonNode) {
if (jsonNode==null)
return "getFailureDescription: -input was null-";
commit 490d4f8556704540a5740e6244c581aa077fb616
Merge: 1831a12 054ba69
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 26 21:01:05 2011 +0200
Merge branch 'master' into as7plugin
commit 1831a12d39873b64e0f4a07be6f274fc40c4a5cb
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 26 17:57:31 2011 +0200
Add some stats on processing times.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index d86b365..5f350c0 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -95,7 +95,9 @@ public class ASConnection {
InputStream inputStream = null;
BufferedReader br=null;
+ long t1 = System.currentTimeMillis();
try {
+
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
@@ -135,11 +137,10 @@ public class ASConnection {
else {
outcome="- no response from server -";
}
-// System.out.println("==> " + outcome);
return operationResult;
}
else {
- System.err.println("IS was null and code was " + responseCode);
+ log.error("IS was null and code was " + responseCode);
}
@@ -152,6 +153,10 @@ public class ASConnection {
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
}
+ long t2 = System.currentTimeMillis();
+ PluginStats stats = PluginStats.getInstance();
+ stats.incrementRequestCount();
+ stats.addRequestTime(t2-t1);
}
return null;
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 ecb3fd6..de53386 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
@@ -77,6 +77,8 @@ import java.util.Set;
public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet,
CreateChildResourceFacet, OperationFacet
{
+ private static final String INTERNAL = "_internal:";
+ private static final int INTERNAL_SIZE = INTERNAL.length();
final Log log = LogFactory.getLog(this.getClass());
ResourceContext context;
@@ -149,31 +151,68 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (MeasurementScheduleRequest req : metrics) {
- Operation op = new ReadAttribute(pathToAddress(path),req.getName()); // TODO batching
- //JsonNode obj = connection.executeRaw(op);
- Result res = connection.execute(op, false);
- if (!res.isSuccess())
- continue;
-
- String val = (String) res.getResult();
-
- if (req.getDataType()== DataType.MEASUREMENT) {
- if (!val.equals("no metrics available")) { // AS 7 returns this
- try {
- Double d = Double.parseDouble(val);
- MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
- report.addData(data);
- } catch (NumberFormatException e) {
- log.warn("Non numeric input for [" + req.getName() + "] : [" + val + "]");
+ if (req.getName().startsWith(INTERNAL))
+ processPluginStats(req,report);
+ else {
+ // Metrics from the application server
+
+ Operation op = new ReadAttribute(pathToAddress(path),req.getName()); // TODO batching
+ //JsonNode obj = connection.executeRaw(op);
+ Result res = connection.execute(op, false);
+ if (!res.isSuccess())
+ continue;
+
+ String val = (String) res.getResult();
+
+ if (req.getDataType()== DataType.MEASUREMENT) {
+ if (!val.equals("no metrics available")) { // AS 7 returns this
+ try {
+ Double d = Double.parseDouble(val);
+ MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
+ report.addData(data);
+ } catch (NumberFormatException e) {
+ log.warn("Non numeric input for [" + req.getName() + "] : [" + val + "]");
+ }
}
+ } else if (req.getDataType()== DataType.TRAIT) {
+ MeasurementDataTrait data = new MeasurementDataTrait(req,val);
+ report.addData(data);
}
- } else if (req.getDataType()== DataType.TRAIT) {
- MeasurementDataTrait data = new MeasurementDataTrait(req,val);
- report.addData(data);
}
}
}
+ /**
+ * Return internal statistics data
+ * @param req Schedule for the requested data
+ * @param report report to add th data to.
+ */
+ private void processPluginStats(MeasurementScheduleRequest req, MeasurementReport report) {
+
+ String name = req.getName();
+ if (!name.startsWith(INTERNAL))
+ return;
+
+ name = name.substring(INTERNAL_SIZE);
+
+ PluginStats stats = PluginStats.getInstance();
+ MeasurementDataNumeric data;
+ Double val;
+ if (name.equals("mgmtRequests")) {
+ val= (double) stats.getRequestCount();
+ }
+ else if (name.equals("requestTime")) {
+ val =(double) stats.getRequestTime();
+ }
+ else if (name.equals("maxTime")) {
+ val = (double) stats.getMaxTime();
+ }
+ else
+ val = Double.NaN;
+
+ data = new MeasurementDataNumeric(req,val);
+ report.addData(data);
+ }
protected ASConnection getASConnection() {
return connection;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/PluginStats.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/PluginStats.java
new file mode 100644
index 0000000..1a44dde
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/PluginStats.java
@@ -0,0 +1,61 @@
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Singleton that keeps track of some statistics of this plugin
+ * @author Heiko W. Rupp
+ */
+public class PluginStats {
+ private static PluginStats ourInstance = new PluginStats();
+
+ AtomicLong requestCount = new AtomicLong();
+ AtomicLong requestTime = new AtomicLong();
+ private static final int FIFO_SIZE = 200; // Initial capacity
+ List<Long> maxTime = new ArrayList<Long>(FIFO_SIZE);
+ final Object lock = new Object();
+
+
+ public static PluginStats getInstance() {
+ return ourInstance;
+ }
+
+ private PluginStats() {
+ }
+
+ public void incrementRequestCount() {
+ requestCount.incrementAndGet();
+ }
+
+ public void addRequestTime(long l) {
+ requestTime.addAndGet(l);
+ insertTime(l);
+ }
+
+ public long getRequestCount() {
+ return requestCount.get();
+ }
+
+ public long getRequestTime() {
+ return requestTime.get();
+ }
+
+ public long getMaxTime() {
+ long max = 0;
+ synchronized (lock) {
+ for (Long i : maxTime)
+ if (i > max )
+ max = i;
+ maxTime = new ArrayList<Long>();
+ }
+ return max;
+ }
+
+ private void insertTime(long time) {
+ synchronized (lock) {
+ maxTime.add(time);
+ }
+ }
+}
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 75484c8..64251bc 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
@@ -135,6 +135,18 @@
</operation>
+ <metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000"
+ displayType="summary" measurementType="trendsup" description="Number of requests sent to the controller"
+ displayName="Number of management requests"
+ />
+ <metric property="_internal:requestTime" category="performance" dataType="measurement" defaultInterval="120000"
+ displayType="summary" measurementType="trendsup" description="Total time for requests" units="milliseconds"
+ displayName="Time used for management requests"/>
+ <metric property="_internal:maxTime" category="performance" dataType="measurement" defaultInterval="120000"
+ displayType="summary" measurementType="dynamic" description="Max time for a request since last metric get" units="milliseconds"
+ displayName="Maximum request time"/>
+
+
<server name="Profile"
description="One profile in a domain"
discovery="SubsystemDiscovery"
@@ -237,6 +249,16 @@
<process-scan name="StandaloneAS" query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
+ <metric property="_internal:mgmtRequests" category="performance" dataType="measurement" defaultInterval="120000"
+ displayType="summary" measurementType="trendsup" description="Number of requests sent to the controller"
+ displayName="Number of management requests"/>
+ <metric property="_internal:requestTime" category="performance" dataType="measurement" defaultInterval="120000"
+ displayType="summary" measurementType="trendsup" description="Total time for requests" units="milliseconds"
+ displayName="Time used for management requests"/>
+ <metric property="_internal:maxTime" category="performance" dataType="measurement" defaultInterval="120000"
+ displayType="summary" measurementType="dynamic" description="Max time for a request since last metric get" units="milliseconds"
+ displayName="Maximum request time"/>
+
<resource-configuration>
<c:list-property name="schema-locations" displayName="Schema locations">
@@ -618,9 +640,9 @@
description="Should an archive validation error report fail the deployment. Default: true"/>
<c:simple-property name="archive-validation-fail-on-warn" type="boolean" readOnly="true" default="false"
description="Should an archive validation warning report fail the deployment. Default: false"/>
- <c:simple-property name="cached-connection-manager-debug" type="boolean" readOnly="true"
+ <c:simple-property name="cached-connection-manager-debug" type="boolean" readOnly="true" default="false"
description="enable/disable debug information logging for cached connection manager"/>
- <c:simple-property name="cached-connection-manager-error" type="boolean" readOnly="true"
+ <c:simple-property name="cached-connection-manager-error" type="boolean" readOnly="true" default="false"
description="enable/disable error information logging for cached connection manager"/>
</resource-configuration>
@@ -937,15 +959,15 @@
<c:simple-property name="path" required="true" type="string" readOnly="false" description="The filesystem path."/>
<c:simple-property name="relative-to" required="false" type="string" readOnly="false"
description="The name of another previously named path, or of one of the standard paths provided by the system.
- If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
- The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
- distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
- working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
- root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
- use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
- log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
- storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
- working area for individual server instances</li></ul>"/>
+If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
+The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
+distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
+working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
+root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
+use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
+log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
+storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
+working area for individual server instances</li></ul>"/>
</parameters>
</operation>
<resource-configuration>
@@ -1001,15 +1023,15 @@
<c:simple-property name="path" required="true" type="string" readOnly="false" description="The filesystem path."/>
<c:simple-property name="relative-to" required="false" type="string" readOnly="false"
description="The name of another previously named path, or of one of the standard paths provided by the system.
- If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
- The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
- distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
- working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
- root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
- use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
- log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
- storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
- working area for individual server instances</li></ul>"/>
+If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
+The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
+distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
+working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
+root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
+use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
+log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
+storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
+working area for individual server instances</li></ul>"/>
</parameters>
</operation>
<resource-configuration>
@@ -1023,14 +1045,14 @@
<c:simple-property name="append" required="false" type="boolean" readOnly="true" description="Specify whether to append to the target file."/>
<c:map-property name="file" description="null" >
<c:simple-property name="relative-to" required="false" type="string" readOnly="true" description="The name of another previously named path, or of one of the standard paths
- provided by the system. If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path
- specified by this attribute. The standard paths provided by the system include:<ul><li>jboss.home - the root directory
- of the JBoss AS distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current working
- directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir - root directory for an
- individual server instance</li><li>jboss.server.data.dir - directory the server will use for persistent data file
- storage</li><li>jboss.server.log.dir - directory the server will use for log file storage</li><li>jboss.server.tmp.dir -
- directory the server will use for temporary file storage</li><li>jboss.domain.servers.dir - directory under which a host controller
- will create the working area for individual server instances</li></ul>"/>
+provided by the system. If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path
+specified by this attribute. The standard paths provided by the system include:<ul><li>jboss.home - the root directory
+of the JBoss AS distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current working
+directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir - root directory for an
+individual server instance</li><li>jboss.server.data.dir - directory the server will use for persistent data file
+storage</li><li>jboss.server.log.dir - directory the server will use for log file storage</li><li>jboss.server.tmp.dir -
+directory the server will use for temporary file storage</li><li>jboss.domain.servers.dir - directory under which a host controller
+will create the working area for individual server instances</li></ul>"/>
<c:simple-property name="path" required="false" type="string" readOnly="true" description="The filesystem path."/>
</c:map-property>
<c:simple-property name="suffix" required="false" type="string" readOnly="true" description="Set the suffix string. The string is in a format which
@@ -1072,15 +1094,15 @@
<c:simple-property name="path" required="true" type="string" readOnly="false" description="The filesystem path."/>
<c:simple-property name="relative-to" required="false" type="string" readOnly="false"
description="The name of another previously named path, or of one of the standard paths provided by the system.
- If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
- The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
- distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
- working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
- root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
- use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
- log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
- storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
- working area for individual server instances</li></ul>"/>
+If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
+The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
+distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
+working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
+root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
+use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
+log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
+storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
+working area for individual server instances</li></ul>"/>
</parameters>
</operation>
<resource-configuration>
@@ -1157,7 +1179,12 @@
<resource-configuration>
<c:simple-property name="extends" required="false" type="string" readOnly="true" description="The parent security domain"/>
<c:simple-property name="cache-type" required="false" type="string" readOnly="true"
- description="Adds a cache to speed up authentication checks. Allowed values are 'default' to use simple map as the cache and 'infinispan' to use an Infinispan cache."/>
+ description="Adds a cache to speed up authentication checks. Allowed values are 'default' to use simple map as the cache and 'infinispan' to use an Infinispan cache.">
+ <c:property-options>
+ <c:option value="default"/>
+ <c:option value="infinispan"/>
+ </c:property-options>
+ </c:simple-property>
</resource-configuration>
</service>
commit 7a7c767c359f82a92056ad4a92ca8cc363ab9bcc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 25 13:21:43 2011 +0200
Get availability by checking if the resource is readable.
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 f35720e..ecb3fd6 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
@@ -93,8 +93,11 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
*/
public AvailabilityType getAvailability() {
- // TODO supply real implementation
- return AvailabilityType.UP;
+
+ ReadResource op = new ReadResource(pathToAddress(path));
+ Result res = connection.execute(op);
+
+ return res.isSuccess()? AvailabilityType.UP: AvailabilityType.DOWN;
}
@@ -179,6 +182,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
protected String getPath() { return path; }
+ // TODO this needs completeion and a big fat refactoring
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
// String myPath = getResultingPath();
commit 461ef8d5b0b2ec61584dd72b1aae39eef031ec3f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 25 12:00:20 2011 +0200
Support for the logging subsystem and make deployments available for standalone mode too.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 5c0a499..d86b365 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -135,7 +135,7 @@ public class ASConnection {
else {
outcome="- no response from server -";
}
- System.out.println("==> " + outcome);
+// System.out.println("==> " + outcome);
return operationResult;
}
else {
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 cbc2893..f35720e 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
@@ -281,8 +281,11 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
else {
- propertySimple = new PropertySimple(key,entry.findValue(key).getValueAsText());
- map.put(propertySimple);
+ JsonNode value = entry.findValue(key);
+ if (value!=null){
+ propertySimple = new PropertySimple(key, value.getValueAsText());
+ map.put(propertySimple);
+ }
}
}
@@ -367,9 +370,9 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
return ret;
}
+
PropertySimple putProperty(JsonNode value, PropertyDefinition def) {
String name = def.getName();
- PropertySimpleType type = ((PropertyDefinitionSimple) def).getType();
PropertySimple ps;
if (value==null) {
@@ -380,6 +383,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
else
return new PropertySimple(name,null);
}
+ PropertySimpleType type = ((PropertyDefinitionSimple) def).getType();
switch (type) {
case BOOLEAN:
@@ -572,7 +576,12 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
resourceKey = addressToPath(serverGroupAddress);
}
else {
- resourceKey = addressToPath(step1.getAddress());
+
+ List<PROPERTY_VALUE> address = step1.getAddress();
+ Operation step3 = new Operation("deploy",address);
+ cop.addStep(step3);
+
+ resourceKey = addressToPath(address);
}
JsonNode result = connection.executeRaw(cop);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/LoggerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/LoggerComponent.java
new file mode 100644
index 0000000..f0d5e89
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/LoggerComponent.java
@@ -0,0 +1,69 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tools.ant.taskdefs.Sleep;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+
+/**
+ * Component class that deals with the Logging subsystem
+ * @author Heiko W. Rupp
+ */
+public class LoggerComponent extends BaseComponent {
+
+ private final Log log = LogFactory.getLog(LoggerComponent.class);
+
+ @Override
+ public OperationResult invokeOperation(String name,
+ Configuration parameters) throws InterruptedException, Exception {
+
+ Operation op = new Operation(name,pathToAddress(getPath()));
+
+ Map<String,Property> propertyMap = parameters.getAllProperties();
+ for (Map.Entry<String,Property> entry : propertyMap.entrySet()) {
+ PropertySimple ps = (PropertySimple) entry.getValue();
+ op.addAdditionalProperty(entry.getKey(),ps.getStringValue());
+ }
+
+
+ ASConnection conn = getASConnection();
+ ComplexResult result = conn.executeComplex(op);
+
+ if (result.isSuccess()) {
+ return new OperationResult("ok");
+ }
+ else {
+ OperationResult failure = new OperationResult();
+ failure.setErrorMessage(result.getFailureDescription().toString());
+ return failure;
+ }
+
+
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index a50ea45..a3ab676 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -134,8 +134,11 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
if (path==null||path.isEmpty())
resKey = newPath;
- else
+ else {
+ if (path.startsWith(","))
+ path = path.substring(1);
resKey = path + "," +childType + "=" + val;
+ }
PropertySimple pathProp = new PropertySimple("path",resKey);
config2.put(pathProp);
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 d7055a3..75484c8 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
@@ -162,24 +162,6 @@
<c:simple-property name="jvm" required="false"/>
</resource-configuration>
- <service name="Deployment"
- class="BaseComponent"
- discovery="SubsystemDiscovery"
- createDeletePolicy="both"
- creationDataType="content">
- <plugin-configuration>
- <c:simple-property name="path" default="deployment" readOnly="true"/>
- </plugin-configuration>
-
- <content name="file" category="deployable" isCreationType="true" description="Deployments on this server group">
- <configuration>
- <c:group name="deployment" displayName="Deployment Options">
- <c:simple-property name="runtimeName" required="true"/>
- </c:group>
- </configuration>
- </content>
-
- </service>
</server>
<server name="Host"
description="Host involved in this domain"
@@ -375,6 +357,7 @@
<c:simple-property name="journal-type" />
</resource-configuration>
+ <!-- this is no child resource TODO
<service name="Acceptor"
discovery="SubsystemDiscovery"
@@ -392,7 +375,6 @@
<c:simple-property name="path" readOnly="true" default="connector"/>
</plugin-configuration>
</service>
-<!-- this is no child resource
<service name="HQueue"
discovery="SubsystemDiscovery"
class="BaseComponent"
@@ -512,9 +494,9 @@
<metric property="bytesSent" measurementType="trendsup"/>
<metric property="bytesReceived" measurementType="trendsup"/>
- <metric property="processingTime" measurementType="trendsup"/>
+ <metric property="processingTime" measurementType="trendsup" units="milliseconds"/>
<metric property="errorCount" measurementType="trendsup" displayType="summary"/>
- <metric property="maxTime" />
+ <metric property="maxTime" units="milliseconds"/>
<metric property="requestCount" measurementType="trendsup" displayType="summary"/>
<resource-configuration>
@@ -819,6 +801,305 @@
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="subsystem=logging"/>
</plugin-configuration>
+
+ <operation name="change-root-log-level" description="Change the root logger level.">
+ <parameters>
+ <c:simple-property name="level" required="true" type="string" readOnly="false"
+ description="The log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded.">
+ <c:property-options>
+ <c:option value="FATAL"/>
+ <c:option value="ERROR"/>
+ <c:option value="WARN"/>
+ <c:option value="INFO"/>
+ <c:option value="DEBUG"/>
+ <c:option value="TRACE"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ </operation>
+
+ <operation name="remove-root-logger" description="Remove the root logger.">
+ </operation>
+
+ <operation name="set-root-logger" description="Set the root logger.">
+ <parameters>
+ <c:simple-property name="level" required="true" type="string" readOnly="false"
+ description="The log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded.">
+ <c:property-options>
+ <c:option value="FATAL"/>
+ <c:option value="ERROR"/>
+ <c:option value="WARN"/>
+ <c:option value="INFO"/>
+ <c:option value="DEBUG"/>
+ <c:option value="TRACE"/>
+ </c:property-options>
+ </c:simple-property>
+
+ <c:list-property name="handlers" required="true" readOnly="false"
+ description="The Handlers associated with this Logger.">
+ <c:simple-property name="handler" type="string"/>
+ </c:list-property>
+ </parameters>
+ </operation>
+
+ <resource-configuration>
+ <c:map-property name="root-logger" description="The root logger for this log context.">
+ <c:simple-property name="level" readOnly="true"
+ description="The log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded." />
+ <c:list-property name="handlers" readOnly="true">
+ <c:simple-property name="handler" readOnly="true" description="The Handlers associated with this Logger."/>
+ </c:list-property>
+ </c:map-property>
+ </resource-configuration>
+
+
+ <service name="ConsoleHandler"
+ discovery="SubsystemDiscovery"
+ class="LoggerComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="console-handler"/>
+ </plugin-configuration>
+
+ <operation name="change-log-level" description="Change the logging level for a handler.">
+ <parameters>
+ <c:simple-property name="level" required="true" type="string" readOnly="false"
+ description="The log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded.">
+ <c:property-options>
+ <c:option value="FATAL"/>
+ <c:option value="ERROR"/>
+ <c:option value="WARN"/>
+ <c:option value="INFO"/>
+ <c:option value="DEBUG"/>
+ <c:option value="TRACE"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ </operation>
+
+ <operation name="disable" description="Disable a logging handler.">
+ </operation>
+
+ <operation name="enable" description="Enable a logging handler.">
+ </operation>
+
+ <resource-configuration>
+ <c:simple-property name="name" required="false" type="string" readOnly="true" description="The handler's name."/>
+ <c:simple-property name="level" required="false" type="string" readOnly="true"
+ description="The log level specifying which message levels will be logged by this. Message levels lower than this value will be discarded. "/>
+ <c:simple-property name="encoding" required="false" type="string" readOnly="true"
+ description="The character encoding used by this Handler."/>
+ <c:simple-property name="filter" required="false" type="string" readOnly="true" description="Defines a simple filter type."/>
+ <c:simple-property name="formatter" required="false" type="string" readOnly="true" description="Defines a formatter."/>
+ <c:simple-property name="autoflush" required="false" type="boolean" readOnly="true" description="Automatically flush after each write."/>
+ <c:simple-property name="target" required="false" type="string" readOnly="true"
+ description="Defines the target of the console handler. The value can either be SYSTEM_OUT or SYSTEM_ERR.">
+ <c:property-options>
+ <c:option value="SYSTEM_OUT"/>
+ <c:option value="SYSTEM_ERR"/>
+ </c:property-options>
+ </c:simple-property>
+ </resource-configuration>
+ </service>
+
+ <service name="FileHandler"
+ discovery="SubsystemDiscovery"
+ class="LoggerComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="file-handler"/>
+ </plugin-configuration>
+
+ <operation name="change-log-level" description="Change the logging level for a handler.">
+ <parameters>
+ <c:simple-property name="level" required="true" type="string" readOnly="false"
+ description="The log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded.">
+ <c:property-options>
+ <c:option value="FATAL"/>
+ <c:option value="ERROR"/>
+ <c:option value="WARN"/>
+ <c:option value="INFO"/>
+ <c:option value="DEBUG"/>
+ <c:option value="TRACE"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ </operation>
+
+ <operation name="disable" description="Disable a logging handler.">
+ </operation>
+
+ <operation name="enable" description="Enable a logging handler.">
+ </operation>
+
+ <operation name="change-file" description="Change the file for a handler.">
+ <parameters>
+ <c:simple-property name="path" required="true" type="string" readOnly="false" description="The filesystem path."/>
+ <c:simple-property name="relative-to" required="false" type="string" readOnly="false"
+ description="The name of another previously named path, or of one of the standard paths provided by the system.
+ If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
+ The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
+ distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
+ working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
+ root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
+ use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
+ log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
+ storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
+ working area for individual server instances</li></ul>"/>
+ </parameters>
+ </operation>
+ <resource-configuration>
+ <c:simple-property name="name" required="false" type="string" readOnly="true" description="The handler's name."/>
+ <c:simple-property name="level" required="false" type="string" readOnly="true"
+ description="The log level specifying which message levels will be logged by this. Message levels lower than this value will be discarded. "/>
+ <c:simple-property name="encoding" required="false" type="string" readOnly="true"
+ description="The character encoding used by this Handler."/>
+ <c:simple-property name="filter" required="false" type="string" readOnly="true" description="Defines a simple filter type."/>
+ <c:simple-property name="formatter" required="false" type="string" readOnly="true" description="Defines a formatter."/>
+ <c:simple-property name="autoflush" required="false" type="boolean" readOnly="true" description="Automatically flush after each write."/>
+ <c:simple-property name="target" required="false" type="string" readOnly="true"
+ description="Defines the target of the console handler. The value can either be SYSTEM_OUT or SYSTEM_ERR.">
+ <c:property-options>
+ <c:option value="SYSTEM_OUT"/>
+ <c:option value="SYSTEM_ERR"/>
+ </c:property-options>
+ </c:simple-property>
+ </resource-configuration>
+ </service>
+ <service name="PeriodicRotatingFileHandler"
+ discovery="SubsystemDiscovery"
+ class="LoggerComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="periodic-rotating-file-handler"/>
+ </plugin-configuration>
+
+ <operation name="change-log-level" description="Change the logging level for a handler.">
+ <parameters>
+ <c:simple-property name="level" required="true" type="string" readOnly="false"
+ description="The log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded.">
+ <c:property-options>
+ <c:option value="FATAL"/>
+ <c:option value="ERROR"/>
+ <c:option value="WARN"/>
+ <c:option value="INFO"/>
+ <c:option value="DEBUG"/>
+ <c:option value="TRACE"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ </operation>
+
+ <operation name="disable" description="Disable a logging handler.">
+ </operation>
+
+ <operation name="enable" description="Enable a logging handler.">
+ </operation>
+
+ <operation name="change-file" description="Change the file for a handler.">
+ <parameters>
+ <c:simple-property name="path" required="true" type="string" readOnly="false" description="The filesystem path."/>
+ <c:simple-property name="relative-to" required="false" type="string" readOnly="false"
+ description="The name of another previously named path, or of one of the standard paths provided by the system.
+ If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
+ The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
+ distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
+ working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
+ root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
+ use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
+ log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
+ storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
+ working area for individual server instances</li></ul>"/>
+ </parameters>
+ </operation>
+ <resource-configuration>
+ <c:simple-property name="name" required="false" type="string" readOnly="true" description="The handler's name."/>
+ <c:simple-property name="level" required="false" type="string" readOnly="true" description="The log level specifying which message levels will be logged by this.
+ Message levels lower than this value will be discarded. "/>
+ <c:simple-property name="encoding" required="false" type="string" readOnly="true" description="The character encoding used by this Handler."/>
+ <c:simple-property name="filter" required="false" type="string" readOnly="true" description="Defines a simple filter type."/>
+ <c:simple-property name="formatter" required="false" type="string" readOnly="true" description="Defines a formatter."/>
+ <c:simple-property name="autoflush" required="false" type="boolean" readOnly="true" description="Automatically flush after each write."/>
+ <c:simple-property name="append" required="false" type="boolean" readOnly="true" description="Specify whether to append to the target file."/>
+ <c:map-property name="file" description="null" >
+ <c:simple-property name="relative-to" required="false" type="string" readOnly="true" description="The name of another previously named path, or of one of the standard paths
+ provided by the system. If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path
+ specified by this attribute. The standard paths provided by the system include:<ul><li>jboss.home - the root directory
+ of the JBoss AS distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current working
+ directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir - root directory for an
+ individual server instance</li><li>jboss.server.data.dir - directory the server will use for persistent data file
+ storage</li><li>jboss.server.log.dir - directory the server will use for log file storage</li><li>jboss.server.tmp.dir -
+ directory the server will use for temporary file storage</li><li>jboss.domain.servers.dir - directory under which a host controller
+ will create the working area for individual server instances</li></ul>"/>
+ <c:simple-property name="path" required="false" type="string" readOnly="true" description="The filesystem path."/>
+ </c:map-property>
+ <c:simple-property name="suffix" required="false" type="string" readOnly="true" description="Set the suffix string. The string is in a format which
+ can be understood by java.text.SimpleDateFormat. The period of the rotation is automatically calculated based on the suffix."/>
+ </resource-configuration>
+ </service>
+ <service name="SizeRotatingFileHandler"
+ discovery="SubsystemDiscovery"
+ class="LoggerComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="size-rotating-file-handler"/>
+ </plugin-configuration>
+
+ <operation name="change-log-level" description="Change the logging level for a handler.">
+ <parameters>
+ <c:simple-property name="level" required="true" type="string" readOnly="false"
+ description="The log level specifying which message levels will be logged by this logger. Message levels lower than this value will be discarded.">
+ <c:property-options>
+ <c:option value="FATAL"/>
+ <c:option value="ERROR"/>
+ <c:option value="WARN"/>
+ <c:option value="INFO"/>
+ <c:option value="DEBUG"/>
+ <c:option value="TRACE"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ </operation>
+
+ <operation name="disable" description="Disable a logging handler.">
+ </operation>
+
+ <operation name="enable" description="Enable a logging handler.">
+ </operation>
+
+ <operation name="change-file" description="Change the file for a handler.">
+ <parameters>
+ <c:simple-property name="path" required="true" type="string" readOnly="false" description="The filesystem path."/>
+ <c:simple-property name="relative-to" required="false" type="string" readOnly="false"
+ description="The name of another previously named path, or of one of the standard paths provided by the system.
+ If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute.
+ The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS
+ distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current
+ working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir -
+ root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will
+ use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for
+ log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file
+ storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the
+ working area for individual server instances</li></ul>"/>
+ </parameters>
+ </operation>
+ <resource-configuration>
+ <c:simple-property name="name" required="false" type="string" readOnly="true" description="The handler's name."/>
+ <c:simple-property name="level" required="false" type="string" readOnly="true" description="The log level specifying which message levels will be logged by this. Message levels lower than this value will be discarded. "/>
+ <c:simple-property name="encoding" required="false" type="string" readOnly="true" description="The character encoding used by this Handler."/>
+ <c:simple-property name="filter" required="false" type="string" readOnly="true" description="Defines a simple filter type."/>
+ <c:simple-property name="formatter" required="false" type="string" readOnly="true" description="Defines a formatter."/>
+ <c:simple-property name="autoflush" required="false" type="boolean" readOnly="true" description="Automatically flush after each write."/>
+ <c:simple-property name="append" required="false" type="boolean" readOnly="true" description="Specify whether to append to the target file."/>
+ <c:map-property name="file" description="null" >
+ <c:simple-property name="relative-to" required="false" type="string" readOnly="true" description="The name of another previously named path, or of one of the standard paths provided by the system. If 'relative-to' is provided, the value of the 'path' attribute is treated as relative to the path specified by this attribute. The standard paths provided by the system include:<ul><li>jboss.home - the root directory of the JBoss AS distribution</li><li>user.home - user's home directory</li><li>user.dir - user's current working directory</li><li>java.home - java installation directory</li><li>jboss.server.base.dir - root directory for an individual server instance</li><li>jboss.server.data.dir - directory the server will use for persistent data file storage</li><li>jboss.server.log.dir - directory the server will use for log file storage</li><li>jboss.server.tmp.dir - directory the server will use for temporary file storage</li><li>jboss.domain.servers.dir - directory under which a host controller will create the working area for individual server instances</li></ul>"/>
+ <c:simple-property name="path" required="false" type="string" readOnly="true" description="The filesystem path."/>
+ </c:map-property>
+ <c:simple-property name="rotate-size" required="false" description="The size at which to rotate the log file." type="long" units="bytes"/>
+ <c:simple-property name="max-backup-index" required="false" description="The maximum number of backups to keep." type="integer" />
+ </resource-configuration>
+ </service>
+
</server>
<server name="Security"
@@ -965,6 +1246,32 @@
<c:simple-property name="webservice-secure-port" type="integer" readOnly="true"
description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
</resource-configuration>
+
+ <service name="Endpoint"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="endpoint"/>
+ </plugin-configuration>
+
+ <metric property="average-processing-time" description="Average endpoint processing time." displayType="summary" units="milliseconds"/>
+ <metric property="min-processing-time" description="Minimal endpoint processing time." units="milliseconds"/>
+ <metric property="max-processing-time" description="Maximal endpoint processing time." units="milliseconds"/>
+ <metric property="total-processing-time" description="Total endpoint processing time." measurementType="trendsup" units="milliseconds"/>
+ <metric property="request-count" description="Count of requests the endpoint processed." displayType="summary" measurementType="trendsup"/>
+ <metric property="response-count" description="Count of responses the endpoint generated." measurementType="trendsup"/>
+ <metric property="fault-count" description="Count of faults the endpoint generated." displayType="summary" measurementType="trendsup"/>
+
+ <resource-configuration>
+ <c:simple-property name="name" required="true" type="string" readOnly="true" description="Webservice endpoint name."/>
+ <c:simple-property name="context" required="true" type="string" readOnly="true" description="Webservice endpoint context."/>
+ <c:simple-property name="class" required="false" type="string" readOnly="true" description="Webservice endpoint class."/>
+ <c:simple-property name="type" required="false" type="string" readOnly="true" description="Webservice endpoint type."/>
+ <c:simple-property name="wsdl-url" required="false" type="string" readOnly="true" description="Webservice endpoint WSDL URL."/>
+ </resource-configuration>
+
+ </service>
</server>
<service name="NetworkInterface"
@@ -1018,4 +1325,30 @@
</service>
+ <service name="Deployment"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ createDeletePolicy="both"
+ creationDataType="content">
+
+
+ <runs-inside>
+ <parent-resource-type name="ServerGroup" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+ <plugin-configuration>
+ <c:simple-property name="path" default="deployment" readOnly="true"/>
+ </plugin-configuration>
+
+ <content name="file" category="deployable" isCreationType="true" description="Deployments on this server group">
+ <configuration>
+ <c:group name="deployment" displayName="Deployment Options">
+ <c:simple-property name="runtimeName" required="true"/>
+ </c:group>
+ </configuration>
+ </content>
+
+ </service>
+
+
</plugin>
commit dd328eac2660aa3b2d4f0d95aa6f031d08ed09cf
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 25 11:34:19 2011 +0200
Changes and optimizations to operations handling and description elements.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index 6d4a0e2..8011628 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -23,14 +23,20 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
+import org.omg.CosNaming._BindingIteratorImplBase;
+
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
/**
- * Generate properties from a domain dump
+ * Generate properties, metrics and operation templates for the
+ * plugin descriptor from a domain dump (server can run in domain
+ * or standalone mode).
+ *
* @author Heiko W. Rupp
*/
+@SuppressWarnings("unchecked")
public class Domain2Descriptor {
public static void main(String[] args) throws Exception {
@@ -48,15 +54,15 @@ public class Domain2Descriptor {
private void run(String[] args) {
- Mode mode = null;
+ D2DMode mode = null;
int pos = 0;
if (args[0].startsWith("-")) {
if (args[0].equals("-m"))
- mode = Domain2Descriptor.Mode.METRICS;
+ mode = D2DMode.METRICS;
else if (args[0].equals("-p"))
- mode = Domain2Descriptor.Mode.PROPERTIES;
+ mode = D2DMode.PROPERTIES;
else if (args[0].equals("-o"))
- mode = Domain2Descriptor.Mode.OPERATION;
+ mode = D2DMode.OPERATION;
else {
usage();
return;
@@ -75,12 +81,12 @@ public class Domain2Descriptor {
Operation op = new Operation("read-resource-description",address);
op.addAdditionalProperty("recursive","true");
- if (mode==Domain2Descriptor.Mode.OPERATION)
+ if (mode== D2DMode.OPERATION)
op.addAdditionalProperty("operations",true);
- if (mode == Domain2Descriptor.Mode.METRICS)
+ if (mode == D2DMode.METRICS)
op.addAdditionalProperty("include-runtime",true);
- ComplexResult res = (ComplexResult) conn.execute(op,true);
+ ComplexResult res = conn.executeComplex(op);
if (!res.isSuccess()) {
System.err.println("Failure: " + res.getFailureDescription());
return;
@@ -88,39 +94,44 @@ public class Domain2Descriptor {
Map<String,Object> resMap = res.getResult();
- if (mode==Domain2Descriptor.Mode.OPERATION) {
- Map<String,Object> operationsMap = (Map<String, Object>) resMap.get("operations");
- for (Map.Entry<String,Object> entry : operationsMap.entrySet()) {
+ String what;
+ if (mode== D2DMode.OPERATION)
+ what="operations";
+ else
+ what="attributes";
+
+ Map<String,Object> attributesMap;
+ if (childType!=null) {
+ Map childMap = (Map) resMap.get("children");
+ Map <String,Object> typeMap = (Map<String, Object>) childMap.get(childType);
+ Map descriptionMap = (Map) typeMap.get("model-description");
+ if (descriptionMap==null) {
+ System.err.println("No model description found");
+ return;
+ }
+ Map starMap = (Map) descriptionMap.get("*");
+ attributesMap = (Map<String, Object>) starMap.get(what);
+ }
+ else {
+ attributesMap = (Map<String, Object>) resMap.get(what);
+ }
+
+ if (mode==D2DMode.OPERATION) {
+ for (Map.Entry<String,Object> entry : attributesMap.entrySet()) {
if (entry.getKey().startsWith("read-"))
continue;
if (entry.getKey().equals("write-attribute"))
continue;
- createOperation((Map<String,Object>)entry.getValue());
+ createOperation(entry.getKey(), (Map<String,Object>)entry.getValue());
}
-
- } else {
- Map<String,Object> attributesMap;
- if (childType!=null) {
- Map childMap = (Map) resMap.get("children");
- Map <String,Object> typeMap = (Map<String, Object>) childMap.get(childType);
- Map descriptionMap = (Map) typeMap.get("model-description");
- if (descriptionMap==null) {
- System.err.println("No model description found");
- return;
- }
- Map starMap = (Map) descriptionMap.get("*");
- attributesMap = (Map<String, Object>) starMap.get("attributes");
- }
- else {
- attributesMap = (Map<String, Object>) resMap.get("attributes");
- }
-
- createProperties(mode, attributesMap, 0);
}
+ else
+ createProperties(mode, attributesMap, 0);
+// }
}
- private void createProperties(Mode mode, Map<String, Object> attributesMap, int indent) {
+ private void createProperties(D2DMode mode, Map<String, Object> attributesMap, int indent) {
if (attributesMap==null)
return;
@@ -161,16 +172,13 @@ public class Domain2Descriptor {
}
- if (ptype== Type.LIST && mode!=Domain2Descriptor.Mode.METRICS) {
+ if (ptype== Type.LIST && mode!= D2DMode.METRICS) {
StringBuilder sb = new StringBuilder("<c:list-property name=\"");
sb.append(entryName);
sb.append("\"");
- if (props.containsKey("description")) {
- sb.append(" description=\"");
- sb.append(props.get("description"));
- sb.append("\"");
- }
+ String description = (String) props.get("description");
+ appendDescription(sb,description);
sb.append(" >\n");
if (!props.containsKey("attributes"))
sb.append(" <c:simple-property name=\"").append(entryName).append("\" />\n");
@@ -192,7 +200,7 @@ public class Domain2Descriptor {
}
String accessType = getAccessType(props);
- if (mode==Domain2Descriptor.Mode.METRICS) {
+ if (mode== D2DMode.METRICS) {
if (!accessType.equals("metric"))
continue;
@@ -204,11 +212,7 @@ public class Domain2Descriptor {
sb.append(" dataType=\"trait\"");
String description = (String) props.get("description");
- if (description!=null) {
- if (sb.length()+description.length() > 120)
- sb.append("\n ");
- sb.append(" description=\"").append(description).append('"');
- }
+ appendDescription(sb,description);
sb.append("/>");
System.out.println(sb.toString());
@@ -224,32 +228,27 @@ public class Domain2Descriptor {
}
}
- private void createOperation(Map<String,Object> operationMap) {
+ private void createOperation(String name, Map<String, Object> operationMap) {
StringBuilder builder = new StringBuilder("<operation name=\"");
- String name = (String) operationMap.get("operation-name");
builder.append(name).append('"');
String description = (String) operationMap.get("description");
- if (description!=null && !description.isEmpty()) {
- builder.append(" description=\"").append(description).append('"');
- }
+ appendDescription(builder, description);
builder.append(">\n");
-
-
- if (!((Map)operationMap.get("request-properties")).isEmpty()) {
- Map<String,Object> map = (Map<String, Object>) operationMap.get("request-properties");
+ Map<String,Object> reqMap = (Map<String, Object>) operationMap.get("request-properties");
+ if (reqMap!=null && !reqMap.isEmpty()) {
builder.append(" <parameters>\n");
- generatePropertiesForMap(builder, map, true);
+ generatePropertiesForMap(builder, reqMap, true);
builder.append(" </parameters>\n");
}
- if (!((Map)operationMap.get("reply-properties")).isEmpty()){
- Map<String,Object> map = (Map<String, Object>) operationMap.get("reply-properties"); // TODO not sure -- perhaps for the java code?
+ Map replyMap = (Map) operationMap.get("reply-properties");
+ if (replyMap!=null && !replyMap.isEmpty()){
builder.append(" <results>\n");
- generatePropertiesForMap(builder, map, true);
+ generatePropertiesForMap(builder, replyMap, true);
builder.append(" </results>\n");
}
@@ -258,6 +257,21 @@ public class Domain2Descriptor {
System.out.println(builder.toString());
}
+ private void appendDescription(StringBuilder builder, String description) {
+ if (description!=null && !description.isEmpty()) {
+ if (builder.length()>120)
+ builder.append("\n ");
+ builder.append(" description=\"");
+
+ description = description.replace("<","<");
+ description = description.replace(">",">");
+ description = description.replace("\"","\\\"");
+
+ builder.append(description);
+ builder.append('"');
+ }
+ }
+
private void generatePropertiesForMap(StringBuilder builder, Map<String, Object> map, boolean forceReadWrite) {
for (Map.Entry<String,Object> entry : map.entrySet()) {
@@ -334,11 +348,7 @@ public class Domain2Descriptor {
}
String description = (String) props.get("description");
- if (description!=null) {
- if (sb.length()+description.length() > 120)
- sb.append("\n ");
- sb.append(" description=\"").append(description).append('"');
- }
+ appendDescription(sb,description);
sb.append("/>");
return sb;
}
@@ -350,6 +360,9 @@ public class Domain2Descriptor {
private Type getTypeFromProps(Map<String, Object> props) {
Map<String,String> tMap = (Map<String, String>) props.get("type");
+ if (tMap==null)
+ return Type.OBJECT;
+
String type = tMap.get("TYPE_MODEL_VALUE");
Type ret = Type.valueOf(type);
@@ -391,6 +404,7 @@ public class Domain2Descriptor {
System.out.println(" path is of kind 'key=value[,key=value]+");
System.out.println(" -p create properties (default)");
System.out.println(" -m create metrics");
+ System.out.println(" -o create operations");
}
public enum Type {
@@ -405,7 +419,7 @@ public class Domain2Descriptor {
;
}
- private enum Mode {
+ private enum D2DMode {
METRICS,
PROPERTIES,
OPERATION
commit 895f8fd65dd46327a171ecb96d498baecc2afffc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 25 11:23:09 2011 +0200
Add a test for AS7-853
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index 1ef3761..57ec4f3 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -153,6 +153,81 @@ public class UploadAndDeployTest {
}
+ // Test for AS7-853
+ @Test(timeOut = 60*1000L, enabled = true)
+ public void testUploadIndividualSteps2() throws Exception {
+
+ String bytes_value = prepare();
+
+ System.out.println("sha: " + bytes_value);
+
+ System.out.println();
+ ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT);
+
+ List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
+ deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Operation op = new Operation("add",deploymentsAddress);
+ List<Object> content = new ArrayList<Object>(1);
+ Map<String,Object> contentValues = new HashMap<String,Object>();
+ contentValues.put("hash",new PROPERTY_VALUE("BYTES_VALUE",bytes_value));
+ content.add(contentValues);
+ op.addAdditionalProperty("content",content);
+ op.addAdditionalProperty("name", TEST_WAR); // this needs to be unique per upload
+ op.addAdditionalProperty("runtime-name", TEST_WAR);
+ System.out.flush();
+ JsonNode ret = connection.executeRaw(op);
+ op = null;
+ System.out.println("Add to /deploy done " + ret);
+ System.out.flush();
+
+ assert ret.toString().contains("success") : ret;
+
+
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ serverGroupAddress.add(new PROPERTY_VALUE("server-group", "main-server-group"));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+
+ Operation attach = new Operation("add",serverGroupAddress,"enabled",true);
+ System.out.flush();
+ ret = connection.executeRaw(attach);
+ System.out.println("Add to server group done: " + ret);
+ System.out.flush();
+
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();
+
+
+ Result depRes;// = connection.execute(deploy);
+
+ Thread.sleep(500);
+
+ Operation undeploy = new Operation("undeploy",serverGroupAddress);
+ depRes = connection.execute(undeploy);
+
+ assert depRes.isSuccess() : "Undeploy went wrong: " + depRes.getFailureDescription();
+ undeploy = null;
+
+ // Now tear down stuff again
+
+ Operation unattach = new Operation("remove",serverGroupAddress);
+ ret = connection.executeRaw(unattach);
+
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success " + ret.getTextValue();
+
+
+ // remove from domain
+
+ Operation remove = new Operation("remove",deploymentsAddress);
+ ret = connection.executeRaw(remove);
+
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "remove from domain was no success " + ret.getTextValue();
+
+ System.out.flush();
+
+ }
+
@Test(timeOut = 60*1000L, enabled = true)
public void testUploadComposite() throws Exception {
commit 3dbd7b89c98c52007fecc64c79a403de1170f68c
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue May 24 15:26:53 2011 +0200
Add a comment that tests need to run against domain mode.
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index f2a4d54..1ef3761 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -36,7 +36,8 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
/**
* Test uploading and deploying to the domain
- * To use it, domain server must be up and running locally and
+ * To use it, a server in <b>domain mode</b> must be up and have it's
+ * <b>DomainController</b> running <b>locally</b> and
* the UPLOAD_FILE must point to a valid archive in the resources directory.
* @author Heiko W. Rupp
*/
commit 506c0dbaf78a349cebeb34f99b96befb57ec1c07
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 20 11:56:14 2011 +0200
Prevent NPE on container shutdown.
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java
index 64a6ff7..b0b37ec 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/event/EventContextImpl.java
@@ -103,7 +103,7 @@ public class EventContextImpl implements EventContext {
public SigarProxy getSigar() {
return getEventManager().getSigar();
}
-
+
private void registerEventPollerInternal(final EventPoller poller, int pollingInterval,
final String sourceLocation) {
EventDefinition eventDefinition = EventUtility.getEventDefinition(poller.getEventType(), this.resource.getResourceType());
@@ -124,6 +124,8 @@ public class EventContextImpl implements EventContext {
EventDefinition eventDefinition = EventUtility.getEventDefinition(eventType, this.resource.getResourceType());
if (eventDefinition == null)
throw new IllegalArgumentException("Unknown event type - no EventDefinition exists with name '" + eventType + "'.");
- getEventManager().unregisterEventPoller(this.resource, eventType, sourceLocation);
+ EventManager eventManager = getEventManager();
+ if (eventManager!=null)
+ eventManager.unregisterEventPoller(this.resource, eventType, sourceLocation);
}
}
commit 63ee4634ec99c852eb69defd272a8f2a79a92ed8
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 20 11:34:44 2011 +0200
Follow the changes in deploy handling of AS and correctly implement delete of deployments
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index eace9b8..5c0a499 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -157,6 +157,16 @@ public class ASConnection {
return null;
}
+
+
+ public Result execute(Operation op) {
+ return execute(op,false);
+ }
+
+ public ComplexResult executeComplex(Operation op) {
+ return (ComplexResult) execute(op,true);
+ }
+
public Result execute(Operation op, boolean isComplex){
JsonNode node = executeRaw(op);
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 609fe69..cbc2893 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
@@ -464,14 +464,40 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
return result;
}
+ public String addressToPath(List<PROPERTY_VALUE> address)
+ {
+ StringBuilder builder = new StringBuilder();
+ Iterator<PROPERTY_VALUE> iter = address.iterator();
+ while (iter.hasNext()) {
+ PROPERTY_VALUE val = iter.next();
+ builder.append(val.getKey()).append('=').append(val.getValue());
+ if (iter.hasNext())
+ builder.append(',');
+ }
+ return builder.toString();
+ }
+
@Override
public void deleteResource() throws Exception {
- System.out.println("delete resource: " + path);
- Operation op = new Operation("remove",pathToAddress(path));
- ComplexResult res = (ComplexResult) connection.execute(op, true);
+ log.info("delete resource: " + path + " ...");
+ List<PROPERTY_VALUE> address = pathToAddress(path);
+ Operation op = new Operation("remove", address);
+ ComplexResult res = connection.executeComplex(op);
if (!res.isSuccess())
throw new IllegalArgumentException("Delete for [" + path + "] failed: " + res.getFailureDescription());
+ if (path.contains("server-group")) {
+ // This was a server group level deployment - we also need to remove the entry in /deployments
+ for (PROPERTY_VALUE val : address) {
+ if (val.getKey().equals("deployment")) {
+ ComplexResult res2 = connection.executeComplex(new Operation("remove",val.getKey(),val.getValue()));
+ if (!res2.isSuccess())
+ throw new IllegalArgumentException("Removal of [" + path + "] falied : " + res2.getFailureDescription());
+ }
+ }
+ }
+ log.info(" ... done");
+
}
@@ -499,6 +525,13 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
String fileName = details.getFileName();
+
+ if (fileName.startsWith("C:\\fakepath\\")) { // TODO this is a hack as the server adds the fake path somehow
+ fileName=fileName.substring("C:\\fakepath\\".length());
+ }
+
+ log.info("Deploying [" + fileName + "] ...");
+
String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
JsonNode resultNode = uploadResult.get("result");
@@ -506,12 +539,19 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
ASConnection connection = getASConnection();
Operation step1 = new Operation("add","deployment",tmpName);
- step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
+// step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
+ List<Object> content = new ArrayList<Object>(1);
+ Map<String,Object> contentValues = new HashMap<String,Object>();
+ contentValues.put("hash",new PROPERTY_VALUE("BYTES_VALUE",hash));
+ content.add(contentValues);
+ step1.addAdditionalProperty("content",content);
+
step1.addAdditionalProperty("name", tmpName);
step1.addAdditionalProperty("runtime-name", fileName);
CompositeOperation cop = new CompositeOperation();
cop.addStep(step1);
+ String resourceKey;
/*
* We need to check here if this is an upload to /deployment only
@@ -519,21 +559,34 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
*/
if (context.getResourceKey().contains("server-group=")) {
- List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>();
serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
serverGroupAddress.add(new PROPERTY_VALUE("deployment", tmpName));
- Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
+ Operation step2 = new Operation("add",serverGroupAddress);
cop.addStep(step2);
+
+ Operation step3 = new Operation("deploy",serverGroupAddress);
+ cop.addStep(step3);
+
+ resourceKey = addressToPath(serverGroupAddress);
+ }
+ else {
+ resourceKey = addressToPath(step1.getAddress());
}
JsonNode result = connection.executeRaw(cop);
if (ASConnection.isErrorReply(result)) {
- report.setErrorMessage(ASConnection.getFailureDescription(resultNode));
+ String failureDescription = ASConnection.getFailureDescription(result);
+ report.setErrorMessage(failureDescription);
report.setStatus(CreateResourceStatus.FAILURE);
+ log.warn(" ... done with failure: " + failureDescription);
}
else {
report.setStatus(CreateResourceStatus.SUCCESS);
+ report.setResourceName(fileName);
+ report.setResourceKey(resourceKey);
+ log.info(" ... with success and key [" + resourceKey + "]" );
}
return report;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index 8c46247..67190ba 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -21,9 +21,11 @@ package org.rhq.modules.plugins.jbossas7;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.codehaus.jackson.JsonNode;
@@ -62,6 +64,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
return null; // TODO: Customise this generated block
}
+ // TODO I think this package code is not used.
@Override
public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages,
ContentServices contentServices) {
@@ -87,23 +90,35 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
deploymentsAddress.add(new PROPERTY_VALUE("deployment", fileName));
Operation step1 = new Operation("add",deploymentsAddress);
- step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
+// step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
+ List<Object> content = new ArrayList<Object>(1);
+ Map<String,Object> contentValues = new HashMap<String,Object>();
+ contentValues.put("hash",new PROPERTY_VALUE("BYTES_VALUE",hash));
+ content.add(contentValues);
+ step1.addAdditionalProperty("content",content);
+
step1.addAdditionalProperty("name", fileName);
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
serverGroupAddress.add(new PROPERTY_VALUE("deployment", fileName));
- Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
+ Operation step2 = new Operation("add",serverGroupAddress);
+ Operation step3 = new Operation("deploy",serverGroupAddress);
CompositeOperation cop = new CompositeOperation();
cop.addStep(step1);
cop.addStep(step2);
+ cop.addStep(step3);
JsonNode result = connection.executeRaw(cop);
if (ASConnection.isErrorReply(result)) // TODO get failure message into response
response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.FAILURE));
- else
- response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.SUCCESS));
+ else {
+ DeployIndividualPackageResponse individualPackageResponse = new DeployIndividualPackageResponse(
+ details.getKey(), ContentResponseResult.SUCCESS);
+ response.addPackageResponse(individualPackageResponse);
+ response.setOverallRequestResult(ContentResponseResult.SUCCESS);
+ }
}
else
response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.FAILURE));
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 7e0a890..d7055a3 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
@@ -857,6 +857,29 @@
description="Specifies the MappingManager implementation class name to use. To use the container default set the value to 'default''."/>
</resource-configuration>
+ <service name="SecurtityDomain"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="security-domain"/>
+ </plugin-configuration>
+
+
+
+ <resource-configuration>
+ <c:simple-property name="extends" required="false" type="string" readOnly="true" description="The parent security domain"/>
+ <c:simple-property name="cache-type" required="false" type="string" readOnly="true"
+ description="Adds a cache to speed up authentication checks. Allowed values are 'default' to use simple map as the cache and 'infinispan' to use an Infinispan cache."/>
+ </resource-configuration>
+ </service>
+
</server>
<server name="Threads"
@@ -915,8 +938,6 @@
</service>
-
-
</server>
<server name="Webservices"
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
index a59b05e..cb10279 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
@@ -92,4 +92,15 @@ public class PathHandlingTest {
}
assert found == 2 : "did not find both keys, but " + found;
}
+
+ public void addr2path() throws Exception {
+
+ String path = "subsystem=jms,profile=default,queue=java:/foo";
+
+ BaseComponent bc = new BaseComponent();
+ List<PROPERTY_VALUE> list = bc.pathToAddress(path);
+
+ String path2 = bc.addressToPath(list);
+ assert path.equals(path2);
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index b1eb277..f2a4d54 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -22,7 +22,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.codehaus.jackson.JsonNode;
import org.testng.annotations.Test;
@@ -54,10 +56,24 @@ public class UploadAndDeployTest {
assert bytes_value != null;
System.out.println("sha: " + bytes_value);
+ assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
}
@Test(timeOut = 60*1000L, enabled = true)
+ public void testDoubleUploadOnly() throws Exception {
+
+ String bytes_value = prepare();
+ String bytes_value2 = prepare();
+
+ assert bytes_value != null;
+ assert bytes_value2 != null;
+ assert bytes_value.equals(bytes_value2);
+
+ assert bytes_value.equals("7jgpMVmynfxpqp8UDleKLmtgbrA=");
+ }
+
+ @Test(timeOut = 60*1000L, enabled = true)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -70,11 +86,16 @@ public class UploadAndDeployTest {
List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
Operation op = new Operation("add",deploymentsAddress);
- op.addAdditionalProperty("hash",new PROPERTY_VALUE("BYTES_VALUE",bytes_value));
- op.addAdditionalProperty("name", TEST_WAR); // this needs to be separate per upload
+ List<Object> content = new ArrayList<Object>(1);
+ Map<String,Object> contentValues = new HashMap<String,Object>();
+ contentValues.put("hash",new PROPERTY_VALUE("BYTES_VALUE",bytes_value));
+ content.add(contentValues);
+ op.addAdditionalProperty("content",content);
+ op.addAdditionalProperty("name", TEST_WAR); // this needs to be unique per upload
op.addAdditionalProperty("runtime-name", TEST_WAR);
System.out.flush();
JsonNode ret = connection.executeRaw(op);
+ op = null;
System.out.println("Add to /deploy done " + ret);
System.out.flush();
@@ -82,12 +103,13 @@ public class UploadAndDeployTest {
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
- serverGroupAddress.add(new PROPERTY_VALUE("server-group","main-server-group"));
+ serverGroupAddress.add(new PROPERTY_VALUE("server-group", "main-server-group"));
serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
- op.addAdditionalProperty("runtime-name", TEST_WAR);
- Operation deploy = new Operation("add",serverGroupAddress,"enabled","true");
+
+ Operation attach = new Operation("add",serverGroupAddress);//,"enabled","true");
+// deploy.addAdditionalProperty("runtime-name", TEST_WAR);
System.out.flush();
- ret = connection.executeRaw(deploy);
+ ret = connection.executeRaw(attach);
System.out.println("Add to server group done: " + ret);
System.out.flush();
@@ -95,10 +117,24 @@ public class UploadAndDeployTest {
assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();
+ Operation deploy = new Operation("deploy",serverGroupAddress);
+ Result depRes = connection.execute(deploy);
+
+ assert depRes.isSuccess() : "Deploy went wrong: " + depRes.getFailureDescription();
+
+
+ Thread.sleep(500);
+
+ Operation undeploy = new Operation("undeploy",serverGroupAddress);
+ depRes = connection.execute(undeploy);
+
+ assert depRes.isSuccess() : "Undeploy went wrong: " + depRes.getFailureDescription();
+ undeploy = null;
+
// Now tear down stuff again
- Operation undeploy = new Operation("remove",serverGroupAddress);
- ret = connection.executeRaw(undeploy);
+ Operation unattach = new Operation("remove",serverGroupAddress);
+ ret = connection.executeRaw(unattach);
assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success " + ret.getTextValue();
@@ -121,26 +157,36 @@ public class UploadAndDeployTest {
String bytes_value = prepare();
+ System.out.println("Prepare done");
+ System.out.flush();
List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
Operation step1 = new Operation("add",deploymentsAddress);
- step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", bytes_value));
- step1.addAdditionalProperty("name", TEST_WAR);
+ List<Object> content = new ArrayList<Object>(1);
+ Map<String,Object> contentValues = new HashMap<String,Object>();
+ contentValues.put("hash",new PROPERTY_VALUE("BYTES_VALUE",bytes_value));
+ content.add(contentValues);
+ step1.addAdditionalProperty("content", content);
+ step1.addAdditionalProperty("name", TEST_WAR); // this needs to be unique per upload
+
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
serverGroupAddress.add(new PROPERTY_VALUE("server-group","main-server-group"));
serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
- Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
+ Operation step2 = new Operation("add",serverGroupAddress);// ,"enabled","true");
+ Operation step2a = new Operation("deploy",serverGroupAddress);
- Operation step3 = new Operation("remove",serverGroupAddress);
+ Operation step3 = new Operation("undeploy",serverGroupAddress);
+ Operation step3a = new Operation("remove",serverGroupAddress);
Operation step4 = new Operation("remove",deploymentsAddress);
CompositeOperation cop = new CompositeOperation();
cop.addStep(step1);
cop.addStep(step2);
+ cop.addStep(step2a);
ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT);
@@ -148,16 +194,23 @@ public class UploadAndDeployTest {
System.out.println(ret);
System.out.flush();
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "Composite deploy was no success " + ret.getTextValue();
+
Thread.sleep(1000);
cop = new CompositeOperation();
cop.addStep(step3);
+ cop.addStep(step3a);
cop.addStep(step4);
ret = connection.executeRaw(cop);
System.out.println(ret);
System.out.flush();
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "Composite remove was no success " + ret.getTextValue();
+
}
commit 1b158d363959f76fbc698d34435b2fc4f6557eab
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 19 10:39:21 2011 +0200
Fix the property name for includes.
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 574e8cb..7e0a890 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
@@ -980,8 +980,8 @@
<c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition" required="false"/>
<!-- note: at domain level there is no port-offset -->
<c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group" required="false"/>
- <c:list-property name="include">
- <c:simple-property name="binding" displayName="Included bindings" description="Other bindings that are included in this one"/>
+ <c:list-property name="includes">
+ <c:simple-property name="includes" displayName="Included bindings" description="Other bindings that are included in this one"/>
</c:list-property>
<c:list-property name="socket-binding">
<c:map-property name="binding">
commit 19cca0b11c0a3d45055d0906e586fd697a9f8e78
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 19 10:38:44 2011 +0200
Barf if a property can not be found in the JSON.
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 ccdd235..609fe69 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
@@ -195,6 +195,10 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (Map.Entry<String,PropertyDefinition> propDefEntry: entrySet) {
PropertyDefinition propDef = propDefEntry.getValue();
JsonNode sub = json.findValue(propDef.getName());
+ if (sub==null) {
+ log.error("No value for property [" + propDef.getName() + "] found - check the descriptor");
+ continue;
+ }
if (propDef instanceof PropertyDefinitionSimple) {
PropertySimple propertySimple;
commit b16fc49c66386a7e399999d62782db7d29221cda
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 18 22:15:06 2011 +0200
Support creation of JMS objects.
This code may be pulled up in a super class, as it is applicable for most/all cases of :add
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
index 70bb5d7..3aeef6e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
@@ -29,12 +29,15 @@ import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
-import org.rhq.modules.plugins.jbossas7.json.Result;
/**
* Component class for the JMS subsystem
@@ -48,42 +51,77 @@ public class JmsComponent extends DomainComponent {
public CreateResourceReport createResource(CreateResourceReport report) {
- Configuration resConf = report.getResourceConfiguration();
Configuration pConf = report.getPluginConfiguration();
+ Configuration resConf = report.getResourceConfiguration();
+ ConfigurationDefinition resConfDef = report.getResourceType().getResourceConfigurationDefinition();
String type = pConf.getSimpleValue("path", "");
List<PROPERTY_VALUE> address = pathToAddress(getPath());
address.add(new PROPERTY_VALUE(type,report.getUserSpecifiedResourceName()));
Operation op = new Operation("add",address);
+
+ // Loop over the properties from the config and add them as properties to the op
for (Map.Entry<String, Property> entry: resConf.getAllProperties().entrySet()) {
Property value = entry.getValue();
if (value !=null) {
+ String name = entry.getKey();
+
if (value instanceof PropertySimple) {
+ PropertyDefinitionSimple propDef = (PropertyDefinitionSimple) resConfDef.get(name);
PropertySimple ps = (PropertySimple) value;
- op.addAdditionalProperty(entry.getKey(), ps.getStringValue()); // TODO determine real type
+ op.addAdditionalProperty(name, getObjectForProperty(ps,propDef));
} else if (value instanceof PropertyList) {
PropertyList propertyList = (PropertyList) value;
- List<String> list = new ArrayList<String>();
+ List<Object> list = new ArrayList<Object>();
+ PropertyDefinitionList pd = resConfDef.getPropertyDefinitionList(name);
+ PropertyDefinitionSimple propDef = (PropertyDefinitionSimple) pd.getMemberDefinition();
for (Property p : propertyList.getList()) {
- list.add(p.toString()); // TODO
+
+ Object o = getObjectForProperty((PropertySimple) p, propDef);
+ list.add(o);
}
- op.addAdditionalProperty(entry.getKey(),list);
+ op.addAdditionalProperty(name,list);
}
}
}
ComplexResult res = (ComplexResult) getASConnection().execute(op,true);
+ // TODO Currently this reports a failure even if it succeeds for jms
+
if (res == null || !res.isSuccess()) {
report.setStatus(CreateResourceStatus.FAILURE);
} else {
report.setStatus(CreateResourceStatus.SUCCESS);
- report.setResourceKey(address.toString()); // TODO ??
+ report.setResourceKey(address.toString());
report.setResourceName(report.getUserSpecifiedResourceName());
}
System.out.println(report);
return report;
}
+
+ Object getObjectForProperty(PropertySimple prop, PropertyDefinitionSimple propDef) {
+
+ PropertySimpleType type = propDef.getType();
+ switch (type) {
+ case STRING:
+ return prop.getStringValue();
+ case INTEGER:
+ return prop.getIntegerValue();
+ case BOOLEAN:
+ return prop.getBooleanValue();
+ case LONG:
+ return prop.getLongValue();
+ case FLOAT:
+ return prop.getFloatValue();
+ case DOUBLE:
+ return prop.getDoubleValue();
+ default:
+ return prop.getStringValue();
+ }
+
+
+ }
}
commit 5abdcb5f64541a372b8a00412b7b9fc38c118827
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 18 22:14:15 2011 +0200
Make failure description an object, as the AS may result stuff that jackson can't deal with.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index ccc967b..c7a983e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -36,7 +36,7 @@ public class Result {
@JsonProperty("compensating-operation")
private Operation compensatingOperation;
@JsonProperty("failure-description")
- private List<Map<String, String>> failureDescription;
+ private /*List<Map<String, String>>*/Object failureDescription;
@JsonIgnore
private boolean success = false;
@@ -74,11 +74,11 @@ public class Result {
this.compensatingOperation = compensatingOperation;
}
- public List<Map<String, String>> getFailureDescription() {
+ public Object getFailureDescription() {
return failureDescription;
}
- public void setFailureDescription(List<Map<String, String>> failureDescription) {
+ public void setFailureDescription(/*List<Map<String, String>>*/Object failureDescription) {
this.failureDescription = failureDescription;
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 2ca9f91..53ac89e 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -23,7 +23,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.annotate.JsonAnyGetter;
import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.SerializationConfig;
import org.testng.annotations.Test;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
@@ -157,7 +160,7 @@ public class OperationJsonTest {
assert result.getResult() == null;
assert result.getCompensatingOperation() == null;
assert result.getFailureDescription() != null;
- assert result.getFailureDescription().size() == 1;
+// assert result.getFailureDescription().size() == 1;
}
public void complexResult1() throws Exception {
@@ -216,4 +219,77 @@ public class OperationJsonTest {
}
+ public void complexResult2() throws Exception {
+
+
+ String resultString =
+ "{\n" +
+ " \"outcome\" : \"failed\",\n" +
+ " \"result\" : {\n" +
+ " \"server-groups\" : {\n" +
+ " \"main-server-group\" : {\n" +
+ " \"server-one\" : {\n" +
+ " \"host\" : \"local\",\n" +
+ " \"response\" : {\n" +
+ " \"outcome\" : \"success\",\n" +
+ " \"result\" : null,\n" +
+ " \"compensating-operation\" : {\n" +
+ " \"operation\" : \"add\",\n" +
+ " \"address\" : [ {\n" +
+ " \"subsystem\" : \"jms\"\n" +
+ " }, {\n" +
+ " \"queue\" : \"flubbr\"\n" +
+ " } ],\n" +
+ " \"durable\" : \"true\",\n" +
+ " \"entries\" : [ \"PropertySimple[id=0, name=entries, value=flubbr, override=null]\" ]\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"server-two\" : {\n" +
+ " \"host\" : \"local\",\n" +
+ " \"response\" : {\n" +
+ " \"outcome\" : \"success\",\n" +
+ " \"result\" : null,\n" +
+ " \"compensating-operation\" : {\n" +
+ " \"operation\" : \"add\",\n" +
+ " \"address\" : [ {\n" +
+ " \"subsystem\" : \"jms\"\n" +
+ " }, {\n" +
+ " \"queue\" : \"flubbr\"\n" +
+ " } ],\n" +
+ " \"durable\" : \"true\",\n" +
+ " \"entries\" : [ \"PropertySimple[id=0, name=entries, value=flubbr, override=null]\" ]\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"server-demo\" : {\n" +
+ " \"host\" : \"local\",\n" +
+ " \"response\" : {\n" +
+ " \"outcome\" : \"failed\",\n" +
+ " \"failure-description\" : \"No handler for add at address [\\n (\\\"host\\\" => \\\"local\\\"),\\n (\\\"server\\\" => \\\"server-demo\\\"),\\n (\\\"subsystem\\\" => \\\"jms\\\"),\\n (\\\"queue\\\" => \\\"flubbr\\\")\\n]\"\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ " },\n" +
+ " \"failure-description\" : \"Operation was not applied successfully to any servers\"\n" +
+ "}";
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
+
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+ assert !result.isSuccess() : "Result should be 'failed', but was not";
+ assert result.getFailureDescription().equals("Operation was not applied successfully to any servers");
+
+ assert result.getResult().containsKey("server-groups");
+ Map<String,Object> sgs = (Map<String, Object>) result.getResult().get("server-groups");
+ assert sgs.containsKey("main-server-group");
+ Map<String,Object> mainSg = (Map<String, Object>) sgs.get("main-server-group");
+ assert mainSg.size()==3 : "Main server group does not have 3 servers, but " + mainSg.size();
+ Map<String,Object> s3 = (Map<String, Object>) mainSg.get("server-demo");
+ Map<String,Object> response = (Map<String, Object>) s3.get("response");
+ assert response!=null;
+
+ }
+
}
commit 427fe807db9993edeb3de4b246c961710f5d7c4a
Merge: 9520bad 25e909e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 18 11:45:37 2011 +0200
Merge branch 'master' into as7plugin
commit 9520bad8e6bd7574dba08530613e526aaee2a768
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 18 11:42:29 2011 +0200
Work on creation of JMS destinations with the normal "create child" workflow.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index f4ba9a0..6d4a0e2 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -242,14 +242,14 @@ public class Domain2Descriptor {
if (!((Map)operationMap.get("request-properties")).isEmpty()) {
Map<String,Object> map = (Map<String, Object>) operationMap.get("request-properties");
builder.append(" <parameters>\n");
- generatePropertiesForMap(builder, map);
+ generatePropertiesForMap(builder, map, true);
builder.append(" </parameters>\n");
}
if (!((Map)operationMap.get("reply-properties")).isEmpty()){
Map<String,Object> map = (Map<String, Object>) operationMap.get("reply-properties"); // TODO not sure -- perhaps for the java code?
builder.append(" <results>\n");
- generatePropertiesForMap(builder, map);
+ generatePropertiesForMap(builder, map, true);
builder.append(" </results>\n");
}
@@ -258,7 +258,7 @@ public class Domain2Descriptor {
System.out.println(builder.toString());
}
- private void generatePropertiesForMap(StringBuilder builder, Map<String, Object> map) {
+ private void generatePropertiesForMap(StringBuilder builder, Map<String, Object> map, boolean forceReadWrite) {
for (Map.Entry<String,Object> entry : map.entrySet()) {
Map<String, Object> entryValue = (Map<String, Object>) entry.getValue();
@@ -266,8 +266,7 @@ public class Domain2Descriptor {
Type type = getTypeFromProps(entryValue);
String typeString = getTypeStringForTypeAndName(type, entryKey);
- builder.append(generateProperty(4, entryValue,typeString, entryKey,getAccessType(
- entryValue)));
+ builder.append(generateProperty(4, entryValue,typeString, entryKey, null));
builder.append('\n');
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
new file mode 100644
index 0000000..70bb5d7
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JmsComponent.java
@@ -0,0 +1,89 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * Component class for the JMS subsystem
+ * @author Heiko W. Rupp
+ */
+public class JmsComponent extends DomainComponent {
+
+ private final Log log = LogFactory.getLog(JmsComponent.class);
+
+ @Override
+ public CreateResourceReport createResource(CreateResourceReport report) {
+
+
+ Configuration resConf = report.getResourceConfiguration();
+ Configuration pConf = report.getPluginConfiguration();
+
+ String type = pConf.getSimpleValue("path", "");
+
+ List<PROPERTY_VALUE> address = pathToAddress(getPath());
+ address.add(new PROPERTY_VALUE(type,report.getUserSpecifiedResourceName()));
+ Operation op = new Operation("add",address);
+ for (Map.Entry<String, Property> entry: resConf.getAllProperties().entrySet()) {
+ Property value = entry.getValue();
+ if (value !=null) {
+
+ if (value instanceof PropertySimple) {
+ PropertySimple ps = (PropertySimple) value;
+ op.addAdditionalProperty(entry.getKey(), ps.getStringValue()); // TODO determine real type
+ } else if (value instanceof PropertyList) {
+ PropertyList propertyList = (PropertyList) value;
+ List<String> list = new ArrayList<String>();
+ for (Property p : propertyList.getList()) {
+ list.add(p.toString()); // TODO
+ }
+ op.addAdditionalProperty(entry.getKey(),list);
+ }
+ }
+ }
+ ComplexResult res = (ComplexResult) getASConnection().execute(op,true);
+
+ if (res == null || !res.isSuccess()) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ } else {
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ report.setResourceKey(address.toString()); // TODO ??
+ report.setResourceName(report.getUserSpecifiedResourceName());
+ }
+
+ System.out.println(report);
+ return report;
+ }
+}
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 b0089f7..574e8cb 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
@@ -392,6 +392,7 @@
<c:simple-property name="path" readOnly="true" default="connector"/>
</plugin-configuration>
</service>
+<!-- this is no child resource
<service name="HQueue"
discovery="SubsystemDiscovery"
class="BaseComponent"
@@ -406,11 +407,12 @@
</resource-configuration>
</service>
+-->
</server>
<server name="JMS"
discovery="SubsystemDiscovery"
- class="DomainComponent"
+ class="JmsComponent"
description="The JMS messaging subsystem"
singleton="true"
>
@@ -425,23 +427,57 @@
<service name="Queue"
discovery="SubsystemDiscovery"
- class="BaseComponent"
+ class="JmsComponent"
+ createDeletePolicy="both"
>
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="queue"/>
</plugin-configuration>
+ <resource-configuration> <!-- See BZ 705713 TODO -->
+ <c:simple-property name="durable" required="false" type="boolean" readOnly="false" default="false"
+ description="Whether the queue is durable or not."/>
+ <c:list-property name="entries" required="false" readOnly="false"
+ description="The jndi names the queue will be bound to.">
+ <c:simple-property name="entries" type="string"/>
+ </c:list-property>
+ <c:simple-property name="selector" required="false" type="string" readOnly="false" description="The queue selector."/>
+ <c:template name="add" description="Properties when adding a new queue" >
+ <c:simple-property name="durable" required="false" type="boolean" default="false"
+ description="Whether the queue is durable or not."/>
+ <c:list-property name="entries" required="false"
+ description="The jndi names the queue will be bound to.">
+ <c:simple-property name="entries" type="string"/>
+ </c:list-property>
+ <c:simple-property name="selector" required="false" type="string" description="The queue selector."/>
+ </c:template>
+ </resource-configuration>
</service>
<service name="Topic"
discovery="SubsystemDiscovery"
- class="BaseComponent"
+ class="JmsComponent"
+ createDeletePolicy="both"
>
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="topic"/>
</plugin-configuration>
+ <resource-configuration> <!-- See BZ 705713 TODO -->
+ <c:list-property name="entries" required="false" readOnly="false"
+ description="The jndi names the queue will be bound to.">
+ <c:simple-property name="entries" type="string"/>
+ </c:list-property>
+ <c:template name="add" description="Template when adding a Topic">
+ <!--<c:list-property name="entries" required="false"-->
+ <!--description="The jndi names the queue will be bound to.">-->
+ <c:simple-property name="entries" type="string"/>
+ <c:simple-property name="foobar" required="false" />
+ <!--</c:list-property>-->
+ </c:template>
+ </resource-configuration>
</service>
<service name="Connection-Factory"
discovery="SubsystemDiscovery"
- class="BaseComponent"
+ class="JmsComponent"
+ createDeletePolicy="both"
>
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="connection-factory"/>
@@ -542,17 +578,30 @@
<c:simple-property name="default-web-module" type="string" readOnly="true" defaultValue="ROOT.war"
description="The web module deployment name that will be mapped as the root webapp."/>
<c:map-property name="access-log" description="The access log configuration for this virtual server." >
- <c:simple-property name="pattern" type="string" readOnly="true" defaultValue="common" description="The access log pattern."/>
- <c:simple-property name="resolve-hosts" type="boolean" readOnly="true" defaultValue="false" description="Host resolution."/>
- <c:simple-property name="extended" type="boolean" readOnly="true" defaultValue="false"
+ <c:simple-property name="pattern" type="string" readOnly="true" defaultValue="common" required="false" description="The access log pattern."/>
+ <c:simple-property name="resolve-hosts" type="boolean" readOnly="true" defaultValue="false" required="false" description="Host resolution."/>
+ <c:simple-property name="extended" type="boolean" readOnly="true" defaultValue="false" required="false"
description="Enable extended pattern, with more options."/>
- <c:simple-property name="prefix" type="string" readOnly="true" description="Prefix for the log file name."/>
- <c:simple-property name="rotate" type="boolean" readOnly="true" defaultValue="true" description="Rotate the access log every day."/>
- <!--<c:simple-property name="directory" description="The location for the access logging." />-->
+ <c:simple-property name="prefix" type="string" readOnly="true" required="false" description="Prefix for the log file name."/>
+ <c:simple-property name="rotate" type="boolean" readOnly="true" defaultValue="true" required="false" description="Rotate the access log every day."/>
+ <c:map-property name="directory" description="The location for the access logging." required="false" >
+ <c:simple-property name="path" required="false" type="string" readOnly="true" description="The relative folder path."/>
+ <c:simple-property name="relative-to" required="false" type="string" readOnly="true"
+ description="The folder the path is relative to."/>
+ </c:map-property>
</c:map-property>
- <!--<c:list-property name="rewrite" >-->
- <!--<c:simple-property name="rewrite" />-->
- <!--</c:list-property>-->
+ <c:list-property name="rewrite" description="A list of rewrite rules that will be processed in order on the URL or vhost specified in the request." >
+ <c:map-property name="rewrite">
+
+ <c:simple-property name="pattern" required="false" type="string" readOnly="true" description="The pattern that will be matched."/>
+ <c:simple-property name="substitution" required="false" type="string" readOnly="true"
+ description="The string that will replace the original URL or vhost."/>
+ <c:simple-property name="flags" required="false" type="string" readOnly="true" description="Option flags for this rewrite rule."/>
+ <c:list-property name="condition" description="A list of conditions this rule needs to match for rewrite to occur." >
+ <c:simple-property name="condition" />
+ </c:list-property>
+ </c:map-property>
+ </c:list-property>
</resource-configuration>
</service>
@@ -756,6 +805,60 @@
</server>
+ <server name="Logging"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=logging"/>
+ </plugin-configuration>
+ </server>
+
+ <server name="Security"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=security"/>
+ </plugin-configuration>
+
+
+
+ <resource-configuration>
+ <c:simple-property name="authentication-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
+ description="Specifies the AuthenticationManager implementation class name to use. To use the container default set the value to 'default'"/>
+ <c:simple-property name="deep-copy-subject-mode" required="false" type="boolean" readOnly="true" defaultValue="false"
+ description="Sets the copy mode of subjects done by the security managers to be deep copies that makes copies of the subject principals and credentials if they are cloneable. It should be set to true if subject include mutable content that can be corrupted when multiple threads have the same identity and cache flushes/logout clearing the subject in one thread results in subject references affecting other threads."/>
+ <c:simple-property name="default-callback-handler-class-name" required="false" type="string" readOnly="true" defaultValue="default"
+ description="A global class name for the CallbackHandler implementation to be used with login modules. To use the container default set the value to 'default'"/>
+ <c:simple-property name="subject-factory-class-name" required="false" type="string" readOnly="true" defaultValue="default"
+ description="Sets the class name for the SubjectFactory implementation to be used. To use the container default set the value to 'default'."/>
+ <c:simple-property name="authorization-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
+ description="Specifies the AuthorizationManager implementation class name to use. To use the container default set the value to 'default'."/>
+ <c:simple-property name="audit-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
+ description="Specifies the AuditManager implementation class name to use. To use the container default set the value to 'default'."/>
+ <c:simple-property name="identity-trust-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
+ description="Specifies the IdentityTrustManager implementation class name to use. To use the container default set the value to 'default'."/>
+ <c:simple-property name="mapping-manager-class-name" required="false" type="string" readOnly="true" defaultValue="default"
+ description="Specifies the MappingManager implementation class name to use. To use the container default set the value to 'default''."/>
+ </resource-configuration>
+
+ </server>
+
<server name="Threads"
discovery="SubsystemDiscovery"
class="BaseComponent"
commit cb3803400824fa0ffcca5fd6b0141973a8316025
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon May 16 18:00:11 2011 +0200
Add support for operations.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index 11d7fe4..f4ba9a0 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -48,13 +48,15 @@ public class Domain2Descriptor {
private void run(String[] args) {
- boolean doMetrics = false;
+ Mode mode = null;
int pos = 0;
if (args[0].startsWith("-")) {
if (args[0].equals("-m"))
- doMetrics = true;
+ mode = Domain2Descriptor.Mode.METRICS;
else if (args[0].equals("-p"))
- doMetrics = false;
+ mode = Domain2Descriptor.Mode.PROPERTIES;
+ else if (args[0].equals("-o"))
+ mode = Domain2Descriptor.Mode.OPERATION;
else {
usage();
return;
@@ -70,39 +72,55 @@ public class Domain2Descriptor {
ASConnection conn = new ASConnection("localhost",9990);
List<PROPERTY_VALUE> address = pathToAddress(path);
- Operation op = new Operation("read-resource-description",address); // ,"operations",true);
+ Operation op = new Operation("read-resource-description",address);
op.addAdditionalProperty("recursive","true");
- if (doMetrics)
+
+ if (mode==Domain2Descriptor.Mode.OPERATION)
+ op.addAdditionalProperty("operations",true);
+ if (mode == Domain2Descriptor.Mode.METRICS)
op.addAdditionalProperty("include-runtime",true);
+
ComplexResult res = (ComplexResult) conn.execute(op,true);
if (!res.isSuccess()) {
System.err.println("Failure: " + res.getFailureDescription());
return;
}
- Map<String,Object> attributesMap;
Map<String,Object> resMap = res.getResult();
- if (childType!=null) {
- Map childMap = (Map) resMap.get("children");
- Map <String,Object> typeMap = (Map<String, Object>) childMap.get(childType);
- Map descriptionMap = (Map) typeMap.get("model-description");
- if (descriptionMap==null) {
- System.err.println("No model description found");
- return;
+ if (mode==Domain2Descriptor.Mode.OPERATION) {
+ Map<String,Object> operationsMap = (Map<String, Object>) resMap.get("operations");
+ for (Map.Entry<String,Object> entry : operationsMap.entrySet()) {
+ if (entry.getKey().startsWith("read-"))
+ continue;
+ if (entry.getKey().equals("write-attribute"))
+ continue;
+
+ createOperation((Map<String,Object>)entry.getValue());
}
- Map starMap = (Map) descriptionMap.get("*");
- attributesMap = (Map<String, Object>) starMap.get("attributes");
- }
- else {
- attributesMap = (Map<String, Object>) resMap.get("attributes");
- }
- createProperties(doMetrics, attributesMap, 0);
+ } else {
+ Map<String,Object> attributesMap;
+ if (childType!=null) {
+ Map childMap = (Map) resMap.get("children");
+ Map <String,Object> typeMap = (Map<String, Object>) childMap.get(childType);
+ Map descriptionMap = (Map) typeMap.get("model-description");
+ if (descriptionMap==null) {
+ System.err.println("No model description found");
+ return;
+ }
+ Map starMap = (Map) descriptionMap.get("*");
+ attributesMap = (Map<String, Object>) starMap.get("attributes");
+ }
+ else {
+ attributesMap = (Map<String, Object>) resMap.get("attributes");
+ }
+ createProperties(mode, attributesMap, 0);
+ }
}
- private void createProperties(boolean doMetrcis, Map<String, Object> attributesMap, int indent) {
+ private void createProperties(Mode mode, Map<String, Object> attributesMap, int indent) {
if (attributesMap==null)
return;
@@ -121,7 +139,7 @@ public class Domain2Descriptor {
Map<String, Object> attributesMap1 = (Map<String, Object>) props.get(
"attributes");
if (attributesMap1!=null)
- createProperties(doMetrcis,
+ createProperties(mode,
attributesMap1, indent+4);
else {
for (Map.Entry<String,Object> emapEntry : props.entrySet()) {
@@ -143,7 +161,7 @@ public class Domain2Descriptor {
}
- if (ptype== Type.LIST && !doMetrcis) {
+ if (ptype== Type.LIST && mode!=Domain2Descriptor.Mode.METRICS) {
StringBuilder sb = new StringBuilder("<c:list-property name=\"");
sb.append(entryName);
@@ -160,7 +178,7 @@ public class Domain2Descriptor {
doIndent(indent,sb);
sb.append("<c:map-property name=\"").append(entryName).append("\">\n");
System.out.println(sb.toString());
- createProperties(doMetrcis, (Map<String, Object>) props.get("attributes"), indent + 4);
+ createProperties(mode, (Map<String, Object>) props.get("attributes"), indent + 4);
sb = new StringBuilder();
doIndent(indent,sb);
sb.append("</c:map-property>\n");
@@ -174,7 +192,7 @@ public class Domain2Descriptor {
}
String accessType = getAccessType(props);
- if (doMetrcis) {
+ if (mode==Domain2Descriptor.Mode.METRICS) {
if (!accessType.equals("metric"))
continue;
@@ -206,6 +224,54 @@ public class Domain2Descriptor {
}
}
+ private void createOperation(Map<String,Object> operationMap) {
+
+ StringBuilder builder = new StringBuilder("<operation name=\"");
+
+ String name = (String) operationMap.get("operation-name");
+ builder.append(name).append('"');
+
+ String description = (String) operationMap.get("description");
+ if (description!=null && !description.isEmpty()) {
+ builder.append(" description=\"").append(description).append('"');
+ }
+ builder.append(">\n");
+
+
+
+ if (!((Map)operationMap.get("request-properties")).isEmpty()) {
+ Map<String,Object> map = (Map<String, Object>) operationMap.get("request-properties");
+ builder.append(" <parameters>\n");
+ generatePropertiesForMap(builder, map);
+ builder.append(" </parameters>\n");
+
+ }
+ if (!((Map)operationMap.get("reply-properties")).isEmpty()){
+ Map<String,Object> map = (Map<String, Object>) operationMap.get("reply-properties"); // TODO not sure -- perhaps for the java code?
+ builder.append(" <results>\n");
+ generatePropertiesForMap(builder, map);
+ builder.append(" </results>\n");
+ }
+
+
+ builder.append("</operation>\n");
+ System.out.println(builder.toString());
+ }
+
+ private void generatePropertiesForMap(StringBuilder builder, Map<String, Object> map) {
+ for (Map.Entry<String,Object> entry : map.entrySet()) {
+
+ Map<String, Object> entryValue = (Map<String, Object>) entry.getValue();
+ String entryKey = entry.getKey();
+
+ Type type = getTypeFromProps(entryValue);
+ String typeString = getTypeStringForTypeAndName(type, entryKey);
+ builder.append(generateProperty(4, entryValue,typeString, entryKey,getAccessType(
+ entryValue)));
+ builder.append('\n');
+ }
+ }
+
private String getAccessType(Map<String, Object> props) {
String accessType = (String) props.get("access-type");
if (accessType==null)
@@ -340,4 +406,11 @@ public class Domain2Descriptor {
;
}
+ private enum Mode {
+ METRICS,
+ PROPERTIES,
+ OPERATION
+ ;
+ }
+
}
commit f4c7cf499cf6ffa9296e21333f88c137d2bc87a7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon May 16 13:45:31 2011 +0200
Prevent possible NPE
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index 088a3b7..11d7fe4 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -87,6 +87,10 @@ public class Domain2Descriptor {
Map childMap = (Map) resMap.get("children");
Map <String,Object> typeMap = (Map<String, Object>) childMap.get(childType);
Map descriptionMap = (Map) typeMap.get("model-description");
+ if (descriptionMap==null) {
+ System.err.println("No model description found");
+ return;
+ }
Map starMap = (Map) descriptionMap.get("*");
attributesMap = (Map<String, Object>) starMap.get("attributes");
}
commit 177b2a3e0bc8d078757044df0e51a1f1b369c98d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon May 16 12:03:02 2011 +0200
Some handling for maps of maps.
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 22aa90b..ccdd235 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
@@ -25,6 +25,7 @@ import org.codehaus.jackson.map.ObjectMapper;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
+import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -330,9 +331,29 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
Map<String,PropertyDefinition> memberDefMap = mapDef.getPropertyDefinitions();
for (Map.Entry<String,PropertyDefinition> maEntry : memberDefMap.entrySet()) {
JsonNode valueNode = json.findValue(maEntry.getKey());
- PropertySimple p = putProperty(valueNode, maEntry.getValue());
- System.out.println(p);
- pm.put(p);
+ Property p;
+ if (maEntry.getValue() instanceof PropertyDefinitionSimple) {
+ p = putProperty(valueNode, maEntry.getValue());
+ pm.put(p);
+ }
+ else if (maEntry.getValue() instanceof PropertyDefinitionMap) { // TODO make this recursive?
+
+ PropertyDefinitionMap pdm = (PropertyDefinitionMap) maEntry.getValue();
+ Map<String,PropertyDefinition> mmDefMap = pdm.getPropertyDefinitions();
+ for (Map.Entry<String,PropertyDefinition> mmDefEntry : mmDefMap.entrySet()) {
+ if (valueNode!=null) {
+ JsonNode node2 = valueNode.findValue(mmDefEntry.getKey());
+ System.err.println("Map not yet implemented " + node2.toString());
+ }
+ else
+ System.err.println("Value node was null " );
+ }
+ }
+ else { // PropDefList
+ System.err.println("List not yet implemented");
+ }
+
+// pm.put(p);
}
ret.put(pm);
}
commit b4c2894cc92a4127503f1d9f1c4675988a6cf44b
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 13 14:42:09 2011 +0200
Better handling of lists of maps.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index ac57b57..088a3b7 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -114,13 +114,13 @@ public class Domain2Descriptor {
if (ptype == Type.OBJECT) {
System.out.println("<c:map-property name=\"" + entryName +"\" description=\"" +
props.get("description") + "\" >");
- Map<String, Object> attributesMap1 = (Map<String, Object>) ((Map<String, Object>) entry.getValue()).get(
+ Map<String, Object> attributesMap1 = (Map<String, Object>) props.get(
"attributes");
if (attributesMap1!=null)
createProperties(doMetrcis,
attributesMap1, indent+4);
else {
- for (Map.Entry<String,Object> emapEntry : ((Map<String,Object>)entry.getValue()).entrySet()) {
+ for (Map.Entry<String,Object> emapEntry : props.entrySet()) {
String key = emapEntry.getKey();
if (key.equals("type") || key.equals("description") || key.equals("required"))
continue;
@@ -141,10 +141,29 @@ public class Domain2Descriptor {
if (ptype== Type.LIST && !doMetrcis) {
- System.out.println("<c:list-property name=\"" + entryName +"\" >");
- System.out.println(" <c:simple-property name=\"" + entryName + "\" />");
- System.out.println("</c:list-property>");
+ StringBuilder sb = new StringBuilder("<c:list-property name=\"");
+ sb.append(entryName);
+ sb.append("\"");
+ if (props.containsKey("description")) {
+ sb.append(" description=\"");
+ sb.append(props.get("description"));
+ sb.append("\"");
+ }
+ sb.append(" >\n");
+ if (!props.containsKey("attributes"))
+ sb.append(" <c:simple-property name=\"").append(entryName).append("\" />\n");
+ else {
+ doIndent(indent,sb);
+ sb.append("<c:map-property name=\"").append(entryName).append("\">\n");
+ System.out.println(sb.toString());
+ createProperties(doMetrcis, (Map<String, Object>) props.get("attributes"), indent + 4);
+ sb = new StringBuilder();
+ doIndent(indent,sb);
+ sb.append("</c:map-property>\n");
+ }
+ sb.append("</c:list-property>");
+ System.out.println(sb.toString());
continue;
commit c308e4477615f11cfae09d93fc486e34622b71f8
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 13 11:24:29 2011 +0200
Support embedded maps.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index cef3d9e..ac57b57 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -106,42 +106,43 @@ public class Domain2Descriptor {
Map<String,Object> props = (Map<String, Object>) entry.getValue();
+ String entryName = entry.getKey();
Type ptype = getTypeFromProps(props);
- String typeString;
-
- switch (ptype) {
- case INT:
- typeString = "integer"; break;
- case STRING:
- typeString = "string"; break;
- case BOOLEAN:
- typeString = "boolean"; break;
- case LONG:
- typeString = "long"; break;
- case BIG_DECIMAL:
- typeString = "long"; break; // TODO better float or double?
- case LIST:
- typeString = "-list-";
- break; // Handled below
- case OBJECT: // an embedded map
- typeString = "-object-";
- System.out.println("<c:list-property name=\"" + entry.getKey() +"\" description=\"" +
+ String typeString = getTypeStringForTypeAndName(ptype, entryName);
+
+ if (ptype == Type.OBJECT) {
+ System.out.println("<c:map-property name=\"" + entryName +"\" description=\"" +
props.get("description") + "\" >");
- createProperties(doMetrcis,
- (Map<String, Object>) ((Map<String, Object>) entry.getValue()).get("attributes"), indent+4);
- System.out.println("</c:list-property>");
+ Map<String, Object> attributesMap1 = (Map<String, Object>) ((Map<String, Object>) entry.getValue()).get(
+ "attributes");
+ if (attributesMap1!=null)
+ createProperties(doMetrcis,
+ attributesMap1, indent+4);
+ else {
+ for (Map.Entry<String,Object> emapEntry : ((Map<String,Object>)entry.getValue()).entrySet()) {
+ String key = emapEntry.getKey();
+ if (key.equals("type") || key.equals("description") || key.equals("required"))
+ continue;
+
+ Map<String,Object> emapEntryValue = (Map<String, Object>) emapEntry.getValue();
+ String ts = getTypeStringForTypeAndName(getTypeFromProps(emapEntryValue),key);
+ StringBuilder sb = generateProperty(indent, emapEntryValue,ts,emapEntry.getKey(),getAccessType(emapEntryValue));
+ System.out.println(sb.toString());
+
+ }
+ }
+
+ System.out.println("</c:map-property>");
continue;
- default:
- typeString = "- unknown -";
- System.err.println("Unknown type " + ptype + " for " + entry.getKey());
+
}
if (ptype== Type.LIST && !doMetrcis) {
- System.out.println("<c:list-property name=\"" + entry.getKey() +"\" >");
- System.out.println(" <c:simple-property name=\"" + entry.getKey() + "\" />");
+ System.out.println("<c:list-property name=\"" + entryName +"\" >");
+ System.out.println(" <c:simple-property name=\"" + entryName + "\" />");
System.out.println("</c:list-property>");
@@ -149,9 +150,7 @@ public class Domain2Descriptor {
continue;
}
- String accessType = (String) props.get("access-type");
- if (accessType==null)
- accessType = "read-only"; // default of as7
+ String accessType = getAccessType(props);
if (doMetrcis) {
if (!accessType.equals("metric"))
continue;
@@ -159,7 +158,7 @@ public class Domain2Descriptor {
StringBuilder sb = new StringBuilder();
doIndent(indent,sb);
sb.append("<metric property=\"");
- sb.append(entry.getKey()).append('"');
+ sb.append(entryName).append('"');
if (ptype== Type.STRING)
sb.append(" dataType=\"trait\"");
@@ -177,43 +176,83 @@ public class Domain2Descriptor {
if (accessType.equals("metric"))
continue;
- StringBuilder sb = new StringBuilder();
- doIndent(indent,sb);
- sb.append("<c:simple-property name=\"");
- sb.append(entry.getKey()).append('"');
+ StringBuilder sb = generateProperty(indent, props, typeString, entryName, accessType);
- Object required = props.get("required");
- if (required != null && (Boolean) required) {
- sb.append(" required=\"true\"");
- }
- else {
- sb.append(" required=\"false\"");
- }
+ System.out.println(sb.toString());
+ }
+ }
+ }
- sb.append(" type=\"").append(typeString).append("\"");
- sb.append(" readOnly=\"");
- if (accessType!=null && accessType.equals("read-only")) // TODO if no access-type is given, the one from the parent applies
- sb.append("true");
- else
- sb.append("false");
- sb.append('"');
-
- Object defVal = props.get("default");
- if (defVal!=null) {
- sb.append(" defaultValue=\"").append(defVal).append('\"');
- }
+ private String getAccessType(Map<String, Object> props) {
+ String accessType = (String) props.get("access-type");
+ if (accessType==null)
+ accessType = "read-only"; // default of as7
+ return accessType;
+ }
- String description = (String) props.get("description");
- if (description!=null) {
- if (sb.length()+description.length() > 120)
- sb.append("\n ");
- sb.append(" description=\"").append(description).append('"');
- }
- sb.append("/>");
+ private String getTypeStringForTypeAndName(Type ptype, String entryName) {
+ String typeString;
+
+ switch (ptype) {
+ case INT:
+ typeString = "integer"; break;
+ case STRING:
+ typeString = "string"; break;
+ case BOOLEAN:
+ typeString = "boolean"; break;
+ case LONG:
+ typeString = "long"; break;
+ case BIG_DECIMAL:
+ typeString = "long"; break; // TODO better float or double?
+ case LIST:
+ typeString = "-list-";
+ break; // Handled below
+ case OBJECT: // an embedded map
+ typeString = "-object-";
+ break; // Handled below
+ default:
+ typeString = "- unknown -";
+ System.err.println("Unknown type " + ptype + " for " + entryName);
+ }
+ return typeString;
+ }
- System.out.println(sb.toString());
- }
+ private StringBuilder generateProperty(int indent, Map<String, Object> props, String typeString, String entryName,
+ String accessType) {
+ StringBuilder sb = new StringBuilder();
+ doIndent(indent,sb);
+ sb.append("<c:simple-property name=\"");
+ sb.append(entryName).append('"');
+
+ Object required = props.get("required");
+ if (required != null && (Boolean) required) {
+ sb.append(" required=\"true\"");
+ }
+ else {
+ sb.append(" required=\"false\"");
+ }
+
+ sb.append(" type=\"").append(typeString).append("\"");
+ sb.append(" readOnly=\"");
+ if (accessType!=null && accessType.equals("read-only")) // TODO if no access-type is given, the one from the parent applies
+ sb.append("true");
+ else
+ sb.append("false");
+ sb.append('"');
+
+ Object defVal = props.get("default");
+ if (defVal!=null) {
+ sb.append(" defaultValue=\"").append(defVal).append('\"');
+ }
+
+ String description = (String) props.get("description");
+ if (description!=null) {
+ if (sb.length()+description.length() > 120)
+ sb.append("\n ");
+ sb.append(" description=\"").append(description).append('"');
}
+ sb.append("/>");
+ return sb;
}
private void doIndent(int indent, StringBuilder sb) {
commit 8ad8f978ec24bbd9e32e91e72f5985418645fc32
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 12 16:55:15 2011 +0200
More properties for the web subsystem and better handling of properties.
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 a73179a..22aa90b 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
@@ -205,7 +205,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
else {
// property is null? Check if it is required
if (propDef.isRequired()) {
- propertySimple = new PropertySimple(propDef.getName(),null);
+ String defaultValue = ((PropertyDefinitionSimple) propDef).getDefaultValue();
+ propertySimple = new PropertySimple(propDef.getName(),defaultValue);
ret.put(propertySimple);
}
}
@@ -312,11 +313,11 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
else if (memberDefinition instanceof PropertyDefinitionSimple) {
String name = memberDefinition.getName();
- Iterator<String> keys = sub.getFieldNames();
+ Iterator<JsonNode> keys = sub.getElements();
while(keys.hasNext()) {
- String entryKey = keys.next();
+ JsonNode entry = keys.next();
- PropertySimple propertySimple = new PropertySimple(name,entryKey);
+ PropertySimple propertySimple = new PropertySimple(name,entry.getTextValue());
propertyList.add(propertySimple);
}
}
@@ -329,7 +330,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
Map<String,PropertyDefinition> memberDefMap = mapDef.getPropertyDefinitions();
for (Map.Entry<String,PropertyDefinition> maEntry : memberDefMap.entrySet()) {
JsonNode valueNode = json.findValue(maEntry.getKey());
- PropertySimple p = putProperty(valueNode,maEntry.getValue());
+ PropertySimple p = putProperty(valueNode, maEntry.getValue());
System.out.println(p);
pm.put(p);
}
@@ -345,6 +346,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
String name = def.getName();
PropertySimpleType type = ((PropertyDefinitionSimple) def).getType();
PropertySimple ps;
+
+ if (value==null) {
+ if (def instanceof PropertyDefinitionSimple) {
+ PropertyDefinitionSimple pds = (PropertyDefinitionSimple) def;
+ return new PropertySimple(name,pds.getDefaultValue());
+ }
+ else
+ return new PropertySimple(name,null);
+ }
+
switch (type) {
case BOOLEAN:
ps = new PropertySimple(name,value.getBooleanValue());
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index d61f963..cef3d9e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -141,7 +141,7 @@ public class Domain2Descriptor {
if (ptype== Type.LIST && !doMetrcis) {
System.out.println("<c:list-property name=\"" + entry.getKey() +"\" >");
- System.out.println(" <c:simple-property name=\"" + entry.getKey() + "\" />");
+ System.out.println(" <c:simple-property name=\"" + entry.getKey() + "\" />");
System.out.println("</c:list-property>");
@@ -173,7 +173,7 @@ public class Domain2Descriptor {
System.out.println(sb.toString());
}
- else {
+ else { // configuration
if (accessType.equals("metric"))
continue;
@@ -186,6 +186,9 @@ public class Domain2Descriptor {
if (required != null && (Boolean) required) {
sb.append(" required=\"true\"");
}
+ else {
+ sb.append(" required=\"false\"");
+ }
sb.append(" type=\"").append(typeString).append("\"");
sb.append(" readOnly=\"");
@@ -197,7 +200,7 @@ public class Domain2Descriptor {
Object defVal = props.get("default");
if (defVal!=null) {
- sb.append(" default=\"").append(defVal).append('\"');
+ sb.append(" defaultValue=\"").append(defVal).append('\"');
}
String description = (String) props.get("description");
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 bbd7ba3..b0089f7 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
@@ -482,9 +482,48 @@
<metric property="requestCount" measurementType="trendsup" displayType="summary"/>
<resource-configuration>
- <c:simple-property name="protocol" required="false" description="The web connector protocol."/>
- <c:simple-property name="socket-binding" required="false" description="The web connector socket-binding reference, this connector should be bound to."/>
- <c:simple-property name="scheme" required="false" description="The web connector scheme"/>
+ <c:simple-property name="protocol" required="true" type="string" readOnly="true" description="The web connector protocol."/>
+ <c:simple-property name="socket-binding" required="true" type="string" readOnly="true"
+ description="The web connector socket-binding reference, this connector should be bound to."/>
+ <c:simple-property name="scheme" type="string" readOnly="true" default="http" description="The web connector scheme."/>
+ <c:simple-property name="executor" type="string" readOnly="true" required="false"
+ description="The name of the executor that should be used for the processing threads of this connector. Defaults to using an internal pool."/>
+ <c:simple-property name="enabled" type="boolean" readOnly="true" defaultValue="true"
+ description="Defines whether the connector should be started on startup."/>
+ <c:simple-property name="enable-lookups" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable DNS lookups for Servlet API."/>
+ <c:simple-property name="proxy-name" type="string" readOnly="true" required="false"
+ description="The host name that will be used when sending a redirect. The default value is null."/>
+ <c:simple-property name="proxy-port" type="integer" readOnly="true" required="false"
+ description="The port that will be used when sending a redirect."/>
+ <c:simple-property name="max-post-size" type="integer" readOnly="true" defaultValue="2097152"
+ description="Maximum size in bytes of a POST request that can be parsed by the container."/>
+ <c:simple-property name="max-save-post-size" type="integer" readOnly="true" defaultValue="4096"
+ description="Maximum size in bytes of a POST request that will be saved during certain authentication schemes."/>
+ <c:simple-property name="secure" type="boolean" readOnly="true" defaultValue="false"
+ description="Indicates if content sent or recieved by the connector is secured from the user perspective."/>
+ <c:simple-property name="redirect-port" type="integer" readOnly="true" defaultValue="8443"
+ description="The port for redirection to a secure connector."/>
+ <c:simple-property name="max-connections" type="integer" readOnly="true" required="false"
+ description="Amount of concurrent connections that can be processed by the connector with optimum performance. The default value depends on the connector used."/>
+ <c:list-property name="virtual-server" description="The list of virtual servers that can be accessed through this connector. The default is to allow all virtual servers.">
+ <c:simple-property name="virtual-server" />
+ </c:list-property>
+ <c:map-property name="ssl" description="The SSL configuration of the connector." >
+ <c:simple-property name="name" type="string" readOnly="true" description="The configuration name."/>
+ <c:simple-property name="key-alias" type="string" readOnly="true" description="The key alias."/>
+ <c:simple-property name="password" type="string" readOnly="true" description="Password."/>
+ <c:simple-property name="certificate-key-file" type="string" readOnly="true" description="Key file for the certificate."/>
+ <c:simple-property name="cipher-suite" type="string" readOnly="true" description="The allowed cipher suite."/>
+ <c:simple-property name="protocol" type="string" readOnly="true" description="The SSL protocols that are enabled."/>
+ <c:simple-property name="verify-client" type="string" readOnly="true" description="Enable client certificate verification."/>
+ <c:simple-property name="verify-depth" type="integer" readOnly="true" description="Limit certificate nesting."/>
+ <c:simple-property name="certificate-file" type="string" readOnly="true" description="Server certificate file."/>
+ <c:simple-property name="ca-certificate-file" type="string" readOnly="true" description="Certificate authority."/>
+ <c:simple-property name="ca-revocation-url" type="string" readOnly="true" description="Certificate authority revocation list."/>
+ <c:simple-property name="session-cache-size" type="string" readOnly="true" description="SSL session cache."/>
+ <c:simple-property name="session-timeout" type="string" readOnly="true" description="SSL session cache timeout."/>
+ </c:map-property>
</resource-configuration>
</service>
@@ -497,13 +536,24 @@
</plugin-configuration>
<resource-configuration>
- <c:simple-property name="access-log"/>
- <c:list-property name="alias" description="The virtual server aliases">
- <c:simple-property name="alias"/>
+ <c:list-property name="alias" >
+ <c:simple-property name="alias" />
</c:list-property>
- <c:simple-property name="rewrite"/>
+ <c:simple-property name="default-web-module" type="string" readOnly="true" defaultValue="ROOT.war"
+ description="The web module deployment name that will be mapped as the root webapp."/>
+ <c:map-property name="access-log" description="The access log configuration for this virtual server." >
+ <c:simple-property name="pattern" type="string" readOnly="true" defaultValue="common" description="The access log pattern."/>
+ <c:simple-property name="resolve-hosts" type="boolean" readOnly="true" defaultValue="false" description="Host resolution."/>
+ <c:simple-property name="extended" type="boolean" readOnly="true" defaultValue="false"
+ description="Enable extended pattern, with more options."/>
+ <c:simple-property name="prefix" type="string" readOnly="true" description="Prefix for the log file name."/>
+ <c:simple-property name="rotate" type="boolean" readOnly="true" defaultValue="true" description="Rotate the access log every day."/>
+ <!--<c:simple-property name="directory" description="The location for the access logging." />-->
+ </c:map-property>
+ <!--<c:list-property name="rewrite" >-->
+ <!--<c:simple-property name="rewrite" />-->
+ <!--</c:list-property>-->
</resource-configuration>
-
</service>
commit 3823cbfce3711e0903dcd2288a6b95899859a7d7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 12 14:45:27 2011 +0200
Bumb version to follow master.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 38cdfa0..7593f18 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -10,7 +10,7 @@
<parent>
<groupId>org.rhq</groupId>
<artifactId>rhq-plugins-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
+ <version>4.1.0-SNAPSHOT</version>
</parent>
<groupId>org.rhq</groupId>
commit c600bb6926683ee771ca11a3d1b69cd6722088f0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 12 13:06:13 2011 +0200
Support default values if provided.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index ab317dc..d61f963 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -48,13 +48,13 @@ public class Domain2Descriptor {
private void run(String[] args) {
- boolean doMetrcis = false;
+ boolean doMetrics = false;
int pos = 0;
if (args[0].startsWith("-")) {
if (args[0].equals("-m"))
- doMetrcis = true;
+ doMetrics = true;
else if (args[0].equals("-p"))
- doMetrcis = false;
+ doMetrics = false;
else {
usage();
return;
@@ -72,7 +72,7 @@ public class Domain2Descriptor {
List<PROPERTY_VALUE> address = pathToAddress(path);
Operation op = new Operation("read-resource-description",address); // ,"operations",true);
op.addAdditionalProperty("recursive","true");
- if (doMetrcis)
+ if (doMetrics)
op.addAdditionalProperty("include-runtime",true);
ComplexResult res = (ComplexResult) conn.execute(op,true);
if (!res.isSuccess()) {
@@ -94,7 +94,7 @@ public class Domain2Descriptor {
attributesMap = (Map<String, Object>) resMap.get("attributes");
}
- createProperties(doMetrcis, attributesMap, 0);
+ createProperties(doMetrics, attributesMap, 0);
}
@@ -195,6 +195,11 @@ public class Domain2Descriptor {
sb.append("false");
sb.append('"');
+ Object defVal = props.get("default");
+ if (defVal!=null) {
+ sb.append(" default=\"").append(defVal).append('\"');
+ }
+
String description = (String) props.get("description");
if (description!=null) {
if (sb.length()+description.length() > 120)
commit 99e9fe5029899b1d53481b90ca8577ff9df8ac61
Merge: f751fc8 7d3d67f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 12 12:29:20 2011 +0200
Merge branch 'master' into as7plugin
commit f751fc8abe6f0562386fdfae5e2e3946e40abc03
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 12 09:36:58 2011 +0200
Get rid of some bogus stuff
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 3d4f335..bbd7ba3 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
@@ -156,9 +156,6 @@
</plugin-configuration>
- <content name="deployment" category="deployable" isCreationType="true" description="Deployments on this domain">
- </content>
-
<resource-configuration>
<c:simple-property name="profile" />
<c:simple-property name="socket-binding-group"/>
@@ -174,11 +171,10 @@
<c:simple-property name="path" default="deployment" readOnly="true"/>
</plugin-configuration>
- <content name="file" category="deployable" isCreationType="true" description="Deployments on this domain">
+ <content name="file" category="deployable" isCreationType="true" description="Deployments on this server group">
<configuration>
<c:group name="deployment" displayName="Deployment Options">
<c:simple-property name="runtimeName" required="true"/>
- <c:simple-property name="alreadyUploaded" type="boolean" description="Was this already uploaded to the Domain? TODO"/>
</c:group>
</configuration>
</content>
@@ -224,8 +220,14 @@
</plugin-configuration>
<content name="file" category="deployable" isCreationType="true" description="Deployments on this domain">
+ <configuration>
+ <c:group name="deployment" displayName="Deployment Options">
+ <c:simple-property name="runtimeName" required="true"/>
+ </c:group>
+ </configuration>
</content>
+
<resource-configuration>
<c:simple-property name="name" readOnly="true"/>
<c:simple-property name="runtime-name" readOnly="true"/>
commit e735bdab1e57ffbf8e8898ae37f4f0e9cedd9f08
Merge: 05bd876 a62f196
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 11 09:19:34 2011 +0200
Merge branch 'master' into as7plugin
commit 05bd876ef224ec81424a5892c4e48b0b80f31fb7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 11 09:17:30 2011 +0200
Prevent NPE if processInfo is null.
diff --git a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java
index 9bd3859..d50f324 100644
--- a/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java
+++ b/modules/plugins/samba/src/main/java/org/rhq/plugins/samba/SambaServerComponent.java
@@ -152,16 +152,18 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
NetworkStats stats = resourceContext.getSystemInformation().getNetworkStats("localhost", PORT);
-
- processInfo.refresh();
-
- for (MeasurementScheduleRequest request : metrics) {
- if (request.getName().startsWith("NetworkStat.")) {
- int val = stats.getByName(request.getName().substring("NetworkStat.".length()));
- report.addData(new MeasurementDataNumeric(request, (double) val));
- } else if (request.getName().startsWith("Process.")) {
- Double value = ObjectUtil.lookupDeepNumericAttributeProperty(processInfo, request.getName().substring("Process.".length()));
- report.addData(new MeasurementDataNumeric(request, value));
+
+ if (processInfo!=null) {
+ processInfo.refresh();
+
+ for (MeasurementScheduleRequest request : metrics) {
+ if (request.getName().startsWith("NetworkStat.")) {
+ int val = stats.getByName(request.getName().substring("NetworkStat.".length()));
+ report.addData(new MeasurementDataNumeric(request, (double) val));
+ } else if (request.getName().startsWith("Process.")) {
+ Double value = ObjectUtil.lookupDeepNumericAttributeProperty(processInfo, request.getName().substring("Process.".length()));
+ report.addData(new MeasurementDataNumeric(request, value));
+ }
}
}
}
@@ -269,7 +271,7 @@ public class SambaServerComponent extends AugeasConfigurationComponent implement
if (args != null) {
processExecution.setArguments(args.split(" "));
}
-
+
processExecution.setCaptureOutput(true);
processExecution.setWaitForCompletion(1000L);
processExecution.setKillOnTimeout(true);
commit 5a31be172085a5e029ae9fb0525de7516562042d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue May 10 21:02:32 2011 +0200
Add datasource metrics and take care of the "no metrics available" response.
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 72ab4dd..a73179a 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
@@ -151,16 +151,17 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
if (!res.isSuccess())
continue;
- String val = (String) res.getResult();
+ String val = (String) res.getResult();
if (req.getDataType()== DataType.MEASUREMENT) {
-
- try {
- Double d = Double.parseDouble(val);
- MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
- report.addData(data);
- } catch (NumberFormatException e) {
- log.warn("Non numeric input for [" + req.getName() + "] : [" + val + "]");
+ if (!val.equals("no metrics available")) { // AS 7 returns this
+ try {
+ Double d = Double.parseDouble(val);
+ MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
+ report.addData(data);
+ } catch (NumberFormatException e) {
+ log.warn("Non numeric input for [" + req.getName() + "] : [" + val + "]");
+ }
}
} else if (req.getDataType()== DataType.TRAIT) {
MeasurementDataTrait data = new MeasurementDataTrait(req,val);
@@ -196,12 +197,18 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
if (propDef instanceof PropertyDefinitionSimple) {
PropertySimple propertySimple;
- if (sub!=null)
+ if (sub!=null) {
+ // Property is non-null -> return it.
propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
+ ret.put(propertySimple);
+ }
else {
- propertySimple = new PropertySimple(propDef.getName(),"- null -"); // TODO store it at all when it is null?
+ // property is null? Check if it is required
+ if (propDef.isRequired()) {
+ propertySimple = new PropertySimple(propDef.getName(),null);
+ ret.put(propertySimple);
+ }
}
- ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
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 50939ae..3d4f335 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
@@ -568,6 +568,28 @@
<c:simple-property name="path" readOnly="true" default="data-source"/>
</plugin-configuration>
+ <metric property="PreparedStatementCacheCurrentSize"
+ description="The number of prepared and callable statements currently cached in the statement cache"/>
+ <metric property="PreparedStatementCacheMissCount"
+ description="The number of times that a statement request could not be satisfied with a statement from the cache"/>
+ <metric property="PreparedStatementCacheAddCount" description="The number of statements added to the statement cache"/>
+ <metric property="PreparedStatementCacheAccessCount" description="The number of times that the statement cache was accessed"/>
+ <metric property="PreparedStatementCacheDeleteCount" description="The number of statements discarded from the cache"/>
+ <metric property="PreparedStatementCacheHitCount" description="The number of times that statements from the cache were used"/>
+ <metric property="AverageBlockingTime" description="The average time spent blocking for a connection"/>
+ <metric property="MaxWaitTime" description="The maximum wait time for a connection"/>
+ <metric property="ActiveCount" description="The active count"/>
+ <metric property="CreatedCount" description="The created count"/>
+ <metric property="MaxCreationTime" description="The maximum time for creating a physical connection"/>
+ <metric property="MaxWaitCount" description="The maximum number of threads waiting for a connection"/>
+ <metric property="TotalCreationTime" description="The total time spent creating physical connections"/>
+ <metric property="AvailableCount" description="The available count"/>
+ <metric property="MaxUsedCount" description="The maximum number of connections used"/>
+ <metric property="TimedOut" description="The timed out count"/>
+ <metric property="TotalBlockingTime" description="The total blocking time"/>
+ <metric property="AverageCreationTime" description="The average time spent creating a physical connection"/>
+ <metric property="DestroyedCount" description="The destroyed count"/>
+
<resource-configuration>
<c:simple-property name="connection-url" required="true" type="string" readOnly="true" description="The JDBC driver connection URL"/>
<c:simple-property name="driver-class" required="true" type="string" readOnly="true"
commit e2d2375fe00d761acf5805255c719bbd01cff397
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue May 10 18:29:33 2011 +0200
Metrics have no type
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index e61ff3c..ab317dc 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -160,7 +160,6 @@ public class Domain2Descriptor {
doIndent(indent,sb);
sb.append("<metric property=\"");
sb.append(entry.getKey()).append('"');
- sb.append(" type=\"").append(typeString).append("\"");
if (ptype== Type.STRING)
sb.append(" dataType=\"trait\"");
commit 9d9c11e54fcd7fccaac08c5d336aaef83bff8995
Merge: 33f3c42 ae6d42e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue May 10 18:12:12 2011 +0200
Merge branch 'master' into as7plugin
commit 33f3c425d2c908379eb4a03f225690e214280287
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon May 9 17:02:00 2011 +0200
Fix uploading of deployments
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index b369a95..80e8ea4 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -42,7 +43,9 @@ import org.codehaus.jackson.map.ObjectMapper;
*/
public class ASUploadConnection {
- private static final String BOUNDARY = "-----------------------------261773107125236";
+ private static final String BOUNDARY_PARAM = "NeAG1QNIHHOyB5joAS7Rox!!";
+
+ private static final String BOUNDARY = "--" + BOUNDARY_PARAM;
private static final String CRLF = "\r\n";
@@ -71,6 +74,7 @@ public class ASUploadConnection {
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod(POST_REQUEST_METHOD);
+ connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY_PARAM);
// Grab the test WAR file and get a stream to its contents to be included in the POST.
os = new BufferedOutputStream(connection.getOutputStream());
@@ -92,6 +96,7 @@ public class ASUploadConnection {
os.flush();
int code = connection.getResponseCode();
+ System.err.println("Response code " + code);
if (code==500)
is = connection.getErrorStream();
else
@@ -128,15 +133,13 @@ public class ASUploadConnection {
}
- private byte[] buildPostRequestHeader(String fileName) {
+ private byte[] buildPostRequestHeader(String fileName) throws UnsupportedEncodingException {
final StringBuilder builder = new StringBuilder();
- builder.append(buildPostRequestHeaderSection("form-data; name=\"test1\"", "", "test1"));
- builder.append(buildPostRequestHeaderSection("form-data; name=\"test2\"", "", "test2"));
builder.append(buildPostRequestHeaderSection("form-data; name=\"file\"; filename=\""+fileName+"\"", "application/octet-stream", ""));
- return builder.toString().getBytes();
+ return builder.toString().getBytes("US-ASCII");
}
- private String buildPostRequestHeaderSection(final String contentDisposition, final String contentType, final String content) {
+ private StringBuilder buildPostRequestHeaderSection(final String contentDisposition, final String contentType, final String content) {
final StringBuilder builder = new StringBuilder();
builder.append(BOUNDARY);
builder.append(CRLF);
@@ -152,16 +155,16 @@ public class ASUploadConnection {
builder.append(content);
}
builder.append(CRLF);
- return builder.toString();
+ return builder;
}
- private byte[] buildPostRequestFooter() {
+ private byte[] buildPostRequestFooter() throws UnsupportedEncodingException{
final StringBuilder builder = new StringBuilder();
builder.append(CRLF);
builder.append(BOUNDARY);
builder.append("--");
builder.append(CRLF);
- return builder.toString().getBytes();
+ return builder.toString().getBytes("US-ASCII");
}
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 48b0094..50939ae 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
@@ -531,9 +531,9 @@
<c:simple-property name="bean-validation-enabled" required="true" type="boolean" readOnly="true"
description="Specify whether bean validation is enabled"/>
<c:simple-property name="archive-validation-enabled" type="boolean" readOnly="true" description="Enabling the validation"/>
- <c:simple-property name="archive-validation-fail-on-error" type="boolean" readOnly="true"
+ <c:simple-property name="archive-validation-fail-on-error" type="boolean" readOnly="true" default="true"
description="Should an archive validation error report fail the deployment. Default: true"/>
- <c:simple-property name="archive-validation-fail-on-warn" type="boolean" readOnly="true"
+ <c:simple-property name="archive-validation-fail-on-warn" type="boolean" readOnly="true" default="false"
description="Should an archive validation warning report fail the deployment. Default: false"/>
<c:simple-property name="cached-connection-manager-debug" type="boolean" readOnly="true"
description="enable/disable debug information logging for cached connection manager"/>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index e4e9d70..b1eb277 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -30,6 +30,7 @@ import org.testng.annotations.Test;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.Result;
/**
* Test uploading and deploying to the domain
@@ -46,6 +47,17 @@ public class UploadAndDeployTest {
private static final int DC_HTTP_PORT = 9990;
@Test(timeOut = 60*1000L, enabled = true)
+ public void testUploadOnly() throws Exception {
+
+ String bytes_value = prepare();
+
+ assert bytes_value != null;
+
+ System.out.println("sha: " + bytes_value);
+
+ }
+
+ @Test(timeOut = 60*1000L, enabled = true)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -79,7 +91,7 @@ public class UploadAndDeployTest {
System.out.println("Add to server group done: " + ret);
System.out.flush();
- assert ret.has("outcome") : "Ret not valied " + ret.toString();
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();
@@ -88,7 +100,7 @@ public class UploadAndDeployTest {
Operation undeploy = new Operation("remove",serverGroupAddress);
ret = connection.executeRaw(undeploy);
- assert ret.has("outcome") : "Ret not valied " + ret.toString();
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success " + ret.getTextValue();
@@ -97,7 +109,7 @@ public class UploadAndDeployTest {
Operation remove = new Operation("remove",deploymentsAddress);
ret = connection.executeRaw(remove);
- assert ret.has("outcome") : "Ret not valied " + ret.toString();
+ assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from domain was no success " + ret.getTextValue();
System.out.flush();
@@ -156,13 +168,19 @@ public class UploadAndDeployTest {
InputStream fis = getClass().getClassLoader().getResourceAsStream(UPLOAD_FILE);
- int b;
- while ((b = fis.read())!=-1) {
- os.write(b);
+ final byte[] buffer = new byte[1024];
+ int numRead = 0;
+
+ while(numRead > -1) {
+ numRead = fis.read(buffer);
+ if(numRead > 0) {
+ os.write(buffer,0,numRead);
+ }
}
fis.close();
JsonNode node = conn.finishUpload();
System.out.println(node);
+ assert node != null : "No result from upload - node was null";
assert node.has("outcome") : "No outcome from upload";
String outcome = node.get("outcome").getTextValue();
assert outcome.equals("success") : "Upload was no success" + outcome;
commit 2f14177fb1381441fafb767076439f1e401d15bc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 6 11:24:52 2011 +0200
Add more subsystems
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 04686c4..48b0094 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
@@ -507,6 +507,42 @@
</server>
+ <server name="General JCA connectors"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ description="General settings of the JCA engine. Not nexessarily for end-users"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=connector"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="default-workmanager-short-running-thread-pool" required="true" type="string" readOnly="true"
+ description="Specify the name of short running thread pool"/>
+ <c:simple-property name="default-workmanager-long-running-thread-pool" required="true" type="string" readOnly="true"
+ description="Specify the name of long running thread pool"/>
+ <c:simple-property name="bean-validation-enabled" required="true" type="boolean" readOnly="true"
+ description="Specify whether bean validation is enabled"/>
+ <c:simple-property name="archive-validation-enabled" type="boolean" readOnly="true" description="Enabling the validation"/>
+ <c:simple-property name="archive-validation-fail-on-error" type="boolean" readOnly="true"
+ description="Should an archive validation error report fail the deployment. Default: true"/>
+ <c:simple-property name="archive-validation-fail-on-warn" type="boolean" readOnly="true"
+ description="Should an archive validation warning report fail the deployment. Default: false"/>
+ <c:simple-property name="cached-connection-manager-debug" type="boolean" readOnly="true"
+ description="enable/disable debug information logging for cached connection manager"/>
+ <c:simple-property name="cached-connection-manager-error" type="boolean" readOnly="true"
+ description="enable/disable error information logging for cached connection manager"/>
+ </resource-configuration>
+
+ </server>
+
<server name="Datasources"
discovery="SubsystemDiscovery"
class="BaseComponent"
@@ -629,6 +665,23 @@
</server>
+ <server name="ResourceAdapters"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=resource-adapters"/>
+ </plugin-configuration>
+ </server>
+
+
<server name="Threads"
discovery="SubsystemDiscovery"
class="BaseComponent"
@@ -689,6 +742,33 @@
</server>
+ <server name="Webservices"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=webservices"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="modify-soap-address" required="true" type="boolean" readOnly="true"
+ description="Whether the soap address can be modified."/>
+ <c:simple-property name="webservice-host" required="true" type="string" readOnly="true"
+ description="The WSDL, that is a required deployment artifact for an endpoint, has a &soap:address> element which points to the location of the endpoint. JBoss supports rewriting of that SOAP address. If the content of &soap:address> is a valid URL, JBossWS will not rewrite it unless 'modifySOAPAddress' is true. If the content of &soap:address> is not a valid URL, JBossWS will rewrite it using the attribute values given below. If 'webServiceHost' is set to 'jbossws.undefined.host', JBossWS uses requesters host when rewriting the &soap:address>"/>
+ <c:simple-property name="webservice-port" type="integer" readOnly="true"
+ description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ <c:simple-property name="webservice-secure-port" type="integer" readOnly="true"
+ description="The non-secure port that will be used for rewriting the SOAP address. If absent the port will be identified by querying the list of installed connectors."/>
+ </resource-configuration>
+ </server>
+
<service name="NetworkInterface"
discovery="SubsystemDiscovery"
class="BaseComponent"
commit fa33a38abec2ac915f128af5a9e262edc36c2f3f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 5 12:07:00 2011 +0200
Prevent a possible NPE.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index 8e42fdf..e61ff3c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -99,6 +99,9 @@ public class Domain2Descriptor {
}
private void createProperties(boolean doMetrcis, Map<String, Object> attributesMap, int indent) {
+ if (attributesMap==null)
+ return;
+
for (Map.Entry<String,Object> entry : attributesMap.entrySet()) {
Map<String,Object> props = (Map<String, Object>) entry.getValue();
commit 3f081f6dc8e72c207bc0bacb8465f8d6195418d7
Merge: ba33706 341a653
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed May 4 15:25:27 2011 +0200
Merge branch 'master' into as7plugin
commit ba33706d7029e1771a3329a429d1348d7c3a29a1
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon May 2 15:39:05 2011 +0200
Also handle nested elements.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
index 599f61c..8e42fdf 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -94,8 +94,11 @@ public class Domain2Descriptor {
attributesMap = (Map<String, Object>) resMap.get("attributes");
}
+ createProperties(doMetrcis, attributesMap, 0);
+ }
+ private void createProperties(boolean doMetrcis, Map<String, Object> attributesMap, int indent) {
for (Map.Entry<String,Object> entry : attributesMap.entrySet()) {
Map<String,Object> props = (Map<String, Object>) entry.getValue();
@@ -118,12 +121,21 @@ public class Domain2Descriptor {
case LIST:
typeString = "-list-";
break; // Handled below
+ case OBJECT: // an embedded map
+ typeString = "-object-";
+ System.out.println("<c:list-property name=\"" + entry.getKey() +"\" description=\"" +
+ props.get("description") + "\" >");
+ createProperties(doMetrcis,
+ (Map<String, Object>) ((Map<String, Object>) entry.getValue()).get("attributes"), indent+4);
+ System.out.println("</c:list-property>");
+
+ continue;
default:
typeString = "- unknown -";
System.err.println("Unknown type " + ptype + " for " + entry.getKey());
}
- if (ptype==Type.LIST && !doMetrcis) {
+ if (ptype== Type.LIST && !doMetrcis) {
System.out.println("<c:list-property name=\"" + entry.getKey() +"\" >");
System.out.println(" <c:simple-property name=\"" + entry.getKey() + "\" />");
@@ -134,14 +146,19 @@ public class Domain2Descriptor {
continue;
}
+ String accessType = (String) props.get("access-type");
+ if (accessType==null)
+ accessType = "read-only"; // default of as7
if (doMetrcis) {
- if (!props.get("access-type").equals("metric"))
+ if (!accessType.equals("metric"))
continue;
- StringBuilder sb = new StringBuilder("<metric property=\"");
+ StringBuilder sb = new StringBuilder();
+ doIndent(indent,sb);
+ sb.append("<metric property=\"");
sb.append(entry.getKey()).append('"');
sb.append(" type=\"").append(typeString).append("\"");
- if (ptype==Type.STRING)
+ if (ptype== Type.STRING)
sb.append(" dataType=\"trait\"");
String description = (String) props.get("description");
@@ -155,8 +172,12 @@ public class Domain2Descriptor {
}
else {
+ if (accessType.equals("metric"))
+ continue;
- StringBuilder sb = new StringBuilder("<c:simple-property name=\"");
+ StringBuilder sb = new StringBuilder();
+ doIndent(indent,sb);
+ sb.append("<c:simple-property name=\"");
sb.append(entry.getKey()).append('"');
Object required = props.get("required");
@@ -166,7 +187,7 @@ public class Domain2Descriptor {
sb.append(" type=\"").append(typeString).append("\"");
sb.append(" readOnly=\"");
- if (props.get("access-type").equals("read-only"))
+ if (accessType!=null && accessType.equals("read-only")) // TODO if no access-type is given, the one from the parent applies
sb.append("true");
else
sb.append("false");
@@ -183,8 +204,11 @@ public class Domain2Descriptor {
System.out.println(sb.toString());
}
}
+ }
-
+ private void doIndent(int indent, StringBuilder sb) {
+ for (int i = 0 ; i < indent ; i++)
+ sb.append(' ');
}
private Type getTypeFromProps(Map<String, Object> props) {
commit 07e330834624e13d48342c9a3e9ba5037490af11
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon May 2 10:47:44 2011 +0200
Remove unused import.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 03a0f12..a50ea45 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -29,7 +29,6 @@ import org.rhq.modules.plugins.jbossas7.json.ReadResource;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
commit d58b242f0d092d7b95b9e544edbc1eae5e32038c
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Apr 28 15:05:57 2011 +0200
Get rid of the old getLevelData() method. We are doing that via operation now.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 12d3ec6..eace9b8 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -26,13 +26,11 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLConnection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
-import org.jetbrains.annotations.Nullable;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
@@ -47,7 +45,6 @@ public class ASConnection {
private final Log log = LogFactory.getLog(ASConnection.class);
URL url;
String urlString;
- private StringBuilder builder;
private ObjectMapper mapper;
public ASConnection(String host, int port) {
@@ -63,64 +60,6 @@ public class ASConnection {
}
- @Deprecated
- JsonNode getLevelData(@Nullable String base, boolean recursive, boolean includeMetrics) throws Exception{
- String ops = null;
- if (recursive)
- ops = "recursive";
- if (includeMetrics)
- ops += "&include-runtime=true";
-
- return getLevelData(base,ops);
-}
-
- /**
- * Return the JSON-Object for a certain path.
- *
- * @param base Path to the object/subsystem. Can be null/"" for the base objects
- * @param ops OperationDescription to run on the api can be null
- * @return A JSONObject encoding the level plus sub levels provided
- * @throws Exception If anything goes wrong
- */
- @Deprecated
- JsonNode getLevelData(@Nullable String base, @Nullable String ops) throws Exception {
-
- URL url2;
- String spec;
- url2 = getBaseUrl(base, ops);
-
- JsonNode tree = null;
-
- URLConnection conn = url2.openConnection();
- InputStream inputStream = null;
- try {
- inputStream = conn.getInputStream();
- } catch (IOException e) {
- System.err.println(e.getMessage());
- return tree;
- }
- BufferedReader in = new BufferedReader(new InputStreamReader(
- inputStream));
- try {
- String line;
- StringBuilder builder = new StringBuilder();
- while ((line = in.readLine()) != null) {
- builder.append(line);
- }
-
- ObjectMapper mapper = new ObjectMapper();
-
- tree = mapper.readTree(builder.toString());
-
- } catch (IOException ioe) {
- System.err.println("for in put " + url2 + " : " + ioe.getMessage());
- } finally {
- in.close();
- }
-
- return tree;
- }
-
static boolean isErrorReply(JsonNode in) {
if (in == null)
@@ -182,14 +121,14 @@ public class ASConnection {
br = new BufferedReader(new InputStreamReader(
inputStream));
String line;
- builder = new StringBuilder();
+ StringBuilder builder = new StringBuilder();
while ((line = br.readLine()) != null) {
builder.append(line);
}
String outcome;
JsonNode operationResult=null;
- if (builder!=null) {
+ if (builder !=null) {
outcome= builder.toString();
operationResult = mapper.readTree(outcome);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 50dd55c..03a0f12 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -25,6 +25,7 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
+import org.rhq.modules.plugins.jbossas7.json.ReadResource;
import java.util.ArrayList;
import java.util.Arrays;
@@ -106,7 +107,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
JsonNode json ;
if (!recursive)
- json = connection.getLevelData(path,recursive, false);
+ json = connection.executeRaw(new ReadResource(parentComponent.pathToAddress(path)));
else {
List<PROPERTY_VALUE> addr ;
addr = parentComponent.pathToAddress(parentPath);
commit ae5428243c5ae6639e3acac97ae476ad05b4f825
Merge: 40c5ede 15a53e5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Apr 28 10:48:43 2011 +0200
Merge branch 'master' into as7plugin
commit 40c5eded43cd9e4d6050c9ca5ecbd06ddd1cd5b1
Merge: 9dc32bc f50680d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 27 21:33:14 2011 +0200
Merge branch 'master' into as7plugin
commit 9dc32bcb1ff5af961cd980c7d0ec518057bedba2
Merge: 0559cb7 0086a69
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 27 16:18:48 2011 +0200
Merge branch 'master' into as7plugin
commit 0559cb7526a5804a39c9883f750dc217d3d096ca
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 20 08:58:28 2011 +0200
Add generating of <metric> elements.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
new file mode 100644
index 0000000..599f61c
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Descriptor.java
@@ -0,0 +1,247 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Generate properties from a domain dump
+ * @author Heiko W. Rupp
+ */
+public class Domain2Descriptor {
+
+ public static void main(String[] args) throws Exception {
+
+ if (args.length<1) {
+ usage();
+ System.exit(1);
+ }
+
+ Domain2Descriptor d2d = new Domain2Descriptor();
+ d2d.run(args);
+
+
+ }
+
+ private void run(String[] args) {
+
+ boolean doMetrcis = false;
+ int pos = 0;
+ if (args[0].startsWith("-")) {
+ if (args[0].equals("-m"))
+ doMetrcis = true;
+ else if (args[0].equals("-p"))
+ doMetrcis = false;
+ else {
+ usage();
+ return;
+ }
+ pos++;
+ }
+
+ String path = args[pos];
+ String childType = null;
+ if (args.length>pos+1)
+ childType = args[pos+1];
+
+ ASConnection conn = new ASConnection("localhost",9990);
+
+ List<PROPERTY_VALUE> address = pathToAddress(path);
+ Operation op = new Operation("read-resource-description",address); // ,"operations",true);
+ op.addAdditionalProperty("recursive","true");
+ if (doMetrcis)
+ op.addAdditionalProperty("include-runtime",true);
+ ComplexResult res = (ComplexResult) conn.execute(op,true);
+ if (!res.isSuccess()) {
+ System.err.println("Failure: " + res.getFailureDescription());
+ return;
+ }
+
+ Map<String,Object> attributesMap;
+
+ Map<String,Object> resMap = res.getResult();
+ if (childType!=null) {
+ Map childMap = (Map) resMap.get("children");
+ Map <String,Object> typeMap = (Map<String, Object>) childMap.get(childType);
+ Map descriptionMap = (Map) typeMap.get("model-description");
+ Map starMap = (Map) descriptionMap.get("*");
+ attributesMap = (Map<String, Object>) starMap.get("attributes");
+ }
+ else {
+ attributesMap = (Map<String, Object>) resMap.get("attributes");
+ }
+
+
+
+ for (Map.Entry<String,Object> entry : attributesMap.entrySet()) {
+
+ Map<String,Object> props = (Map<String, Object>) entry.getValue();
+
+
+ Type ptype = getTypeFromProps(props);
+ String typeString;
+
+ switch (ptype) {
+ case INT:
+ typeString = "integer"; break;
+ case STRING:
+ typeString = "string"; break;
+ case BOOLEAN:
+ typeString = "boolean"; break;
+ case LONG:
+ typeString = "long"; break;
+ case BIG_DECIMAL:
+ typeString = "long"; break; // TODO better float or double?
+ case LIST:
+ typeString = "-list-";
+ break; // Handled below
+ default:
+ typeString = "- unknown -";
+ System.err.println("Unknown type " + ptype + " for " + entry.getKey());
+ }
+
+ if (ptype==Type.LIST && !doMetrcis) {
+
+ System.out.println("<c:list-property name=\"" + entry.getKey() +"\" >");
+ System.out.println(" <c:simple-property name=\"" + entry.getKey() + "\" />");
+ System.out.println("</c:list-property>");
+
+
+
+ continue;
+ }
+
+ if (doMetrcis) {
+ if (!props.get("access-type").equals("metric"))
+ continue;
+
+ StringBuilder sb = new StringBuilder("<metric property=\"");
+ sb.append(entry.getKey()).append('"');
+ sb.append(" type=\"").append(typeString).append("\"");
+ if (ptype==Type.STRING)
+ sb.append(" dataType=\"trait\"");
+
+ String description = (String) props.get("description");
+ if (description!=null) {
+ if (sb.length()+description.length() > 120)
+ sb.append("\n ");
+ sb.append(" description=\"").append(description).append('"');
+ }
+ sb.append("/>");
+ System.out.println(sb.toString());
+
+ }
+ else {
+
+ StringBuilder sb = new StringBuilder("<c:simple-property name=\"");
+ sb.append(entry.getKey()).append('"');
+
+ Object required = props.get("required");
+ if (required != null && (Boolean) required) {
+ sb.append(" required=\"true\"");
+ }
+
+ sb.append(" type=\"").append(typeString).append("\"");
+ sb.append(" readOnly=\"");
+ if (props.get("access-type").equals("read-only"))
+ sb.append("true");
+ else
+ sb.append("false");
+ sb.append('"');
+
+ String description = (String) props.get("description");
+ if (description!=null) {
+ if (sb.length()+description.length() > 120)
+ sb.append("\n ");
+ sb.append(" description=\"").append(description).append('"');
+ }
+ sb.append("/>");
+
+ System.out.println(sb.toString());
+ }
+ }
+
+
+ }
+
+ private Type getTypeFromProps(Map<String, Object> props) {
+ Map<String,String> tMap = (Map<String, String>) props.get("type");
+ String type = tMap.get("TYPE_MODEL_VALUE");
+ Type ret = Type.valueOf(type);
+
+ return ret;
+ }
+
+ /**
+ * Convert a path in the form key=value,key=value... to a List of properties.
+ * @param path Path to translate
+ * @return List of properties
+ */
+ public List<PROPERTY_VALUE> pathToAddress(String path) {
+ if (path==null || path.isEmpty())
+ return Collections.emptyList();
+
+ List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
+ String[] components = path.split(",");
+ for (String component : components) {
+ String tmp = component.trim();
+
+ if (tmp.contains("=")) {
+ // strip / from the start of the key if it happens to be there
+ if (tmp.startsWith("/"))
+ tmp = tmp.substring(1);
+
+ String[] pair = tmp.split("=");
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]);
+ result.add(valuePair);
+ }
+ }
+
+ return result;
+ }
+
+
+
+ private static void usage() {
+ System.out.println("Domain2Properties [-p|-m] path type");
+ System.out.println(" path is of kind 'key=value[,key=value]+");
+ System.out.println(" -p create properties (default)");
+ System.out.println(" -m create metrics");
+ }
+
+ public enum Type {
+ STRING,
+ INT,
+ BOOLEAN,
+ LONG,
+ BIG_DECIMAL,
+ OBJECT,
+ LIST
+
+ ;
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Properties.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Properties.java
deleted file mode 100644
index 0b8b38e..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Properties.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import com.apple.java.Usage;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
-import org.rhq.modules.plugins.jbossas7.json.Operation;
-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
-
-/**
- * Generate properties from a domain dump
- * @author Heiko W. Rupp
- */
-public class Domain2Properties {
-
- public static void main(String[] args) throws Exception {
-
- if (args.length<2) {
- usage();
- System.exit(1);
- }
-
- Domain2Properties dp = new Domain2Properties();
- dp.run(args);
-
-
- }
-
- private void run(String[] args) {
-
- String path = args[0];
- String type = args[1];
-
- ASConnection conn = new ASConnection("localhost",9990);
-
- List<PROPERTY_VALUE> address = pathToAddress(path);
- Operation op = new Operation("read-resource-description",address,"operations",true);
- op.addAdditionalProperty("recursive","true");
- ComplexResult res = (ComplexResult) conn.execute(op,true);
- if (!res.isSuccess()) {
- System.err.println("Failure: " + res.getFailureDescription());
- return;
- }
-
-
- Map<String,Object> resMap = res.getResult();
- Map childMap = (Map) resMap.get("children");
- Map <String,Object> typeMap = (Map<String, Object>) childMap.get(type);
- Map descriptionMap = (Map) typeMap.get("model-description");
- Map starMap = (Map) descriptionMap.get("*");
- Map<String,Object> attributesMap = (Map<String, Object>) starMap.get("attributes");
-
-
-
- for (Map.Entry<String,Object> entry : attributesMap.entrySet()) {
-
- Map<String,Object> props = (Map<String, Object>) entry.getValue();
-
-
- Type ptype = getTypeFromProps(props);
- String typeString;
-
- switch (ptype) {
- case INT:
- typeString = "integer"; break;
- case STRING:
- typeString = "string"; break;
- case BOOLEAN:
- typeString = "boolean"; break;
- case LONG:
- typeString = "long"; break;
- case BIG_DECIMAL:
- typeString = "long"; break; // TODO bettter float or double?
- case LIST:
- typeString = "-list-";
- break; // Handled below
- default:
- typeString = "- unknown -";
- System.err.println("Unknown type " + ptype + " for " + entry.getKey());
- }
-
- if (ptype==Type.LIST) {
-
- System.out.println("<c:list-property name=\"" + entry.getKey() +"\" >");
- System.out.println(" <c:simple-property name=\"" + entry.getKey() + "\" />");
- System.out.println("</c:list-property>");
-
-
-
- continue;
- }
-
- StringBuilder sb = new StringBuilder("<c:simple-property name=\"");
- sb.append(entry.getKey()).append('"');
-
- if ((Boolean) props.get("required")) {
- sb.append(" required=\"true\"");
- }
-
- sb.append(" type=\"").append(typeString).append("\"");
- sb.append(" readOnly=\"");
- if (props.get("access-type").equals("read-only"))
- sb.append("true");
- else
- sb.append("false");
- sb.append('"');
-
- String description = (String) props.get("description");
- if (sb.length()+description.length() > 120)
- sb.append("\n ");
- sb.append(" description=\"").append(description).append('"');
- sb.append("/>");
-
- System.out.println(sb.toString());
- }
-
-
- }
-
- private Type getTypeFromProps(Map<String, Object> props) {
- Map<String,String> tMap = (Map<String, String>) props.get("type");
- String type = tMap.get("TYPE_MODEL_VALUE");
- Type ret = Type.valueOf(type);
-
- return ret;
- }
-
- /**
- * Convert a path in the form key=value,key=value... to a List of properties.
- * @param path Path to translate
- * @return List of properties
- */
- public List<PROPERTY_VALUE> pathToAddress(String path) {
- if (path==null || path.isEmpty())
- return Collections.emptyList();
-
- List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
- String[] components = path.split(",");
- for (String component : components) {
- String tmp = component.trim();
-
- if (tmp.contains("=")) {
- // strip / from the start of the key if it happens to be there
- if (tmp.startsWith("/"))
- tmp = tmp.substring(1);
-
- String[] pair = tmp.split("=");
- PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]);
- result.add(valuePair);
- }
- }
-
- return result;
- }
-
-
-
- private static void usage() {
- System.out.println("Domain2Properties path type");
- System.out.println(" path is of kind 'key=value[,key=value]+");
- }
-
- public enum Type {
- STRING,
- INT,
- BOOLEAN,
- LONG,
- BIG_DECIMAL,
- OBJECT,
- LIST
-
- ;
- }
-
-}
commit 47863657731b18878a50252743504ac825299636
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Apr 19 15:08:41 2011 +0200
Put the Domain below the DomainController node and remove the separate domain node. Also add some more properties.
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 f03f62c..72ab4dd 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
@@ -67,6 +67,7 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -316,13 +317,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
} // end List of ..
else if (propDef instanceof PropertyDefinitionMap) {
PropertyDefinitionMap mapDef = (PropertyDefinitionMap) propDef;
+ PropertyMap pm = new PropertyMap(mapDef.getName());
+
Map<String,PropertyDefinition> memberDefMap = mapDef.getPropertyDefinitions();
for (Map.Entry<String,PropertyDefinition> maEntry : memberDefMap.entrySet()) {
JsonNode valueNode = json.findValue(maEntry.getKey());
- System.out.println(valueNode);
PropertySimple p = putProperty(valueNode,maEntry.getValue());
- ret.put(p);
+ System.out.println(p);
+ pm.put(p);
}
+ ret.put(pm);
}
}
@@ -496,6 +500,99 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
@Override
public OperationResult invokeOperation(String name,
Configuration parameters) throws InterruptedException, Exception {
- return null; // TODO: Customise this generated block
+
+ if (!name.contains(":")) {
+ OperationResult badName = new OperationResult("Operation name did not contain a ':'");
+ badName.setErrorMessage("Operation name did not contain a ':'");
+ return badName;
+ }
+
+ int colonPos = name.indexOf(':');
+ String what = name.substring(0, colonPos);
+ String op = name.substring(colonPos+1);
+ Operation operation=null;
+
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
+
+ if (what.equals("server-group")) {
+ String groupName = parameters.getSimpleValue("name",null);
+ String profile = parameters.getSimpleValue("profile","default");
+
+ address.add(new PROPERTY_VALUE("server-group",groupName));
+
+ operation = new Operation(op,address,"profile",profile);
+ } else if (what.equals("server")) {
+
+ if (context.getResourceType().getName().equals("JBossAS-Managed")) {
+ String host = conf.getSimpleValue("domainHost","local");
+ address.add(new PROPERTY_VALUE("host",host));
+ address.add(new PROPERTY_VALUE("server-config",myServerName));
+ operation = new Operation(op,address);
+ }
+ else if (context.getResourceType().getName().equals("Host")) {
+ address.addAll(pathToAddress(getPath()));
+ String serverName = parameters.getSimpleValue("name",null);
+ address.add(new PROPERTY_VALUE("server-config",serverName));
+ Map<String,Object> props = new HashMap<String, Object>();
+ String serverGroup = parameters.getSimpleValue("group",null);
+ props.put("group",serverGroup);
+ if (op.equals("add")) {
+ props.put("name",serverName);
+ boolean autoStart = parameters.getSimple("auto-start").getBooleanValue();
+ props.put("auto-start",autoStart);
+ // TODO put more properties in
+ }
+
+ operation = new Operation(op,address,props);
+ }
+ } else if (what.equals("destination")) {
+ address.addAll(pathToAddress(getPath()));
+ String newName = parameters.getSimpleValue("name","");
+// String type = parameters.getSimpleValue("type","Queue").toLowerCase();
+// address.add(new PROPERTY_VALUE(type,newName));
+ String queueName = parameters.getSimpleValue("queue-address","");
+ Map<String,Object> props = new HashMap<String, Object>();
+ props.put("queue-address",queueName);
+ operation = new Operation(op,address);
+ } else if (what.equals("managed-server")) {
+ String chost = parameters.getSimpleValue("hostname","");
+ String serverName = parameters.getSimpleValue("servername","");
+ String serverGroup = parameters.getSimpleValue("server-group","");
+ String socketBindings = parameters.getSimpleValue("socket-bindings","");
+ String portS = parameters.getSimpleValue("port-offset","0");
+ int port = Integer.parseInt(portS);
+ String autostartS = parameters.getSimpleValue("auto-start","false");
+ boolean autoStart = Boolean.getBoolean(autostartS);
+
+ address.add(new PROPERTY_VALUE("host", chost));
+ address.add(new PROPERTY_VALUE("server-config",serverName));
+ Map<String,Object> props = new HashMap<String, Object>();
+ props.put("name",serverName);
+ props.put("group",serverGroup);
+ props.put("socket-binding-group",socketBindings);
+ props.put("socket-binding-port-offset",port);
+ props.put("auto-start",autoStart);
+
+ operation = new Operation(op,address,props);
+ } else if (what.equals("domain")) {
+ operation = new Operation(op,Collections.<PROPERTY_VALUE>emptyList());
+ }
+
+ OperationResult operationResult = new OperationResult();
+ if (operation!=null) {
+ JsonNode result = connection.executeRaw(operation);
+
+ if (ASConnection.isErrorReply(result)) {
+ operationResult.setErrorMessage(ASConnection.getFailureDescription(result));
+ }
+ else {
+ operationResult.setSimpleResult(ASConnection.getSuccessDescription(result));
+ }
+ }
+ else {
+ operationResult.setErrorMessage("No valid operation was given");
+ }
+ // TODO throw an exception if the operation failed?
+ return operationResult;
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 8d9ff0f..2f71edb 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -76,6 +76,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
String serverNameFull;
String serverName;
String psName = psr.getProcessScan().getName();
+ String description = discoveryContext.getResourceType().getDescription();
if (psName.equals("ProcessController")) {
serverNameFull = "ProcessController";
serverName = "ProcessController";
@@ -85,6 +86,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
if (hp.isLocal) {
serverName = "DomainController";
serverNameFull = "DomainController";
+ description = "Domain controller for an AS7 domain";
}
else {
serverName = "HostController";
@@ -138,7 +140,7 @@ public class BaseProcessDiscovery extends AbstractBaseDiscovery implements Resou
serverNameFull, // key TODO distinguish per domain?
serverName, // Name
null, // TODO real version ?
- discoveryContext.getResourceType().getDescription(), // Description
+ description, // Description
config,
psr.getProcessInfo()
);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index 1d73822..35425e3 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -68,100 +68,4 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
return super.getAvailability(); // TODO: Customise this generated block
}
- @Override
- public OperationResult invokeOperation(String name,
- Configuration parameters) throws InterruptedException, Exception {
-
- if (!name.contains(":")) {
- OperationResult badName = new OperationResult("Operation name did not contain a ':'");
- badName.setErrorMessage("Operation name did not contain a ':'");
- return badName;
- }
-
- int colonPos = name.indexOf(':');
- String what = name.substring(0, colonPos);
- String op = name.substring(colonPos+1);
- Operation operation=null;
-
- List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
-
- if (what.equals("server-group")) {
- String groupName = parameters.getSimpleValue("name",null);
- String profile = parameters.getSimpleValue("profile","default");
-
- address.add(new PROPERTY_VALUE("server-group",groupName));
-
- operation = new Operation(op,address,"profile",profile);
- } else if (what.equals("server")) {
-
- if (context.getResourceType().getName().equals("JBossAS-Managed")) {
- String host = conf.getSimpleValue("domainHost","local");
- address.add(new PROPERTY_VALUE("host",host));
- address.add(new PROPERTY_VALUE("server-config",myServerName));
- operation = new Operation(op,address);
- }
- else if (context.getResourceType().getName().equals("Host")) {
- address.addAll(pathToAddress(getPath()));
- String serverName = parameters.getSimpleValue("name",null);
- address.add(new PROPERTY_VALUE("server-config",serverName));
- Map<String,Object> props = new HashMap<String, Object>();
- String serverGroup = parameters.getSimpleValue("group",null);
- props.put("group",serverGroup);
- if (op.equals("add")) {
- props.put("name",serverName);
- boolean autoStart = parameters.getSimple("auto-start").getBooleanValue();
- props.put("auto-start",autoStart);
- // TODO put more properties in
- }
-
- operation = new Operation(op,address,props);
- }
- } else if (what.equals("destination")) {
- address.addAll(pathToAddress(getPath()));
- String newName = parameters.getSimpleValue("name","");
-// String type = parameters.getSimpleValue("type","Queue").toLowerCase();
-// address.add(new PROPERTY_VALUE(type,newName));
- String queueName = parameters.getSimpleValue("queue-address","");
- Map<String,Object> props = new HashMap<String, Object>();
- props.put("queue-address",queueName);
- operation = new Operation(op,address);
- } else if (what.equals("managed-server")) {
- String chost = parameters.getSimpleValue("hostname","");
- String serverName = parameters.getSimpleValue("servername","");
- String serverGroup = parameters.getSimpleValue("server-group","");
- String socketBindings = parameters.getSimpleValue("socket-bindings","");
- String portS = parameters.getSimpleValue("port-offset","0");
- int port = Integer.parseInt(portS);
- String autostartS = parameters.getSimpleValue("auto-start","false");
- boolean autoStart = Boolean.getBoolean(autostartS);
-
- address.add(new PROPERTY_VALUE("host", chost));
- address.add(new PROPERTY_VALUE("server-config",serverName));
- Map<String,Object> props = new HashMap<String, Object>();
- props.put("name",serverName);
- props.put("group",serverGroup);
- props.put("socket-binding-group",socketBindings);
- props.put("socket-binding-port-offset",port);
- props.put("auto-start",autoStart);
-
- operation = new Operation(op,address,props);
- }
-
- OperationResult operationResult = new OperationResult();
- if (operation!=null) {
- JsonNode result = connection.executeRaw(operation);
-
- if (ASConnection.isErrorReply(result)) {
- operationResult.setErrorMessage(ASConnection.getFailureDescription(result));
- }
- else {
- operationResult.setSimpleResult(ASConnection.getSuccessDescription(result));
- }
- }
- else {
- operationResult.setErrorMessage("No valid operation was given");
- }
- // TODO throw an exception if the operation failed?
- return operationResult;
- }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
deleted file mode 100644
index a8b1058..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ProcessScanResult;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.core.system.ProcessInfo;
-
-/**
- * Discover the domain. This is done by scanning for host controllers.
- * If they are also DC, the domain-controller element points to local.
- *
- * @author Heiko W. Rupp
- */
-@SuppressWarnings("unused")
-public class DomainDiscovery extends AbstractBaseDiscovery<BaseComponent> {
-
- private final Log log = LogFactory.getLog(this.getClass());
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
- throws Exception {
-
- Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
-
-
- List<ProcessScanResult> scans = context.getAutoDiscoveredProcesses();
-
- for (ProcessScanResult psr : scans) {
-
- // get the HostController, to find host.xml
- String psName = psr.getProcessScan().getName();
- if (!psName.equals("HostController"))
- continue;
-
- // Now we have the host controller, lets get the host.xml file
- // and obtain the domain controller info from there
- ProcessInfo processInfo = psr.getProcessInfo();
- readHostXml(processInfo,true);
- HostPort dcHp = getDomainControllerFromHostXml();
-
- if (!dcHp.isLocal) {
- log.info("Domain controller is not local, but at " + dcHp);
- continue;
- }
-
- // Ok, this is a domain controller, so we can return a Domain resource.
-
- // Get the management port and save for later use
- HostPort managementHostPort = getManagementPortFromHostXml();
- Configuration config = context.getDefaultPluginConfiguration();
- config.put(new PropertySimple("port",managementHostPort.port));
- config.put(new PropertySimple("hostname",managementHostPort.host));
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- "Domain", // Key
- "Domain", // Name
- null, // Version
- context.getResourceType().getDescription(), // Description
- config,
- null);
- details.add(detail);
- }
- return details;
- }
-}
\ No newline at end of file
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 80df496..04686c4 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
@@ -96,32 +96,9 @@
<process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
- <operation name="shutdown" description="Shut this Host-/Domaincontroller down with all managed servers.">
+ <operation name="domain:shutdown" displayName="Shutdown Domain" description="Shut this Host-/Domaincontroller down with all managed servers.">
</operation>
-
- </server>
-
- <server name="Domain"
- discovery="DomainDiscovery"
- class="DomainComponent"
- description="An AS7 management profile">
-
- <subcategories>
- <subcategory name="Integration" />
- <subcategory name="Core"/>
- <subcategory name="Web"/>
- </subcategories>
-
- <plugin-configuration>
- <c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/>
- <c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/>
- </plugin-configuration>
-
- <!-- Scan for host controller is intentional -->
- <process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
-
-
<operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
<parameters>
<c:simple-property name="name" description="Name of Group to add"/>
@@ -556,18 +533,75 @@
</plugin-configuration>
<resource-configuration>
- <c:map-property name="configuration">
- <c:simple-property name="connection-url"/>
- <c:simple-property name="driver-class"/>
- <c:simple-property name="jndi-name"/>
- <c:simple-property name="driver"/>
- <c:simple-property name="pool-name"/>
- <c:simple-property name="use-java-context" type="boolean"/>
- <c:simple-property name="enabled" type="boolean"/>
- <c:simple-property name="user-name"/>
- <c:simple-property name="password"/>
- <!-- TODO more when they become available in the AS -->
- </c:map-property>
+ <c:simple-property name="connection-url" required="true" type="string" readOnly="true" description="The JDBC driver connection URL"/>
+ <c:simple-property name="driver-class" required="true" type="string" readOnly="true"
+ description="The fully qualifed name of the JDBC driver class"/>
+ <c:simple-property name="jndi-name" required="true" type="string" readOnly="true"
+ description="Specifies the JNDI name for the datasource"/>
+ <c:simple-property name="driver" required="true" type="string" readOnly="true"
+ description="Defines the JDBC driver the datasource should use with this format: <driver-name>#<major-version>.<minor-version> where <driver-name> is the fully qualifed name of the JDBC driver class"/>
+ <c:simple-property name="new-connection-sql" type="string" readOnly="true"
+ description="Specifies an SQL statement to execute whenever a connection is added to the connection pool."/>
+ <c:simple-property name="pool-name" type="string" readOnly="true"
+ description="Specifies the pool name for the datasource used for management"/>
+ <c:simple-property name="url-delimiter" type="string" readOnly="true"
+ description="Specifies the delimeter for URLs in connection-url for HA datasources"/>
+ <c:simple-property name="url-selector-strategy-class-name" type="string" readOnly="true"
+ description="A class that implements org.jboss.jca.adapters.jdbc.URLSelectorStrategy"/>
+ <c:simple-property name="use-java-context" type="boolean" readOnly="true"
+ description="Setting this to false will bind the DataSource into global JNDI;"/>
+ <c:simple-property name="enabled" type="string" readOnly="true" description="Specifies if the datasource should be enabled"/>
+ <c:simple-property name="max-pool-size" type="integer" readOnly="false"
+ description="The max-pool-size element indicates the maximum number of connections for a pool. No more connections will be created in each sub-pool."/>
+ <c:simple-property name="min-pool-size" type="integer" readOnly="false"
+ description="The min-pool-size element indicates the minimum number of connections a pool should hold. These are not created until a Subject is known from a request for a connection."/>
+ <c:simple-property name="pool-prefill" type="boolean" readOnly="false"
+ description="Whether to attempt to prefill the connection pool. Changing this value require a server restart."/>
+ <c:simple-property name="pool-use-strict-min" type="boolean" readOnly="false"
+ description="Define if the min-pool-size should be considered a strictly."/>
+ <c:simple-property name="user-name" type="string" readOnly="true"
+ description="Specify the username used when creating a new connection."/>
+ <c:simple-property name="password" type="password" readOnly="true"
+ description="Specify the passwprd used when creating a new connection."/>
+ <c:simple-property name="prepared-statements-cacheSize" type="long" readOnly="true"
+ description="The number of prepared statements per connection in an LRU cache"/>
+ <c:simple-property name="share-prepared-statements" type="boolean" readOnly="true"
+ description="Whether to share prepare statements, i.e. whether asking for same statement twice without closing uses the same underlying prepared statement"/>
+ <c:simple-property name="track-statements" type="string" readOnly="true"
+ description="Whether to check for unclosed statements when a connection is returned to the pool and result sets are closed when a statement is closed/return to the prepared statement cache. valid values are: false - do not track statements and results true - track statements and result sets and warn when they are not closed nowarn - track statements but do no warn about them being unclosed"/>
+ <c:simple-property name="allocation-retry" type="integer" readOnly="true"
+ description="The allocation retry element indicates the number of times that allocating a connection should be tried before throwing an exception."/>
+ <c:simple-property name="allocation-retry-wait-millis" type="long" readOnly="true"
+ description="Indicates the time in milliseconds to wait between retrying to allocate a connection."/>
+ <c:simple-property name="blocking-timeout-wait-millis" type="long" readOnly="false"
+ description="The blocking-timeout-millis element indicates the maximum time in milliseconds to block while waiting for a connection before throwing an exception. Note that this blocks only while waiting for a permit for a connection, and will never throw an exception if creating a new connection takes an inordinately long time."/>
+ <c:simple-property name="idle-timeout-minutes" type="long" readOnly="false"
+ description="The idle-timeout-minutes elements indicates the maximum time in minutes a connection may be idle before being closed. The actual maximum time depends also on the IdleRemover scan time, which is 1/2 the smallest idle-timeout-minutes of any pool. Changing this value require a server restart."/>
+ <c:simple-property name="query-timeout" type="long" readOnly="true"
+ description="Any configured query timeout in seconds The default is no timeout"/>
+ <c:simple-property name="use-try-lock" type="long" readOnly="true"
+ description="Any configured timeout for internal locks on the resource adapter objects in seconds"/>
+ <c:simple-property name="set-tx-query-timeout" type="boolean" readOnly="true"
+ description="Whether to set the query timeout based on the time remaining until transaction timeout, any configured query timeout will be used if there is no transaction."/>
+ <c:simple-property name="transaction-isolation" type="string" readOnly="true"
+ description="Set java.sql.Connection transaction isolation level to use. The constants defined by transaction-isolation-values are the possible transaction isolation levels and include: TRANSACTION_READ_UNCOMMITTED TRANSACTION_READ_COMMITTED TRANSACTION_REPEATABLE_READ TRANSACTION_SERIALIZABLE TRANSACTION_NONE"/>
+ <c:simple-property name="check-valid-connection-sql" type="string" readOnly="true"
+ description="Specify an SQL statement to check validity of a pool connection. This may be called when managed connection is taken from pool for use."/>
+ <c:simple-property name="exception-sorter-class-name" type="string" readOnly="true"
+ description="An org.jboss.jca.adapters.jdbc.ExceptionSorter that provides a boolean isExceptionFatal(SQLException e) method to validate is an exception should be broadcast to all javax.resource.spi.ConnectionEventListener as a connectionErrorOccurred"/>
+ <c:simple-property name="stale-connection-checker-class-name" type="string" readOnly="true"
+ description="An org.jboss.jca.adapters.jdbc.StaleConnectionChecker that provides a boolean isStaleConnection(SQLException e) method which if it it returns true will wrap the exception in an org.jboss.jca.adapters.jdbc.StaleConnectionException"/>
+ <c:simple-property name="valid-connection-checker-class-name" type="string" readOnly="true"
+ description="An org.jboss.jca.adapters.jdbc.ValidConnectionChecker that provides a SQLException isValidConnection(Connection e) method to validate is a connection is valid. An exception means the connection is destroyed. This overrides the check-valid-connection-sql when present."/>
+ <c:simple-property name="background-validation-minutes" type="long" readOnly="false"
+ description="The background-validation-minutes element specifies the amount of time, in minutes, that background validation will run. Changing this value require a server restart."/>
+ <c:simple-property name="background-validation" type="boolean" readOnly="false"
+ description="An element to specify that connections should be validated on a background thread versus being validated prior to use. Changing this value require a server restart."/>
+ <c:simple-property name="use-fast-fail" type="boolean" readOnly="false"
+ description="Whether fail a connection allocation on the first connection if it is invalid (true) or keep trying until the pool is exhausted of all potential connections (false)"/>
+ <c:simple-property name="validate-on-match" type="boolean" readOnly="true"
+ description="The validate-on-match element indicates whether or not connection level validation should be done when a connection factory attempts to match a managed connection for a given set. This is typically exclusive to the use of background validation"/>
+ <c:simple-property name="spy" type="boolean" readOnly="true" description="whatever spy or not the jdbc connection"/>
</resource-configuration>
</service>
@@ -595,13 +629,73 @@
</server>
+ <server name="Threads"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="subsystem=threads"/>
+ </plugin-configuration>
+
+ <service name="ThreadFactory"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="thread-factory"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="name" required="true" type="string" readOnly="true" description="The bean name of the created thread factory."/>
+ <c:simple-property name="group-name" type="string" readOnly="false"
+ description="Specifies the name of a the thread group to create for this thread factory."/>
+ <c:simple-property name="thread-name-pattern" type="string" readOnly="false"
+ description="The template used to create names for threads. The following patterns may be used:
+ %% - emit a percent sign
+ %t - emit the per-factory thread sequence number
+ %g - emit the global thread sequence number
+ %f - emit the factory sequence number
+ %i - emit the thread ID."/>
+ <c:simple-property name="priority" type="integer" readOnly="false"
+ description="May be used to specify the thread priority of created threads."/>
+ <c:list-property name="properties" >
+ <c:simple-property name="properties" /> <!-- TODO list of maps ? -->
+ </c:list-property>
+ </resource-configuration>
+ </service>
+
+ <service name="ThreadPool"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="bounded-queue-thread-pool|queueless-thread-pool|scheduled-thread-pool|unbounded-queue-thread-pool"/>
+ </plugin-configuration>
+ </service>
+
+
+
+
+ </server>
+
<service name="NetworkInterface"
discovery="SubsystemDiscovery"
class="BaseComponent"
description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
<runs-inside>
- <parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="HostController" plugin="jboss-as-7"/>
<parent-resource-type name="Host" plugin="jboss-as-7"/>
<parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
</runs-inside>
@@ -616,7 +710,7 @@
class="BaseComponent"
>
<runs-inside>
- <parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="HostController" plugin="jboss-as-7"/>
<parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
</runs-inside>
commit 92e81c2b9607a0f58ca23d9695316cb6025b2a68
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 18 17:55:59 2011 +0200
Allow for multiple types to be separated by a bar ( | ).
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 18ba3ba..50dd55c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -26,6 +26,8 @@ import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@@ -62,119 +64,129 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
Configuration config = context.getDefaultPluginConfiguration();
- String cpath = config.getSimpleValue("path", null);
- if (cpath==null) {
+ String confPath = config.getSimpleValue("path", null);
+ if (confPath==null) {
log.error("Path plugin config is null for ResourceType [" + context.getResourceType().getName() +"].");
return details;
}
+ List<String> subTypes = new ArrayList<String>();
+ if (confPath.contains("|")) {
+ subTypes.addAll(Arrays.asList(confPath.split("\\|")));
+ }
+ else
+ subTypes.add(confPath);
- boolean recursive = false;
- String parentPath = parentComponent.getPath();
+ for (String cpath : subTypes) {
- String path;
- String childType = null;
- if (!cpath.contains("=")) { // NO = -> no sub path, but a type
- recursive = true;
- childType = cpath;
- }
+ boolean recursive = false;
- if (parentPath==null || parentPath.isEmpty())
- path = "";
- else
- path = parentPath;
+ String parentPath = parentComponent.getPath();
+
+ String path;
+ String childType = null;
+ if (!cpath.contains("=")) { // NO = -> no sub path, but a type
+ recursive = true;
+ childType = cpath;
- if (cpath.contains("="))
- path += "," + cpath;
+ }
- System.out.println("total path: [" + path + "]");
+ if (parentPath==null || parentPath.isEmpty())
+ path = "";
+ else
+ path = parentPath;
+ if (cpath.contains("="))
+ path += "," + cpath;
- JsonNode json ;
- if (!recursive)
- json = connection.getLevelData(path,recursive, false);
- else {
- List<PROPERTY_VALUE> addr ;
- addr = parentComponent.pathToAddress(parentPath);
- json = connection.executeRaw(new ReadChildrenNames(addr, childType));
- }
- if (!ASConnection.isErrorReply(json)) {
- if (recursive) {
+ System.out.println("total path: [" + path + "]");
+
+
+ JsonNode json ;
+ if (!recursive)
+ json = connection.getLevelData(path,recursive, false);
+ else {
+ List<PROPERTY_VALUE> addr ;
+ addr = parentComponent.pathToAddress(parentPath);
+ json = connection.executeRaw(new ReadChildrenNames(addr, childType));
+ }
+ if (!ASConnection.isErrorReply(json)) {
+ if (recursive) {
- JsonNode subNode = json.findPath("result");
+ JsonNode subNode = json.findPath("result");
- if (subNode!=null && subNode.isContainerNode()){
+ if (subNode!=null && subNode.isContainerNode()){
- Iterator<JsonNode> iter = subNode.getElements();
- while (iter.hasNext()) {
+ Iterator<JsonNode> iter = subNode.getElements();
+ while (iter.hasNext()) {
- JsonNode node = iter.next();
- String val = node.getTextValue();
+ JsonNode node = iter.next();
+ String val = node.getTextValue();
- String newPath = cpath + "=" + val;
- Configuration config2 = context.getDefaultPluginConfiguration();
+ String newPath = cpath + "=" + val;
+ Configuration config2 = context.getDefaultPluginConfiguration();
- String resKey;
+ String resKey;
- if (path==null||path.isEmpty())
- resKey = newPath;
- else
- resKey = path + "," +childType + "=" + val;
+ if (path==null||path.isEmpty())
+ resKey = newPath;
+ else
+ resKey = path + "," +childType + "=" + val;
- PropertySimple pathProp = new PropertySimple("path",resKey);
- config2.put(pathProp);
+ PropertySimple pathProp = new PropertySimple("path",resKey);
+ config2.put(pathProp);
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- resKey, // Key
- val, // Name
- null, // Version
- "TODO", // subsystem.description, // TODO Description
- config2,
- null);
- details.add(detail);
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ resKey, // Key
+ val, // Name
+ null, // Version
+ "TODO", // subsystem.description, // TODO Description
+ config2,
+ null);
+ details.add(detail);
+ }
}
- }
- else {
+ else {
- if (subNode==null) {
- log.error("subNode was null for " + path + " and type " + context.getResourceType().getName());
+ if (subNode==null) {
+ log.error("subNode was null for " + path + " and type " + context.getResourceType().getName());
+ }
+ else if (!subNode.isNull())
+ log.info("subnode was no container");
}
- else if (!subNode.isNull())
- log.info("subnode was no container");
+
}
+ else {
- }
- else {
+ String resKey = path;
+ String name = resKey.substring(resKey.lastIndexOf("=") + 1);
+ Configuration config2 = context.getDefaultPluginConfiguration();
+ PropertySimple pathProp = new PropertySimple("path",path);
+ config2.put(pathProp);
- String resKey = path;
- String name = resKey.substring(resKey.lastIndexOf("=") + 1);
- Configuration config2 = context.getDefaultPluginConfiguration();
- PropertySimple pathProp = new PropertySimple("path",path);
- config2.put(pathProp);
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ path, // Key
+ name, // Name
+ null, // Version
+ path, // Description
+ config2,
+ null);
+ details.add(detail);
+ }
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- path, // Key
- name, // Name
- null, // Version
- path, // Description
- config2,
- null);
- details.add(detail);
}
- return details;
}
-
- return Collections.emptySet();
+ return details;
}
}
commit 3496a92b6fc1765c530141c84062dc1e106f9b71
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 18 17:21:49 2011 +0200
(Yet) small helper to create the properties for resource configurations by reading the descriptions from the domain.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Properties.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Properties.java
new file mode 100644
index 0000000..0b8b38e
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/Domain2Properties.java
@@ -0,0 +1,200 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import com.apple.java.Usage;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Generate properties from a domain dump
+ * @author Heiko W. Rupp
+ */
+public class Domain2Properties {
+
+ public static void main(String[] args) throws Exception {
+
+ if (args.length<2) {
+ usage();
+ System.exit(1);
+ }
+
+ Domain2Properties dp = new Domain2Properties();
+ dp.run(args);
+
+
+ }
+
+ private void run(String[] args) {
+
+ String path = args[0];
+ String type = args[1];
+
+ ASConnection conn = new ASConnection("localhost",9990);
+
+ List<PROPERTY_VALUE> address = pathToAddress(path);
+ Operation op = new Operation("read-resource-description",address,"operations",true);
+ op.addAdditionalProperty("recursive","true");
+ ComplexResult res = (ComplexResult) conn.execute(op,true);
+ if (!res.isSuccess()) {
+ System.err.println("Failure: " + res.getFailureDescription());
+ return;
+ }
+
+
+ Map<String,Object> resMap = res.getResult();
+ Map childMap = (Map) resMap.get("children");
+ Map <String,Object> typeMap = (Map<String, Object>) childMap.get(type);
+ Map descriptionMap = (Map) typeMap.get("model-description");
+ Map starMap = (Map) descriptionMap.get("*");
+ Map<String,Object> attributesMap = (Map<String, Object>) starMap.get("attributes");
+
+
+
+ for (Map.Entry<String,Object> entry : attributesMap.entrySet()) {
+
+ Map<String,Object> props = (Map<String, Object>) entry.getValue();
+
+
+ Type ptype = getTypeFromProps(props);
+ String typeString;
+
+ switch (ptype) {
+ case INT:
+ typeString = "integer"; break;
+ case STRING:
+ typeString = "string"; break;
+ case BOOLEAN:
+ typeString = "boolean"; break;
+ case LONG:
+ typeString = "long"; break;
+ case BIG_DECIMAL:
+ typeString = "long"; break; // TODO bettter float or double?
+ case LIST:
+ typeString = "-list-";
+ break; // Handled below
+ default:
+ typeString = "- unknown -";
+ System.err.println("Unknown type " + ptype + " for " + entry.getKey());
+ }
+
+ if (ptype==Type.LIST) {
+
+ System.out.println("<c:list-property name=\"" + entry.getKey() +"\" >");
+ System.out.println(" <c:simple-property name=\"" + entry.getKey() + "\" />");
+ System.out.println("</c:list-property>");
+
+
+
+ continue;
+ }
+
+ StringBuilder sb = new StringBuilder("<c:simple-property name=\"");
+ sb.append(entry.getKey()).append('"');
+
+ if ((Boolean) props.get("required")) {
+ sb.append(" required=\"true\"");
+ }
+
+ sb.append(" type=\"").append(typeString).append("\"");
+ sb.append(" readOnly=\"");
+ if (props.get("access-type").equals("read-only"))
+ sb.append("true");
+ else
+ sb.append("false");
+ sb.append('"');
+
+ String description = (String) props.get("description");
+ if (sb.length()+description.length() > 120)
+ sb.append("\n ");
+ sb.append(" description=\"").append(description).append('"');
+ sb.append("/>");
+
+ System.out.println(sb.toString());
+ }
+
+
+ }
+
+ private Type getTypeFromProps(Map<String, Object> props) {
+ Map<String,String> tMap = (Map<String, String>) props.get("type");
+ String type = tMap.get("TYPE_MODEL_VALUE");
+ Type ret = Type.valueOf(type);
+
+ return ret;
+ }
+
+ /**
+ * Convert a path in the form key=value,key=value... to a List of properties.
+ * @param path Path to translate
+ * @return List of properties
+ */
+ public List<PROPERTY_VALUE> pathToAddress(String path) {
+ if (path==null || path.isEmpty())
+ return Collections.emptyList();
+
+ List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
+ String[] components = path.split(",");
+ for (String component : components) {
+ String tmp = component.trim();
+
+ if (tmp.contains("=")) {
+ // strip / from the start of the key if it happens to be there
+ if (tmp.startsWith("/"))
+ tmp = tmp.substring(1);
+
+ String[] pair = tmp.split("=");
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]);
+ result.add(valuePair);
+ }
+ }
+
+ return result;
+ }
+
+
+
+ private static void usage() {
+ System.out.println("Domain2Properties path type");
+ System.out.println(" path is of kind 'key=value[,key=value]+");
+ }
+
+ public enum Type {
+ STRING,
+ INT,
+ BOOLEAN,
+ LONG,
+ BIG_DECIMAL,
+ OBJECT,
+ LIST
+
+ ;
+ }
+
+}
commit e42f046825018fb8c74b6e33c3be401acf47acb4
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 18 12:54:56 2011 +0200
If we detect the DC, name it so.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 0de50b8..12d3ec6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -133,10 +133,6 @@ public class ASConnection {
outcome = outcomeNode.getTextValue();
if (outcome.equals("failed")) {
JsonNode reasonNode = in.findValue("failure-description");
- if (reasonNode==null)
- reasonNode = in.findValue("domain-failure-description");// TODO JBAS-9182
- if (reasonNode==null)
- reasonNode = in.findValue("host-failure-descriptions"); // TODO JBAS-9182
String reason = reasonNode.getTextValue();
// log.info(reason);
@@ -266,10 +262,6 @@ public class ASConnection {
if (jsonNode==null)
return "getFailureDescription: -input was null-";
JsonNode node = jsonNode.findValue("failure-description");
- if (node==null)
- node = jsonNode.findValue("domain-failure-description"); // TODO JBAS-9182
- if (node==null)
- node = jsonNode.findValue("host-failure-descriptions"); // TODO JBAS-9182
return node.getValueAsText();
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
index 7a648c9..63a4e45 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
@@ -48,8 +48,8 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
// private final Log log = LogFactory.getLog(AbstractBaseDiscovery.class);
- protected void readHostXml(ProcessInfo processInfo) {
- String hostXmlFile = getHostXmlFileLocation(processInfo);
+ protected void readHostXml(ProcessInfo processInfo,boolean isDomainMode) {
+ String hostXmlFile = getHostXmlFileLocation(processInfo,isDomainMode);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
@@ -61,23 +61,6 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
}
}
- /**
- * Get the location of the host definition file (host.xml in domain mode, standalone.xml
- * in standalone mode.
- *
- * @param processInfo ProcessInfo structure containing the ENV variables
- * @return The path to the definition file.
- */
- private String getHostXmlFileLocation(ProcessInfo processInfo) {
-
- String home = getHomeDirFromCommandLine(processInfo.getCommandLine());
- StringBuilder builder = new StringBuilder(home);
- builder.append("/domain");
- builder.append("/configuration");
- builder.append("/host.xml");
- return builder.toString();
-
- }
String getHomeDirFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
@@ -202,6 +185,32 @@ public abstract class AbstractBaseDiscovery<T extends ResourceComponent> impleme
return new HostPort(false);
}
+ /**
+ * Get the location of the host definition file (host.xml in domain mode, standalone.xml
+ * in standalone mode.
+ * @param processInfo ProcessInfo structure containing the ENV variables
+ * @param isDomain Are we looking for host.xml (=isDomain) or not
+ * @return The path to the definition file.
+ */
+ protected String getHostXmlFileLocation(ProcessInfo processInfo, boolean isDomain) {
+
+ String home = processInfo.getEnvironmentVariable("jboss.home.dir");
+ if (home==null)
+ home = getHomeDirFromCommandLine(processInfo.getCommandLine());
+ StringBuilder builder = new StringBuilder(home);
+ if (isDomain)
+ builder.append("/domain");
+ else
+ builder.append("/standalone");
+ builder.append("/configuration");
+ if (isDomain)
+ builder.append("/host.xml");
+ else
+ builder.append("/standalone.xml");
+ return builder.toString();
+
+ }
+
protected static class HostPort {
String host;
int port;
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 3b77360..f03f62c 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
@@ -53,6 +53,8 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
@@ -71,7 +73,7 @@ import java.util.Map;
import java.util.Set;
public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet,
- CreateChildResourceFacet
+ CreateChildResourceFacet, OperationFacet
{
final Log log = LogFactory.getLog(this.getClass());
@@ -490,4 +492,10 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
return report;
}
+
+ @Override
+ public OperationResult invokeOperation(String name,
+ Configuration parameters) throws InterruptedException, Exception {
+ return null; // TODO: Customise this generated block
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 9fa8396..8d9ff0f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -49,7 +49,7 @@ import org.rhq.plugins.jmx.JMXDiscoveryComponent;
/**
* Discovery class
*/
-public class BaseProcessDiscovery implements ResourceDiscoveryComponent
+public class BaseProcessDiscovery extends AbstractBaseDiscovery implements ResourceDiscoveryComponent
{
@@ -80,8 +80,19 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
serverNameFull = "ProcessController";
serverName = "ProcessController";
} else if (psName.equals("HostController")) {
- serverName = "HostController";
- serverNameFull = "HostController";
+ readHostXml(psr.getProcessInfo(),true);
+ HostPort hp = getDomainControllerFromHostXml();
+ if (hp.isLocal) {
+ serverName = "DomainController";
+ serverNameFull = "DomainController";
+ }
+ else {
+ serverName = "HostController";
+ serverNameFull = "HostController";
+ }
+ config.put(new PropertySimple("homedir",getHomeDirFromCommandLine(psr.getProcessInfo().getCommandLine())));
+ // TODO add the start script
+
} else {
serverNameFull = getBaseDirFromCommandLine(commandLine);
if (serverNameFull==null || serverNameFull.isEmpty()) {
@@ -127,7 +138,7 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
serverNameFull, // key TODO distinguish per domain?
serverName, // Name
null, // TODO real version ?
- "TODO", // Description
+ discoveryContext.getResourceType().getDescription(), // Description
config,
psr.getProcessInfo()
);
@@ -160,30 +171,6 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
return hostName;
}
- /**
- * Get the location of the host definition file (host.xml in domain mode, standalone.xml
- * in standalone mode.
- * @param processInfo ProcessInfo structure containing the ENV variables
- * @param isDomain Are we looking for host.xml (=isDomain) or not
- * @return The path to the definition file.
- */
- private String getHostXmlFileLocation(ProcessInfo processInfo, boolean isDomain) {
-
- String home = processInfo.getEnvironmentVariable("jboss.home.dir");
- StringBuilder builder = new StringBuilder(home);
- if (isDomain)
- builder.append("/domain");
- else
- builder.append("/standalone");
- builder.append("/configuration");
- if (isDomain)
- builder.append("/host.xml");
- else
- builder.append("/standalone.xml");
- return builder.toString();
-
- }
-
String getBaseDirFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
if (line.startsWith(DJBOSS_SERVER_BASE_DIR))
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
index 667b3ee..a8b1058 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
@@ -61,7 +61,7 @@ public class DomainDiscovery extends AbstractBaseDiscovery<BaseComponent> {
// Now we have the host controller, lets get the host.xml file
// and obtain the domain controller info from there
ProcessInfo processInfo = psr.getProcessInfo();
- readHostXml(processInfo);
+ readHostXml(processInfo,true);
HostPort dcHp = getDomainControllerFromHostXml();
if (!dcHp.isLocal) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 7f39a9f..3f57a06 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -70,7 +70,7 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
// Now we have the host controller, lets get the host.xml file
// and obtain the servers from there.
ProcessInfo processInfo = psr.getProcessInfo();
- readHostXml(processInfo);
+ readHostXml(processInfo,true);
String hostName = findHostName();
HostPort managementHostPort = getManagementPortFromHostXml();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index a87a6f8..ccc967b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -37,10 +37,6 @@ public class Result {
private Operation compensatingOperation;
@JsonProperty("failure-description")
private List<Map<String, String>> failureDescription;
- @JsonProperty("host-failure-description") // TODO JBAS-9182
- private List<Map<String, String>> hostFailureDescription;
- @JsonProperty("domain-failure-description") // TODO JBAS-9182
- private List<Map<String, String>> domainFailureDescription;
@JsonIgnore
private boolean success = false;
@@ -86,19 +82,4 @@ public class Result {
this.failureDescription = failureDescription;
}
- public List<Map<String, String>> getHostFailureDescription() {
- return hostFailureDescription;
- }
-
- public void setHostFailureDescription(List<Map<String, String>> hostFailureDescription) {
- this.hostFailureDescription = hostFailureDescription;
- }
-
- public List<Map<String, String>> getDomainFailureDescription() {
- return domainFailureDescription;
- }
-
- public void setDomainFailureDescription(List<Map<String, String>> domainFailureDescription) {
- this.domainFailureDescription = domainFailureDescription;
- }
}
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 b6600ab..80df496 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
@@ -83,7 +83,7 @@
<server name="HostController"
discovery="BaseProcessDiscovery"
class="BaseComponent"
- description="Domain controller delegate for this host"
+ description="Domain controller (delegate) for this host"
>
<plugin-configuration>
@@ -96,8 +96,7 @@
<process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
- <operation name="dummyOperation">
- <!-- TODO supply parameters and return values -->
+ <operation name="shutdown" description="Shut this Host-/Domaincontroller down with all managed servers.">
</operation>
commit d59ccb6efc2e5edc240ae388c036a0087b4a5e9c
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Apr 15 15:16:37 2011 +0200
Add domain level deployments
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 8d47d9d..3b77360 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
@@ -34,20 +34,27 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.configuration.definition.PropertySimpleType;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
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.core.domain.resource.CreateResourceStatus;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.content.ContentContext;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
+import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -55,6 +62,7 @@ import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
import org.rhq.modules.plugins.jbossas7.json.ReadResource;
import org.rhq.modules.plugins.jbossas7.json.Result;
+import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -62,7 +70,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet
+public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet,
+ CreateChildResourceFacet
{
final Log log = LogFactory.getLog(this.getClass());
@@ -178,7 +187,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
ObjectMapper mapper = new ObjectMapper();
Set<Map.Entry<String, PropertyDefinition>> entrySet = configDef.getPropertyDefinitions().entrySet();
- for (Map.Entry<String,PropertyDefinition> propDefEntry: entrySet) { // TODO all properties
+ for (Map.Entry<String,PropertyDefinition> propDefEntry: entrySet) {
PropertyDefinition propDef = propDefEntry.getValue();
JsonNode sub = json.findValue(propDef.getName());
if (propDef instanceof PropertyDefinitionSimple) {
@@ -187,7 +196,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
if (sub!=null)
propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
else {
- propertySimple = new PropertySimple(propDef.getName(),null); // TODO store it at all when it is null?
+ propertySimple = new PropertySimple(propDef.getName(),"- null -"); // TODO store it at all when it is null?
}
ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
@@ -415,4 +424,70 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
if (!res.isSuccess())
throw new IllegalArgumentException("Delete for [" + path + "] failed: " + res.getFailureDescription());
}
+
+
+ @Override
+ public CreateResourceReport createResource(CreateResourceReport report) {
+
+
+ ResourcePackageDetails details = report.getPackageDetails();
+
+ ContentContext cctx = context.getContentContext();
+ ContentServices contentServices = cctx.getContentServices();
+ String resourceTypeName = report.getResourceType().getName();
+
+ ASUploadConnection uploadConnection = new ASUploadConnection(host,port);
+ OutputStream out = uploadConnection.getOutputStream(details.getFileName());
+ contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
+
+ JsonNode uploadResult = uploadConnection.finishUpload();
+ System.out.println(uploadResult);
+ if (ASConnection.isErrorReply(uploadResult)) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage(ASConnection.getFailureDescription(uploadResult));
+
+ return report;
+ }
+
+ String fileName = details.getFileName();
+ String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
+
+ JsonNode resultNode = uploadResult.get("result");
+ String hash = resultNode.get("BYTES_VALUE").getTextValue();
+ ASConnection connection = getASConnection();
+
+ Operation step1 = new Operation("add","deployment",tmpName);
+ step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
+ step1.addAdditionalProperty("name", tmpName);
+ step1.addAdditionalProperty("runtime-name", fileName);
+
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
+
+ /*
+ * We need to check here if this is an upload to /deployment only
+ * or if this should be deployed to a server group too
+ */
+ if (context.getResourceKey().contains("server-group=")) {
+
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", tmpName));
+ Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
+
+ cop.addStep(step2);
+ }
+
+ JsonNode result = connection.executeRaw(cop);
+ if (ASConnection.isErrorReply(result)) {
+ report.setErrorMessage(ASConnection.getFailureDescription(resultNode));
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ else {
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ }
+
+ return report;
+
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index c2d1994..8c46247 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -157,64 +157,6 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
return null; // TODO: Customise this generated block
}
- @Override
- public CreateResourceReport createResource(CreateResourceReport report) {
-
-
- ResourcePackageDetails details = report.getPackageDetails();
-
- ContentContext cctx = context.getContentContext();
- ContentServices contentServices = cctx.getContentServices();
- String resourceTypeName = report.getResourceType().getName();
-
- ASUploadConnection uploadConnection = new ASUploadConnection(host,port);
- OutputStream out = uploadConnection.getOutputStream(details.getFileName());
- contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
-
- JsonNode uploadResult = uploadConnection.finishUpload();
- System.out.println(uploadResult);
- if (ASConnection.isErrorReply(uploadResult)) {
- report.setStatus(CreateResourceStatus.FAILURE);
- report.setErrorMessage(ASConnection.getFailureDescription(uploadResult));
-
- return report;
- }
-
- String fileName = details.getFileName();
- String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
-
- JsonNode resultNode = uploadResult.get("result");
- String hash = resultNode.get("BYTES_VALUE").getTextValue();
- ASConnection connection = getASConnection();
-
- Operation step1 = new Operation("add","deployment",tmpName);
- step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
- step1.addAdditionalProperty("name", tmpName);
- step1.addAdditionalProperty("runtime-name", fileName);
-
- List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
- serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
- serverGroupAddress.add(new PROPERTY_VALUE("deployment", tmpName));
- Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
-
- CompositeOperation cop = new CompositeOperation();
- cop.addStep(step1);
- cop.addStep(step2);
-
- JsonNode result = connection.executeRaw(cop);
- if (ASConnection.isErrorReply(result)) {
- report.setErrorMessage(ASConnection.getFailureDescription(resultNode));
- report.setStatus(CreateResourceStatus.FAILURE);
- }
- else {
- report.setStatus(CreateResourceStatus.SUCCESS);
- }
-
- return report;
-
- }
-
-
private String serverGroupFromKey() {
String key1 = context.getResourceKey();
return key1.substring(key1.lastIndexOf("/")+1);
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 a699550..b6600ab 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
@@ -202,6 +202,7 @@
<configuration>
<c:group name="deployment" displayName="Deployment Options">
<c:simple-property name="runtimeName" required="true"/>
+ <c:simple-property name="alreadyUploaded" type="boolean" description="Was this already uploaded to the Domain? TODO"/>
</c:group>
</configuration>
</content>
@@ -237,6 +238,24 @@
</operation>
</server>
+ <service name="DomainDeployment"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ createDeletePolicy="both"
+ creationDataType="content">
+ <plugin-configuration>
+ <c:simple-property name="path" default="deployment" readOnly="true"/>
+ </plugin-configuration>
+
+ <content name="file" category="deployable" isCreationType="true" description="Deployments on this domain">
+ </content>
+
+ <resource-configuration>
+ <c:simple-property name="name" readOnly="true"/>
+ <c:simple-property name="runtime-name" readOnly="true"/>
+ <c:simple-property name="hash" readOnly="true"/>
+ </resource-configuration>
+ </service>
</server>
<server name="JBossAS7-Standalone"
commit 187e9130ad1521cd4d20cb93d08d171024733da2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Apr 15 12:11:24 2011 +0200
Support removing deployments from server groups.
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 3403b29..8d47d9d 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
@@ -47,6 +47,7 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
@@ -407,8 +408,11 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
@Override
public void deleteResource() throws Exception {
- // TODO: Customise this generated block
System.out.println("delete resource: " + path);
+ Operation op = new Operation("remove",pathToAddress(path));
+ ComplexResult res = (ComplexResult) connection.execute(op, true);
+ if (!res.isSuccess())
+ throw new IllegalArgumentException("Delete for [" + path + "] failed: " + res.getFailureDescription());
}
}
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 13560e7..a699550 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
@@ -186,14 +186,13 @@
<resource-configuration>
<c:simple-property name="profile" />
<c:simple-property name="socket-binding-group"/>
- <c:simple-property name="jvm"/>
- <c:simple-property name="deployment" required="false"/> <!-- TODO change structure. Or put below as resource? -->
+ <c:simple-property name="jvm" required="false"/>
</resource-configuration>
<service name="Deployment"
class="BaseComponent"
discovery="SubsystemDiscovery"
- createDeletePolicy="create-only"
+ createDeletePolicy="both"
creationDataType="content">
<plugin-configuration>
<c:simple-property name="path" default="deployment" readOnly="true"/>
commit c3eed4cad8cf3401ef726fc73a75d51acf51d6c3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Apr 15 10:57:23 2011 +0200
Creation of deployments, managed servers (2nd way)
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 3a978b4..0de50b8 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -174,12 +174,14 @@ public class ASConnection {
out.flush();
out.close();
- if (conn.getResponseCode()==HttpURLConnection.HTTP_OK) {
+ int responseCode = conn.getResponseCode();
+ if (responseCode ==HttpURLConnection.HTTP_OK) {
inputStream = conn.getInputStream();
} else {
inputStream = conn.getErrorStream();
}
+ if (inputStream!=null) {
br = new BufferedReader(new InputStreamReader(
inputStream));
@@ -200,6 +202,10 @@ public class ASConnection {
}
System.out.println("==> " + outcome);
return operationResult;
+ }
+ else {
+ System.err.println("IS was null and code was " + responseCode);
+ }
} catch (IOException e) {
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 6109c9f..3403b29 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
@@ -42,6 +42,7 @@ import org.rhq.core.domain.measurement.MeasurementReport;
import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.pluginapi.configuration.ConfigurationFacet;
import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
@@ -60,7 +61,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet
+public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet, DeleteResourceFacet
{
final Log log = LogFactory.getLog(this.getClass());
@@ -404,4 +405,10 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
return result;
}
+ @Override
+ public void deleteResource() throws Exception {
+ // TODO: Customise this generated block
+
+ System.out.println("delete resource: " + path);
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 8597d8f..9fa8396 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -105,7 +105,7 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
}
String logFile = getLogFileFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
- String javaClazz = psr.getProcessInfo().getName();
+// String javaClazz = psr.getProcessInfo().getName();
/*
@@ -115,11 +115,11 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
*/
// config.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
// javaClazz));
- config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
- LocalVMTypeDescriptor.class.getName()));
-
- // TODO vmid will change when the detected server is bounced - how do we follow this?
- config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid()));
+// config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
+// LocalVMTypeDescriptor.class.getName()));
+//
+// // TODO vmid will change when the detected server is bounced - how do we follow this?
+// config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid()));
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index 05f79d8..1d73822 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -125,6 +125,26 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
Map<String,Object> props = new HashMap<String, Object>();
props.put("queue-address",queueName);
operation = new Operation(op,address);
+ } else if (what.equals("managed-server")) {
+ String chost = parameters.getSimpleValue("hostname","");
+ String serverName = parameters.getSimpleValue("servername","");
+ String serverGroup = parameters.getSimpleValue("server-group","");
+ String socketBindings = parameters.getSimpleValue("socket-bindings","");
+ String portS = parameters.getSimpleValue("port-offset","0");
+ int port = Integer.parseInt(portS);
+ String autostartS = parameters.getSimpleValue("auto-start","false");
+ boolean autoStart = Boolean.getBoolean(autostartS);
+
+ address.add(new PROPERTY_VALUE("host", chost));
+ address.add(new PROPERTY_VALUE("server-config",serverName));
+ Map<String,Object> props = new HashMap<String, Object>();
+ props.put("name",serverName);
+ props.put("group",serverGroup);
+ props.put("socket-binding-group",socketBindings);
+ props.put("socket-binding-port-offset",port);
+ props.put("auto-start",autoStart);
+
+ operation = new Operation(op,address,props);
}
OperationResult operationResult = new OperationResult();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index 8bafbb4..c2d1994 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -91,7 +91,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
step1.addAdditionalProperty("name", fileName);
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
- serverGroupAddress.add(new PROPERTY_VALUE("server-group",serverGroupFromKey()));
+ serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
serverGroupAddress.add(new PROPERTY_VALUE("deployment", fileName));
Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
@@ -180,22 +180,21 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
return report;
}
- String fileName = report.getUserSpecifiedResourceName();
+ String fileName = details.getFileName();
+ String tmpName = fileName; // TODO figure out the tmp-name biz with the AS guys
JsonNode resultNode = uploadResult.get("result");
String hash = resultNode.get("BYTES_VALUE").getTextValue();
ASConnection connection = getASConnection();
- List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
- deploymentsAddress.add(new PROPERTY_VALUE("deployment", fileName));
- Operation step1 = new Operation("add",deploymentsAddress);
+ Operation step1 = new Operation("add","deployment",tmpName);
step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
- step1.addAdditionalProperty("name", fileName); // TODO set a random name here - or wait on AS to "fix" this
+ step1.addAdditionalProperty("name", tmpName);
step1.addAdditionalProperty("runtime-name", fileName);
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
- serverGroupAddress.add(new PROPERTY_VALUE("server-group",serverGroupFromKey()));
- serverGroupAddress.add(new PROPERTY_VALUE("deployment", fileName));
+ serverGroupAddress.addAll(pathToAddress(context.getResourceKey()));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", tmpName));
Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
CompositeOperation cop = new CompositeOperation();
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 f2c9a5e..13560e7 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
@@ -134,6 +134,30 @@
<c:simple-property name="name" description="Name of Group to add"/>
</parameters>
</operation>
+ <operation name="managed-server:add" displayName="Add managed server" description="Add a new managed server">
+ <parameters>
+ <c:simple-property name="servername" displayName="Name of the new server" required="true"/>
+ <c:simple-property name="hostname" displayName="Name of the host to put the server on" required="true"/>
+ <c:simple-property name="server-group" displayName="Server group to add to" required="true"/>
+ <c:simple-property name="socket-bindings" displayName="Socket bindings to base upon" default="standard-sockets" description="Socket bindings to base upon"/>
+ <c:simple-property name="port-offset" displayName="Port offset" default="0" type="integer" />
+ <c:simple-property name="auto-start" displayName="Autostart" default="false" type="boolean" />
+ </parameters>
+ <results>
+ <c:simple-property name="result" description="Outcome of the create server operation"/>
+ </results>
+ </operation>
+ <operation name="managed-server:remove" displayName="Remove managed server" description="Remove a managed server">
+ <parameters>
+ <c:simple-property name="servername" displayName="Name of the server to remove" required="true"/>
+ <c:simple-property name="hostname" displayName="Name of the host where the server is on" required="true"/>
+ </parameters>
+ <results>
+ <c:simple-property name="result" description="Outcome of the remove server operation"/>
+ </results>
+
+ </operation>
+
<server name="Profile"
description="One profile in a domain"
@@ -166,12 +190,16 @@
<c:simple-property name="deployment" required="false"/> <!-- TODO change structure. Or put below as resource? -->
</resource-configuration>
- <service name="Deployment" class="BaseComponent" discovery="SubsystemDiscovery" createDeletePolicy="create-only" creationDataType="content">
+ <service name="Deployment"
+ class="BaseComponent"
+ discovery="SubsystemDiscovery"
+ createDeletePolicy="create-only"
+ creationDataType="content">
<plugin-configuration>
<c:simple-property name="path" default="deployment" readOnly="true"/>
</plugin-configuration>
- <content name="deployment" category="deployable" isCreationType="true" description="Deployments on this domain">
+ <content name="file" category="deployable" isCreationType="true" description="Deployments on this domain">
<configuration>
<c:group name="deployment" displayName="Deployment Options">
<c:simple-property name="runtimeName" required="true"/>
@@ -208,13 +236,6 @@
<c:simple-property name="result" description="Outcome of the delete server operation"/>
</results>
</operation>
-
-<!--
- <resource-configuration>
- <c:list-property name="server-config" />
- </resource-configuration>
--->
-
</server>
</server>
commit bdf889e91b51f59f5f17346bb6e78e86f4aebbaf
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Apr 14 16:38:34 2011 +0200
SocketBindingGroups and NetworkInterfaces are now detected via SubsystemDiscovery. Deprecate getLevelData()
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 54c734d..3a978b4 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -63,6 +63,7 @@ public class ASConnection {
}
+ @Deprecated
JsonNode getLevelData(@Nullable String base, boolean recursive, boolean includeMetrics) throws Exception{
String ops = null;
if (recursive)
@@ -72,24 +73,16 @@ public class ASConnection {
return getLevelData(base,ops);
}
- /**
- * Return the default data for base
- * @param base
- * @return
- * @throws Exception
- */
- JsonNode getLevelData(@Nullable String base) throws Exception {
- return getLevelData(base,"operation=resource-description&recursive&include-runtime=true");
- }
/**
- * Return the JSON-Ojbect for a certain path.
+ * Return the JSON-Object for a certain path.
*
* @param base Path to the object/subsystem. Can be null/"" for the base objects
* @param ops OperationDescription to run on the api can be null
* @return A JSONObject encoding the level plus sub levels provided
* @throws Exception If anything goes wrong
*/
+ @Deprecated
JsonNode getLevelData(@Nullable String base, @Nullable String ops) throws Exception {
URL url2;
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 8ed6c96..6109c9f 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
@@ -169,6 +169,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
List<PROPERTY_VALUE> address = pathToAddress(path);
Operation op = new ReadResource(address); // TOTO set recursive flag?
+ op.addAdditionalProperty("recursive","true");
JsonNode json = connection.executeRaw(op);
Configuration ret = new Configuration();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
deleted file mode 100644
index 1fc1e9b..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.modules.plugins.jbossas7.json.Attribute;
-import org.rhq.modules.plugins.jbossas7.json.Domain;
-import org.rhq.modules.plugins.jbossas7.json.NetworkInterface;
-
-/**
- * Discover subsystems
- *
- * @author Heiko W. Rupp
- */
-@SuppressWarnings("unused")
-public class InterfaceDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
-
- private final Log log = LogFactory.getLog(this.getClass());
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
- throws Exception {
-
- Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
- mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
-
- BaseComponent parentComponent = context.getParentResourceComponent();
- ASConnection connection = parentComponent.getASConnection();
-
-
-
- JsonNode json = connection.getLevelData(null, null);
- if (!ASConnection.isErrorReply(json)) {
- Domain domain = mapper.readValue(json, new TypeReference<Domain>() {});
-
- for (Map.Entry<String,String> entry: domain.interfaces.entrySet()) {
-
- String key = entry.getKey();
- String path = "/interface/" + key;
- JsonNode subJson = connection.getLevelData(path);
-
- NetworkInterface networkInterface = mapper.readValue(subJson, new TypeReference<NetworkInterface>() {});
- networkInterface.name= key;
- for (Map.Entry<String,Attribute> nentry : networkInterface.attributes.entrySet()) {
- nentry.getValue().name = nentry.getKey();
-
- String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
- String name = resKey.substring(resKey.lastIndexOf("/") + 1);
-
- Configuration config = context.getDefaultPluginConfiguration();
-
- PropertySimple propertySimple = new PropertySimple("path",path);
- config.put(propertySimple);
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- path, // Key
- name, // Name
- null, // Version
- networkInterface.description, // Description
- config,
- null);
- details.add(detail);
- }
- }
-
- return details;
- }
-
- return Collections.emptySet();
- }
-
-}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
deleted file mode 100644
index 89472b8..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.modules.plugins.jbossas7.json.Attribute;
-import org.rhq.modules.plugins.jbossas7.json.Domain;
-import org.rhq.modules.plugins.jbossas7.json.SocketBindingGroup;
-
-/**
- * Discover subsystems
- *
- * @author Heiko W. Rupp
- */
-@SuppressWarnings("unused")
-public class SocketBindingGroupDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
-
- private final Log log = LogFactory.getLog(this.getClass());
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
- throws Exception {
-
- Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
- mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
-
- BaseComponent parentComponent = context.getParentResourceComponent();
- ASConnection connection = parentComponent.getASConnection();
-
-
-
- JsonNode json = connection.getLevelData(null, null);
- if (!ASConnection.isErrorReply(json)) {
- Domain domain = mapper.readValue(json, new TypeReference<Domain>() {});
-
- for (Map.Entry<String,String> entry: domain.socketBindingGroup.entrySet()) {
-
- String key = entry.getKey();
- String path = "/socket-binding-group/" + key;
- JsonNode subJson = connection.getLevelData(path);
-
- SocketBindingGroup bindingGroup = mapper.readValue(subJson, new TypeReference<SocketBindingGroup>() {});
- bindingGroup.name= key;
-
- String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
- String name = resKey.substring(resKey.lastIndexOf("/") + 1);
-
- Configuration config = context.getDefaultPluginConfiguration();
-
- PropertySimple propertySimple = new PropertySimple("path",path);
- config.put(propertySimple);
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- path, // Key
- name, // Name
- null, // Version
- "SocketBinding Group", // Description
- config,
- null);
- details.add(detail);
- }
-
- return details;
- }
-
- return Collections.emptySet();
- }
-
-}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index a7abfe6..d5802a3 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -70,6 +70,13 @@ public class Operation {
}
+ public Operation(String operation, String addressKey, String addressValue) {
+ this.operation = operation;
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(1);
+ address.add(new PROPERTY_VALUE(addressKey, addressValue));
+ this.address = address;
+ }
+
public Operation() {
// needed for Jackson
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java
index c2eab45..bf1072c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java
@@ -26,7 +26,13 @@ import java.util.List;
*/
public class ReadResource extends Operation {
+ private static final String READ_RESOURCE = "read-resource";
+
public ReadResource(List<PROPERTY_VALUE> address) {
- super("read-resource", address);
+ super(READ_RESOURCE, address);
+ }
+
+ public ReadResource(String resourceType,String typeValue) {
+ super(READ_RESOURCE,resourceType,typeValue);
}
}
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 e75507a..f2c9a5e 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
@@ -558,7 +558,7 @@
</server>
<service name="NetworkInterface"
- discovery="InterfaceDiscovery"
+ discovery="SubsystemDiscovery"
class="BaseComponent"
description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
@@ -574,7 +574,7 @@
</service>
<service name="SocketBindingGroup"
- discovery="SocketBindingGroupDiscovery"
+ discovery="SubsystemDiscovery"
class="BaseComponent"
>
<runs-inside>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 34d722c..2ca9f91 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -180,6 +180,23 @@ public class OperationJsonTest {
assert aliases.get(0).equals("example.com");
}
+ public void arrayResult1() throws Exception {
+
+ String resultString = "{\"outcome\":\"success\",\"result\":[\"standard-sockets\",\"messaging-sockets\"],\"compensating-operation\":null}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("success");
+ assert result.isSuccess();
+ List<String> stringList = (List<String>) result.getResult();
+ assert stringList.size()==2;
+ assert stringList.get(0).equals("standard-sockets");
+ assert stringList.get(1).equals("messaging-sockets");
+
+ }
+
public void compensatingOp() throws Exception {
String resultString = "{\"outcome\" : \"success\", \"result\" : null, \"compensating-operation\" : {\"operation\" : \"remove\", \"address\" : [{\"deployment\" : \"test.war\"}]}}";
commit adcd6872d41e2c96a307afbc53590c8165b8474a
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Apr 14 11:36:34 2011 +0200
Some cleanup and changes in ASConnection
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index d58f0c9..54c734d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -45,16 +45,12 @@ import org.rhq.modules.plugins.jbossas7.json.Result;
public class ASConnection {
private final Log log = LogFactory.getLog(ASConnection.class);
- private int port;
- private String host;
URL url;
String urlString;
private StringBuilder builder;
private ObjectMapper mapper;
public ASConnection(String host, int port) {
- this.host = host;
- this.port = port;
try {
url = new URL("http",host,port,"/domain-api");
@@ -167,7 +163,7 @@ public class ASConnection {
* @return JsonNode that describes the result
* @param operation an Operation that should be run on the domain controller
*/
- public JsonNode execute(Operation operation) {
+ public JsonNode executeRaw(Operation operation) {
InputStream inputStream = null;
BufferedReader br=null;
@@ -187,30 +183,18 @@ public class ASConnection {
if (conn.getResponseCode()==HttpURLConnection.HTTP_OK) {
inputStream = conn.getInputStream();
-
- br = new BufferedReader(new InputStreamReader(
- inputStream));
- String line;
- builder = new StringBuilder();
- while ((line = br.readLine()) != null) {
- builder.append(line);
- }
- br.close();
+ } else {
+ inputStream = conn.getErrorStream();
}
- else {
- InputStream errorStream = conn.getErrorStream();
- if (errorStream!=null) {
- br = new BufferedReader(new InputStreamReader(errorStream));
- String line;
- builder = new StringBuilder();
- while ((line = br.readLine()) != null) {
- builder.append(line);
- }
- br.close();
- }
+
+
+ br = new BufferedReader(new InputStreamReader(
+ inputStream));
+ String line;
+ builder = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ builder.append(line);
}
- if (br!=null)
- br.close();
String outcome;
JsonNode operationResult=null;
@@ -227,13 +211,20 @@ public class ASConnection {
} catch (IOException e) {
log.error("Failed to get data: " + e.getMessage() );
+ } finally {
+ if (br!=null)
+ try {
+ br.close();
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
}
return null;
}
- public Result execute2(Operation op, boolean isComplex){
- JsonNode node = execute(op);
+ public Result execute(Operation op, boolean isComplex){
+ JsonNode node = executeRaw(op);
try {
Result res;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index 63b7881..b369a95 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -18,7 +18,6 @@
*/
package org.rhq.modules.plugins.jbossas7;
-import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.Closeable;
@@ -29,8 +28,6 @@ import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
-import com.sun.org.apache.xerces.internal.impl.xpath.regex.REUtil;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
@@ -51,18 +48,26 @@ public class ASUploadConnection {
private static final String POST_REQUEST_METHOD = "POST";
- private static final String UPLOAD_URL = "http://localhost:9990/domain-api/add-content";
+ private static final String UPLOAD_URL_PATH = "/domain-api/add-content";
private final Log log = LogFactory.getLog(ASUploadConnection.class);
BufferedOutputStream os = null;
InputStream is = null;
private HttpURLConnection connection;
+ private String host;
+ private int port;
+
+ public ASUploadConnection(String dcHost, int port) {
+ this.host = dcHost;
+ this.port = port;
+ }
public OutputStream getOutputStream(String fileName) {
try {
// Create the HTTP connection to the upload URL
- connection = (HttpURLConnection) new URL(UPLOAD_URL).openConnection();
+ String url = "http://" + host + ":" + port + UPLOAD_URL_PATH;
+ connection = (HttpURLConnection) new URL(url).openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod(POST_REQUEST_METHOD);
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 26e2b4a..8ed6c96 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
@@ -70,6 +70,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
ASConnection connection;
String path;
String key;
+ String host;
+ int port;
/**
* Return availability of this resource
@@ -91,9 +93,9 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
// TODO add code to start the resource / connection to it
String typeName = context.getResourceType().getName();
- String host = conf.getSimpleValue("hostname","localhost");
+ host = conf.getSimpleValue("hostname","localhost");
String portString = conf.getSimpleValue("port","9990");
- int port = Integer.parseInt(portString);
+ port = Integer.parseInt(portString);
connection = new ASConnection(host,port);
path = conf.getSimpleValue("path", null);
@@ -130,8 +132,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
Operation op = new ReadAttribute(pathToAddress(path),req.getName()); // TODO batching
- //JsonNode obj = connection.execute(op);
- Result res = connection.execute2(op, false);
+ //JsonNode obj = connection.executeRaw(op);
+ Result res = connection.execute(op, false);
if (!res.isSuccess())
continue;
@@ -167,7 +169,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
List<PROPERTY_VALUE> address = pathToAddress(path);
Operation op = new ReadResource(address); // TOTO set recursive flag?
- JsonNode json = connection.execute(op);
+ JsonNode json = connection.executeRaw(op);
Configuration ret = new Configuration();
ObjectMapper mapper = new ObjectMapper();
@@ -364,7 +366,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
NameValuePair nvp = new NameValuePair(entry.getKey(),entry.getValue().getStringValue());
Operation writeAttribute = new Operation("write-attribute",pathToAddress(getResultingPath()),nvp);
- JsonNode result= connection.execute(writeAttribute);
+ JsonNode result= connection.executeRaw(writeAttribute);
if(ASConnection.isErrorReply(result)) {
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessage(ASConnection.getFailureDescription(result));
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index 176e6ce..05f79d8 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -19,7 +19,6 @@
package org.rhq.modules.plugins.jbossas7;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -51,7 +50,7 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
Operation getStatus = new Operation("read-attribute",address,"name","status");
JsonNode result = null;
try {
- result = connection.execute(getStatus);
+ result = connection.executeRaw(getStatus);
} catch (Exception e) {
log.warn(e.getMessage());
return AvailabilityType.DOWN;
@@ -130,7 +129,7 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
OperationResult operationResult = new OperationResult();
if (operation!=null) {
- JsonNode result = connection.execute(operation);
+ JsonNode result = connection.executeRaw(operation);
if (ASConnection.isErrorReply(result)) {
operationResult.setErrorMessage(ASConnection.getFailureDescription(result));
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 264716e..7f39a9f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -127,7 +127,7 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
address.add(new PROPERTY_VALUE("server-group",serverGroup));
Operation op = new ReadResource(address);
- ComplexResult res = (ComplexResult) dcConnection.execute2(op,true);
+ ComplexResult res = (ComplexResult) dcConnection.execute(op, true);
if (res.isSuccess()) {
if (res.getResult().containsKey("socket-binding-group")) {
String sbg = (String) res.getResult().get("socket-binding-group");
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index b79c9a3..8bafbb4 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -26,8 +26,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.content.PackageDetailsKey;
@@ -53,11 +51,11 @@ import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
* Component dealing with server group specific things
* @author Heiko W. Rupp
*/
+@SuppressWarnings("unused")
public class ServerGroupComponent extends DomainComponent implements ContentFacet, CreateChildResourceFacet {
private static final String SUCCESS = "success";
private static final String OUTCOME = "outcome";
- private final Log log = LogFactory.getLog(ServerGroupComponent.class);
@Override
public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) {
@@ -74,7 +72,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
for (ResourcePackageDetails details : packages) {
- ASUploadConnection uploadConnection = new ASUploadConnection();
+ ASUploadConnection uploadConnection = new ASUploadConnection(host,port);
String fileName = details.getFileName();
OutputStream out = uploadConnection.getOutputStream(fileName);
contentServices.downloadPackageBits(cctx, details.getKey(), out, false);
@@ -101,7 +99,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
cop.addStep(step1);
cop.addStep(step2);
- JsonNode result = connection.execute(cop);
+ JsonNode result = connection.executeRaw(cop);
if (ASConnection.isErrorReply(result)) // TODO get failure message into response
response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.FAILURE));
else
@@ -131,7 +129,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
List<PROPERTY_VALUE> serverGroupAddress = pathToAddress(path);
Operation op = new ReadChildrenNames(serverGroupAddress,"deployment"); // TODO read full packages not onyl names
- JsonNode node = connection.execute(op);
+ JsonNode node = connection.executeRaw(op);
if (ASConnection.isErrorReply(node))
return null;
@@ -169,9 +167,8 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
ContentServices contentServices = cctx.getContentServices();
String resourceTypeName = report.getResourceType().getName();
- ASUploadConnection uploadConnection = new ASUploadConnection();
+ ASUploadConnection uploadConnection = new ASUploadConnection(host,port);
OutputStream out = uploadConnection.getOutputStream(details.getFileName());
-// contentServices.downloadPackageBits(cctx,details.getKey(),out,false);
contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
JsonNode uploadResult = uploadConnection.finishUpload();
@@ -205,7 +202,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
cop.addStep(step1);
cop.addStep(step2);
- JsonNode result = connection.execute(cop);
+ JsonNode result = connection.executeRaw(cop);
if (ASConnection.isErrorReply(result)) {
report.setErrorMessage(ASConnection.getFailureDescription(resultNode));
report.setStatus(CreateResourceStatus.FAILURE);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index f233e3e..18ba3ba 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -98,7 +98,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
else {
List<PROPERTY_VALUE> addr ;
addr = parentComponent.pathToAddress(parentPath);
- json = connection.execute(new ReadChildrenNames(addr, childType));
+ json = connection.executeRaw(new ReadChildrenNames(addr, childType));
}
if (!ASConnection.isErrorReply(json)) {
if (recursive) {
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index a519e97..e4e9d70 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -42,8 +42,10 @@ public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
private static final String UPLOAD_FILE = "test-simple.war";
+ private static final String DC_HOST = "localhost";
+ private static final int DC_HTTP_PORT = 9990;
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L, enabled = true)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -51,7 +53,7 @@ public class UploadAndDeployTest {
System.out.println("sha: " + bytes_value);
System.out.println();
- ASConnection connection = new ASConnection("localhost",9990);
+ ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT);
List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
@@ -60,7 +62,7 @@ public class UploadAndDeployTest {
op.addAdditionalProperty("name", TEST_WAR); // this needs to be separate per upload
op.addAdditionalProperty("runtime-name", TEST_WAR);
System.out.flush();
- JsonNode ret = connection.execute(op);
+ JsonNode ret = connection.executeRaw(op);
System.out.println("Add to /deploy done " + ret);
System.out.flush();
@@ -73,7 +75,7 @@ public class UploadAndDeployTest {
op.addAdditionalProperty("runtime-name", TEST_WAR);
Operation deploy = new Operation("add",serverGroupAddress,"enabled","true");
System.out.flush();
- ret = connection.execute(deploy);
+ ret = connection.executeRaw(deploy);
System.out.println("Add to server group done: " + ret);
System.out.flush();
@@ -84,7 +86,7 @@ public class UploadAndDeployTest {
// Now tear down stuff again
Operation undeploy = new Operation("remove",serverGroupAddress);
- ret = connection.execute(undeploy);
+ ret = connection.executeRaw(undeploy);
assert ret.has("outcome") : "Ret not valied " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success " + ret.getTextValue();
@@ -93,7 +95,7 @@ public class UploadAndDeployTest {
// remove from domain
Operation remove = new Operation("remove",deploymentsAddress);
- ret = connection.execute(remove);
+ ret = connection.executeRaw(remove);
assert ret.has("outcome") : "Ret not valied " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from domain was no success " + ret.getTextValue();
@@ -102,7 +104,7 @@ public class UploadAndDeployTest {
}
- @Test(timeOut = 60*1000L)
+ @Test(timeOut = 60*1000L, enabled = true)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
@@ -129,8 +131,8 @@ public class UploadAndDeployTest {
cop.addStep(step2);
- ASConnection connection = new ASConnection("localhost",9990);
- JsonNode ret = connection.execute(cop);
+ ASConnection connection = new ASConnection(DC_HOST, DC_HTTP_PORT);
+ JsonNode ret = connection.executeRaw(cop);
System.out.println(ret);
System.out.flush();
@@ -139,7 +141,7 @@ public class UploadAndDeployTest {
cop = new CompositeOperation();
cop.addStep(step3);
cop.addStep(step4);
- ret = connection.execute(cop);
+ ret = connection.executeRaw(cop);
System.out.println(ret);
System.out.flush();
@@ -148,8 +150,8 @@ public class UploadAndDeployTest {
}
private String prepare() throws IOException {
- ASUploadConnection conn = new ASUploadConnection();
- OutputStream os = conn.getOutputStream("test1.war");
+ ASUploadConnection conn = new ASUploadConnection(DC_HOST, DC_HTTP_PORT);
+ OutputStream os = conn.getOutputStream("test.war");
commit 66fcac2419b39494c40b2cd5a8901e06beaf502f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 17:25:39 2011 +0200
If no socket binding group is defined in host.xml, reach out to the domain controller and get it from there.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 2fa711c..264716e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -37,6 +37,10 @@ import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.system.ProcessInfo;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.ReadResource;
/**
* Discovery class for managed AS 7 instances.
@@ -79,10 +83,19 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
config.put(new PropertySimple("group",serverInfo.group));
config.put(new PropertySimple("port",managementHostPort.port));
config.put(new PropertySimple("hostname",managementHostPort.host));
- if (serverInfo.bindingGroup!=null)
+ if (serverInfo.bindingGroup!=null) {
config.put(new PropertySimple("socket-binding-group",serverInfo.bindingGroup));
- else
- config.put(new PropertySimple("socket-binding-group", "standard-sockets")); // TODO remove when AS has no more "undefined"
+ config.put(new PropertySimple("socket-binding-port-offset",serverInfo.portOffset));
+ }
+ else {
+ HostPort dcHP = getDomainControllerFromHostXml();
+ if (dcHP.port == 9999)
+ dcHP.port = 9990; // TODO Hack until JBAS-9306 is solved
+
+ ServerInfo dcInfo = getBindingsFromDC(dcHP, serverInfo.group);
+ config.put(new PropertySimple("socket-binding-group", dcInfo.bindingGroup));
+ config.put(new PropertySimple("socket-binding-port-offset",dcInfo.portOffset));
+ }
config.put(new PropertySimple("socket-binding-port-offset",serverInfo.portOffset));
@@ -109,6 +122,25 @@ public class ManagedASDiscovery extends AbstractBaseDiscovery
return discoveredResources;
}
+ private ServerInfo getBindingsFromDC(HostPort domainController, String serverGroup) {
+ ASConnection dcConnection = new ASConnection(domainController.host,domainController.port);
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
+ address.add(new PROPERTY_VALUE("server-group",serverGroup));
+ Operation op = new ReadResource(address);
+ ComplexResult res = (ComplexResult) dcConnection.execute2(op,true);
+ if (res.isSuccess()) {
+ if (res.getResult().containsKey("socket-binding-group")) {
+ String sbg = (String) res.getResult().get("socket-binding-group");
+
+ ServerInfo serverInfo = new ServerInfo();
+ serverInfo.bindingGroup = sbg;
+ return serverInfo;
+ }
+ }
+
+ return new ServerInfo();
+ }
+
/**
* Loop through the Process scans for ManagedAS and if found extract the logfile path.
* @param scans process scan results
commit f22bc3f1472bca5c05bab29319c02998048d0bcb
Merge: 7660aec e9639a9
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:22:16 2011 +0200
Merge branch 'master' into as7plugin
commit 7660aec86b71f0c90945bfacf8f9831af4de11dd
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:18:32 2011 +0200
BZ 693700 - prevent NPE for empty <c:list-property/>
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
index 8b9868a..fd2decc 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/configuration/metadata/ConfigurationMetadataManagerBean.java
@@ -450,15 +450,23 @@ public class ConfigurationMetadataManagerBean implements ConfigurationMetadataMa
* the member prop def for the list. If the member prop def is a nested structure the whole thing
* is replaced from the top.
*
- * @param exList the existing prop def list
+ * @param exList the existing prop def list
* @param newList the new prop def list
*/
private void replaceListProperty(PropertyDefinitionList exList, PropertyDefinitionList newList) {
PropertyDefinition doomedMemberDef = null;
+ if (newList.getMemberDefinition()==null) {
+ log.error("\n\n!! Member definition for new list property [" + newList.getName() + "] is null - check and fix the plugin descriptor\n");
+ return;
+ }
+
+ // We did not have a member definition before (which is wrong )
+ // we need to add it now
// only remove the existing member if it is a different entity
- if (exList.getMemberDefinition().getId() != newList.getMemberDefinition().getId()) {
- doomedMemberDef = exList.getMemberDefinition();
+ PropertyDefinition exListMemberDefinition = exList.getMemberDefinition();
+ if (exListMemberDefinition !=null && exListMemberDefinition.getId() != newList.getMemberDefinition().getId()) {
+ doomedMemberDef = exListMemberDefinition;
}
exList.setMemberDefinition(newList.getMemberDefinition());
commit 71fef20671e86e28c40c4ac5cf923d5a32971bcb
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:10:13 2011 +0200
Improve handling and detection of Domain and managed servers.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index cdf7edb..d58f0c9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -226,7 +226,7 @@ public class ASConnection {
} catch (IOException e) {
- e.printStackTrace(); // TODO: Customise this generated block
+ log.error("Failed to get data: " + e.getMessage() );
}
return null;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
new file mode 100644
index 0000000..7a648c9
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/AbstractBaseDiscovery.java
@@ -0,0 +1,230 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.system.ProcessInfo;
+
+/**
+ * Abstract base class for some discovery related functionality - especially
+ * in the area of processes and host.xml
+ * @author Heiko W. Rupp
+ */
+public abstract class AbstractBaseDiscovery<T extends ResourceComponent> implements ResourceDiscoveryComponent<T> {
+ static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
+ private static final String DJBOSS_SERVER_HOME_DIR = "-Djboss.home.dir";
+ static final int DEFAULT_MGMT_PORT = 9990;
+ protected Document hostXml;
+ protected final Log log = LogFactory.getLog(this.getClass());
+
+// private final Log log = LogFactory.getLog(AbstractBaseDiscovery.class);
+
+ protected void readHostXml(ProcessInfo processInfo) {
+ String hostXmlFile = getHostXmlFileLocation(processInfo);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ try {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ InputStream is = new FileInputStream(hostXmlFile);
+ hostXml = builder.parse(is);
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+ }
+
+ /**
+ * Get the location of the host definition file (host.xml in domain mode, standalone.xml
+ * in standalone mode.
+ *
+ * @param processInfo ProcessInfo structure containing the ENV variables
+ * @return The path to the definition file.
+ */
+ private String getHostXmlFileLocation(ProcessInfo processInfo) {
+
+ String home = getHomeDirFromCommandLine(processInfo.getCommandLine());
+ StringBuilder builder = new StringBuilder(home);
+ builder.append("/domain");
+ builder.append("/configuration");
+ builder.append("/host.xml");
+ return builder.toString();
+
+ }
+
+ String getHomeDirFromCommandLine(String[] commandLine) {
+ for (String line: commandLine) {
+ if (line.startsWith(DJBOSS_SERVER_HOME_DIR))
+ return line.substring(DJBOSS_SERVER_HOME_DIR.length()+1);
+ }
+ return "";
+ }
+
+ String getLogFileFromCommandLine(String[] commandLine) {
+
+ for (String line: commandLine) {
+ if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
+ return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length());
+ }
+ return "";
+ }
+
+ protected HostPort getManagementPortFromHostXml() {
+ Element host = hostXml.getDocumentElement();
+ NodeList interfaceParent = host.getElementsByTagName("management-interfaces");
+ if (interfaceParent ==null || interfaceParent.getLength()==0) {
+ log.warn("No <management-interfaces> found in host.xml");
+ return new HostPort();
+ }
+ NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes();
+ if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) {
+ log.warn("No <*-interface> found in host.xml");
+ return new HostPort();
+ }
+ for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) {
+ if (!(mgmtInterfaces.item(i) instanceof Element))
+ continue;
+
+ Element mgmtInterface = (Element) mgmtInterfaces.item(i);
+ if (mgmtInterface.getNodeName().equals("http-interface")) {
+ String tmp = mgmtInterface.getAttribute("port");
+ int port = Integer.valueOf(tmp);
+ HostPort hp = new HostPort();
+ hp.isLocal=true;
+ hp.port = port;
+
+ String nIf = mgmtInterface.getAttribute("interface");
+ String hostName = getInterface(nIf);
+ hp.host = hostName;
+ return hp;
+ }
+ }
+ return new HostPort();
+ }
+
+ private String getInterface(String nIf) {
+ Element host = hostXml.getDocumentElement();
+ NodeList interfaceParent = host.getElementsByTagName("interfaces");
+ if (interfaceParent ==null || interfaceParent.getLength()==0) {
+ log.warn("No <interfaces> found in host.xml");
+ return null;
+ }
+ NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes();
+ if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) {
+ log.warn("No <*-interface> found in host.xml");
+ return null;
+ }
+ for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) {
+ if (!(mgmtInterfaces.item(i) instanceof Element))
+ continue;
+ Element mgmtInterface = (Element) mgmtInterfaces.item(i);
+ if (mgmtInterface.getNodeName().equals("interface")) {
+ String name = mgmtInterface.getAttribute("name");
+ if (!name.equals(nIf))
+ continue;
+
+ NodeList nl = mgmtInterface.getChildNodes();
+ if (nl!=null) {
+ for (int j = 0 ; j < nl.getLength(); j++) {
+ if (!(nl.item(j) instanceof Element))
+ continue;
+
+ String nodeName = nl.item(j).getNodeName();
+ if (nodeName.equals("any-ipv4-address"))
+ return "0.0.0.0";
+
+ String x = ((Element) nl.item(j)).getAttribute("value");
+ return x;
+
+ // TODO check for <any> and so on
+ }
+ }
+ }
+
+ }
+ return null; // TODO: Customise this generated block
+ }
+
+ protected String findHostName() {
+ String hostName = hostXml.getDocumentElement().getAttribute("name");
+ return hostName;
+ }
+
+ protected HostPort getDomainControllerFromHostXml() {
+
+ Element host = hostXml.getDocumentElement();
+ NodeList dcParent = host.getElementsByTagName("domain-controller");
+ if (dcParent==null || dcParent.getLength()==0)
+ return new HostPort(false);
+ NodeList interfs = dcParent.item(0).getChildNodes();
+ for (int i = 0; i < interfs.getLength(); i++) {
+ if (!(interfs.item(i)instanceof Element))
+ continue;
+
+ Element interf = (Element) interfs.item(i);
+ if (interf.getNodeName().equals("local"))
+ return new HostPort();
+
+ // not local, so get the remote
+ HostPort hp = new HostPort(false);
+ hp.host = interf.getAttribute("host");
+ hp.port = Integer.parseInt(interf.getAttribute("port"));
+ return hp;
+ }
+
+ return new HostPort(false);
+ }
+
+ protected static class HostPort {
+ String host;
+ int port;
+ boolean isLocal = true;
+
+ public HostPort() {
+ host = "localhost";
+ port = DEFAULT_MGMT_PORT;
+ isLocal = true;
+ }
+
+ public HostPort(boolean local) {
+ this();
+ isLocal = local;
+ }
+
+ @Override
+ public String toString() {
+ return "HostPort{" +
+ "host='" + host + '\'' +
+ ", port=" + port +
+ ", isLocal=" + isLocal +
+ '}';
+ }
+ }
+}
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 43509b8..26e2b4a 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
@@ -101,7 +101,6 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
-// Object o = connection.getLevelData("", false); // BASE entries
myServerName = context.getResourceKey().substring(context.getResourceKey().lastIndexOf("/")+1);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
index 07c1522..667b3ee 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
@@ -18,29 +18,28 @@
*/
package org.rhq.modules.plugins.jbossas7;
-import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.system.ProcessInfo;
/**
- * Discover the domain
+ * Discover the domain. This is done by scanning for host controllers.
+ * If they are also DC, the domain-controller element points to local.
*
* @author Heiko W. Rupp
*/
@SuppressWarnings("unused")
-public class DomainDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+public class DomainDiscovery extends AbstractBaseDiscovery<BaseComponent> {
private final Log log = LogFactory.getLog(this.getClass());
@@ -49,50 +48,45 @@ public class DomainDiscovery implements ResourceDiscoveryComponent<BaseComponent
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
- mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
- // TODO get next from some host.xml file
- String host = "localhost";
- String portString = "9990";
- int port = Integer.parseInt(portString);
- ASConnection connection = new ASConnection(host,port);
+ List<ProcessScanResult> scans = context.getAutoDiscoveredProcesses();
+ for (ProcessScanResult psr : scans) {
- Configuration config = context.getDefaultPluginConfiguration();
+ // get the HostController, to find host.xml
+ String psName = psr.getProcessScan().getName();
+ if (!psName.equals("HostController"))
+ continue;
+ // Now we have the host controller, lets get the host.xml file
+ // and obtain the domain controller info from there
+ ProcessInfo processInfo = psr.getProcessInfo();
+ readHostXml(processInfo);
+ HostPort dcHp = getDomainControllerFromHostXml();
- // A domain has a server group so check for it.
- boolean found = false;
- JsonNode json = connection.getLevelData(null,null);
- if (!ASConnection.isErrorReply(json)) {
-
- Iterator<String> fields = json.getFieldNames();
- while (fields.hasNext()) {
- String field = fields.next();
- if (field.equals("server-group"))
- found=true;
-
- }
-
- if (found) {
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- "Domain", // Key
- "Domain", // Name
- null, // Version
- context.getResourceType().getDescription(), // Description
- config,
- null);
- details.add(detail);
+ if (!dcHp.isLocal) {
+ log.info("Domain controller is not local, but at " + dcHp);
+ continue;
}
- return details;
+ // Ok, this is a domain controller, so we can return a Domain resource.
+
+ // Get the management port and save for later use
+ HostPort managementHostPort = getManagementPortFromHostXml();
+ Configuration config = context.getDefaultPluginConfiguration();
+ config.put(new PropertySimple("port",managementHostPort.port));
+ config.put(new PropertySimple("hostname",managementHostPort.host));
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ "Domain", // Key
+ "Domain", // Name
+ null, // Version
+ context.getResourceType().getDescription(), // Description
+ config,
+ null);
+ details.add(detail);
}
-
- return Collections.emptySet();
+ return details;
}
-
-}
+}
\ No newline at end of file
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
index 86e3b99..2fa711c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -19,20 +19,12 @@
package org.rhq.modules.plugins.jbossas7;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
@@ -43,7 +35,6 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
import org.rhq.core.system.ProcessInfo;
@@ -52,18 +43,10 @@ import org.rhq.core.system.ProcessInfo;
*
* @author Heiko W. Rupp
*/
-public class ManagedASDiscovery implements ResourceDiscoveryComponent
+public class ManagedASDiscovery extends AbstractBaseDiscovery
{
- static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
- static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
- static final String DLOGGING_CONFIGURATION = "-Dlogging.configuration=";
- static final int DEFAULT_MGMT_PORT = 9990;
- private final Log log = LogFactory.getLog(this.getClass());
- private Document hostXml;
- private static final String DJBOSS_SERVER_HOME_DIR = "-Djboss.home.dir";
-
/**
* Run the auto-discovery
*/
@@ -85,7 +68,7 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
ProcessInfo processInfo = psr.getProcessInfo();
readHostXml(processInfo);
String hostName = findHostName();
- int port = getManagementPortFromHostXml();
+ HostPort managementHostPort = getManagementPortFromHostXml();
List<ServerInfo> serverNames = getServersFromHostXml();
@@ -94,7 +77,15 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
Configuration config = discoveryContext.getDefaultPluginConfiguration();
config.put(new PropertySimple("domainHost",hostName));
config.put(new PropertySimple("group",serverInfo.group));
- config.put(new PropertySimple("port",port));
+ config.put(new PropertySimple("port",managementHostPort.port));
+ config.put(new PropertySimple("hostname",managementHostPort.host));
+ if (serverInfo.bindingGroup!=null)
+ config.put(new PropertySimple("socket-binding-group",serverInfo.bindingGroup));
+ else
+ config.put(new PropertySimple("socket-binding-group", "standard-sockets")); // TODO remove when AS has no more "undefined"
+ config.put(new PropertySimple("socket-binding-port-offset",serverInfo.portOffset));
+
+
// TODO this fails for the downed servers.
// get from the domain or other place as soon as the domain provides it.
@@ -140,32 +131,6 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
}
}
- private int getManagementPortFromHostXml() {
- Element host = hostXml.getDocumentElement();
- NodeList interfaceParent = host.getElementsByTagName("management-interfaces");
- if (interfaceParent ==null || interfaceParent.getLength()==0) {
- log.warn("No <management-interfaces> found in host.xml");
- return DEFAULT_MGMT_PORT;
- }
- NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes();
- if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) {
- log.warn("No <*-interface> found in host.xml");
- return DEFAULT_MGMT_PORT;
- }
- for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) {
- if (!(mgmtInterfaces.item(i) instanceof Element))
- continue;
-
- Element mgmtInterface = (Element) mgmtInterfaces.item(i);
- if (mgmtInterface.getNodeName().equals("http-interface")) {
- String tmp = mgmtInterface.getAttribute("port");
- int port = Integer.valueOf(tmp);
- return port;
- }
- }
- return DEFAULT_MGMT_PORT;
- }
-
private List<ServerInfo> getServersFromHostXml() {
Element host = hostXml.getDocumentElement();
@@ -193,70 +158,30 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
autoStart = "false";
info.autoStart = Boolean.getBoolean(autoStart);
- result.add(info);
- }
-
- return result;
- }
+ // Look for <socket-binding-group ref="standard-sockets" port-offset="250"/>
+ NodeList sbgs = server.getChildNodes();
+ if (sbgs!=null) {
+ for (int j = 0 ; j < sbgs.getLength(); j++) {
+ if (!(sbgs.item(j) instanceof Element))
+ continue;
+ Element sbg = (Element) sbgs.item(j);
+ if (!sbg.getNodeName().equals("socket-binding-group"))
+ continue;
- private String findHostName() {
- String hostName = hostXml.getDocumentElement().getAttribute("name");
- return hostName;
- }
+ info.bindingGroup = sbg.getAttribute("ref");
+ String portOffset = sbg.getAttribute("port-offset");
+ if (portOffset!=null && !portOffset.isEmpty())
+ info.portOffset = Integer.parseInt(portOffset);
- private void readHostXml(ProcessInfo processInfo) {
- String hostXmlFile = getHostXmlFileLocation(processInfo);
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputStream is = new FileInputStream(hostXmlFile);
- hostXml = builder.parse(is);
- is.close();
- } catch (Exception e) {
- e.printStackTrace(); // TODO: Customise this generated block
+ }
+ }
+ result.add(info);
}
- }
-
- /**
- * Get the location of the host definition file (host.xml in domain mode, standalone.xml
- * in standalone mode.
- *
- * @param processInfo ProcessInfo structure containing the ENV variables
- * @return The path to the definition file.
- */
- private String getHostXmlFileLocation(ProcessInfo processInfo) {
-
- String home = getHomeDirFromCommandLine(processInfo.getCommandLine());
- StringBuilder builder = new StringBuilder(home);
- builder.append("/domain");
- builder.append("/configuration");
- builder.append("/host.xml");
- return builder.toString();
-
- }
-
-
- String getHomeDirFromCommandLine(String[] commandLine) {
- for (String line: commandLine) {
- if (line.startsWith(DJBOSS_SERVER_HOME_DIR))
- return line.substring(DJBOSS_SERVER_HOME_DIR.length()+1);
- }
- return "";
+ return result;
}
-//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
-//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties
-
- String getLogFileFromCommandLine(String[] commandLine) {
-
- for (String line: commandLine) {
- if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
- return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length());
- }
- return "";
- }
private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) {
@@ -278,12 +203,12 @@ public class ManagedASDiscovery implements ResourceDiscoveryComponent
}
}
- private class ServerInfo {
+ private static class ServerInfo {
String name;
String group;
boolean autoStart;
-
-
+ int portOffset;
+ String bindingGroup;
}
}
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 099d1b9..e75507a 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
@@ -114,6 +114,15 @@
<subcategory name="Web"/>
</subcategories>
+ <plugin-configuration>
+ <c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/>
+ </plugin-configuration>
+
+ <!-- Scan for host controller is intentional -->
+ <process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
+
+
<operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
<parameters>
<c:simple-property name="name" description="Name of Group to add"/>
@@ -251,10 +260,12 @@
class="DomainComponent"
>
<plugin-configuration>
- <c:simple-property name="hostname" default="localhost" required="true"/>
- <c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="hostname" default="localhost" displayName="Management host" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" displayName="Management port" required="true"/>
<c:simple-property name="domainHost" readOnly="true" description="Hostname in the domain"/>
<c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/>
+ <c:simple-property name="socket-binding-group" readOnly="true" displayName="Socket binding group" description="Socket bindngs to use"/>
+ <c:simple-property name="socket-binding-port-offset" readOnly="true" displayName="Port Offset" type="integer" default="0" description="Offset to the base ports"/>
&logSources;
</plugin-configuration>
commit c629ea66985a1d2f161ba625f8622024e121a23e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 13 13:09:23 2011 +0200
Improve Result handling.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
index 2d011fd..a87a6f8 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -18,11 +18,15 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
+import java.util.List;
+import java.util.Map;
+
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
/**
- * {"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null}
+ * Counterpart of a result JSON object like e.g.:
+ * <pre>{"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null}</pre>
* @author Heiko W. Rupp
*/
public class Result {
@@ -30,7 +34,13 @@ public class Result {
private String outcome;
private Object result;
@JsonProperty("compensating-operation")
- private Object compensatingOperation;
+ private Operation compensatingOperation;
+ @JsonProperty("failure-description")
+ private List<Map<String, String>> failureDescription;
+ @JsonProperty("host-failure-description") // TODO JBAS-9182
+ private List<Map<String, String>> hostFailureDescription;
+ @JsonProperty("domain-failure-description") // TODO JBAS-9182
+ private List<Map<String, String>> domainFailureDescription;
@JsonIgnore
private boolean success = false;
@@ -60,11 +70,35 @@ public class Result {
this.result = result;
}
- public Object getCompensatingOperation() {
+ public Operation getCompensatingOperation() {
return compensatingOperation;
}
- public void setCompensatingOperation(Object compensatingOperation) {
+ public void setCompensatingOperation(Operation compensatingOperation) {
this.compensatingOperation = compensatingOperation;
}
+
+ public List<Map<String, String>> getFailureDescription() {
+ return failureDescription;
+ }
+
+ public void setFailureDescription(List<Map<String, String>> failureDescription) {
+ this.failureDescription = failureDescription;
+ }
+
+ public List<Map<String, String>> getHostFailureDescription() {
+ return hostFailureDescription;
+ }
+
+ public void setHostFailureDescription(List<Map<String, String>> hostFailureDescription) {
+ this.hostFailureDescription = hostFailureDescription;
+ }
+
+ public List<Map<String, String>> getDomainFailureDescription() {
+ return domainFailureDescription;
+ }
+
+ public void setDomainFailureDescription(List<Map<String, String>> domainFailureDescription) {
+ this.domainFailureDescription = domainFailureDescription;
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 64d9d30..34d722c 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -141,6 +141,23 @@ public class OperationJsonTest {
assert result != null;
assert result.getOutcome().equals("success");
assert result.isSuccess();
+ assert result.getFailureDescription() == null;
+ }
+ public void simpleResultWithFailure() throws Exception {
+
+ String resultString = "{\"outcome\" : \"failed\", \"failure-description\" : [{ \"java.util.NoSuchElementException\" : \"No child 'profile' exists\" }]}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("failed");
+ assert !result.isSuccess();
+
+ assert result.getResult() == null;
+ assert result.getCompensatingOperation() == null;
+ assert result.getFailureDescription() != null;
+ assert result.getFailureDescription().size() == 1;
}
public void complexResult1() throws Exception {
@@ -162,4 +179,24 @@ public class OperationJsonTest {
assert aliases.size()==1;
assert aliases.get(0).equals("example.com");
}
+
+ public void compensatingOp() throws Exception {
+
+ String resultString = "{\"outcome\" : \"success\", \"result\" : null, \"compensating-operation\" : {\"operation\" : \"remove\", \"address\" : [{\"deployment\" : \"test.war\"}]}}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("success");
+ assert result.isSuccess();
+
+ assert result.getCompensatingOperation()!=null;
+
+ Operation op = result.getCompensatingOperation();
+
+ assert op.getOperation().equals("remove");
+
+ }
+
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index 11e25ad..a519e97 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -43,6 +43,7 @@ public class UploadAndDeployTest {
static final String TEST_WAR = "test.war";
private static final String UPLOAD_FILE = "test-simple.war";
+ @Test(timeOut = 60*1000L)
public void testUploadIndividualSteps() throws Exception {
String bytes_value = prepare();
@@ -101,6 +102,7 @@ public class UploadAndDeployTest {
}
+ @Test(timeOut = 60*1000L)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
commit 721b38accafbd2b609810dc2f6ad2665aa0e21cc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Apr 12 14:10:32 2011 +0200
Transition resource path from /type/value/type.. to type=value pairs.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 9037537..cdf7edb 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -27,8 +27,6 @@ import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,9 +34,9 @@ import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.jetbrains.annotations.Nullable;
-import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
-import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
/**
* Provide connections to the AS and reading / writing date from/to it.
@@ -52,6 +50,7 @@ public class ASConnection {
URL url;
String urlString;
private StringBuilder builder;
+ private ObjectMapper mapper;
public ASConnection(String host, int port) {
this.host = host;
@@ -63,6 +62,8 @@ public class ASConnection {
} catch (MalformedURLException e) {
throw new IllegalArgumentException(e.getMessage());
}
+
+ mapper = new ObjectMapper();
}
@@ -131,11 +132,6 @@ public class ASConnection {
return tree;
}
- JsonNode getAttributeValue(@Nullable String base, @Nullable String attributeName) throws Exception {
- String op = "operation=attribute&name=" + attributeName;
- return getLevelData(base,op);
- }
-
static boolean isErrorReply(JsonNode in) {
if (in == null)
@@ -181,8 +177,6 @@ public class ASConnection {
conn.setRequestMethod("POST");
OutputStream out = conn.getOutputStream();
- ObjectMapper mapper = new ObjectMapper();
-
String result = mapper.writeValueAsString(operation);
System.out.println("Json to send: " + result);
System.out.flush();
@@ -238,6 +232,22 @@ public class ASConnection {
return null;
}
+ public Result execute2(Operation op, boolean isComplex){
+ JsonNode node = execute(op);
+
+ try {
+ Result res;
+ if (isComplex)
+ res = mapper.readValue(node,ComplexResult.class);
+ else
+ res = mapper.readValue(node,Result.class);
+ return res;
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ return null;
+ }
+ }
+
private URL getBaseUrl(String base, String ops) throws MalformedURLException {
String spec;
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 28b94f9..43509b8 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
@@ -33,6 +33,7 @@ import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -45,11 +46,12 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.ReadAttribute;
+import org.rhq.modules.plugins.jbossas7.json.ReadResource;
+import org.rhq.modules.plugins.jbossas7.json.Result;
import java.util.ArrayList;
import java.util.Collections;
@@ -58,8 +60,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import com.sun.org.apache.xml.internal.security.utils.Base64;
-
public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet
{
final Log log = LogFactory.getLog(this.getClass());
@@ -129,14 +129,24 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (MeasurementScheduleRequest req : metrics) {
- JsonNode obj = connection.getAttributeValue(key, req.getName()); // TODO batching
- String val = obj.getValueAsText();
+ Operation op = new ReadAttribute(pathToAddress(path),req.getName()); // TODO batching
+ //JsonNode obj = connection.execute(op);
+ Result res = connection.execute2(op, false);
+ if (!res.isSuccess())
+ continue;
+
+ String val = (String) res.getResult();
+
if (req.getDataType()== DataType.MEASUREMENT) {
- Double d = Double.parseDouble(val);
- MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
- report.addData(data);
+ try {
+ Double d = Double.parseDouble(val);
+ MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
+ report.addData(data);
+ } catch (NumberFormatException e) {
+ log.warn("Non numeric input for [" + req.getName() + "] : [" + val + "]");
+ }
} else if (req.getDataType()== DataType.TRAIT) {
MeasurementDataTrait data = new MeasurementDataTrait(req,val);
report.addData(data);
@@ -154,15 +164,18 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- String myPath = getResultingPath();
-
+// String myPath = getResultingPath();
- JsonNode json = connection.getLevelData(myPath,true,false);
+ List<PROPERTY_VALUE> address = pathToAddress(path);
+ Operation op = new ReadResource(address); // TOTO set recursive flag?
+ JsonNode json = connection.execute(op);
Configuration ret = new Configuration();
ObjectMapper mapper = new ObjectMapper();
- for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
+ Set<Map.Entry<String, PropertyDefinition>> entrySet = configDef.getPropertyDefinitions().entrySet();
+ for (Map.Entry<String,PropertyDefinition> propDefEntry: entrySet) { // TODO all properties
+ PropertyDefinition propDef = propDefEntry.getValue();
JsonNode sub = json.findValue(propDef.getName());
if (propDef instanceof PropertyDefinitionSimple) {
PropertySimple propertySimple;
@@ -285,6 +298,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
}
ret.put(propertyList);
+ } // end List of ..
+ else if (propDef instanceof PropertyDefinitionMap) {
+ PropertyDefinitionMap mapDef = (PropertyDefinitionMap) propDef;
+ Map<String,PropertyDefinition> memberDefMap = mapDef.getPropertyDefinitions();
+ for (Map.Entry<String,PropertyDefinition> maEntry : memberDefMap.entrySet()) {
+ JsonNode valueNode = json.findValue(maEntry.getKey());
+ System.out.println(valueNode);
+ PropertySimple p = putProperty(valueNode,maEntry.getValue());
+ ret.put(p);
+ }
}
}
@@ -292,6 +315,31 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
return ret;
}
+ PropertySimple putProperty(JsonNode value, PropertyDefinition def) {
+ String name = def.getName();
+ PropertySimpleType type = ((PropertyDefinitionSimple) def).getType();
+ PropertySimple ps;
+ switch (type) {
+ case BOOLEAN:
+ ps = new PropertySimple(name,value.getBooleanValue());
+ break;
+ case FLOAT:
+ case DOUBLE:
+ ps = new PropertySimple(name,value.getDoubleValue());
+ break;
+ case INTEGER:
+ ps = new PropertySimple(name,value.getIntValue());
+ break;
+ case LONG:
+ ps = new PropertySimple(name,value.getLongValue());
+ break;
+ default:
+ ps = new PropertySimple(name,value.getTextValue());
+ }
+
+ return ps;
+ }
+
protected String getResultingPath() {
ResourceComponent parentResourceComponent = context.getParentResourceComponent();
String parentPath =null;
@@ -302,10 +350,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
if (parentPath!=null) {
- if (parentPath.endsWith("/") || path.startsWith("/"))
- myPath = parentPath + path;
- else
- myPath = parentPath + "/" + path;
+ myPath = parentPath + "," + path;
}
else
myPath = path;
@@ -329,21 +374,29 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
- protected List<PROPERTY_VALUE> pathToAddress(String path) {
+ /**
+ * Convert a path in the form key=value,key=value... to a List of properties.
+ * @param path Path to translate
+ * @return List of properties
+ */
+ public List<PROPERTY_VALUE> pathToAddress(String path) {
if (path==null || path.isEmpty())
return Collections.emptyList();
- if (path.endsWith("/"))
- path = path.substring(0,path.length()-1);
-
- if (path.startsWith("/"))
- path = path.substring(1);
-
List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
- String[] components = path.split("/");
- for (int i = 0; i < components.length ; i+=2) {
- PROPERTY_VALUE valuePair = new PROPERTY_VALUE(components[i],components[i+1]);
- result.add(valuePair);
+ String[] components = path.split(",");
+ for (String component : components) {
+ String tmp = component.trim();
+
+ if (tmp.contains("=")) {
+ // strip / from the start of the key if it happens to be there
+ if (tmp.startsWith("/"))
+ tmp = tmp.substring(1);
+
+ String[] pair = tmp.split("=");
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(pair[0], pair[1]);
+ result.add(valuePair);
+ }
}
return result;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
index 7608b9c..07c1522 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
@@ -21,7 +21,6 @@ package org.rhq.modules.plugins.jbossas7;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
-import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -29,13 +28,11 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.modules.plugins.jbossas7.json.Subsystem;
/**
* Discover the domain
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index ff7048b..b79c9a3 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -128,8 +128,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
@Override
public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
- List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
- serverGroupAddress.add(new PROPERTY_VALUE("server-group",serverGroupFromKey()));
+ List<PROPERTY_VALUE> serverGroupAddress = pathToAddress(path);
Operation op = new ReadChildrenNames(serverGroupAddress,"deployment"); // TODO read full packages not onyl names
JsonNode node = connection.execute(op);
@@ -194,7 +193,8 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
deploymentsAddress.add(new PROPERTY_VALUE("deployment", fileName));
Operation step1 = new Operation("add",deploymentsAddress);
step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
- step1.addAdditionalProperty("name", fileName);
+ step1.addAdditionalProperty("name", fileName); // TODO set a random name here - or wait on AS to "fix" this
+ step1.addAdditionalProperty("runtime-name", fileName);
List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
serverGroupAddress.add(new PROPERTY_VALUE("server-group",serverGroupFromKey()));
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index b6619b8..f233e3e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -63,26 +63,31 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
Configuration config = context.getDefaultPluginConfiguration();
String cpath = config.getSimpleValue("path", null);
+ if (cpath==null) {
+ log.error("Path plugin config is null for ResourceType [" + context.getResourceType().getName() +"].");
+ return details;
+ }
+
+
boolean recursive = false;
String parentPath = parentComponent.getPath();
String path;
- if (cpath!=null && cpath.endsWith("/*")) {
- path = cpath.substring(0,cpath.length()-2);
+ String childType = null;
+ if (!cpath.contains("=")) { // NO = -> no sub path, but a type
recursive = true;
+ childType = cpath;
+
}
+
+ if (parentPath==null || parentPath.isEmpty())
+ path = "";
else
- path = cpath;
-
- if (parentPath!=null && !parentPath.isEmpty()) {
- if (recursive)
- path = parentPath;
- else if (parentPath.endsWith("/") || path.startsWith("/"))
- path = parentPath + path;
- else
- path = parentPath + "/" + path;
- }
+ path = parentPath;
+
+ if (cpath.contains("="))
+ path += "," + cpath;
System.out.println("total path: [" + path + "]");
@@ -93,19 +98,12 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
else {
List<PROPERTY_VALUE> addr ;
addr = parentComponent.pathToAddress(parentPath);
- String childType = cpath.substring(0, cpath.length() - 2);
- if (childType.startsWith("/"))
- childType = childType.substring(1);
json = connection.execute(new ReadChildrenNames(addr, childType));
}
if (!ASConnection.isErrorReply(json)) {
if (recursive) {
- int i = path.lastIndexOf("/");
- String subPath = path.substring(i+1);
JsonNode subNode = json.findPath("result");
- if (subNode==null || subNode.isNull())
- subNode = json.get(subPath); // TODO clean this up. to get the 'key' in a path from the AS we need to use get()
if (subNode!=null && subNode.isContainerNode()){
@@ -116,24 +114,24 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String val = node.getTextValue();
- String newPath = cpath.replaceAll("\\*",val);
+ String newPath = cpath + "=" + val;
Configuration config2 = context.getDefaultPluginConfiguration();
- PropertySimple pathProp = new PropertySimple("path",newPath);
- config2.put(pathProp);
+
String resKey;
- String childType = cpath.substring(0, cpath.length() - 2);
- if (childType.startsWith("/"))
- childType = childType.substring(1);
- resKey = context.getParentResourceContext().getResourceKey() + "/" +childType + "/" + val;
- String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+ if (path==null||path.isEmpty())
+ resKey = newPath;
+ else
+ resKey = path + "," +childType + "=" + val;
+ PropertySimple pathProp = new PropertySimple("path",resKey);
+ config2.put(pathProp);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
context.getResourceType(), // DataType
resKey, // Key
- name, // Name
+ val, // Name
null, // Version
"TODO", // subsystem.description, // TODO Description
config2,
@@ -155,7 +153,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String resKey = path;
- String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+ String name = resKey.substring(resKey.lastIndexOf("=") + 1);
Configuration config2 = context.getDefaultPluginConfiguration();
PropertySimple pathProp = new PropertySimple("path",path);
config2.put(pathProp);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ComplexResult.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ComplexResult.java
new file mode 100644
index 0000000..134026d
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ComplexResult.java
@@ -0,0 +1,40 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.rhq.modules.plugins.jbossas7.json.Result;
+
+/**
+ * A result object with a complex 'result' member
+ * @author Heiko W. Rupp
+ */
+public class ComplexResult extends Result {
+
+ private Map<String,Object> result;
+
+ public Map<String, Object> getResult() {
+ return result;
+ }
+
+ public void setResult(Map<String, Object> result) {
+ this.result = result;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadAttribute.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadAttribute.java
new file mode 100644
index 0000000..773e862
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadAttribute.java
@@ -0,0 +1,32 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.List;
+
+/**
+ * Read Attribute operation
+ * @author Heiko W. Rupp
+ */
+public class ReadAttribute extends Operation {
+
+ public ReadAttribute(List<PROPERTY_VALUE> address, String name) {
+ super("read-attribute",address,"name",name);
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
new file mode 100644
index 0000000..2d011fd
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Result.java
@@ -0,0 +1,70 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * {"outcome" : "success", "result" : "no metrics available", "compensating-operation" : null}
+ * @author Heiko W. Rupp
+ */
+public class Result {
+
+ private String outcome;
+ private Object result;
+ @JsonProperty("compensating-operation")
+ private Object compensatingOperation;
+ @JsonIgnore
+ private boolean success = false;
+
+ public Result() {
+
+ }
+
+ public String getOutcome() {
+ return outcome;
+ }
+
+ public void setOutcome(String outcome) {
+ this.outcome = outcome;
+ if (outcome.equalsIgnoreCase("success"))
+ success = true;
+ }
+
+ public boolean isSuccess() {
+ return success;
+ }
+
+ public Object getResult() {
+ return result;
+ }
+
+ public void setResult(Object result) {
+ this.result = result;
+ }
+
+ public Object getCompensatingOperation() {
+ return compensatingOperation;
+ }
+
+ public void setCompensatingOperation(Object compensatingOperation) {
+ this.compensatingOperation = compensatingOperation;
+ }
+}
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 435f58f..099d1b9 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
@@ -108,6 +108,12 @@
class="DomainComponent"
description="An AS7 management profile">
+ <subcategories>
+ <subcategory name="Integration" />
+ <subcategory name="Core"/>
+ <subcategory name="Web"/>
+ </subcategories>
+
<operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
<parameters>
<c:simple-property name="name" description="Name of Group to add"/>
@@ -126,7 +132,7 @@
class="BaseComponent">
<plugin-configuration>
- <c:simple-property name="path" default="/profile/*" readOnly="true"/>
+ <c:simple-property name="path" default="profile" readOnly="true"/>
</plugin-configuration>
</server>
<server name="ServerGroup"
@@ -137,7 +143,7 @@
<!-- TODO move operation to createDeletePolicy="create-only" -->
<plugin-configuration>
- <c:simple-property name="path" default="/server-group/*" readOnly="true"/>
+ <c:simple-property name="path" default="server-group" readOnly="true"/>
</plugin-configuration>
@@ -153,7 +159,7 @@
<service name="Deployment" class="BaseComponent" discovery="SubsystemDiscovery" createDeletePolicy="create-only" creationDataType="content">
<plugin-configuration>
- <c:simple-property name="path" default="/deployment/*" readOnly="true"/>
+ <c:simple-property name="path" default="deployment" readOnly="true"/>
</plugin-configuration>
<content name="deployment" category="deployable" isCreationType="true" description="Deployments on this domain">
@@ -172,7 +178,7 @@
class="DomainComponent"
>
<plugin-configuration>
- <c:simple-property name="path" default="/host/*" readOnly="true"/>
+ <c:simple-property name="path" default="host" readOnly="true"/>
</plugin-configuration>
<operation name="server:add" displayName="Create server" description="Add a new server to this host.">
@@ -307,7 +313,7 @@
</runs-inside>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
+ <c:simple-property name="path" readOnly="true" default="subsystem=messaging"/>
</plugin-configuration>
<operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic">
@@ -363,7 +369,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="queue/*"/>
+ <c:simple-property name="path" readOnly="true" default="queue"/>
</plugin-configuration>
<resource-configuration>
<c:simple-property name="queue-address" required="true"/>
@@ -386,7 +392,7 @@
</runs-inside>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/jms"/>
+ <c:simple-property name="path" readOnly="true" default="subsystem=jms"/>
</plugin-configuration>
<service name="Queue"
@@ -394,7 +400,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="queue/*"/>
+ <c:simple-property name="path" readOnly="true" default="queue"/>
</plugin-configuration>
</service>
<service name="Topic"
@@ -402,7 +408,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="topic/*"/>
+ <c:simple-property name="path" readOnly="true" default="topic"/>
</plugin-configuration>
</service>
<service name="Connection-Factory"
@@ -410,7 +416,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="connection-factory/*"/>
+ <c:simple-property name="path" readOnly="true" default="connection-factory"/>
</plugin-configuration>
</service>
@@ -428,7 +434,7 @@
</runs-inside>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/web"/>
+ <c:simple-property name="path" readOnly="true" default="subsystem=web"/>
</plugin-configuration>
<service name="Connector"
@@ -436,7 +442,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/connector/*"/>
+ <c:simple-property name="path" readOnly="true" default="connector"/>
</plugin-configuration>
@@ -459,7 +465,7 @@
discovery="SubsystemDiscovery"
class="BaseComponent">
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/virtual-server/*"/>
+ <c:simple-property name="path" readOnly="true" default="virtual-server"/>
</plugin-configuration>
<resource-configuration>
@@ -487,7 +493,7 @@
</runs-inside>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/datasources"/>
+ <c:simple-property name="path" readOnly="true" default="subsystem=datasources"/>
</plugin-configuration>
<service name="DataSource"
@@ -497,7 +503,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="data-source/*"/>
+ <c:simple-property name="path" readOnly="true" default="data-source"/>
</plugin-configuration>
<resource-configuration>
@@ -523,7 +529,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="xa-data-source/*"/>
+ <c:simple-property name="path" readOnly="true" default="xa-data-source"/>
</plugin-configuration>
</service>
@@ -534,7 +540,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="jdbc-driver/*"/>
+ <c:simple-property name="path" readOnly="true" default="jdbc-driver"/>
</plugin-configuration>
</service>
@@ -552,7 +558,7 @@
</runs-inside>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/"/>
+ <c:simple-property name="path" readOnly="true" default="interface"/>
</plugin-configuration>
</service>
@@ -567,7 +573,7 @@
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/socket-binding-group/"/>
+ <c:simple-property name="path" readOnly="true" default="socket-binding-group"/>
</plugin-configuration>
<resource-configuration>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 9110fbd..64d9d30 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -26,9 +26,11 @@ import java.util.Map;
import org.codehaus.jackson.map.ObjectMapper;
import org.testng.annotations.Test;
+import org.rhq.modules.plugins.jbossas7.json.ComplexResult;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.Result;
/**
* @author Heiko W. Rupp
@@ -116,4 +118,48 @@ public class OperationJsonTest {
System.out.println(result);
}
+
+ public void simpleResult() throws Exception {
+
+ String resultString = "{\"outcome\" : \"success\", \"result\" : \"no metrics available\", \"compensating-operation\" : null}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("success");
+ assert result.isSuccess();
+ }
+
+ public void simpleResult2() throws Exception {
+
+ String resultString = "{\"outcome\" : \"success\", \"result\" : \"DISABLED\", \"compensating-operation\" : null}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ Result result = mapper.readValue(resultString,Result.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("success");
+ assert result.isSuccess();
+ }
+
+ public void complexResult1() throws Exception {
+
+ String resultString = " {\"outcome\" : \"success\", \"result\" : {\"alias\" : [\"example.com\"], \"access-log\" : null, \"rewrite\" : null}, \"compensating-operation\" : null}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ ComplexResult result = mapper.readValue(resultString,ComplexResult.class);
+
+ assert result != null;
+ assert result.getOutcome().equals("success");
+ assert result.isSuccess();
+ assert result.getResult().size()==3;
+ String rewrite = (String) result.getResult().get("rewrite");
+ assert rewrite == null;
+
+ List<String> aliases = (List<String>) result.getResult().get("alias");
+ assert aliases != null;
+ assert aliases.size()==1;
+ assert aliases.get(0).equals("example.com");
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
new file mode 100644
index 0000000..a59b05e
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/PathHandlingTest.java
@@ -0,0 +1,95 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Test handling of path elements.
+ * A path to a resource consists of pairs type=value that are
+ * separated by commas
+ * @author Heiko W. Rupp
+ */
+@Test
+public class PathHandlingTest {
+
+ public void buildPath1() throws Exception {
+
+ String path = "/subsystem=jms,profile=default,queue=foo";
+
+ BaseComponent bc = new BaseComponent();
+ List<PROPERTY_VALUE> list = bc.pathToAddress(path);
+
+ int found = 0;
+ for (PROPERTY_VALUE p : list) {
+ if (p.getKey().equals("subsystem")) {
+ assert p.getValue().equals("jms");
+ found++;
+ }
+ if (p.getKey().equals("queue")) {
+ found++;
+ assert p.getValue().equals("foo");
+ }
+ }
+ assert found == 2 : "did not find both keys, but " + found;
+ }
+
+ public void buildPath2() throws Exception {
+
+ String path = "/subsystem=jms,profile=default,queue=java:/foo";
+
+ BaseComponent bc = new BaseComponent();
+ List<PROPERTY_VALUE> list = bc.pathToAddress(path);
+
+ assert list.size()==3 : "We don't have 3 components, but " + list.size();
+ for (PROPERTY_VALUE p : list) {
+ if (p.getKey().equals("subsystem"))
+ assert p.getValue().equals("jms");
+ if (p.getKey().equals("queue"))
+ assert p.getValue().equals("java:/foo") : "Queue value is wrong: " + p.getValue();
+
+ }
+ }
+
+ public void buildIncomplete() throws Exception {
+
+ String path = "/subsystem=jms,profile=default,queue=java:/foo,topic";
+
+ BaseComponent bc = new BaseComponent();
+ List<PROPERTY_VALUE> list = bc.pathToAddress(path);
+
+ assert list.size()==3 : "We don't have 3 components, but " + list.size();
+ int found = 0;
+ for (PROPERTY_VALUE p : list) {
+ if (p.getKey().equals("subsystem")) {
+ assert p.getValue().equals("jms");
+ found++;
+ }
+ if (p.getKey().equals("queue")) {
+ assert p.getValue().equals("java:/foo") : "Queue value is wrong: " + p.getValue();
+ found++;
+ }
+ }
+ assert found == 2 : "did not find both keys, but " + found;
+ }
+}
commit 5522a71fd7559bf707094665c020095c3fc6add7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 11 15:01:01 2011 +0200
Better resource detection and keying, Creation of deployments.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 491fb77..9037537 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -137,7 +137,7 @@ public class ASConnection {
}
- boolean isErrorReply(JsonNode in) {
+ static boolean isErrorReply(JsonNode in) {
if (in == null)
return true;
@@ -154,7 +154,7 @@ public class ASConnection {
reasonNode = in.findValue("host-failure-descriptions"); // TODO JBAS-9182
String reason = reasonNode.getTextValue();
- log.info(reason);
+// log.info(reason);
return true;
}
@@ -262,7 +262,7 @@ public class ASConnection {
return url2;
}
- public String getFailureDescription(JsonNode jsonNode) {
+ public static String getFailureDescription(JsonNode jsonNode) {
if (jsonNode==null)
return "getFailureDescription: -input was null-";
JsonNode node = jsonNode.findValue("failure-description");
@@ -273,7 +273,7 @@ public class ASConnection {
return node.getValueAsText();
}
- public String getSuccessDescription(JsonNode jsonNode) {
+ public static String getSuccessDescription(JsonNode jsonNode) {
if (jsonNode==null)
return "No message found";
JsonNode node = jsonNode.findValue("result");
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 644fc24..28b94f9 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
@@ -62,7 +62,7 @@ import com.sun.org.apache.xml.internal.security.utils.Base64;
public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet
{
- private final Log log = LogFactory.getLog(this.getClass());
+ final Log log = LogFactory.getLog(this.getClass());
ResourceContext context;
Configuration conf;
@@ -321,9 +321,9 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
NameValuePair nvp = new NameValuePair(entry.getKey(),entry.getValue().getStringValue());
Operation writeAttribute = new Operation("write-attribute",pathToAddress(getResultingPath()),nvp);
JsonNode result= connection.execute(writeAttribute);
- if(connection.isErrorReply(result)) {
+ if(ASConnection.isErrorReply(result)) {
report.setStatus(ConfigurationUpdateStatus.FAILURE);
- report.setErrorMessage(connection.getFailureDescription(result));
+ report.setErrorMessage(ASConnection.getFailureDescription(result));
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index 21005a9..176e6ce 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -49,11 +49,17 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
address.add(new PROPERTY_VALUE("host",host));
address.add(new PROPERTY_VALUE("server-config",myServerName));
Operation getStatus = new Operation("read-attribute",address,"name","status");
- JsonNode result = connection.execute(getStatus);
- if (connection.isErrorReply(result))
+ JsonNode result = null;
+ try {
+ result = connection.execute(getStatus);
+ } catch (Exception e) {
+ log.warn(e.getMessage());
+ return AvailabilityType.DOWN;
+ }
+ if (ASConnection.isErrorReply(result))
return AvailabilityType.DOWN;
- String msg = connection.getSuccessDescription(result);
+ String msg = ASConnection.getSuccessDescription(result);
if (msg.contains("STARTED"))
return AvailabilityType.UP;
else
@@ -126,11 +132,11 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
if (operation!=null) {
JsonNode result = connection.execute(operation);
- if (connection.isErrorReply(result)) {
- operationResult.setErrorMessage(connection.getFailureDescription(result));
+ if (ASConnection.isErrorReply(result)) {
+ operationResult.setErrorMessage(ASConnection.getFailureDescription(result));
}
else {
- operationResult.setSimpleResult(connection.getSuccessDescription(result));
+ operationResult.setSimpleResult(ASConnection.getSuccessDescription(result));
}
}
else {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
index ad09c77..7608b9c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
@@ -69,7 +69,7 @@ public class DomainDiscovery implements ResourceDiscoveryComponent<BaseComponent
// A domain has a server group so check for it.
boolean found = false;
JsonNode json = connection.getLevelData(null,null);
- if (!connection.isErrorReply(json)) {
+ if (!ASConnection.isErrorReply(json)) {
Iterator<String> fields = json.getFieldNames();
while (fields.hasNext()) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
index 021b10c..1fc1e9b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
@@ -64,7 +64,7 @@ public class InterfaceDiscovery implements ResourceDiscoveryComponent<BaseCompon
JsonNode json = connection.getLevelData(null, null);
- if (!connection.isErrorReply(json)) {
+ if (!ASConnection.isErrorReply(json)) {
Domain domain = mapper.readValue(json, new TypeReference<Domain>() {});
for (Map.Entry<String,String> entry: domain.interfaces.entrySet()) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index 0e26e7d..ff7048b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -55,6 +55,8 @@ import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
*/
public class ServerGroupComponent extends DomainComponent implements ContentFacet, CreateChildResourceFacet {
+ private static final String SUCCESS = "success";
+ private static final String OUTCOME = "outcome";
private final Log log = LogFactory.getLog(ServerGroupComponent.class);
@Override
@@ -77,9 +79,9 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
OutputStream out = uploadConnection.getOutputStream(fileName);
contentServices.downloadPackageBits(cctx, details.getKey(), out, false);
JsonNode uploadResult = uploadConnection.finishUpload();
- if (uploadResult.has("outcome")) {
- String outcome = uploadResult.get("outcome").getTextValue();
- if (outcome.equals("success")) { // Upload was successful, so now add the file to the server group
+ if (uploadResult.has(OUTCOME)) {
+ String outcome = uploadResult.get(OUTCOME).getTextValue();
+ if (outcome.equals(SUCCESS)) { // Upload was successful, so now add the file to the server group
JsonNode resultNode = uploadResult.get("result");
String hash = resultNode.get("BYTES_VALUE").getTextValue();
ASConnection connection = getASConnection();
@@ -100,7 +102,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
cop.addStep(step2);
JsonNode result = connection.execute(cop);
- if (connection.isErrorReply(result)) // TODO get failure message into response
+ if (ASConnection.isErrorReply(result)) // TODO get failure message into response
response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.FAILURE));
else
response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.SUCCESS));
@@ -131,7 +133,7 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
Operation op = new ReadChildrenNames(serverGroupAddress,"deployment"); // TODO read full packages not onyl names
JsonNode node = connection.execute(op);
- if (connection.isErrorReply(node))
+ if (ASConnection.isErrorReply(node))
return null;
JsonNode result = node.get("result");
@@ -168,16 +170,49 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
ContentServices contentServices = cctx.getContentServices();
String resourceTypeName = report.getResourceType().getName();
- ASUploadConnection connection = new ASUploadConnection();
- OutputStream out = connection.getOutputStream(details.getFileName());
+ ASUploadConnection uploadConnection = new ASUploadConnection();
+ OutputStream out = uploadConnection.getOutputStream(details.getFileName());
// contentServices.downloadPackageBits(cctx,details.getKey(),out,false);
contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
- JsonNode result = connection.finishUpload();
- System.out.println(result);
+ JsonNode uploadResult = uploadConnection.finishUpload();
+ System.out.println(uploadResult);
+ if (ASConnection.isErrorReply(uploadResult)) {
+ report.setStatus(CreateResourceStatus.FAILURE);
+ report.setErrorMessage(ASConnection.getFailureDescription(uploadResult));
+ return report;
+ }
+
+ String fileName = report.getUserSpecifiedResourceName();
+
+ JsonNode resultNode = uploadResult.get("result");
+ String hash = resultNode.get("BYTES_VALUE").getTextValue();
+ ASConnection connection = getASConnection();
+
+ List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
+ deploymentsAddress.add(new PROPERTY_VALUE("deployment", fileName));
+ Operation step1 = new Operation("add",deploymentsAddress);
+ step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
+ step1.addAdditionalProperty("name", fileName);
+
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ serverGroupAddress.add(new PROPERTY_VALUE("server-group",serverGroupFromKey()));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", fileName));
+ Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
+
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
+ cop.addStep(step2);
- report.setStatus(CreateResourceStatus.SUCCESS) ;
+ JsonNode result = connection.execute(cop);
+ if (ASConnection.isErrorReply(result)) {
+ report.setErrorMessage(ASConnection.getFailureDescription(resultNode));
+ report.setStatus(CreateResourceStatus.FAILURE);
+ }
+ else {
+ report.setStatus(CreateResourceStatus.SUCCESS);
+ }
return report;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
index 4411f8c..89472b8 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
@@ -64,7 +64,7 @@ public class SocketBindingGroupDiscovery implements ResourceDiscoveryComponent<B
JsonNode json = connection.getLevelData(null, null);
- if (!connection.isErrorReply(json)) {
+ if (!ASConnection.isErrorReply(json)) {
Domain domain = mapper.readValue(json, new TypeReference<Domain>() {});
for (Map.Entry<String,String> entry: domain.socketBindingGroup.entrySet()) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index e351237..b6619b8 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -98,7 +98,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
childType = childType.substring(1);
json = connection.execute(new ReadChildrenNames(addr, childType));
}
- if (!connection.isErrorReply(json)) {
+ if (!ASConnection.isErrorReply(json)) {
if (recursive) {
int i = path.lastIndexOf("/");
String subPath = path.substring(i+1);
@@ -130,13 +130,12 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
-
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
context.getResourceType(), // DataType
resKey, // Key
name, // Name
null, // Version
- "TODO", // subsystem.description, // Description
+ "TODO", // subsystem.description, // TODO Description
config2,
null);
details.add(detail);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
index 8c5b37c..23d10bb 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
@@ -27,7 +27,7 @@ import java.util.List;
public class ReadChildrenNames extends Operation {
/**
- * Reas children names of a given type below a given address
+ * Read children names of a given type below a given address
* @param address Address to look at e.g. /profile/default/subsystem/messaging
* @param childType e.g. queue
*/
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java
new file mode 100644
index 0000000..c2eab45
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadResource.java
@@ -0,0 +1,32 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.List;
+
+/**
+ * Reads data for one AS 7 resource
+ * @author Heiko W. Rupp
+ */
+public class ReadResource extends Operation {
+
+ public ReadResource(List<PROPERTY_VALUE> address) {
+ super("read-resource", address);
+ }
+}
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 e3bd676..435f58f 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
@@ -150,10 +150,20 @@
<c:simple-property name="jvm"/>
<c:simple-property name="deployment" required="false"/> <!-- TODO change structure. Or put below as resource? -->
</resource-configuration>
- <service name="Deployment" class="BaseComponent" discovery="SubsystemDiscovery" createDeletePolicy="create-only">
+
+ <service name="Deployment" class="BaseComponent" discovery="SubsystemDiscovery" createDeletePolicy="create-only" creationDataType="content">
<plugin-configuration>
<c:simple-property name="path" default="/deployment/*" readOnly="true"/>
</plugin-configuration>
+
+ <content name="deployment" category="deployable" isCreationType="true" description="Deployments on this domain">
+ <configuration>
+ <c:group name="deployment" displayName="Deployment Options">
+ <c:simple-property name="runtimeName" required="true"/>
+ </c:group>
+ </configuration>
+ </content>
+
</service>
</server>
<server name="Host"
@@ -489,6 +499,21 @@
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="data-source/*"/>
</plugin-configuration>
+
+ <resource-configuration>
+ <c:map-property name="configuration">
+ <c:simple-property name="connection-url"/>
+ <c:simple-property name="driver-class"/>
+ <c:simple-property name="jndi-name"/>
+ <c:simple-property name="driver"/>
+ <c:simple-property name="pool-name"/>
+ <c:simple-property name="use-java-context" type="boolean"/>
+ <c:simple-property name="enabled" type="boolean"/>
+ <c:simple-property name="user-name"/>
+ <c:simple-property name="password"/>
+ <!-- TODO more when they become available in the AS -->
+ </c:map-property>
+ </resource-configuration>
</service>
<service name="XADataSource"
commit 13237c98e08a967eb8ffe7c397f9bf8e6cf0110f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 11 11:39:40 2011 +0200
Small reformat + cleanup
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 0182077..e351237 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -107,51 +107,48 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
if (subNode==null || subNode.isNull())
subNode = json.get(subPath); // TODO clean this up. to get the 'key' in a path from the AS we need to use get()
-// Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
if (subNode!=null && subNode.isContainerNode()){
- Iterator<JsonNode> iter = subNode.getElements();
-// if (subsystemMap==null) {
-// log.warn("SubsystemMap was null for path [" + path + "] and subPath ["+ subPath + "] and subNode [" + subNode + "]");
-// return Collections.emptySet();
-// }
+ Iterator<JsonNode> iter = subNode.getElements();
while (iter.hasNext()) {
JsonNode node = iter.next();
- String val = node.getTextValue();
+ String val = node.getTextValue();
- String newPath = cpath.replaceAll("\\*",val);
- Configuration config2 = context.getDefaultPluginConfiguration();
- PropertySimple pathProp = new PropertySimple("path",newPath);
- config2.put(pathProp);
+ String newPath = cpath.replaceAll("\\*",val);
+ Configuration config2 = context.getDefaultPluginConfiguration();
+ PropertySimple pathProp = new PropertySimple("path",newPath);
+ config2.put(pathProp);
- String resKey;
- String childType = cpath.substring(0, cpath.length() - 2);
- if (childType.startsWith("/"))
- childType = childType.substring(1);
+ String resKey;
+ String childType = cpath.substring(0, cpath.length() - 2);
+ if (childType.startsWith("/"))
+ childType = childType.substring(1);
- resKey = context.getParentResourceContext().getResourceKey() + "/" +childType + "/" + val;
- String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+ resKey = context.getParentResourceContext().getResourceKey() + "/" +childType + "/" + val;
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- resKey, // Key
- name, // Name
- null, // Version
- "TODO", // subsystem.description, // Description
- config2,
- null);
- details.add(detail);
- }
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ resKey, // Key
+ name, // Name
+ null, // Version
+ "TODO", // subsystem.description, // Description
+ config2,
+ null);
+ details.add(detail);
+ }
}
else {
- System.out.println("subnode was no array");
- if (subNode==null)
+ if (subNode==null) {
log.error("subNode was null for " + path + " and type " + context.getResourceType().getName());
+ }
+ else if (!subNode.isNull())
+ log.info("subnode was no container");
}
}
commit 9129e2b888dd8131ee9e816bb45afb484c8a52ef
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Apr 11 11:26:57 2011 +0200
Create correct resource key looking at types.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 747aff0..0182077 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -76,11 +76,14 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
path = cpath;
if (parentPath!=null && !parentPath.isEmpty()) {
- if (parentPath.endsWith("/") || path.startsWith("/"))
+ if (recursive)
+ path = parentPath;
+ else if (parentPath.endsWith("/") || path.startsWith("/"))
path = parentPath + path;
else
path = parentPath + "/" + path;
}
+
System.out.println("total path: [" + path + "]");
@@ -105,7 +108,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
subNode = json.get(subPath); // TODO clean this up. to get the 'key' in a path from the AS we need to use get()
// Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
- if (subNode!=null && subNode.isArray()) {
+ if (subNode!=null && subNode.isContainerNode()){
Iterator<JsonNode> iter = subNode.getElements();
// if (subsystemMap==null) {
@@ -123,13 +126,19 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
PropertySimple pathProp = new PropertySimple("path",newPath);
config2.put(pathProp);
- String resKey = context.getParentResourceContext().getResourceKey() + "/" + val;
+ String resKey;
+ String childType = cpath.substring(0, cpath.length() - 2);
+ if (childType.startsWith("/"))
+ childType = childType.substring(1);
+
+ resKey = context.getParentResourceContext().getResourceKey() + "/" +childType + "/" + val;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
context.getResourceType(), // DataType
- path + "/" + val, // Key
+ resKey, // Key
name, // Name
null, // Version
"TODO", // subsystem.description, // Description
commit 1e328a1a6e156566cc5d28be7449915c6fdd5df1
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Apr 8 19:12:53 2011 +0200
Re-activate the undeployment
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
index e477886..11e25ad 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -80,8 +80,7 @@ public class UploadAndDeployTest {
assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();
- // Now teat down stuff again
-/*
+ // Now tear down stuff again
Operation undeploy = new Operation("remove",serverGroupAddress);
ret = connection.execute(undeploy);
@@ -100,10 +99,8 @@ public class UploadAndDeployTest {
System.out.flush();
-*/
}
- @Test(enabled = false)
public void testUploadComposite() throws Exception {
String bytes_value = prepare();
commit afa28b8660dbcd8c0041475a3d41e765f038dd08
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Apr 8 19:06:10 2011 +0200
Upload and deployment of files into server groups.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 0c6d516..491fb77 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -185,6 +185,7 @@ public class ASConnection {
String result = mapper.writeValueAsString(operation);
System.out.println("Json to send: " + result);
+ System.out.flush();
mapper.writeValue(out, operation);
out.flush();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
index f3e9ee0..63b7881 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -20,9 +20,11 @@ package org.rhq.modules.plugins.jbossas7;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
@@ -32,6 +34,7 @@ import com.sun.org.apache.xerces.internal.impl.xpath.regex.REUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
/**
* Connection for uploading of content.
@@ -53,7 +56,7 @@ public class ASUploadConnection {
private final Log log = LogFactory.getLog(ASUploadConnection.class);
BufferedOutputStream os = null;
- BufferedInputStream is = null;
+ InputStream is = null;
private HttpURLConnection connection;
public OutputStream getOutputStream(String fileName) {
@@ -78,12 +81,35 @@ public class ASUploadConnection {
}
public JsonNode finishUpload() {
+ JsonNode tree = null;
try {
os.write(buildPostRequestFooter());
os.flush();
- is = new BufferedInputStream(connection.getInputStream());
- // TODO read from IN
+ int code = connection.getResponseCode();
+ if (code==500)
+ is = connection.getErrorStream();
+ else
+ is = connection.getInputStream();
+
+ if (is != null) {
+ BufferedReader in = new BufferedReader(new InputStreamReader(is));
+ String line;
+ StringBuilder builder = new StringBuilder();
+ while ((line = in.readLine()) != null) {
+ builder.append(line);
+ }
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ String s = builder.toString();
+ if (s!=null)
+ tree = mapper.readTree(s);
+ else
+ System.out.println("- no result received from InputStream -");
+ }
+ else
+ System.out.println("- no InputStream available -");
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
@@ -93,7 +119,7 @@ public class ASUploadConnection {
closeQuietly(os);
}
- return null;
+ return tree;
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
index 9650731..0e26e7d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -20,6 +20,9 @@ package org.rhq.modules.plugins.jbossas7;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -27,7 +30,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
+import org.rhq.core.domain.content.PackageDetailsKey;
import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.ContentResponseResult;
+import org.rhq.core.domain.content.transfer.DeployIndividualPackageResponse;
import org.rhq.core.domain.content.transfer.DeployPackageStep;
import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
@@ -38,6 +44,10 @@ import org.rhq.core.pluginapi.content.ContentFacet;
import org.rhq.core.pluginapi.content.ContentServices;
import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
/**
* Component dealing with server group specific things
@@ -58,17 +68,54 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
ContentContext cctx = context.getContentContext();
- String uploadUrl = "http://localhost:9990/domain-api/add-content";
+ DeployPackagesResponse response = new DeployPackagesResponse();
for (ResourcePackageDetails details : packages) {
+
ASUploadConnection uploadConnection = new ASUploadConnection();
- OutputStream out = uploadConnection.getOutputStream(details.getFileName());
+ String fileName = details.getFileName();
+ OutputStream out = uploadConnection.getOutputStream(fileName);
contentServices.downloadPackageBits(cctx, details.getKey(), out, false);
- JsonNode result = uploadConnection.finishUpload();
+ JsonNode uploadResult = uploadConnection.finishUpload();
+ if (uploadResult.has("outcome")) {
+ String outcome = uploadResult.get("outcome").getTextValue();
+ if (outcome.equals("success")) { // Upload was successful, so now add the file to the server group
+ JsonNode resultNode = uploadResult.get("result");
+ String hash = resultNode.get("BYTES_VALUE").getTextValue();
+ ASConnection connection = getASConnection();
+
+ List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
+ deploymentsAddress.add(new PROPERTY_VALUE("deployment", fileName));
+ Operation step1 = new Operation("add",deploymentsAddress);
+ step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", hash));
+ step1.addAdditionalProperty("name", fileName);
+
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ serverGroupAddress.add(new PROPERTY_VALUE("server-group",serverGroupFromKey()));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", fileName));
+ Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
+
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
+ cop.addStep(step2);
+
+ JsonNode result = connection.execute(cop);
+ if (connection.isErrorReply(result)) // TODO get failure message into response
+ response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.FAILURE));
+ else
+ response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.SUCCESS));
+ }
+ else
+ response.addPackageResponse(new DeployIndividualPackageResponse(details.getKey(),ContentResponseResult.FAILURE));
+ }
+ else {
+ response.addPackageResponse(
+ new DeployIndividualPackageResponse(details.getKey(), ContentResponseResult.FAILURE));
+ }
}
- return null; // TODO: Customise this generated block
+ return response;
}
@Override
@@ -78,7 +125,32 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
@Override
public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
- return null; // TODO: Customise this generated block
+
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ serverGroupAddress.add(new PROPERTY_VALUE("server-group",serverGroupFromKey()));
+
+ Operation op = new ReadChildrenNames(serverGroupAddress,"deployment"); // TODO read full packages not onyl names
+ JsonNode node = connection.execute(op);
+ if (connection.isErrorReply(node))
+ return null;
+
+ JsonNode result = node.get("result");
+ Iterator<JsonNode> iter = result.getElements();
+ Set<ResourcePackageDetails> details = new HashSet<ResourcePackageDetails>();
+ while (iter.hasNext()) {
+ JsonNode jNode = iter.next();
+ String file = jNode.getTextValue();
+ String t;
+ if (file.contains("."))
+ t = file.substring(file.lastIndexOf(".")+1);
+ else
+ t = "-none-";
+
+ ResourcePackageDetails detail = new ResourcePackageDetails(new PackageDetailsKey(file,"1.0",t,"all"));
+ details.add(detail);
+ }
+ return details;
+
}
@Override
@@ -110,4 +182,10 @@ public class ServerGroupComponent extends DomainComponent implements ContentFace
return report;
}
+
+
+ private String serverGroupFromKey() {
+ String key1 = context.getResourceKey();
+ return key1.substring(key1.lastIndexOf("/")+1);
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 9aea097..747aff0 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -68,7 +68,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String parentPath = parentComponent.getPath();
String path;
- if (cpath.endsWith("/*")) {
+ if (cpath!=null && cpath.endsWith("/*")) {
path = cpath.substring(0,cpath.length()-2);
recursive = true;
}
@@ -105,7 +105,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
subNode = json.get(subPath); // TODO clean this up. to get the 'key' in a path from the AS we need to use get()
// Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
- if (subNode.isArray()) {
+ if (subNode!=null && subNode.isArray()) {
Iterator<JsonNode> iter = subNode.getElements();
// if (subsystemMap==null) {
@@ -139,7 +139,10 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
}
}
else {
+
System.out.println("subnode was no array");
+ if (subNode==null)
+ log.error("subNode was null for " + path + " and type " + context.getResourceType().getName());
}
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index e538c94..a7abfe6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -67,7 +67,6 @@ public class Operation {
public Operation(String operation, List<PROPERTY_VALUE> address) {
this.operation = operation;
this.address = address;
- additionalProperties = Collections.emptyMap();
}
@@ -76,7 +75,7 @@ public class Operation {
}
@JsonAnySetter
- public void addAdditionalProperty(String key, String value) {
+ public void addAdditionalProperty(String key, Object value) {
if (additionalProperties == null)
additionalProperties = new HashMap<String, Object>();
additionalProperties.put(key,value);
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 258da2c..e3bd676 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
@@ -150,7 +150,11 @@
<c:simple-property name="jvm"/>
<c:simple-property name="deployment" required="false"/> <!-- TODO change structure. Or put below as resource? -->
</resource-configuration>
- <service name="Deployment" class="BaseComponent" discovery="SubsystemDiscovery" createDeletePolicy="create-only"/>
+ <service name="Deployment" class="BaseComponent" discovery="SubsystemDiscovery" createDeletePolicy="create-only">
+ <plugin-configuration>
+ <c:simple-property name="path" default="/deployment/*" readOnly="true"/>
+ </plugin-configuration>
+ </service>
</server>
<server name="Host"
description="Host involved in this domain"
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 5ba843f..9110fbd 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -84,6 +84,7 @@ public class OperationJsonTest {
props.put("someBool",true);
Operation operation = new Operation("add",address,props);
+ operation.addAdditionalProperty("foo","bar");
ObjectMapper mapper = new ObjectMapper();
@@ -97,8 +98,22 @@ public class OperationJsonTest {
assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation();
assert op.getAdditionalProperties().containsKey("someBool") : "Key someBool not found ";
Object someBool = op.getAdditionalProperties().get("someBool");
- assert Boolean.valueOf((String) someBool) : "someBool was not true";
+ assert Boolean.valueOf((Boolean) someBool) : "someBool was not true";
+ }
+
+ public void addPropsTest() throws Exception {
+ List<PROPERTY_VALUE> address=new ArrayList<PROPERTY_VALUE>(2);
+ PROPERTY_VALUE part = new PROPERTY_VALUE("/server-group","newOne");
+ address.add(part);
+
+ Operation operation = new Operation("add",address);
+ operation.addAdditionalProperty("foo","bar");
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ String result = mapper.writeValueAsString(operation);
+ System.out.println(result);
}
}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
new file mode 100644
index 0000000..e477886
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/UploadAndDeployTest.java
@@ -0,0 +1,172 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.codehaus.jackson.JsonNode;
+import org.testng.annotations.Test;
+
+import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Test uploading and deploying to the domain
+ * To use it, domain server must be up and running locally and
+ * the UPLOAD_FILE must point to a valid archive in the resources directory.
+ * @author Heiko W. Rupp
+ */
+@Test
+public class UploadAndDeployTest {
+
+ static final String TEST_WAR = "test.war";
+ private static final String UPLOAD_FILE = "test-simple.war";
+
+ public void testUploadIndividualSteps() throws Exception {
+
+ String bytes_value = prepare();
+
+ System.out.println("sha: " + bytes_value);
+
+ System.out.println();
+ ASConnection connection = new ASConnection("localhost",9990);
+
+ List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
+ deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Operation op = new Operation("add",deploymentsAddress);
+ op.addAdditionalProperty("hash",new PROPERTY_VALUE("BYTES_VALUE",bytes_value));
+ op.addAdditionalProperty("name", TEST_WAR); // this needs to be separate per upload
+ op.addAdditionalProperty("runtime-name", TEST_WAR);
+ System.out.flush();
+ JsonNode ret = connection.execute(op);
+ System.out.println("Add to /deploy done " + ret);
+ System.out.flush();
+
+ assert ret.toString().contains("success") : ret;
+
+
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ serverGroupAddress.add(new PROPERTY_VALUE("server-group","main-server-group"));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ op.addAdditionalProperty("runtime-name", TEST_WAR);
+ Operation deploy = new Operation("add",serverGroupAddress,"enabled","true");
+ System.out.flush();
+ ret = connection.execute(deploy);
+ System.out.println("Add to server group done: " + ret);
+ System.out.flush();
+
+ assert ret.has("outcome") : "Ret not valied " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();
+
+
+ // Now teat down stuff again
+/*
+
+ Operation undeploy = new Operation("remove",serverGroupAddress);
+ ret = connection.execute(undeploy);
+
+ assert ret.has("outcome") : "Ret not valied " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success " + ret.getTextValue();
+
+
+ // remove from domain
+
+ Operation remove = new Operation("remove",deploymentsAddress);
+ ret = connection.execute(remove);
+
+ assert ret.has("outcome") : "Ret not valied " + ret.toString();
+ assert ret.get("outcome").getTextValue().equals("success") : "remove from domain was no success " + ret.getTextValue();
+
+ System.out.flush();
+
+*/
+ }
+
+ @Test(enabled = false)
+ public void testUploadComposite() throws Exception {
+
+ String bytes_value = prepare();
+
+
+ List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
+ deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Operation step1 = new Operation("add",deploymentsAddress);
+ step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", bytes_value));
+ step1.addAdditionalProperty("name", TEST_WAR);
+
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ serverGroupAddress.add(new PROPERTY_VALUE("server-group","main-server-group"));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
+
+
+ Operation step3 = new Operation("remove",serverGroupAddress);
+
+ Operation step4 = new Operation("remove",deploymentsAddress);
+
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
+ cop.addStep(step2);
+
+
+ ASConnection connection = new ASConnection("localhost",9990);
+ JsonNode ret = connection.execute(cop);
+ System.out.println(ret);
+ System.out.flush();
+
+ Thread.sleep(1000);
+
+ cop = new CompositeOperation();
+ cop.addStep(step3);
+ cop.addStep(step4);
+ ret = connection.execute(cop);
+
+ System.out.println(ret);
+ System.out.flush();
+
+
+ }
+
+ private String prepare() throws IOException {
+ ASUploadConnection conn = new ASUploadConnection();
+ OutputStream os = conn.getOutputStream("test1.war");
+
+
+
+ InputStream fis = getClass().getClassLoader().getResourceAsStream(UPLOAD_FILE);
+ int b;
+ while ((b = fis.read())!=-1) {
+ os.write(b);
+ }
+ fis.close();
+ JsonNode node = conn.finishUpload();
+ System.out.println(node);
+ assert node.has("outcome") : "No outcome from upload";
+ String outcome = node.get("outcome").getTextValue();
+ assert outcome.equals("success") : "Upload was no success" + outcome;
+
+ JsonNode resultNode = node.get("result");
+ return resultNode.get("BYTES_VALUE").getTextValue();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/test/resources/test-simple.war b/modules/plugins/jboss-as-7/src/test/resources/test-simple.war
new file mode 100644
index 0000000..bd427b1
Binary files /dev/null and b/modules/plugins/jboss-as-7/src/test/resources/test-simple.war differ
commit 6e262803ae8e328cc397a75d00404ea844f5fb54
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Apr 8 16:34:39 2011 +0200
Add composite operations
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/CompositeOperation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/CompositeOperation.java
new file mode 100644
index 0000000..98cc214
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/CompositeOperation.java
@@ -0,0 +1,64 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * A composite operation contains multiple steps of a
+ * task that requires many individual operations to complete
+ * @author Heiko W. Rupp
+ */
+public class CompositeOperation extends Operation {
+
+
+
+ @JsonProperty
+ List<Operation> steps = new ArrayList<Operation>();
+
+ OperationHeaders operationHeaders;
+
+ public CompositeOperation(List<Operation> steps) {
+ super("composite",new ArrayList<PROPERTY_VALUE>());
+ this.steps = steps;
+ }
+
+ public CompositeOperation() {
+ super("composite",new ArrayList<PROPERTY_VALUE>());
+ }
+
+ public void addStep(Operation step) {
+ steps.add(step);
+ }
+
+ public void setOperationHeaders(OperationHeaders headers) {
+ operationHeaders = headers;
+ }
+
+ private class OperationHeaders {
+ @JsonProperty("in-series")
+ List<PROPERTY_VALUE>inSeries = Collections.emptyList();
+ @JsonProperty("rollback-across-groups")
+ boolean rollbackAcrossGroups;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/CompositeOperationTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/CompositeOperationTest.java
new file mode 100644
index 0000000..dddbe51
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/CompositeOperationTest.java
@@ -0,0 +1,108 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.testng.annotations.Test;
+
+import org.rhq.modules.plugins.jbossas7.json.CompositeOperation;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Test composite operations
+ * @author Heiko W. Rupp
+ */
+@Test
+public class CompositeOperationTest {
+
+ public void serializationTest() throws Exception {
+
+ List<PROPERTY_VALUE> address=new ArrayList<PROPERTY_VALUE>(3);
+ PROPERTY_VALUE part = new PROPERTY_VALUE("subsystem","web");
+ address.add(part);
+ part = new PROPERTY_VALUE("connector","http");
+ address.add(part);
+ part = new PROPERTY_VALUE("profile","default");
+ address.add(part);
+
+ CompositeOperation op = new CompositeOperation();
+
+ Operation step1 = new Operation("add", address);
+ op.addStep(step1);
+
+ Operation step2 = new Operation("deploy", address);
+ op.addStep(step2);
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ String result = mapper.writeValueAsString(op);
+
+ System.out.println(result);
+
+ assert result.contains("http");
+
+ }
+
+ public void serializationTest2() throws Exception {
+
+
+ List<PROPERTY_VALUE> deploymentsAddress = new ArrayList<PROPERTY_VALUE>(1);
+ String TEST_WAR = "test.war";
+ deploymentsAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Operation step1 = new Operation("add",deploymentsAddress);
+ String bytes_value = "123";
+ step1.addAdditionalProperty("hash", new PROPERTY_VALUE("BYTES_VALUE", bytes_value));
+ step1.addAdditionalProperty("name", TEST_WAR);
+
+ List<PROPERTY_VALUE> serverGroupAddress = new ArrayList<PROPERTY_VALUE>(1);
+ serverGroupAddress.add(new PROPERTY_VALUE("server-group","main-server-group"));
+ serverGroupAddress.add(new PROPERTY_VALUE("deployment", TEST_WAR));
+ Operation step2 = new Operation("add",serverGroupAddress,"enabled","true");
+
+
+ Operation step3 = new Operation("remove",serverGroupAddress);
+
+ Operation step4 = new Operation("remove",deploymentsAddress);
+
+ CompositeOperation cop = new CompositeOperation();
+ cop.addStep(step1);
+ cop.addStep(step2);
+ cop.addStep(step3);
+ cop.addStep(step4);
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ String result = mapper.writeValueAsString(cop);
+ System.out.println(result);
+ System.out.flush();
+
+ JsonNode node = mapper.readTree(result);
+
+ assert node.has("operation");
+ assert !node.get("operation").isNull() : "Operations was null, but should not be " + result;
+ assert node.get("operation").getTextValue().equals("composite") : node;
+
+ }
+}
commit 1054ae44f1831fc3c7787bd118d4d5e7c1ad725b
Merge: 7bda199 7b91cb2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 6 21:52:03 2011 +0200
Merge branch 'master' into as7plugin
commit 7bda199733e460362365e15793cc607b25acff48
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 6 21:49:39 2011 +0200
Improve detection of child resources
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 5dbd0b3..644fc24 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
@@ -52,6 +52,7 @@ import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -329,6 +330,9 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
protected List<PROPERTY_VALUE> pathToAddress(String path) {
+ if (path==null || path.isEmpty())
+ return Collections.emptyList();
+
if (path.endsWith("/"))
path = path.substring(0,path.length()-1);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index a06a296..21005a9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -114,8 +114,11 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
} else if (what.equals("destination")) {
address.addAll(pathToAddress(getPath()));
String newName = parameters.getSimpleValue("name","");
- String type = parameters.getSimpleValue("type","Queue").toLowerCase();
- address.add(new PROPERTY_VALUE(type,newName));
+// String type = parameters.getSimpleValue("type","Queue").toLowerCase();
+// address.add(new PROPERTY_VALUE(type,newName));
+ String queueName = parameters.getSimpleValue("queue-address","");
+ Map<String,Object> props = new HashMap<String, Object>();
+ props.put("queue-address",queueName);
operation = new Operation(op,address);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 1c498d1..9aea097 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -23,11 +23,13 @@ import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.modules.plugins.jbossas7.json.Subsystem;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.ReadChildrenNames;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Map;
+import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
@@ -35,7 +37,6 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
/**
* Discover subsystems
@@ -83,47 +84,63 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
System.out.println("total path: [" + path + "]");
- JsonNode json = connection.getLevelData(path,recursive, false);
+ JsonNode json ;
+ if (!recursive)
+ json = connection.getLevelData(path,recursive, false);
+ else {
+ List<PROPERTY_VALUE> addr ;
+ addr = parentComponent.pathToAddress(parentPath);
+ String childType = cpath.substring(0, cpath.length() - 2);
+ if (childType.startsWith("/"))
+ childType = childType.substring(1);
+ json = connection.execute(new ReadChildrenNames(addr, childType));
+ }
if (!connection.isErrorReply(json)) {
if (recursive) {
int i = path.lastIndexOf("/");
String subPath = path.substring(i+1);
- JsonNode subNode = json.findPath(subPath);
+ JsonNode subNode = json.findPath("result");
if (subNode==null || subNode.isNull())
subNode = json.get(subPath); // TODO clean this up. to get the 'key' in a path from the AS we need to use get()
- Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
+// Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
+ if (subNode.isArray()) {
- if (subsystemMap==null) {
- log.warn("SubsystemMap was null for path [" + path + "] and subPath ["+ subPath + "] and subNode [" + subNode + "]");
- return Collections.emptySet();
- }
+ Iterator<JsonNode> iter = subNode.getElements();
+// if (subsystemMap==null) {
+// log.warn("SubsystemMap was null for path [" + path + "] and subPath ["+ subPath + "] and subNode [" + subNode + "]");
+// return Collections.emptySet();
+// }
+ while (iter.hasNext()) {
+ JsonNode node = iter.next();
+ String val = node.getTextValue();
- for (Map.Entry<String,Subsystem> entry: subsystemMap.entrySet()) {
- String key = entry.getKey();
- Subsystem subsystem = entry.getValue();
- String newPath = cpath.replaceAll("\\*",key);
+ String newPath = cpath.replaceAll("\\*",val);
Configuration config2 = context.getDefaultPluginConfiguration();
PropertySimple pathProp = new PropertySimple("path",newPath);
config2.put(pathProp);
- String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + val;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
context.getResourceType(), // DataType
- path + "/" + key, // Key
+ path + "/" + val, // Key
name, // Name
null, // Version
- subsystem.description, // Description
+ "TODO", // subsystem.description, // Description
config2,
null);
details.add(detail);
}
+ }
+ else {
+ System.out.println("subnode was no array");
+ }
}
else {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
index b2c8223..efe389b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
@@ -59,4 +59,11 @@ public class PROPERTY_VALUE implements Serializable{
this.value = value;
}
+ @Override
+ public String toString() {
+ return "PROPERTY_VALUE{" +
+ "key='" + key + '\'' +
+ ", value='" + value + '\'' +
+ '}';
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
new file mode 100644
index 0000000..8c5b37c
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/ReadChildrenNames.java
@@ -0,0 +1,37 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.List;
+
+/**
+ * Operation that reads children of a given type from an address
+ * @author Heiko W. Rupp
+ */
+public class ReadChildrenNames extends Operation {
+
+ /**
+ * Reas children names of a given type below a given address
+ * @param address Address to look at e.g. /profile/default/subsystem/messaging
+ * @param childType e.g. queue
+ */
+ public ReadChildrenNames(List<PROPERTY_VALUE> address, String childType) {
+ super("read-children-names",address,"child-type",childType);
+ }
+}
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 6741bb3..258da2c 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
@@ -51,7 +51,7 @@
version="4.0.0-SNAPSHOT"
>
- <depends plugin="JMX" useClasses="true"/>
+<!-- <depends plugin="JMX" useClasses="true"/> -->
<!-- TODO I think we should introduce an abstract AS7 plugin that contains some base functionality and then
@@ -284,6 +284,7 @@
<server name="Messaging"
discovery="SubsystemDiscovery"
class="DomainComponent"
+ description="The underlying HornetQ based messaging subsystem"
singleton="true"
>
<runs-inside>
@@ -298,12 +299,15 @@
<operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic">
<parameters>
<c:simple-property name="name" description="Name of the Destination" required="true"/>
+ <c:simple-property name="queue-address" description="The queue address defines what address is used for routing messages." required="true"/>
<c:simple-property name="type" description="Type of Destination to create" default="Queue">
<c:property-options>
<c:option value="Queue"/>
<c:option value="Topic"/>
</c:property-options>
</c:simple-property>
+ <c:simple-property name="filter" description="The queue message filter definition."/>
+ <c:simple-property name="durable" description="Defines whether the queue is durable." type="boolean" default="false"/>
</parameters>
<results>
<c:simple-property name="operationResult"/>
@@ -329,7 +333,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/acceptor"/>
+ <c:simple-property name="path" readOnly="true" default="acceptor"/>
</plugin-configuration>
</service>
<service name="MessagingConnector"
@@ -337,17 +341,65 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/connector"/>
+ <c:simple-property name="path" readOnly="true" default="connector"/>
</plugin-configuration>
</service>
- <service name="Queue"
+ <service name="HQueue"
discovery="SubsystemDiscovery"
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/queue/*"/>
+ <c:simple-property name="path" readOnly="true" default="queue/*"/>
+ </plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="queue-address" required="true"/>
+ <c:simple-property name="filter" />
+ <c:simple-property name="durable" type="boolean"/>
+ </resource-configuration>
+
+ </service>
+ </server>
+
+ <server name="JMS"
+ discovery="SubsystemDiscovery"
+ class="DomainComponent"
+ description="The JMS messaging subsystem"
+ singleton="true"
+ >
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/jms"/>
+ </plugin-configuration>
+
+ <service name="Queue"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="queue/*"/>
</plugin-configuration>
</service>
+ <service name="Topic"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="topic/*"/>
+ </plugin-configuration>
+ </service>
+ <service name="Connection-Factory"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="connection-factory/*"/>
+ </plugin-configuration>
+ </service>
+
</server>
<server name="JBossWeb"
@@ -377,9 +429,9 @@
<metric property="bytesSent" measurementType="trendsup"/>
<metric property="bytesReceived" measurementType="trendsup"/>
<metric property="processingTime" measurementType="trendsup"/>
- <metric property="errorCount" measurementType="trendsup"/>
+ <metric property="errorCount" measurementType="trendsup" displayType="summary"/>
<metric property="maxTime" />
- <metric property="requestCount" measurementType="trendsup"/>
+ <metric property="requestCount" measurementType="trendsup" displayType="summary"/>
<resource-configuration>
<c:simple-property name="protocol" required="false" description="The web connector protocol."/>
@@ -431,7 +483,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/data-source/*"/>
+ <c:simple-property name="path" readOnly="true" default="data-source/*"/>
</plugin-configuration>
</service>
@@ -442,7 +494,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/xa-data-source/*"/>
+ <c:simple-property name="path" readOnly="true" default="xa-data-source/*"/>
</plugin-configuration>
</service>
@@ -453,7 +505,7 @@
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/jdbc-driver/*"/>
+ <c:simple-property name="path" readOnly="true" default="jdbc-driver/*"/>
</plugin-configuration>
</service>
commit f2dc89709b73b7506403f04ff36dc894a44232f5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Apr 6 12:28:18 2011 +0200
Detect Managed AS through hosts.xml , start with deployments.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
new file mode 100644
index 0000000..f3e9ee0
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASUploadConnection.java
@@ -0,0 +1,144 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import com.sun.org.apache.xerces.internal.impl.xpath.regex.REUtil;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+
+/**
+ * Connection for uploading of content.
+ * Partially taken from https://github.com/jbossas/jboss-as/blob/master/testsuite/smoke/src/test/...
+ *
+ * @author Jonathan Pearlin (of the original code)
+ * @author Heiko W. Rupp
+ */
+public class ASUploadConnection {
+
+ private static final String BOUNDARY = "-----------------------------261773107125236";
+
+ private static final String CRLF = "\r\n";
+
+ private static final String POST_REQUEST_METHOD = "POST";
+
+ private static final String UPLOAD_URL = "http://localhost:9990/domain-api/add-content";
+
+ private final Log log = LogFactory.getLog(ASUploadConnection.class);
+
+ BufferedOutputStream os = null;
+ BufferedInputStream is = null;
+ private HttpURLConnection connection;
+
+ public OutputStream getOutputStream(String fileName) {
+ try {
+ // Create the HTTP connection to the upload URL
+ connection = (HttpURLConnection) new URL(UPLOAD_URL).openConnection();
+ connection.setDoInput(true);
+ connection.setDoOutput(true);
+ connection.setRequestMethod(POST_REQUEST_METHOD);
+
+ // Grab the test WAR file and get a stream to its contents to be included in the POST.
+ os = new BufferedOutputStream(connection.getOutputStream());
+ os.write(buildPostRequestHeader(fileName));
+
+ return os;
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public JsonNode finishUpload() {
+ try {
+ os.write(buildPostRequestFooter());
+ os.flush();
+
+ is = new BufferedInputStream(connection.getInputStream());
+ // TODO read from IN
+
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+ finally {
+ closeQuietly(is);
+ closeQuietly(os);
+ }
+
+ return null;
+ }
+
+
+ private byte[] buildPostRequestHeader(String fileName) {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(buildPostRequestHeaderSection("form-data; name=\"test1\"", "", "test1"));
+ builder.append(buildPostRequestHeaderSection("form-data; name=\"test2\"", "", "test2"));
+ builder.append(buildPostRequestHeaderSection("form-data; name=\"file\"; filename=\""+fileName+"\"", "application/octet-stream", ""));
+ return builder.toString().getBytes();
+ }
+
+ private String buildPostRequestHeaderSection(final String contentDisposition, final String contentType, final String content) {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(BOUNDARY);
+ builder.append(CRLF);
+ if(contentDisposition != null && contentDisposition.length() > 0) {
+ builder.append(String.format("Content-Disposition: %s", contentDisposition));
+ }
+ builder.append(CRLF);
+ if(contentType != null && contentType.length() > 0) {
+ builder.append(String.format("Content-Type: %s", contentType));
+ }
+ builder.append(CRLF);
+ if(content != null && content.length() > 0) {
+ builder.append(content);
+ }
+ builder.append(CRLF);
+ return builder.toString();
+ }
+
+ private byte[] buildPostRequestFooter() {
+ final StringBuilder builder = new StringBuilder();
+ builder.append(CRLF);
+ builder.append(BOUNDARY);
+ builder.append("--");
+ builder.append(CRLF);
+ return builder.toString().getBytes();
+ }
+
+
+ private void closeQuietly(final Closeable closeable) {
+ if(closeable != null) {
+ try {
+ closeable.close();
+ } catch (final IOException e) {}
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index 5ea4bd7..8597d8f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -1,3 +1,21 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.modules.plugins.jbossas7;
import java.io.File;
@@ -58,12 +76,9 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
String serverNameFull;
String serverName;
String psName = psr.getProcessScan().getName();
- if (psName.equals("ProcessManager")) {
- serverNameFull = "ProcessManager";
- serverName = "ProcessManager";
- } else if (psName.equals("ASManager")) {
- serverName = "ASManager";
- serverNameFull = "ASManager";
+ if (psName.equals("ProcessController")) {
+ serverNameFull = "ProcessController";
+ serverName = "ProcessController";
} else if (psName.equals("HostController")) {
serverName = "HostController";
serverNameFull = "HostController";
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
new file mode 100644
index 0000000..86e3b99
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ManagedASDiscovery.java
@@ -0,0 +1,289 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.system.ProcessInfo;
+
+/**
+ * Discovery class for managed AS 7 instances.
+ *
+ * @author Heiko W. Rupp
+ */
+public class ManagedASDiscovery implements ResourceDiscoveryComponent
+
+{
+
+ static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
+ static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
+ static final String DLOGGING_CONFIGURATION = "-Dlogging.configuration=";
+ static final int DEFAULT_MGMT_PORT = 9990;
+ private final Log log = LogFactory.getLog(this.getClass());
+ private Document hostXml;
+ private static final String DJBOSS_SERVER_HOME_DIR = "-Djboss.home.dir";
+
+ /**
+ * Run the auto-discovery
+ */
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+
+ List<ProcessScanResult> scans = discoveryContext.getAutoDiscoveredProcesses();
+
+ for (ProcessScanResult psr : scans) {
+
+ // get the HostController, as this is an indicator for managed AS
+ String psName = psr.getProcessScan().getName();
+ if (!psName.equals("HostController"))
+ continue;
+
+ // Now we have the host controller, lets get the host.xml file
+ // and obtain the servers from there.
+ ProcessInfo processInfo = psr.getProcessInfo();
+ readHostXml(processInfo);
+ String hostName = findHostName();
+ int port = getManagementPortFromHostXml();
+
+
+ List<ServerInfo> serverNames = getServersFromHostXml();
+ for (ServerInfo serverInfo : serverNames) {
+
+ Configuration config = discoveryContext.getDefaultPluginConfiguration();
+ config.put(new PropertySimple("domainHost",hostName));
+ config.put(new PropertySimple("group",serverInfo.group));
+ config.put(new PropertySimple("port",port));
+
+ // TODO this fails for the downed servers.
+ // get from the domain or other place as soon as the domain provides it.
+ initLogFile(scans, serverInfo.name, config, getHomeDirFromCommandLine(processInfo.getCommandLine()));
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ discoveryContext.getResourceType(), // ResourceType
+ hostName + "/" + serverInfo.name, // key
+ serverInfo.name, // Name
+ null, // TODO real version - get from Domain as soon as it is provided
+ "Managed AS 7 instance", // Description
+ config,
+ null
+ );
+
+ // Add to return values
+ discoveredResources.add(detail);
+ log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverInfo);
+ }
+ }
+ return discoveredResources;
+ }
+
+ /**
+ * Loop through the Process scans for ManagedAS and if found extract the logfile path.
+ * @param scans process scan results
+ * @param name server name to look for
+ * @param config config to put the info in
+ * @param basePath
+ */
+ private void initLogFile(List<ProcessScanResult> scans, String name, Configuration config, String basePath) {
+
+ for (ProcessScanResult psr : scans) {
+ if (!psr.getProcessScan().getName().equals("ManagedAS"))
+ continue;
+
+ String[] commandLine = psr.getProcessInfo().getCommandLine();
+
+ String logFile = basePath + File.separator + getLogFileFromCommandLine(commandLine);
+
+ if (logFile.contains(name))
+ initLogEventSourcesConfigProp(logFile,config);
+ }
+ }
+
+ private int getManagementPortFromHostXml() {
+ Element host = hostXml.getDocumentElement();
+ NodeList interfaceParent = host.getElementsByTagName("management-interfaces");
+ if (interfaceParent ==null || interfaceParent.getLength()==0) {
+ log.warn("No <management-interfaces> found in host.xml");
+ return DEFAULT_MGMT_PORT;
+ }
+ NodeList mgmtInterfaces = interfaceParent.item(0).getChildNodes();
+ if (mgmtInterfaces==null || mgmtInterfaces.getLength()==0) {
+ log.warn("No <*-interface> found in host.xml");
+ return DEFAULT_MGMT_PORT;
+ }
+ for (int i = 0 ; i < mgmtInterfaces.getLength(); i++) {
+ if (!(mgmtInterfaces.item(i) instanceof Element))
+ continue;
+
+ Element mgmtInterface = (Element) mgmtInterfaces.item(i);
+ if (mgmtInterface.getNodeName().equals("http-interface")) {
+ String tmp = mgmtInterface.getAttribute("port");
+ int port = Integer.valueOf(tmp);
+ return port;
+ }
+ }
+ return DEFAULT_MGMT_PORT;
+ }
+
+ private List<ServerInfo> getServersFromHostXml() {
+
+ Element host = hostXml.getDocumentElement();
+ NodeList serversElement = host.getElementsByTagName("servers");
+ if (serversElement ==null || serversElement.getLength()==0) {
+ log.warn("No <servers> found in host.xml");
+ return Collections.emptyList();
+ }
+ NodeList servers = serversElement.item(0).getChildNodes();
+ if (servers==null || servers.getLength()==0) {
+ log.warn("No <server> found in host.xml");
+ return Collections.emptyList();
+ }
+ List<ServerInfo> result = new ArrayList<ServerInfo>();
+ for (int i = 0 ; i < servers.getLength(); i++) {
+ if (!(servers.item(i) instanceof Element))
+ continue;
+
+ ServerInfo info = new ServerInfo();
+ Element server = (Element) servers.item(i);
+ info.name = server.getAttribute("name");
+ info.group = server.getAttribute("group");
+ String autoStart = server.getAttribute("autoStart");
+ if (autoStart==null || autoStart.isEmpty())
+ autoStart = "false";
+ info.autoStart = Boolean.getBoolean(autoStart);
+
+ result.add(info);
+ }
+
+ return result;
+ }
+
+
+ private String findHostName() {
+ String hostName = hostXml.getDocumentElement().getAttribute("name");
+ return hostName;
+ }
+
+ private void readHostXml(ProcessInfo processInfo) {
+ String hostXmlFile = getHostXmlFileLocation(processInfo);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ try {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ InputStream is = new FileInputStream(hostXmlFile);
+ hostXml = builder.parse(is);
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+ }
+
+ /**
+ * Get the location of the host definition file (host.xml in domain mode, standalone.xml
+ * in standalone mode.
+ *
+ * @param processInfo ProcessInfo structure containing the ENV variables
+ * @return The path to the definition file.
+ */
+ private String getHostXmlFileLocation(ProcessInfo processInfo) {
+
+ String home = getHomeDirFromCommandLine(processInfo.getCommandLine());
+ StringBuilder builder = new StringBuilder(home);
+ builder.append("/domain");
+ builder.append("/configuration");
+ builder.append("/host.xml");
+ return builder.toString();
+
+ }
+
+
+
+ String getHomeDirFromCommandLine(String[] commandLine) {
+ for (String line: commandLine) {
+ if (line.startsWith(DJBOSS_SERVER_HOME_DIR))
+ return line.substring(DJBOSS_SERVER_HOME_DIR.length()+1);
+ }
+ return "";
+ }
+
+//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
+//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties
+
+ String getLogFileFromCommandLine(String[] commandLine) {
+
+ for (String line: commandLine) {
+ if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
+ return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length());
+ }
+ return "";
+ }
+
+ private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) {
+
+ PropertyList logEventSources = pluginConfiguration
+ .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP);
+
+ if (logEventSources==null)
+ return;
+
+ File serverLogFile = new File(fileName);
+
+ if (serverLogFile.exists() && !serverLogFile.isDirectory()) {
+ PropertyMap serverLogEventSource = new PropertyMap("logEventSource");
+ serverLogEventSource.put(new PropertySimple(
+ LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile));
+ serverLogEventSource.put(new PropertySimple(
+ LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE));
+ logEventSources.add(serverLogEventSource);
+ }
+ }
+
+ private class ServerInfo {
+ String name;
+ String group;
+ boolean autoStart;
+
+
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
new file mode 100644
index 0000000..9650731
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ServerGroupComponent.java
@@ -0,0 +1,113 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+
+import org.rhq.core.domain.content.PackageType;
+import org.rhq.core.domain.content.transfer.DeployPackageStep;
+import org.rhq.core.domain.content.transfer.DeployPackagesResponse;
+import org.rhq.core.domain.content.transfer.RemovePackagesResponse;
+import org.rhq.core.domain.content.transfer.ResourcePackageDetails;
+import org.rhq.core.domain.resource.CreateResourceStatus;
+import org.rhq.core.pluginapi.content.ContentContext;
+import org.rhq.core.pluginapi.content.ContentFacet;
+import org.rhq.core.pluginapi.content.ContentServices;
+import org.rhq.core.pluginapi.inventory.CreateChildResourceFacet;
+import org.rhq.core.pluginapi.inventory.CreateResourceReport;
+
+/**
+ * Component dealing with server group specific things
+ * @author Heiko W. Rupp
+ */
+public class ServerGroupComponent extends DomainComponent implements ContentFacet, CreateChildResourceFacet {
+
+ private final Log log = LogFactory.getLog(ServerGroupComponent.class);
+
+ @Override
+ public List<DeployPackageStep> generateInstallationSteps(ResourcePackageDetails packageDetails) {
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public DeployPackagesResponse deployPackages(Set<ResourcePackageDetails> packages,
+ ContentServices contentServices) {
+
+ ContentContext cctx = context.getContentContext();
+
+ String uploadUrl = "http://localhost:9990/domain-api/add-content";
+
+ for (ResourcePackageDetails details : packages) {
+ ASUploadConnection uploadConnection = new ASUploadConnection();
+ OutputStream out = uploadConnection.getOutputStream(details.getFileName());
+ contentServices.downloadPackageBits(cctx, details.getKey(), out, false);
+ JsonNode result = uploadConnection.finishUpload();
+ }
+
+
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public RemovePackagesResponse removePackages(Set<ResourcePackageDetails> packages) {
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public Set<ResourcePackageDetails> discoverDeployedPackages(PackageType type) {
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public InputStream retrievePackageBits(ResourcePackageDetails packageDetails) {
+ return null; // TODO: Customise this generated block
+ }
+
+ @Override
+ public CreateResourceReport createResource(CreateResourceReport report) {
+
+
+ ResourcePackageDetails details = report.getPackageDetails();
+
+ ContentContext cctx = context.getContentContext();
+ ContentServices contentServices = cctx.getContentServices();
+ String resourceTypeName = report.getResourceType().getName();
+
+ ASUploadConnection connection = new ASUploadConnection();
+ OutputStream out = connection.getOutputStream(details.getFileName());
+// contentServices.downloadPackageBits(cctx,details.getKey(),out,false);
+ contentServices.downloadPackageBitsForChildResource(cctx, resourceTypeName, details.getKey(), out);
+
+ JsonNode result = connection.finishUpload();
+ System.out.println(result);
+
+
+ report.setStatus(CreateResourceStatus.SUCCESS) ;
+
+ return report;
+
+ }
+}
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 02b4bf8..6741bb3 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
@@ -71,7 +71,7 @@
&logSources;
</plugin-configuration>
- <process-scan name="ProcessManager" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/>
+ <process-scan name="ProcessController" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/>
<operation name="dummyOperation">
@@ -93,7 +93,7 @@
&logSources;
</plugin-configuration>
- <process-scan name="ProcessManager" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
+ <process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
<operation name="dummyOperation">
@@ -132,16 +132,25 @@
<server name="ServerGroup"
description="Server groups on this domain"
discovery="SubsystemDiscovery"
- class="ServerGroupComponent">
+ class="ServerGroupComponent"
+ >
+ <!-- TODO move operation to createDeletePolicy="create-only" -->
+
<plugin-configuration>
<c:simple-property name="path" default="/server-group/*" readOnly="true"/>
</plugin-configuration>
+
+
+ <content name="deployment" category="deployable" isCreationType="true" description="Deployments on this domain">
+ </content>
+
<resource-configuration>
<c:simple-property name="profile" />
<c:simple-property name="socket-binding-group"/>
<c:simple-property name="jvm"/>
<c:simple-property name="deployment" required="false"/> <!-- TODO change structure. Or put below as resource? -->
</resource-configuration>
+ <service name="Deployment" class="BaseComponent" discovery="SubsystemDiscovery" createDeletePolicy="create-only"/>
</server>
<server name="Host"
description="Host involved in this domain"
@@ -171,9 +180,11 @@
</results>
</operation>
+<!--
<resource-configuration>
<c:list-property name="server-config" />
</resource-configuration>
+-->
</server>
@@ -216,16 +227,20 @@
</server>
<server name="JBossAS-Managed"
- discovery="BaseProcessDiscovery"
+ discovery="ManagedASDiscovery"
class="DomainComponent"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" required="true"/>
<c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:simple-property name="domainHost" readOnly="true" description="Hostname in the domain"/>
+ <c:simple-property name="group" readOnly="true" displayName="Server Group" description="Server Group this instance belongs to."/>
&logSources;
</plugin-configuration>
+ <!-- Scan for host controller is intentional -->
+ <process-scan name="HostController" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
<process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
<operation name="server:start" description="Start this server instance." displayName="Start">
@@ -330,7 +345,7 @@
class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/queue/"/>
+ <c:simple-property name="path" readOnly="true" default="/queue/*"/>
</plugin-configuration>
</service>
</server>
@@ -383,7 +398,9 @@
<resource-configuration>
<c:simple-property name="access-log"/>
- <c:list-property name="alias" description="The virtual server aliases"/>
+ <c:list-property name="alias" description="The virtual server aliases">
+ <c:simple-property name="alias"/>
+ </c:list-property>
<c:simple-property name="rewrite"/>
</resource-configuration>
commit 3b22a190f79b18c80c485f6f5b86c0a7f0b179e2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Apr 5 21:45:49 2011 +0200
Make sure the input stream is closed. Otherwise we are keeping too many connections open and AS will choke on us.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 97788ae..0c6d516 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -173,6 +173,8 @@ public class ASConnection {
*/
public JsonNode execute(Operation operation) {
+ InputStream inputStream = null;
+ BufferedReader br=null;
try {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
@@ -188,23 +190,22 @@ public class ASConnection {
out.flush();
out.close();
- InputStream inputStream;
if (conn.getResponseCode()==HttpURLConnection.HTTP_OK) {
inputStream = conn.getInputStream();
- BufferedReader in = new BufferedReader(new InputStreamReader(
+ br = new BufferedReader(new InputStreamReader(
inputStream));
String line;
builder = new StringBuilder();
- while ((line = in.readLine()) != null) {
+ while ((line = br.readLine()) != null) {
builder.append(line);
}
- in.close();
+ br.close();
}
else {
InputStream errorStream = conn.getErrorStream();
if (errorStream!=null) {
- BufferedReader br = new BufferedReader(new InputStreamReader(errorStream));
+ br = new BufferedReader(new InputStreamReader(errorStream));
String line;
builder = new StringBuilder();
while ((line = br.readLine()) != null) {
@@ -213,6 +214,9 @@ public class ASConnection {
br.close();
}
}
+ if (br!=null)
+ br.close();
+
String outcome;
JsonNode operationResult=null;
if (builder!=null) {
commit 5f9a6b6cbe98d47ef75deac36e7a81b5cc73b427
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Sat Apr 2 09:24:27 2011 +0200
Allow creation and removal of Messaging destinations.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index bd0b458..97788ae 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -150,6 +150,9 @@ public class ASConnection {
JsonNode reasonNode = in.findValue("failure-description");
if (reasonNode==null)
reasonNode = in.findValue("domain-failure-description");// TODO JBAS-9182
+ if (reasonNode==null)
+ reasonNode = in.findValue("host-failure-descriptions"); // TODO JBAS-9182
+
String reason = reasonNode.getTextValue();
log.info(reason);
return true;
@@ -260,6 +263,8 @@ public class ASConnection {
JsonNode node = jsonNode.findValue("failure-description");
if (node==null)
node = jsonNode.findValue("domain-failure-description"); // TODO JBAS-9182
+ if (node==null)
+ node = jsonNode.findValue("host-failure-descriptions"); // TODO JBAS-9182
return node.getValueAsText();
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index b53dd74..a06a296 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -78,16 +78,16 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
String op = name.substring(colonPos+1);
Operation operation=null;
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
+
if (what.equals("server-group")) {
String groupName = parameters.getSimpleValue("name",null);
String profile = parameters.getSimpleValue("profile","default");
- List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(1);
address.add(new PROPERTY_VALUE("server-group",groupName));
operation = new Operation(op,address,"profile",profile);
} else if (what.equals("server")) {
- List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
if (context.getResourceType().getName().equals("JBossAS-Managed")) {
String host = conf.getSimpleValue("domainHost","local");
@@ -99,17 +99,24 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
address.addAll(pathToAddress(getPath()));
String serverName = parameters.getSimpleValue("name",null);
address.add(new PROPERTY_VALUE("server-config",serverName));
- Map<String,String> props = new HashMap<String, String>();
+ Map<String,Object> props = new HashMap<String, Object>();
String serverGroup = parameters.getSimpleValue("group",null);
- props.put("name",serverName);
props.put("group",serverGroup);
-// boolean autoStart = parameters.getSimple("auto-start").getBooleanValue();
-// props.put("auto-start",String.valueOf(autoStart));
- // TODO put more properties in
+ if (op.equals("add")) {
+ props.put("name",serverName);
+ boolean autoStart = parameters.getSimple("auto-start").getBooleanValue();
+ props.put("auto-start",autoStart);
+ // TODO put more properties in
+ }
operation = new Operation(op,address,props);
}
-
+ } else if (what.equals("destination")) {
+ address.addAll(pathToAddress(getPath()));
+ String newName = parameters.getSimpleValue("name","");
+ String type = parameters.getSimpleValue("type","Queue").toLowerCase();
+ address.add(new PROPERTY_VALUE(type,newName));
+ operation = new Operation(op,address);
}
OperationResult operationResult = new OperationResult();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index b577407..1c498d1 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -95,6 +95,12 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
+ if (subsystemMap==null) {
+ log.warn("SubsystemMap was null for path [" + path + "] and subPath ["+ subPath + "] and subNode [" + subNode + "]");
+ return Collections.emptySet();
+ }
+
+
for (Map.Entry<String,Subsystem> entry: subsystemMap.entrySet()) {
String key = entry.getKey();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index 92abbae..e538c94 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -38,28 +38,28 @@ public class Operation {
private String operation;
@JsonProperty
private List<PROPERTY_VALUE> address = Collections.emptyList();
- private Map<String,String> additionalProperties;
+ private Map<String,Object> additionalProperties;
public Operation(String operation, List<PROPERTY_VALUE> address, NameValuePair payload) {
this.operation = operation;
this.address = address;
- additionalProperties = new HashMap<String,String>(2);
+ additionalProperties = new HashMap<String,Object>(2);
additionalProperties.put("name",payload.name);
additionalProperties.put("value",payload.value);
}
- public Operation(String operation, List<PROPERTY_VALUE> address, Map<String,String> payload) {
+ public Operation(String operation, List<PROPERTY_VALUE> address, Map<String,Object> payload) {
this.operation = operation;
this.address = address;
this.additionalProperties = payload;
}
- public Operation(String operation, List<PROPERTY_VALUE> address, String key, String value) {
+ public Operation(String operation, List<PROPERTY_VALUE> address, String key, Object value) {
this.operation = operation;
this.address = address;
- additionalProperties = new HashMap<String,String>(1);
+ additionalProperties = new HashMap<String,Object>(1);
additionalProperties.put(key,value);
}
@@ -78,30 +78,30 @@ public class Operation {
@JsonAnySetter
public void addAdditionalProperty(String key, String value) {
if (additionalProperties == null)
- additionalProperties = new HashMap<String, String>();
+ additionalProperties = new HashMap<String, Object>();
additionalProperties.put(key,value);
}
- public void setAdditionalProperties(Map<String, String> additionalProperties) {
+ public void setAdditionalProperties(Map<String, Object> additionalProperties) {
this.additionalProperties = additionalProperties;
}
@JsonAnyGetter
- public Map<String,String> getAdditionalProperties() {
+ public Map<String,Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonIgnore
public String getName() {
- return getProperty("name");
+ return (String) getProperty("name");
}
@JsonIgnore
public String getValue() {
- return getProperty("value");
+ return (String) getProperty("value");
}
- private String getProperty(String key) {
+ private Object getProperty(String key) {
if (additionalProperties.containsKey(key))
return additionalProperties.get(key);
else
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 e77a2ca..02b4bf8 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
@@ -132,7 +132,7 @@
<server name="ServerGroup"
description="Server groups on this domain"
discovery="SubsystemDiscovery"
- class="BaseComponent">
+ class="ServerGroupComponent">
<plugin-configuration>
<c:simple-property name="path" default="/server-group/*" readOnly="true"/>
</plugin-configuration>
@@ -156,7 +156,7 @@
<parameters>
<c:simple-property name="name" description="Name of this new server" required="true"/>
<c:simple-property name="group" displayName="Server Group" description="Server group to put this sever in" default="" required="false"/>
- <c:simple-property name="auto-start" displayName="Autostart" description="Should this server start at boot?" type="boolean" default="false" required="false"/>
+ <c:simple-property name="auto-start" displayName="Autostart" description="Should this server start at boot?" type="boolean" default="false" required="true"/>
</parameters>
<results>
<c:simple-property name="result" description="Outcome of the create server operation"/>
@@ -228,9 +228,21 @@
<process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
- <operation name="server:start" description="Start this server instance." displayName="Start"/>
- <operation name="server:stop" description="Stop this server instance." displayName="Stop"/>
- <operation name="server:restart" description="Restart this server instance." displayName="Restart"/>
+ <operation name="server:start" description="Start this server instance." displayName="Start">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="server:stop" description="Stop this server instance." displayName="Stop">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="server:restart" description="Restart this server instance." displayName="Restart">
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
@@ -256,7 +268,7 @@
<server name="Messaging"
discovery="SubsystemDiscovery"
- class="BaseComponent"
+ class="DomainComponent"
singleton="true"
>
<runs-inside>
@@ -268,6 +280,29 @@
<c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
</plugin-configuration>
+ <operation name="destination:add" displayName="Add destination" description="Add a Queue or Topic">
+ <parameters>
+ <c:simple-property name="name" description="Name of the Destination" required="true"/>
+ <c:simple-property name="type" description="Type of Destination to create" default="Queue">
+ <c:property-options>
+ <c:option value="Queue"/>
+ <c:option value="Topic"/>
+ </c:property-options>
+ </c:simple-property>
+ </parameters>
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+ <operation name="destination:remove" displayName="Remove Destination" description="Remove a destination">
+ <parameters>
+ <c:simple-property name="name" description="Name of the Destination" required="true"/>
+ </parameters>
+ <results>
+ <c:simple-property name="operationResult"/>
+ </results>
+ </operation>
+
<resource-configuration>
<c:simple-property name="journal-min-files" />
<c:simple-property name="journal-type" />
@@ -281,10 +316,23 @@
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/acceptor"/>
</plugin-configuration>
-
-
</service>
-
+ <service name="MessagingConnector"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/connector"/>
+ </plugin-configuration>
+ </service>
+ <service name="Queue"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/queue/"/>
+ </plugin-configuration>
+ </service>
</server>
<server name="JBossWeb"
@@ -344,6 +392,56 @@
</server>
+ <server name="Datasources"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/datasources"/>
+ </plugin-configuration>
+
+ <service name="DataSource"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/data-source/*"/>
+ </plugin-configuration>
+ </service>
+
+ <service name="XADataSource"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/xa-data-source/*"/>
+ </plugin-configuration>
+ </service>
+
+ <service name="JdbcDriver"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/jdbc-driver/*"/>
+ </plugin-configuration>
+ </service>
+
+ </server>
+
<service name="NetworkInterface"
discovery="InterfaceDiscovery"
class="BaseComponent"
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 929a87c..5ba843f 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -79,8 +79,9 @@ public class OperationJsonTest {
PROPERTY_VALUE part = new PROPERTY_VALUE("/server-group","newOne");
address.add(part);
- Map<String,String> props = new HashMap<String, String>();
+ Map<String,Object> props = new HashMap<String, Object>();
props.put("profile","default");
+ props.put("someBool",true);
Operation operation = new Operation("add",address,props);
@@ -94,6 +95,10 @@ public class OperationJsonTest {
Operation op = mapper.readValue(result,Operation.class);
assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation();
+ assert op.getAdditionalProperties().containsKey("someBool") : "Key someBool not found ";
+ Object someBool = op.getAdditionalProperties().get("someBool");
+ assert Boolean.valueOf((String) someBool) : "someBool was not true";
+
}
}
commit a3fdac16d1b0301ca4771c61ba7f7517d2880117
Merge: 7122b59 080e1d7
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 31 12:56:44 2011 +0200
Merge branch 'master' into as7plugin
commit 7122b59f83eab6785068f46224f4d601373f26ef
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 31 12:24:46 2011 +0200
Start support for adding and removal of server instances.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 470722d..bd0b458 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -210,11 +210,19 @@ public class ASConnection {
br.close();
}
}
- String outcome = builder.toString();
+ String outcome;
+ JsonNode operationResult=null;
+ if (builder!=null) {
+ outcome= builder.toString();
+ operationResult = mapper.readTree(outcome);
+ }
+ else {
+ outcome="- no response from server -";
+ }
System.out.println("==> " + outcome);
- JsonNode operationResult = mapper.readTree(outcome);
return operationResult;
+
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index 460aebf..b53dd74 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -20,7 +20,9 @@ package org.rhq.modules.plugins.jbossas7;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.codehaus.jackson.JsonNode;
@@ -87,12 +89,27 @@ public class DomainComponent extends BaseComponent implements OperationFacet{
} else if (what.equals("server")) {
List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
- String host = conf.getSimpleValue("domainHost","local");
-
- address.add(new PROPERTY_VALUE("host",host));
- address.add(new PROPERTY_VALUE("server-config",myServerName));
+ if (context.getResourceType().getName().equals("JBossAS-Managed")) {
+ String host = conf.getSimpleValue("domainHost","local");
+ address.add(new PROPERTY_VALUE("host",host));
+ address.add(new PROPERTY_VALUE("server-config",myServerName));
+ operation = new Operation(op,address);
+ }
+ else if (context.getResourceType().getName().equals("Host")) {
+ address.addAll(pathToAddress(getPath()));
+ String serverName = parameters.getSimpleValue("name",null);
+ address.add(new PROPERTY_VALUE("server-config",serverName));
+ Map<String,String> props = new HashMap<String, String>();
+ String serverGroup = parameters.getSimpleValue("group",null);
+ props.put("name",serverName);
+ props.put("group",serverGroup);
+// boolean autoStart = parameters.getSimple("auto-start").getBooleanValue();
+// props.put("auto-start",String.valueOf(autoStart));
+ // TODO put more properties in
+
+ operation = new Operation(op,address,props);
+ }
- operation = new Operation(op,address);
}
OperationResult operationResult = new OperationResult();
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 9994339..e77a2ca 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
@@ -120,7 +120,6 @@
</parameters>
</operation>
-
<server name="Profile"
description="One profile in a domain"
discovery="SubsystemDiscovery"
@@ -147,12 +146,31 @@
<server name="Host"
description="Host involved in this domain"
discovery="SubsystemDiscovery"
- class="BaseComponent"
+ class="DomainComponent"
>
<plugin-configuration>
<c:simple-property name="path" default="/host/*" readOnly="true"/>
</plugin-configuration>
+ <operation name="server:add" displayName="Create server" description="Add a new server to this host.">
+ <parameters>
+ <c:simple-property name="name" description="Name of this new server" required="true"/>
+ <c:simple-property name="group" displayName="Server Group" description="Server group to put this sever in" default="" required="false"/>
+ <c:simple-property name="auto-start" displayName="Autostart" description="Should this server start at boot?" type="boolean" default="false" required="false"/>
+ </parameters>
+ <results>
+ <c:simple-property name="result" description="Outcome of the create server operation"/>
+ </results>
+ </operation>
+ <operation name="server:remove" displayName="Delete server" description="Deletes a server on this host.">
+ <parameters>
+ <c:simple-property name="name" description="Name of this new server" required="true"/>
+ </parameters>
+ <results>
+ <c:simple-property name="result" description="Outcome of the delete server operation"/>
+ </results>
+ </operation>
+
<resource-configuration>
<c:list-property name="server-config" />
</resource-configuration>
@@ -210,9 +228,10 @@
<process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
- <operation name="server:start" description="Start this server instance."/>
- <operation name="server:stop" description="Stop this server instance."/>
- <operation name="server:restart" description="Restart this server instance."/>
+ <operation name="server:start" description="Start this server instance." displayName="Start"/>
+ <operation name="server:stop" description="Stop this server instance." displayName="Stop"/>
+ <operation name="server:restart" description="Restart this server instance." displayName="Restart"/>
+
</server>
commit f2aa9b3dfbe8d6c2cc7b8239a753fe1f7023142a
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 31 08:30:04 2011 +0200
Get availability for a managed server from the domain.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
index bfed04a..460aebf 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.Operation;
@@ -38,6 +39,29 @@ import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
public class DomainComponent extends BaseComponent implements OperationFacet{
@Override
+ public AvailabilityType getAvailability() {
+
+ if (context.getResourceType().getName().equals("JBossAS-Managed")) {
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(2);
+ String host = conf.getSimpleValue("domainHost","local");
+ address.add(new PROPERTY_VALUE("host",host));
+ address.add(new PROPERTY_VALUE("server-config",myServerName));
+ Operation getStatus = new Operation("read-attribute",address,"name","status");
+ JsonNode result = connection.execute(getStatus);
+ if (connection.isErrorReply(result))
+ return AvailabilityType.DOWN;
+
+ String msg = connection.getSuccessDescription(result);
+ if (msg.contains("STARTED"))
+ return AvailabilityType.UP;
+ else
+ return AvailabilityType.DOWN;
+ }
+
+ return super.getAvailability(); // TODO: Customise this generated block
+ }
+
+ @Override
public OperationResult invokeOperation(String name,
Configuration parameters) throws InterruptedException, Exception {
commit 397d5539988b798e49d2dc6e3f896c125274e0bc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 30 21:42:40 2011 +0200
Support start/stop/restart of servers.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 401887b..470722d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -199,7 +199,6 @@ public class ASConnection {
in.close();
}
else {
- System.out.println(conn.getResponseCode());
InputStream errorStream = conn.getErrorStream();
if (errorStream!=null) {
BufferedReader br = new BufferedReader(new InputStreamReader(errorStream));
@@ -254,6 +253,12 @@ public class ASConnection {
if (node==null)
node = jsonNode.findValue("domain-failure-description"); // TODO JBAS-9182
return node.getValueAsText();
+ }
+ public String getSuccessDescription(JsonNode jsonNode) {
+ if (jsonNode==null)
+ return "No message found";
+ JsonNode node = jsonNode.findValue("result");
+ return node.getValueAsText();
}
}
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 3b025f3..5dbd0b3 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
@@ -291,7 +291,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
return ret;
}
- private String getResultingPath() {
+ protected String getResultingPath() {
ResourceComponent parentResourceComponent = context.getParentResourceComponent();
String parentPath =null;
String myPath;
@@ -328,7 +328,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
- private List<PROPERTY_VALUE> pathToAddress(String path) {
+ protected List<PROPERTY_VALUE> pathToAddress(String path) {
if (path.endsWith("/"))
path = path.substring(0,path.length()-1);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
index c38e297..5ea4bd7 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -1,12 +1,19 @@
package org.rhq.modules.plugins.jbossas7;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
+import org.w3c.dom.Document;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.PropertyList;
@@ -17,6 +24,7 @@ import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.core.system.ProcessInfo;
import org.rhq.plugins.jmx.JMXDiscoveryComponent;
@@ -29,6 +37,7 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
+ static final String DLOGGING_CONFIGURATION = "-Dlogging.configuration=";
private final Log log = LogFactory.getLog(this.getClass());
/**
@@ -69,6 +78,10 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
tmp = tmp.substring( i + 8);
tmp = tmp.substring(0,tmp.indexOf("/"));
serverNameFull = tmp;
+
+ String host = findHost(psr.getProcessInfo(),true);
+ config.put(new PropertySimple("domainHost",host));
+
}
serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
if (serverName.isEmpty())
@@ -114,7 +127,49 @@ public class BaseProcessDiscovery implements ResourceDiscoveryComponent
}
- String getBaseDirFromCommandLine(String[] commandLine) {
+ private String findHost(ProcessInfo processInfo,boolean isDomain) {
+ String hostXmlFile = getHostXmlFileLocation(processInfo, isDomain);
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ String hostName = null;
+ try {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ InputStream is = new FileInputStream(hostXmlFile);
+ Document document = builder.parse(is); // TODO keep this around
+ hostName = document.getDocumentElement().getAttribute("name");
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+ if (hostName==null)
+ hostName="local"; // Fallback to the installation default
+ return hostName;
+ }
+
+ /**
+ * Get the location of the host definition file (host.xml in domain mode, standalone.xml
+ * in standalone mode.
+ * @param processInfo ProcessInfo structure containing the ENV variables
+ * @param isDomain Are we looking for host.xml (=isDomain) or not
+ * @return The path to the definition file.
+ */
+ private String getHostXmlFileLocation(ProcessInfo processInfo, boolean isDomain) {
+
+ String home = processInfo.getEnvironmentVariable("jboss.home.dir");
+ StringBuilder builder = new StringBuilder(home);
+ if (isDomain)
+ builder.append("/domain");
+ else
+ builder.append("/standalone");
+ builder.append("/configuration");
+ if (isDomain)
+ builder.append("/host.xml");
+ else
+ builder.append("/standalone.xml");
+ return builder.toString();
+
+ }
+
+ String getBaseDirFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
if (line.startsWith(DJBOSS_SERVER_BASE_DIR))
return line.substring(DJBOSS_SERVER_BASE_DIR.length());
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
new file mode 100644
index 0000000..bfed04a
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainComponent.java
@@ -0,0 +1,91 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.codehaus.jackson.JsonNode;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Common stuff for the Domain
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class DomainComponent extends BaseComponent implements OperationFacet{
+
+ @Override
+ public OperationResult invokeOperation(String name,
+ Configuration parameters) throws InterruptedException, Exception {
+
+ if (!name.contains(":")) {
+ OperationResult badName = new OperationResult("Operation name did not contain a ':'");
+ badName.setErrorMessage("Operation name did not contain a ':'");
+ return badName;
+ }
+
+ int colonPos = name.indexOf(':');
+ String what = name.substring(0, colonPos);
+ String op = name.substring(colonPos+1);
+ Operation operation=null;
+
+ if (what.equals("server-group")) {
+ String groupName = parameters.getSimpleValue("name",null);
+ String profile = parameters.getSimpleValue("profile","default");
+
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>(1);
+ address.add(new PROPERTY_VALUE("server-group",groupName));
+
+ operation = new Operation(op,address,"profile",profile);
+ } else if (what.equals("server")) {
+ List<PROPERTY_VALUE> address = new ArrayList<PROPERTY_VALUE>();
+
+ String host = conf.getSimpleValue("domainHost","local");
+
+ address.add(new PROPERTY_VALUE("host",host));
+ address.add(new PROPERTY_VALUE("server-config",myServerName));
+
+ operation = new Operation(op,address);
+ }
+
+ OperationResult operationResult = new OperationResult();
+ if (operation!=null) {
+ JsonNode result = connection.execute(operation);
+
+ if (connection.isErrorReply(result)) {
+ operationResult.setErrorMessage(connection.getFailureDescription(result));
+ }
+ else {
+ operationResult.setSimpleResult(connection.getSuccessDescription(result));
+ }
+ }
+ else {
+ operationResult.setErrorMessage("No valid operation was given");
+ }
+ // TODO throw an exception if the operation failed?
+ return operationResult;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index 898f176..92abbae 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -64,6 +64,13 @@ public class Operation {
}
+ public Operation(String operation, List<PROPERTY_VALUE> address) {
+ this.operation = operation;
+ this.address = address;
+ additionalProperties = Collections.emptyMap();
+
+ }
+
public Operation() {
// needed for Jackson
}
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 6af7de6..9994339 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
@@ -199,7 +199,7 @@
<server name="JBossAS-Managed"
discovery="BaseProcessDiscovery"
- class="BaseComponent"
+ class="DomainComponent"
>
<plugin-configuration>
<c:simple-property name="hostname" default="localhost" required="true"/>
@@ -210,6 +210,11 @@
<process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
+ <operation name="server:start" description="Start this server instance."/>
+ <operation name="server:stop" description="Stop this server instance."/>
+ <operation name="server:restart" description="Restart this server instance."/>
+
+
</server>
commit 63147effa639ef08f8cff763393efbafcd3a8607
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 30 12:17:21 2011 +0200
Make executing of Operations more generic and implement add/remove of serverGroups.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 192a54f..401887b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -148,6 +148,8 @@ public class ASConnection {
outcome = outcomeNode.getTextValue();
if (outcome.equals("failed")) {
JsonNode reasonNode = in.findValue("failure-description");
+ if (reasonNode==null)
+ reasonNode = in.findValue("domain-failure-description");// TODO JBAS-9182
String reason = reasonNode.getTextValue();
log.info(reason);
return true;
@@ -163,11 +165,10 @@ public class ASConnection {
/**
* Execute an operation against the domain api
- * @param path Node to manipulate
- * @param operationName operation to run
- * @param attributeValue attribute-name-value pair
+ * @return JsonNode that describes the result
+ * @param operation an Operation that should be run on the domain controller
*/
- public JsonNode execute(String path, String operationName, NameValuePair attributeValue) {
+ public JsonNode execute(Operation operation) {
try {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
@@ -177,8 +178,6 @@ public class ASConnection {
ObjectMapper mapper = new ObjectMapper();
- Operation operation = new Operation(operationName,pathToAddress(path),attributeValue);
-
String result = mapper.writeValueAsString(operation);
System.out.println("Json to send: " + result);
mapper.writeValue(out, operation);
@@ -224,22 +223,6 @@ public class ASConnection {
return null;
}
- private List<PROPERTY_VALUE> pathToAddress(String path) {
- if (path.endsWith("/"))
- path = path.substring(0,path.length()-1);
-
- if (path.startsWith("/"))
- path = path.substring(1);
-
- List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
- String[] components = path.split("/");
- for (int i = 0; i < components.length ; i+=2) {
- PROPERTY_VALUE valuePair = new PROPERTY_VALUE(components[i],components[i+1]);
- result.add(valuePair);
- }
-
- return result;
- }
private URL getBaseUrl(String base, String ops) throws MalformedURLException {
String spec;
@@ -268,6 +251,8 @@ public class ASConnection {
if (jsonNode==null)
return "getFailureDescription: -input was null-";
JsonNode node = jsonNode.findValue("failure-description");
+ if (node==null)
+ node = jsonNode.findValue("domain-failure-description"); // TODO JBAS-9182
return node.getValueAsText();
}
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 788531b..3b025f3 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
@@ -45,9 +45,13 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -149,22 +153,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- ResourceComponent parentResourceComponent = context.getParentResourceComponent();
- String parentPath =null;
- String myPath;
- if (parentResourceComponent instanceof BaseComponent) {
- BaseComponent parentComponent = (BaseComponent) parentResourceComponent;
- parentPath = parentComponent.getPath();
- }
-
- if (parentPath!=null) {
- if (parentPath.endsWith("/") || path.startsWith("/"))
- myPath = parentPath + path;
- else
- myPath = parentPath + "/" + path;
- }
- else
- myPath = path;
+ String myPath = getResultingPath();
JsonNode json = connection.getLevelData(myPath,true,false);
@@ -302,6 +291,26 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
return ret;
}
+ private String getResultingPath() {
+ ResourceComponent parentResourceComponent = context.getParentResourceComponent();
+ String parentPath =null;
+ String myPath;
+ if (parentResourceComponent instanceof BaseComponent) {
+ BaseComponent parentComponent = (BaseComponent) parentResourceComponent;
+ parentPath = parentComponent.getPath();
+ }
+
+ if (parentPath!=null) {
+ if (parentPath.endsWith("/") || path.startsWith("/"))
+ myPath = parentPath + path;
+ else
+ myPath = parentPath + "/" + path;
+ }
+ else
+ myPath = path;
+ return myPath;
+ }
+
public void updateResourceConfiguration(ConfigurationUpdateReport report) {
@@ -309,7 +318,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (Map.Entry<String, PropertySimple> entry : conf.getSimpleProperties().entrySet()) {
NameValuePair nvp = new NameValuePair(entry.getKey(),entry.getValue().getStringValue());
- JsonNode result= connection.execute(key,"write-attribute",nvp); // TODO path / key handling
+ Operation writeAttribute = new Operation("write-attribute",pathToAddress(getResultingPath()),nvp);
+ JsonNode result= connection.execute(writeAttribute);
if(connection.isErrorReply(result)) {
report.setStatus(ConfigurationUpdateStatus.FAILURE);
report.setErrorMessage(connection.getFailureDescription(result));
@@ -317,4 +327,22 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
}
+
+ private List<PROPERTY_VALUE> pathToAddress(String path) {
+ if (path.endsWith("/"))
+ path = path.substring(0,path.length()-1);
+
+ if (path.startsWith("/"))
+ path = path.substring(1);
+
+ List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
+ String[] components = path.split("/");
+ for (int i = 0; i < components.length ; i+=2) {
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(components[i],components[i+1]);
+ result.add(valuePair);
+ }
+
+ return result;
+ }
+
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index 642b41f..898f176 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -20,10 +20,14 @@ package org.rhq.modules.plugins.jbossas7.json;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.codehaus.jackson.annotate.JsonAnyGetter;
+import org.codehaus.jackson.annotate.JsonAnySetter;
+import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.annotate.JsonValue;
/**
* Operation to run on the server
@@ -31,23 +35,71 @@ import org.codehaus.jackson.annotate.JsonValue;
*/
public class Operation {
+ private String operation;
+ @JsonProperty
+ private List<PROPERTY_VALUE> address = Collections.emptyList();
+ private Map<String,String> additionalProperties;
+
+
public Operation(String operation, List<PROPERTY_VALUE> address, NameValuePair payload) {
this.operation = operation;
this.address = address;
- this.name = payload.name;
- this.value = payload.value;
+ additionalProperties = new HashMap<String,String>(2);
+ additionalProperties.put("name",payload.name);
+ additionalProperties.put("value",payload.value);
+
+ }
+
+ public Operation(String operation, List<PROPERTY_VALUE> address, Map<String,String> payload) {
+ this.operation = operation;
+ this.address = address;
+ this.additionalProperties = payload;
+ }
+
+ public Operation(String operation, List<PROPERTY_VALUE> address, String key, String value) {
+ this.operation = operation;
+ this.address = address;
+ additionalProperties = new HashMap<String,String>(1);
+ additionalProperties.put(key,value);
+
}
public Operation() {
// needed for Jackson
}
- private String operation;
- @JsonProperty
- private List<PROPERTY_VALUE> address = Collections.emptyList();
+ @JsonAnySetter
+ public void addAdditionalProperty(String key, String value) {
+ if (additionalProperties == null)
+ additionalProperties = new HashMap<String, String>();
+ additionalProperties.put(key,value);
+ }
- private String name;
- private String value;
+ public void setAdditionalProperties(Map<String, String> additionalProperties) {
+ this.additionalProperties = additionalProperties;
+ }
+
+ @JsonAnyGetter
+ public Map<String,String> getAdditionalProperties() {
+ return this.additionalProperties;
+ }
+
+ @JsonIgnore
+ public String getName() {
+ return getProperty("name");
+ }
+
+ @JsonIgnore
+ public String getValue() {
+ return getProperty("value");
+ }
+
+ private String getProperty(String key) {
+ if (additionalProperties.containsKey(key))
+ return additionalProperties.get(key);
+ else
+ return null;
+ }
public String getOperation() {
return operation;
@@ -72,58 +124,5 @@ public class Operation {
return address;
}
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- /*
- [localhost:9999 /subsystem=web/connector=http] :write-attribute(name=socket-binding,value=jndi)
- yield JSON to send:
- {
- "operation" : "write-attribute",
- "name" : "socket-binding",
- "value" : "jndi",
- "address" : [
- {
- "PROPERTY_VALUE" : {
- "subsystem" : "web"
- }
- },
- {
- "PROPERTY_VALUE" : {
- "connector" : "http"
- }
- }
- ]
- }
- */
-
-// @JsonValue
-// public String toString() {
-// StringBuilder b = new StringBuilder();
-// b.append('{');
-// b.append("\"operation\":\"").append(operation).append("\",");
-// b.append("\"address\":");
-// if (address!=null && !address.isEmpty())
-// b.append(address);
-// else
-// b.append("[]");
-// b.append(',');
-// b.append(payload);
-// b.append("}");
-// return b.toString();
-// }
}
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 ee6b21f..6af7de6 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
@@ -105,9 +105,21 @@
<server name="Domain"
discovery="DomainDiscovery"
- class="BaseComponent"
+ class="DomainComponent"
description="An AS7 management profile">
+ <operation name="server-group:add" displayName="Add ServerGroup" description="Add a server group to the Domain.">
+ <parameters>
+ <c:simple-property name="name" description="Name of Group to add"/>
+ <c:simple-property name="profile" description="Profile to add this group to"/>
+ </parameters>
+ </operation>
+ <operation name="server-group:remove" displayName="Remove ServerGroup" description="Remove a server group from the Domain.">
+ <parameters>
+ <c:simple-property name="name" description="Name of Group to add"/>
+ </parameters>
+ </operation>
+
<server name="Profile"
description="One profile in a domain"
@@ -125,7 +137,6 @@
<plugin-configuration>
<c:simple-property name="path" default="/server-group/*" readOnly="true"/>
</plugin-configuration>
-
<resource-configuration>
<c:simple-property name="profile" />
<c:simple-property name="socket-binding-group"/>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 4909595..929a87c 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -19,7 +19,9 @@
package org.rhq.modules.plugins.jbossas7;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.codehaus.jackson.map.ObjectMapper;
import org.testng.annotations.Test;
@@ -70,4 +72,28 @@ public class OperationJsonTest {
assert pv.getKey().equals("myKey") : "Key is " + pv.getKey();
assert pv.getValue().equals("myValue"): "Value is " + pv.getValue();
}
+
+ public void anyPayloadTest() throws Exception {
+
+ List<PROPERTY_VALUE> address=new ArrayList<PROPERTY_VALUE>(2);
+ PROPERTY_VALUE part = new PROPERTY_VALUE("/server-group","newOne");
+ address.add(part);
+
+ Map<String,String> props = new HashMap<String, String>();
+ props.put("profile","default");
+
+ Operation operation = new Operation("add",address,props);
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ String result = mapper.writeValueAsString(operation);
+ System.out.println(result);
+
+ assert !result.contains("name") : "Result contains a name property but should not : " + result;
+ assert !result.contains("null") : "Result contains null values but should not : " + result;
+
+ Operation op = mapper.readValue(result,Operation.class);
+ assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation();
+
+ }
}
commit bb592ab259599fcb931b681ec083cce7ed492b9f
Merge: 80b2237 7a161e2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 29 17:30:04 2011 +0200
Merge branch 'master' into as7plugin
commit 80b2237cc9bb9fb01cd04c30dd3e13ee8f1e9244
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 29 13:36:38 2011 +0200
Rename class to better reflect its purpose.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
deleted file mode 100644
index 7c55233..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
+++ /dev/null
@@ -1,157 +0,0 @@
-package org.rhq.modules.plugins.jbossas7;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertyList;
-import org.rhq.core.domain.configuration.PropertyMap;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ProcessScanResult;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.plugins.jmx.JMXDiscoveryComponent;
-
-
-/**
- * Discovery class
- */
-public class BaseDiscovery implements ResourceDiscoveryComponent
-
-{
-
- static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
- static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
- private final Log log = LogFactory.getLog(this.getClass());
-
- /**
- * Run the auto-discovery
- */
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception {
- Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
-
-
- List<ProcessScanResult> scans = discoveryContext.getAutoDiscoveredProcesses();
-
- for (ProcessScanResult psr : scans) {
-
- Configuration config = discoveryContext.getDefaultPluginConfiguration();
- // IF SE, then look at domain/configuration/host.xml <management interface="default" port="9990
- // for management port
- String[] commandLine = psr.getProcessInfo().getCommandLine();
- String serverNameFull;
- String serverName;
- String psName = psr.getProcessScan().getName();
- if (psName.equals("ProcessManager")) {
- serverNameFull = "ProcessManager";
- serverName = "ProcessManager";
- } else if (psName.equals("ASManager")) {
- serverName = "ASManager";
- serverNameFull = "ASManager";
- } else if (psName.equals("HostController")) {
- serverName = "HostController";
- serverNameFull = "HostController";
- } else {
- serverNameFull = getBaseDirFromCommandLine(commandLine);
- if (serverNameFull==null || serverNameFull.isEmpty()) {
- // Try to obtain the server name
- // -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log
- // This is a hack until I know a better way to do so.
- String tmp = getLogFileFromCommandLine(commandLine);
- int i = tmp.indexOf("servers/");
- tmp = tmp.substring( i + 8);
- tmp = tmp.substring(0,tmp.indexOf("/"));
- serverNameFull = tmp;
- }
- serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
- if (serverName.isEmpty())
- serverName = serverNameFull;
-
- }
- String logFile = getLogFileFromCommandLine(commandLine);
- initLogEventSourcesConfigProp(logFile,config);
- String javaClazz = psr.getProcessInfo().getName();
-
-
- /*
- * We'll connect to the discovered VM on the local host, so set the jmx connection
- * properties accordingly. This may only work on JDK6+, but then JDK5 is deprecated
- * anyway.
- */
-// config.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
-// javaClazz));
- config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
- LocalVMTypeDescriptor.class.getName()));
-
- // TODO vmid will change when the detected server is bounced - how do we follow this?
- config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid()));
-
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- discoveryContext.getResourceType(), // ResourceType
- serverNameFull, // key TODO distinguish per domain?
- serverName, // Name
- null, // TODO real version ?
- "TODO", // Description
- config,
- psr.getProcessInfo()
- );
-
-
- // Add to return values
- discoveredResources.add(detail);
- log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverNameFull);
- }
-
- return discoveredResources;
-
- }
-
- String getBaseDirFromCommandLine(String[] commandLine) {
- for (String line: commandLine) {
- if (line.startsWith(DJBOSS_SERVER_BASE_DIR))
- return line.substring(DJBOSS_SERVER_BASE_DIR.length());
- }
- return "";
- }
-
-//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
-//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties
-
- String getLogFileFromCommandLine(String[] commandLine) {
-
- for (String line: commandLine) {
- if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
- return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length());
- }
- return "";
- }
-
- private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) {
-
- PropertyList logEventSources = pluginConfiguration
- .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP);
-
- if (logEventSources==null)
- return;
-
- File serverLogFile = new File(fileName);
-
- if (serverLogFile.exists() && !serverLogFile.isDirectory()) {
- PropertyMap serverLogEventSource = new PropertyMap("logEventSource");
- serverLogEventSource.put(new PropertySimple(
- LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile));
- serverLogEventSource.put(new PropertySimple(
- LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE));
- logEventSources.add(serverLogEventSource);
- }
- }
-
-}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
new file mode 100644
index 0000000..c38e297
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java
@@ -0,0 +1,157 @@
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.JMXDiscoveryComponent;
+
+
+/**
+ * Discovery class
+ */
+public class BaseProcessDiscovery implements ResourceDiscoveryComponent
+
+{
+
+ static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
+ static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ /**
+ * Run the auto-discovery
+ */
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+
+ List<ProcessScanResult> scans = discoveryContext.getAutoDiscoveredProcesses();
+
+ for (ProcessScanResult psr : scans) {
+
+ Configuration config = discoveryContext.getDefaultPluginConfiguration();
+ // IF SE, then look at domain/configuration/host.xml <management interface="default" port="9990
+ // for management port
+ String[] commandLine = psr.getProcessInfo().getCommandLine();
+ String serverNameFull;
+ String serverName;
+ String psName = psr.getProcessScan().getName();
+ if (psName.equals("ProcessManager")) {
+ serverNameFull = "ProcessManager";
+ serverName = "ProcessManager";
+ } else if (psName.equals("ASManager")) {
+ serverName = "ASManager";
+ serverNameFull = "ASManager";
+ } else if (psName.equals("HostController")) {
+ serverName = "HostController";
+ serverNameFull = "HostController";
+ } else {
+ serverNameFull = getBaseDirFromCommandLine(commandLine);
+ if (serverNameFull==null || serverNameFull.isEmpty()) {
+ // Try to obtain the server name
+ // -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log
+ // This is a hack until I know a better way to do so.
+ String tmp = getLogFileFromCommandLine(commandLine);
+ int i = tmp.indexOf("servers/");
+ tmp = tmp.substring( i + 8);
+ tmp = tmp.substring(0,tmp.indexOf("/"));
+ serverNameFull = tmp;
+ }
+ serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
+ if (serverName.isEmpty())
+ serverName = serverNameFull;
+
+ }
+ String logFile = getLogFileFromCommandLine(commandLine);
+ initLogEventSourcesConfigProp(logFile,config);
+ String javaClazz = psr.getProcessInfo().getName();
+
+
+ /*
+ * We'll connect to the discovered VM on the local host, so set the jmx connection
+ * properties accordingly. This may only work on JDK6+, but then JDK5 is deprecated
+ * anyway.
+ */
+// config.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
+// javaClazz));
+ config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
+ LocalVMTypeDescriptor.class.getName()));
+
+ // TODO vmid will change when the detected server is bounced - how do we follow this?
+ config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid()));
+
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ discoveryContext.getResourceType(), // ResourceType
+ serverNameFull, // key TODO distinguish per domain?
+ serverName, // Name
+ null, // TODO real version ?
+ "TODO", // Description
+ config,
+ psr.getProcessInfo()
+ );
+
+
+ // Add to return values
+ discoveredResources.add(detail);
+ log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverNameFull);
+ }
+
+ return discoveredResources;
+
+ }
+
+ String getBaseDirFromCommandLine(String[] commandLine) {
+ for (String line: commandLine) {
+ if (line.startsWith(DJBOSS_SERVER_BASE_DIR))
+ return line.substring(DJBOSS_SERVER_BASE_DIR.length());
+ }
+ return "";
+ }
+
+//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
+//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties
+
+ String getLogFileFromCommandLine(String[] commandLine) {
+
+ for (String line: commandLine) {
+ if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
+ return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length());
+ }
+ return "";
+ }
+
+ private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) {
+
+ PropertyList logEventSources = pluginConfiguration
+ .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP);
+
+ if (logEventSources==null)
+ return;
+
+ File serverLogFile = new File(fileName);
+
+ if (serverLogFile.exists() && !serverLogFile.isDirectory()) {
+ PropertyMap serverLogEventSource = new PropertyMap("logEventSource");
+ serverLogEventSource.put(new PropertySimple(
+ LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile));
+ serverLogEventSource.put(new PropertySimple(
+ LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE));
+ logEventSources.add(serverLogEventSource);
+ }
+ }
+
+}
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 2825e10..ee6b21f 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
@@ -59,7 +59,7 @@
-->
<server name="ProcessController"
- discovery="BaseDiscovery"
+ discovery="BaseProcessDiscovery"
class="BaseComponent"
description="Reaper process for other AS7 servicees"
>
@@ -80,6 +80,28 @@
</server>
+ <server name="HostController"
+ discovery="BaseProcessDiscovery"
+ class="BaseComponent"
+ description="Domain controller delegate for this host"
+ >
+
+ <plugin-configuration>
+ <c:simple-property name="hostname" default="localhost" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true"/>
+
+ &logSources;
+ </plugin-configuration>
+
+ <process-scan name="ProcessManager" query="process|basename|match=^java.*,arg|org.jboss.as.host-controller|match=.*"/>
+
+
+ <operation name="dummyOperation">
+ <!-- TODO supply parameters and return values -->
+ </operation>
+
+
+ </server>
<server name="Domain"
discovery="DomainDiscovery"
@@ -129,7 +151,7 @@
</server>
<server name="JBossAS7-Standalone"
- discovery="BaseDiscovery"
+ discovery="BaseProcessDiscovery"
class="BaseComponent"
>
@@ -165,7 +187,7 @@
</server>
<server name="JBossAS-Managed"
- discovery="BaseDiscovery"
+ discovery="BaseProcessDiscovery"
class="BaseComponent"
>
<plugin-configuration>
commit 800fe24b2eff29a7922a9b9a4ab1a309d352a077
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 29 13:24:29 2011 +0200
Better discover managed AS servers - get their name from the log file for now.
TODO: should we better query the DC, as this also knows the AS that are not auto-started.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
index 96737dd..7c55233 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
@@ -55,10 +55,21 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
} else if (psName.equals("ASManager")) {
serverName = "ASManager";
serverNameFull = "ASManager";
+ } else if (psName.equals("HostController")) {
+ serverName = "HostController";
+ serverNameFull = "HostController";
} else {
serverNameFull = getBaseDirFromCommandLine(commandLine);
- if (serverNameFull==null || serverNameFull.isEmpty())
- serverNameFull="JBossAS7";
+ if (serverNameFull==null || serverNameFull.isEmpty()) {
+ // Try to obtain the server name
+ // -Dorg.jboss.boot.log.file=domain/servers/server-one/log/boot.log
+ // This is a hack until I know a better way to do so.
+ String tmp = getLogFileFromCommandLine(commandLine);
+ int i = tmp.indexOf("servers/");
+ tmp = tmp.substring( i + 8);
+ tmp = tmp.substring(0,tmp.indexOf("/"));
+ serverNameFull = tmp;
+ }
serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
if (serverName.isEmpty())
serverName = serverNameFull;
commit ba753e1d0ce503b7252ae9e92cbdb9b810ec4519
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 28 22:12:31 2011 +0200
Add server-groups and hosts to the domain.
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 a2b5335..788531b 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
@@ -53,6 +53,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import com.sun.org.apache.xml.internal.security.utils.Base64;
+
public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet
{
private final Log log = LogFactory.getLog(this.getClass());
@@ -147,13 +149,22 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- BaseComponent parentComponent = (BaseComponent) context.getParentResourceComponent();
+ ResourceComponent parentResourceComponent = context.getParentResourceComponent();
+ String parentPath =null;
String myPath;
- String parentPath = parentComponent.getPath();
- if (parentPath.endsWith("/") || path.startsWith("/"))
- myPath = parentPath + path;
+ if (parentResourceComponent instanceof BaseComponent) {
+ BaseComponent parentComponent = (BaseComponent) parentResourceComponent;
+ parentPath = parentComponent.getPath();
+ }
+
+ if (parentPath!=null) {
+ if (parentPath.endsWith("/") || path.startsWith("/"))
+ myPath = parentPath + path;
+ else
+ myPath = parentPath + "/" + path;
+ }
else
- myPath = parentPath + "/" + path;
+ myPath = path;
JsonNode json = connection.getLevelData(myPath,true,false);
@@ -169,19 +180,30 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
if (sub!=null)
propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
else {
- propertySimple = new PropertySimple(propDef.getName(),null); // TODO store it at all?
+ propertySimple = new PropertySimple(propDef.getName(),null); // TODO store it at all when it is null?
}
ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
if (memberDefinition ==null) {
- Iterator<JsonNode> values = sub.getElements();
- while (values.hasNext()) {
- JsonNode node = values.next();
- String value = node.getTextValue();
- PropertySimple propertySimple = new PropertySimple(propDef.getName(),value);
- propertyList.add(propertySimple);
+ if (sub.isObject()) {
+ Iterator<String> fields = sub.getFieldNames();
+ while(fields.hasNext()) {
+ String fieldName = fields.next();
+ JsonNode subNode = sub.get(fieldName);
+ PropertySimple propertySimple = new PropertySimple(propDef.getName(),fieldName);
+ propertyList.add(propertySimple);
+ }
+ } else {
+ System.out.println("===Sub not object==="); // TODO evaluate this branch again
+ Iterator<JsonNode> values = sub.getElements();
+ while (values.hasNext()) {
+ JsonNode node = values.next();
+ String value = node.getTextValue();
+ PropertySimple propertySimple = new PropertySimple(propDef.getName(),value);
+ propertyList.add(propertySimple);
+ }
}
}
else if (memberDefinition instanceof PropertyDefinitionMap) {
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 8176e8a..2825e10 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
@@ -104,6 +104,26 @@
<c:simple-property name="path" default="/server-group/*" readOnly="true"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="profile" />
+ <c:simple-property name="socket-binding-group"/>
+ <c:simple-property name="jvm"/>
+ <c:simple-property name="deployment" required="false"/> <!-- TODO change structure. Or put below as resource? -->
+ </resource-configuration>
+ </server>
+ <server name="Host"
+ description="Host involved in this domain"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" default="/host/*" readOnly="true"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:list-property name="server-config" />
+ </resource-configuration>
+
</server>
</server>
@@ -128,11 +148,6 @@
<process-scan name="StandaloneAS" query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
- <operation name="dummyOperation">
- <!-- TODO supply parameters and return values -->
- </operation>
-
-
<resource-configuration>
<c:list-property name="schema-locations" displayName="Schema locations">
<c:map-property name="location">
@@ -162,17 +177,6 @@
<process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
-
- <metric property="serverGroup" dataType="trait" displayType="summary" />
- <resource-configuration>
- <!--<c:group name="interfaces">-->
- <c:simple-property name="loopback" default="127.0.0.1" />
- <c:simple-property name="external" default="any" />
- <c:simple-property name="public" default="any" />
- <!--</c:group>-->
- </resource-configuration>
-
-
</server>
@@ -290,6 +294,7 @@
<runs-inside>
<parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="Host" plugin="jboss-as-7"/>
<parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
</runs-inside>
commit 76830060b0233e12f319b7baae24fd23d850756d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 28 17:55:31 2011 +0200
More path handling improvements.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index c626c49..192a54f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -138,6 +138,9 @@ public class ASConnection {
boolean isErrorReply(JsonNode in) {
+ if (in == null)
+ return true;
+
if (in.has("outcome")) {
String outcome = null;
try {
@@ -262,6 +265,8 @@ public class ASConnection {
}
public String getFailureDescription(JsonNode jsonNode) {
+ if (jsonNode==null)
+ return "getFailureDescription: -input was null-";
JsonNode node = jsonNode.findValue("failure-description");
return node.getValueAsText();
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 9407172..a2b5335 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
@@ -147,7 +147,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- JsonNode json = connection.getLevelData(path,true,false); // TODO path ? key?
+ BaseComponent parentComponent = (BaseComponent) context.getParentResourceComponent();
+ String myPath;
+ String parentPath = parentComponent.getPath();
+ if (parentPath.endsWith("/") || path.startsWith("/"))
+ myPath = parentPath + path;
+ else
+ myPath = parentPath + "/" + path;
+
+
+ JsonNode json = connection.getLevelData(myPath,true,false);
Configuration ret = new Configuration();
ObjectMapper mapper = new ObjectMapper();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 4cde830..b577407 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -19,6 +19,7 @@
package org.rhq.modules.plugins.jbossas7;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -89,6 +90,8 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String subPath = path.substring(i+1);
JsonNode subNode = json.findPath(subPath);
+ if (subNode==null || subNode.isNull())
+ subNode = json.get(subPath); // TODO clean this up. to get the 'key' in a path from the AS we need to use get()
Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
@@ -97,7 +100,9 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String key = entry.getKey();
Subsystem subsystem = entry.getValue();
String newPath = cpath.replaceAll("\\*",key);
- config.getSimple("path").setStringValue(newPath);
+ Configuration config2 = context.getDefaultPluginConfiguration();
+ PropertySimple pathProp = new PropertySimple("path",newPath);
+ config2.put(pathProp);
String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
@@ -109,7 +114,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
name, // Name
null, // Version
subsystem.description, // Description
- config,
+ config2,
null);
details.add(detail);
}
@@ -120,7 +125,10 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String resKey = path;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
- config.getSimple("path").setStringValue(path);
+ Configuration config2 = context.getDefaultPluginConfiguration();
+ PropertySimple pathProp = new PropertySimple("path",path);
+ config2.put(pathProp);
+
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
@@ -129,7 +137,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
name, // Name
null, // Version
path, // Description
- config,
+ config2,
null);
details.add(detail);
}
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 654ee06..8176e8a 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
@@ -96,7 +96,7 @@
<c:simple-property name="path" default="/profile/*" readOnly="true"/>
</plugin-configuration>
</server>
- <server name="ServerGroups"
+ <server name="ServerGroup"
description="Server groups on this domain"
discovery="SubsystemDiscovery"
class="BaseComponent">
@@ -283,54 +283,54 @@
</server>
- <service name="NetworkInterface"
- discovery="InterfaceDiscovery"
- class="BaseComponent"
- description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
+ <service name="NetworkInterface"
+ discovery="InterfaceDiscovery"
+ class="BaseComponent"
+ description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
- <runs-inside>
- <parent-resource-type name="Domain" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
- </runs-inside>
+ <runs-inside>
+ <parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/"/>
- </plugin-configuration>
- </service>
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/"/>
+ </plugin-configuration>
+ </service>
- <service name="SocketBindingGroup"
- discovery="SocketBindingGroupDiscovery"
- class="BaseComponent"
- >
- <runs-inside>
- <parent-resource-type name="Domain" plugin="jboss-as-7"/>
- <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
- </runs-inside>
+ <service name="SocketBindingGroup"
+ discovery="SocketBindingGroupDiscovery"
+ class="BaseComponent"
+ >
+ <runs-inside>
+ <parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/socket-binding-group/"/>
- </plugin-configuration>
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/socket-binding-group/"/>
+ </plugin-configuration>
- <resource-configuration>
- <c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition" required="false"/>
- <!-- note: at domain level there is no port-offset -->
- <c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group" required="false"/>
- <c:list-property name="include">
- <c:simple-property name="binding" displayName="Included bindings" description="Other bindings that are included in this one"/>
- </c:list-property>
- <c:list-property name="socket-binding">
- <c:map-property name="binding">
- <c:simple-property name="name" description="The name of the socket. Services which need to access the socket configuration information will find it using this name."/>
- <c:simple-property name="interface" description="Name of the interface to which the socket should be bound, or, for multicast sockets, the interface on which it should listen. This should be one of the declared interfaces." required="false"/>
- <c:simple-property name="port" description="Number of the port to which the socket should be bound." type="integer"/>
- <c:simple-property name="fixed-port" description="Whether the port value should remain fixed even if numeric offsets are applied to the other sockets in the socket group." type="boolean"/>
- <c:simple-property name="multicast-address" description="Multicast address on which the socket should receive multicast traffic. If unspecified, the socket will not be configured to receive multicast." />
- <c:simple-property name="multicast-port" description="Port on which the socket should receive multicast traffic. Must be configured if 'multicast-address' is configured." type="integer"/>
- </c:map-property>
- </c:list-property>
- </resource-configuration>
+ <resource-configuration>
+ <c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition" required="false"/>
+ <!-- note: at domain level there is no port-offset -->
+ <c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group" required="false"/>
+ <c:list-property name="include">
+ <c:simple-property name="binding" displayName="Included bindings" description="Other bindings that are included in this one"/>
+ </c:list-property>
+ <c:list-property name="socket-binding">
+ <c:map-property name="binding">
+ <c:simple-property name="name" description="The name of the socket. Services which need to access the socket configuration information will find it using this name."/>
+ <c:simple-property name="interface" description="Name of the interface to which the socket should be bound, or, for multicast sockets, the interface on which it should listen. This should be one of the declared interfaces." required="false"/>
+ <c:simple-property name="port" description="Number of the port to which the socket should be bound." type="integer"/>
+ <c:simple-property name="fixed-port" description="Whether the port value should remain fixed even if numeric offsets are applied to the other sockets in the socket group." type="boolean"/>
+ <c:simple-property name="multicast-address" description="Multicast address on which the socket should receive multicast traffic. If unspecified, the socket will not be configured to receive multicast." />
+ <c:simple-property name="multicast-port" description="Port on which the socket should receive multicast traffic. Must be configured if 'multicast-address' is configured." type="integer"/>
+ </c:map-property>
+ </c:list-property>
+ </resource-configuration>
- </service>
+ </service>
</plugin>
commit cac8c1fe12745ceb5b72573800d27787bc6398c2
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 28 16:18:48 2011 +0200
Shuffle stuff around to support domain mode.
Add Domain discovery, improve handling of the "path" config element.
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 64e575b..9407172 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
@@ -155,8 +155,14 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
JsonNode sub = json.findValue(propDef.getName());
if (propDef instanceof PropertyDefinitionSimple) {
- PropertySimple propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
- ret.put(propertySimple);
+ PropertySimple propertySimple;
+
+ if (sub!=null)
+ propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
+ else {
+ propertySimple = new PropertySimple(propDef.getName(),null); // TODO store it at all?
+ }
+ ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
index e2d73c4..96737dd 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
@@ -1,23 +1,19 @@
package org.rhq.modules.plugins.jbossas7;
import java.io.File;
-import java.net.InetAddress;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ProcessScanResult;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -68,7 +64,7 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
serverName = serverNameFull;
}
- String logFile = getLogFieFromCommandLine(commandLine);
+ String logFile = getLogFileFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
String javaClazz = psr.getProcessInfo().getName();
@@ -118,7 +114,7 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties
- String getLogFieFromCommandLine(String[] commandLine) {
+ String getLogFileFromCommandLine(String[] commandLine) {
for (String line: commandLine) {
if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
new file mode 100644
index 0000000..ad09c77
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DomainDiscovery.java
@@ -0,0 +1,101 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Subsystem;
+
+/**
+ * Discover the domain
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class DomainDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
+
+ // TODO get next from some host.xml file
+ String host = "localhost";
+ String portString = "9990";
+ int port = Integer.parseInt(portString);
+ ASConnection connection = new ASConnection(host,port);
+
+
+ Configuration config = context.getDefaultPluginConfiguration();
+
+
+ // A domain has a server group so check for it.
+ boolean found = false;
+ JsonNode json = connection.getLevelData(null,null);
+ if (!connection.isErrorReply(json)) {
+
+ Iterator<String> fields = json.getFieldNames();
+ while (fields.hasNext()) {
+ String field = fields.next();
+ if (field.equals("server-group"))
+ found=true;
+
+ }
+
+ if (found) {
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ "Domain", // Key
+ "Domain", // Name
+ null, // Version
+ context.getResourceType().getDescription(), // Description
+ config,
+ null);
+ details.add(detail);
+ }
+
+ return details;
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index a017194..4cde830 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -63,6 +63,8 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String cpath = config.getSimpleValue("path", null);
boolean recursive = false;
+ String parentPath = parentComponent.getPath();
+
String path;
if (cpath.endsWith("/*")) {
path = cpath.substring(0,cpath.length()-2);
@@ -71,6 +73,14 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
else
path = cpath;
+ if (parentPath!=null && !parentPath.isEmpty()) {
+ if (parentPath.endsWith("/") || path.startsWith("/"))
+ path = parentPath + path;
+ else
+ path = parentPath + "/" + path;
+ }
+ System.out.println("total path: [" + path + "]");
+
JsonNode json = connection.getLevelData(path,recursive, false);
if (!connection.isErrorReply(json)) {
@@ -86,6 +96,8 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String key = entry.getKey();
Subsystem subsystem = entry.getValue();
+ String newPath = cpath.replaceAll("\\*",key);
+ config.getSimple("path").setStringValue(newPath);
String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
@@ -108,6 +120,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
String resKey = path;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+ config.getSimple("path").setStringValue(path);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
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 54fd4cf..654ee06 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
@@ -51,7 +51,7 @@
version="4.0.0-SNAPSHOT"
>
- <depends plugin="JMX"/>
+ <depends plugin="JMX" useClasses="true"/>
<!-- TODO I think we should introduce an abstract AS7 plugin that contains some base functionality and then
@@ -78,18 +78,33 @@
<!-- TODO supply parameters and return values -->
</operation>
- <!--
- <server name="ProcessManager JVM"
- description="JVM of the ProcessManager"
- sourcePlugin="JMX"
- sourceType="JMX Server"
- discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
- class="org.rhq.plugins.jmx.JMXServerComponent"
- singleton="true"
- />
- -->
+
+ </server>
+
+ <server name="Domain"
+ discovery="DomainDiscovery"
+ class="BaseComponent"
+ description="An AS7 management profile">
+ <server name="Profile"
+ description="One profile in a domain"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+
+ <plugin-configuration>
+ <c:simple-property name="path" default="/profile/*" readOnly="true"/>
+ </plugin-configuration>
+ </server>
+ <server name="ServerGroups"
+ description="Server groups on this domain"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" default="/server-group/*" readOnly="true"/>
+ </plugin-configuration>
+
+ </server>
</server>
@@ -116,16 +131,7 @@
<operation name="dummyOperation">
<!-- TODO supply parameters and return values -->
</operation>
- <!--
- <server name="JBoss AS standalone JVM"
- description="JVM of the standalone JBossAS"
- sourcePlugin="JMX"
- sourceType="JMX Server"
- discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
- class="org.rhq.plugins.jmx.JMXServerComponent"
- singleton="true"
- />
- -->
+
<resource-configuration>
<c:list-property name="schema-locations" displayName="Schema locations">
@@ -139,89 +145,154 @@
</c:list-property>
</resource-configuration>
- <server name="Messaging"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
+
+
+ </server>
+
+ <server name="JBossAS-Managed"
+ discovery="BaseDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="hostname" default="localhost" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true"/>
+
+ &logSources;
+ </plugin-configuration>
+
+ <process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
+
+
+ <metric property="serverGroup" dataType="trait" displayType="summary" />
+ <resource-configuration>
+ <!--<c:group name="interfaces">-->
+ <c:simple-property name="loopback" default="127.0.0.1" />
+ <c:simple-property name="external" default="any" />
+ <c:simple-property name="public" default="any" />
+ <!--</c:group>-->
+ </resource-configuration>
+
+
+ </server>
+
+
+<!--
+ <server name="JBoss AS JVM"
+ description="JVM of the standalone JBossAS"
+ sourcePlugin="JMX"
+ sourceType="JMX Server"
+ discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
+ class="org.rhq.plugins.jmx.JMXServerComponent"
+ singleton="true"
+ >
+ <runs-inside>
+ <parent-resource-type name="JBossAS-Managed" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ <parent-resource-type name="ProcessController" plugin="jboss-as-7"/>
+ </runs-inside>
+ </server>
+-->
+
+ <server name="Messaging"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="journal-min-files" />
+ <c:simple-property name="journal-type" />
+ </resource-configuration>
+
+
+ <service name="Acceptor"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
+ <c:simple-property name="path" readOnly="true" default="/acceptor"/>
</plugin-configuration>
- <resource-configuration>
- <c:simple-property name="journal-min-files" />
- <c:simple-property name="journal-type" />
- </resource-configuration>
+ </service>
- <service name="Acceptor"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/messaging/acceptor"/>
- </plugin-configuration>
+ </server>
+ <server name="JBossWeb"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ singleton="true"
+ >
- </service>
+ <runs-inside>
+ <parent-resource-type name="Profile" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
- </server>
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/web"/>
+ </plugin-configuration>
- <server name="JBossWeb"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- singleton="true"
+ <service name="Connector"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
>
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/web"/>
+ <c:simple-property name="path" readOnly="true" default="/connector/*"/>
</plugin-configuration>
- <service name="Connector"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/web/connector/*"/>
- </plugin-configuration>
-
- <metric property="bytesSent" measurementType="trendsup"/>
- <metric property="bytesReceived" measurementType="trendsup"/>
- <metric property="processingTime" measurementType="trendsup"/>
- <metric property="errorCount" measurementType="trendsup"/>
- <metric property="maxTime" />
- <metric property="requestCount" measurementType="trendsup"/>
+ <metric property="bytesSent" measurementType="trendsup"/>
+ <metric property="bytesReceived" measurementType="trendsup"/>
+ <metric property="processingTime" measurementType="trendsup"/>
+ <metric property="errorCount" measurementType="trendsup"/>
+ <metric property="maxTime" />
+ <metric property="requestCount" measurementType="trendsup"/>
- <resource-configuration>
- <c:simple-property name="protocol" required="false" description="The web connector protocol."/>
- <c:simple-property name="socket-binding" required="false" description="The web connector socket-binding reference, this connector should be bound to."/>
- <c:simple-property name="scheme" required="false" description="The web connector scheme"/>
- </resource-configuration>
+ <resource-configuration>
+ <c:simple-property name="protocol" required="false" description="The web connector protocol."/>
+ <c:simple-property name="socket-binding" required="false" description="The web connector socket-binding reference, this connector should be bound to."/>
+ <c:simple-property name="scheme" required="false" description="The web connector scheme"/>
+ </resource-configuration>
- </service>
+ </service>
- <service name="VHost"
- discovery="SubsystemDiscovery"
- class="BaseComponent">
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/web/virtual-server/*"/>
- </plugin-configuration>
+ <service name="VHost"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/virtual-server/*"/>
+ </plugin-configuration>
- <resource-configuration>
- <c:simple-property name="access-log"/>
- <c:list-property name="alias" description="The virtual server aliases"/>
- <c:simple-property name="rewrite"/>
- </resource-configuration>
+ <resource-configuration>
+ <c:simple-property name="access-log"/>
+ <c:list-property name="alias" description="The virtual server aliases"/>
+ <c:simple-property name="rewrite"/>
+ </resource-configuration>
- </service>
+ </service>
- </server>
+ </server>
<service name="NetworkInterface"
discovery="InterfaceDiscovery"
class="BaseComponent"
description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
+
+ <runs-inside>
+ <parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/"/>
</plugin-configuration>
@@ -231,13 +302,23 @@
discovery="SocketBindingGroupDiscovery"
class="BaseComponent"
>
+ <runs-inside>
+ <parent-resource-type name="Domain" plugin="jboss-as-7"/>
+ <parent-resource-type name="JBossAS7-Standalone" plugin="jboss-as-7"/>
+ </runs-inside>
+
+
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/socket-binding-group/"/>
</plugin-configuration>
<resource-configuration>
<c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition" required="false"/>
+ <!-- note: at domain level there is no port-offset -->
<c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group" required="false"/>
+ <c:list-property name="include">
+ <c:simple-property name="binding" displayName="Included bindings" description="Other bindings that are included in this one"/>
+ </c:list-property>
<c:list-property name="socket-binding">
<c:map-property name="binding">
<c:simple-property name="name" description="The name of the socket. Services which need to access the socket configuration information will find it using this name."/>
@@ -252,41 +333,4 @@
</service>
-
- </server>
-
- <server name="JBossAS-Managed"
- discovery="BaseDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="hostname" default="localhost" required="true"/>
- <c:simple-property name="port" default="9990" type="integer" required="true"/>
-
- &logSources;
- </plugin-configuration>
-
- <process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
-
-
- <metric property="serverGroup" dataType="trait" displayType="summary" />
- <resource-configuration>
- <!--<c:group name="interfaces">-->
- <c:simple-property name="loopback" default="127.0.0.1" />
- <c:simple-property name="external" default="any" />
- <c:simple-property name="public" default="any" />
- <!--</c:group>-->
- </resource-configuration>
-
- <server name="JBoss AS managed JVM"
- description="JVM of the managed JBossAS"
- sourcePlugin="JMX"
- sourceType="JMX Server"
- discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
- class="org.rhq.plugins.jmx.JMXServerComponent"
- singleton="true"
- />
-
- </server>
-
</plugin>
commit cab2192295a5186955f23713b763e32b6e64c8bc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 25 17:39:22 2011 +0100
Convert extensions to a list of simple props.
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 8d3a7a8..64e575b 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
@@ -247,6 +247,16 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
}
}
+ else if (memberDefinition instanceof PropertyDefinitionSimple) {
+ String name = memberDefinition.getName();
+ Iterator<String> keys = sub.getFieldNames();
+ while(keys.hasNext()) {
+ String entryKey = keys.next();
+
+ PropertySimple propertySimple = new PropertySimple(name,entryKey);
+ propertyList.add(propertySimple);
+ }
+ }
ret.put(propertyList);
}
}
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 6a00d57..54fd4cf 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
@@ -135,9 +135,7 @@
</c:map-property>
</c:list-property>
<c:list-property name="extension" displayName="Installed extensions">
- <c:map-property name="extension">
- <c:simple-property name="name" readOnly="true"/>
- </c:map-property>
+ <c:simple-property name="name" readOnly="true"/>
</c:list-property>
</resource-configuration>
commit 73ebc9d575c836294ac6f45df3e662c325def109
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 25 17:00:06 2011 +0100
Support /extension and /schema-locations as resource config on AS
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 50bd98d..c626c49 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -194,7 +194,6 @@ public class ASConnection {
while ((line = in.readLine()) != null) {
builder.append(line);
}
-// System.out.println(builder.toString());
in.close();
}
else {
@@ -207,11 +206,12 @@ public class ASConnection {
while ((line = br.readLine()) != null) {
builder.append(line);
}
-// System.out.println(builder.toString());
br.close();
}
}
- JsonNode operationResult = mapper.readTree(builder.toString());
+ String outcome = builder.toString();
+ System.out.println("==> " + outcome);
+ JsonNode operationResult = mapper.readTree(outcome);
return operationResult;
} catch (IOException e) {
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 a4c388f..8d3a7a8 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
@@ -21,6 +21,7 @@ package org.rhq.modules.plugins.jbossas7;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
@@ -45,8 +46,10 @@ import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -61,7 +64,6 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
String path;
String key;
-
/**
* Return availability of this resource
* @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
@@ -145,9 +147,10 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- JsonNode json = connection.getLevelData(key,true,false); // TODO path ? key?
+ JsonNode json = connection.getLevelData(path,true,false); // TODO path ? key?
Configuration ret = new Configuration();
+ ObjectMapper mapper = new ObjectMapper();
for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
JsonNode sub = json.findValue(propDef.getName());
@@ -156,7 +159,8 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
- if (((PropertyDefinitionList) propDef).getMemberDefinition()==null) {
+ PropertyDefinition memberDefinition = ((PropertyDefinitionList) propDef).getMemberDefinition();
+ if (memberDefinition ==null) {
Iterator<JsonNode> values = sub.getElements();
while (values.hasNext()) {
JsonNode node = values.next();
@@ -165,20 +169,82 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
propertyList.add(propertySimple);
}
}
- else if (((PropertyDefinitionList) propDef).getMemberDefinition() instanceof PropertyDefinitionMap) {
- Iterator<String> entries = sub.getFieldNames();
- while (entries.hasNext()) {
- String entryKey = entries.next();
- JsonNode node = sub.findPath(entryKey);
- PropertyMap map = new PropertyMap(((PropertyDefinitionList) propDef).getMemberDefinition().getName()); // TODO : name from def or 'entryKey' ?
- Iterator<String> fields = node.getFieldNames(); // TODO loop over fields from map and not from json
- while (fields.hasNext()) {
- String key = fields.next();
-
- PropertySimple propertySimple = new PropertySimple(key,node.findValue(key).getValueAsText());
- map.put(propertySimple);
+ else if (memberDefinition instanceof PropertyDefinitionMap) {
+ PropertySimple propertySimple;
+
+ if (sub.isArray()) {
+ Iterator<JsonNode> entries = sub.getElements();
+ while (entries.hasNext()) {
+ JsonNode entry = entries.next(); // -> one row in the list i.e. one map
+
+ // Distinguish here?
+
+ PropertyMap map = new PropertyMap(memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
+ Iterator<JsonNode> fields = entry.getElements(); // TODO loop over fields from map and not from json
+ while (fields.hasNext()) {
+ JsonNode field = fields.next();
+ if (field.isObject()) {
+ // TODO only works for tuples at the moment - migrate to some different kind of parsing!
+ PROPERTY_VALUE prop = mapper.readValue(field,PROPERTY_VALUE.class);
+ // now need to find the names of the properties
+ List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
+ if (defList.isEmpty())
+ throw new IllegalArgumentException("Map " + memberDefinition.getName() + " has no members");
+ String key = defList.get(0).getName();
+ String value = prop.getKey();
+ propertySimple = new PropertySimple(key,value);
+ map.put(propertySimple);
+ if (defList.size()>1) {
+ key = defList.get(1).getName();
+ value = prop.getValue();
+ propertySimple = new PropertySimple(key,value);
+ map.put(propertySimple);
+
+ }
+ } else { // TODO reached?
+ String key = field.getValueAsText();
+ if (key.equals("PROPERTY_VALUE")) { // TODO this may change in the future in the AS implementation
+ JsonNode pv = entry.findValue(key);
+ String k = pv.toString();
+ String v = pv.getValueAsText();
+ propertySimple = new PropertySimple(k,v);
+ map.put(propertySimple);
+
+ }
+ else {
+ propertySimple = new PropertySimple(key,entry.findValue(key).getValueAsText());
+ map.put(propertySimple);
+
+ }
+ }
+ }
+ propertyList.add(map);
+ }
+ }
+ else if (sub.isObject()) {
+ Iterator<String> keys = sub.getFieldNames();
+ while(keys.hasNext()) {
+ String entryKey = keys.next();
+
+ JsonNode node = sub.findPath(entryKey);
+ PropertyMap map = new PropertyMap(memberDefinition.getName()); // TODO : name from def or 'entryKey' ?
+ if (node.isObject()) {
+ Iterator<String> fields = node.getFieldNames(); // TODO loop over fields from map and not from json
+ while (fields.hasNext()) {
+ String key = fields.next();
+
+ propertySimple = new PropertySimple(key,node.findValue(key).getValueAsText());
+ map.put(propertySimple);
+ }
+ propertyList.add(map);
+ } else if (sub.isNull()) {
+ List<PropertyDefinition> defList = ((PropertyDefinitionMap) memberDefinition).getSummaryPropertyDefinitions();
+ String key = defList.get(0).getName();
+ propertySimple = new PropertySimple(key,entryKey);
+ map.put(propertySimple);
+ }
}
- propertyList.add(map);
+
}
}
ret.put(propertyList);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
index 571dbab..e2d73c4 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
@@ -67,17 +67,6 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
if (serverName.isEmpty())
serverName = serverNameFull;
-// DomainClient client = DomainClient.Factory.create(InetAddress.getByName("localhost"),9990); //
-// Map<ServerIdentity,ServerStatus> serverStatuses = client.getServerStatuses();
-// for (Map.Entry<ServerIdentity,ServerStatus> entry : serverStatuses.entrySet()) {
-// ServerIdentity identity = entry.getKey();
-// ServerStatus status = entry.getValue();
-// if (identity.getServerName().equals(serverName)) {
-// String serverGroupName = identity.getServerGroupName();
-// config.put(new PropertySimple("server-group",serverGroupName));
-// }
-//
-// }
}
String logFile = getLogFieFromCommandLine(commandLine);
initLogEventSourcesConfigProp(logFile,config);
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
index fdc04c6..f145aa6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
@@ -30,6 +30,8 @@ public class NameValuePair {
public String name;
public String value;
+ public NameValuePair() {}
+
public NameValuePair(String name, String value) {
this.name = name;
this.value = value;
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 7abbfeb..6a00d57 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
@@ -127,9 +127,25 @@
/>
-->
+ <resource-configuration>
+ <c:list-property name="schema-locations" displayName="Schema locations">
+ <c:map-property name="location">
+ <c:simple-property name="urn" readOnly="true"/>
+ <c:simple-property name="location" readOnly="true"/>
+ </c:map-property>
+ </c:list-property>
+ <c:list-property name="extension" displayName="Installed extensions">
+ <c:map-property name="extension">
+ <c:simple-property name="name" readOnly="true"/>
+ </c:map-property>
+ </c:list-property>
+ </resource-configuration>
+
<server name="Messaging"
discovery="SubsystemDiscovery"
- class="BaseComponent">
+ class="BaseComponent"
+ singleton="true"
+ >
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
</plugin-configuration>
@@ -156,6 +172,7 @@
<server name="JBossWeb"
discovery="SubsystemDiscovery"
class="BaseComponent"
+ singleton="true"
>
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/subsystem/web"/>
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
index 4082612..4909595 100644
--- a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -51,13 +51,12 @@ public class OperationJsonTest {
String result = mapper.writeValueAsString(operation);
- System.out.println(operation);
- System.out.println(result);
-
Operation op = mapper.readValue(result,Operation.class);
assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation();
assert op.getName().equals("socket-binding") : "attribute name is " + op.getName();
assert op.getValue().equals("jndi") : "attribute value is " + op.getValue();
+ assert op.getAddress().size()==2 : "Address did not contain 2 parts, but " + op.getAddress().size();
+
}
commit 8256274472de89eeb3f733de08ff79740d7fca7e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 25 13:17:55 2011 +0100
Improve support for execute operations on AS
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 663df43..50bd98d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -51,6 +51,7 @@ public class ASConnection {
private String host;
URL url;
String urlString;
+ private StringBuilder builder;
public ASConnection(String host, int port) {
this.host = host;
@@ -157,18 +158,23 @@ public class ASConnection {
return false;
}
- public void execute(String path, String operationName, NameValuePair nvp) {
+ /**
+ * Execute an operation against the domain api
+ * @param path Node to manipulate
+ * @param operationName operation to run
+ * @param attributeValue attribute-name-value pair
+ */
+ public JsonNode execute(String path, String operationName, NameValuePair attributeValue) {
try {
- URL url = getBaseUrl(path,"operation="+operationName);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
-// conn.setRequestMethod("POST");
+ conn.setRequestMethod("POST");
OutputStream out = conn.getOutputStream();
ObjectMapper mapper = new ObjectMapper();
- Operation operation = new Operation(operationName,pathToAddress(path),nvp);
+ Operation operation = new Operation(operationName,pathToAddress(path),attributeValue);
String result = mapper.writeValueAsString(operation);
System.out.println("Json to send: " + result);
@@ -184,17 +190,35 @@ public class ASConnection {
BufferedReader in = new BufferedReader(new InputStreamReader(
inputStream));
String line;
- StringBuilder builder = new StringBuilder();
+ builder = new StringBuilder();
while ((line = in.readLine()) != null) {
builder.append(line);
}
- System.out.println(builder.toString());
+// System.out.println(builder.toString());
+ in.close();
}
+ else {
+ System.out.println(conn.getResponseCode());
+ InputStream errorStream = conn.getErrorStream();
+ if (errorStream!=null) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(errorStream));
+ String line;
+ builder = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ builder.append(line);
+ }
+// System.out.println(builder.toString());
+ br.close();
+ }
+ }
+ JsonNode operationResult = mapper.readTree(builder.toString());
+ return operationResult;
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
}
+ return null;
}
private List<PROPERTY_VALUE> pathToAddress(String path) {
@@ -237,4 +261,9 @@ public class ASConnection {
return url2;
}
+ public String getFailureDescription(JsonNode jsonNode) {
+ JsonNode node = jsonNode.findValue("failure-description");
+ return node.getValueAsText();
+
+ }
}
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 ad3516e..a4c388f 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
@@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.ConfigurationUpdateStatus;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -195,10 +196,12 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
for (Map.Entry<String, PropertySimple> entry : conf.getSimpleProperties().entrySet()) {
NameValuePair nvp = new NameValuePair(entry.getKey(),entry.getValue().getStringValue());
- connection.execute(path,"write-attribute",nvp);
+ JsonNode result= connection.execute(key,"write-attribute",nvp); // TODO path / key handling
+ if(connection.isErrorReply(result)) {
+ report.setStatus(ConfigurationUpdateStatus.FAILURE);
+ report.setErrorMessage(connection.getFailureDescription(result));
+ }
}
-
- // TODO: Customise this generated block
}
}
commit 0b87441a0a79ca22d01456a293213902b001795b
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri Mar 25 12:00:32 2011 +0100
Implement serialization and deserialization of Operation to/from json.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index ef75ab7..38cdfa0 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -30,8 +30,8 @@
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
</configuration>
</plugin>
<plugin>
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 0fb28b1..663df43 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -35,8 +35,8 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.jetbrains.annotations.Nullable;
-import org.omg.CORBA.NamedValue;
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import org.rhq.modules.plugins.jbossas7.json.Operation;
@@ -157,10 +157,10 @@ public class ASConnection {
return false;
}
- public void execute(String path, String s, NameValuePair nvp) {
+ public void execute(String path, String operationName, NameValuePair nvp) {
try {
- URL url = getBaseUrl(path,"operation="+s);
+ URL url = getBaseUrl(path,"operation="+operationName);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
// conn.setRequestMethod("POST");
@@ -168,11 +168,7 @@ public class ASConnection {
ObjectMapper mapper = new ObjectMapper();
- Operation operation = new Operation();
- operation.operation=s;
- operation.nvp=nvp;
- operation.address=pathToAddress(path);
-
+ Operation operation = new Operation(operationName,pathToAddress(path),nvp);
String result = mapper.writeValueAsString(operation);
System.out.println("Json to send: " + result);
@@ -201,17 +197,17 @@ public class ASConnection {
}
- private List<NameValuePair> pathToAddress(String path) {
+ private List<PROPERTY_VALUE> pathToAddress(String path) {
if (path.endsWith("/"))
path = path.substring(0,path.length()-1);
if (path.startsWith("/"))
path = path.substring(1);
- List<NameValuePair> result = new ArrayList<NameValuePair>();
+ List<PROPERTY_VALUE> result = new ArrayList<PROPERTY_VALUE>();
String[] components = path.split("/");
for (int i = 0; i < components.length ; i+=2) {
- NameValuePair valuePair = new NameValuePair(components[i],components[i+1]);
+ PROPERTY_VALUE valuePair = new PROPERTY_VALUE(components[i],components[i+1]);
result.add(valuePair);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
index ff3f10c..fdc04c6 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
@@ -18,6 +18,7 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonValue;
/**
@@ -34,9 +35,4 @@ public class NameValuePair {
this.value = value;
}
- @JsonValue
- @Override
- public String toString() {
- return name +":"+ value ;
- }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index 4f5cda1..642b41f 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -18,8 +18,11 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonValue;
/**
@@ -28,20 +31,99 @@ import org.codehaus.jackson.annotate.JsonValue;
*/
public class Operation {
- public String operation;
- public List<NameValuePair> address;
+ public Operation(String operation, List<PROPERTY_VALUE> address, NameValuePair payload) {
+ this.operation = operation;
+ this.address = address;
+ this.name = payload.name;
+ this.value = payload.value;
+ }
+
+ public Operation() {
+ // needed for Jackson
+ }
+
+ private String operation;
+ @JsonProperty
+ private List<PROPERTY_VALUE> address = Collections.emptyList();
+
+ private String name;
+ private String value;
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
- public NameValuePair nvp;
+ public List<PROPERTY_VALUE> getAddress() {
+ return address;
+ }
+
+ public void setAddress(List<PROPERTY_VALUE> address) {
+ this.address = address;
+ }
- @JsonValue
- public String toString() {
- StringBuilder b = new StringBuilder();
- b.append("{");
- b.append("operation:").append(operation).append(",\n");
- b.append("address:").append(address).append(",\n");
- b.append(nvp);
- b.append("}");
- return b.toString();
+ public List<PROPERTY_VALUE> addToAddress(PROPERTY_VALUE component) {
+ if (address==null)
+ address = new ArrayList<PROPERTY_VALUE>();
+ address.add(component);
+ return address;
}
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /*
+ [localhost:9999 /subsystem=web/connector=http] :write-attribute(name=socket-binding,value=jndi)
+ yield JSON to send:
+ {
+ "operation" : "write-attribute",
+ "name" : "socket-binding",
+ "value" : "jndi",
+ "address" : [
+ {
+ "PROPERTY_VALUE" : {
+ "subsystem" : "web"
+ }
+ },
+ {
+ "PROPERTY_VALUE" : {
+ "connector" : "http"
+ }
+ }
+ ]
+ }
+ */
+
+// @JsonValue
+// public String toString() {
+// StringBuilder b = new StringBuilder();
+// b.append('{');
+// b.append("\"operation\":\"").append(operation).append("\",");
+// b.append("\"address\":");
+// if (address!=null && !address.isEmpty())
+// b.append(address);
+// else
+// b.append("[]");
+// b.append(',');
+// b.append(payload);
+// b.append("}");
+// return b.toString();
+// }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
new file mode 100644
index 0000000..b2c8223
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/PROPERTY_VALUE.java
@@ -0,0 +1,62 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.io.Serializable;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.annotate.JsonValue;
+import org.codehaus.jackson.map.annotate.JsonDeserialize;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import org.rhq.modules.plugins.jbossas7.json.serializer.PropertyValueDeserializer;
+import org.rhq.modules.plugins.jbossas7.json.serializer.PropertyValueSerializer;
+
+/**
+ * @author Heiko W. Rupp
+ */
+@JsonSerialize(using = PropertyValueSerializer.class)
+@JsonDeserialize(using = PropertyValueDeserializer.class)
+public class PROPERTY_VALUE implements Serializable{
+
+ private String key;
+ private String value;
+
+ public PROPERTY_VALUE(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java
new file mode 100644
index 0000000..11e6ae3
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueDeserializer.java
@@ -0,0 +1,53 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json.serializer;
+
+import java.io.IOException;
+import java.lang.ref.PhantomReference;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.JsonDeserializer;
+
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Deserialize {"foo":"bar"} into a PROPERTY_VALUE
+ * @author Heiko W. Rupp
+ */
+public class PropertyValueDeserializer extends JsonDeserializer<PROPERTY_VALUE> {
+
+
+ @Override
+ public PROPERTY_VALUE deserialize(JsonParser jsonParser,
+ DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
+
+ String tmp = jsonParser.getText(); // {
+ jsonParser.nextToken();
+ String key = jsonParser.getText();
+ jsonParser.nextToken();
+ String value = jsonParser.getText();
+ jsonParser.nextToken();
+ tmp = jsonParser.getText(); // }
+
+ PROPERTY_VALUE pv = new PROPERTY_VALUE(key,value);
+ return pv;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java
new file mode 100644
index 0000000..e7dda18
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/serializer/PropertyValueSerializer.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json.serializer;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+
+/**
+ * Serialize the key/value pair from PROPERTY_VALUE into {"value of key":"value of value"}
+ * @author Heiko W. Rupp
+ */
+public class PropertyValueSerializer extends JsonSerializer<PROPERTY_VALUE> {
+
+ @Override
+ public void serialize(PROPERTY_VALUE property_value, JsonGenerator jsonGenerator,
+ SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
+
+ jsonGenerator.writeStartObject();
+ jsonGenerator.writeFieldName(property_value.getKey());
+ jsonGenerator.writeString(property_value.getValue());
+ jsonGenerator.writeEndObject();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
new file mode 100644
index 0000000..4082612
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/test/java/org/rhq/modules/plugins/jbossas7/OperationJsonTest.java
@@ -0,0 +1,74 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.testng.annotations.Test;
+
+import org.rhq.modules.plugins.jbossas7.json.PROPERTY_VALUE;
+import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
+
+/**
+ * @author Heiko W. Rupp
+ */
+@Test
+public class OperationJsonTest {
+
+
+ public void operationSerDeserTest() throws Exception{
+
+ List<PROPERTY_VALUE> address=new ArrayList<PROPERTY_VALUE>(2);
+ PROPERTY_VALUE part = new PROPERTY_VALUE("subsystem","web");
+ address.add(part);
+ part = new PROPERTY_VALUE("connector","http");
+ address.add(part);
+
+ NameValuePair payload = new NameValuePair("socket-binding","jndi");
+ Operation operation = new Operation("write-attribute",address,payload);
+
+
+ ObjectMapper mapper = new ObjectMapper();
+
+ String result = mapper.writeValueAsString(operation);
+
+ System.out.println(operation);
+ System.out.println(result);
+
+ Operation op = mapper.readValue(result,Operation.class);
+ assert op.getOperation().equals(operation.getOperation()) : "Operation is " + op.getOperation();
+ assert op.getName().equals("socket-binding") : "attribute name is " + op.getName();
+ assert op.getValue().equals("jndi") : "attribute value is " + op.getValue();
+
+ }
+
+ public void propertyValueDeserTest() throws Exception {
+
+ String json = "{\"myKey\":\"myValue\"}";
+
+ ObjectMapper mapper = new ObjectMapper();
+ PROPERTY_VALUE pv = mapper.readValue(json,PROPERTY_VALUE.class);
+
+ assert pv.getKey().equals("myKey") : "Key is " + pv.getKey();
+ assert pv.getValue().equals("myValue"): "Value is " + pv.getValue();
+ }
+}
commit 4c3726f4046e43d05e96cb71e413c6e6356db298
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 24 13:13:49 2011 +0100
Support reading metrics.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index c136b20..0fb28b1 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -130,6 +130,11 @@ public class ASConnection {
return tree;
}
+ JsonNode getAttributeValue(@Nullable String base, @Nullable String attributeName) throws Exception {
+ String op = "operation=attribute&name=" + attributeName;
+ return getLevelData(base,op);
+ }
+
boolean isErrorReply(JsonNode in) {
if (in.has("outcome")) {
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 f700597..ad3516e 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
@@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
@@ -44,13 +43,9 @@ import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
import org.rhq.core.pluginapi.measurement.MeasurementFacet;
-import org.rhq.core.pluginapi.operation.OperationContext;
-import org.rhq.core.pluginapi.operation.OperationFacet;
-import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -117,26 +112,24 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
/**
* Gather measurement data
- * @see org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport, java.util.Set)
+ * @see org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport, java.util.Set)
*/
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
- JsonNode obj = connection.getLevelData(key,false,true);
for (MeasurementScheduleRequest req : metrics) {
- if (obj.has(req.getName())) {
-/*
- String val = obj.getString(req.getName());
- if (req.getDataType()== DataType.MEASUREMENT) {
-
- Double d = Double.parseDouble(val);
- MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
- report.addData(data);
- } else if (req.getDataType()== DataType.TRAIT) {
- MeasurementDataTrait data = new MeasurementDataTrait(req,val);
- report.addData(data);
- }
-*/
+
+ JsonNode obj = connection.getAttributeValue(key, req.getName()); // TODO batching
+
+ String val = obj.getValueAsText();
+ if (req.getDataType()== DataType.MEASUREMENT) {
+
+ Double d = Double.parseDouble(val);
+ MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
+ report.addData(data);
+ } else if (req.getDataType()== DataType.TRAIT) {
+ MeasurementDataTrait data = new MeasurementDataTrait(req,val);
+ report.addData(data);
}
}
}
commit bbee70600f8faf000892e14a5fdea2a749f0bfb6
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 24 09:49:46 2011 +0100
Bindings are now a list of maps within the binding group.
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 28c0592..f700597 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
@@ -25,10 +25,12 @@ import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
@@ -149,7 +151,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- JsonNode json = connection.getLevelData(key,false,false); // TODO path ? key?
+ JsonNode json = connection.getLevelData(key,true,false); // TODO path ? key?
Configuration ret = new Configuration();
@@ -160,12 +162,30 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
ret.put(propertySimple);
} else if (propDef instanceof PropertyDefinitionList) {
PropertyList propertyList = new PropertyList(propDef.getName());
- Iterator<JsonNode> values = sub.getElements();
- while (values.hasNext()) {
- JsonNode node = values.next();
- String value = node.getTextValue();
- PropertySimple propertySimple = new PropertySimple(propDef.getName(),value);
- propertyList.add(propertySimple);
+ if (((PropertyDefinitionList) propDef).getMemberDefinition()==null) {
+ Iterator<JsonNode> values = sub.getElements();
+ while (values.hasNext()) {
+ JsonNode node = values.next();
+ String value = node.getTextValue();
+ PropertySimple propertySimple = new PropertySimple(propDef.getName(),value);
+ propertyList.add(propertySimple);
+ }
+ }
+ else if (((PropertyDefinitionList) propDef).getMemberDefinition() instanceof PropertyDefinitionMap) {
+ Iterator<String> entries = sub.getFieldNames();
+ while (entries.hasNext()) {
+ String entryKey = entries.next();
+ JsonNode node = sub.findPath(entryKey);
+ PropertyMap map = new PropertyMap(((PropertyDefinitionList) propDef).getMemberDefinition().getName()); // TODO : name from def or 'entryKey' ?
+ Iterator<String> fields = node.getFieldNames(); // TODO loop over fields from map and not from json
+ while (fields.hasNext()) {
+ String key = fields.next();
+
+ PropertySimple propertySimple = new PropertySimple(key,node.findValue(key).getValueAsText());
+ map.put(propertySimple);
+ }
+ propertyList.add(map);
+ }
}
ret.put(propertyList);
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
deleted file mode 100644
index c9b7a5e..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
-import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
-import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
-import org.rhq.modules.plugins.jbossas7.json.Domain;
-import org.rhq.modules.plugins.jbossas7.json.SocketBindingGroup;
-
-/**
- * Discover single bindings in a socket binding group
- *
- * TODO: Is this better a resource-configuration on the parent?
- *
- * @author Heiko W. Rupp
- */
-@SuppressWarnings("unused")
-public class SocketBindingDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
-
- private final Log log = LogFactory.getLog(this.getClass());
-
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
- throws Exception {
-
- Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
-
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
- mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
-
- BaseComponent parentComponent = context.getParentResourceComponent();
- ASConnection connection = parentComponent.getASConnection();
-
- String path = parentComponent.getPath();
-
-
- JsonNode json = connection.getLevelData(path,true,false);
- if (!connection.isErrorReply(json)) {
-
- SocketBindingGroup bindingGroup = mapper.readValue(json, new TypeReference<SocketBindingGroup>() {});
- // TODO put bindingGroup. {name, default-interface, port-offset into parent
-
-
- for (Map.Entry<String,SocketBindingGroup.Binding> entry: bindingGroup.bindings.entrySet()) {
-
- String key = entry.getKey();
- String cpath = path + "/socket-binding/" + key;
-
-
- String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
- String name = resKey.substring(resKey.lastIndexOf("/") + 1);
-
- Configuration config = context.getDefaultPluginConfiguration();
-
- PropertySimple propertySimple = new PropertySimple("path",cpath);
- config.put(propertySimple);
-
- DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // DataType
- path, // Key
- name, // Name
- null, // Version
- "Binding Group", // Description
- config,
- null);
- details.add(detail);
- log.info("Added " + detail);
- }
-
- return details;
-
- }
-
- return Collections.emptySet();
- }
-
-}
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 9a04f04..7abbfeb 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
@@ -223,16 +223,18 @@
<resource-configuration>
<c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition" required="false"/>
<c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group" required="false"/>
+ <c:list-property name="socket-binding">
+ <c:map-property name="binding">
+ <c:simple-property name="name" description="The name of the socket. Services which need to access the socket configuration information will find it using this name."/>
+ <c:simple-property name="interface" description="Name of the interface to which the socket should be bound, or, for multicast sockets, the interface on which it should listen. This should be one of the declared interfaces." required="false"/>
+ <c:simple-property name="port" description="Number of the port to which the socket should be bound." type="integer"/>
+ <c:simple-property name="fixed-port" description="Whether the port value should remain fixed even if numeric offsets are applied to the other sockets in the socket group." type="boolean"/>
+ <c:simple-property name="multicast-address" description="Multicast address on which the socket should receive multicast traffic. If unspecified, the socket will not be configured to receive multicast." />
+ <c:simple-property name="multicast-port" description="Port on which the socket should receive multicast traffic. Must be configured if 'multicast-address' is configured." type="integer"/>
+ </c:map-property>
+ </c:list-property>
</resource-configuration>
- <service name="SocketBinding"
- discovery="SocketBindingDiscovery"
- class="BaseComponent">
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true"/>
- </plugin-configuration>
-
- </service>
</service>
commit 296dba2916369ca75012995cbf7aa1863745e9b0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 23 21:19:19 2011 +0100
Fix naming for 'singleton' subsystems
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 75683cb..a017194 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -106,7 +106,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
else {
- String resKey = context.getParentResourceContext().getResourceKey();
+ String resKey = path;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
commit 3a14db1b4c745bd66b863f872c3fd062bb296f9f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 23 21:09:45 2011 +0100
SubsystemComponent is (currently) not needed.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
index abf6d35..d23cd5d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
@@ -28,9 +28,9 @@ import org.rhq.core.pluginapi.inventory.ResourceContext;
*
* @author Heiko W. Rupp
*/
-public class DatasourceComponent implements ResourceComponent<SubsystemComponent> {
+public class DatasourceComponent implements ResourceComponent<BaseComponent> {
- public void start(ResourceContext<SubsystemComponent> subsystemComponentResourceContext) throws InvalidPluginConfigurationException, Exception {
+ public void start(ResourceContext<BaseComponent> subsystemComponentResourceContext) throws InvalidPluginConfigurationException, Exception {
// TODO: Customise this generated block
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
index d756543..e205c29 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
@@ -32,9 +32,9 @@ import java.util.Set;
*
* @author Heiko W. Rupp
*/
-public class DatasourceDiscovery implements ResourceDiscoveryComponent<SubsystemComponent> {
+public class DatasourceDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
- public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<SubsystemComponent> discoveryContext) throws InvalidPluginConfigurationException, Exception {
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> discoveryContext) throws InvalidPluginConfigurationException, Exception {
/*
if (subsys instanceof DataSourcesSubsystemElement) {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java
deleted file mode 100644
index 09d753c..0000000
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.modules.plugins.jbossas7;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.measurement.AvailabilityType;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
-import org.rhq.core.pluginapi.inventory.ResourceComponent;
-import org.rhq.core.pluginapi.inventory.ResourceContext;
-
-/**
- * Resource component for subsystems
- *
- * Deprecated - use BaseComponent
- * @author Heiko W. Rupp
- */
-@Deprecated
-public class SubsystemComponent implements ResourceComponent<BaseComponent> {
-
- ResourceContext<BaseComponent> context;
- Configuration config;
- String path;
- String key ;
-
- public void start(ResourceContext<BaseComponent> context) throws InvalidPluginConfigurationException, Exception {
- this.config = context.getPluginConfiguration();
- path = config.getSimpleValue("path", null);
- this.context = context;
- key = context.getResourceKey();
-
- }
-
- public void stop() {
- // TODO: Customise this generated block
- }
-
- public AvailabilityType getAvailability() {
- return AvailabilityType.UP; // TODO: Customise this generated block
- }
-
-
-}
commit f70a35bfea7d230783b3079a2d16edcf0b60adb0
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 23 16:47:25 2011 +0100
Include more items and allow for reading of list properties.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 005421d..c136b20 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -23,17 +23,22 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.jetbrains.annotations.Nullable;
+import org.omg.CORBA.NamedValue;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import org.rhq.modules.plugins.jbossas7.json.Operation;
/**
* Provide connections to the AS and reading / writing date from/to it.
@@ -83,7 +88,7 @@ public class ASConnection {
* Return the JSON-Ojbect for a certain path.
*
* @param base Path to the object/subsystem. Can be null/"" for the base objects
- * @param ops Operation to run on the api can be null
+ * @param ops OperationDescription to run on the api can be null
* @return A JSONObject encoding the level plus sub levels provided
* @throws Exception If anything goes wrong
*/
@@ -151,21 +156,62 @@ public class ASConnection {
try {
URL url = getBaseUrl(path,"operation="+s);
- URLConnection conn = url.openConnection();
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoOutput(true);
+// conn.setRequestMethod("POST");
OutputStream out = conn.getOutputStream();
ObjectMapper mapper = new ObjectMapper();
- mapper.writeValue(out,nvp);
+
+ Operation operation = new Operation();
+ operation.operation=s;
+ operation.nvp=nvp;
+ operation.address=pathToAddress(path);
+
+
+ String result = mapper.writeValueAsString(operation);
+ System.out.println("Json to send: " + result);
+ mapper.writeValue(out, operation);
+
out.flush();
out.close();
+
+ InputStream inputStream;
+ if (conn.getResponseCode()==HttpURLConnection.HTTP_OK) {
+ inputStream = conn.getInputStream();
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ inputStream));
+ String line;
+ StringBuilder builder = new StringBuilder();
+ while ((line = in.readLine()) != null) {
+ builder.append(line);
+ }
+ System.out.println(builder.toString());
+ }
+
} catch (IOException e) {
e.printStackTrace(); // TODO: Customise this generated block
}
}
+ private List<NameValuePair> pathToAddress(String path) {
+ if (path.endsWith("/"))
+ path = path.substring(0,path.length()-1);
+ if (path.startsWith("/"))
+ path = path.substring(1);
+ List<NameValuePair> result = new ArrayList<NameValuePair>();
+ String[] components = path.split("/");
+ for (int i = 0; i < components.length ; i+=2) {
+ NameValuePair valuePair = new NameValuePair(components[i],components[i+1]);
+ result.add(valuePair);
+ }
+
+ return result;
+ }
private URL getBaseUrl(String base, String ops) throws MalformedURLException {
String spec;
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 ca746e0..28c0592 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
@@ -24,9 +24,12 @@ import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDataNumeric;
@@ -44,6 +47,8 @@ import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -144,14 +149,26 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet, Confi
public Configuration loadResourceConfiguration() throws Exception {
ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
- JsonNode json = connection.getLevelData(path,false,false);
+ JsonNode json = connection.getLevelData(key,false,false); // TODO path ? key?
Configuration ret = new Configuration();
for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
JsonNode sub = json.findValue(propDef.getName());
- PropertySimple propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
- ret.put(propertySimple);
+ if (propDef instanceof PropertyDefinitionSimple) {
+ PropertySimple propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
+ ret.put(propertySimple);
+ } else if (propDef instanceof PropertyDefinitionList) {
+ PropertyList propertyList = new PropertyList(propDef.getName());
+ Iterator<JsonNode> values = sub.getElements();
+ while (values.hasNext()) {
+ JsonNode node = values.next();
+ String value = node.getTextValue();
+ PropertySimple propertySimple = new PropertySimple(propDef.getName(),value);
+ propertyList.add(propertySimple);
+ }
+ ret.put(propertyList);
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
index 83d0e3e..571dbab 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
@@ -61,7 +61,11 @@ public class BaseDiscovery implements ResourceDiscoveryComponent
serverNameFull = "ASManager";
} else {
serverNameFull = getBaseDirFromCommandLine(commandLine);
+ if (serverNameFull==null || serverNameFull.isEmpty())
+ serverNameFull="JBossAS7";
serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
+ if (serverName.isEmpty())
+ serverName = serverNameFull;
// DomainClient client = DomainClient.Factory.create(InetAddress.getByName("localhost"),9990); //
// Map<ServerIdentity,ServerStatus> serverStatuses = client.getServerStatuses();
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
index 9c8ca19..ff3f10c 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
@@ -18,6 +18,8 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
+import org.codehaus.jackson.annotate.JsonValue;
+
/**
*
* @author Heiko W. Rupp
@@ -31,4 +33,10 @@ public class NameValuePair {
this.name = name;
this.value = value;
}
+
+ @JsonValue
+ @Override
+ public String toString() {
+ return name +":"+ value ;
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
index f00c421..4f5cda1 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -18,63 +18,30 @@
*/
package org.rhq.modules.plugins.jbossas7.json;
-import java.util.Map;
+import java.util.List;
-import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.annotate.JsonValue;
/**
- * // TODO: Document this
+ * Operation to run on the server
* @author Heiko W. Rupp
*/
public class Operation {
- @JsonProperty("operation-name")
- public String operationName;
- public String description;
- @JsonProperty("request-properties")
- public Map<String,As7RequestProperty> requestProperties;
-// @JsonProperty("reply-properties")
-// public ArrayList<As7ReplyProperty> replyProperties;
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("Operation");
- sb.append("{operationName='").append(operationName).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append(", requestProperties=").append(requestProperties);
-// sb.append(", replyProperties=").append(replyProperties);
- sb.append('}');
- return sb.toString();
- }
+ public String operation;
+ public List<NameValuePair> address;
- public static class As7RequestProperty {
- public String description;
- public boolean required;
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("As7RequestProperty");
- sb.append("{description='").append(description).append('\'');
- sb.append(", required=").append(required);
- sb.append('}');
- return sb.toString();
- }
- }
+ public NameValuePair nvp;
- public static class As7ReplyProperty {
- @JsonProperty("value-type")
- public String valueType;
- public String description;
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append("As7ReplyProperty");
- sb.append("{valueType='").append(valueType).append('\'');
- sb.append(", description='").append(description).append('\'');
- sb.append('}');
- return sb.toString();
- }
+ @JsonValue
+ public String toString() {
+ StringBuilder b = new StringBuilder();
+ b.append("{");
+ b.append("operation:").append(operation).append(",\n");
+ b.append("address:").append(address).append(",\n");
+ b.append(nvp);
+ b.append("}");
+ return b.toString();
}
}
+
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/OperationDescription.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/OperationDescription.java
new file mode 100644
index 0000000..18b3a40
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/OperationDescription.java
@@ -0,0 +1,80 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class OperationDescription {
+ @JsonProperty("operation-name")
+ public String operationName;
+ public String description;
+ @JsonProperty("request-properties")
+ public Map<String,As7RequestProperty> requestProperties;
+// @JsonProperty("reply-properties")
+// public ArrayList<As7ReplyProperty> replyProperties;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("OperationDescription");
+ sb.append("{operationName='").append(operationName).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append(", requestProperties=").append(requestProperties);
+// sb.append(", replyProperties=").append(replyProperties);
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public static class As7RequestProperty {
+ public String description;
+ public boolean required;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("As7RequestProperty");
+ sb.append("{description='").append(description).append('\'');
+ sb.append(", required=").append(required);
+ sb.append('}');
+ return sb.toString();
+ }
+ }
+
+ public static class As7ReplyProperty {
+ @JsonProperty("value-type")
+ public String valueType;
+ public String description;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("As7ReplyProperty");
+ sb.append("{valueType='").append(valueType).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
index 89b41a0..7774cd3 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
@@ -37,7 +37,7 @@ public class Subsystem {
@JsonProperty("attributes") Map <String,Attribute> attributes;
@JsonProperty("model-description")
Subsystem modelDescription;
- @JsonProperty("operations") Map<String,Operation> operations = new HashMap<String, Operation>();
+ @JsonProperty("operations") Map<String,OperationDescription> operations = new HashMap<String, OperationDescription>();
public Map<String,Subsystem> children;
@@ -57,7 +57,7 @@ public class Subsystem {
sb.append(", model-description=").append(modelDescription).append('\n');
sb.append("\n, operations=");
if (operations!=null) {
- for (Map.Entry<String,Operation> ops : operations.entrySet())
+ for (Map.Entry<String,OperationDescription> ops : operations.entrySet())
sb.append(" ").append(ops).append('\n');
}
sb.append(", children=").append(children).append('\n');
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 81da4b6..9a04f04 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
@@ -169,6 +169,7 @@
<c:simple-property name="path" readOnly="true" default="/subsystem/web/connector/*"/>
</plugin-configuration>
+
<metric property="bytesSent" measurementType="trendsup"/>
<metric property="bytesReceived" measurementType="trendsup"/>
<metric property="processingTime" measurementType="trendsup"/>
@@ -176,6 +177,12 @@
<metric property="maxTime" />
<metric property="requestCount" measurementType="trendsup"/>
+ <resource-configuration>
+ <c:simple-property name="protocol" required="false" description="The web connector protocol."/>
+ <c:simple-property name="socket-binding" required="false" description="The web connector socket-binding reference, this connector should be bound to."/>
+ <c:simple-property name="scheme" required="false" description="The web connector scheme"/>
+ </resource-configuration>
+
</service>
<service name="VHost"
@@ -185,6 +192,11 @@
<c:simple-property name="path" readOnly="true" default="/subsystem/web/virtual-server/*"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="access-log"/>
+ <c:list-property name="alias" description="The virtual server aliases"/>
+ <c:simple-property name="rewrite"/>
+ </resource-configuration>
</service>
@@ -209,8 +221,8 @@
</plugin-configuration>
<resource-configuration>
- <c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition"/>
- <c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group"/>
+ <c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition" required="false"/>
+ <c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group" required="false"/>
</resource-configuration>
<service name="SocketBinding"
commit 3914a1c51bcb6f24e70ff2243664778b79b04873
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Mar 23 10:41:56 2011 +0100
Add support for reading of resource-config
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index 6b64b7b..005421d 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -22,6 +22,7 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -32,6 +33,8 @@ import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;
import org.jetbrains.annotations.Nullable;
+import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+
/**
* Provide connections to the AS and reading / writing date from/to it.
* @author Heiko W. Rupp
@@ -88,23 +91,7 @@ public class ASConnection {
URL url2;
String spec;
- if (base!=null && !base.isEmpty()) {
- if (!base.startsWith("/")) {
- spec = urlString + "/" + base;
- }
- else {
- spec = urlString + base;
- }
- if (ops!=null) {
- if (!ops.startsWith("?"))
- ops = "?" + ops;
- spec += ops;
- }
-
- url2 = new URL(spec);
- }
- else
- url2 = url;
+ url2 = getBaseUrl(base, ops);
JsonNode tree = null;
@@ -160,5 +147,47 @@ public class ASConnection {
return false;
}
+ public void execute(String path, String s, NameValuePair nvp) {
+
+ try {
+ URL url = getBaseUrl(path,"operation="+s);
+ URLConnection conn = url.openConnection();
+ OutputStream out = conn.getOutputStream();
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.writeValue(out,nvp);
+ out.flush();
+ out.close();
+ } catch (IOException e) {
+ e.printStackTrace(); // TODO: Customise this generated block
+ }
+
+ }
+
+
+
+
+ private URL getBaseUrl(String base, String ops) throws MalformedURLException {
+ String spec;
+ URL url2;
+ if (base!=null && !base.isEmpty()) {
+ if (!base.startsWith("/")) {
+ spec = urlString + "/" + base;
+ }
+ else {
+ spec = urlString + base;
+ }
+ if (ops!=null) {
+ if (!ops.startsWith("?"))
+ ops = "?" + ops;
+ spec += ops;
+ }
+
+ url2 = new URL(spec);
+ }
+ else
+ url2 = url;
+ return url2;
+ }
}
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 2f293d9..ca746e0 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
@@ -23,12 +23,18 @@ import org.apache.commons.logging.LogFactory;
import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.measurement.AvailabilityType;
import org.rhq.core.domain.measurement.DataType;
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.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
@@ -36,10 +42,12 @@ import org.rhq.core.pluginapi.measurement.MeasurementFacet;
import org.rhq.core.pluginapi.operation.OperationContext;
import org.rhq.core.pluginapi.operation.OperationFacet;
import org.rhq.core.pluginapi.operation.OperationResult;
+import org.rhq.modules.plugins.jbossas7.json.NameValuePair;
+import java.util.Map;
import java.util.Set;
-public class BaseComponent implements ResourceComponent, MeasurementFacet
+public class BaseComponent implements ResourceComponent, MeasurementFacet, ConfigurationFacet
{
private final Log log = LogFactory.getLog(this.getClass());
@@ -134,7 +142,33 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
protected String getPath() { return path; }
+ public Configuration loadResourceConfiguration() throws Exception {
+ ConfigurationDefinition configDef = context.getResourceType().getResourceConfigurationDefinition();
+ JsonNode json = connection.getLevelData(path,false,false);
+ Configuration ret = new Configuration();
+
+ for (PropertyDefinition propDef: configDef.getNonGroupedProperties()) {
+ JsonNode sub = json.findValue(propDef.getName());
+ PropertySimple propertySimple = new PropertySimple(propDef.getName(),sub.getValueAsText());
+ ret.put(propertySimple);
+ }
+
+
+ return ret;
+ }
+
+ public void updateResourceConfiguration(ConfigurationUpdateReport report) {
+ Configuration conf = report.getConfiguration();
+ for (Map.Entry<String, PropertySimple> entry : conf.getSimpleProperties().entrySet()) {
+
+ NameValuePair nvp = new NameValuePair(entry.getKey(),entry.getValue().getStringValue());
+ connection.execute(path,"write-attribute",nvp);
+ }
+
+
+ // TODO: Customise this generated block
+ }
}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
new file mode 100644
index 0000000..9c8ca19
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NameValuePair.java
@@ -0,0 +1,34 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+/**
+ *
+ * @author Heiko W. Rupp
+ */
+public class NameValuePair {
+
+ public String name;
+ public String value;
+
+ public NameValuePair(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+}
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 98a97d8..81da4b6 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
@@ -93,7 +93,7 @@
</server>
- <server name="JBossAS7 (Standalone)"
+ <server name="JBossAS7-Standalone"
discovery="BaseDiscovery"
class="BaseComponent"
>
@@ -127,29 +127,29 @@
/>
-->
- <server name="Messaging"
+ <server name="Messaging"
discovery="SubsystemDiscovery"
class="BaseComponent">
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
</plugin-configuration>
- <resource-configuration>
- <c:simple-property name="journal-min-files" />
- <c:simple-property name="journal-type" />
- </resource-configuration>
+ <resource-configuration>
+ <c:simple-property name="journal-min-files" />
+ <c:simple-property name="journal-type" />
+ </resource-configuration>
- <service name="Acceptor"
- discovery="SubsystemDiscovery"
- class="BaseComponent"
- >
- <plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/subsystem/messaging/acceptor"/>
- </plugin-configuration>
+ <service name="Acceptor"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/messaging/acceptor"/>
+ </plugin-configuration>
- </service>
+ </service>
</server>
@@ -164,7 +164,7 @@
<service name="Connector"
discovery="SubsystemDiscovery"
class="BaseComponent"
- >
+ >
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/subsystem/web/connector/*"/>
</plugin-configuration>
@@ -176,11 +176,11 @@
<metric property="maxTime" />
<metric property="requestCount" measurementType="trendsup"/>
- </service>
+ </service>
<service name="VHost"
- discovery="SubsystemDiscovery"
- class="BaseComponent">
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/subsystem/web/virtual-server/*"/>
</plugin-configuration>
@@ -196,32 +196,37 @@
class="BaseComponent"
description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
<plugin-configuration>
- <c:simple-property name="path" readOnly="true" default="/"/>
+ <c:simple-property name="path" readOnly="true" default="/"/>
</plugin-configuration>
</service>
<service name="SocketBindingGroup"
discovery="SocketBindingGroupDiscovery"
class="BaseComponent"
- >
+ >
<plugin-configuration>
<c:simple-property name="path" readOnly="true" default="/socket-binding-group/"/>
</plugin-configuration>
+ <resource-configuration>
+ <c:simple-property name="default-interface" readOnly="true" displayName="Default Interface" description="Default Interface for these bindings. See NetworkInterfaces for its definition"/>
+ <c:simple-property name="port-offset" readOnly="true" displayName="Port Offset" description="Offset from standard ports for this group"/>
+ </resource-configuration>
+
<service name="SocketBinding"
discovery="SocketBindingDiscovery"
class="BaseComponent">
<plugin-configuration>
- <c:simple-property name="path" readOnly="true"/>
+ <c:simple-property name="path" readOnly="true"/>
</plugin-configuration>
- </service>
- </service>
+ </service>
+ </service>
</server>
- <server name="JBossAS (Managed)"
+ <server name="JBossAS-Managed"
discovery="BaseDiscovery"
class="BaseComponent"
>
@@ -238,9 +243,9 @@
<metric property="serverGroup" dataType="trait" displayType="summary" />
<resource-configuration>
<!--<c:group name="interfaces">-->
- <c:simple-property name="loopback" default="127.0.0.1" />
- <c:simple-property name="external" default="any" />
- <c:simple-property name="public" default="any" />
+ <c:simple-property name="loopback" default="127.0.0.1" />
+ <c:simple-property name="external" default="any" />
+ <c:simple-property name="public" default="any" />
<!--</c:group>-->
</resource-configuration>
@@ -251,7 +256,7 @@
discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
class="org.rhq.plugins.jmx.JMXServerComponent"
singleton="true"
- />
+ />
</server>
commit 0f0f7680d7ddb486e63a28ec35874d93f2d1c883
Merge: 69260ab 2f4429f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 22 21:30:15 2011 +0100
Merge branch 'master' into as7plugin
commit 69260ab75e307e19def5831efa6520d1306abdc6
Merge: 92fd80e 6996576
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 22 21:14:53 2011 +0100
Merge branch 'master' into as7plugin
commit 92fd80e33e8367ef8cf228e35c2209037c15dad3
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Mar 22 21:13:58 2011 +0100
Update the plugin to use the JSON interface.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index cf4c3ae..ef75ab7 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -22,6 +22,7 @@
<properties>
<scm.module.path>TODO</scm.module.path>
<json.version>${project.json.version}</json.version>
+ <jackson.version>1.7.4</jackson.version>
</properties>
<build>
@@ -45,11 +46,15 @@
<configuration>
<artifactItems>
<artifactItem>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>${json.version}</version>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>${jackson.version}</version>
+ </artifactItem>
+ <artifactItem>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>${jackson.version}</version>
</artifactItem>
-
</artifactItems>
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
@@ -177,12 +182,11 @@
<dependencies>
<dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>${json.version}</version>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>${jackson.version}</version>
</dependency>
-
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
index a28dc2e..6b64b7b 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -19,6 +19,8 @@
package org.rhq.modules.plugins.jbossas7;
import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
@@ -26,8 +28,9 @@ import java.net.URLConnection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.json.JSONException;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.jetbrains.annotations.Nullable;
/**
* Provide connections to the AS and reading / writing date from/to it.
@@ -53,66 +56,103 @@ public class ASConnection {
}
}
+
+ JsonNode getLevelData(@Nullable String base, boolean recursive, boolean includeMetrics) throws Exception{
+ String ops = null;
+ if (recursive)
+ ops = "recursive";
+ if (includeMetrics)
+ ops += "&include-runtime=true";
+
+ return getLevelData(base,ops);
+}
+ /**
+ * Return the default data for base
+ * @param base
+ * @return
+ * @throws Exception
+ */
+ JsonNode getLevelData(@Nullable String base) throws Exception {
+ return getLevelData(base,"operation=resource-description&recursive&include-runtime=true");
+ }
+
/**
* Return the JSON-Ojbect for a certain path.
*
- *
* @param base Path to the object/subsystem. Can be null/"" for the base objects
- * @param recursive Shall lover levels be recursively obtained. May generate a lot of data.
- * @param includeMetrics Should metrice be requested as well?
+ * @param ops Operation to run on the api can be null
* @return A JSONObject encoding the level plus sub levels provided
* @throws Exception If anything goes wrong
*/
- JSONObject getLevelData(String base, boolean recursive, boolean includeMetrics) throws Exception {
+ JsonNode getLevelData(@Nullable String base, @Nullable String ops) throws Exception {
URL url2;
+ String spec;
if (base!=null && !base.isEmpty()) {
- String spec;
if (!base.startsWith("/")) {
spec = urlString + "/" + base;
}
else {
spec = urlString + base;
}
- if (recursive)
- spec += "?recursive";
- if (includeMetrics)
- spec += "?include-runtime=true"; // TODO this will change ?query-metrics=true for metrics only
+ if (ops!=null) {
+ if (!ops.startsWith("?"))
+ ops = "?" + ops;
+ spec += ops;
+ }
url2 = new URL(spec);
}
else
url2 = url;
+ JsonNode tree = null;
+
URLConnection conn = url2.openConnection();
+ InputStream inputStream = null;
+ try {
+ inputStream = conn.getInputStream();
+ } catch (IOException e) {
+ System.err.println(e.getMessage());
+ return tree;
+ }
BufferedReader in = new BufferedReader(new InputStreamReader(
- conn.getInputStream()));
+ inputStream));
+ try {
+ String line;
+ StringBuilder builder = new StringBuilder();
+ while ((line = in.readLine()) != null) {
+ builder.append(line);
+ }
- String line;
- StringBuilder builder = new StringBuilder();
- while ((line = in.readLine()) != null) {
- builder.append(line);
- }
+ ObjectMapper mapper = new ObjectMapper();
- JSONObject object = new JSONObject(builder.toString());
+ tree = mapper.readTree(builder.toString());
+
+ } catch (IOException ioe) {
+ System.err.println("for in put " + url2 + " : " + ioe.getMessage());
+ } finally {
+ in.close();
+ }
- in.close();
- return object;
+ return tree;
}
- boolean isErrorReply(JSONObject in) {
+ boolean isErrorReply(JsonNode in) {
if (in.has("outcome")) {
String outcome = null;
try {
- outcome = in.getString("outcome");
+ JsonNode outcomeNode = in.findValue("outcome");
+ outcome = outcomeNode.getTextValue();
if (outcome.equals("failed")) {
- String reason = in.getString("failure-description");
+ JsonNode reasonNode = in.findValue("failure-description");
+ String reason = reasonNode.getTextValue();
log.info(reason);
return true;
}
- } catch (JSONException e) {
+ } catch (Exception e) {
e.printStackTrace(); // TODO
return true;
}
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 04264b4..2f293d9 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,8 +1,26 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
package org.rhq.modules.plugins.jbossas7;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.json.JSONObject;
+import org.codehaus.jackson.JsonNode;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.measurement.AvailabilityType;
@@ -11,8 +29,6 @@ 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.core.pluginapi.configuration.ConfigurationFacet;
-import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceComponent;
import org.rhq.core.pluginapi.inventory.ResourceContext;
@@ -30,7 +46,6 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
ResourceContext context;
Configuration conf;
String myServerName;
- private static final String[] INTERFACE_NAMES = new String[]{"loopback","external","public"};
ASConnection connection;
String path;
String key;
@@ -91,10 +106,11 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
*/
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
- JSONObject obj = connection.getLevelData(key,false,true);
+ JsonNode obj = connection.getLevelData(key,false,true);
for (MeasurementScheduleRequest req : metrics) {
if (obj.has(req.getName())) {
+/*
String val = obj.getString(req.getName());
if (req.getDataType()== DataType.MEASUREMENT) {
@@ -105,6 +121,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
MeasurementDataTrait data = new MeasurementDataTrait(req,val);
report.addData(data);
}
+*/
}
}
}
@@ -115,7 +132,7 @@ public class BaseComponent implements ResourceComponent, MeasurementFacet
}
-
+ protected String getPath() { return path; }
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
index 745dc2e..d756543 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
@@ -45,7 +45,7 @@ public class DatasourceDiscovery implements ResourceDiscoveryComponent<Subsystem
for (DataSource source : sources.getDataSource()) {
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- discoveryContext.getResourceType(), // Type
+ discoveryContext.getResourceType(), // DataType
source.getJndiName(), // Key
source.getJndiName(), // Name TODO improve
null, // version
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
new file mode 100644
index 0000000..021b10c
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/InterfaceDiscovery.java
@@ -0,0 +1,107 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Attribute;
+import org.rhq.modules.plugins.jbossas7.json.Domain;
+import org.rhq.modules.plugins.jbossas7.json.NetworkInterface;
+
+/**
+ * Discover subsystems
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class InterfaceDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
+
+ BaseComponent parentComponent = context.getParentResourceComponent();
+ ASConnection connection = parentComponent.getASConnection();
+
+
+
+ JsonNode json = connection.getLevelData(null, null);
+ if (!connection.isErrorReply(json)) {
+ Domain domain = mapper.readValue(json, new TypeReference<Domain>() {});
+
+ for (Map.Entry<String,String> entry: domain.interfaces.entrySet()) {
+
+ String key = entry.getKey();
+ String path = "/interface/" + key;
+ JsonNode subJson = connection.getLevelData(path);
+
+ NetworkInterface networkInterface = mapper.readValue(subJson, new TypeReference<NetworkInterface>() {});
+ networkInterface.name= key;
+ for (Map.Entry<String,Attribute> nentry : networkInterface.attributes.entrySet()) {
+ nentry.getValue().name = nentry.getKey();
+
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
+ Configuration config = context.getDefaultPluginConfiguration();
+
+ PropertySimple propertySimple = new PropertySimple("path",path);
+ config.put(propertySimple);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ path, // Key
+ name, // Name
+ null, // Version
+ networkInterface.description, // Description
+ config,
+ null);
+ details.add(detail);
+ }
+ }
+
+ return details;
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
new file mode 100644
index 0000000..c9b7a5e
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingDiscovery.java
@@ -0,0 +1,108 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Domain;
+import org.rhq.modules.plugins.jbossas7.json.SocketBindingGroup;
+
+/**
+ * Discover single bindings in a socket binding group
+ *
+ * TODO: Is this better a resource-configuration on the parent?
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class SocketBindingDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
+
+ BaseComponent parentComponent = context.getParentResourceComponent();
+ ASConnection connection = parentComponent.getASConnection();
+
+ String path = parentComponent.getPath();
+
+
+ JsonNode json = connection.getLevelData(path,true,false);
+ if (!connection.isErrorReply(json)) {
+
+ SocketBindingGroup bindingGroup = mapper.readValue(json, new TypeReference<SocketBindingGroup>() {});
+ // TODO put bindingGroup. {name, default-interface, port-offset into parent
+
+
+ for (Map.Entry<String,SocketBindingGroup.Binding> entry: bindingGroup.bindings.entrySet()) {
+
+ String key = entry.getKey();
+ String cpath = path + "/socket-binding/" + key;
+
+
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
+ Configuration config = context.getDefaultPluginConfiguration();
+
+ PropertySimple propertySimple = new PropertySimple("path",cpath);
+ config.put(propertySimple);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ path, // Key
+ name, // Name
+ null, // Version
+ "Binding Group", // Description
+ config,
+ null);
+ details.add(detail);
+ log.info("Added " + detail);
+ }
+
+ return details;
+
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
new file mode 100644
index 0000000..4411f8c
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SocketBindingGroupDiscovery.java
@@ -0,0 +1,104 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Attribute;
+import org.rhq.modules.plugins.jbossas7.json.Domain;
+import org.rhq.modules.plugins.jbossas7.json.SocketBindingGroup;
+
+/**
+ * Discover subsystems
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class SocketBindingGroupDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
+
+ BaseComponent parentComponent = context.getParentResourceComponent();
+ ASConnection connection = parentComponent.getASConnection();
+
+
+
+ JsonNode json = connection.getLevelData(null, null);
+ if (!connection.isErrorReply(json)) {
+ Domain domain = mapper.readValue(json, new TypeReference<Domain>() {});
+
+ for (Map.Entry<String,String> entry: domain.socketBindingGroup.entrySet()) {
+
+ String key = entry.getKey();
+ String path = "/socket-binding-group/" + key;
+ JsonNode subJson = connection.getLevelData(path);
+
+ SocketBindingGroup bindingGroup = mapper.readValue(subJson, new TypeReference<SocketBindingGroup>() {});
+ bindingGroup.name= key;
+
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
+ Configuration config = context.getDefaultPluginConfiguration();
+
+ PropertySimple propertySimple = new PropertySimple("path",path);
+ config.put(propertySimple);
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // DataType
+ path, // Key
+ name, // Name
+ null, // Version
+ "SocketBinding Group", // Description
+ config,
+ null);
+ details.add(detail);
+ }
+
+ return details;
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
index 7833f67..75683cb 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -20,29 +20,40 @@ package org.rhq.modules.plugins.jbossas7;
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
-import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.modules.plugins.jbossas7.json.Subsystem;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
-import org.json.JSONObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.map.DeserializationConfig;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.type.TypeReference;
/**
* Discover subsystems
*
* @author Heiko W. Rupp
*/
+@SuppressWarnings("unused")
public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+ private final Log log = LogFactory.getLog(this.getClass());
+
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
- throws InvalidPluginConfigurationException, Exception {
+ throws Exception {
Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ mapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING,true);
BaseComponent parentComponent = context.getParentResourceComponent();
ASConnection connection = parentComponent.getASConnection();
@@ -61,29 +72,31 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
path = cpath;
- JSONObject o = connection.getLevelData(path,recursive, false);
- if (!connection.isErrorReply(o)) {
+ JsonNode json = connection.getLevelData(path,recursive, false);
+ if (!connection.isErrorReply(json)) {
if (recursive) {
int i = path.lastIndexOf("/");
String subPath = path.substring(i+1);
- o = o.getJSONObject(subPath);
+ JsonNode subNode = json.findPath(subPath);
+
+ Map<String,Subsystem> subsystemMap = mapper.readValue(subNode,new TypeReference<Map<String,Subsystem>>() {});
- Iterator keyIter = o.keys() ;
- while (keyIter.hasNext()) {
+ for (Map.Entry<String,Subsystem> entry: subsystemMap.entrySet()) {
- String key = (String) keyIter.next();
+ String key = entry.getKey();
+ Subsystem subsystem = entry.getValue();
String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
String name = resKey.substring(resKey.lastIndexOf("/") + 1);
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // Type
+ context.getResourceType(), // DataType
path + "/" + key, // Key
name, // Name
null, // Version
- path, // Description
+ subsystem.description, // Description
config,
null);
details.add(detail);
@@ -98,7 +111,7 @@ public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseCompon
DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
- context.getResourceType(), // Type
+ context.getResourceType(), // DataType
path, // Key
name, // Name
null, // Version
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Attribute.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Attribute.java
new file mode 100644
index 0000000..02dbb5d
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Attribute.java
@@ -0,0 +1,86 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class Attribute {
+
+ public String name;
+ public String description;
+ public boolean required;
+ public boolean nillable;
+ @JsonProperty("access-type")
+ public AccessType accessType;
+ public Storage storage;
+ public Type type;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Attribute");
+ sb.append("{name='").append(name).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append(", required=").append(required);
+ sb.append(", nillable=").append(nillable);
+ sb.append(", accessType='").append(accessType).append('\'');
+ sb.append(", storage='").append(storage).append('\'');
+ sb.append(", type=").append(type);
+ sb.append('}');
+ return sb.toString();
+ }
+
+
+ public enum AccessType {
+ METRIC("metric"),
+ READ_ONLY("read-only")
+ ;
+
+ String jsonName;
+
+ AccessType(String jsonName) {
+ this.jsonName = jsonName;
+ }
+
+ @Override
+ public String toString() {
+ return jsonName;
+ }
+ }
+
+ public enum Storage {
+ CONFIGURATION("configuration"),
+ RUNTIME("runtime")
+ ;
+
+ String jsonName;
+
+ Storage(String jsonName) {
+ this.jsonName =jsonName;
+ }
+
+ @Override
+ public String toString() {
+ return jsonName;
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Domain.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Domain.java
new file mode 100644
index 0000000..8600c15
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Domain.java
@@ -0,0 +1,53 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class Domain {
+
+
+ public String name;
+ @JsonProperty("management-interfaces") Map<String,String> managementInterfaces;
+ @JsonProperty("profile-name") String profileName;
+ public Map<String,String> path;
+ public Map<String,String> subsystem;
+ @JsonProperty("interface")
+ public Map<String,String> interfaces;
+ @JsonProperty("socket-binding-group")
+ public Map<String,String> socketBindingGroup;
+
+ @Override
+ public String toString() {
+ return "Domain{" +
+ "name='" + name + '\'' +
+ ", managementInterfaces=" + managementInterfaces +
+ ", profileName='" + profileName + '\'' +
+ ", path=" + path +
+ ", subsystem=" + subsystem +
+ ", interfaces=" + interfaces +
+ ", socketBindingGroup=" + socketBindingGroup +
+ '}';
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NetworkInterface.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NetworkInterface.java
new file mode 100644
index 0000000..0af6ed1
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/NetworkInterface.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class NetworkInterface {
+
+ public String name;
+ public String description;
+ @JsonProperty("attributes")
+ public
+ Map<String,Attribute> attributes;
+
+
+ @Override
+ public String toString() {
+ return "NetworkInterface{" +
+ "name='" + name + '\'' +
+ ", description='" + description + '\'' +
+ ", attributes=" + attributes +
+ '}';
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
new file mode 100644
index 0000000..f00c421
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Operation.java
@@ -0,0 +1,80 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class Operation {
+ @JsonProperty("operation-name")
+ public String operationName;
+ public String description;
+ @JsonProperty("request-properties")
+ public Map<String,As7RequestProperty> requestProperties;
+// @JsonProperty("reply-properties")
+// public ArrayList<As7ReplyProperty> replyProperties;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Operation");
+ sb.append("{operationName='").append(operationName).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append(", requestProperties=").append(requestProperties);
+// sb.append(", replyProperties=").append(replyProperties);
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public static class As7RequestProperty {
+ public String description;
+ public boolean required;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("As7RequestProperty");
+ sb.append("{description='").append(description).append('\'');
+ sb.append(", required=").append(required);
+ sb.append('}');
+ return sb.toString();
+ }
+ }
+
+ public static class As7ReplyProperty {
+ @JsonProperty("value-type")
+ public String valueType;
+ public String description;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("As7ReplyProperty");
+ sb.append("{valueType='").append(valueType).append('\'');
+ sb.append(", description='").append(description).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/SocketBindingGroup.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/SocketBindingGroup.java
new file mode 100644
index 0000000..5d2b6ee
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/SocketBindingGroup.java
@@ -0,0 +1,47 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * One Socket binding group of a domain
+ * @author Heiko W. Rupp
+ */
+public class SocketBindingGroup {
+
+
+ public String name;
+ @JsonProperty("default-interface") public String defaultInterface;
+ @JsonProperty("port-offset") public int portOffset;
+ @JsonProperty("socket-binding") public Map<String,Binding> bindings;
+
+
+ public static class Binding {
+ public String name;
+ @JsonProperty("interface") public String iFace;
+ public int port;
+ @JsonProperty("fixed-port") public Integer fixedPort;
+ @JsonProperty("multicast-address") public String mcastAddress;
+ @JsonProperty("multicast-port") public Integer mcastPort;
+
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
new file mode 100644
index 0000000..89b41a0
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Subsystem.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class Subsystem {
+
+ String subsystemName;
+
+ @JsonProperty("head-comment-allowed") boolean headCommentAllowed;
+ @JsonProperty("tail-comment-allowed") boolean tailCommentAllowed;
+// public DataType type;
+ public String description;
+ @JsonProperty("attributes") Map <String,Attribute> attributes;
+ @JsonProperty("model-description")
+ Subsystem modelDescription;
+ @JsonProperty("operations") Map<String,Operation> operations = new HashMap<String, Operation>();
+ public Map<String,Subsystem> children;
+
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Subsystem");
+ sb.append("{headCommentAllowed=").append(headCommentAllowed);
+ sb.append(", tailCommentAllowed=").append(tailCommentAllowed);
+// sb.append(", type=").append(type).append('\n');
+ sb.append(", description='").append(description).append('\'').append('\n');
+ sb.append(", attributes=\n");
+ if (attributes!=null) {
+ for (Map.Entry<String,Attribute> attr : attributes.entrySet())
+ sb.append(" ").append(attr).append('\n');
+ }
+ sb.append(", model-description=").append(modelDescription).append('\n');
+ sb.append("\n, operations=");
+ if (operations!=null) {
+ for (Map.Entry<String,Operation> ops : operations.entrySet())
+ sb.append(" ").append(ops).append('\n');
+ }
+ sb.append(", children=").append(children).append('\n');
+ sb.append("\n}");
+ return sb.toString();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Tuple.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Tuple.java
new file mode 100644
index 0000000..01e31d3
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Tuple.java
@@ -0,0 +1,35 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+/**
+ * @author Heiko W. Rupp
+ */
+public class Tuple {
+ String key;
+ String value;
+
+ @Override
+ public String toString() {
+ return "Tuple{" +
+ "key='" + key + '\'' +
+ ", value='" + value + '\'' +
+ '}';
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Type.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Type.java
new file mode 100644
index 0000000..0ad1fe8
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/Type.java
@@ -0,0 +1,50 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class Type {
+
+ @JsonProperty("TYPE_MODEL_VALUE")
+ public DataType modelValue;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("Type");
+ sb.append("{modelValue='").append(modelValue).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public enum DataType {
+ STRING,
+ INT,
+ BOOLEAN,
+ OBJECT,
+ LIST
+
+ ;
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/TypeModelValue.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/TypeModelValue.java
new file mode 100644
index 0000000..6856adb
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/json/TypeModelValue.java
@@ -0,0 +1,39 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7.json;
+
+/**
+ * // TODO: Document this
+ * @author Heiko W. Rupp
+ */
+public class TypeModelValue {
+
+ public String TYPE_MODEL_VALUE;
+ public String value;
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("TypeModelValue");
+ sb.append("{TYPE_MODEL_VALUE='").append(TYPE_MODEL_VALUE).append('\'');
+ sb.append(", value='").append(value).append('\'');
+ sb.append('}');
+ return sb.toString();
+ }
+}
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 e29d0d2..98a97d8 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
@@ -93,7 +93,7 @@
</server>
- <server name="JBossAS (Standalone)"
+ <server name="JBossAS7 (Standalone)"
discovery="BaseDiscovery"
class="BaseComponent"
>
@@ -178,8 +178,47 @@
</service>
+ <service name="VHost"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/web/virtual-server/*"/>
+ </plugin-configuration>
+
+
+ </service>
+
</server>
+
+ <service name="NetworkInterface"
+ discovery="InterfaceDiscovery"
+ class="BaseComponent"
+ description="A named network interface, along with required criteria for determining the IP address to associate with that interface">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/"/>
+ </plugin-configuration>
+ </service>
+
+ <service name="SocketBindingGroup"
+ discovery="SocketBindingGroupDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/socket-binding-group/"/>
+ </plugin-configuration>
+
+ <service name="SocketBinding"
+ discovery="SocketBindingDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true"/>
+ </plugin-configuration>
+
+ </service>
+ </service>
+
+
</server>
<server name="JBossAS (Managed)"
commit 6a46a9c96002addd485058a7269247a9bf67739c
Merge: 33e4ce8 829d5ff
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Mar 14 14:44:50 2011 +0100
Merge branch 'master' into as7plugin
commit 33e4ce87753d91c82dd1dd3c9c539acb311cda85
Merge: c3cd8f3 332d99a
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 3 17:50:29 2011 +0100
Merge branch 'master' into as7plugin
commit c3cd8f3f135563765a73a3c76f7db9bdf2b3d617
Merge: 7d233c8 3fc1998
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Mar 3 14:13:32 2011 +0100
Merge branch 'master' into as7plugin
commit 7d233c8a1a76d3c2dfd9742b9f5ab1b222e01792
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Feb 21 22:15:18 2011 +0100
Put json parser version into a property and use this in the sub-projects.
diff --git a/modules/plugins/hudson/pom.xml b/modules/plugins/hudson/pom.xml
index 71c974a..a8f6739 100644
--- a/modules/plugins/hudson/pom.xml
+++ b/modules/plugins/hudson/pom.xml
@@ -22,7 +22,7 @@
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
- <version>20080701</version>
+ <version>${project.json.version}</version>
<scope>provided</scope>
</dependency>
@@ -63,7 +63,7 @@
<artifactItem>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
- <version>20080701</version>
+ <version>${project.json.version}</version>
</artifactItem>
</artifactItems>
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
index 0e6df0b..cf4c3ae 100644
--- a/modules/plugins/jboss-as-7/pom.xml
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -21,7 +21,7 @@
<properties>
<scm.module.path>TODO</scm.module.path>
- <json.version>20080701</json.version>
+ <json.version>${project.json.version}</json.version>
</properties>
<build>
diff --git a/pom.xml b/pom.xml
index 7c07d11..4ace1d2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -150,6 +150,7 @@
<!-- NOTE: The below line is a workaround for a Maven bug, where it does not expand settings.* properties
used in the distributionManagement section of the POM. -->
<localRepository>${user.home}/.m2/repository</localRepository>
+ <project.json.version>20080701</project.json.version>
</properties>
commit c8ffdf7cf0202a3b59675f7a8a201c3a2fc87f4f
Merge: 5221182 6a43faf
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Feb 21 22:01:40 2011 +0100
Merge branch 'master' into as7plugin
commit 52211828eed5ebd533de2759de221f48a60c3eda
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Tue Feb 15 21:13:59 2011 +0100
First cut of a JBossAS7 plugin using the brand new http-based API.
diff --git a/modules/plugins/jboss-as-7/pom.xml b/modules/plugins/jboss-as-7/pom.xml
new file mode 100644
index 0000000..0e6df0b
--- /dev/null
+++ b/modules/plugins/jboss-as-7/pom.xml
@@ -0,0 +1,221 @@
+<project
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+
+ >
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-plugins-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-jboss-as-7-plugin</artifactId>
+ <packaging>jar</packaging>
+
+ <name>RHQ JBoss-AS-7 Plugin</name>
+
+ <properties>
+ <scm.module.path>TODO</scm.module.path>
+ <json.version>20080701</json.version>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependency-jars</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>${json.version}</version>
+ </artifactItem>
+
+
+ </artifactItems>
+ <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>dev</id>
+
+ <properties>
+ <rhq.rootDir>../../..</rhq.rootDir>
+ <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
+ <rhq.deploymentDir>
+ ${rhq.containerDir}/jbossas/server/default/deploy/${rhq.earName}/rhq-downloads/rhq-plugins
+ </rhq.deploymentDir>
+ </properties>
+
+ <build>
+ <plugins>
+
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+
+ <execution>
+ <id>deploy</id>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <mkdir dir="${rhq.deploymentDir}"/>
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Updating ${deployment.file}...</echo>
+ <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>deploy-jar-meta-inf</id>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
+ <unjar src="${project.build.directory}/${project.build.finalName}.jar"
+ dest="${project.build.outputDirectory}">
+ <patternset>
+ <include name="META-INF/**"/>
+ </patternset>
+ </unjar>
+ <jar destfile="${deployment.file}"
+ manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
+ update="true">
+ </jar>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>undeploy</id>
+ <phase>clean</phase>
+ <configuration>
+ <tasks>
+ <property name="deployment.file"
+ location="${rhq.deploymentDir}/${project.build.finalName}.jar"/>
+ <echo>*** Deleting ${deployment.file}...</echo>
+ <delete file="${deployment.file}"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+ </profile>
+ </profiles>
+
+
+ <repositories>
+ <repository>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <id>jboss</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.org/maven2/</url>
+ </repository>
+ <!-- TODO add your own maven repositories here (if needed) -->
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <id>jboss</id>
+ <name>JBoss Plugin Repository</name>
+ <url>http://repository.jboss.org/maven2/</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>${json.version}</version>
+ </dependency>
+
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>${commons-logging.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-core-plugin-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>${rhq.groupId}</groupId>
+ <artifactId>rhq-core-native-system</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-jmx-plugin</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <!-- TODO add your dependencies here -->
+
+ </dependencies>
+</project>
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
new file mode 100644
index 0000000..a28dc2e
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ASConnection.java
@@ -0,0 +1,124 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+/**
+ * Provide connections to the AS and reading / writing date from/to it.
+ * @author Heiko W. Rupp
+ */
+public class ASConnection {
+
+ private final Log log = LogFactory.getLog(ASConnection.class);
+ private int port;
+ private String host;
+ URL url;
+ String urlString;
+
+ public ASConnection(String host, int port) {
+ this.host = host;
+ this.port = port;
+
+ try {
+ url = new URL("http",host,port,"/domain-api");
+ urlString = url.toString();
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
+
+ /**
+ * Return the JSON-Ojbect for a certain path.
+ *
+ *
+ * @param base Path to the object/subsystem. Can be null/"" for the base objects
+ * @param recursive Shall lover levels be recursively obtained. May generate a lot of data.
+ * @param includeMetrics Should metrice be requested as well?
+ * @return A JSONObject encoding the level plus sub levels provided
+ * @throws Exception If anything goes wrong
+ */
+ JSONObject getLevelData(String base, boolean recursive, boolean includeMetrics) throws Exception {
+
+ URL url2;
+ if (base!=null && !base.isEmpty()) {
+ String spec;
+ if (!base.startsWith("/")) {
+ spec = urlString + "/" + base;
+ }
+ else {
+ spec = urlString + base;
+ }
+ if (recursive)
+ spec += "?recursive";
+ if (includeMetrics)
+ spec += "?include-runtime=true"; // TODO this will change ?query-metrics=true for metrics only
+
+ url2 = new URL(spec);
+ }
+ else
+ url2 = url;
+
+ URLConnection conn = url2.openConnection();
+ BufferedReader in = new BufferedReader(new InputStreamReader(
+ conn.getInputStream()));
+
+ String line;
+ StringBuilder builder = new StringBuilder();
+ while ((line = in.readLine()) != null) {
+ builder.append(line);
+ }
+
+ JSONObject object = new JSONObject(builder.toString());
+
+ in.close();
+ return object;
+ }
+
+
+ boolean isErrorReply(JSONObject in) {
+ if (in.has("outcome")) {
+ String outcome = null;
+ try {
+ outcome = in.getString("outcome");
+ if (outcome.equals("failed")) {
+ String reason = in.getString("failure-description");
+ log.info(reason);
+ return true;
+ }
+
+ } catch (JSONException e) {
+ e.printStackTrace(); // TODO
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+}
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
new file mode 100644
index 0000000..04264b4
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseComponent.java
@@ -0,0 +1,123 @@
+package org.rhq.modules.plugins.jbossas7;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.json.JSONObject;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.DataType;
+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.core.pluginapi.configuration.ConfigurationFacet;
+import org.rhq.core.pluginapi.configuration.ConfigurationUpdateReport;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+import org.rhq.core.pluginapi.operation.OperationContext;
+import org.rhq.core.pluginapi.operation.OperationFacet;
+import org.rhq.core.pluginapi.operation.OperationResult;
+
+import java.util.Set;
+
+public class BaseComponent implements ResourceComponent, MeasurementFacet
+{
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ ResourceContext context;
+ Configuration conf;
+ String myServerName;
+ private static final String[] INTERFACE_NAMES = new String[]{"loopback","external","public"};
+ ASConnection connection;
+ String path;
+ String key;
+
+
+ /**
+ * Return availability of this resource
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
+ */
+ public AvailabilityType getAvailability() {
+ // TODO supply real implementation
+ return AvailabilityType.UP;
+ }
+
+
+ /**
+ * Start the resource connection
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#start(org.rhq.core.pluginapi.inventory.ResourceContext)
+ */
+ public void start(ResourceContext context) throws InvalidPluginConfigurationException, Exception {
+ this.context = context;
+ conf = context.getPluginConfiguration();
+ // TODO add code to start the resource / connection to it
+
+ String typeName = context.getResourceType().getName();
+ String host = conf.getSimpleValue("hostname","localhost");
+ String portString = conf.getSimpleValue("port","9990");
+ int port = Integer.parseInt(portString);
+ connection = new ASConnection(host,port);
+
+ path = conf.getSimpleValue("path", null);
+ key = context.getResourceKey();
+
+
+
+// Object o = connection.getLevelData("", false); // BASE entries
+
+ myServerName = context.getResourceKey().substring(context.getResourceKey().lastIndexOf("/")+1);
+
+
+ }
+
+
+ /**
+ * Tear down the resource connection
+ * @see org.rhq.core.pluginapi.inventory.ResourceComponent#stop()
+ */
+ public void stop() {
+
+
+ }
+
+
+
+ /**
+ * Gather measurement data
+ * @see org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport, java.util.Set)
+ */
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
+
+ JSONObject obj = connection.getLevelData(key,false,true);
+
+ for (MeasurementScheduleRequest req : metrics) {
+ if (obj.has(req.getName())) {
+ String val = obj.getString(req.getName());
+ if (req.getDataType()== DataType.MEASUREMENT) {
+
+ Double d = Double.parseDouble(val);
+ MeasurementDataNumeric data = new MeasurementDataNumeric(req,d);
+ report.addData(data);
+ } else if (req.getDataType()== DataType.TRAIT) {
+ MeasurementDataTrait data = new MeasurementDataTrait(req,val);
+ report.addData(data);
+ }
+ }
+ }
+ }
+
+
+ protected ASConnection getASConnection() {
+ return connection;
+ }
+
+
+
+
+
+
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
new file mode 100644
index 0000000..83d0e3e
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseDiscovery.java
@@ -0,0 +1,157 @@
+package org.rhq.modules.plugins.jbossas7;
+
+import java.io.File;
+import java.net.InetAddress;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
+import org.rhq.core.domain.configuration.PropertyList;
+import org.rhq.core.domain.configuration.PropertyMap;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.pluginapi.event.log.LogFileEventResourceComponentHelper;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ProcessScanResult;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.plugins.jmx.JMXDiscoveryComponent;
+
+
+/**
+ * Discovery class
+ */
+public class BaseDiscovery implements ResourceDiscoveryComponent
+
+{
+
+ static final String DJBOSS_SERVER_BASE_DIR = "-Djboss.server.base.dir=";
+ static final String DORG_JBOSS_BOOT_LOG_FILE = "-Dorg.jboss.boot.log.file=";
+ private final Log log = LogFactory.getLog(this.getClass());
+
+ /**
+ * Run the auto-discovery
+ */
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext discoveryContext) throws Exception {
+ Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
+
+
+ List<ProcessScanResult> scans = discoveryContext.getAutoDiscoveredProcesses();
+
+ for (ProcessScanResult psr : scans) {
+
+ Configuration config = discoveryContext.getDefaultPluginConfiguration();
+ // IF SE, then look at domain/configuration/host.xml <management interface="default" port="9990
+ // for management port
+ String[] commandLine = psr.getProcessInfo().getCommandLine();
+ String serverNameFull;
+ String serverName;
+ String psName = psr.getProcessScan().getName();
+ if (psName.equals("ProcessManager")) {
+ serverNameFull = "ProcessManager";
+ serverName = "ProcessManager";
+ } else if (psName.equals("ASManager")) {
+ serverName = "ASManager";
+ serverNameFull = "ASManager";
+ } else {
+ serverNameFull = getBaseDirFromCommandLine(commandLine);
+ serverName = serverNameFull.substring(serverNameFull.lastIndexOf("/")+1);
+
+// DomainClient client = DomainClient.Factory.create(InetAddress.getByName("localhost"),9990); //
+// Map<ServerIdentity,ServerStatus> serverStatuses = client.getServerStatuses();
+// for (Map.Entry<ServerIdentity,ServerStatus> entry : serverStatuses.entrySet()) {
+// ServerIdentity identity = entry.getKey();
+// ServerStatus status = entry.getValue();
+// if (identity.getServerName().equals(serverName)) {
+// String serverGroupName = identity.getServerGroupName();
+// config.put(new PropertySimple("server-group",serverGroupName));
+// }
+//
+// }
+ }
+ String logFile = getLogFieFromCommandLine(commandLine);
+ initLogEventSourcesConfigProp(logFile,config);
+ String javaClazz = psr.getProcessInfo().getName();
+
+
+ /*
+ * We'll connect to the discovered VM on the local host, so set the jmx connection
+ * properties accordingly. This may only work on JDK6+, but then JDK5 is deprecated
+ * anyway.
+ */
+// config.put(new PropertySimple(JMXDiscoveryComponent.COMMAND_LINE_CONFIG_PROPERTY,
+// javaClazz));
+ config.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
+ LocalVMTypeDescriptor.class.getName()));
+
+ // TODO vmid will change when the detected server is bounced - how do we follow this?
+ config.put(new PropertySimple(JMXDiscoveryComponent.VMID_CONFIG_PROPERTY,psr.getProcessInfo().getPid()));
+
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ discoveryContext.getResourceType(), // ResourceType
+ serverNameFull, // key TODO distinguish per domain?
+ serverName, // Name
+ null, // TODO real version ?
+ "TODO", // Description
+ config,
+ psr.getProcessInfo()
+ );
+
+
+ // Add to return values
+ discoveredResources.add(detail);
+ log.info("Discovered new ... " + discoveryContext.getResourceType() + ", " + serverNameFull);
+ }
+
+ return discoveredResources;
+
+ }
+
+ String getBaseDirFromCommandLine(String[] commandLine) {
+ for (String line: commandLine) {
+ if (line.startsWith(DJBOSS_SERVER_BASE_DIR))
+ return line.substring(DJBOSS_SERVER_BASE_DIR.length());
+ }
+ return "";
+ }
+
+//-Dorg.jboss.boot.log.file=/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/log/server-manager/boot.log
+//-Dlogging.configuration=file:/devel/jbas7/jboss-as/build/target/jboss-7.0.0.Alpha2/domain/configuration/logging.properties
+
+ String getLogFieFromCommandLine(String[] commandLine) {
+
+ for (String line: commandLine) {
+ if (line.startsWith(DORG_JBOSS_BOOT_LOG_FILE))
+ return line.substring(DORG_JBOSS_BOOT_LOG_FILE.length());
+ }
+ return "";
+ }
+
+ private void initLogEventSourcesConfigProp(String fileName, Configuration pluginConfiguration) {
+
+ PropertyList logEventSources = pluginConfiguration
+ .getList(LogFileEventResourceComponentHelper.LOG_EVENT_SOURCES_CONFIG_PROP);
+
+ if (logEventSources==null)
+ return;
+
+ File serverLogFile = new File(fileName);
+
+ if (serverLogFile.exists() && !serverLogFile.isDirectory()) {
+ PropertyMap serverLogEventSource = new PropertyMap("logEventSource");
+ serverLogEventSource.put(new PropertySimple(
+ LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.LOG_FILE_PATH, serverLogFile));
+ serverLogEventSource.put(new PropertySimple(
+ LogFileEventResourceComponentHelper.LogEventSourcePropertyNames.ENABLED, Boolean.FALSE));
+ logEventSources.add(serverLogEventSource);
+ }
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
new file mode 100644
index 0000000..abf6d35
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceComponent.java
@@ -0,0 +1,44 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+
+/**
+ * // TODO: Document this
+ *
+ * @author Heiko W. Rupp
+ */
+public class DatasourceComponent implements ResourceComponent<SubsystemComponent> {
+
+ public void start(ResourceContext<SubsystemComponent> subsystemComponentResourceContext) throws InvalidPluginConfigurationException, Exception {
+ // TODO: Customise this generated block
+ }
+
+ public void stop() {
+ // TODO: Customise this generated block
+ }
+
+ public AvailabilityType getAvailability() {
+ return null; // TODO: Customise this generated block
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
new file mode 100644
index 0000000..745dc2e
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/DatasourceDiscovery.java
@@ -0,0 +1,65 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Discover Datasources
+ *
+ * @author Heiko W. Rupp
+ */
+public class DatasourceDiscovery implements ResourceDiscoveryComponent<SubsystemComponent> {
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<SubsystemComponent> discoveryContext) throws InvalidPluginConfigurationException, Exception {
+
+/*
+ if (subsys instanceof DataSourcesSubsystemElement) {
+ DataSourcesSubsystemElement element = (DataSourcesSubsystemElement) subsys;
+ DataSources sources = element.getDatasources();
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
+
+ for (DataSource source : sources.getDataSource()) {
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ discoveryContext.getResourceType(), // Type
+ source.getJndiName(), // Key
+ source.getJndiName(), // Name TODO improve
+ null, // version
+ "A datasource", // description
+ discoveryContext.getDefaultPluginConfiguration(),
+ null // Process scans
+
+ );
+ details.add(detail);
+ }
+ return details;
+ }
+
+*/
+ return Collections.emptySet();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java
new file mode 100644
index 0000000..09d753c
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemComponent.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+
+/**
+ * Resource component for subsystems
+ *
+ * Deprecated - use BaseComponent
+ * @author Heiko W. Rupp
+ */
+@Deprecated
+public class SubsystemComponent implements ResourceComponent<BaseComponent> {
+
+ ResourceContext<BaseComponent> context;
+ Configuration config;
+ String path;
+ String key ;
+
+ public void start(ResourceContext<BaseComponent> context) throws InvalidPluginConfigurationException, Exception {
+ this.config = context.getPluginConfiguration();
+ path = config.getSimpleValue("path", null);
+ this.context = context;
+ key = context.getResourceKey();
+
+ }
+
+ public void stop() {
+ // TODO: Customise this generated block
+ }
+
+ public AvailabilityType getAvailability() {
+ return AvailabilityType.UP; // TODO: Customise this generated block
+ }
+
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
new file mode 100644
index 0000000..7833f67
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/SubsystemDiscovery.java
@@ -0,0 +1,117 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2011 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.json.JSONObject;
+
+/**
+ * Discover subsystems
+ *
+ * @author Heiko W. Rupp
+ */
+public class SubsystemDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws InvalidPluginConfigurationException, Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>(1);
+
+
+ BaseComponent parentComponent = context.getParentResourceComponent();
+ ASConnection connection = parentComponent.getASConnection();
+
+
+ Configuration config = context.getDefaultPluginConfiguration();
+ String cpath = config.getSimpleValue("path", null);
+ boolean recursive = false;
+
+ String path;
+ if (cpath.endsWith("/*")) {
+ path = cpath.substring(0,cpath.length()-2);
+ recursive = true;
+ }
+ else
+ path = cpath;
+
+
+ JSONObject o = connection.getLevelData(path,recursive, false);
+ if (!connection.isErrorReply(o)) {
+ if (recursive) {
+ int i = path.lastIndexOf("/");
+ String subPath = path.substring(i+1);
+
+ o = o.getJSONObject(subPath);
+
+ Iterator keyIter = o.keys() ;
+ while (keyIter.hasNext()) {
+
+ String key = (String) keyIter.next();
+
+ String resKey = context.getParentResourceContext().getResourceKey() + "/" + key;
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // Type
+ path + "/" + key, // Key
+ name, // Name
+ null, // Version
+ path, // Description
+ config,
+ null);
+ details.add(detail);
+ }
+
+ }
+ else {
+
+
+ String resKey = context.getParentResourceContext().getResourceKey();
+ String name = resKey.substring(resKey.lastIndexOf("/") + 1);
+
+
+ DiscoveredResourceDetails detail = new DiscoveredResourceDetails(
+ context.getResourceType(), // Type
+ path, // Key
+ name, // Name
+ null, // Version
+ path, // Description
+ config,
+ null);
+ details.add(detail);
+ }
+
+ return details;
+ }
+
+ return Collections.emptySet();
+ }
+
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WarComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WarComponent.java
new file mode 100644
index 0000000..7382a6d
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WarComponent.java
@@ -0,0 +1,58 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.inventory.DeleteResourceFacet;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+
+/**
+ * Monitoring of war files
+ *
+ * @author Heiko W. Rupp
+ */
+public class WarComponent implements ResourceComponent<BaseComponent>, DeleteResourceFacet {
+
+ ResourceContext<BaseComponent> context;
+
+ public void start(ResourceContext<BaseComponent> context) throws InvalidPluginConfigurationException, Exception {
+ this.context = context;
+ }
+
+ public void stop() {
+ }
+
+ public AvailabilityType getAvailability() {
+ return AvailabilityType.UP;
+ }
+
+ public void deleteResource() throws Exception {
+//
+// DomainDeploymentManager deploymentManager = client.getDeploymentManager();
+// DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
+//
+// String name = context.getResourceKey(); // key and name are the same at the moment
+//
+// UndeployDeploymentPlanBuilder udpb = builder.undeploy(name);
+// RemoveDeploymentPlanBuilder rdpb = udpb.andRemoveUndeployed();
+// rdpb.build();
+ }
+}
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WarDiscovery.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WarDiscovery.java
new file mode 100644
index 0000000..adadcba
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/WarDiscovery.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.modules.plugins.jbossas7;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.InvalidPluginConfigurationException;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Discover war files
+ *
+ * @author Heiko W. Rupp
+ */
+public class WarDiscovery implements ResourceDiscoveryComponent<BaseComponent> {
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext<BaseComponent> context)
+ throws InvalidPluginConfigurationException, Exception {
+
+ Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
+
+ BaseComponent baseComponent = context.getParentResourceComponent();
+
+ return details;
+ }
+}
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
new file mode 100644
index 0000000..e29d0d2
--- /dev/null
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -0,0 +1,219 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE plugin [
+
+ <!ENTITY logSources '
+ <c:group name="event" displayName="Events">
+ <c:list-property name="logEventSources">
+ <c:map-property name="logEventSource">
+ <c:simple-property name="logFilePath" type="file" summary="true"
+ description="The absolute path to the source log file."/>
+ <c:simple-property name="enabled" type="boolean" summary="true"
+ description="A flag indicating whether of not this log Event source is currently
+ enabled (i.e. whether the associated log file should be tailed for
+ new entries)."/>
+ <c:simple-property name="dateFormat" required="false"
+ description="The date format to use when parsing the dates in log entries. The
+ format must be in the syntax defined by the Java SimpleDateFormat
+ class. If not specified, the three date formats that are predefined
+ by Log4J (ISO8601, DATE, and ABSOLUTE) will be tried."/>
+ <c:simple-property name="includesPattern" required="false"
+ description="A regular expression against which a log entrys detail is matched
+ to determine if an Event should be fired for that entry. If not
+ specified, no filtering of log entries will be done based on their
+ detail."/>
+ <c:simple-property name="minimumSeverity" required="false" default="error"
+ description="The minimum severity of Events that should be collected for this
+ source. If not specified, there is no minimum severity (i.e. all
+ events will be collected).">
+ <c:property-options>
+ <c:option name="debug" value="debug"/>
+ <c:option name="info" value="info"/>
+ <c:option name="warn" value="warn"/>
+ <c:option name="error" value="error"/>
+ <c:option name="fatal" value="fatal"/>
+ </c:property-options>
+ </c:simple-property>
+ </c:map-property>
+ </c:list-property>
+ </c:group>
+'>
+
+ ]>
+
+<plugin name="jboss-as-7"
+ displayName="JBoss-AS-7-Plugin"
+ description="Management of JBossAS 7"
+ package="org.rhq.modules.plugins.jbossas7"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration"
+ version="4.0.0-SNAPSHOT"
+ >
+
+ <depends plugin="JMX"/>
+
+
+ <!-- TODO I think we should introduce an abstract AS7 plugin that contains some base functionality and then
+ ~~ additional 'Personalities' for the kinds of servers (PM, SM, Standalone AS, Managed AS)
+ -->
+
+ <server name="ProcessController"
+ discovery="BaseDiscovery"
+ class="BaseComponent"
+ description="Reaper process for other AS7 servicees"
+ >
+
+ <plugin-configuration>
+ <c:simple-property name="hostname" default="localhost" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true"/>
+
+ &logSources;
+ </plugin-configuration>
+
+ <process-scan name="ProcessManager" query="process|basename|match=^java.*,arg|org.jboss.as.process-controller|match=.*"/>
+
+
+ <operation name="dummyOperation">
+ <!-- TODO supply parameters and return values -->
+ </operation>
+
+ <!--
+ <server name="ProcessManager JVM"
+ description="JVM of the ProcessManager"
+ sourcePlugin="JMX"
+ sourceType="JMX Server"
+ discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
+ class="org.rhq.plugins.jmx.JMXServerComponent"
+ singleton="true"
+ />
+ -->
+
+
+
+ </server>
+
+ <server name="JBossAS (Standalone)"
+ discovery="BaseDiscovery"
+ class="BaseComponent"
+ >
+
+ <plugin-configuration>
+ <c:simple-property name="hostname" default="localhost" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true"/>
+ <c:list-property name="system-properties">
+ <c:map-property name="system-property">
+ <c:simple-property name="key" readOnly="true"/>
+ <c:simple-property name="value" readOnly="true"/>
+ </c:map-property>
+ </c:list-property>
+ &logSources;
+ </plugin-configuration>
+
+ <process-scan name="StandaloneAS" query="process|basename|match=^java.*,arg|org.jboss.as.standalone|match=.*"/>
+
+
+ <operation name="dummyOperation">
+ <!-- TODO supply parameters and return values -->
+ </operation>
+ <!--
+ <server name="JBoss AS standalone JVM"
+ description="JVM of the standalone JBossAS"
+ sourcePlugin="JMX"
+ sourceType="JMX Server"
+ discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
+ class="org.rhq.plugins.jmx.JMXServerComponent"
+ singleton="true"
+ />
+ -->
+
+ <server name="Messaging"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent">
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/messaging"/>
+ </plugin-configuration>
+
+ <resource-configuration>
+ <c:simple-property name="journal-min-files" />
+ <c:simple-property name="journal-type" />
+ </resource-configuration>
+
+
+ <service name="Acceptor"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/messaging/acceptor"/>
+ </plugin-configuration>
+
+
+ </service>
+
+ </server>
+
+ <server name="JBossWeb"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/web"/>
+ </plugin-configuration>
+
+ <service name="Connector"
+ discovery="SubsystemDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="path" readOnly="true" default="/subsystem/web/connector/*"/>
+ </plugin-configuration>
+
+ <metric property="bytesSent" measurementType="trendsup"/>
+ <metric property="bytesReceived" measurementType="trendsup"/>
+ <metric property="processingTime" measurementType="trendsup"/>
+ <metric property="errorCount" measurementType="trendsup"/>
+ <metric property="maxTime" />
+ <metric property="requestCount" measurementType="trendsup"/>
+
+ </service>
+
+
+ </server>
+ </server>
+
+ <server name="JBossAS (Managed)"
+ discovery="BaseDiscovery"
+ class="BaseComponent"
+ >
+ <plugin-configuration>
+ <c:simple-property name="hostname" default="localhost" required="true"/>
+ <c:simple-property name="port" default="9990" type="integer" required="true"/>
+
+ &logSources;
+ </plugin-configuration>
+
+ <process-scan name="ManagedAS" query="process|basename|match=^java.*,arg|org.jboss.as.server|match=.*"/>
+
+
+ <metric property="serverGroup" dataType="trait" displayType="summary" />
+ <resource-configuration>
+ <!--<c:group name="interfaces">-->
+ <c:simple-property name="loopback" default="127.0.0.1" />
+ <c:simple-property name="external" default="any" />
+ <c:simple-property name="public" default="any" />
+ <!--</c:group>-->
+ </resource-configuration>
+
+ <server name="JBoss AS managed JVM"
+ description="JVM of the managed JBossAS"
+ sourcePlugin="JMX"
+ sourceType="JMX Server"
+ discovery="org.rhq.plugins.jmx.LocalJMXServerDiscoveryComponent"
+ class="org.rhq.plugins.jmx.JMXServerComponent"
+ singleton="true"
+ />
+
+ </server>
+
+</plugin>
diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml
index 1582597..de1fad6 100644
--- a/modules/plugins/pom.xml
+++ b/modules/plugins/pom.xml
@@ -115,6 +115,7 @@
<module>rhq-server</module>
<module>jboss-cache</module>
<module>jboss-as-5</module>
+ <module>jboss-as-7</module>
<module>jboss-cache-v3</module>
<!-- was not in Jopr build at merge time <module>jbossOSGi</module> -->
<module>database</module>
12 years, 10 months
[rhq] Branch 'drift' - 3 commits - modules/core modules/plugins
by mazz
modules/core/dbutils/pom.xml | 2
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml | 41 +++-------
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java | 3
3 files changed, 19 insertions(+), 27 deletions(-)
New commits:
commit 819d8fc91e1cbd04a8d5e0d4ed82d402d38b0ce1
Merge: 1e24f2a 19558e1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jun 27 17:31:28 2011 -0400
Merge commit 'origin/master' into drift
Conflicts:
modules/core/dbutils/pom.xml
modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
diff --cc modules/core/dbutils/pom.xml
index d79b738,a368986..e2a599d
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@@ -22,7 -22,7 +22,7 @@@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.113</db.schema.version>
- <db.schema.version>2.110</db.schema.version>
++ <db.schema.version>2.112</db.schema.version>
</properties>
<dependencies>
diff --cc modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 8e276a1,df0daf7..8f0a9c7
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@@ -3441,145 -3442,9 +3441,134 @@@
REFERENCES RHQ_CONFIG_PROP_DEF (ID)
</statement>
</schema-directSQL>
- <schema-createSequence name="rhq_config_prop_def_opt_src_id_seq" initial="10001" />
+ <schema-createSequence name="rhq_config_pd_osrc_id_seq" initial="10001" />
</schemaSpec>
+ <schemaSpec version="2.111">
+ <schema-directSQL>
+ <statement desc="Creating global drift configuration definition">
+ INSERT INTO rhq_config_def (id, name, description)
+ VALUES (1, 'GLOBAL_DRIFT_CONFIG_DEF', 'The drift configuration definition')
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type,
+ order_index, dtype, config_def_id)
+ VALUES (1, 'name', 'Drift Configuration Name', 'The drift configuration name', true, 'string',
+ 0, 'property', 1)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type,
+ default_value, order_index, dtype, config_def_id)
+ VALUES (2, 'enabled', 'Enabled', 'Enables or disables drift detection for this configuration', true, 'boolean',
+ 'false', 1, 'property', 1)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type,
+ order_index, dtype, config_def_id)
+ VALUES (3, 'basedir', 'Base Directory', 'The base directory from which files will be monitored for drift.',
+ true, 'string', 2, 'property', 1)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, required, simple_type,
+ order_index, dtype, default_value, config_def_id)
+ VALUES (4, 'interval', 'Interval', 'The interval, in seconds, between drift detection scans for this configuration. Default is thirty minutes.',
+ false, 'long', 3, 'property', '1800', 1)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, description, order_index,
+ config_def_id)
+ VALUES (5, 'includes', 'Includes', 'list', 'A set of patterns that specify files and/or directories to include.',
+ 4, 1)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, parent_list_definition_id)
+ VALUES (6, 'include', 'Include', 'map', 4)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type,
+ order_index, dtype, parent_map_definition_id)
+ VALUES (7, 'path', 'Path', 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.',
+ 'string', 0, 'property', 5)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type,
+ order_index, dtype, parent_map_definition_id)
+ VALUES (8, 'pattern', 'Pattern', 'TBD', 'string', 1, 'property', 5)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, description, order_index,
+ config_def_id)
+ VALUES (9, 'excludes', 'Excludes', 'list', 'A set of patterns that specify files and/or directories to exclude.',
+ 5, 1)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, dtype, parent_list_definition_id)
+ VALUES (10, 'exclude', 'Exclude', 'map', 8)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type,
+ order_index, dtype, parent_map_definition_id)
+ VALUES (11, 'path', 'Path', 'A file system path that can be a directory or a file. The path is assumed to be relative to the base directory of the drift configuration.',
+ 'string', 0, 'property', 9)
+ </statement>
+ <statement>
+ INSERT INTO rhq_config_prop_def (id, name, display_name, description, simple_type,
+ order_index, dtype, parent_map_definition_id)
+ VALUES (12, 'pattern', 'Pattern', 'TBD', 'string', 1, 'property', 9)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
+ <schemaSpec version="2.112">
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_DRIFT_TEMPLATE">
+ CREATE TABLE RHQ_DRIFT_TEMPLATE (
+ RESOURCE_TYPE_ID INTEGER,
+ CONFIG_TEMPLATE_ID INTEGER)
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_DRIFT_TEMPLATE" column="RESOURCE_TYPE_ID" nullable="false"/>
+ <schema-alterColumn table="RHQ_DRIFT_TEMPLATE" column="CONFIG_TEMPLATE_ID" nullable="false"/>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_DRIFT_TEMPLATE foreign key to RHQ_RESOURCE_TYPE">
+ ALTER TABLE RHQ_DRIFT_TEMPLATE
+ ADD CONSTRAINT RESOURCE_TYPE_ID_FK
+ FOREIGN KEY (RESOURCE_TYPE_ID)
+ REFERENCES RHQ_RESOURCE_TYPE (ID)
+ </statement>
+ <statement desc="Creating RHQ_DRIFT_TEMPLATE foreign key to RHQ_CONFIG_TEMPLATE">
+ ALTER TABLE RHQ_DRIFT_TEMPLATE
+ ADD CONSTRAINT CONFIG_TEMPLATE_ID_FK
+ FOREIGN KEY (CONFIG_TEMPLATE_ID)
+ REFERENCES RHQ_CONFIG_TEMPLATE (ID)
+ </statement>
+ </schema-directSQL>
+
+ <schema-directSQL>
+ <statement desc="Creating table RHQ_DRIFT_CONFIG">
+ CREATE TABLE RHQ_DRIFT_CONFIG (
+ RESOURCE_ID INTEGER,
+ CONFIG_ID INTEGER)
+ </statement>
+ </schema-directSQL>
+ <schema-alterColumn table="RHQ_DRIFT_CONFIG" column="RESOURCE_ID" nullable="false"/>
+ <schema-alterColumn table="RHQ_DRIFT_CONFIG" column="CONFIG_ID" nullable="false"/>
+ <schema-directSQL>
+ <statement desc="Creating RHQ_DRIFT_CONFIG foreign key to RHQ_RESOURCE">
+ ALTER TABLE RHQ_DRIFT_CONFIG
+ ADD CONSTRAINT RESOURCE_ID_FK
+ FOREIGN KEY (RESOURCE_ID)
+ REFERENCES RHQ_RESOURCE (ID)
+ </statement>
+ <statement desc="Creating RHQ_DRIFT_CONFIG foreign key to RHQ_CONFIG">
+ ALTER TABLE RHQ_DRIFT_CONFIG
+ ADD CONSTRAINT CONFIG_ID_FK
+ FOREIGN KEY (CONFIG_ID)
+ REFERENCES RHQ_CONFIG (ID)
+ </statement>
+ </schema-directSQL>
+ </schemaSpec>
+
- <schemaSpec version="2.113">
- <schema-directSQL>
- <statement desc="rename to correct name">
- ALTER TABLE RHQ_PROP_DEF_OPT_SRC
- RENAME TO RHQ_CONFIG_PD_OSRC
- </statement>
- <statement desc="rename sequence">
- ALTER TABLE rhq_config_prop_def_opt_src_id_seq RENAME TO rhq_config_pd_osrc_id_seq
- </statement>
- </schema-directSQL>
- </schemaSpec>
</dbupgrade>
</target>
</project>
commit 19558e110cd6f9233225e7122d8af4baafb1ea56
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Jun 27 17:27:39 2011 -0400
we can't rename tables (which is essentially removing an old table and creating a new table)
because dbsetup won't work - the dbsetup uninstall won't know about the old table to remove if it is still around
collapse the two dbupgrade steps into one
diff --git a/modules/core/dbutils/pom.xml b/modules/core/dbutils/pom.xml
index 39f0798..a368986 100644
--- a/modules/core/dbutils/pom.xml
+++ b/modules/core/dbutils/pom.xml
@@ -22,7 +22,7 @@
<properties>
<scm.module.path>modules/core/dbutils/</scm.module.path>
- <db.schema.version>2.111</db.schema.version>
+ <db.schema.version>2.110</db.schema.version>
</properties>
<dependencies>
diff --git a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
index 9950e58..df0daf7 100644
--- a/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
+++ b/modules/core/dbutils/src/main/scripts/dbupgrade/db-upgrade.xml
@@ -3417,44 +3417,34 @@
<schemaSpec version="2.110">
<schema-directSQL>
- <statement desc="Creating table RHQ_PROP_DEF_OPT_SRC">
- CREATE TABLE RHQ_PROP_DEF_OPT_SRC ( ID INTEGER PRIMARY KEY )
+ <statement desc="Creating table RHQ_CONFIG_PD_OSRC">
+ CREATE TABLE RHQ_CONFIG_PD_OSRC ( ID INTEGER PRIMARY KEY )
</statement>
</schema-directSQL>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="LINK_TO_TARGET" columnType="BOOLEAN"/>
- <schema-alterColumn table="RHQ_PROP_DEF_OPT_SRC" column="LINK_TO_TARGET" nullable="TRUE"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="LINK_TO_TARGET" columnType="BOOLEAN"/>
+ <schema-alterColumn table="RHQ_CONFIG_PD_OSRC" column="LINK_TO_TARGET" nullable="TRUE"/>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="FILTER" columnType="VARCHAR2" precision="40"/>
- <schema-alterColumn table="RHQ_PROP_DEF_OPT_SRC" column="FILTER" nullable="TRUE"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="FILTER" columnType="VARCHAR2" precision="40"/>
+ <schema-alterColumn table="RHQ_CONFIG_PD_OSRC" column="FILTER" nullable="TRUE"/>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="EXPRESSION" columnType="VARCHAR2" precision="400"/>
- <schema-alterColumn table="RHQ_PROP_DEF_OPT_SRC" column="EXPRESSION" nullable="FALSE"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="EXPRESSION" columnType="VARCHAR2" precision="400"/>
+ <schema-alterColumn table="RHQ_CONFIG_PD_OSRC" column="EXPRESSION" nullable="FALSE"/>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="TARGET_TYPE" columnType="VARCHAR2" precision="20"/>
- <schema-alterColumn table="RHQ_PROP_DEF_OPT_SRC" column="TARGET_TYPE" nullable="FALSE"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="TARGET_TYPE" columnType="VARCHAR2" precision="20"/>
+ <schema-alterColumn table="RHQ_CONFIG_PD_OSRC" column="TARGET_TYPE" nullable="FALSE"/>
- <schema-addColumn table="RHQ_PROP_DEF_OPT_SRC" column="PROPERTY_DEF_ID" columnType="INTEGER"/>
+ <schema-addColumn table="RHQ_CONFIG_PD_OSRC" column="PROPERTY_DEF_ID" columnType="INTEGER"/>
<schema-directSQL>
- <statement desc="Adding a fk">
- ALTER TABLE RHQ_PROP_DEF_OPT_SRC
- ADD CONSTRAINT RHQ_PROP_DEF_OPT_SRC_ID_FK
+ <statement desc="Adding a foreign key constraint to RHQ_CONFIG_PD_OSRC">
+ ALTER TABLE RHQ_CONFIG_PD_OSRC
+ ADD CONSTRAINT RHQ_CONFIG_PD_OSRC_ID_FK
FOREIGN KEY (PROPERTY_DEF_ID)
REFERENCES RHQ_CONFIG_PROP_DEF (ID)
</statement>
</schema-directSQL>
- <schema-createSequence name="rhq_config_prop_def_opt_src_id_seq" initial="10001" />
- </schemaSpec>
- <schemaSpec version="2.111">
- <schema-directSQL>
- <statement desc="rename to correct name">
- ALTER TABLE RHQ_PROP_DEF_OPT_SRC
- RENAME TO RHQ_CONFIG_PD_OSRC
- </statement>
- <statement desc="rename sequence">
- ALTER TABLE rhq_config_prop_def_opt_src_id_seq RENAME TO rhq_config_pd_osrc_id_seq
- </statement>
- </schema-directSQL>
+ <schema-createSequence name="rhq_config_pd_osrc_id_seq" initial="10001" />
</schemaSpec>
+
</dbupgrade>
</target>
</project>
commit 1553673802ec3f30d6582d6f0a8df3707cc5d6a1
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Jun 27 17:55:59 2011 +0200
Fix a possible NPE that prevents config rendering.
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
index f66cefd..ae8e5d9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/ConfigurationDelegate.java
@@ -219,6 +219,9 @@ public class ConfigurationDelegate implements ConfigurationFacet {
* @return the populated map
*/
PropertyMap handlePropertyMap(PropertyDefinitionMap propDef, Object valueObject) {
+ if (valueObject==null)
+ return null;
+
PropertyMap propertyMap = new PropertyMap(propDef.getName());
Map<String, PropertyDefinition> memberDefMap = propDef.getPropertyDefinitions();
12 years, 10 months