From 89b926e15e12d63bf454e9574bcda2c3e2e5cc46 Mon Sep 17 00:00:00 2001 From: Dustin Johnson Date: Wed, 12 Jun 2013 12:04:08 -0500 Subject: [PATCH] Issue #2038 Correct required size estimations for subscription updates Change-Id: I7994cb1492a4a541b6fe4720179fe928b3365db0 Former-commit-id: 757c711d2ea13ec2e16bdec502fa9f074265a9aa [formerly 9156ec8c2d2eb07bbc827ffab06a354d2a999e57] [formerly 757c711d2ea13ec2e16bdec502fa9f074265a9aa [formerly 9156ec8c2d2eb07bbc827ffab06a354d2a999e57] [formerly 94eeac2f7d08352ea8f283be5e8cdec1836c0ee8 [formerly 2fb575c534a756a835cc072429ba78a417d3c445]]] Former-commit-id: 94eeac2f7d08352ea8f283be5e8cdec1836c0ee8 Former-commit-id: e383aa83e1f320d0c29ba827e7b220b7209230f4 [formerly c227436a3e97d7157735de1de79a610924c869a5] Former-commit-id: f6b7d97fd267886d45f9802e181b454c992d2918 --- .../subscription/CreateSubscriptionDlg.java | 5 ++-- .../DisplayForceApplyPromptDialog.java | 3 ++- .../subscription/SubscriptionService.java | 12 ++++++--- .../bandwidth/IProposeScheduleResponse.java | 3 ++- .../registry/SiteSubscription.java | 2 ++ .../bandwidth/BandwidthServiceIntTest.java | 26 +++++++++++++++++++ 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/CreateSubscriptionDlg.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/CreateSubscriptionDlg.java index 442b5a7988..f7bc585894 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/CreateSubscriptionDlg.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/CreateSubscriptionDlg.java @@ -100,7 +100,8 @@ import com.raytheon.viz.ui.presenter.components.CheckBoxConf; * Jan 25, 2013 1528 djohnson Use priority enum instead of raw integers. * Apr 08, 2013 1826 djohnson Remove delivery options. * May 15, 2013 1040 mpduff Add Shared sites. - * Jun 04, 2013 223 mpduff Modify for point data. + * Jun 04, 2013 223 mpduff Modify for point data. + * Jun 12, 2013 2038 djohnson No longer modal. * * * @@ -185,7 +186,7 @@ public class CreateSubscriptionDlg extends CaveSWTDialog implements * true for new subscription, false for edit */ public CreateSubscriptionDlg(Shell parent, boolean create) { - super(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL, + super(parent, SWT.DIALOG_TRIM, CAVE.INDEPENDENT_SHELL | CAVE.PERSPECTIVE_INDEPENDENT); this.create = create; diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/DisplayForceApplyPromptDialog.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/DisplayForceApplyPromptDialog.java index 97c59b43a6..189a34303b 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/DisplayForceApplyPromptDialog.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/DisplayForceApplyPromptDialog.java @@ -51,6 +51,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog; * ------------ ---------- ----------- -------------------------- * Nov 29, 2012 djohnson Initial creation * May 22, 2013 1650 djohnson Add more bandwidth information. + * Jun 12, 2013 2038 djohnson Maximum allowed size is returned in kilobytes. * * * @@ -133,7 +134,7 @@ public class DisplayForceApplyPromptDialog extends CaveSWTDialog { sizeLabel .setText("Maximum allowed size with current latency: " + SizeUtil - .prettyByteSize(configuration.maximumAllowedSize)); + .prettyKiloByteSize(configuration.maximumAllowedSize)); sizeLabel .setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); } diff --git a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionService.java b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionService.java index 30c489d5a7..58ca553ba9 100644 --- a/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionService.java +++ b/cave/com.raytheon.uf.viz.datadelivery/src/com/raytheon/uf/viz/datadelivery/subscription/SubscriptionService.java @@ -83,6 +83,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils; * Mar 29, 2013 1841 djohnson Subscription is now UserSubscription. * May 14, 2013 2000 djohnson Check for subscription overlap/duplication. * May 23, 2013 1650 djohnson Move out some presentation logic to DisplayForceApplyPromptDialog. + * Jun 12, 2013 2038 djohnson Launch subscription manager on the UI thread. * * * @@ -649,9 +650,14 @@ public class SubscriptionService implements ISubscriptionService { return new SubscriptionServiceResult(true); case EDIT_SUBSCRIPTIONS: if (!result.config.isNotAbleToScheduleOnlyTheSubscription()) { - new SubscriptionManagerAction() - .loadSubscriptionManager(SubscriptionManagerFilters - .getByNames(result.config.wouldBeUnscheduledSubscriptions)); + VizApp.runSync(new Runnable() { + @Override + public void run() { + new SubscriptionManagerAction() + .loadSubscriptionManager(SubscriptionManagerFilters + .getByNames(result.config.wouldBeUnscheduledSubscriptions)); + } + }); } return new SubscriptionServiceResult(true); default: diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/IProposeScheduleResponse.java b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/IProposeScheduleResponse.java index b9ead2f746..36544d5893 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/IProposeScheduleResponse.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.bandwidth/src/com/raytheon/uf/common/datadelivery/bandwidth/IProposeScheduleResponse.java @@ -33,6 +33,7 @@ import java.util.Set; * ------------ ---------- ----------- -------------------------- * Nov 29, 2012 1286 djohnson Initial creation * May 28, 2013 1650 djohnson More information when failing to schedule. + * Jun 12, 2013 2038 djohnson Maximum allowed size is returned in kilobytes. * * * @@ -84,7 +85,7 @@ public interface IProposeScheduleResponse { * Get the required dataset size for the subscription to not unschedule any * subscriptions. * - * @return the required dataset size + * @return the required dataset size, in kilobytes */ long getRequiredDataSetSize(); } diff --git a/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/SiteSubscription.java b/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/SiteSubscription.java index 9cdbf0fcae..00a71fc9ba 100644 --- a/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/SiteSubscription.java +++ b/edexOsgi/com.raytheon.uf.common.datadelivery.registry/src/com/raytheon/uf/common/datadelivery/registry/SiteSubscription.java @@ -58,6 +58,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; * Mar 29, 2013 1841 djohnson Renamed to UserSubscription. * May 15, 2013 1040 mpduff Added addOfficeId. * May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription. + * Jun 12, 2013 2038 djohnson Set registryId from each constructor with arguments. * * * @@ -103,6 +104,7 @@ public class SiteSubscription extends RecurringSubscription { public SiteSubscription(SiteSubscription sub) { super(sub); this.setOwner(sub.getOwner()); + this.setId(RegistryUtil.getRegistryObjectKey(this)); } @XmlAttribute diff --git a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java index df7cebc40b..8842cb19c8 100644 --- a/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java +++ b/tests/integration/com/raytheon/uf/edex/datadelivery/bandwidth/BandwidthServiceIntTest.java @@ -73,6 +73,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil; * Feb 26, 2013 1643 djohnson BandwidthService extends reusable class. * Feb 27, 2013 1644 djohnson Bandwidth service is the WFO version. * May 20, 2013 1650 djohnson Add test for returning required dataset size. + * Jun 12, 2013 2038 djohnson Add test for returning required dataset size on subscription update. * * * @@ -393,6 +394,31 @@ public class BandwidthServiceIntTest extends AbstractWfoBandwidthManagerIntTest expectedRequiredDataSetSize, requiredDataSetSize); } + @Test + public void testProposeScheduleSubscriptionsSecondDoesntFitReturnsRequiredSizeForSubscriptionUpdate() { + + Subscription subscription = createSubscriptionThatFillsHalfABucket(); + subscription.getTime().setCycleTimes( + Arrays.asList(Integer.valueOf(6), Integer.valueOf(8))); + + Set unscheduledSubscriptions = service.schedule(subscription); + verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions); + + // We can only fit up to a bucket + final long expectedRequiredDataSetSize = createSubscriptionThatFillsUpABucket() + .getDataSetSize(); + + // Try to update the subscription to fill two buckets + subscription.setDataSetSize(createSubscriptionThatFillsUpTwoBuckets() + .getDataSetSize()); + + final long requiredDataSetSize = service.proposeSchedule(subscription) + .getRequiredDataSetSize(); + assertEquals( + "The required dataset size should have been returned from propose schedule!", + expectedRequiredDataSetSize, requiredDataSetSize); + } + @Test public void testDetermineRequiredSizeReturnsZeroIfUnableToFitAtAll() {