[rhq] modules/plugins
by Heiko W. Rupp
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseProcessDiscovery.java | 3 -
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java | 25 +++++++---
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java | 8 +++
3 files changed, 29 insertions(+), 7 deletions(-)
New commits:
commit 3bba88c36f7d4a91ac5ac824c0e5b7fd43c3dd0b
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 10 14:39:21 2013 +0200
BZ 961787 - try to determine AS/WFLY via domain api version before falling back to directory names, as this is more reliable.
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 9a4d5bd..cc13406 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
@@ -193,7 +193,8 @@ public abstract class BaseProcessDiscovery implements ResourceDiscoveryComponent
serverPluginConfig.setHostname(managementHostPort.host);
serverPluginConfig.setPort(managementHostPort.port);
pluginConfig.setSimpleValue("realm", hostConfig.getManagementSecurityRealm());
- JBossProductType productType = JBossProductType.determineJBossProductType(homeDir);
+ String apiVersion = hostConfig.getDomainApiVersion();
+ JBossProductType productType = JBossProductType.determineJBossProductType(homeDir, apiVersion);
serverPluginConfig.setProductType(productType);
pluginConfig.setSimpleValue("hostXmlFileName", getHostXmlFileName(commandLine));
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java
index 9edfb2f..9eb63f9 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/JBossProductType.java
@@ -37,7 +37,7 @@ public enum JBossProductType {
JPP("JPP", "JBoss EAP 6", "JBoss Portal Platform 6", "Portal Platform"),
// EWP("EWP", "JBoss EWP 6", "JBoss Enterprise Web Platform 6", "EWP"),
SOA("SOA-P", "JBoss SOA-P 6", "JBoss Enterprise SOA Platform (ESB)", "SOAP"),
- WILDFLY8("WildFly","WildFly 8" ,"WildFly Appliction Server 8" , "WildFly");
+ WILDFLY8("WildFly","WildFly 8" ,"WildFly Application Server 8" , "WildFly");
public final String SHORT_NAME;
public final String NAME;
@@ -55,13 +55,28 @@ public enum JBossProductType {
/**
* Determines the product type of a JBoss product installation.
*
+ *
* @param homeDir the JBoss product installation directory (e.g. /opt/jboss-as-7.1.1.Final)
*
+ * @param apiVersion
* @return the product type
*/
- public static JBossProductType determineJBossProductType(File homeDir) {
+ public static JBossProductType determineJBossProductType(File homeDir, String apiVersion) {
try {
- return determineJBossProductTypeViaProductConfFile(homeDir);
+ JBossProductType jBossProductType = determineJBossProductTypeViaProductConfFile(homeDir);
+ if (jBossProductType==null) {
+ // Wildfly and The Server Formerly Known AS JBossAS share the same absence of a slot
+ // and thus have no product type. So we need to check differently
+ // AS 7.0/1 use a domain api version of 1.x, while WildFly uses version 2.0+
+ // like 2.0 in "urn:jboss:domain:2.0" from <server xmlns="..." > element in standalone.xml
+ if (apiVersion.startsWith("1")) {
+ jBossProductType = JBossProductType.AS;
+ } else {
+ // We should later check for newer WildFly versions to differentiate them
+ jBossProductType = JBossProductType.WILDFLY8;
+ }
+ }
+ return jBossProductType;
} catch (Exception e) {
// TODO: Log an error.
return determineJBossProductTypeViaHomeDirName(homeDir);
@@ -109,9 +124,7 @@ public enum JBossProductType {
throw new RuntimeException("Unknown product type: " + slot);
}
} else {
- // Wildfly and The Server Formerly Known AS JBossAS share the same absence of a slot
- // so we need another way to distinguish them
- productType = determineJBossProductTypeViaHomeDirName(homeDir);
+ productType = null;
}
return productType;
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java
index a8909ff..329246e 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/helper/HostConfiguration.java
@@ -233,6 +233,14 @@ public class HostConfiguration {
return securityPropertyFile;
}
+ public String getDomainApiVersion() {
+
+ String version = document.getFirstChild().getAttributes().getNamedItem("xmlns").getTextContent();
+
+ version = version.substring(version.lastIndexOf(':')+1);
+ return version;
+ }
+
/**
* Run the passed xpathExpression on the prepopulated hostXml document and
* return the target element or attribute as a String.
11 years, 1 month
[rhq] 2 commits - modules/core modules/enterprise modules/integration-tests
by Heiko W. Rupp
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java | 31 ++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java | 3
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/BadArgumentException.java | 5
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java | 18 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java | 10 +
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ContentTest.java | 67 +++------
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java | 69 +++++++++-
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java | 9 +
8 files changed, 153 insertions(+), 59 deletions(-)
New commits:
commit 8868d16074902e9996f00cce8db697d02fce21ad
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 10 12:18:26 2013 +0200
BZ 960959 apply inventory status filtering with COMMITTED as default for searches.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
index 138ca40..2dde3a4 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/Criteria.java
@@ -52,7 +52,7 @@ public abstract class Criteria implements Serializable, BaseCriteria {
* Use this to get the global fields for this Criteria field type. Don't use inspection as the field names
* for this abstract base class do not conform (for legacy reasons) to the prefix convention help by the
* subclasses.
- *
+ *
* @return The set of global fields for this Criteria field type. Meaning, usable by all subclasses.
*/
public List<String> getGlobalFields() {
@@ -76,7 +76,7 @@ public abstract class Criteria implements Serializable, BaseCriteria {
* private NonBindingOverrideFilter filterResourceOnly; // requires overrides - finds only those associated with a resource
* ...
* filterOverrides.put("resourceTypeOnly", "resourceType IS NOT NULL"); // notice no ? parameter
- *
+ *
* Note: Typically a null value is analogous to OFF.
*/
public enum NonBindingOverrideFilter {
@@ -87,12 +87,12 @@ public abstract class Criteria implements Serializable, BaseCriteria {
* Apply a restriction to reduce the cost of the {@link Criteria}-based query generation and execution routines.
*/
public enum Restriction {
- /**
+ /**
* This returns an empty {@link PageList} result whose {@link PageList#getTotalSize()} method otherwise
* contains the correct value.
*/
COUNT_ONLY,
- /**
+ /**
* This will return the {@link PageList} result whose {@link PageList#isUnbounded()} returned true, meaning
* that the value contained within {@link PageList#getTotalSize()} is invalid / undefined.
*/
@@ -121,10 +121,10 @@ public abstract class Criteria implements Serializable, BaseCriteria {
// All Criteria support sorting on ID
protected PageOrdering sortId;
-
+
// All Criteria support filtering on ID
protected Integer filterId;
-
+
// All Criteria support filtering on IDs
protected List<Integer> filterIds;
@@ -176,7 +176,7 @@ public abstract class Criteria implements Serializable, BaseCriteria {
addSortField("id");
this.sortId = sortId;
}
-
+
public void addFilterId(Integer filterId) {
this.filterId = filterId;
}
@@ -189,6 +189,13 @@ public abstract class Criteria implements Serializable, BaseCriteria {
orderingFieldNames.add("sort" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1));
}
+ /**
+ * Sets the paging constraints to return items [pageNumber * pageSize , ((pageNumber+1) * pageSize) -1 ].
+ * For this to work correctly, you also need to set the sort
+ * criteria (do not rely on implicit id-sorting to work correctly.
+ * @param pageNumber The page to fetch. This is 0-based.
+ * @param pageSize The number of items to return.
+ */
public void setPaging(int pageNumber, int pageSize) {
this.pageNumber = pageNumber;
this.pageSize = pageSize;
@@ -196,7 +203,7 @@ public abstract class Criteria implements Serializable, BaseCriteria {
/**
* If the pageControl is set, then this criteria object will completely ignore any
- * calls made to setPaging(pageNumber, pageSize) as well as addSortField(fieldName),
+ * calls made to setPaging(pageNumber, pageSize) as well as addSortField(fieldName),
* which is useful from a server-side calling context where the PageControl object
* will already have been created for you by the extensions at the JSF layer.
*/
@@ -248,7 +255,7 @@ public abstract class Criteria implements Serializable, BaseCriteria {
/**
* If set to true, string-based filters will use exact string matches;
- * Default is 'false', which means we'll fuzzy match
+ * Default is 'false', which means we'll fuzzy match
*/
public void setStrict(boolean strict) {
this.strict = strict;
@@ -262,9 +269,9 @@ public abstract class Criteria implements Serializable, BaseCriteria {
* By default, two queries will be generated for this Criteria: one which fetches the requested page/subset of
* entity results, and one which fetches the total cardinality of the result set. If you wish to only retrieve one
* of those pieces of data, you can do so by setting a restriction on the query generation and execution routines.
- *
+ *
* The restriction, once set, can be removed by passing NULL to this method.
- *
+ *
* @see Restriction
*/
public void setRestriction(Restriction restriction) {
@@ -325,7 +332,7 @@ public abstract class Criteria implements Serializable, BaseCriteria {
* Somewhat analogous to JPA's Query.getSingleResult. Wrap a CriteriaQuery result with this method when
* expecting a single result from the fetch. If the result set has only one entry it is returned. Otherwise
* a RuntimeException is thrown, indicating whether no results, or multiple results were found.
- *
+ *
* @param result
* @return
* @throws RuntimeException In not exactly one result is found. The message will include either the String
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
index 7a198bd..0038099 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/AbstractRestBean.java
@@ -52,8 +52,6 @@ import org.infinispan.Cache;
import org.infinispan.manager.CacheContainer;
import org.rhq.core.domain.auth.Subject;
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.PropertySimple;
import org.rhq.core.domain.measurement.DataType;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.measurement.MeasurementSchedule;
@@ -349,6 +347,7 @@ public class AbstractRestBean {
rwt.setTypeName(resourceType.getName());
rwt.setTypeId(resourceType.getId());
rwt.setPluginName(resourceType.getPlugin());
+ rwt.setStatus(res.getInventoryStatus().name());
Resource parent = res.getParentResource();
if (parent != null) {
rwt.setParentId(parent.getId());
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/BadArgumentException.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/BadArgumentException.java
index cea84c2..3879f73 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/BadArgumentException.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/BadArgumentException.java
@@ -23,7 +23,10 @@ import javax.ejb.ApplicationException;
/**
* Exception if arguments are bad.
* Don't use java.lang.IllegalArgumentException, as this is no
- * Application Exception and gets wrapped
+ * Application Exception and gets wrapped.
+ *
+ * The ExceptionMapper translates this into a 406 repsonse code
+ *
* @author Heiko W. Rupp
*/
@ApplicationException(rollback = false, inherited = true)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
index 3e1d195..288e9f7 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java
@@ -177,14 +177,28 @@ public class ResourceHandlerBean extends AbstractRestBean {
@GET @GZIP
@Path("/")
+ @ApiError(code = 406, reason = "The passed inventory status was invalid")
@ApiOperation(value = "Search for resources by the given search string, possibly limited by category and paged", responseClass = "ResourceWithType")
- public Response getResourcesByQuery(@ApiParam("String to search in the resource name") @QueryParam("q") String q,
+ public Response getResourcesByQuery(@ApiParam("Limit results to param in the resource name") @QueryParam("q") String q,
@ApiParam("Limit to category (PLATFORM, SERVER, SERVICE") @QueryParam("category") String category,
@ApiParam("Page size for paging") @QueryParam("ps") @DefaultValue("20") int pageSize,
- @ApiParam("Page for paging") @QueryParam("page") Integer page,
+ @ApiParam("Page for paging, 0-based") @QueryParam("page") Integer page,
+ @ApiParam(value = "Limit to Inventory status of the resources", allowableValues = "ALL, NEW, IGNORED, COMMITTED, DELETED, UNINVENTORIED")
+ @DefaultValue("COMMITTED") @QueryParam("status") String status,
@Context HttpHeaders headers,
@Context UriInfo uriInfo) {
+
ResourceCriteria criteria = new ResourceCriteria();
+ if (!status.toLowerCase().equals("all")) {
+ try {
+ criteria.addFilterInventoryStatus(InventoryStatus.valueOf(status.toUpperCase()));
+ } catch (IllegalArgumentException iae) {
+ throw new BadArgumentException("status","Value " + status + " is not in the list of allowed values: ALL, NEW, IGNORED, COMMITTED, DELETED, UNINVENTORIED" );
+ }
+ } else {
+ // JavaDoc says to explicitly set to null in order to get all Status
+ criteria.addFilterInventoryStatus(null);
+ }
if (q!=null) {
criteria.addFilterName(q);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
index 6b9aace..703e897 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/domain/ResourceWithType.java
@@ -52,6 +52,7 @@ public class ResourceWithType {
Integer typeId;
String pluginName;
Integer parentId;
+ String status;
List<Link> links = new ArrayList<Link>();
private String ancestry;
@@ -126,6 +127,15 @@ public class ResourceWithType {
this.parentId = parentId;
}
+ @ApiProperty(value = "Inventory status of the resource.",allowableValues = "NEW, IGNORED, COMMITTED, DELETED, UNINVENTORIED" )
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
@XmlElementRef
public List<Link> getLinks() {
return links;
diff --git a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
index c71bbd8..3efd807 100644
--- a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
+++ b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java
@@ -113,7 +113,6 @@ public class ResourcesTest extends AbstractBase {
@Test
public void testGetPlatformUILink() {
- Response response =
given()
.header(acceptJson)
.pathParam("id", _platformId)
@@ -145,6 +144,74 @@ public class ResourcesTest extends AbstractBase {
}
@Test
+ public void testResourceQueryAllStatus() throws Exception {
+ String json = get("/resource/platforms.json").asString();
+ String platformName = JsonPath.with(json).get("[0].resourceName");
+
+ given()
+ .header("Accept", "application/json")
+ .with()
+ .queryParam("q", platformName)
+ .queryParam("status","all")
+ .queryParam("category", "platform")
+ .expect()
+ .statusCode(200)
+ .body("links.self", notNullValue())
+ .when()
+ .get("/resource");
+ }
+
+ @Test
+ public void testResourceQueryCommittedStatus() throws Exception {
+ String json = get("/resource/platforms.json").asString();
+ String platformName = JsonPath.with(json).get("[0].resourceName");
+
+ given()
+ .header("Accept", "application/json")
+ .with()
+ .queryParam("q", platformName)
+ .queryParam("status","committed")
+ .queryParam("category", "platform")
+ .expect()
+ .statusCode(200)
+ .body("links.self", notNullValue())
+ .when()
+ .get("/resource");
+ }
+
+ @Test
+ public void testResourceQueryNewStatus() throws Exception {
+
+ // Unfortunately we can not assume that there are
+ // any resources in other states than COMMITTED
+ given()
+ .header("Accept", "application/json")
+ .with()
+ .queryParam("status","NeW")
+ .expect()
+ .statusCode(200)
+ .when()
+ .get("/resource");
+ }
+
+ @Test
+ public void testResourceQueryBadStatus() throws Exception {
+ String json = get("/resource/platforms.json").asString();
+ String platformName = JsonPath.with(json).get("[0].resourceName");
+
+ given()
+ .header("Accept", "application/json")
+ .with()
+ .queryParam("q", platformName)
+ .queryParam("status","Frobnitz")
+ .queryParam("category", "platform")
+ .expect()
+ .statusCode(406)
+ .when()
+ .get("/resource");
+ }
+
+ @Test
public void testResourceQueryCategory() throws Exception {
with()
diff --git a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
index 6cbcea0..f060101 100644
--- a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
+++ b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Resource.java
@@ -33,6 +33,7 @@ public class Resource {
String typeName;
String pluginName;
Integer parentId;
+ String status;
int typeId;
List<Map> links;
String ancestry;
@@ -103,4 +104,12 @@ public class Resource {
public void setAncestry(String ancestry) {
this.ancestry = ancestry;
}
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
}
commit c12f45a0dac01b601ce05fc7046042b83e51b184
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 10 11:15:25 2013 +0200
Make this test use the RHQ server, so that no external EAP needs to be set up.
diff --git a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ContentTest.java b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ContentTest.java
index 5532b13..7e3f45a 100644
--- a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ContentTest.java
+++ b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ContentTest.java
@@ -176,7 +176,7 @@ public class ContentTest extends AbstractBase {
List<Map<String,Object>> resources =
given()
.header(acceptJson)
- .queryParam("q","EAP (127.0.0.1:9990)") // TODO fragile -- better search for it?
+ .queryParam("q","EAP (127.0.0.1:6990)") // TODO Can we identify the RHQ server itself better?
.queryParam("category","SERVER")
.expect()
.statusCode(200)
@@ -188,6 +188,7 @@ public class ContentTest extends AbstractBase {
assert resources.size()>0;
int as7Id = Integer.valueOf((String)resources.get(0).get("resourceId"));
+ int createdResourceId=-1;
// create child of eap6 as deployment
try {
@@ -223,25 +224,33 @@ public class ContentTest extends AbstractBase {
int status = response.getStatusCode();
String location = response.getHeader("Location");
- System.out.println("Location " + location + "\n\n");
+ System.out.println("\nLocation " + location + "\n\n");
assert location!=null;
// We need to check what we got. A 302 means the deploy is still
// in progress, so we need to wait a little longer
while (status==302) {
- status =
+ response =
given()
.header(acceptJson)
.log().everything()
.expect()
- .statusCode(isOneOf(200,201,302))
+ .statusCode(isOneOf(200, 201, 302))
.log().everything()
.when()
- .get(location)
- .getStatusCode();
+ .get(location);
+
+ status = response.getStatusCode();
}
+ createdResourceId = response.jsonPath().getInt("resourceId");
+
+ System.out.println("\n Deploy is done, resource Id = " + createdResourceId + " \n");
+ System.out.flush();
+
+ assert createdResourceId != -1;
+
} finally {
// Remove the uploaded content
@@ -254,47 +263,23 @@ public class ContentTest extends AbstractBase {
.when()
.delete("/content/{handle}");
+ System.out.println("\n Content removed \n");
+ System.out.flush();
+
+
+ // We need to wait here a little, as the machinery is not used to
+ // quick create-delete-cycles
+ Thread.sleep(20*1000L);
- // try to remove the created resource
- Response response =
given()
- .queryParam("q", "test-simple.war")
.header(acceptJson)
+ .queryParam("physical", "true") // Also remove target on the EAP instance
+ .pathParam("id",createdResourceId)
+ .log().everything()
.expect()
.log().everything()
.when()
- .get("/resource");
-
- List links = response.body().jsonPath().getList("links");
-
- System.out.println(links);
- assert links!=null;
-
- if (links.size()>0) {
-
- String link = null;
- @SuppressWarnings("unchecked")
- List<Map<String,Map<String,String>>> listOfMaps = (List<Map<String, Map<String, String>>>) links.get(0);
-
- for (Map<String,Map<String,String>> map : listOfMaps) {
- if (map.containsKey("self")) {
- link = map.get("self").get("href");
- break;
- }
- }
-
- assert link != null;
-
- System.out.println("Link: " + link);
-
- given()
- .header(acceptJson)
- .queryParam("physical","true") // Also remove target on the EAP instance
- .expect()
- .log().everything()
- .when()
- .delete(link);
- }
+ .delete("/resource/{id}");
}
11 years, 1 month
[rhq] modules/enterprise
by mazz
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 38 ++++++++++
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java | 3
2 files changed, 41 insertions(+)
New commits:
commit 80e9f520ab6dfa5fa42357aa7fa5dbfdeb98d631
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu May 9 21:50:21 2013 -0400
BZ 951382 - if keystore/truststore is left undefined in agent config, we'll explicitly set the pref for the user using the "conf/" location
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index d959552..6e1a95a 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -2313,6 +2313,9 @@ public class AgentMain {
* @throws Exception if any error causes the startup to fail
*/
private void startCommServices(BootstrapLatchCommandListener listener) throws Exception {
+ // BZ 951382 - if any locations for keystore/truststore are not configured, set our own defaults to the conf/ directory
+ assignDefaultLocationToKeystoreTruststoreFiles();
+
// create our client sender so we can send commands to our server
// do this before we create our auto-discovery listener and start the server-side services
// since it will be needed by the listener very quickly if the server is already online
@@ -2348,6 +2351,41 @@ public class AgentMain {
return;
}
+ private void assignDefaultLocationToKeystoreTruststoreFiles() {
+ File confDir = new File("conf");
+ if (!confDir.exists()) {
+ return; // conf/ doesn't exist (perhaps we are running in a test?) - do nothing and just fallback to the standard defaults
+ }
+
+ String prefNamesFileNames[][] = {
+ { ServiceContainerConfigurationConstants.CONNECTOR_SECURITY_KEYSTORE_FILE,
+ ServiceContainerConfigurationConstants.DEFAULT_CONNECTOR_SECURITY_KEYSTORE_FILE_NAME },
+ { ServiceContainerConfigurationConstants.CONNECTOR_SECURITY_TRUSTSTORE_FILE,
+ ServiceContainerConfigurationConstants.DEFAULT_CONNECTOR_SECURITY_TRUSTSTORE_FILE_NAME },
+ { AgentConfigurationConstants.CLIENT_SENDER_SECURITY_KEYSTORE_FILE,
+ AgentConfigurationConstants.DEFAULT_CLIENT_SENDER_SECURITY_KEYSTORE_FILE_NAME },
+ { AgentConfigurationConstants.CLIENT_SENDER_SECURITY_TRUSTSTORE_FILE,
+ AgentConfigurationConstants.DEFAULT_CLIENT_SENDER_SECURITY_TRUSTSTORE_FILE_NAME } };
+
+ Preferences prefs = m_configuration.getPreferences();
+ for (String[] prefNameFileName : prefNamesFileNames) {
+ String value = prefs.get(prefNameFileName[0], null);
+ if (value == null) {
+ value = new File(confDir, prefNameFileName[1]).getAbsolutePath();
+ prefs.put(prefNameFileName[0], value);
+ LOG.debug(AgentI18NResourceKeys.CERT_FILE_LOCATION, prefNameFileName[0], value);
+ }
+ }
+
+ try {
+ prefs.flush();
+ } catch (Exception e) {
+ LOG.warn(AgentI18NResourceKeys.CANNOT_STORE_PREFERENCES, "keystore/truststore files", e);
+ }
+
+ return;
+ }
+
private boolean isAutoDiscoveryEnabled() {
return m_autoDiscoveryListener != null;
}
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java
index 10761ff..21a39a9 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java
@@ -28,6 +28,9 @@ import mazz.i18n.annotation.I18NResourceBundle;
*/
@I18NResourceBundle(baseName = "agent-messages", defaultLocale = "en")
public interface AgentI18NResourceKeys {
+ @I18NMessage("Explicitly setting file location [{0}] to [{1}]")
+ String CERT_FILE_LOCATION = "AgentConfiguration.cert-file-location";
+
@I18NMessage("The configured server alias [{0}] cannot be resolved - will use localhost address. Cause: {1}")
String SERVER_ALIAS_UNKNOWN = "AgentConfiguration.server-alias-unknown";
11 years, 1 month
[rhq] Branch 'hotfix/jon3.1.2' - modules/plugins
by Larry O'Leary
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 6f54aa596b809b75e0190b7a9fd9e033aaead1bb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 29 11:15:34 2013 -0400
BZ 957282 957288 add bundle target of "Install Directory"
(cherry picked from commit fabce7666b08f73ea113807ec42b47a3d3eb5929)
(cherry picked from commit a214605ec9abd53cc20b0a3eeeed34465b54e9f1)
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 ff4644b..a2f23a7 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
@@ -1329,6 +1329,10 @@
</drift-definition>
<bundle-target>
+ <destination-base-dir name="Install Directory" description="The top directory where the application server is installed. (i.e. the value found in the 'Home Directory' connection property)">
+ <value-context>pluginConfiguration</value-context>
+ <value-name>homeDir</value-name>
+ </destination-base-dir>
<destination-base-dir name="Deploy Directory" description="The deployment directory for a standalone server">
<value-context>measurementTrait</value-context>
<value-name>deployDir</value-name>
11 years, 1 month
[rhq] Branch 'release/jon3.1.x' - modules/plugins
by Larry O'Leary
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit a214605ec9abd53cc20b0a3eeeed34465b54e9f1
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Apr 29 11:15:34 2013 -0400
BZ 957282 957288 add bundle target of "Install Directory"
(cherry picked from commit fabce7666b08f73ea113807ec42b47a3d3eb5929)
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 ff4644b..a2f23a7 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
@@ -1329,6 +1329,10 @@
</drift-definition>
<bundle-target>
+ <destination-base-dir name="Install Directory" description="The top directory where the application server is installed. (i.e. the value found in the 'Home Directory' connection property)">
+ <value-context>pluginConfiguration</value-context>
+ <value-name>homeDir</value-name>
+ </destination-base-dir>
<destination-base-dir name="Deploy Directory" description="The deployment directory for a standalone server">
<value-context>measurementTrait</value-context>
<value-name>deployDir</value-name>
11 years, 1 month
[rhq] Branch 'hotfix/jon3.1.2' - modules/plugins
by Larry O'Leary
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
New commits:
commit 3a5d7b1ce3c369b8fa19d1bae082e7a71009550f
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Mar 6 12:24:27 2013 +0100
[BZ 894493] - [as7] Start operation returns failure when start script returns exit code 0 (success). Added the test for the exit[C code.
(cherry-pick from c0fe931b74ac8eccfc5be8af2275bea5d8c0c917)
(cherry picked from commit ca4fdfafa7546c03d6d809d2c01a50f8cedc4432)
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 98a46d2..b4c7aa4 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -330,8 +330,9 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
logExecutionResults(results);
if (results.getError() != null) {
operationResult.setErrorMessage(results.getError().getMessage());
- } else if (results.getExitCode() != null) {
- operationResult.setErrorMessage("Start failed with error code " + results.getExitCode() + ":\n" + results.getCapturedOutput());
+ } else if (results.getExitCode() != null && results.getExitCode() != 0) {
+ operationResult.setErrorMessage("Start failed with error code " + results.getExitCode() + ":\n"
+ + results.getCapturedOutput());
} else {
// Try to connect to the server - ping once per second, timing out after 20s.
boolean up = waitForServerToStart();
11 years, 1 month
[rhq] Branch 'release/jon3.1.x' - modules/plugins
by Larry O'Leary
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
New commits:
commit ca4fdfafa7546c03d6d809d2c01a50f8cedc4432
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Wed Mar 6 12:24:27 2013 +0100
[BZ 894493] - [as7] Start operation returns failure when start script returns exit code 0 (success). Added the test for the exit[C code.
(cherry-pick from c0fe931b74ac8eccfc5be8af2275bea5d8c0c917)
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 98a46d2..b4c7aa4 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -330,8 +330,9 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
logExecutionResults(results);
if (results.getError() != null) {
operationResult.setErrorMessage(results.getError().getMessage());
- } else if (results.getExitCode() != null) {
- operationResult.setErrorMessage("Start failed with error code " + results.getExitCode() + ":\n" + results.getCapturedOutput());
+ } else if (results.getExitCode() != null && results.getExitCode() != 0) {
+ operationResult.setErrorMessage("Start failed with error code " + results.getExitCode() + ":\n"
+ + results.getCapturedOutput());
} else {
// Try to connect to the server - ping once per second, timing out after 20s.
boolean up = waitForServerToStart();
11 years, 1 month
[rhq] Branch 'feature/cassandra-backend' - modules/enterprise
by snegrea
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java | 91 ++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/SessionManagerBean.java | 68 ------
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 101 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java | 9
4 files changed, 204 insertions(+), 65 deletions(-)
New commits:
commit f4375bc5908aacf15c0e5ef0e49504c755286056
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Thu May 9 16:04:44 2013 -0500
Move the storage node discovery code from the session manager bean to the storage manager bean. Attempt to find the resources associated with the storage node seed list. Fill in the status of the storage node based on the resource information.
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
index 7418f71..1f6959e 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
@@ -20,13 +20,24 @@
package org.rhq.enterprise.server.cloud;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
+import java.util.UUID;
+import javax.persistence.Query;
+
+import org.testng.Assert;
import org.testng.annotations.Test;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.cloud.StorageNode;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
@@ -48,6 +59,50 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
overlord = LookupUtil.getSubjectManager().getOverlord();
}
+ @Test
+ public void testInit() throws Exception {
+ final String cassandraSeedsProperty = "rhq.cassandra.seeds";
+ final String originalSeedValue = System.getProperty(cassandraSeedsProperty);
+
+ try {
+ executeInTransaction(new TransactionCallback() {
+
+ @Override
+ public void execute() throws Exception {
+ System.setProperty(cassandraSeedsProperty,
+ "testhost|123|123,hostWithNoFoundResource|987|987,secondHostWithNoFoundResource|123|123");
+
+ String testHostName = "testhost";
+
+ cleanDatabase();
+
+ ResourceType testResourceType = createResourceType();
+ Resource testResource = createResource(testResourceType, testHostName);
+
+ nodeManager.scanForStorageNodes();
+
+ List<StorageNode> storageNodes = nodeManager.getStorageNodes();
+ Assert.assertEquals(storageNodes.size(), 3);
+
+ for (StorageNode storageNode : storageNodes) {
+ Assert.assertNotNull(storageNode.getAddress());
+ if (storageNode.getAddress().equals(testHostName)) {
+ Assert.assertNotNull(storageNode.getResource());
+ Assert.assertEquals(storageNode.getResource().getId(), testResource.getId());
+ } else {
+ Assert.assertNull(storageNode.getResource());
+ }
+
+ }
+
+ cleanDatabase();
+ }
+ });
+ } finally {
+ System.setProperty(cassandraSeedsProperty, originalSeedValue);
+ }
+ }
+
@Test(groups = "integration.ejb3")
public void testStorageNodeCriteriaFinder() throws Exception {
@@ -55,7 +110,7 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
executeInTransaction(new TransactionCallback() {
public void execute() throws Exception {
- // verify that all storage nodes objects are actually parsed.
+ // verify that all storage nodes objects are actually parsed.
final Set<String> nodeAddresses = new HashSet<String>(storageNodeCount);
final String prefix = "storage_node";
@@ -109,4 +164,38 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
}
});
}
+
+ private void cleanDatabase() throws Exception {
+ Query query = getEntityManager().createQuery("DELETE from StorageNode");
+ query.executeUpdate();
+
+ query = getEntityManager().createQuery("DELETE from Availability");
+ query.executeUpdate();
+
+ query = getEntityManager().createQuery("DELETE from Resource");
+ query.executeUpdate();
+
+ query = getEntityManager().createQuery("DELETE from ResourceType r WHERE r.name = :name").setParameter(
+ "name", "Cassandra Daemon");
+ query.executeUpdate();
+ }
+
+ private ResourceType createResourceType() throws Exception {
+ ResourceType resourceType = new ResourceType("Cassandra Daemon", "Cassandra", ResourceCategory.SERVER, null);
+ ConfigurationDefinition pluginConfigurationDefinition = new ConfigurationDefinition("config", null);
+ pluginConfigurationDefinition.put(new PropertyDefinitionSimple("host", null, true, PropertySimpleType.STRING));
+ resourceType.setPluginConfigurationDefinition(pluginConfigurationDefinition);
+ getEntityManager().persist(resourceType);
+
+ return resourceType;
+ }
+
+ private Resource createResource(ResourceType resourceType, String host) throws Exception {
+ Resource resource = new Resource("CassandraDaemon", "CassandraDaemon (testhost)", resourceType);
+ resource.setUuid(UUID.randomUUID().toString());
+ resource.getPluginConfiguration().setSimpleValue("host", host);
+ getEntityManager().persist(resource);
+
+ return resource;
+ }
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/SessionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/SessionManagerBean.java
index 2cc0978..a10f4e3 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/SessionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cassandra/SessionManagerBean.java
@@ -26,9 +26,7 @@
package org.rhq.enterprise.server.cassandra;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
@@ -40,7 +38,6 @@ import com.datastax.driver.core.SimpleAuthInfoProvider;
import org.rhq.cassandra.util.ClusterBuilder;
import org.rhq.core.domain.cloud.StorageNode;
-import org.rhq.core.domain.cloud.StorageNode.OperationMode;
import org.rhq.enterprise.server.cloud.StorageNodeManagerLocal;
import org.rhq.server.metrics.CQLException;
import org.rhq.server.metrics.MetricsConfiguration;
@@ -61,8 +58,6 @@ public class SessionManagerBean {
@PostConstruct
private void createSession() {
try {
- this.createStorageNodeEntities();
-
String username = System.getProperty("rhq.cassandra.username");
if (username == null) {
throw new CQLException("The rhq.cassandra.username property is null. Cannot create session.");
@@ -73,27 +68,20 @@ public class SessionManagerBean {
throw new CQLException("The rhq.cassandra.password property is null. Cannot create session.");
}
- String seedProp = System.getProperty("rhq.cassandra.seeds");
- if (seedProp == null) {
- throw new CQLException("The rhq.cassandra.seeds property is null. Cannot create session.");
- }
- int port = -1;
- String[] seeds = seedProp.split(",");
- String[] hostNames = new String[seeds.length];
- for (int i = 0; i < seeds.length; ++i) {
- StorageNode node = new StorageNode();
- node.parseNodeInformation(seeds[i]);
- port = node.getCqlPort();
- hostNames[i] = node.getAddress();
+ List<StorageNode> storageNodes = storageNodeManager.getStorageNodes();
+ if (storageNodes.size() <= 0) {
+ throw new CQLException("Storage node seed list not available.");
}
- if (port == -1) {
- throw new RuntimeException("Failed to initialize client port. Cannot create " +
- Session.class.getName() + " object.");
+ List<String> hostNames = new ArrayList<String>();
+ for (StorageNode storageNode : storageNodes) {
+ hostNames.add(storageNode.getAddress());
}
+ int port = storageNodes.get(0).getCqlPort();
+ System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Cluster cluster = new ClusterBuilder()
- .addContactPoints(hostNames)
+ .addContactPoints((String[]) hostNames.toArray())
.withAuthInfoProvider(new SimpleAuthInfoProvider().add("username", username).add("password", password))
.withPort(port)
.build();
@@ -103,44 +91,6 @@ public class SessionManagerBean {
}
}
- private void createStorageNodeEntities() {
- try {
- String seedProp = System.getProperty("rhq.cassandra.seeds");
- if (seedProp == null) {
- throw new CQLException("The rhq.cassandra.seeds property is null. Cannot create session.");
- }
-
- List<StorageNode> storageNodes = storageNodeManager.getStorageNodes();
- if (storageNodes == null) {
- storageNodes = new ArrayList<StorageNode>();
- }
-
- Map<String, StorageNode> storageNodeMap = new HashMap<String, StorageNode>();
- for (StorageNode storageNode : storageNodes) {
- storageNodeMap.put(storageNode.getAddress(), storageNode);
- }
-
- String[] seeds = seedProp.split(",");
- for (int i = 0; i < seeds.length; ++i) {
- StorageNode discoveredStorageNode = new StorageNode();
- discoveredStorageNode.parseNodeInformation(seeds[i]);
- discoveredStorageNode.setOperationMode(OperationMode.NORMAL);
-
- if (storageNodeMap.containsKey(discoveredStorageNode.getAddress())) {
- StorageNode existingStorageNode = storageNodeMap.get(discoveredStorageNode.getAddress());
- existingStorageNode.setJmxPort(discoveredStorageNode.getJmxPort());
- existingStorageNode.setCqlPort(discoveredStorageNode.getCqlPort());
- }
- else {
- storageNodeMap.put(discoveredStorageNode.getAddress(), discoveredStorageNode);
- }
- }
-
- storageNodeManager.updateStorageNodeList(storageNodeMap.values());
- } catch (Exception e) {
- throw new CQLException("Unable to create session", e);
- }
- }
public Session getSession() {
return session;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index 5b2479a..feecabd 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -24,9 +24,14 @@
*/
package org.rhq.enterprise.server.cloud;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import javax.ejb.EJB;
+import javax.ejb.Init;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@@ -37,12 +42,20 @@ import org.jetbrains.annotations.Nullable;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.authz.Permission;
import org.rhq.core.domain.cloud.StorageNode;
+import org.rhq.core.domain.cloud.StorageNode.OperationMode;
+import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.domain.criteria.StorageNodeCriteria;
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.resource.InventoryStatus;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.util.PageList;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.authz.RequiredPermission;
+import org.rhq.enterprise.server.resource.ResourceManagerLocal;
import org.rhq.enterprise.server.util.CriteriaQueryGenerator;
import org.rhq.enterprise.server.util.CriteriaQueryRunner;
+import org.rhq.server.metrics.CQLException;
@Stateless
public class StorageNodeManagerBean implements StorageNodeManagerLocal {
@@ -50,6 +63,91 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal {
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
private EntityManager entityManager;
+ @EJB
+ ResourceManagerLocal resourceManager;
+
+ @Init
+ @Override
+ public void scanForStorageNodes() {
+ try {
+ String seedProp = System.getProperty("rhq.cassandra.seeds");
+ if (seedProp == null) {
+ throw new CQLException("The rhq.cassandra.seeds property is null. Cannot create session.");
+ }
+
+ List<StorageNode> storageNodes = this.getStorageNodes();
+ if (storageNodes == null) {
+ storageNodes = new ArrayList<StorageNode>();
+ }
+
+ for (StorageNode storageNode : storageNodes) {
+ storageNode.setOperationMode(OperationMode.DOWN);
+ }
+
+ Map<String, StorageNode> storageNodeMap = new HashMap<String, StorageNode>();
+ for (StorageNode storageNode : storageNodes) {
+ storageNodeMap.put(storageNode.getAddress(), storageNode);
+ }
+
+ String[] seeds = seedProp.split(",");
+ for (int i = 0; i < seeds.length; ++i) {
+ StorageNode discoveredStorageNode = new StorageNode();
+ discoveredStorageNode.parseNodeInformation(seeds[i]);
+
+ //Mark the node as down for now since no information is available.
+ //This will change to the correct value once a corresponding resource
+ //is found in the inventory
+ discoveredStorageNode.setOperationMode(OperationMode.DOWN);
+
+ if (storageNodeMap.containsKey(discoveredStorageNode.getAddress())) {
+ StorageNode existingStorageNode = storageNodeMap.get(discoveredStorageNode.getAddress());
+ existingStorageNode.setJmxPort(discoveredStorageNode.getJmxPort());
+ existingStorageNode.setCqlPort(discoveredStorageNode.getCqlPort());
+ } else {
+ storageNodeMap.put(discoveredStorageNode.getAddress(), discoveredStorageNode);
+ }
+ }
+
+ this.discoverResourceInformation(storageNodeMap);
+
+ this.updateStorageNodeList(storageNodeMap.values());
+ } catch (Exception e) {
+ throw new CQLException("Unable to create session", e);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void discoverResourceInformation(Map<String, StorageNode> storageNodeMap) {
+ Query query = entityManager.createNamedQuery(ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN)
+ .setParameter("name", "Cassandra Daemon").setParameter("plugin", "Cassandra");
+ List<ResourceType> resourceTypes = (List<ResourceType>) query.getResultList();
+
+ if (resourceTypes.isEmpty()) {
+ return;
+ }
+
+ query = entityManager.createNamedQuery(Resource.QUERY_FIND_BY_TYPE_ADMIN).setParameter("type",
+ resourceTypes.get(0));
+ List<Resource> cassandraResources = (List<Resource>) query.getResultList();
+
+ for (Resource resource : cassandraResources) {
+ Configuration resourceConfiguration = resource.getPluginConfiguration();
+ String host = resourceConfiguration.getSimpleValue("host");
+
+ if (host != null && storageNodeMap.containsKey(host)) {
+ StorageNode storageNode = storageNodeMap.get(host);
+
+ storageNode.setResource(resource);
+ if(resource.getInventoryStatus() == InventoryStatus.NEW){
+ storageNode.setOperationMode(OperationMode.INSTALLED);
+ } else if (resource.getInventoryStatus() == InventoryStatus.COMMITTED
+ && resource.getCurrentAvailability().getAvailabilityType() == AvailabilityType.UP) {
+ storageNode.setOperationMode(OperationMode.NORMAL);
+ }
+ }
+ }
+ }
+
@SuppressWarnings("unchecked")
@Nullable
public List<StorageNode> getStorageNodes() {
@@ -61,8 +159,9 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal {
for (StorageNode storageNode : storageNodes) {
entityManager.persist(storageNode);
}
+ entityManager.flush();
}
-
+
@RequiredPermission(Permission.MANAGE_SETTINGS)
public PageList<StorageNode> findStorageNodesByCriteria(Subject subject, StorageNodeCriteria criteria) {
CriteriaQueryGenerator generator = new CriteriaQueryGenerator(subject, criteria);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
index e13bc22..dc615ed 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerLocal.java
@@ -31,16 +31,17 @@ import org.rhq.core.domain.util.PageList;
@Local
public interface StorageNodeManagerLocal {
-
+ void scanForStorageNodes();
+
List<StorageNode> getStorageNodes();
void updateStorageNodeList(Collection<StorageNode> storageNodes);
-
+
/**
* Fetches the list of StorageNode entities based on provided criteria.
- *
+ *
* the subject needs to have MANAGE_SETTINGS permissions.
- *
+ *
* @param subject caller
* @param criteria the criteria
* @return list of nodes
11 years, 1 month
[rhq] Branch 'feature/cassandra-backend' - 2 commits - modules/enterprise modules/helpers
by John Sanda
modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java | 8 ++++++--
modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
New commits:
commit cb13460ea77356de6054a2be5ccabc4bb8f6ad30
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu May 9 15:00:55 2013 -0400
fix credentials for creating schema
diff --git a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
index d3085ad..f153dcd 100644
--- a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
+++ b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/Simulator.java
@@ -217,7 +217,7 @@ public class Simulator implements ShutdownManager {
private void createSchema(List<StorageNode> nodes) {
try {
log.info("Creating schema");
- SchemaManager schemaManager = new SchemaManager("rhqadmin", "rhqadmin", nodes);
+ SchemaManager schemaManager = new SchemaManager("cassandra", "cassandra", nodes);
schemaManager.createSchema();
schemaManager.updateSchema();
} catch (Exception e) {
commit 668eda8f5c60eeac0d63a8cdaa05c8cf362f8e8c
Author: John Sanda <jsanda(a)redhat.com>
Date: Thu May 9 14:56:40 2013 -0400
use separate executor and stream handler when running rhq-installer.sh --test
In the startRHQServerForInstallation method we first start the server then
execute rhq-installer.sh --test to verify that the server is ready for the
installer to run. On multiple occassions I got a IllegalThreadStateException
due to trying to run threads in PumpStreamHandler that had already been
stopped. This commit runs rhq-installer.sh --test with a separate executor and
PumpStreamHandler to prevent this from happening.
diff --git a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
index d2e4c0e..d6b6156 100644
--- a/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
+++ b/modules/enterprise/server/server-control/src/main/java/org/rhq/server/control/command/Install.java
@@ -384,11 +384,15 @@ public class Install extends ControlCommand {
log.info("Waiting for server to complete its start up");
commandLine = getCommandLine("rhq-installer", "--test");
+ Executor installerExecutor = new DefaultExecutor();
+ installerExecutor.setWorkingDirectory(binDir);
+ installerExecutor.setStreamHandler(new PumpStreamHandler());
+
// TODO add a max retries (probably want it to be configurable)
- int exitCode = executor.execute(commandLine);
+ int exitCode = installerExecutor.execute(commandLine);
while (exitCode != 0) {
log.debug("Still waiting for server to complete its start up");
- exitCode = executor.execute(commandLine);
+ exitCode = installerExecutor.execute(commandLine);
}
log.info("The server start up has completed");
11 years, 1 month
[rhq] Branch 'bug/620603' - modules/core
by lkrejci
modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java | 21 +++++-----
modules/core/domain/src/main/resources/META-INF/persistence.xml | 2
2 files changed, 12 insertions(+), 11 deletions(-)
New commits:
commit 123778d7ba37b679ca937e27bc48d8bb37e18b1e
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu May 9 15:15:02 2013 +0200
[BZ 620603] - Re-enabling the limited JOIN FETCH reporting
with a more informative message, asking the users to co-operate in
identifying the individual uses of the problematic JOIN FETCH queries that
we potentially missed.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
index f826e41..8eb4b3e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
@@ -15,8 +15,8 @@ import org.hibernate.event.spi.EventSource;
import org.hibernate.hql.internal.ast.QueryTranslatorImpl;
/**
- * This class can be used to quickly identify and analyze usages of JOIN FETCH together with limits on JPA queries.
- * It will log the JPA, generated SQL and a filtered stacktrace for each such usage. This is to enhance the diagnostics
+ * This class can be used to quickly identify and analyze usages of JOIN FETCH together with limits on JPA queries. It
+ * will log the JPA, generated SQL and a filtered stacktrace for each such usage. This is to enhance the diagnostics
* that Hibernate itself offers that merely dumps a message about in-memory filtering of results resulting from the use
* of JOIN FETCH together with limits.
*
@@ -24,7 +24,7 @@ import org.hibernate.hql.internal.ast.QueryTranslatorImpl;
*/
public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
- private static Log LOG = LogFactory.getLog("JOIN FETCH Perf");
+ private static Log LOG = LogFactory.getLog("JOIN FETCH Performance");
public JoinFetchReportingQueryTranslator(String queryIdentifier, String query, Map enabledFilters,
SessionFactoryImplementor factory) {
@@ -49,11 +49,14 @@ public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
}
}
- public void report() {
+ public void report(String method) {
if (time != 0) {
time = System.currentTimeMillis() - time;
- LOG.warn("List with first: " + firstRow + ", max: " + maxRows + " took " + time + "ms:\n" +
- getQueryString() + "\n\nSQL:\n" + getSQLString() + "\n" + extractRHQCalls(new Exception()));
+ LOG.warn("Encountered a query with potentially bad performance. While this is not a bug and the " +
+ "system functions as designed, please report this to RHQ community so that we can reimplement our" +
+ " code to work better.\n" + method + "() with first: " + firstRow + ", max: " + maxRows + " took "
+ + time + "ms:\n" + getQueryString() + "\n\nSQL:\n" + getSQLString() + "\n" +
+ extractRHQCalls(new Exception()));
}
}
@@ -80,7 +83,7 @@ public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
List ret = super.list(session, queryParameters);
- usage.report();
+ usage.report("list");
return ret;
}
@@ -91,7 +94,7 @@ public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
Iterator ret = super.iterate(queryParameters, session);
- usage.report();
+ usage.report("iterate");
return ret;
}
@@ -103,7 +106,7 @@ public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
ScrollableResults ret = super.scroll(queryParameters, session);
- usage.report();
+ usage.report("scroll");
return ret;
}
diff --git a/modules/core/domain/src/main/resources/META-INF/persistence.xml b/modules/core/domain/src/main/resources/META-INF/persistence.xml
index a15fd2e..1bbd8c2 100644
--- a/modules/core/domain/src/main/resources/META-INF/persistence.xml
+++ b/modules/core/domain/src/main/resources/META-INF/persistence.xml
@@ -21,9 +21,7 @@
<!--<property name="com.intellij.javaee.persistence.datasource" value="rhq-oracle" />-->
<property name="com.intellij.javaee.persistence.datasource" value="rhq-postgres" />
- <!-- Used only for debugging the usages of JOIN FETCHes
<property name="hibernate.query.factory_class" value="org.rhq.core.domain.util.JoinFetchReportingQueryTranslatorFactory" />
- -->
<!-- This value doesn't have any theoretical grounds and is purely based on experiments. Value of 32 gives
the best compromise between the quick load of queries with low and high limits (i.e. page size in tens vs.
11 years, 1 month