[rhq] Branch 'drift' - 5 commits - modules/enterprise
by mazz
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java | 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/GWTServiceLookup.java | 15
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TestGWTService.java | 34 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java | 4
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java | 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java | 14
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestRpcView.java | 52 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TestGWTServiceImpl.java | 43 ++
modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml | 8
modules/enterprise/remoting/cli/src/main/samples/drift.js | 153 ++++++++--
modules/enterprise/remoting/cli/src/main/samples/util.js | 17 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java | 2
15 files changed, 332 insertions(+), 56 deletions(-)
New commits:
commit ca05f4252c167e01f0cf4c4bf8ab3b044117a62d
Merge: 64e471e b612594
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Sep 1 09:52:06 2011 -0400
Merge commit 'origin/master' into drift
commit b6125949237abceab2abd2fcee70f339f12c4fa6
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Aug 31 22:33:19 2011 -0400
[BZ 734881] Need to check for empty content because oracle blobs don't handle it
When a file is empty we still persist a row for it in rhq_drift_file.
The blob is set to null. This works fine on postgresql, but results in
the NPE reported in BZ 734881. To work around this, we now check the
size which is also stored in the rhq_drift_file table, and if the size
is zero, DriftManagerBean.getDriftFileContent just returns an empty
stream instead of opening an input stream on the blob.
This required one additional change. We previously were not storing the
size in rhq_drift_file. I have updated
JPADriftServerBean.persistDriftFileData to save the size now as well.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
index daa7a68..16e0d73 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
@@ -211,12 +211,13 @@ public class JPADriftServerBean implements JPADriftServerLocal {
@Override
@TransactionAttribute(REQUIRES_NEW)
- public void persistDriftFileData(JPADriftFile driftFile, InputStream data) throws Exception {
+ public void persistDriftFileData(JPADriftFile driftFile, InputStream data, long numBytes) throws Exception {
JPADriftFileBits df = entityManager.find(JPADriftFileBits.class, driftFile.getHashId());
if (null == df) {
throw new IllegalArgumentException("JPADriftFile not found [" + driftFile.getHashId() + "]");
}
+ df.setDataSize(numBytes);
df.setData(Hibernate.createBlob(new BufferedInputStream(data)));
df.setStatus(LOADED);
}
@@ -377,7 +378,7 @@ public class JPADriftServerBean implements JPADriftServerLocal {
for (File file : dir.listFiles()) {
JPADriftFile driftFile = new JPADriftFile(file.getName());
try {
- JPADriftServer.persistDriftFileData(driftFile, new FileInputStream(file));
+ JPADriftServer.persistDriftFileData(driftFile, new FileInputStream(file), file.length());
} catch (Exception e) {
LogFactory.getLog(getClass()).info("Skipping bad drift file", e);
}
@@ -400,6 +401,9 @@ public class JPADriftServerBean implements JPADriftServerLocal {
try {
JPADriftFileBits content = (JPADriftFileBits) entityManager.createNamedQuery(
JPADriftFileBits.QUERY_FIND_BY_ID).setParameter("hashId", hash).getSingleResult();
+ if (content.getDataSize() == null || content.getDataSize() < 1) {
+ return "";
+ }
byte[] bytes = StreamUtil.slurp(content.getBlob().getBinaryStream());
return new String(bytes);
} catch (SQLException e) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
index 7142ead..9da1a5b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
@@ -85,7 +85,7 @@ public interface JPADriftServerLocal {
* @param data
* @throws Exception
*/
- void persistDriftFileData(JPADriftFile driftFile, InputStream data) throws Exception;
+ void persistDriftFileData(JPADriftFile driftFile, InputStream data, long numBytes) throws Exception;
/**
* This method stores the provided change-set file for the resource. The version will be incremented based
commit 59387081b9bf66be0970958473d8cc52debae774
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Aug 31 17:33:18 2011 -0400
[BZ 734610] remove validator on username field that was disallowing usernames
less than 6 characters long (https://bugzilla.redhat.com/show_bug.cgi?id=734610)
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
index b0d418f..5e915c6 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/LoginView.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -55,7 +55,6 @@ import com.smartgwt.client.widgets.form.fields.SubmitItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
-import com.smartgwt.client.widgets.form.validator.LengthRangeValidator;
import com.smartgwt.client.widgets.form.validator.RegExpValidator;
import com.smartgwt.client.widgets.layout.HStack;
@@ -495,16 +494,6 @@ public class LoginView extends LocatableCanvas {
for (FormItem item : form.getFields()) {
String name = item.getName();
if ((name != null) && (!name.isEmpty())) {
- if (name.equals(USERNAME)) {
- LengthRangeValidator validator = new LengthRangeValidator();
- validator.setMin(6);
- item.setValidators(validator);
- }
- if (name.equals(FIRST)) {
- LengthRangeValidator validator = new LengthRangeValidator();
- validator.setMin(1);
- item.setValidators(validator);
- }
if (name.equals(EMAIL)) {
RegExpValidator emailValidator = new RegExpValidator();
emailValidator.setErrorMessage(MSG.view_login_invalidEmail());
commit f4fdec760496263f02cba9e1e713f124e597a83b
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Aug 31 17:18:11 2011 -0400
[BZ 722548] add new #Test/Rpc view that can be used to invoke a new sleep() RPC
method that sleeps for a specified number of seconds; increase default RPC
timeout from 10s to 30s; use custom timeouts for autodiscovery queue,
config history list, group schedules list views, which may exceed even the new
default timeout (https://bugzilla.redhat.com/show_bug.cgi?id=722548)
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 8f5dbc1..c516592 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
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -58,6 +58,10 @@ public class GWTServiceLookup {
return secure(ConfigurationGWTServiceAsync.Util.getInstance());
}
+ public static ConfigurationGWTServiceAsync getConfigurationService(int timeout) {
+ return secure(ConfigurationGWTServiceAsync.Util.getInstance(), timeout);
+ }
+
public static DriftGWTServiceAsync getDriftService() {
return secure(DriftGWTServiceAsync.Util.getInstance());
}
@@ -190,6 +194,10 @@ public class GWTServiceLookup {
return secure(AgentGWTServiceAsync.Util.getInstance());
}
+ public static TestGWTServiceAsync getTestService() {
+ return secure(TestGWTServiceAsync.Util.getInstance());
+ }
+
@SuppressWarnings("unchecked")
private static <T> T secure(Object sdt) {
return (T) secure(sdt, -1);
@@ -208,7 +216,8 @@ public class GWTServiceLookup {
public static class SessionRpcRequestBuilder extends RpcRequestBuilder {
private static int DEBUG_TIMEOUT_FUDGE_FACTOR = 30000;
- private static int DEFAULT_RPC_TIMEOUT = 10000;
+ private static int DEFAULT_RPC_TIMEOUT = 30000;
+
private int timeout;
public SessionRpcRequestBuilder(int timeout) {
@@ -221,7 +230,7 @@ public class GWTServiceLookup {
this.timeout = (timeout <= 0) ? DEFAULT_RPC_TIMEOUT : timeout;
}
- if (CoreGUI.isDebugMode()) {
+ if (CoreGUI.isDebugMode() && (this.timeout != 0)) {
// debug mode is slow, so give requests more time to complete otherwise you'll get
// weird exceptions whose messages are extremely unhelpful in finding root cause
this.timeout += DEBUG_TIMEOUT_FUDGE_FACTOR;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TestGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TestGWTService.java
new file mode 100644
index 0000000..168edfa
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/TestGWTService.java
@@ -0,0 +1,34 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.gwt;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+
+/**
+ * @author Ian Springer
+ */
+public interface TestGWTService extends RemoteService {
+
+ void sleep(int seconds) throws RuntimeException;
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
index 1f4d491..c21484d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/schedules/SchedulesDataSource.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -43,7 +43,10 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
* @author Ian Springer
*/
public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDataSource {
- private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService();
+
+ // Specify 60s timeout to compensate for schedule updates taking a long time for large groups.
+ // TODO (ips, 08/31/11): Remove this once updating of group schedules has been optimized.
+ private MeasurementDataGWTServiceAsync measurementService = GWTServiceLookup.getMeasurementDataService(60 * 1000);
private int resourceGroupId;
public SchedulesDataSource(int resourceGroupId) {
@@ -157,4 +160,5 @@ public class SchedulesDataSource extends AbstractMeasurementScheduleCompositeDat
}
});
}
+
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
index b92fb94..9991f9c 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/configuration/AbstractConfigurationHistoryDataSource.java
@@ -78,7 +78,9 @@ public abstract class AbstractConfigurationHistoryDataSource<T extends AbstractR
public static final String RESOURCE_ID = "resourceId";
}
- private ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService();
+ // Specify 60s timeout to compensate for Configurations being fetched for all of the config updates.
+ // TODO (ips, 08/31/11): Remove this once fetching of Configurations has been disabled.
+ private ConfigurationGWTServiceAsync configurationService = GWTServiceLookup.getConfigurationService(60 * 1000);
protected ConfigurationGWTServiceAsync getConfigurationService() {
return this.configurationService;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
index 6769b9c..cccc08a 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/AutodiscoveryQueueDataSource.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
+ * Copyright (C) 2005-2011 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -65,7 +65,11 @@ public class AutodiscoveryQueueDataSource extends DataSource {
private int unlimited = -1;
private int maximumPlatformsToDisplay = -1;
- private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(1000000);
+
+ // Specify 60s timeout to compensate for slow loading of this view due to lack of paging of results.
+ // TODO (ips, 08/31/11): Remove this once paging has been implemented.
+ private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(60 * 1000);
+
private PermissionsLoader permissionsLoader = new PermissionsLoader();
private TreeGrid dataContainerReference = null;
private static final Permission MANAGE_INVENTORY = Permission.MANAGE_INVENTORY;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
index 4daa3c6..9b0cfe3 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/discovery/ResourceAutodiscoveryView.java
@@ -79,7 +79,14 @@ public class ResourceAutodiscoveryView extends LocatableVLayout implements Refre
// This allows the selection handler to ignore selection changes initiated by us, as opposed to by the user.
private boolean selectionChangedHandlerDisabled;
- private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(1000000);
+ private ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
+
+ // Specify 3m timeout to compensate for import taking a long time for a large number of Resources.
+ // TODO (ips, 08/31/11): Remove this once import has been refactored to be partially asynchronous, i.e. where the
+ // call to importResources() flips all the Resources to a new COMMITTING inventory status
+ // and then kicks off a background job to do the actual work of committing (syncing to
+ // Agents, etc.).
+ private ResourceGWTServiceAsync importResourceService = GWTServiceLookup.getResourceService(3 * 60 * 1000);
public ResourceAutodiscoveryView(String locatorId) {
super(locatorId);
@@ -317,11 +324,14 @@ public class ResourceAutodiscoveryView extends LocatableVLayout implements Refre
importButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
disableButtons(selectAllButton, deselectAllButton, importButton, ignoreButton, unignoreButton);
+ // TODO (ips): Make the below message sticky, but add a new ClearSticky Message option that the
+ // below callback methods can use to clear it once the importResources() call has
+ // completed.
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_autoDiscoveryQ_importInProgress(), Message.Severity.Info, EnumSet
.of(Message.Option.Transient)));
- resourceService.importResources(getSelectedIds(), new AsyncCallback<Void>() {
+ importResourceService.importResources(getSelectedIds(), new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(MSG.view_autoDiscoveryQ_importFailure(), caught);
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestRpcView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestRpcView.java
new file mode 100644
index 0000000..b3c333f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestRpcView.java
@@ -0,0 +1,52 @@
+package org.rhq.enterprise.gui.coregui.client.test;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.TestGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+
+/**
+ * @author Ian Springer
+ */
+public class TestRpcView extends LocatableVLayout {
+
+ public TestRpcView(String locatorId) {
+ super(locatorId);
+ setMargin(10);
+
+ DynamicForm form = new DynamicForm();
+ form.setWidth(400);
+
+ final FormItem item = new FormItem("seconds");
+ item.setTitle("Seconds to sleep");
+ item.setRequired(true);
+
+ ButtonItem button = new ButtonItem("execute", "Execute");
+ button.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent event) {
+ TestGWTServiceAsync testService = GWTServiceLookup.getTestService();
+ final int seconds = Integer.valueOf((String)item.getValue());
+ testService.sleep(seconds, new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError("sleep(" + seconds + ") RPC call failed.", caught);
+ }
+
+ public void onSuccess(Void result) {
+ CoreGUI.getMessageCenter().notify(new Message("sleep(" + seconds + ") RPC completed."));
+ }
+ });
+ }
+ });
+ form.setItems(item, button);
+
+ addMember(form);
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
index 58a6cd6..a9e131b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
@@ -79,6 +79,7 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
private static final ViewName MISC_SECTION_VIEW_ID = new ViewName("Misc");
private static final ViewName PAGE_PLURALIZATION_TEST = new ViewName("PluralizationTest");
private static final ViewName PAGE_ASYNC = new ViewName("Async");
+ private static final ViewName PAGE_RPC = new ViewName("Rpc");
public TestTopView() {
// This is a top level view, so our locator id can simply be our view id.
@@ -235,7 +236,13 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
}
});
- return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, asyncItem);
+ NavigationItem rpcItem = new NavigationItem(PAGE_RPC, null, new ViewFactory() {
+ public Canvas createView() {
+ return new TestRpcView(extendLocatorId(PAGE_RPC.getName()));
+ }
+ });
+
+ return new NavigationSection(MISC_SECTION_VIEW_ID, pluralizationItem, asyncItem, rpcItem);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TestGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TestGWTServiceImpl.java
new file mode 100644
index 0000000..8f9a518
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/TestGWTServiceImpl.java
@@ -0,0 +1,43 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2011 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.enterprise.gui.coregui.server.gwt;
+
+import org.rhq.enterprise.gui.coregui.client.gwt.TestGWTService;
+
+/**
+ * @author Ian Springer
+ */
+public class TestGWTServiceImpl extends AbstractGWTServiceImpl implements TestGWTService {
+
+ private static final long serialVersionUID = 1L;
+
+ public void sleep(int seconds) throws RuntimeException {
+ try {
+ Thread.sleep(seconds * 1000);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw getExceptionToThrowToClient(e);
+ }
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
index c4943ed..ebc12f5 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/coregui/src/main/webapp/WEB-INF/web.xml
@@ -161,6 +161,10 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI DriftGWTService</servlet-name>
<servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.DriftGWTServiceImpl</servlet-class>
</servlet>
+ <servlet>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI TestGWTService</servlet-name>
+ <servlet-class>org.rhq.enterprise.gui.coregui.server.gwt.TestGWTServiceImpl</servlet-class>
+ </servlet>
<servlet-mapping>
@@ -311,6 +315,10 @@
<servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI DriftGWTService</servlet-name>
<url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/DriftGWTService</url-pattern>
</servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>org.rhq.enterprise.gui.coregui.CoreGUI TestGWTService</servlet-name>
+ <url-pattern>/org.rhq.enterprise.gui.coregui.CoreGUI/TestGWTService</url-pattern>
+ </servlet-mapping>
<welcome-file-list>
commit 3bcea7dc24cf65119b17b2f19a95e21777980082
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Aug 31 14:25:07 2011 -0400
[BZ 734814] Adding docs
diff --git a/modules/enterprise/remoting/cli/src/main/samples/drift.js b/modules/enterprise/remoting/cli/src/main/samples/drift.js
index 5a1e6e0a..ff7c31a 100644
--- a/modules/enterprise/remoting/cli/src/main/samples/drift.js
+++ b/modules/enterprise/remoting/cli/src/main/samples/drift.js
@@ -1,10 +1,64 @@
-// This script has a dependency on rhq/etc/cl-scripts/util.js. The following
-// command needs to be run in order to load the functions in util.js:
-//
-// exec -f /path/to/rhq/etc/cli-scripts/util.js
-//
-// Then the same exec command can be run to load functions in this script.
+/**
+ * file: drift.js
+ *
+ * description: This script contains functions that illustrate and highlight
+ * drift monitoring functionality. Some of the functionality demonstrated in
+ * this script is currently available only via RHQ's remote client (and CLI)
+ * at the time of this writing. This script has a dependency on util.js. To
+ * load this script's functions into your CLI session execute the following
+ * from the CLI shell,
+ *
+ * $ login <username> <password>
+ * $ exec -f samples/util.js
+ * $ exec -f samples/drift.js
+ *
+ * Note that you must login before you can load the scripts. Also please note
+ * that if a function is not documented, then it is not intended for public
+ * use. It is used only as an internal helper function.
+ *
+ * author: jsanda(a)redhat.com
+ */
+/**
+ * description: Generates a snapshot of changes sets belonging to a particular
+ * drift configuration of a specific resource. By default all change sets are
+ * included in the snapshot. An optional third argument can be specified to
+ * limit or control the number of change sets included in the snapshot.
+ *
+ * Note that a snapshot is an accumulation or aggregation of change sets that
+ * provides a view of a resource, or more precisely, all files being monitored
+ * for drift, at a particular version or point in time.
+ *
+ * arguments:
+ * rid: A resource id, expected to be an integer
+ *
+ * cname: The drift configuration name as a string
+ *
+ * filters: (optional) A map or JS object that limits the number of
+ * change sets included in the snapshot
+ *
+ * return: A org.rhq.core.domamin.drift.DriftSnapshot object
+ *
+ * usage:
+ * // generates a snapshot that includes all change sets belonging to the
+ * // mydrift drift configuration.
+ * createSnapshot(123, 'mydrift')
+ *
+ * // generates a snapshot starting a change set version 3 and including
+ * // everything more recent than it.
+ * createSnapshot(123, 'mydrift', {"startVersion": 3})
+ *
+ * // generates a snapshot that includes change sets 3 through 5 inclusive.
+ * createSnapshot(123, 'mydrift', {"startVersion": 3, "endVersion": 5})
+ *
+ * // generates a snaphot that includes everything after the specified
+ * // timestamp. Note that the timestamp should be specified in milliseconds.
+ * createSnapshot(123, 'mydrift', {"createdAfter": 1314811734365})
+ *
+ * // generates a snapshot that includes all change sets that were created
+ * // between the two timestamps.
+ * createSnapshot(123, 'mydrift', {"createdAfter": 1314811734365, "createdBefore": 9994811734365})
+ */
function createSnapshot(rid, cname) {
var config = findDriftConfig(rid, function(c) { return cname.equals(c.name) });
@@ -35,6 +89,39 @@ function findDriftConfig(rid, filter) {
});
}
+/**
+ * description: Generates a diff report that is printed to the console. By
+ * default this function generates a snapshot diff. The function expects two
+ * arguments which should be DriftSnapshot objects. A diff between those two
+ * snapshots is generated and printed to the console. A path can be specified
+ * as an optional third argument. If a path is a specified as a third argument,
+ * then a file diff will be performed using the file that matches the path in
+ * each change set. The format will be a unified diff.
+ *
+ * Note that the snapshots can be from the same or from different resources;
+ * however, if they are from different resources, it is assumed that the
+ * resources are of the same type.
+ *
+ * arguments:
+ * s1: A DriftSnapshot object
+ *
+ * s2: A DriftSnapshot object
+ *
+ * path: (optional) A string that specifies a path that exists in both s1 and
+ * s2.
+ *
+ * return: This function does not return a useful value. It may be an empty
+ * string or it could be null. Instead of returns its results, the function
+ * prints them to the CLI console. As such, this function is intended for
+ * use from the interactive CLI shell.
+ *
+ * usage:
+ * // Generates a snapshot diff report
+ * diff(s1, s2)
+ *
+ * // Generates a file diff report in the unified format
+ * diff(s1, s2, 'jboss_home/bin/run.conf')
+ */
function diff(s1, s2) {
var theDiff = s1.diff(s2);
@@ -73,12 +160,40 @@ function diff(s1, s2) {
report('elements not in right', theDiff.elementsNotInRight);
}
+/**
+ * description: Generates and returns the drift history for a file being
+ * monitored for drift. This function takes three arguments. The first two, the
+ * resource id drift configuration name, uniquely identify the drift
+ * configuration. The third argument specifies a path that is set up for
+ * monitoring by the drift configuration.
+ *
+ * arguments:
+ * rid: A resource id
+ *
+ * configName: A drift configuration name
+ *
+ * path: A path that is set up for drift monitoring by the drift
+ * configuration that is identified by the first two arguments. The path
+ * should be specified as relative to the base directory from which
+ * monitoring is done.
+ *
+ * return: A History object, which is a native JS object. This object contains
+ * a few methods for working with the file history:
+ *
+ * list: prints a short summary of all versions of the file
+ * view: returns the contents of a particular version of the file
+ * compare: compares two versions of the file and prints a unified diff
+ *
+ * usage:
+ * $ history = fetchHistory(123, 'mydrift', 'bin/run.conf')
+ * $ history.list() // prints a summary of all versions of 'bin/run.conf'
+ * $ history.view(1) // returns the full contents of version 1 of the file
+ * $ history.compare(1, 2) // generates and prints a unified diff of versions 1 and 2
+ */
function fetchHistory(rid, configName, path) {
function History() {
var entries = [];
- this.echo = function(msg) {println(msg);}
-
function findDrift(version) {
return find(entries, function(drift) {
return drift.changeSet.version == version
@@ -139,26 +254,4 @@ function fetchHistory(rid, configName, path) {
}
return new History();
-
-/*
- var criteria = GenericDriftCriteria();
- criteria.addFilterResourceIds([rid]);
- criteria.fetchChangeSet(true);
- criteria.addFilterPath(path);
-
- var drifts = DriftManager.findDriftsByCriteria(criteria);
- var history = [];
- foreach(drifts, function(drift) {
- if (drift.changeSet.driftConfiguration.name == configName &&
- drift.path == path) {
- history.push(drift);
- }
- });
-
- history.sort(function(d1, d2) {
- return d1.changeSet.version <= d2.changeSet.version
- });
-
- return history;
-*/
}
diff --git a/modules/enterprise/remoting/cli/src/main/samples/util.js b/modules/enterprise/remoting/cli/src/main/samples/util.js
index e0bb219..0369fe8 100644
--- a/modules/enterprise/remoting/cli/src/main/samples/util.js
+++ b/modules/enterprise/remoting/cli/src/main/samples/util.js
@@ -1,4 +1,21 @@
/**
+ * file: util.js
+ *
+ * description: This script contains functions that provide core, low-level
+ * functionality such as iterating over a collection or searching a collection.
+ * This has no other script or library dependencies. To load the functions into
+ * your CLI session execute the following from the CLI shell,
+ *
+ * $ login <username> <password>
+ * $ exec -f samples/util.js
+ *
+ * Note that you must login before you can load the script.
+ *
+ * author: jsanda(a)redhat.com
+ */
+
+
+/**
* If obj is a JS array or a java.util.Collection, each element is passed to
* the callback function. If obj is a java.util.Map, each map entry is passed
* to the callback function as a key/value pair. If obj is none of the
12 years, 8 months
[rhq] modules/enterprise
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java | 8 ++++++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
New commits:
commit b6125949237abceab2abd2fcee70f339f12c4fa6
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Aug 31 22:33:19 2011 -0400
[BZ 734881] Need to check for empty content because oracle blobs don't handle it
When a file is empty we still persist a row for it in rhq_drift_file.
The blob is set to null. This works fine on postgresql, but results in
the NPE reported in BZ 734881. To work around this, we now check the
size which is also stored in the rhq_drift_file table, and if the size
is zero, DriftManagerBean.getDriftFileContent just returns an empty
stream instead of opening an input stream on the blob.
This required one additional change. We previously were not storing the
size in rhq_drift_file. I have updated
JPADriftServerBean.persistDriftFileData to save the size now as well.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
index daa7a68..16e0d73 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerBean.java
@@ -211,12 +211,13 @@ public class JPADriftServerBean implements JPADriftServerLocal {
@Override
@TransactionAttribute(REQUIRES_NEW)
- public void persistDriftFileData(JPADriftFile driftFile, InputStream data) throws Exception {
+ public void persistDriftFileData(JPADriftFile driftFile, InputStream data, long numBytes) throws Exception {
JPADriftFileBits df = entityManager.find(JPADriftFileBits.class, driftFile.getHashId());
if (null == df) {
throw new IllegalArgumentException("JPADriftFile not found [" + driftFile.getHashId() + "]");
}
+ df.setDataSize(numBytes);
df.setData(Hibernate.createBlob(new BufferedInputStream(data)));
df.setStatus(LOADED);
}
@@ -377,7 +378,7 @@ public class JPADriftServerBean implements JPADriftServerLocal {
for (File file : dir.listFiles()) {
JPADriftFile driftFile = new JPADriftFile(file.getName());
try {
- JPADriftServer.persistDriftFileData(driftFile, new FileInputStream(file));
+ JPADriftServer.persistDriftFileData(driftFile, new FileInputStream(file), file.length());
} catch (Exception e) {
LogFactory.getLog(getClass()).info("Skipping bad drift file", e);
}
@@ -400,6 +401,9 @@ public class JPADriftServerBean implements JPADriftServerLocal {
try {
JPADriftFileBits content = (JPADriftFileBits) entityManager.createNamedQuery(
JPADriftFileBits.QUERY_FIND_BY_ID).setParameter("hashId", hash).getSingleResult();
+ if (content.getDataSize() == null || content.getDataSize() < 1) {
+ return "";
+ }
byte[] bytes = StreamUtil.slurp(content.getBlob().getBinaryStream());
return new String(bytes);
} catch (SQLException e) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
index 7142ead..9da1a5b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/drift/JPADriftServerLocal.java
@@ -85,7 +85,7 @@ public interface JPADriftServerLocal {
* @param data
* @throws Exception
*/
- void persistDriftFileData(JPADriftFile driftFile, InputStream data) throws Exception;
+ void persistDriftFileData(JPADriftFile driftFile, InputStream data, long numBytes) throws Exception;
/**
* This method stores the provided change-set file for the resource. The version will be incremented based
12 years, 8 months