[rhq] Branch 'release-3.0.0' - modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 8cd52536cba1ff8546c6b0c7b9e434dd71549f29
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Dec 20 12:57:13 2010 +0100
BZ 663987 - disable direct path insert for the key, as direct path insert does not support select(<same table>) in the same Tx.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
index 770ae6e..1658438 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/CallTimeDataManagerBean.java
@@ -80,7 +80,7 @@ public class CallTimeDataManagerBean implements CallTimeDataManagerLocal, CallTi
private static final String DATA_VALUE_TABLE_NAME = "RHQ_CALLTIME_DATA_VALUE";
private static final String DATA_KEY_TABLE_NAME = "RHQ_CALLTIME_DATA_KEY";
- private static final String CALLTIME_KEY_INSERT_STATEMENT = "INSERT /*+ APPEND */ INTO " + DATA_KEY_TABLE_NAME
+ private static final String CALLTIME_KEY_INSERT_STATEMENT = "INSERT INTO " + DATA_KEY_TABLE_NAME
+ "(id, schedule_id, call_destination) " + "SELECT %s, ?, ? FROM RHQ_numbers WHERE i = 42 "
+ "AND NOT EXISTS (SELECT * FROM " + DATA_KEY_TABLE_NAME + " WHERE schedule_id = ? AND call_destination = ?)";
13 years, 5 months
[rhq] modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java | 106 ++++++++--
1 file changed, 85 insertions(+), 21 deletions(-)
New commits:
commit 42b8ca52ac85b6d7e71b8786e2ff64037e7c566d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Mon Dec 20 11:58:42 2010 +0100
Better cleanup and introduce a sleep() call, as the previous mergeMeasurementReport is largely asynchronous inside. Sleep prevents random test failures.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java
index 734f1df..2c3ab88 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java
@@ -18,11 +18,15 @@
*/
package org.rhq.enterprise.server.measurement.test;
+import java.util.ArrayList;
import java.util.Date;
+import java.util.List;
import java.util.Random;
import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -37,6 +41,7 @@ import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
import org.rhq.core.domain.measurement.MeasurementUnits;
import org.rhq.core.domain.measurement.calltime.CallTimeData;
import org.rhq.core.domain.measurement.calltime.CallTimeDataComposite;
+import org.rhq.core.domain.measurement.calltime.CallTimeDataKey;
import org.rhq.core.domain.resource.Agent;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceCategory;
@@ -55,6 +60,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class MeasurementDataManagerTest extends AbstractEJB3Test {
+ private static final int DELTA = 20;
private MeasurementDataManagerLocal measurementDataManager;
private CallTimeDataManagerLocal callTimeDataManager;
@@ -63,6 +69,8 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
private Resource resource1,resource2;
private MeasurementDefinition definitionCt1;
private MeasurementDefinition definitionCt2;
+ private ResourceType theResourceType;
+ private Agent theAgent;
@BeforeMethod
public void beforeMethod() {
@@ -79,11 +87,60 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
}
+ @AfterMethod
+ public void afterMethod() {
+
+ try {
+ // delete values
+ callTimeDataManager.purgeCallTimeData(new Date());
+
+ EntityManager em = beginTx();
+ // delete keys
+ List<Integer> resourceIds = new ArrayList<Integer>();
+ resourceIds.add(resource1.getId());
+ resourceIds.add(resource2.getId());
+ Query q = em.createNamedQuery(CallTimeDataKey.QUERY_DELETE_BY_RESOURCES);
+ q.setParameter("resourceIds",resourceIds);
+ q.executeUpdate();
+
+ resource1 = em.merge(resource1);
+ for (MeasurementSchedule sched : resource1.getSchedules()) {
+ em.remove(sched);
+ }
+ em.remove(resource1);
+
+ resource2 = em.merge(resource2);
+ for (MeasurementSchedule sched : resource2.getSchedules()) {
+ em.remove(sched);
+ }
+ em.remove(resource2);
+
+ definitionCt1 = em.merge(definitionCt1);
+ em.remove(definitionCt1);
+ definitionCt2 = em.merge(definitionCt2);
+ em.remove(definitionCt2);
+
+ theResourceType = em.merge(theResourceType);
+ em.remove(theResourceType);
+
+ theAgent = em.merge(theAgent);
+ em.remove(theAgent);
+
+ commitAndClose(em);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+ }
+
+
@Test
public void bz658491() throws Exception {
- EntityManager em = beginTx();
try {
+ EntityManager em = beginTx();
+
setupResources(em);
MeasurementSchedule schedule1 = new MeasurementSchedule(definitionCt1,resource1);
@@ -97,6 +154,7 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
resource2.addSchedule(schedule2);
em.flush();
+ long now = System.currentTimeMillis();
MeasurementScheduleRequest request1 = new MeasurementScheduleRequest(schedule1);
MeasurementScheduleRequest request2 = new MeasurementScheduleRequest(schedule2);
@@ -111,14 +169,18 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
report.addData(data1);
report.addData(data2);
+ commitAndClose(em);
+
measurementDataManager.mergeMeasurementReport(report);
- em.flush();
+ // Do not remove this sleep -- the previous is is asynchronous
+ // and the sleep "guarantees" that data is actually hitting the db
+ Thread.sleep(1000);
PageList<CallTimeDataComposite> list1 = callTimeDataManager.findCallTimeDataForResource(overlord,schedule1.getId(),
- 0,System.currentTimeMillis(),new PageControl());
+ now-DELTA,System.currentTimeMillis()+DELTA,new PageControl());
PageList<CallTimeDataComposite> list2 = callTimeDataManager.findCallTimeDataForResource(overlord,schedule2.getId(),
- 0,System.currentTimeMillis(),new PageControl());
+ now-DELTA,System.currentTimeMillis()+DELTA,new PageControl());
assert list1 != null;
assert list2 != null;
@@ -130,19 +192,15 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
} catch (Exception e) {
e.printStackTrace();
throw e;
- } finally {
- if (em != null) {
- getTransactionManager().rollback();
- em.close();
- }
}
}
- @Test(enabled = false)
+ @Test
public void bz658491OneResource() throws Exception {
- EntityManager em = beginTx();
try {
+ EntityManager em = beginTx();
+
setupResources(em);
MeasurementSchedule schedule1 = new MeasurementSchedule(definitionCt1,resource1);
@@ -156,6 +214,7 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
resource2.addSchedule(schedule2);
em.flush();
+ long now = System.currentTimeMillis();
MeasurementScheduleRequest request1 = new MeasurementScheduleRequest(schedule1);
MeasurementScheduleRequest request2 = new MeasurementScheduleRequest(schedule2);
@@ -170,14 +229,18 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
report.addData(data1);
report.addData(data2);
+ commitAndClose(em);
+
measurementDataManager.mergeMeasurementReport(report);
- em.flush();
+ // Do not remove this sleep -- the previous is is asynchronous
+ // and the sleep "guarantees" that data is actually hitting the db
+ Thread.sleep(1000);
PageList<CallTimeDataComposite> list1 = callTimeDataManager.findCallTimeDataForResource(overlord,schedule1.getId(),
- 0,System.currentTimeMillis(),new PageControl());
+ now- DELTA,System.currentTimeMillis()+ DELTA,new PageControl());
PageList<CallTimeDataComposite> list2 = callTimeDataManager.findCallTimeDataForResource(overlord,schedule2.getId(),
- 0,System.currentTimeMillis(),new PageControl());
+ now- DELTA,System.currentTimeMillis()+ DELTA,new PageControl());
assert list1 != null;
assert list2 != null;
@@ -189,11 +252,6 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
} catch (Exception e) {
e.printStackTrace();
throw e;
- } finally {
- if (em != null) {
- getTransactionManager().rollback();
- em.close();
- }
}
}
@@ -205,10 +263,10 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
*
*/
private void setupResources(EntityManager em) {
- Agent theAgent = new Agent("testagent", "localhost", 1234, "", "randomToken");
+ theAgent = new Agent("testagent", "localhost", 1234, "", "randomToken");
em.persist(theAgent);
- ResourceType theResourceType = new ResourceType("test-plat", "test-plugin", ResourceCategory.PLATFORM, null);
+ theResourceType = new ResourceType("test-plat", "test-plugin", ResourceCategory.PLATFORM, null);
em.persist(theResourceType);
definitionCt1 = new MeasurementDefinition("CT-Def1", MeasurementCategory.PERFORMANCE,
@@ -237,4 +295,10 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
EntityManager em = getEntityManager();
return em;
}
+
+ private void commitAndClose(EntityManager em) throws Exception {
+ em.flush();
+ getTransactionManager().commit();
+ em.close();
+ }
}
13 years, 5 months
[rhq] modules/core
by lkrejci
modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 6d4c02a946fe0117ba033b385a747b0a9d1e133b
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Dec 20 10:58:40 2010 +0100
BZ 656471 - adding missing index definition in db setup.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
index 8108cb9..903f334 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
@@ -133,6 +133,10 @@
<field ref="TIME_STAMP"/>
</primaryKey>
</constraint>
+
+ <index name="RHQ_MEAS_DATA_1D_TIME_IDX">
+ <field ref="TIME_STAMP" />
+ </index>
</table>
13 years, 5 months
[rhq] Branch 'release-3.0.0' - modules/core
by lkrejci
modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml | 4 ++++
1 file changed, 4 insertions(+)
New commits:
commit 4f29065c937833a03f96d5d09f2f36d9fd5781f9
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Mon Dec 20 10:58:40 2010 +0100
BZ 656471 - adding missing index definition in db setup.
diff --git a/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml b/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
index 8108cb9..903f334 100644
--- a/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
+++ b/modules/core/dbutils/src/main/scripts/dbsetup/measurement-schema.xml
@@ -133,6 +133,10 @@
<field ref="TIME_STAMP"/>
</primaryKey>
</constraint>
+
+ <index name="RHQ_MEAS_DATA_1D_TIME_IDX">
+ <field ref="TIME_STAMP" />
+ </index>
</table>
13 years, 5 months
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 26 +++++-----
1 file changed, 13 insertions(+), 13 deletions(-)
New commits:
commit 652d90efa3584115cf6c0747902e449e59a41038
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Dec 20 04:20:04 2010 -0500
append new lines to enhanced group authorization where fragment
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 2ef27e2..ea4cf62 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -183,7 +183,7 @@ public final class CriteriaQueryGenerator {
* chains: 1) role-based for groups, 2) role-based for containing cluster groups, 3) private groups.
* so, we need to support group token authorization using a more complicated where-filter.
*/
- setAuthorizationCustomConditionFragment(getEnhancedGroupAuthorizationJoinFragment(fragment, subjectId));
+ setAuthorizationCustomConditionFragment(getEnhancedGroupAuthorizationWhereFragment(fragment, subjectId));
} else {
throw new IllegalArgumentException(this.getClass().getSimpleName()
+ " does not yet support generating queries for '" + type + "' token types");
@@ -206,19 +206,19 @@ public final class CriteriaQueryGenerator {
}
}
- private String getEnhancedGroupAuthorizationJoinFragment(String fragment, int subjectId) {
+ private String getEnhancedGroupAuthorizationWhereFragment(String fragment, int subjectId) {
String customAuthzFragment = "" //
- + "( %alias%.id IN ( SELECT %alias%.id " //
- + " FROM %alias%.roles r JOIN r.subjects s " //
- + " WHERE s.id = %subjectId% )" //
- + " OR" //
- + " %alias%.id IN ( SELECT %alias%.id " //
- + " FROM %alias%.clusterResourceGroup crg JOIN crg.roles r JOIN r.subjects s " //
- + " WHERE crg.recursive = true AND s = %subjectId% )" //
- + " OR" //
- + " %alias%.id IN ( SELECT %alias%.id" //
- + " FROM %alias%.subject s" //
- + " WHERE s.id = %subjectId% )";
+ + "( %alias%.id IN ( SELECT %alias%.id " + NL //
+ + " FROM %alias%.roles r JOIN r.subjects s " + NL //
+ + " WHERE s.id = %subjectId% )" + NL //
+ + " OR" + NL //
+ + " %alias%.id IN ( SELECT %alias%.id " + NL //
+ + " FROM %alias%.clusterResourceGroup crg JOIN crg.roles r JOIN r.subjects s " + NL //
+ + " WHERE crg.recursive = true AND s = %subjectId% )" + NL //
+ + " OR" + NL //
+ + " %alias%.id IN ( SELECT %alias%.id" + NL //
+ + " FROM %alias%.subject s" + NL //
+ + " WHERE s.id = %subjectId% ) ) " + NL;
String aliasReplacement = (fragment != null ? fragment + "." : "") + criteria.getAlias();
customAuthzFragment = customAuthzFragment.replace("%alias%", aliasReplacement);
customAuthzFragment = customAuthzFragment.replace("%subjectId%", String.valueOf(subjectId));
13 years, 5 months
[rhq] 3 commits - modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 4 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java | 2
modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 35 +++++++---
4 files changed, 31 insertions(+), 11 deletions(-)
New commits:
commit 6183f641287c29b574b12b8a0615bf77a902ec8f
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Dec 20 04:02:13 2010 -0500
enhance group authorization token fragment to account for all group types
* supported types are the 1) regular role-based joins, 2) role-based joins
to the containing cluster group, 3) private / subject-owned groups
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 32c6950..2ef27e2 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -178,16 +178,12 @@ public final class CriteriaQueryGenerator {
+ "JOIN authRole.subjects authSubject " + NL;
}
} else if (type == AuthorizationTokenType.GROUP) {
- if (fragment == null) {
- this.authorizationJoinFragment = "" //
- + "JOIN " + alias + ".roles authRole " + NL //
- + "JOIN authRole.subjects authSubject " + NL;
- } else {
- this.authorizationJoinFragment = "" //
- + "JOIN " + alias + "." + fragment + " authGroup " + NL //
- + "JOIN authGroup.roles authRole " + NL //
- + "JOIN authRole.subjects authSubject " + NL;
- }
+ /*
+ * can no longer use JOIN-based filters for groups. need to support 3 completely separate authorization
+ * chains: 1) role-based for groups, 2) role-based for containing cluster groups, 3) private groups.
+ * so, we need to support group token authorization using a more complicated where-filter.
+ */
+ setAuthorizationCustomConditionFragment(getEnhancedGroupAuthorizationJoinFragment(fragment, subjectId));
} else {
throw new IllegalArgumentException(this.getClass().getSimpleName()
+ " does not yet support generating queries for '" + type + "' token types");
@@ -210,6 +206,25 @@ public final class CriteriaQueryGenerator {
}
}
+ private String getEnhancedGroupAuthorizationJoinFragment(String fragment, int subjectId) {
+ String customAuthzFragment = "" //
+ + "( %alias%.id IN ( SELECT %alias%.id " //
+ + " FROM %alias%.roles r JOIN r.subjects s " //
+ + " WHERE s.id = %subjectId% )" //
+ + " OR" //
+ + " %alias%.id IN ( SELECT %alias%.id " //
+ + " FROM %alias%.clusterResourceGroup crg JOIN crg.roles r JOIN r.subjects s " //
+ + " WHERE crg.recursive = true AND s = %subjectId% )" //
+ + " OR" //
+ + " %alias%.id IN ( SELECT %alias%.id" //
+ + " FROM %alias%.subject s" //
+ + " WHERE s.id = %subjectId% )";
+ String aliasReplacement = (fragment != null ? fragment + "." : "") + criteria.getAlias();
+ customAuthzFragment = customAuthzFragment.replace("%alias%", aliasReplacement);
+ customAuthzFragment = customAuthzFragment.replace("%subjectId%", String.valueOf(subjectId));
+ return customAuthzFragment;
+ }
+
public String getParameterReplacedQuery(boolean countQuery) {
String query = getQueryString(countQuery);
commit de53f73d84df7e7815cfff2d15d86f5f7a4748c7
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Dec 20 03:58:48 2010 -0500
add commented out debugging parameters to rhq-server.sh
diff --git a/modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh b/modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh
index bbef0bf..b08ceaa 100644
--- a/modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh
+++ b/modules/enterprise/server/container/src/main/bin-resources/bin/rhq-server.sh
@@ -54,6 +54,7 @@
# is mainly used to augment the Server's
# default set of options. This can be
# left unset if it is not needed.
+#RHQ_SERVER_ADDITIONAL_JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n
#
# RHQ_SERVER_CMDLINE_OPTS - If this is defined, these are the command line
# arguments that will be passed to the RHQ Server
commit 9ba744a9f8089930ade0def90731ae0456f13af2
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Dec 20 02:20:37 2010 -0500
up the timeout for recalculating group definitions - it could be expensive
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
index 981fadc..d675373 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java
@@ -62,6 +62,10 @@ public class GWTServiceLookup {
return secure(ResourceGroupGWTServiceAsync.Util.getInstance());
}
+ public static ResourceGroupGWTServiceAsync getResourceGroupService(int timeout) {
+ return secure(ResourceGroupGWTServiceAsync.Util.getInstance(), timeout);
+ }
+
public static ResourceTypeGWTServiceAsync getResourceTypeGWTService() {
return secure(ResourceTypeGWTServiceAsync.Util.getInstance());
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
index 9ab4029..7ad448a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/definitions/SingleGroupDefinitionView.java
@@ -150,7 +150,7 @@ public class SingleGroupDefinitionView extends LocatableVLayout implements Bookm
form.saveData(new DSCallback() {
@Override
public void execute(DSResponse response, Object rawData, DSRequest request) {
- GWTServiceLookup.getResourceGroupService().recalculateGroupDefinitions(
+ GWTServiceLookup.getResourceGroupService(600000).recalculateGroupDefinitions(
new int[] { groupDefinitionId }, new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
13 years, 5 months
[rhq] modules/enterprise
by mazz
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java | 16 +++++-----
1 file changed, 8 insertions(+), 8 deletions(-)
New commits:
commit a803ca2fd91ee10ccabe5d398e981db8977caf59
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Mon Dec 20 00:22:30 2010 -0500
fix help text
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 f924d00..5948154 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
@@ -1662,15 +1662,15 @@ public interface AgentI18NResourceKeys {
String LISTDATA_HELP = "PromptCommand.listdata.help";
@I18NMessage("Lists files found in the data directory, optionally deleting them.\\n\\\n"
- + "\\This is an advanced command for adminstrators use only. You should not\\n\\\n"
- + "\\delete data files unless you know what you are doing. You could render\\n\\\n"
- + "\\the agent useless if you delete files that you should not.\\n\\\n"
- + "\\ -v, --verbose={true|false} : enables/disables more detailed file lists\\n\\\n"
- + "\\ -r, --recurse: recurse down subdirectories\\n\\\n"
+ + "This is an advanced command for administrators use only. You should not\\n\\\n"
+ + "delete data files unless you know what you are doing. You could render\\n\\\n"
+ + "the agent useless if you delete files that you should not.\\n\\\n"
+ + "\\ -v, --verbose : enables more detailed file lists\\n\\\n"
+ + "\\ -r, --recurse : recurse into subdirectories\\n\\\n"
+ "\\ -d, --delete : delete the files that are listed\\n\\\n"
- + "\\ 'bundles'|path_name : the relative path under the data directory to list\\n\\\n"
- + "\\ If 'bundle', will list data files from the bundle\\n\\\n"
- + "\\ subsystem")
+ + "\\ 'bundles'|path_name : the relative path under the data directory to list.\\n\\\n"
+ + "\\ If 'bundles', will list data files from the bundle\\n\\\n"
+ + "\\ subsystem.")
String LISTDATA_DETAILED_HELP = "PromptCommand.listdata.detailed-help";
@I18NMessage("You cannot use .. in the path - you can only list files within the data directory")
13 years, 5 months
[rhq] modules/enterprise
by mazz
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit e2992dff3266c2985ed2b077d3b8fe6b66350460
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Dec 19 23:56:33 2010 -0500
BZ 648579 - type - fix the help constant
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java
index 762ebad..c36fd81 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java
@@ -63,7 +63,7 @@ public class ListDataPromptCommand implements AgentPromptCommand {
}
public String getDetailedHelp() {
- return MSG.getMsg(AgentI18NResourceKeys.GC_DETAILED_HELP);
+ return MSG.getMsg(AgentI18NResourceKeys.LISTDATA_DETAILED_HELP);
}
private void processArguments(AgentMain agent, String[] args) {
13 years, 5 months
[rhq] modules/enterprise
by mazz
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 14
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java | 51 ++
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java | 207 ++++++++++
3 files changed, 266 insertions(+), 6 deletions(-)
New commits:
commit 438e904d526a280acafc0a8fc1892269ceaef1ae
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Sun Dec 19 23:51:46 2010 -0500
BZ 648579 add ability to view bundle tmp files and optionally delete them. this adds a general command that lets you peek in the agent data directory and subdirectories
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 43c2ba5..1ffa079 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
@@ -115,6 +115,7 @@ import org.rhq.enterprise.agent.promptcmd.GetConfigPromptCommand;
import org.rhq.enterprise.agent.promptcmd.HelpPromptCommand;
import org.rhq.enterprise.agent.promptcmd.IdentifyPromptCommand;
import org.rhq.enterprise.agent.promptcmd.InventoryPromptCommand;
+import org.rhq.enterprise.agent.promptcmd.ListDataPromptCommand;
import org.rhq.enterprise.agent.promptcmd.LogPromptCommand;
import org.rhq.enterprise.agent.promptcmd.MetricsPromptCommand;
import org.rhq.enterprise.agent.promptcmd.NativePromptCommand;
@@ -1628,7 +1629,7 @@ public class AgentMain {
//the next thing is to setup the conditional restart of the PC if it fails to merge
//the upgrade results with the server due to some network glitch
m_clientSender.addStateListener(new PluginContainerConditionalRestartListener(), false);
-
+
return register;
}
@@ -3036,7 +3037,7 @@ public class AgentMain {
new LogPromptCommand(), new TimerPromptCommand(), new PingPromptCommand(), new DownloadPromptCommand(),
new DumpSpoolPromptCommand(), new SenderPromptCommand(), new FailoverPromptCommand(),
new UpdatePromptCommand(), new DebugPromptCommand(), new SleepPromptCommand(), new GCPromptCommand(),
- new SchedulesPromptCommand() };
+ new SchedulesPromptCommand(), new ListDataPromptCommand() };
// hold the conflicts
StringBuilder conflicts = new StringBuilder();
@@ -3412,15 +3413,16 @@ public class AgentMain {
try {
InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager();
if (inventoryManager != null && inventoryManager.hasUpgradeMergeFailed()) {
- m_output.println(MSG.getMsg(AgentI18NResourceKeys.RESTARTING_PLUGIN_CONTAINER_AFTER_UPGRADE_MERGE_FAILURE));
+ m_output.println(MSG
+ .getMsg(AgentI18NResourceKeys.RESTARTING_PLUGIN_CONTAINER_AFTER_UPGRADE_MERGE_FAILURE));
LOG.info(AgentI18NResourceKeys.RESTARTING_PLUGIN_CONTAINER_AFTER_UPGRADE_MERGE_FAILURE);
-
+
PluginContainerPromptCommand pcCommand = new PluginContainerPromptCommand();
pcCommand.execute(AgentMain.this, new String[] { "stop" });
pcCommand.execute(AgentMain.this, new String[] { "start" });
}
} catch (Exception e) {
- LOG.error("Failed to restart the plugin container when server connection established.");
+ LOG.error("Failed to restart the plugin container when server connection established.");
}
return true;
}
@@ -3430,7 +3432,7 @@ public class AgentMain {
return true;
}
}
-
+
/**
* When the agent starts up, it needs to create the communications servers before starting the plugin container;
* however, the agent must not process any incoming commands until after the plugin container fully starts. This
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 c28349c..f924d00 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
@@ -1652,6 +1652,57 @@ public interface AgentI18NResourceKeys {
@I18NMessage("days")
String UNITS_DAYS = "units.days";
+ @I18NMessage("listdata")
+ String LISTDATA = "PromptCommand.listdata";
+
+ @I18NMessage("listdata [--delete] [--recurse] [--verbose] <'bundles'|path_name>")
+ String LISTDATA_SYNTAX = "PromptCommand.listdata.syntax";
+
+ @I18NMessage("Lists and optionally deletes agent data files. USE WITH CAUTION!")
+ String LISTDATA_HELP = "PromptCommand.listdata.help";
+
+ @I18NMessage("Lists files found in the data directory, optionally deleting them.\\n\\\n"
+ + "\\This is an advanced command for adminstrators use only. You should not\\n\\\n"
+ + "\\delete data files unless you know what you are doing. You could render\\n\\\n"
+ + "\\the agent useless if you delete files that you should not.\\n\\\n"
+ + "\\ -v, --verbose={true|false} : enables/disables more detailed file lists\\n\\\n"
+ + "\\ -r, --recurse: recurse down subdirectories\\n\\\n"
+ + "\\ -d, --delete : delete the files that are listed\\n\\\n"
+ + "\\ 'bundles'|path_name : the relative path under the data directory to list\\n\\\n"
+ + "\\ If 'bundle', will list data files from the bundle\\n\\\n"
+ + "\\ subsystem")
+ String LISTDATA_DETAILED_HELP = "PromptCommand.listdata.detailed-help";
+
+ @I18NMessage("You cannot use .. in the path - you can only list files within the data directory")
+ String LISTDATA_DOTDOT_NOT_ALLOWED = "PromptCommand.listdata.dotdot-not-allowed";
+
+ @I18NMessage("You can only list files within the data directory - no absolute paths allowed")
+ String LISTDATA_ABSOLUTE_NOT_ALLOWED = "PromptCommand.listdata.absolute-not-allowed";
+
+ @I18NMessage("Agent data directory: [{0}]")
+ String LISTDATA_DATA_DIR = "PromptCommand.listdata.data_dir";
+
+ @I18NMessage("File not found: [{0}]")
+ String LISTDATA_FILE_NOT_FOUND = "PromptCommand.listdata.file_not_found";
+
+ @I18NMessage("Deleted: [{0}]")
+ String LISTDATA_DELETED = "PromptCommand.listdata.deleted";
+
+ @I18NMessage("Delete failed: [{0}]")
+ String LISTDATA_DELETED_FAILED = "PromptCommand.listdata.deleted_failed";
+
+ @I18NMessage("{0}")
+ String LISTDATA_FILE_INFO = "PromptCommand.listdata.file_info";
+
+ @I18NMessage("{1,date,short} {1,time,short}\t{2} bytes\t{0}")
+ String LISTDATA_FILE_INFO_VERBOSE = "PromptCommand.listdata.file_info_verbose";
+
+ @I18NMessage("{0}")
+ String LISTDATA_DIR_INFO = "PromptCommand.listdata.dir_info";
+
+ @I18NMessage("{1,date,short} {1,time,short}\t{2} files\t{0}")
+ String LISTDATA_DIR_INFO_VERBOSE = "PromptCommand.listdata.dir_info_verbose";
+
@I18NMessage("gc")
String GC = "PromptCommand.gc";
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java
new file mode 100644
index 0000000..762ebad
--- /dev/null
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/promptcmd/ListDataPromptCommand.java
@@ -0,0 +1,207 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 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.agent.promptcmd;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Date;
+
+import mazz.i18n.Msg;
+
+import org.rhq.enterprise.agent.AgentMain;
+import org.rhq.enterprise.agent.i18n.AgentI18NFactory;
+import org.rhq.enterprise.agent.i18n.AgentI18NResourceKeys;
+
+/**
+ * Allows you to peek into the agent's data directory. This also provides
+ * a way to delete files in the data directory and its subdirectories, allowing
+ * you to clean up temporary or unused data files that may be bloating the agent.
+ *
+ * @author John Mazzitelli
+ */
+public class ListDataPromptCommand implements AgentPromptCommand {
+ private static final Msg MSG = AgentI18NFactory.getMsg();
+
+ public String getPromptCommandString() {
+ return MSG.getMsg(AgentI18NResourceKeys.LISTDATA);
+ }
+
+ public boolean execute(AgentMain agent, String[] args) {
+ // strip the first argument, which is the name of our prompt command
+ String[] realArgs = new String[args.length - 1];
+ System.arraycopy(args, 1, realArgs, 0, args.length - 1);
+
+ processArguments(agent, realArgs);
+ return true;
+ }
+
+ public String getSyntax() {
+ return MSG.getMsg(AgentI18NResourceKeys.LISTDATA_SYNTAX);
+ }
+
+ public String getHelp() {
+ return MSG.getMsg(AgentI18NResourceKeys.LISTDATA_HELP);
+ }
+
+ public String getDetailedHelp() {
+ return MSG.getMsg(AgentI18NResourceKeys.GC_DETAILED_HELP);
+ }
+
+ private void processArguments(AgentMain agent, String[] args) {
+ PrintWriter out = agent.getOut();
+
+ String sopts = "-dvr";
+ LongOpt[] lopts = { new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'),
+ new LongOpt("recurse", LongOpt.NO_ARGUMENT, null, 'r'),
+ new LongOpt("delete", LongOpt.NO_ARGUMENT, null, 'd') };
+
+ Getopt getopt = new Getopt(getPromptCommandString(), args, sopts, lopts);
+ int code;
+ boolean verbose = false;
+ boolean recurse = false;
+ boolean delete = false;
+ String pathname = null;
+
+ while ((pathname == null) && (code = getopt.getopt()) != -1) {
+ switch (code) {
+ case ':':
+ case '?': {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
+ break;
+ }
+
+ case 1: {
+ // we found the path name - stop processing arguments
+ pathname = getopt.getOptarg();
+ break;
+ }
+
+ case 'v': {
+ verbose = true;
+ break;
+ }
+
+ case 'r': {
+ recurse = true;
+ break;
+ }
+
+ case 'd': {
+ delete = true;
+ break;
+ }
+ }
+ }
+
+ if (getopt.getOptind() < args.length || pathname == null) {
+ // we got too many arguments on the command line
+ out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
+ return;
+ }
+
+ // sneaky sneaky - do not allow the user to attempt to go up to parent directories
+ if (pathname.indexOf("..") != -1) {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_DOTDOT_NOT_ALLOWED));
+ return;
+ }
+
+ // sneaky sneaky - do not allow the user to attempt to go to any absolute path
+ if (new File(pathname).isAbsolute()) {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_ABSOLUTE_NOT_ALLOWED));
+ return;
+ }
+
+ String dataDir = agent.getConfiguration().getDataDirectory().getAbsolutePath();
+
+ if (verbose) {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_DATA_DIR, dataDir));
+ }
+
+ if ("bundles".equals(pathname)) {
+ pathname = "tmp/bundle-versions";
+ }
+
+ list(out, dataDir, new File(dataDir, pathname), verbose, recurse, delete);
+
+ return;
+ }
+
+ private void list(PrintWriter out, String dataDir, File file, boolean verbose, boolean recurse, boolean delete) {
+ String relativePath = getRelativePath(dataDir, file);
+
+ if (file.isFile()) {
+ printFileInfo(out, dataDir, file, verbose);
+ } else if (file.isDirectory()) {
+ printDirInfo(out, dataDir, file, verbose);
+ File[] dirFiles = file.listFiles();
+ if (recurse) {
+ for (File dirFile : dirFiles) {
+ list(out, dataDir, dirFile, verbose, recurse, delete);
+ }
+ }
+ } else {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_FILE_NOT_FOUND, relativePath));
+ return;
+
+ }
+
+ if (delete) {
+ boolean ok = file.delete();
+ if (ok) {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_DELETED, relativePath));
+ } else {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_DELETED_FAILED, relativePath));
+ }
+ }
+ }
+
+ private void printFileInfo(PrintWriter out, String dataDir, File file, boolean verbose) {
+ String name = getRelativePath(dataDir, file);
+ if (verbose) {
+ long filesize = file.length();
+ Date lastModified = new Date(file.lastModified());
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_FILE_INFO_VERBOSE, name, lastModified, filesize));
+ } else {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_FILE_INFO, name));
+ }
+ }
+
+ private void printDirInfo(PrintWriter out, String dataDir, File dir, boolean verbose) {
+ String name = getRelativePath(dataDir, dir);
+ if (verbose) {
+ int filecount = dir.listFiles().length;
+ Date lastModified = new Date(dir.lastModified());
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_DIR_INFO_VERBOSE, name, lastModified, filecount));
+ } else {
+ out.println(MSG.getMsg(AgentI18NResourceKeys.LISTDATA_DIR_INFO, name));
+ }
+ }
+
+ private String getRelativePath(String dataDir, File file) {
+ try {
+ return file.getAbsolutePath().substring(dataDir.length());
+ } catch (Exception e) {
+ // something weird happened, just show the path
+ return file.getPath();
+ }
+ }
+}
13 years, 5 months
[rhq] modules/pom.xml
by Joseph Marques
modules/pom.xml | 1 +
1 file changed, 1 insertion(+)
New commits:
commit bb0b69b2a1a0169269f0e2f3189dfc89a6f03fdc
Author: Joseph Marques <joseph(a)redhat.com>
Date: Sun Dec 19 23:06:22 2010 -0500
add core/client-api module to 'coregui' profile
* some bundle classes in server/jar refer to client-api classes
diff --git a/modules/pom.xml b/modules/pom.xml
index 35040d3..f760f66 100644
--- a/modules/pom.xml
+++ b/modules/pom.xml
@@ -87,6 +87,7 @@
</activation>
<modules>
<module>core/domain</module>
+ <module>core/client-api</module>
<module>enterprise/server/jar</module>
<module>enterprise/gui/coregui</module>
</modules>
13 years, 5 months