Issue #2038 More information when bandwidth manager can't schedule a subscription
Amend: Peer review comments Change-Id: If2ae3f98a3a04709c2cdc7632ca89f2ee6a5e08d Former-commit-id: b1414f6aebda59cb6d83d1f0d0154fa4cd850953
This commit is contained in:
parent
1bc4437154
commit
0a9e7ed740
78 changed files with 2405 additions and 688 deletions
|
@ -21,7 +21,6 @@ package com.raytheon.uf.viz.datadelivery.actions;
|
|||
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
|
@ -33,7 +32,9 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
import com.raytheon.uf.viz.core.auth.UserController;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.datadelivery.services.DataDeliveryServices;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionManagerFilter;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerDlg;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerFilters;
|
||||
|
||||
/**
|
||||
* Subscription Manager Dialog Action class.
|
||||
|
@ -46,6 +47,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerDlg;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 10, 2012 mpduff Initial creation
|
||||
* Oct 03, 2012 1241 djohnson Use {@link DataDeliveryPermission}.
|
||||
* May 28, 2013 1650 djohnson Allow using filters for the Subscription Manager Dialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -54,6 +56,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerDlg;
|
|||
*/
|
||||
|
||||
public class SubscriptionManagerAction extends AbstractHandler {
|
||||
|
||||
/** Status Handler */
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SubscriptionManagerAction.class);
|
||||
|
@ -64,8 +67,24 @@ public class SubscriptionManagerAction extends AbstractHandler {
|
|||
/** Permission String */
|
||||
private final DataDeliveryPermission permission = DataDeliveryPermission.SUBSCRIPTION_VIEW;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public SubscriptionManagerAction() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
public Object execute(ExecutionEvent arg0) {
|
||||
return loadSubscriptionManager(SubscriptionManagerFilters.getAll());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the SubscriptionManager dialog with the specified filter.
|
||||
*
|
||||
* @param filter
|
||||
* the filter
|
||||
*/
|
||||
public Object loadSubscriptionManager(ISubscriptionManagerFilter filter) {
|
||||
try {
|
||||
// check if user is authorized
|
||||
IUser user = UserController.getUserObject();
|
||||
|
@ -78,7 +97,7 @@ public class SubscriptionManagerAction extends AbstractHandler {
|
|||
if ((dlg == null) || (dlg.isDisposed() == true)) {
|
||||
Shell shell = PlatformUI.getWorkbench()
|
||||
.getActiveWorkbenchWindow().getShell();
|
||||
dlg = new SubscriptionManagerDlg(shell);
|
||||
dlg = new SubscriptionManagerDlg(shell, filter);
|
||||
dlg.open();
|
||||
} else {
|
||||
dlg.bringToTop();
|
||||
|
|
|
@ -33,6 +33,8 @@ import org.eclipse.swt.widgets.Layout;
|
|||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionAction;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.ISubscriptionManagerFilter;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionManagerFilters;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionTableComp;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionTableComp.SubscriptionType;
|
||||
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
|
||||
|
@ -53,6 +55,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
|
|||
* Dec 03, 2012 1269 mpduff Change to take a list of subscriptions for the view mode.
|
||||
* Dec 10, 2012 1300 bgonzale Table filtering by dataset and provider.
|
||||
* May 23, 2012 2020 mpduff Implement method.
|
||||
* May 28, 2013 1650 djohnson Filters now control what subscriptions are shown.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -179,16 +182,16 @@ public class SubscriptionViewer extends AbstractViewDlg implements
|
|||
tableConfig.setTableStyle(SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL
|
||||
| SWT.MULTI | SWT.FULL_SELECTION);
|
||||
tableConfig.setTableHeight(200);
|
||||
tableComp = new SubscriptionTableComp(shell, tableConfig, this,
|
||||
SubscriptionType.VIEWER);
|
||||
|
||||
if (isTableFilteredByDatasetAndProvider()) {
|
||||
tableComp.populateActiveFilteredDataByDataSetAndProvider(
|
||||
datasetName, providerName);
|
||||
} else {
|
||||
tableComp.setSubscriptionNameList(this.subscriptionNameList);
|
||||
tableComp.populateData();
|
||||
}
|
||||
ISubscriptionManagerFilter filter = (isTableFilteredByDatasetAndProvider()) ? SubscriptionManagerFilters
|
||||
.getByProviderAndDataSet(providerName, datasetName) :
|
||||
SubscriptionManagerFilters
|
||||
.getByNames(this.subscriptionNameList);
|
||||
|
||||
tableComp = new SubscriptionTableComp(shell, tableConfig, this,
|
||||
SubscriptionType.VIEWER, filter);
|
||||
|
||||
tableComp.populateData();
|
||||
tableComp.populateTable();
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,8 @@ import com.raytheon.viz.ui.widgets.duallist.IUpdate;
|
|||
* Jan 02, 2013 1441 djohnson Access GroupDefinitionManager in a static fashion.
|
||||
* Apr 08, 2013 1826 djohnson Remove unused code, delivery options.
|
||||
* May 15, 2013 1040 mpduff OfficeID is now a list so need to add it rather than set it.
|
||||
* May 23, 2013 1650 djohnson Fix creation of new GroupDefinitions.
|
||||
* May 28, 2013 1650 djohnson More information when failing to schedule subscriptions.
|
||||
* </pre>
|
||||
*
|
||||
* @author jpiatt
|
||||
|
@ -359,6 +361,10 @@ public class UserSelectComp extends Composite implements IUpdate, IDisplay,
|
|||
// Get Group Definition
|
||||
GroupDefinition groupDefinition = GroupDefinitionManager
|
||||
.getGroup(groupName);
|
||||
if (groupDefinition == null) {
|
||||
groupDefinition = new GroupDefinition();
|
||||
groupDefinition.setGroupName(groupName);
|
||||
}
|
||||
|
||||
for (Subscription subscription : groupSubscriptions) {
|
||||
|
||||
|
@ -499,15 +505,20 @@ public class UserSelectComp extends Composite implements IUpdate, IDisplay,
|
|||
public String getOptionDisplayText(ForceApplyPromptResponse option,
|
||||
int requiredLatency, Subscription subscription,
|
||||
Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
final boolean singleSubscription = wouldBeUnscheduledSubscriptions
|
||||
.size() == 1;
|
||||
switch (option) {
|
||||
case CANCEL:
|
||||
return "Do not update the group definition.";
|
||||
case FORCE_APPLY:
|
||||
if (wouldBeUnscheduledSubscriptions.size() == 1) {
|
||||
if (singleSubscription) {
|
||||
return "Update the group definition and unschedule "
|
||||
+ wouldBeUnscheduledSubscriptions.iterator().next();
|
||||
}
|
||||
return "Update the group definition and unschedule the subscriptions";
|
||||
case EDIT_SUBSCRIPTIONS:
|
||||
return "Edit the "
|
||||
+ ((singleSubscription) ? "subscription" : "subscriptions");
|
||||
case INCREASE_LATENCY:
|
||||
// Signifies it should not be an option
|
||||
return null;
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceA
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 4, 2012 1286 djohnson Initial creation
|
||||
* May 28, 2013 1650 djohnson More information when failing to schedule subscriptions.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -78,17 +79,22 @@ public class CancelForceApplyAndIncreaseLatencyDisplayText implements
|
|||
int requiredLatency, Subscription subscription,
|
||||
Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
final String name = subscription.getName();
|
||||
final boolean singleSubscription = wouldBeUnscheduledSubscriptions
|
||||
.size() == 1;
|
||||
switch (option) {
|
||||
case CANCEL:
|
||||
return "Do not " + actionText + " " + name;
|
||||
case FORCE_APPLY:
|
||||
if (wouldBeUnscheduledSubscriptions.size() == 1
|
||||
if (singleSubscription
|
||||
&& wouldBeUnscheduledSubscriptions.contains(name)) {
|
||||
return titleCaseActionText + " " + name
|
||||
+ " and leave in an unscheduled status";
|
||||
}
|
||||
return titleCaseActionText + " " + name
|
||||
+ " and unschedule the others";
|
||||
case EDIT_SUBSCRIPTIONS:
|
||||
return "Edit the "
|
||||
+ ((singleSubscription) ? "subscription" : "subscriptions");
|
||||
case INCREASE_LATENCY:
|
||||
return "Increase the latency on " + name + " to " + requiredLatency
|
||||
+ " minutes";
|
||||
|
|
|
@ -19,52 +19,48 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.subscription;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.events.SelectionListener;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Group;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.List;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.util.SizeUtil;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.ForceApplyPromptResponse;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceApplyPromptDisplayText;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Dialog allowing the user to choose how to continue with their subscription
|
||||
* creation/modification request.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 29, 2012 djohnson Initial creation
|
||||
*
|
||||
* May 22, 2013 1650 djohnson Add more bandwidth information.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class DisplayForceApplyPromptDialog extends CaveSWTDialog {
|
||||
private final String dialogTitle;
|
||||
|
||||
private final String message;
|
||||
|
||||
private final int requiredLatency;
|
||||
|
||||
private final IForceApplyPromptDisplayText displayTextStrategy;
|
||||
|
||||
private final Subscription subscription;
|
||||
|
||||
private final Set<String> wouldBeUnscheduledSubscriptions;
|
||||
private final ForceApplyPromptConfiguration configuration;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -75,61 +71,99 @@ public class DisplayForceApplyPromptDialog extends CaveSWTDialog {
|
|||
* @param subscription
|
||||
* @param wouldBeUnscheduledSubscriptions
|
||||
*/
|
||||
public DisplayForceApplyPromptDialog(String title, String message,
|
||||
int requiredLatency,
|
||||
IForceApplyPromptDisplayText displayTextStrategy,
|
||||
Subscription subscription,
|
||||
Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
super(displayTextStrategy.getShell());
|
||||
public DisplayForceApplyPromptDialog(
|
||||
ForceApplyPromptConfiguration configuration) {
|
||||
super(configuration.displayTextStrategy.getShell());
|
||||
|
||||
this.dialogTitle = title;
|
||||
this.message = message;
|
||||
this.requiredLatency = requiredLatency;
|
||||
this.displayTextStrategy = displayTextStrategy;
|
||||
this.subscription = subscription;
|
||||
this.wouldBeUnscheduledSubscriptions = wouldBeUnscheduledSubscriptions;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @param subscription
|
||||
*
|
||||
* @param subscription
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(final Shell shell) {
|
||||
setText(dialogTitle);
|
||||
setText(configuration.title);
|
||||
|
||||
// Initialize layout
|
||||
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
GridData gd = new GridData(SWT.FILL, SWT.FILL, false, true);
|
||||
gd.widthHint = 400;
|
||||
gd.heightHint = 100;
|
||||
|
||||
Label textLabel = new Label(shell, SWT.WRAP);
|
||||
textLabel.setLayoutData(gd);
|
||||
textLabel.setText(message);
|
||||
textLabel.setText(configuration.message);
|
||||
|
||||
if (configuration.hasUnscheduledSubscriptions()) {
|
||||
Composite unscheduledSubscriptionsComp = new Composite(shell,
|
||||
SWT.NONE);
|
||||
unscheduledSubscriptionsComp.setLayout(new GridLayout(1, false));
|
||||
unscheduledSubscriptionsComp.setLayoutData(new GridData(SWT.FILL,
|
||||
SWT.FILL, true, true));
|
||||
|
||||
final List list = new List(unscheduledSubscriptionsComp, SWT.MULTI
|
||||
| SWT.BORDER);
|
||||
list.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
final SelectionListener listener = new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
list.deselectAll();
|
||||
}
|
||||
};
|
||||
list.setItems(configuration.wouldBeUnscheduledSubscriptions
|
||||
.toArray(new String[configuration.wouldBeUnscheduledSubscriptions
|
||||
.size()]));
|
||||
list.addSelectionListener(listener);
|
||||
}
|
||||
|
||||
if (configuration.hasBandwidthDetails()) {
|
||||
Group group = new Group(shell, SWT.BORDER);
|
||||
group.setText("Bandwidth Details");
|
||||
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
group.setLayout(new GridLayout(1, false));
|
||||
|
||||
Label rulesLatency = new Label(group, SWT.WRAP);
|
||||
rulesLatency.setText("Maximum latency recommended by rules: "
|
||||
+ configuration.maximumLatency + " minutes");
|
||||
rulesLatency.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
|
||||
true));
|
||||
|
||||
Label sizeLabel = new Label(group, SWT.WRAP);
|
||||
sizeLabel
|
||||
.setText("Maximum allowed size with current latency: "
|
||||
+ SizeUtil
|
||||
.prettyByteSize(configuration.maximumAllowedSize));
|
||||
sizeLabel
|
||||
.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
}
|
||||
|
||||
Composite leftComp = new Composite(shell, SWT.NONE);
|
||||
leftComp.setLayout(new GridLayout(1, false));
|
||||
leftComp.setLayoutData(new GridData(SWT.LEFT, SWT.DEFAULT, true, false));
|
||||
|
||||
Label choiceLabel = new Label(leftComp, SWT.WRAP);
|
||||
choiceLabel.setLayoutData(gd);
|
||||
choiceLabel.setText("\nWhat would you like to do?\n");
|
||||
|
||||
// Add radio buttons
|
||||
Composite leftComp = new Composite(shell, SWT.NONE);
|
||||
GridLayout gl = new GridLayout(1, false);
|
||||
leftComp.setLayout(gl);
|
||||
GridData gd2 = new GridData(SWT.LEFT, SWT.DEFAULT, true, false);
|
||||
leftComp.setLayoutData(gd2);
|
||||
|
||||
Button[] radios = getRadioButtons(leftComp, requiredLatency,
|
||||
displayTextStrategy, subscription);
|
||||
Button[] radios = getRadioButtons(leftComp,
|
||||
configuration.requiredLatency,
|
||||
configuration.displayTextStrategy, configuration.subscription);
|
||||
radios[0].setSelection(true);
|
||||
setReturnValue(ForceApplyPromptResponse.CANCEL);
|
||||
radios[0].setFocus();
|
||||
|
||||
// Add a close button
|
||||
// Add an OK button
|
||||
Composite centeredComp = new Composite(shell, SWT.NONE);
|
||||
gl = new GridLayout(1, false);
|
||||
centeredComp.setLayout(gl);
|
||||
gd2 = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||
centeredComp.setLayoutData(gd2);
|
||||
centeredComp.setLayout(new GridLayout(1, false));
|
||||
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
|
||||
centeredComp.setLayoutData(gd);
|
||||
|
||||
Button closeBtn = new Button(centeredComp, SWT.NONE);
|
||||
closeBtn.setText("OK");
|
||||
closeBtn.setLayoutData(gd2);
|
||||
closeBtn.addSelectionListener(new SelectionAdapter() {
|
||||
Button okBtn = new Button(centeredComp, SWT.NONE);
|
||||
okBtn.setText("OK");
|
||||
okBtn.setLayoutData(gd);
|
||||
okBtn.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
shell.dispose();
|
||||
|
@ -158,30 +192,29 @@ public class DisplayForceApplyPromptDialog extends CaveSWTDialog {
|
|||
.values();
|
||||
final int length = values.length;
|
||||
|
||||
Button[] buttons = new Button[length];
|
||||
java.util.List<Button> buttons = Lists.newArrayList();
|
||||
for (int i = 0; i < length; i++) {
|
||||
final ForceApplyPromptResponse promptResponse = values[i];
|
||||
|
||||
buttons[i] = new Button(composite, SWT.RADIO);
|
||||
final String optionDisplayText = displayTextStrategy
|
||||
.getOptionDisplayText(promptResponse, requiredLatency,
|
||||
subscription, wouldBeUnscheduledSubscriptions);
|
||||
subscription,
|
||||
configuration.wouldBeUnscheduledSubscriptions);
|
||||
|
||||
// Skip any options that return a null display text
|
||||
if (optionDisplayText == null) {
|
||||
buttons[i].setVisible(false);
|
||||
continue;
|
||||
if (optionDisplayText != null) {
|
||||
Button button = new Button(composite, SWT.RADIO);
|
||||
button.setText(optionDisplayText);
|
||||
button.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
setReturnValue(promptResponse);
|
||||
}
|
||||
});
|
||||
buttons.add(button);
|
||||
}
|
||||
|
||||
buttons[i].setText(optionDisplayText);
|
||||
buttons[i].addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
setReturnValue(promptResponse);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return buttons;
|
||||
return buttons.toArray(new Button[buttons.size()]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,204 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.subscription;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.util.StringUtil;
|
||||
import com.raytheon.uf.viz.datadelivery.subscription.SubscriptionService.IForceApplyPromptDisplayText;
|
||||
|
||||
/**
|
||||
* Configuration for a force apply prompt.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 22, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ForceApplyPromptConfiguration {
|
||||
|
||||
public final String title;
|
||||
|
||||
public final String message;
|
||||
|
||||
public final int requiredLatency;
|
||||
|
||||
public final int maximumLatency;
|
||||
|
||||
public final long maximumAllowedSize;
|
||||
|
||||
public final IForceApplyPromptDisplayText displayTextStrategy;
|
||||
|
||||
public final Subscription subscription;
|
||||
|
||||
public final Set<String> wouldBeUnscheduledSubscriptions;
|
||||
|
||||
/**
|
||||
* Constructor used when there is a single subscription failing to schedule.
|
||||
*
|
||||
* @param title
|
||||
* @param message
|
||||
* @param requiredLatency
|
||||
* @param maximumLatency
|
||||
* @param maximumAllowedSize
|
||||
* @param displayTextStrategy
|
||||
* @param subscription
|
||||
* @param wouldBeUnscheduledSubscriptions
|
||||
*/
|
||||
public ForceApplyPromptConfiguration(String title, String message,
|
||||
int requiredLatency, int maximumLatency, long maximumAllowedSize,
|
||||
IForceApplyPromptDisplayText displayTextStrategy,
|
||||
Subscription subscription,
|
||||
Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
this.title = title;
|
||||
this.message = message;
|
||||
this.requiredLatency = requiredLatency;
|
||||
this.maximumLatency = maximumLatency;
|
||||
this.maximumAllowedSize = maximumAllowedSize;
|
||||
this.displayTextStrategy = displayTextStrategy;
|
||||
this.subscription = subscription;
|
||||
this.wouldBeUnscheduledSubscriptions = wouldBeUnscheduledSubscriptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used when there are multiple subscriptions failing to
|
||||
* schedule.
|
||||
*
|
||||
* @param title
|
||||
* @param message
|
||||
* @param displayTextStrategy
|
||||
*/
|
||||
public ForceApplyPromptConfiguration(String title, String message,
|
||||
IForceApplyPromptDisplayText displayTextStrategy,
|
||||
Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
this(title, message, IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
IProposeScheduleResponse.VALUE_NOT_SET, displayTextStrategy,
|
||||
null, wouldBeUnscheduledSubscriptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the configuration would unschedule subscriptions other
|
||||
* than the one being modified/created.
|
||||
*
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean hasUnscheduledSubscriptions() {
|
||||
return subscription == null
|
||||
|| wouldBeUnscheduledSubscriptions.size() > 1
|
||||
|| !wouldBeUnscheduledSubscriptions.contains(subscription
|
||||
.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the configuration contains bandwidth manager details.
|
||||
*
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean hasBandwidthDetails() {
|
||||
return requiredLatency != IProposeScheduleResponse.VALUE_NOT_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the subscription attempting to be scheduled is the only
|
||||
* subscription that wouldn't be able to schedule.
|
||||
*
|
||||
* @return true or false
|
||||
*/
|
||||
public boolean isNotAbleToScheduleOnlyTheSubscription() {
|
||||
return subscription != null
|
||||
&& wouldBeUnscheduledSubscriptions.size() == 1
|
||||
&& wouldBeUnscheduledSubscriptions.contains(subscription
|
||||
.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof ForceApplyPromptConfiguration) {
|
||||
ForceApplyPromptConfiguration other = (ForceApplyPromptConfiguration) obj;
|
||||
|
||||
EqualsBuilder builder = new EqualsBuilder();
|
||||
builder.append(this.title, other.title);
|
||||
builder.append(this.message, other.message);
|
||||
builder.append(this.requiredLatency, other.requiredLatency);
|
||||
builder.append(this.maximumLatency, other.maximumLatency);
|
||||
builder.append(this.maximumAllowedSize, other.maximumAllowedSize);
|
||||
builder.append(this.subscription, other.subscription);
|
||||
builder.append(this.wouldBeUnscheduledSubscriptions,
|
||||
other.wouldBeUnscheduledSubscriptions);
|
||||
return builder.isEquals();
|
||||
}
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
HashCodeBuilder builder = new HashCodeBuilder();
|
||||
builder.append(this.title);
|
||||
builder.append(this.message);
|
||||
builder.append(this.requiredLatency);
|
||||
builder.append(this.maximumLatency);
|
||||
builder.append(this.maximumAllowedSize);
|
||||
builder.append(this.subscription);
|
||||
builder.append(this.wouldBeUnscheduledSubscriptions);
|
||||
return builder.toHashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("title: ").append(title).append(StringUtil.NEWLINE);
|
||||
sb.append("message: ").append(message).append(StringUtil.NEWLINE);
|
||||
sb.append("required latency: ").append(requiredLatency)
|
||||
.append(StringUtil.NEWLINE);
|
||||
sb.append("maximum latency: ").append(maximumLatency)
|
||||
.append(StringUtil.NEWLINE);
|
||||
sb.append("maximum allowed size: ").append(maximumAllowedSize)
|
||||
.append(StringUtil.NEWLINE);
|
||||
sb.append("subscription: ")
|
||||
.append(subscription == null ? "null" : subscription.getName())
|
||||
.append(StringUtil.NEWLINE);
|
||||
sb.append("wouldBeUnscheduledSubscriptions: ").append(
|
||||
wouldBeUnscheduledSubscriptions);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.subscription;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Allows calling code to specify a filter for the contents of the
|
||||
* {@link SubscriptionManagerDlg}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 23, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface ISubscriptionManagerFilter {
|
||||
/**
|
||||
* Allows calling code to determine how to find the subscriptions to be
|
||||
* included in the table.
|
||||
*
|
||||
* @param subscriptionHandler
|
||||
* the subscription handler
|
||||
* @return the list of subscriptions
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
List<Subscription> getSubscriptions(ISubscriptionHandler subscriptionHandler)
|
||||
throws RegistryHandlerException;
|
||||
}
|
|
@ -21,6 +21,7 @@ package com.raytheon.uf.viz.datadelivery.subscription;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -120,6 +121,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
|||
* Mar 29, 2013 1841 djohnson Subscription implementations now provide a copy method.
|
||||
* May 09, 2013 2000 djohnson Copy subscription now requires editing first to prevent duplicates, and remove duplicate code.
|
||||
* May 17, 2013 1040 mpduff Change office id to list for shared subscription.
|
||||
* May 28, 2013 1650 djohnson Allow specifying filters for what subscriptions to show.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -133,25 +135,6 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(SubscriptionManagerDlg.class);
|
||||
|
||||
/** Enumeration to use with Deliver Notify */
|
||||
public static enum SubscriptionNotification {
|
||||
/** Subscription notification of type Delivery */
|
||||
DELIVERY("Delivery"),
|
||||
/** Subscription notification of type Notify */
|
||||
NOTIFY("Notify");
|
||||
|
||||
private String subnotif;
|
||||
|
||||
private SubscriptionNotification(String subnotif) {
|
||||
this.subnotif = subnotif;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return subnotif;
|
||||
}
|
||||
}
|
||||
|
||||
/** Enumeration to use with Data set */
|
||||
public static enum FullDataset {
|
||||
/** Full data set of type Full */
|
||||
|
@ -225,16 +208,22 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
private final ISubscriptionNotificationService subscriptionNotificationService = DataDeliveryServices
|
||||
.getSubscriptionNotificationService();
|
||||
|
||||
private final ISubscriptionManagerFilter filter;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param parent
|
||||
* The parent shell
|
||||
* @param filter
|
||||
*/
|
||||
public SubscriptionManagerDlg(Shell parent) {
|
||||
public SubscriptionManagerDlg(Shell parent,
|
||||
ISubscriptionManagerFilter filter) {
|
||||
super(parent, SWT.DIALOG_TRIM | SWT.MIN | SWT.RESIZE,
|
||||
CAVE.INDEPENDENT_SHELL | CAVE.PERSPECTIVE_INDEPENDENT);
|
||||
|
||||
this.filter = filter;
|
||||
|
||||
setText("Data Delivery Subscription Manager");
|
||||
}
|
||||
|
||||
|
@ -489,7 +478,7 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
| SWT.MULTI | SWT.FULL_SELECTION);
|
||||
tableConfig.setTableHeight(200);
|
||||
tableComp = new SubscriptionTableComp(shell, tableConfig, this,
|
||||
SubscriptionType.MANAGER);
|
||||
SubscriptionType.MANAGER, filter);
|
||||
|
||||
tableComp.populateData();
|
||||
tableComp.populateTable();
|
||||
|
@ -786,10 +775,35 @@ public class SubscriptionManagerDlg extends CaveSWTDialog implements
|
|||
*/
|
||||
private void handleFilterSelection() {
|
||||
|
||||
String group = groupCbo.getText();
|
||||
String office = officeCbo.getText();
|
||||
final String group = groupCbo.getText();
|
||||
final String office = officeCbo.getText();
|
||||
|
||||
tableComp.populateFilteredData(group, office);
|
||||
tableComp.setSubscriptionFilter(new ISubscriptionManagerFilter() {
|
||||
|
||||
@Override
|
||||
public List<Subscription> getSubscriptions(
|
||||
ISubscriptionHandler subscriptionHandler)
|
||||
throws RegistryHandlerException {
|
||||
final List<Subscription> results = filter.getSubscriptions(subscriptionHandler);
|
||||
|
||||
// Remove any that don't match the configured filters. TODO:
|
||||
// This should be cleaned up at some point in the future
|
||||
for (Iterator<Subscription> iter = results.iterator(); iter
|
||||
.hasNext();) {
|
||||
Subscription subscription = iter.next();
|
||||
if ((office == null || "ALL".equals(office) || subscription
|
||||
.getOfficeIDs().contains(office))
|
||||
&& (group == null
|
||||
|| "All Subscriptions".equals(group)
|
||||
|| group.equals(subscription.getGroupName()))) {
|
||||
continue;
|
||||
}
|
||||
iter.remove();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
});
|
||||
tableComp.populateData();
|
||||
tableComp.populateTable();
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.viz.datadelivery.subscription;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Provides filters to use with the SubscriptionManagerDlg.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 23, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public final class SubscriptionManagerFilters {
|
||||
|
||||
private static final ISubscriptionManagerFilter RETRIEVE_ALL = new ISubscriptionManagerFilter() {
|
||||
@Override
|
||||
public List<Subscription> getSubscriptions(
|
||||
ISubscriptionHandler subscriptionHandler)
|
||||
throws RegistryHandlerException {
|
||||
return subscriptionHandler.getAll();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Prevent construction.
|
||||
*/
|
||||
private SubscriptionManagerFilters() {
|
||||
}
|
||||
|
||||
public static ISubscriptionManagerFilter getAll() {
|
||||
return RETRIEVE_ALL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter that only accepts subscriptions with the specified names.
|
||||
*
|
||||
* @param names
|
||||
* the names
|
||||
* @return the filter
|
||||
*/
|
||||
public static ISubscriptionManagerFilter getByNames(
|
||||
final Collection<String> names) {
|
||||
return new ISubscriptionManagerFilter() {
|
||||
@Override
|
||||
public List<Subscription> getSubscriptions(
|
||||
ISubscriptionHandler subscriptionHandler)
|
||||
throws RegistryHandlerException {
|
||||
return subscriptionHandler.getByNames(names);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param providerName
|
||||
* @param datasetName
|
||||
* @return
|
||||
*/
|
||||
public static ISubscriptionManagerFilter getByProviderAndDataSet(
|
||||
final String providerName, final String datasetName) {
|
||||
return new ISubscriptionManagerFilter() {
|
||||
@Override
|
||||
public List<Subscription> getSubscriptions(
|
||||
ISubscriptionHandler subscriptionHandler)
|
||||
throws RegistryHandlerException {
|
||||
return subscriptionHandler.getActiveByDataSetAndProvider(
|
||||
datasetName, providerName);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
|
@ -36,6 +36,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raytheon.uf.common.auth.user.IUser;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IBandwidthService;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
|
@ -57,6 +58,8 @@ import com.raytheon.uf.common.util.StringUtil;
|
|||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.auth.UserController;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.datadelivery.actions.SubscriptionManagerAction;
|
||||
import com.raytheon.uf.viz.datadelivery.system.SystemRuleManager;
|
||||
import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
||||
|
||||
/**
|
||||
|
@ -79,6 +82,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
|||
* Jan 28, 2013 1530 djohnson Reset unscheduled flag with each update.
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -105,14 +109,10 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
* @param subscription
|
||||
*/
|
||||
@Override
|
||||
public ForceApplyPromptResponse displayForceApplyPrompt(String title,
|
||||
String message, int requiredLatency,
|
||||
IForceApplyPromptDisplayText displayTextStrategy,
|
||||
Subscription subscription,
|
||||
Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
public ForceApplyPromptResponse displayForceApplyPrompt(
|
||||
ForceApplyPromptConfiguration configuration) {
|
||||
DisplayForceApplyPromptDialog dlg = new DisplayForceApplyPromptDialog(
|
||||
title, message, requiredLatency, displayTextStrategy,
|
||||
subscription, wouldBeUnscheduledSubscriptions);
|
||||
configuration);
|
||||
forceApplyPromptResponse = (ForceApplyPromptResponse) dlg.open();
|
||||
return forceApplyPromptResponse;
|
||||
}
|
||||
|
@ -219,18 +219,12 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
private final class ProposeResult {
|
||||
private final boolean promptUser;
|
||||
|
||||
private final String message;
|
||||
private final ForceApplyPromptConfiguration config;
|
||||
|
||||
private final int requiredLatency;
|
||||
|
||||
private final Set<String> wouldBeUnscheduledSubscriptions;
|
||||
|
||||
private ProposeResult(boolean promptUser, String message,
|
||||
int requiredLatency, Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
private ProposeResult(boolean promptUser,
|
||||
ForceApplyPromptConfiguration config) {
|
||||
this.promptUser = promptUser;
|
||||
this.message = message;
|
||||
this.requiredLatency = requiredLatency;
|
||||
this.wouldBeUnscheduledSubscriptions = wouldBeUnscheduledSubscriptions;
|
||||
this.config = config;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +241,7 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
* Enumeration of force apply responses.
|
||||
*/
|
||||
public static enum ForceApplyPromptResponse {
|
||||
CANCEL, INCREASE_LATENCY, FORCE_APPLY;
|
||||
CANCEL, INCREASE_LATENCY, EDIT_SUBSCRIPTIONS, FORCE_APPLY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,18 +252,13 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
/**
|
||||
* Display the force apply prompt.
|
||||
*
|
||||
* @param title
|
||||
* @param message
|
||||
* @param requiredLatency
|
||||
* @param displayTextStrategy
|
||||
* @param wouldBeUnscheduledSubscriptions
|
||||
* @param configuration
|
||||
* the configuration
|
||||
*
|
||||
* @return the response
|
||||
*/
|
||||
ForceApplyPromptResponse displayForceApplyPrompt(String title,
|
||||
String message, int requiredLatency,
|
||||
IForceApplyPromptDisplayText displayTextStrategy,
|
||||
Subscription subscription,
|
||||
Set<String> wouldBeUnscheduledSubscriptions);
|
||||
ForceApplyPromptResponse displayForceApplyPrompt(
|
||||
ForceApplyPromptConfiguration configuration);
|
||||
|
||||
ForceApplyPromptResponse getForceApplyPromptResponse();
|
||||
|
||||
|
@ -609,8 +598,9 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
}
|
||||
if (!overlappingSubscriptions.isEmpty()) {
|
||||
Collections.sort(overlappingSubscriptions);
|
||||
forceApplyPrompt.displayMessage(
|
||||
displayTextStrategy,
|
||||
forceApplyPrompt
|
||||
.displayMessage(
|
||||
displayTextStrategy,
|
||||
StringUtil
|
||||
.createMessage(
|
||||
ISubscriptionOverlapService.OVERLAPPING_SUBSCRIPTIONS,
|
||||
|
@ -620,7 +610,7 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
|
||||
try {
|
||||
final ProposeResult result = proposeScheduleAndAction(
|
||||
subscriptions, action);
|
||||
subscriptions, action, displayTextStrategy);
|
||||
|
||||
if (result.promptUser) {
|
||||
final Subscription subscription = (subscriptions.size() == 1) ? subscriptions
|
||||
|
@ -629,15 +619,13 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
VizApp.runSync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
forceApplyPrompt.displayForceApplyPrompt(TITLE,
|
||||
result.message, result.requiredLatency,
|
||||
displayTextStrategy, subscription,
|
||||
result.wouldBeUnscheduledSubscriptions);
|
||||
forceApplyPrompt.displayForceApplyPrompt(result.config);
|
||||
}
|
||||
});
|
||||
switch (forceApplyPrompt.getForceApplyPromptResponse()) {
|
||||
case INCREASE_LATENCY:
|
||||
subscription.setLatencyInMinutes(result.requiredLatency);
|
||||
subscription
|
||||
.setLatencyInMinutes(result.config.requiredLatency);
|
||||
// Intentional fall-through
|
||||
case FORCE_APPLY:
|
||||
// Have to make sure we set them to not be unscheduled, let
|
||||
|
@ -657,13 +645,20 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
return new SubscriptionServiceResult(sb.toString());
|
||||
case CANCEL:
|
||||
return new SubscriptionServiceResult(true);
|
||||
case EDIT_SUBSCRIPTIONS:
|
||||
if (!result.config.isNotAbleToScheduleOnlyTheSubscription()) {
|
||||
new SubscriptionManagerAction()
|
||||
.loadSubscriptionManager(SubscriptionManagerFilters
|
||||
.getByNames(result.config.wouldBeUnscheduledSubscriptions));
|
||||
}
|
||||
return new SubscriptionServiceResult(true);
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unknown force apply prompt response! Did you add a new type that must be handled?");
|
||||
}
|
||||
}
|
||||
|
||||
return new SubscriptionServiceResult(result.message);
|
||||
return new SubscriptionServiceResult(result.config.message);
|
||||
} catch (RegistryHandlerException e) {
|
||||
// The in-memory objects must be corrupted since we schedule first,
|
||||
// then store to the registry, so a reinitialize is called for
|
||||
|
@ -685,7 +680,8 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
*/
|
||||
private ProposeResult proposeScheduleAndAction(
|
||||
List<Subscription> subscriptions,
|
||||
ServiceInteraction serviceInteraction)
|
||||
ServiceInteraction serviceInteraction,
|
||||
IForceApplyPromptDisplayText displayTextStrategy)
|
||||
throws RegistryHandlerException {
|
||||
|
||||
IProposeScheduleResponse proposeScheduleresponse = bandwidthService
|
||||
|
@ -694,17 +690,18 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
.getUnscheduledSubscriptions();
|
||||
boolean wouldUnscheduleSubs = !unscheduledSubscriptions.isEmpty();
|
||||
|
||||
String response = null;
|
||||
ForceApplyPromptConfiguration response = null;
|
||||
if (wouldUnscheduleSubs) {
|
||||
response = getWouldCauseUnscheduledSubscriptionsPortion(
|
||||
unscheduledSubscriptions, subscriptions);
|
||||
unscheduledSubscriptions, subscriptions,
|
||||
proposeScheduleresponse, displayTextStrategy);
|
||||
} else {
|
||||
response = serviceInteraction.call();
|
||||
response = new ForceApplyPromptConfiguration(TITLE,
|
||||
serviceInteraction.call(), displayTextStrategy,
|
||||
unscheduledSubscriptions);
|
||||
}
|
||||
|
||||
return new ProposeResult(wouldUnscheduleSubs, response,
|
||||
proposeScheduleresponse.getRequiredLatency(),
|
||||
unscheduledSubscriptions);
|
||||
return new ProposeResult(wouldUnscheduleSubs, response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -714,15 +711,19 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
* the unscheduled subscriptions
|
||||
* @param subscriptions
|
||||
* the subscriptions which were attempting to schedule
|
||||
* @param dataSize
|
||||
*/
|
||||
private String getWouldCauseUnscheduledSubscriptionsPortion(
|
||||
private ForceApplyPromptConfiguration getWouldCauseUnscheduledSubscriptionsPortion(
|
||||
Set<String> unscheduledSubscriptions,
|
||||
List<Subscription> subscriptions) {
|
||||
List<Subscription> subscriptions,
|
||||
IProposeScheduleResponse proposeScheduleResponse,
|
||||
IForceApplyPromptDisplayText displayTextStrategy) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
|
||||
// Handle the case where it's just the subscription we're changing
|
||||
// itself that would not schedule
|
||||
if ((subscriptions.size() == 1 && unscheduledSubscriptions.size() == 1)
|
||||
final boolean singleSubscription = subscriptions.size() == 1;
|
||||
if ((singleSubscription && unscheduledSubscriptions.size() == 1)
|
||||
&& (subscriptions.get(0).getName()
|
||||
.equals(unscheduledSubscriptions.iterator().next()))) {
|
||||
final Subscription subscription = subscriptions.get(0);
|
||||
|
@ -731,15 +732,26 @@ public class SubscriptionService implements ISubscriptionService {
|
|||
: "Subscription " + subscription.getName())
|
||||
.append(" would not fully schedule with the bandwidth management system if this action were performed.");
|
||||
} else {
|
||||
msg.append(StringUtil
|
||||
.createMessage(
|
||||
"The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:",
|
||||
unscheduledSubscriptions));
|
||||
msg.append("The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:");
|
||||
}
|
||||
|
||||
msg.append("\n\nWhat would you like to do?");
|
||||
if (singleSubscription) {
|
||||
Subscription subscription = subscriptions.get(0);
|
||||
final int maximumLatencyFromRules = SystemRuleManager.getInstance()
|
||||
.getLatency(
|
||||
subscription,
|
||||
Sets.newTreeSet(subscription.getTime()
|
||||
.getCycleTimes()));
|
||||
|
||||
return msg.toString();
|
||||
return new ForceApplyPromptConfiguration(TITLE, msg.toString(),
|
||||
proposeScheduleResponse.getRequiredLatency(),
|
||||
maximumLatencyFromRules,
|
||||
proposeScheduleResponse.getRequiredDataSetSize(),
|
||||
displayTextStrategy, subscription, unscheduledSubscriptions);
|
||||
} else {
|
||||
return new ForceApplyPromptConfiguration(TITLE, msg.toString(),
|
||||
displayTextStrategy, unscheduledSubscriptions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,7 +46,6 @@ import org.eclipse.swt.widgets.TableItem;
|
|||
import com.raytheon.uf.common.auth.user.IUser;
|
||||
import com.raytheon.uf.common.datadelivery.registry.PendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
|
||||
import com.raytheon.uf.common.datadelivery.request.DataDeliveryPermission;
|
||||
import com.raytheon.uf.common.datadelivery.service.BaseSubscriptionNotificationResponse;
|
||||
|
@ -102,6 +101,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils.TABLE_TYPE;
|
|||
* May 09, 2013 2000 djohnson Consolidate and remove duplicate code.
|
||||
* May 15, 2013 1040 mpduff Place markNotBusyInUIThread in a finally block.
|
||||
* May 23, 2013 2020 mpduff Call updateControls();
|
||||
* May 28, 2013 1650 djohnson More information when failing to schedule subscriptions.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -131,6 +131,9 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
private final NotificationMessageContainsType notificationMessageChecker = new NotificationMessageContainsType(
|
||||
BaseSubscriptionNotificationResponse.class);
|
||||
|
||||
/** Filters out which subscriptions to show **/
|
||||
private ISubscriptionManagerFilter subscriptionFilter;
|
||||
|
||||
/**
|
||||
* Enumeration to determine the type of subscription dialog this class is
|
||||
* used with.
|
||||
|
@ -149,10 +152,6 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
/** The subscription type. */
|
||||
private SubscriptionType subType = SubscriptionType.VIEWER;
|
||||
|
||||
// volatile so Eclipse job threads will see the reference that is set on the
|
||||
// UI thread
|
||||
private volatile List<String> subscriptionNameList;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -164,13 +163,17 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
* Subscription action callback.
|
||||
* @param subType
|
||||
* Subscription type.
|
||||
* @param filter
|
||||
* @param filter
|
||||
*/
|
||||
public SubscriptionTableComp(Composite parent, TableCompConfig tableConfig,
|
||||
ISubscriptionAction callback, SubscriptionType subType) {
|
||||
ISubscriptionAction callback, SubscriptionType subType,
|
||||
ISubscriptionManagerFilter subscriptionFilter) {
|
||||
super(parent, tableConfig, true);
|
||||
|
||||
this.subType = subType;
|
||||
this.subActionCallback = callback;
|
||||
this.subscriptionFilter = subscriptionFilter;
|
||||
|
||||
init();
|
||||
}
|
||||
|
@ -359,66 +362,10 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
updateColumnSortImage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the table data according to the filter selections, .
|
||||
*
|
||||
* @param groupName
|
||||
* name of subscription group
|
||||
*
|
||||
* @param officeId
|
||||
* Office identifier, such as OAX
|
||||
*/
|
||||
public void populateFilteredData(String groupName, String officeId) {
|
||||
subManagerData.clearAll();
|
||||
|
||||
if ("All Subscriptions".equals(groupName)) {
|
||||
groupName = null;
|
||||
}
|
||||
|
||||
if ("ALL".equals(officeId)) {
|
||||
officeId = null;
|
||||
}
|
||||
|
||||
try {
|
||||
List<Subscription> lo = DataDeliveryHandlers
|
||||
.getSubscriptionHandler().getByFilters(groupName, officeId);
|
||||
for (Subscription subscription : lo) {
|
||||
addSubscription(subscription);
|
||||
}
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to retrieve the list of subscriptions.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the table data according to the filter selections, .
|
||||
*
|
||||
* @param datasetName
|
||||
* name of dataset. e.g. gfs
|
||||
*
|
||||
* @param provider
|
||||
* name of provider. e.g. NOMADS
|
||||
*/
|
||||
public void populateActiveFilteredDataByDataSetAndProvider(
|
||||
String datasetName, String providerName) {
|
||||
subManagerData.clearAll();
|
||||
|
||||
try {
|
||||
List<Subscription> lo = DataDeliveryHandlers
|
||||
.getSubscriptionHandler().getActiveByDataSetAndProvider(
|
||||
datasetName, providerName);
|
||||
for (Subscription subscription : lo) {
|
||||
addSubscription(subscription);
|
||||
}
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to retrieve the list of subscriptions.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the data.
|
||||
*
|
||||
* @param filter
|
||||
*/
|
||||
public void populateData() {
|
||||
subManagerData.clearAll();
|
||||
|
@ -433,18 +380,7 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
protected IStatus run(IProgressMonitor monitor) {
|
||||
try {
|
||||
DataDeliveryGUIUtils.markBusyInUIThread(jobShell);
|
||||
if (subscriptionNameList == null
|
||||
|| subscriptionNameList.isEmpty()) {
|
||||
List<Subscription> lo = handler.getAll();
|
||||
subList.addAll(lo);
|
||||
} else {
|
||||
for (String subName : subscriptionNameList) {
|
||||
Subscription sub = handler.getByName(subName);
|
||||
if (sub != null) {
|
||||
subList.add(sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
subList.addAll(subscriptionFilter.getSubscriptions(handler));
|
||||
return Status.OK_STATUS;
|
||||
} catch (RegistryHandlerException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
|
@ -822,15 +758,6 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
return groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subscription list.
|
||||
*
|
||||
* @param subscriptionNameList
|
||||
*/
|
||||
public void setSubscriptionNameList(List<String> subscriptionNameList) {
|
||||
this.subscriptionNameList = subscriptionNameList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the selected subscription.
|
||||
*
|
||||
|
@ -842,4 +769,12 @@ public class SubscriptionTableComp extends TableComp implements IGroupAction {
|
|||
idx);
|
||||
return row.getSubscription();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param subscriptionFilter
|
||||
*/
|
||||
public void setSubscriptionFilter(
|
||||
ISubscriptionManagerFilter subscriptionFilter) {
|
||||
this.subscriptionFilter = subscriptionFilter;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,6 +136,7 @@ import com.raytheon.viz.ui.presenter.IDisplay;
|
|||
* Apr 08, 2013 1826 djohnson Remove delivery options.
|
||||
* May 15, 2013 1040 mpduff Implement shared subscriptions.
|
||||
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
|
||||
* May 28, 2013 1650 djohnson More information when failing to schedule subscriptions.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -1099,11 +1100,13 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
|
|||
public String getOptionDisplayText(ForceApplyPromptResponse option,
|
||||
int requiredLatency, Subscription subscription,
|
||||
Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
final boolean singleSubscription = wouldBeUnscheduledSubscriptions
|
||||
.size() == 1;
|
||||
switch (option) {
|
||||
case CANCEL:
|
||||
return "Do not store the adhoc query";
|
||||
case FORCE_APPLY:
|
||||
if (wouldBeUnscheduledSubscriptions.size() == 1
|
||||
if (singleSubscription
|
||||
&& wouldBeUnscheduledSubscriptions.contains(subscription
|
||||
.getName())) {
|
||||
// Can't force apply a query that won't ever be processed
|
||||
|
@ -1113,6 +1116,9 @@ public abstract class SubsetManagerDlg<DATASET extends DataSet, PRESENTER extend
|
|||
case INCREASE_LATENCY:
|
||||
return "Increase the latency on the adhoc query to "
|
||||
+ requiredLatency + " minutes";
|
||||
case EDIT_SUBSCRIPTIONS:
|
||||
return "Edit the "
|
||||
+ ((singleSubscription) ? "subscription" : "subscriptions");
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Don't know how to handle option [" + option + "]");
|
||||
|
|
|
@ -48,6 +48,7 @@ import com.raytheon.uf.viz.datadelivery.utils.DataDeliveryUtils;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 14, 2013 2000 djohnson Initial creation
|
||||
* May 23, 2013 1650 djohnson Reword change bandwidth message.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -159,7 +160,7 @@ public class BandwidthTab extends SystemApplyCancelTab {
|
|||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder(StringUtil.createMessage(
|
||||
"Changing the default bandwidth for " + Network.OPSNET
|
||||
"Changing the bandwidth for " + Network.OPSNET
|
||||
+ " will unschedule the following subscriptions:",
|
||||
subscriptionNames));
|
||||
sb.append(StringUtil.NEWLINE).append(StringUtil.NEWLINE);
|
||||
|
|
|
@ -256,11 +256,13 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
public String getOptionDisplayText(ForceApplyPromptResponse option,
|
||||
int requiredLatency, Subscription subscription,
|
||||
Set<String> wouldBeUnscheduledSubscriptions) {
|
||||
final boolean singleSubscription = wouldBeUnscheduledSubscriptions
|
||||
.size() == 1;
|
||||
switch (option) {
|
||||
case CANCEL:
|
||||
return "Do not update the rules";
|
||||
case FORCE_APPLY:
|
||||
if (wouldBeUnscheduledSubscriptions.size() == 1) {
|
||||
if (singleSubscription) {
|
||||
return "Update the rules and unschedule "
|
||||
+ wouldBeUnscheduledSubscriptions.iterator().next();
|
||||
}
|
||||
|
@ -268,6 +270,9 @@ public class SystemManagementDlg extends CaveSWTDialog implements IDisplay,
|
|||
case INCREASE_LATENCY:
|
||||
// Signifies it should not be an option
|
||||
return null;
|
||||
case EDIT_SUBSCRIPTIONS:
|
||||
return "Edit the "
|
||||
+ ((singleSubscription) ? "subscription" : "subscriptions");
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Don't know how to handle option [" + option + "]");
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.raytheon.uf.common.serialization.comm.RequestRouter;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 5, 2013 1580 mpduff Initial creation.
|
||||
* May 28, 2013 1650 djohnson Return subscriber on register method for Spring.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -71,6 +72,10 @@ public class CaveEventBusHandler implements IEventBusHandler {
|
|||
*/
|
||||
@Override
|
||||
public void publish(final Event event) {
|
||||
if (event == null) {
|
||||
throw new IllegalArgumentException("Cannot publish a null event");
|
||||
}
|
||||
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -89,7 +94,7 @@ public class CaveEventBusHandler implements IEventBusHandler {
|
|||
* UnsupportedOperationException.
|
||||
*/
|
||||
@Override
|
||||
public void register(Object subscriber) {
|
||||
public Object register(Object subscriber) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,14 @@
|
|||
-- Start a transaction
|
||||
BEGIN;
|
||||
|
||||
-- Update UserSubscription value entries to not have the notify attribute
|
||||
-- Update SiteSubscription value entries to not have the notify attribute
|
||||
update ebxml.value set stringvalue = regexp_replace(stringvalue, 'notify=".*?" ', '', 'g');
|
||||
|
||||
-- Update GroupDefinition value entries to not have the option attribute
|
||||
-- Explanation of how this works: \\1 is the first set of parentheses, \\2 is the second set,
|
||||
-- So we are removing the option="<anything>" section out of any rows that have it and stitching the
|
||||
-- data back together.
|
||||
update ebxml.value set stringvalue = regexp_replace(stringvalue, '(<groupDefinition.*?)option=".*?"(.*)', E'\\1\\2', 'g');
|
||||
|
||||
-- Commit the transaction
|
||||
END;
|
||||
|
|
|
@ -213,6 +213,7 @@
|
|||
|
||||
<mode name="statsTemplate" template="true">
|
||||
<include>event-common.xml</include>
|
||||
<include>eventbus-common.xml</include>
|
||||
<include>stats-common.xml</include>
|
||||
</mode>
|
||||
<mode name="dataDeliveryTemplate" template="true">
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.Set;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 29, 2012 1286 djohnson Initial creation
|
||||
* May 28, 2013 1650 djohnson More information when failing to schedule.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,11 +53,16 @@ public interface IProposeScheduleResponse {
|
|||
|
||||
@Override
|
||||
public int getRequiredLatency() {
|
||||
return REQUIRED_LATENCY_NOT_SET;
|
||||
return VALUE_NOT_SET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRequiredDataSetSize() {
|
||||
return VALUE_NOT_SET;
|
||||
}
|
||||
};
|
||||
|
||||
int REQUIRED_LATENCY_NOT_SET = -1;
|
||||
int VALUE_NOT_SET = -1;
|
||||
|
||||
/**
|
||||
* Get the set of subscription names that would be unscheduled if the
|
||||
|
@ -73,4 +79,12 @@ public interface IProposeScheduleResponse {
|
|||
* @return the required latency
|
||||
*/
|
||||
int getRequiredLatency();
|
||||
|
||||
/**
|
||||
* Get the required dataset size for the subscription to not unschedule any
|
||||
* subscriptions.
|
||||
*
|
||||
* @return the required dataset size
|
||||
*/
|
||||
long getRequiredDataSetSize();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 29, 2012 1286 djohnson Initial creation
|
||||
* May 28, 2013 1650 djohnson More information when failing to schedule.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -49,7 +50,10 @@ public class ProposeScheduleResponse implements IProposeScheduleResponse {
|
|||
private Set<String> unscheduledSubscriptions = Collections.emptySet();
|
||||
|
||||
@DynamicSerializeElement
|
||||
private int requiredLatency = IProposeScheduleResponse.REQUIRED_LATENCY_NOT_SET;
|
||||
private int requiredLatency = IProposeScheduleResponse.VALUE_NOT_SET;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private long requiredDataSetSize = IProposeScheduleResponse.VALUE_NOT_SET;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -81,4 +85,21 @@ public class ProposeScheduleResponse implements IProposeScheduleResponse {
|
|||
public int getRequiredLatency() {
|
||||
return requiredLatency;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param requiredDataSetSize
|
||||
*/
|
||||
public void setRequiredDataSetSize(long requiredDataSetSize) {
|
||||
this.requiredDataSetSize = requiredDataSetSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public long getRequiredDataSetSize() {
|
||||
return requiredDataSetSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
* Dec 10, 2012 1259 bsteffen Switch Data Delivery from LatLon to referenced envelopes.
|
||||
* Jan 02, 2013 1441 djohnson Add constants.
|
||||
* Apr 08, 2013 1826 djohnson Remove delivery options.
|
||||
* May 22, 2013 1650 djohnson Remove option instance variable.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -64,10 +65,6 @@ public class GroupDefinition {
|
|||
@SlotAttribute
|
||||
protected String groupName;
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
protected Integer option;
|
||||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@SlotAttribute
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.raytheon.uf.common.datadelivery.registry.ebxml;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
|
@ -33,6 +34,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
* Oct 03, 2012 1241 djohnson Move query parameters in from SubscriptionQuery.
|
||||
* Oct 10, 2012 0726 djohnson Add {@link #setActive(boolean)}.
|
||||
* Feb 20, 2013 1543 djohnson Add ability to filter on routes.
|
||||
* May 28, 2013 1650 djohnson More information when failing to schedule.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -76,7 +78,32 @@ public abstract class SubscriptionFilterableQuery<T> extends
|
|||
* The value of the name attribute to search for.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
setAttribute("name", new StringAttribute(name));
|
||||
setAttribute(Subscription.NAME_SLOT, new StringAttribute(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* A setter for the queryable attribute name is like a String value. Using
|
||||
* this setter will equate to an HQL "like" query against the specified
|
||||
* column name.
|
||||
*
|
||||
* @param name
|
||||
* The HQL compliant like value to use to query name attribute.
|
||||
*/
|
||||
public void setNameLike(String name) {
|
||||
setAttribute(Subscription.NAME_SLOT, new StringAttribute(name, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* A setter for the queryable attribute providerName equals a List of String
|
||||
* values. Using this setter will equate to an HQL "in list" query against
|
||||
* the specified column name.
|
||||
*
|
||||
* @param collectionNames
|
||||
* The values of the name attribute to search for.
|
||||
*/
|
||||
public void setNames(Collection<String> names) {
|
||||
setAttribute(Subscription.NAME_SLOT, new StringAttribute(
|
||||
new ArrayList<String>(names)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.common.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -46,6 +47,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* Oct 03, 2012 1241 djohnson More query methods.
|
||||
* Oct 10, 2012 0726 djohnson Add {@link #getActive()}.
|
||||
* Feb 20, 2013 1543 djohnson Add ability to filter on routes.
|
||||
* May 28, 2013 1650 djohnson Add getByNames.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -74,6 +76,23 @@ public abstract class BaseSubscriptionHandler<T extends Subscription, QUERY exte
|
|||
return response.getSingleResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getByNames(Collection<String> names)
|
||||
throws RegistryHandlerException {
|
||||
SubscriptionFilterableQuery<T> query = getQuery();
|
||||
query.setNames(names);
|
||||
|
||||
RegistryQueryResponse<T> response = RegistryManager
|
||||
.getRegistyObjects(query);
|
||||
|
||||
checkResponse(response, "getByNames");
|
||||
|
||||
return response.getResults();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.common.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -41,6 +42,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* Oct 03, 2012 1241 djohnson More query methods.
|
||||
* Oct 10, 2012 0726 djohnson Add {@link #getActive()}.
|
||||
* Feb 20, 2013 1543 djohnson Add ability to filter on routes.
|
||||
* May 28, 2013 1650 djohnson Add getByNames.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -61,6 +63,16 @@ public interface IBaseSubscriptionHandler<T extends Subscription> extends
|
|||
*/
|
||||
T getByName(String name) throws RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Retrieve subscriptions by name.
|
||||
*
|
||||
* @param names
|
||||
* the namnes
|
||||
* @return the subscriptions
|
||||
*/
|
||||
List<T> getByNames(Collection<String> names)
|
||||
throws RegistryHandlerException;
|
||||
|
||||
/**
|
||||
* Retrieve a list of subscriptions by the owner.
|
||||
*
|
||||
|
|
|
@ -28,11 +28,11 @@ import java.util.Set;
|
|||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSharedSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Network;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.registry.handler.IRegistryObjectHandler;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.util.CollectionUtil;
|
||||
|
@ -50,6 +50,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
* Sep 18, 2012 1169 djohnson Initial creation
|
||||
* Sep 24, 2012 1157 mpduff Changed to use InitialPendingSubscription.
|
||||
* 4/9/2013 1802 bphillip Using constant values from constants package instead of RegistryUtil
|
||||
* May 28, 2013 1650 djohnson Add getByNames.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -91,6 +92,19 @@ public class PendingSubscriptionHandler implements IPendingSubscriptionHandler {
|
|||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<InitialPendingSubscription> getByNames(Collection<String> names)
|
||||
throws RegistryHandlerException {
|
||||
List<InitialPendingSubscription> subs = Lists.newArrayList();
|
||||
subs.addAll(siteSubscriptionHandler.getByNames(names));
|
||||
subs.addAll(sharedSubscriptionHandler.getByNames(names));
|
||||
|
||||
return subs;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
|
@ -50,6 +50,7 @@ import com.raytheon.uf.common.util.CollectionUtil;
|
|||
* Apr 05, 2013 1841 djohnson Add support for shared subscriptions.
|
||||
* 4/9/2013 1802 bphillip Using constant values from constants package instead of RegistryUtil
|
||||
* May 21, 2013 2020 mpduff Rename UserSubscription to SiteSubscription.
|
||||
* May 28, 2013 1650 djohnson Add getByNames.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -140,6 +141,19 @@ public class SubscriptionHandler implements ISubscriptionHandler {
|
|||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<Subscription> getByNames(Collection<String> names)
|
||||
throws RegistryHandlerException {
|
||||
List<Subscription> subs = Lists.newArrayList();
|
||||
subs.addAll(siteSubscriptionHandler.getByNames(names));
|
||||
subs.addAll(sharedSubscriptionHandler.getByNames(names));
|
||||
|
||||
return subs;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -344,4 +358,5 @@ public class SubscriptionHandler implements ISubscriptionHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="res"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
.,\
|
||||
res/
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean id="eventBus" class="com.raytheon.uf.common.event.EventBusBean" />
|
||||
|
||||
</beans>
|
|
@ -2,10 +2,6 @@ package com.raytheon.uf.common.event;
|
|||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* The EventBus.
|
||||
*
|
||||
|
@ -20,6 +16,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Dec 11, 2012 1407 djohnson Separate the creation of the Google EventBus from the wrapper class.
|
||||
* Feb 05, 2013 1580 mpduff Moved to common, use IEventBusHandler.
|
||||
* Apr 29, 2013 1910 djohnson Watch for NPEs and errors unregistering.
|
||||
* May 28, 2013 1650 djohnson Simplify and extract out the general event bus handling for reuse.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -34,11 +31,6 @@ public final class EventBus {
|
|||
.iterator().next();
|
||||
}
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(EventBus.class);
|
||||
|
||||
private static final String NULL_SUBSCRIBER = "Ignoring a null subscriber.";
|
||||
|
||||
private EventBus() {
|
||||
|
||||
}
|
||||
|
@ -50,12 +42,7 @@ public final class EventBus {
|
|||
* The subscriber to register
|
||||
*/
|
||||
public static void register(Object subscriber) {
|
||||
if (subscriber != null) {
|
||||
handler.register(subscriber);
|
||||
} else {
|
||||
statusHandler.handle(Priority.WARN, NULL_SUBSCRIBER,
|
||||
new IllegalArgumentException(NULL_SUBSCRIBER));
|
||||
}
|
||||
handler.register(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -65,19 +52,7 @@ public final class EventBus {
|
|||
* The subscriber to unregister
|
||||
*/
|
||||
public static void unregister(Object subscriber) {
|
||||
if (subscriber != null) {
|
||||
try {
|
||||
handler.unregister(subscriber);
|
||||
} catch (Throwable t) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Unable to unregister subscriber of type ["
|
||||
+ subscriber.getClass().getName()
|
||||
+ "] from the retrieval event bus!", t);
|
||||
}
|
||||
} else {
|
||||
statusHandler.handle(Priority.WARN, NULL_SUBSCRIBER,
|
||||
new IllegalArgumentException(NULL_SUBSCRIBER));
|
||||
}
|
||||
handler.unregister(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,10 +62,6 @@ public final class EventBus {
|
|||
* The event to publish
|
||||
*/
|
||||
public static void publish(Event event) {
|
||||
if (event == null) {
|
||||
throw new IllegalArgumentException("Cannot publish a null event");
|
||||
}
|
||||
|
||||
handler.publish(event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.event;
|
||||
|
||||
|
||||
/**
|
||||
* Convenient Spring Bean class that simplifies access to the {@link EventBus}
|
||||
* from Spring.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 24, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class EventBusBean implements IEventBusHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object register(Object subscriber) {
|
||||
EventBus.register(subscriber);
|
||||
return subscriber;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void unregister(Object subscriber) {
|
||||
EventBus.unregister(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void publish(Event event) {
|
||||
EventBus.publish(event);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.event;
|
||||
|
||||
/**
|
||||
* Base interface for interacting with an EventBus.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 28, 2013 1650 djohnson Extracted from {@link IEventBusHandler}.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IBaseEventBusHandler<T> {
|
||||
|
||||
/**
|
||||
* Publishes objects for all subscribers to receive
|
||||
*
|
||||
* @param object
|
||||
* the object
|
||||
*/
|
||||
void publish(T object);
|
||||
|
||||
/**
|
||||
* Register an object with the event bus.
|
||||
*
|
||||
* @param subscriber
|
||||
* the subscriber to register
|
||||
* @return the subscriber reference
|
||||
*/
|
||||
Object register(Object subscriber);
|
||||
|
||||
/**
|
||||
* Unregister an object with the event bus.
|
||||
*
|
||||
* @param subscriber
|
||||
* the object subscribed to the event buss
|
||||
*/
|
||||
void unregister(Object subscriber);
|
||||
|
||||
}
|
|
@ -29,6 +29,7 @@ package com.raytheon.uf.common.event;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 5, 2013 1580 mpduff Initial creation.
|
||||
* May 28, 2013 1650 djohnson Extract out the general event bus contract for reuse.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -36,30 +37,5 @@ package com.raytheon.uf.common.event;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public interface IEventBusHandler {
|
||||
|
||||
/**
|
||||
* Publishes events for all subscribers to receive
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
void publish(Event event);
|
||||
|
||||
/**
|
||||
* Register an object with the event bus.
|
||||
*
|
||||
* @param subscriber
|
||||
* the subscriber to register
|
||||
*/
|
||||
void register(Object subscriber);
|
||||
|
||||
/**
|
||||
* Unregister an object with the event bus.
|
||||
*
|
||||
* @param subscriber
|
||||
* the object subscribed to the event buss
|
||||
*/
|
||||
void unregister(Object subscriber);
|
||||
|
||||
public interface IEventBusHandler extends IBaseEventBusHandler<Event> {
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthAsyncEventBusFactory
|
|
@ -0,0 +1 @@
|
|||
com.raytheon.uf.edex.datadelivery.bandwidth.notification.EdexBandwidthEventBusHandler
|
|
@ -0,0 +1,17 @@
|
|||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
|
||||
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<constructor-arg ref="retrievalManager" />
|
||||
</bean>
|
||||
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<constructor-arg ref="bandwidthManager" />
|
||||
</bean>
|
||||
|
||||
<bean factory-bean="bandwidthEventBus" factory-method="register">
|
||||
<constructor-arg ref="bandwidthManager" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -11,6 +11,8 @@
|
|||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="bandwidthEventBus" class="com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthEventBusBean" />
|
||||
|
||||
<bean id="bandwidthDao" factory-bean="bandwidthContextFactory"
|
||||
factory-method="getBandwidthDao" />
|
||||
|
@ -101,16 +103,6 @@
|
|||
<property name="retrievalPlans" ref="retrievalPlans" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="retrievalManager" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="BandwidthManagerProcessor"
|
||||
class="com.raytheon.uf.edex.datadelivery.bandwidth.processing.Processor" />
|
||||
<bean id="BandwidthManagerRetrieval"
|
||||
|
|
|
@ -109,6 +109,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Mar 11, 2013 1645 djohnson Watch configuration file for changes.
|
||||
* Mar 28, 2013 1841 djohnson Subscription is now UserSubscription.
|
||||
* May 02, 2013 1910 djohnson Shutdown proposed bandwidth managers in a finally.
|
||||
* May 20, 2013 1650 djohnson Add in capability to find required dataset size.
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -142,16 +143,17 @@ public abstract class BandwidthManager extends
|
|||
@VisibleForTesting
|
||||
final Runnable watchForConfigFileChanges = new Runnable() {
|
||||
|
||||
private final IFileModifiedWatcher fileModifiedWatcher = FileUtil.getFileModifiedWatcher(EdexBandwidthContextFactory
|
||||
.getBandwidthMapConfig());
|
||||
private final IFileModifiedWatcher fileModifiedWatcher = FileUtil
|
||||
.getFileModifiedWatcher(EdexBandwidthContextFactory
|
||||
.getBandwidthMapConfig());
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (fileModifiedWatcher.hasBeenModified()) {
|
||||
bandwidthMapConfigurationUpdated();
|
||||
}
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void run() {
|
||||
if (fileModifiedWatcher.hasBeenModified()) {
|
||||
bandwidthMapConfigurationUpdated();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public BandwidthManager(IBandwidthDbInit dbInit,
|
||||
IBandwidthDao bandwidthDao, RetrievalManager retrievalManager,
|
||||
|
@ -161,13 +163,10 @@ public abstract class BandwidthManager extends
|
|||
this.retrievalManager = retrievalManager;
|
||||
this.bandwidthDaoUtil = bandwidthDaoUtil;
|
||||
|
||||
EventBus.register(this);
|
||||
BandwidthEventBus.register(this);
|
||||
|
||||
// schedule maintenance tasks
|
||||
scheduler = Executors.newScheduledThreadPool(1);
|
||||
scheduler.scheduleAtFixedRate(watchForConfigFileChanges,
|
||||
1, 1, TimeUnit.MINUTES);
|
||||
scheduler.scheduleAtFixedRate(watchForConfigFileChanges, 1, 1,
|
||||
TimeUnit.MINUTES);
|
||||
scheduler.scheduleAtFixedRate(new MaintanenceTask(), 1, 5,
|
||||
TimeUnit.MINUTES);
|
||||
}
|
||||
|
@ -1172,8 +1171,11 @@ public abstract class BandwidthManager extends
|
|||
// scheduled, just apply
|
||||
scheduleSubscriptions(subscriptions);
|
||||
} else if (subscriptions.size() == 1) {
|
||||
int requiredLatency = determineRequiredLatency(subscriptions.get(0));
|
||||
final Subscription subscription = subscriptions.get(0);
|
||||
int requiredLatency = determineRequiredLatency(subscription);
|
||||
proposeResponse.setRequiredLatency(requiredLatency);
|
||||
long requiredDataSetSize = determineRequiredDataSetSize(subscription);
|
||||
proposeResponse.setRequiredDataSetSize(requiredDataSetSize);
|
||||
}
|
||||
return proposeResponse;
|
||||
}
|
||||
|
@ -1402,7 +1404,6 @@ public abstract class BandwidthManager extends
|
|||
nullSafeShutdown(proposedBwManager);
|
||||
}
|
||||
|
||||
|
||||
return subscriptions;
|
||||
}
|
||||
|
||||
|
@ -1461,8 +1462,7 @@ public abstract class BandwidthManager extends
|
|||
try {
|
||||
ctx = new ClassPathXmlApplicationContext(springFiles,
|
||||
EDEXUtil.getSpringContext());
|
||||
return (BandwidthManager) ctx.getBean("bandwidthManager",
|
||||
BandwidthManager.class);
|
||||
return ctx.getBean("bandwidthManager", BandwidthManager.class);
|
||||
} finally {
|
||||
if (close) {
|
||||
Util.close(ctx);
|
||||
|
@ -1578,18 +1578,9 @@ public abstract class BandwidthManager extends
|
|||
*/
|
||||
@VisibleForTesting
|
||||
void shutdown() {
|
||||
try {
|
||||
EventBus.unregister(this);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Unable to unregister from the EventBus.", e);
|
||||
}
|
||||
try {
|
||||
BandwidthEventBus.unregister(this);
|
||||
} catch (Exception e) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Unable to unregister from the BandwidthEventBus.", e);
|
||||
}
|
||||
unregisterFromEventBus();
|
||||
unregisterFromBandwidthEventBus();
|
||||
|
||||
try {
|
||||
retrievalManager.shutdown();
|
||||
} catch (Exception e) {
|
||||
|
@ -1604,6 +1595,20 @@ public abstract class BandwidthManager extends
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister from the {@link EventBus}.
|
||||
*/
|
||||
private void unregisterFromEventBus() {
|
||||
EventBus.unregister(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister from the {@link BandwidthEventBus}.
|
||||
*/
|
||||
private void unregisterFromBandwidthEventBus() {
|
||||
BandwidthEventBus.register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Spring files used to create a new instance of this
|
||||
* {@link BandwidthManager} type.
|
||||
|
@ -1622,85 +1627,111 @@ public abstract class BandwidthManager extends
|
|||
*/
|
||||
@VisibleForTesting
|
||||
int determineRequiredLatency(final Subscription subscription) {
|
||||
final int requiredLatency = determineRequiredValue(subscription,
|
||||
new FindSubscriptionRequiredLatency());
|
||||
|
||||
final int bufferRoomInMinutes = retrievalManager.getPlan(
|
||||
subscription.getRoute()).getBucketMinutes();
|
||||
|
||||
return requiredLatency + bufferRoomInMinutes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the dataset size that would be required on the subscription for
|
||||
* it to be fully scheduled.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
* @return the required dataset size
|
||||
*/
|
||||
private long determineRequiredDataSetSize(final Subscription subscription) {
|
||||
return determineRequiredValue(subscription,
|
||||
new FindSubscriptionRequiredDataSetSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine a value that would be required on the subscription for it to be
|
||||
* fully scheduled.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
* @param strategy
|
||||
* the required value strategy
|
||||
* @return the required value
|
||||
*/
|
||||
private <T extends Comparable<T>> T determineRequiredValue(
|
||||
final Subscription subscription,
|
||||
final IFindSubscriptionRequiredValue<T> strategy) {
|
||||
ITimer timer = TimeUtil.getTimer();
|
||||
timer.start();
|
||||
|
||||
boolean foundLatency = false;
|
||||
int latency = subscription.getLatencyInMinutes();
|
||||
if (latency < 1) {
|
||||
latency = 1;
|
||||
}
|
||||
int previousLatency = latency;
|
||||
boolean foundRequiredValue = false;
|
||||
T currentValue = strategy.getInitialValue(subscription);
|
||||
|
||||
T previousValue = currentValue;
|
||||
do {
|
||||
// Double the latency until we have two values we can binary
|
||||
// search between...
|
||||
previousLatency = latency;
|
||||
latency *= 2;
|
||||
previousValue = currentValue;
|
||||
currentValue = strategy.getNextValue(subscription, currentValue);
|
||||
|
||||
Subscription clone = subscription.copy();
|
||||
clone.setLatencyInMinutes(latency);
|
||||
foundLatency = isSchedulableWithoutConflict(clone);
|
||||
} while (!foundLatency);
|
||||
Subscription clone = strategy.setValue(subscription.copy(),
|
||||
currentValue);
|
||||
foundRequiredValue = isSchedulableWithoutConflict(clone);
|
||||
} while (!foundRequiredValue);
|
||||
|
||||
SortedSet<Integer> possibleLatencies = new TreeSet<Integer>();
|
||||
for (int i = previousLatency; i < (latency + 1); i++) {
|
||||
possibleLatencies.add(Integer.valueOf(i));
|
||||
}
|
||||
SortedSet<T> possibleValues = strategy.getPossibleValues(previousValue,
|
||||
currentValue);
|
||||
|
||||
IBinarySearchResponse<Integer> response = AlgorithmUtil.binarySearch(
|
||||
possibleLatencies, new Comparable<Integer>() {
|
||||
IBinarySearchResponse<T> response = AlgorithmUtil.binarySearch(
|
||||
possibleValues, new Comparable<T>() {
|
||||
@Override
|
||||
public int compareTo(Integer valueToCheck) {
|
||||
Subscription clone = subscription.copy();
|
||||
clone.setLatencyInMinutes(valueToCheck);
|
||||
public int compareTo(T valueToCheck) {
|
||||
Subscription clone = strategy.setValue(
|
||||
subscription.copy(), valueToCheck);
|
||||
|
||||
boolean latencyWouldWork = isSchedulableWithoutConflict(clone);
|
||||
boolean valueWouldWork = isSchedulableWithoutConflict(clone);
|
||||
|
||||
// Check if one value less would not work, if so
|
||||
// then this is the required latency, otherwise keep
|
||||
// Check if one more restrictive value would not work,
|
||||
// if so then this is the required value, otherwise keep
|
||||
// searching
|
||||
if (latencyWouldWork) {
|
||||
clone.setLatencyInMinutes(clone
|
||||
.getLatencyInMinutes() - 1);
|
||||
if (valueWouldWork) {
|
||||
clone = strategy.setValue(
|
||||
subscription.copy(),
|
||||
strategy.getNextRestrictiveValue(valueToCheck));
|
||||
|
||||
return (isSchedulableWithoutConflict(clone)) ? 1
|
||||
: 0;
|
||||
} else {
|
||||
// Still too low, stuff would be unscheduled
|
||||
// Stuff would still be unscheduled
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
final Integer binarySearchedLatency = response.getItem();
|
||||
if (binarySearchedLatency != null) {
|
||||
latency = binarySearchedLatency.intValue();
|
||||
final T binarySearchedValue = response.getItem();
|
||||
final String valueDescription = strategy.getValueDescription();
|
||||
if (binarySearchedValue != null) {
|
||||
currentValue = binarySearchedValue;
|
||||
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler.debug(String.format(
|
||||
"Found required latency of [%s] in [%s] iterations",
|
||||
binarySearchedLatency, response.getIterations()));
|
||||
statusHandler.debug(String.format("Found required "
|
||||
+ valueDescription + " of [%s] in [%s] iterations",
|
||||
binarySearchedValue, response.getIterations()));
|
||||
}
|
||||
} else {
|
||||
statusHandler
|
||||
.warn(String
|
||||
.format("Unable to find the required latency with a binary search, using required latency [%s]",
|
||||
latency));
|
||||
statusHandler.warn(String.format("Unable to find the required "
|
||||
+ valueDescription
|
||||
+ " with a binary search, using value [%s]", currentValue));
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
|
||||
int bufferRoomInMinutes = retrievalManager.getPlan(
|
||||
subscription.getRoute()).getBucketMinutes();
|
||||
final String logMsg = String.format("Determined required "
|
||||
+ valueDescription + " of [%s] in [%s] ms.", currentValue,
|
||||
timer.getElapsedTime());
|
||||
|
||||
final String logMsg = String
|
||||
.format("Determined required latency of [%s] in [%s] ms. Adding buffer room of [%s] minutes",
|
||||
latency, timer.getElapsedTime(), bufferRoomInMinutes);
|
||||
statusHandler.info(logMsg);
|
||||
|
||||
latency += bufferRoomInMinutes;
|
||||
|
||||
return latency;
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
|
||||
/**
|
||||
* Find the subscription size that would allow it to be fully scheduled.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 20, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
class FindSubscriptionRequiredDataSetSize implements
|
||||
IFindSubscriptionRequiredValue<Long> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Long getInitialValue(Subscription subscription) {
|
||||
return subscription.getDataSetSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Long getNextValue(Subscription subscription, Long currentValue) {
|
||||
return currentValue /= 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Subscription setValue(Subscription subscription, Long value) {
|
||||
subscription.setDataSetSize(value);
|
||||
return subscription;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SortedSet<Long> getPossibleValues(Long previousValue,
|
||||
Long currentValue) {
|
||||
SortedSet<Long> possibleValues = new TreeSet<Long>(
|
||||
Collections.reverseOrder());
|
||||
for (long i = currentValue; i < previousValue; i++) {
|
||||
possibleValues.add(Long.valueOf(i));
|
||||
}
|
||||
return possibleValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Long getNextRestrictiveValue(Long value) {
|
||||
// For DataSet size, a higher value would be more restrictive
|
||||
return Long.valueOf(value.longValue() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getValueDescription() {
|
||||
return "dataset size";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
|
||||
/**
|
||||
* Find the subscription latency that would allow it to be fully scheduled.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 20, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class FindSubscriptionRequiredLatency implements
|
||||
IFindSubscriptionRequiredValue<Integer> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Integer getInitialValue(Subscription subscription) {
|
||||
int latency = subscription.getLatencyInMinutes();
|
||||
if (latency < 1) {
|
||||
latency = 1;
|
||||
}
|
||||
return latency;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Integer getNextValue(Subscription subscription, Integer currentValue) {
|
||||
return currentValue *= 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Subscription setValue(Subscription subscription, Integer value) {
|
||||
subscription.setLatencyInMinutes(value.intValue());
|
||||
return subscription;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public SortedSet<Integer> getPossibleValues(Integer previousValue,
|
||||
Integer currentValue) {
|
||||
SortedSet<Integer> possibleValues = new TreeSet<Integer>();
|
||||
for (int i = previousValue; i < (currentValue + 1); i++) {
|
||||
possibleValues.add(Integer.valueOf(i));
|
||||
}
|
||||
return possibleValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Integer getNextRestrictiveValue(Integer value) {
|
||||
// For latency, a less value would be more restrictive
|
||||
return Integer.valueOf(value.intValue() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getValueDescription() {
|
||||
return "latency";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth;
|
||||
|
||||
import java.util.SortedSet;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
|
||||
/**
|
||||
* Defines the interface to search for a required value on a subscription so
|
||||
* that it would fully schedule.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 20, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
interface IFindSubscriptionRequiredValue<T extends Comparable<T>> {
|
||||
|
||||
/**
|
||||
* Get the initial value from the subscription.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
* @return the initial value
|
||||
*/
|
||||
T getInitialValue(Subscription subscription);
|
||||
|
||||
/**
|
||||
* Get the next value that should be tried, when doing a large search.
|
||||
*
|
||||
* @param subscription
|
||||
* the subscription
|
||||
* @param currentValue
|
||||
* the next value that should be attempted
|
||||
* @return the next value
|
||||
*/
|
||||
T getNextValue(Subscription subscription, T currentValue);
|
||||
|
||||
Subscription setValue(Subscription subscription, T value);
|
||||
|
||||
/**
|
||||
* Get all values that should be included between the value that did not
|
||||
* work and the value that did work.
|
||||
*
|
||||
* @param valueThatDidNotWork
|
||||
* the value that did not work
|
||||
* @param valueThatDidWork
|
||||
* the value that did work
|
||||
* @return the set of values that will be binary searched
|
||||
*/
|
||||
SortedSet<T> getPossibleValues(T valueThatDidNotWork, T valueThatDidWork);
|
||||
|
||||
/**
|
||||
* Get the value that would be closest to the given value, but be more
|
||||
* restrictive (i.e. more likely to not work).
|
||||
*
|
||||
* @param value
|
||||
* the value
|
||||
* @return the more restrictive value to attempt
|
||||
*/
|
||||
T getNextRestrictiveValue(T value);
|
||||
|
||||
/**
|
||||
* Get the description of the value that is being sought.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
String getValueDescription();
|
||||
}
|
|
@ -64,6 +64,7 @@ public class WfoBandwidthManagerCreator implements IEdexBandwidthManagerCreator
|
|||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-edex-impl.xml"),
|
||||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery.xml"),
|
||||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-daos.xml"),
|
||||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-eventbus.xml"),
|
||||
JarUtil.getResResourcePath("/spring/thrift-bandwidth.xml"),
|
||||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-wfo.xml") };
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import com.google.common.eventbus.AsyncEventBus;
|
||||
|
@ -38,6 +40,7 @@ import com.raytheon.uf.edex.core.EDEXUtil;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 11, 2012 1286 djohnson Initial creation
|
||||
* Feb 06, 2013 1543 djohnson Changes to correspond with EventBus changes.
|
||||
* May 28, 2013 1650 djohnson Changes to match functionality in general event bus handling.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -96,4 +99,13 @@ public class BandwidthAsyncEventBusFactory implements BandwidthEventBusFactory {
|
|||
return retrievalBus;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<EventBus> getEventBuses() {
|
||||
return Arrays.<EventBus> asList(dataSetBus, retrievalBus,
|
||||
subscriptionBus);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,15 +2,6 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
|||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.SubscriptionRetrievalFulfilled;
|
||||
|
||||
/**
|
||||
* Class encapsulating the notification system used by BandwidthManager.
|
||||
*
|
||||
|
@ -24,33 +15,24 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.SubscriptionRetriev
|
|||
* Dec 11, 2012 1286 djohnson Create a factory to hold Google event buses.
|
||||
* Feb 07, 2013 1543 djohnson Changed to behave similarly to EventBus.
|
||||
* Apr 29, 2013 1910 djohnson Watch for NPEs and errors unregistering.
|
||||
* May 28, 2013 1650 djohnson Simplify and use the extracted general event bus handling.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BandwidthEventBus {
|
||||
public final class BandwidthEventBus {
|
||||
|
||||
private static final BandwidthEventBusFactory eventBusFactory;
|
||||
private static final IBandwidthEventBusHandler handler;
|
||||
static {
|
||||
eventBusFactory = ServiceLoader
|
||||
.<BandwidthEventBusFactory> load(BandwidthEventBusFactory.class)
|
||||
.iterator().next();
|
||||
handler = ServiceLoader
|
||||
.<IBandwidthEventBusHandler> load(
|
||||
IBandwidthEventBusHandler.class).iterator().next();
|
||||
}
|
||||
|
||||
private static final com.google.common.eventbus.EventBus dataSetBus = eventBusFactory
|
||||
.getDataSetBus();
|
||||
private BandwidthEventBus() {
|
||||
|
||||
private static final com.google.common.eventbus.EventBus subscriptionBus = eventBusFactory
|
||||
.getSubscriptionBus();
|
||||
|
||||
private static final com.google.common.eventbus.EventBus retrievalBus = eventBusFactory
|
||||
.getRetrievalBus();
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(BandwidthEventBus.class);
|
||||
|
||||
private static final String NULL_SUBSCRIBER = "Ignoring a null subscriber.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an object with the event bus.
|
||||
|
@ -58,14 +40,7 @@ public class BandwidthEventBus {
|
|||
* @param subscriber
|
||||
*/
|
||||
public static void register(Object subscriber) {
|
||||
if (subscriber != null) {
|
||||
BandwidthEventBus.retrievalBus.register(subscriber);
|
||||
BandwidthEventBus.subscriptionBus.register(subscriber);
|
||||
BandwidthEventBus.dataSetBus.register(subscriber);
|
||||
} else {
|
||||
statusHandler.handle(Priority.WARN, NULL_SUBSCRIBER,
|
||||
new IllegalArgumentException(NULL_SUBSCRIBER));
|
||||
}
|
||||
handler.register(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,58 +49,16 @@ public class BandwidthEventBus {
|
|||
* @param subscriber
|
||||
*/
|
||||
public static void unregister(Object subscriber) {
|
||||
if (subscriber != null) {
|
||||
try {
|
||||
BandwidthEventBus.retrievalBus.unregister(subscriber);
|
||||
} catch (Throwable t) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Unable to unregister subscriber of type ["
|
||||
+ subscriber.getClass().getName()
|
||||
+ "] from the retrieval event bus!", t);
|
||||
}
|
||||
try {
|
||||
BandwidthEventBus.subscriptionBus.unregister(subscriber);
|
||||
} catch (Throwable t) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Unable to unregister subscriber of type ["
|
||||
+ subscriber.getClass().getName()
|
||||
+ "] from the subscription event bus!", t);
|
||||
}
|
||||
try {
|
||||
BandwidthEventBus.dataSetBus.unregister(subscriber);
|
||||
} catch (Throwable t) {
|
||||
statusHandler.handle(Priority.WARN,
|
||||
"Unable to unregister subscriber of type ["
|
||||
+ subscriber.getClass().getName()
|
||||
+ "] from the dataSet event bus!", t);
|
||||
}
|
||||
} else {
|
||||
statusHandler.handle(Priority.WARN, NULL_SUBSCRIBER,
|
||||
new IllegalArgumentException(NULL_SUBSCRIBER));
|
||||
}
|
||||
handler.unregister(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes events for all subscribers to receive
|
||||
*
|
||||
* @param event
|
||||
* @param object
|
||||
*/
|
||||
public static void publish(Object object) {
|
||||
if (object instanceof SubscriptionRetrieval) {
|
||||
BandwidthEventBus.retrievalBus.post(object);
|
||||
} else if (object instanceof SubscriptionRetrievalFulfilled) {
|
||||
BandwidthEventBus.subscriptionBus.post(object);
|
||||
} else if (object instanceof DataSetMetaData) {
|
||||
BandwidthEventBus.dataSetBus.post(object);
|
||||
} else if (object instanceof Subscription) {
|
||||
BandwidthEventBus.subscriptionBus.post(object);
|
||||
} else if (object instanceof RemoveRegistryEvent) {
|
||||
BandwidthEventBus.subscriptionBus.post(object);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Object type ["
|
||||
+ object.getClass().getName()
|
||||
+ "] not supported in BandwidthEventBus");
|
||||
}
|
||||
handler.publish(object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
||||
|
||||
|
||||
/**
|
||||
* Convenient Spring Bean class that simplifies access to the
|
||||
* {@link BandwidthEventBus} from Spring.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 24, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
public class BandwidthEventBusBean implements IBandwidthEventBusHandler {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object register(Object subscriber) {
|
||||
BandwidthEventBus.register(subscriber);
|
||||
return subscriber;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void unregister(Object subscriber) {
|
||||
BandwidthEventBus.unregister(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void publish(Object event) {
|
||||
BandwidthEventBus.publish(event);
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.raytheon.uf.edex.event.GoogleEventBusFactory;
|
||||
|
||||
/**
|
||||
* Interface for the bandwidth event bus factory.
|
||||
|
@ -31,6 +32,7 @@ import com.google.common.eventbus.EventBus;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 11, 2012 djohnson Initial creation
|
||||
* May 28, 2013 1650 djohnson Returns the event buses required by extending GoogleEventBusFactory.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -38,7 +40,7 @@ import com.google.common.eventbus.EventBus;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
interface BandwidthEventBusFactory {
|
||||
interface BandwidthEventBusFactory extends GoogleEventBusFactory {
|
||||
|
||||
/**
|
||||
* Get the data set bus.
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.SubscriptionRetrievalFulfilled;
|
||||
import com.raytheon.uf.edex.event.BaseEdexEventBusHandler;
|
||||
|
||||
/**
|
||||
* Bandwidth Event Bus handler used on EDEX.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 28, 2013 1650 djohnson Extracted from {@link BandwidthEventBus}.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EdexBandwidthEventBusHandler extends
|
||||
BaseEdexEventBusHandler<Object> implements IBandwidthEventBusHandler {
|
||||
|
||||
private final com.google.common.eventbus.EventBus dataSetBus;
|
||||
|
||||
private final com.google.common.eventbus.EventBus subscriptionBus;
|
||||
|
||||
private final com.google.common.eventbus.EventBus retrievalBus;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public EdexBandwidthEventBusHandler() {
|
||||
this(new BandwidthAsyncEventBusFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param eventBusFactory
|
||||
* the factory to retrieve google event buses
|
||||
*/
|
||||
EdexBandwidthEventBusHandler(BandwidthEventBusFactory eventBusFactory) {
|
||||
super(eventBusFactory);
|
||||
this.dataSetBus = eventBusFactory.getDataSetBus();
|
||||
this.subscriptionBus = eventBusFactory.getSubscriptionBus();
|
||||
this.retrievalBus = eventBusFactory.getRetrievalBus();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void publishInternal(Object object) {
|
||||
|
||||
if (object instanceof SubscriptionRetrieval) {
|
||||
retrievalBus.post(object);
|
||||
} else if (object instanceof SubscriptionRetrievalFulfilled) {
|
||||
subscriptionBus.post(object);
|
||||
} else if (object instanceof DataSetMetaData) {
|
||||
dataSetBus.post(object);
|
||||
} else if (object instanceof Subscription) {
|
||||
subscriptionBus.post(object);
|
||||
} else if (object instanceof RemoveRegistryEvent) {
|
||||
subscriptionBus.post(object);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Object type ["
|
||||
+ object.getClass().getName()
|
||||
+ "] not supported in BandwidthEventBus");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
||||
|
||||
import com.raytheon.uf.common.event.IBaseEventBusHandler;
|
||||
|
||||
/**
|
||||
* Interface for the {@link BandwidthEventBus} handler functionality.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 11, 2012 djohnson Initial creation
|
||||
* May 28, 2013 1650 djohnson Reuse the general event bus handling.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
interface IBandwidthEventBusHandler extends IBaseEventBusHandler<Object> {
|
||||
}
|
|
@ -9,17 +9,10 @@
|
|||
value="jms-generic:topic:notify.msg?destinationResolver=#qpidDurableResolver" />
|
||||
<property name="notificationDao" ref="notificationDao" />
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="notificationHandler" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<constructor-arg ref="notificationHandler" />
|
||||
</bean>
|
||||
|
||||
<!-- verify text product info for site, spawns in separate thread to not
|
||||
delay start up -->
|
||||
|
|
|
@ -4,17 +4,10 @@
|
|||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
|
||||
<bean id="logHandler" class="com.raytheon.uf.edex.event.handler.LogHandler" />
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="logHandler" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<constructor-arg ref="logHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="eventPublishHandler" class="com.raytheon.uf.edex.event.handler.EventPublishHandler" />
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import com.google.common.eventbus.AsyncEventBus;
|
||||
|
@ -38,6 +40,7 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 11, 2012 1407 djohnson Moved in from EventBus.
|
||||
* May 28, 2013 1650 djohnson Add method to get all event buses.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -46,7 +49,6 @@ import com.raytheon.uf.common.status.UFStatus;
|
|||
*/
|
||||
class AsynchronousEventBusFactory implements GoogleEventBusFactory {
|
||||
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(AsynchronousEventBusFactory.class);
|
||||
|
||||
|
@ -60,7 +62,7 @@ class AsynchronousEventBusFactory implements GoogleEventBusFactory {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public EventBus getEventBus() {
|
||||
public List<EventBus> getEventBuses() {
|
||||
int threadCount = 15;
|
||||
try {
|
||||
threadCount = Integer.getInteger(EVENT_BUS_THREAD_COUNT_PROPERTY,
|
||||
|
@ -71,8 +73,8 @@ class AsynchronousEventBusFactory implements GoogleEventBusFactory {
|
|||
EVENT_BUS_THREAD_COUNT_PROPERTY, threadCount);
|
||||
statusHandler.error(logMessage, e);
|
||||
}
|
||||
return new AsyncEventBus(EVENT_BUS_NAME,
|
||||
Executors.newFixedThreadPool(threadCount));
|
||||
return Arrays.<EventBus> asList(new AsyncEventBus(EVENT_BUS_NAME,
|
||||
Executors.newFixedThreadPool(threadCount)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,249 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.event;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.raytheon.uf.common.event.IBaseEventBusHandler;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* EDEX implementation of {@link IBaseEventBusHandler}
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 28, 2013 1650 djohnson Simplified and extracted from {@link EdexEventBusHandler}.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class BaseEdexEventBusHandler<T> implements
|
||||
IBaseEventBusHandler<T>, TransactionSynchronization {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(BaseEdexEventBusHandler.class);
|
||||
|
||||
private final ThreadLocal<List<T>> eventStorageList = new ThreadLocal<List<T>>() {
|
||||
|
||||
@Override
|
||||
protected List<T> initialValue() {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private static final String NULL_SUBSCRIBER = "Ignoring a null subscriber.";
|
||||
|
||||
// Set that keeps a reference to all objects which have registered, which
|
||||
// simplifies whether or not an object should be unregistered since google
|
||||
// eventbus doesn't have a way of knowing who did or did not register
|
||||
private final Set<Object> registeredObjects = Collections
|
||||
.synchronizedSet(Collections
|
||||
.<Object> newSetFromMap(new IdentityHashMap<Object, Boolean>()));
|
||||
|
||||
/**
|
||||
* The actual Google EventBus instances being wrapped.
|
||||
*/
|
||||
protected final List<com.google.common.eventbus.EventBus> googleEventBuses;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public BaseEdexEventBusHandler() {
|
||||
this(new AsynchronousEventBusFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor specifying how to create the EventBus instances.
|
||||
*
|
||||
* @param eventBusFactory
|
||||
* the factory
|
||||
*/
|
||||
protected BaseEdexEventBusHandler(GoogleEventBusFactory eventBusFactory) {
|
||||
this.googleEventBuses = eventBusFactory.getEventBuses();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void publish(T event) {
|
||||
if (event == null) {
|
||||
throw new IllegalArgumentException("Cannot publish a null event");
|
||||
}
|
||||
|
||||
if (isTransactionActive()) {
|
||||
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
if (!TransactionSynchronizationManager.getSynchronizations()
|
||||
.contains(this)) {
|
||||
TransactionSynchronizationManager
|
||||
.registerSynchronization(this);
|
||||
}
|
||||
}
|
||||
eventStorageList.get().add(event);
|
||||
} else {
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler
|
||||
.debug("Sending event from non-transactional operation");
|
||||
}
|
||||
publishInternal(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish the actual event object.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
protected abstract void publishInternal(T event);
|
||||
|
||||
/**
|
||||
* Check to see if a transaction is active.
|
||||
*
|
||||
* @return true if a transaction is active
|
||||
*/
|
||||
protected boolean isTransactionActive() {
|
||||
return TransactionSynchronizationManager.isActualTransactionActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Object register(Object subscriber) {
|
||||
if (subscriber != null) {
|
||||
final boolean registered = registeredObjects.add(subscriber);
|
||||
if (registered) {
|
||||
for (EventBus eventBus : googleEventBuses) {
|
||||
eventBus.register(subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
final String logMsg = (registered) ? "Registered subscriber of type ["
|
||||
+ subscriber.getClass().getName()
|
||||
+ "] with the event bus."
|
||||
: "Ignoring request to register subscriber of type ["
|
||||
+ subscriber.getClass().getName()
|
||||
+ "] from the event bus, as it was already registered!";
|
||||
|
||||
statusHandler.handle(Priority.DEBUG, logMsg);
|
||||
}
|
||||
} else {
|
||||
statusHandler.handle(Priority.WARN, NULL_SUBSCRIBER,
|
||||
new IllegalArgumentException(NULL_SUBSCRIBER));
|
||||
}
|
||||
|
||||
return subscriber;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void unregister(Object subscriber) {
|
||||
if (subscriber != null) {
|
||||
final boolean removed = registeredObjects.remove(subscriber);
|
||||
if (removed) {
|
||||
for (EventBus eventBus : googleEventBuses) {
|
||||
eventBus.unregister(subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
final String logMsg = (removed) ? "Unregistered subscriber of type ["
|
||||
+ subscriber.getClass().getName()
|
||||
+ "] from the event bus."
|
||||
: "Ignoring request to unregister subscriber of type ["
|
||||
+ subscriber.getClass().getName()
|
||||
+ "] from the event bus, as it was never registered!";
|
||||
|
||||
statusHandler.handle(Priority.DEBUG, logMsg);
|
||||
}
|
||||
} else {
|
||||
statusHandler.handle(Priority.WARN, NULL_SUBSCRIBER,
|
||||
new IllegalArgumentException(NULL_SUBSCRIBER));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suspend() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCommit(boolean readOnly) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCompletion() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCommit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(int status) {
|
||||
List<T> list = eventStorageList.get();
|
||||
if (status == TransactionSynchronization.STATUS_COMMITTED) {
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler.debug("Posting " + list.size()
|
||||
+ " objects on the event bus");
|
||||
}
|
||||
for (T event : list) {
|
||||
for (EventBus eventBus : googleEventBuses) {
|
||||
eventBus.post(event);
|
||||
}
|
||||
}
|
||||
} else if (status == TransactionSynchronization.STATUS_ROLLED_BACK) {
|
||||
statusHandler.info("Transaction rolled back. Discarding "
|
||||
+ list.size() + " events.");
|
||||
}
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
}
|
|
@ -19,18 +19,10 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.raytheon.uf.common.event.Event;
|
||||
import com.raytheon.uf.common.event.IEventBusHandler;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
|
||||
/**
|
||||
* EDEX implementation of {@link IEventBusHandler}
|
||||
|
@ -44,6 +36,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* Feb 5, 2013 1580 mpduff Initial creation.
|
||||
* 3/18/2013 1802 bphillip Modified to use transaction synchronization
|
||||
* May 9, 2013 1989 njensen Spring 3.1.4 compatibility
|
||||
* May 28, 2013 1650 djohnson Simplify and extract out the general event bus handling for reuse.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -51,127 +44,36 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
|
|||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EdexEventBusHandler implements IEventBusHandler,
|
||||
TransactionSynchronization {
|
||||
|
||||
private static final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(EdexEventBusHandler.class);
|
||||
|
||||
private static ThreadLocal<List<Event>> eventStorageList = new ThreadLocal<List<Event>>() {
|
||||
|
||||
@Override
|
||||
protected List<Event> initialValue() {
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@VisibleForTesting
|
||||
EdexEventBusHandler(GoogleEventBusFactory eventBusFactory) {
|
||||
this.googleEventBus = eventBusFactory.getEventBus();
|
||||
}
|
||||
public class EdexEventBusHandler extends BaseEdexEventBusHandler<Event>
|
||||
implements IEventBusHandler {
|
||||
|
||||
/**
|
||||
* The actual Google EventBus being wrapped.
|
||||
*/
|
||||
private final com.google.common.eventbus.EventBus googleEventBus;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Constructor specifying the event bus factory.
|
||||
*
|
||||
* @param eventBusFactory
|
||||
*/
|
||||
public EdexEventBusHandler() {
|
||||
this(new AsynchronousEventBusFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void publish(Event event) {
|
||||
if (isTransactionActive()) {
|
||||
|
||||
if (TransactionSynchronizationManager.isSynchronizationActive()) {
|
||||
if (!TransactionSynchronizationManager.getSynchronizations()
|
||||
.contains(this)) {
|
||||
TransactionSynchronizationManager
|
||||
.registerSynchronization(this);
|
||||
}
|
||||
}
|
||||
eventStorageList.get().add(event);
|
||||
} else {
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler
|
||||
.debug("Sending event from non-transactional operation");
|
||||
}
|
||||
this.googleEventBus.post(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if a transaction is active.
|
||||
* Constructor specifying the event bus factory.
|
||||
*
|
||||
* @return true if a transaction is active
|
||||
* @param eventBusFactory
|
||||
*/
|
||||
protected boolean isTransactionActive() {
|
||||
return TransactionSynchronizationManager.isActualTransactionActive();
|
||||
@VisibleForTesting
|
||||
EdexEventBusHandler(GoogleEventBusFactory eventBusFactory) {
|
||||
super(eventBusFactory);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void register(Object subscriber) {
|
||||
this.googleEventBus.register(subscriber);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void unregister(Object subscriber) {
|
||||
this.googleEventBus.unregister(subscriber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suspend() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCommit(boolean readOnly) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCompletion() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCommit() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(int status) {
|
||||
List<Event> list = eventStorageList.get();
|
||||
if (status == TransactionSynchronization.STATUS_COMMITTED) {
|
||||
if (statusHandler.isPriorityEnabled(Priority.DEBUG)) {
|
||||
statusHandler.debug("Posting " + list.size()
|
||||
+ " events on the event bus");
|
||||
}
|
||||
for (Event event : list) {
|
||||
this.googleEventBus.post(event);
|
||||
}
|
||||
} else if (status == TransactionSynchronization.STATUS_ROLLED_BACK) {
|
||||
statusHandler.info("Transaction rolled back. Discarding "
|
||||
+ list.size() + " events.");
|
||||
protected void publishInternal(Event event) {
|
||||
for (EventBus eventBus : googleEventBuses) {
|
||||
eventBus.post(event);
|
||||
}
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,12 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* Interface that defines how to get an {@link EventBus} for system use.
|
||||
* Intentionally package-private as it should only be used within this package,
|
||||
* and not part of the public API.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -33,19 +33,21 @@ import com.google.common.eventbus.EventBus;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Dec 11, 2012 1407 djohnson Initial creation
|
||||
*
|
||||
* May 28, 2013 1650 djohnson Change to get a list of event bus instances.
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
interface GoogleEventBusFactory {
|
||||
public interface GoogleEventBusFactory {
|
||||
|
||||
/**
|
||||
* Get the Google {@link EventBus} that will be wrapped with an AWIPS class.
|
||||
* Get the Google {@link EventBus} instances that will be wrapped with an
|
||||
* AWIPS class.
|
||||
*
|
||||
* @return the {@link EventBus} instances
|
||||
*
|
||||
* @return the {@link EventBus}
|
||||
*/
|
||||
EventBus getEventBus();
|
||||
List<EventBus> getEventBuses();
|
||||
|
||||
}
|
||||
|
|
|
@ -28,14 +28,8 @@
|
|||
<property name="notificationListenerFactory" ref="notificationListenerFactory" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="RegistrySubscriptionManager" />
|
||||
</list>
|
||||
</property>
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<constructor-arg ref="RegistrySubscriptionManager" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
|
@ -11,6 +11,7 @@
|
|||
http://cxf.apache.org/schemas/jaxrs.xsd">
|
||||
|
||||
<import resource="file:///${edex.home}/conf/spring/edex-db.xml" />
|
||||
<import resource="classpath:res/spring/eventbus-common.xml" />
|
||||
<import resource="classpath:res/spring/ebxml.xml" />
|
||||
<import resource="classpath:res/spring/ebxml-webservices.xml" />
|
||||
<import resource="classpath:res/spring/ebxml-validator-plugins.xml" />
|
||||
|
|
|
@ -18,19 +18,10 @@
|
|||
<bean id="statsHandler" class="com.raytheon.uf.edex.stats.handler.StatsHandler">
|
||||
<property name="statsDao" ref="statsDao" />
|
||||
</bean>
|
||||
|
||||
<bean
|
||||
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
|
||||
<property name="staticMethod"
|
||||
value="com.raytheon.uf.common.event.EventBus.register" />
|
||||
<property name="arguments">
|
||||
<list>
|
||||
<ref bean="statsHandler" />
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
<bean factory-bean="eventBus" factory-method="register">
|
||||
<constructor-arg ref="statsHandler" />
|
||||
</bean>
|
||||
|
||||
<bean id="statsDao" class="com.raytheon.uf.edex.stats.dao.StatsDao">
|
||||
<property name="sessionFactory" ref="metadataSessionFactory" />
|
||||
|
|
|
@ -113,8 +113,10 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
|
|||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.EVENTBUS_COMMON_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_EVENTBUS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML,
|
||||
|
|
|
@ -79,6 +79,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
* Feb 20, 2013 1543 djohnson Use WFO bandwidth manager.
|
||||
* 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.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -87,6 +88,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
|
|||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.EVENTBUS_COMMON_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
|
||||
|
@ -293,10 +295,30 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
|
|||
.asList(subscription, subscription2));
|
||||
assertEquals(
|
||||
"Expected the required latency to not be set when the propose schedule fits",
|
||||
IProposeScheduleResponse.REQUIRED_LATENCY_NOT_SET,
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
response.getRequiredLatency());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleTwoSubscriptionsThatFitReturnsNotSetRequiredDataSetSize() {
|
||||
|
||||
// Two subscriptions, the sum of which will fill up a bucket exactly
|
||||
Subscription subscription = createSubscriptionThatFillsHalfABucket();
|
||||
Subscription subscription2 = createSubscriptionThatFillsHalfABucket();
|
||||
|
||||
subscription.getTime().setCycleTimes(
|
||||
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
|
||||
subscription2.getTime().setCycleTimes(
|
||||
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
|
||||
|
||||
IProposeScheduleResponse response = service.proposeSchedule(Arrays
|
||||
.asList(subscription, subscription2));
|
||||
assertEquals(
|
||||
"Expected the required latency to not be set when the propose schedule fits",
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
response.getRequiredDataSetSize());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleTwoSubscriptionsSecondDoesNotFitReturnsSecondsName() {
|
||||
|
||||
|
@ -363,6 +385,55 @@ public class BandwidthServiceIntTest extends AbstractBandwidthManagerIntTest {
|
|||
6, requiredLatency);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProposeScheduleSubscriptionsSecondDoesntFitReturnsRequiredSize() {
|
||||
|
||||
Subscription subscription = createSubscriptionThatFillsHalfABucket();
|
||||
Subscription subscription2 = createSubscriptionThatFillsUpTenBuckets();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
subscription.getTime().setCycleTimes(
|
||||
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
|
||||
subscription2.getTime().setCycleTimes(
|
||||
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
// The maximum dataset size that could fit in the bucket is another
|
||||
// subscription the same size as the first
|
||||
final long expectedRequiredDataSetSize = subscription.getDataSetSize();
|
||||
final long requiredDataSetSize = service.proposeSchedule(subscription2)
|
||||
.getRequiredDataSetSize();
|
||||
assertEquals(
|
||||
"The required dataset size should have been returned from propose schedule!",
|
||||
expectedRequiredDataSetSize, requiredDataSetSize);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetermineRequiredSizeReturnsZeroIfUnableToFitAtAll() {
|
||||
|
||||
Subscription subscription = createSubscriptionThatFillsUpABucket();
|
||||
Subscription subscription2 = createSubscriptionThatFillsUpABucket();
|
||||
|
||||
// subscription2 will not be able to schedule for cycle hour 8
|
||||
subscription.getTime().setCycleTimes(
|
||||
Arrays.asList(Integer.valueOf(6), Integer.valueOf(8)));
|
||||
subscription2.getTime().setCycleTimes(
|
||||
Arrays.asList(Integer.valueOf(3), Integer.valueOf(8)));
|
||||
|
||||
Set<String> unscheduledSubscriptions = service.schedule(subscription);
|
||||
verifyNoSubscriptionsWereUnscheduled(unscheduledSubscriptions);
|
||||
|
||||
// The maximum dataset size that could fit in the bucket is another
|
||||
// subscription the same size as the first
|
||||
final long expectedRequiredDataSetSize = 0;
|
||||
final long requiredDataSetSize = service.proposeSchedule(subscription2)
|
||||
.getRequiredDataSetSize();
|
||||
assertEquals("The required dataset size should have returned 0!",
|
||||
expectedRequiredDataSetSize, requiredDataSetSize);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReinitializeStartsNewBandwidthManager() {
|
||||
BandwidthManager originalBandwidthManager = BandwidthServiceIntTest.this.bandwidthManager;
|
||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.edex.datadelivery.bandwidth;
|
|||
|
||||
import com.raytheon.uf.common.util.JarUtil;
|
||||
import com.raytheon.uf.common.util.SpringFiles;
|
||||
import com.raytheon.uf.common.util.TestUtil;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.WfoBandwidthManagerCreator.WfoBandwidthManager;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
|
||||
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDbInit;
|
||||
|
@ -52,9 +51,10 @@ public class IntegrationTestWfoBandwidthManager extends WfoBandwidthManager {
|
|||
|
||||
static final String[] INTEGRATION_TEST_SPRING_FILES = new String[] {
|
||||
"/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml",
|
||||
JarUtil.getResResourcePath("/spring/bandwidth-datadelivery-daos.xml"),
|
||||
TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_XML),
|
||||
TestUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML) };
|
||||
JarUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML),
|
||||
JarUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_XML),
|
||||
JarUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_EVENTBUS_XML),
|
||||
JarUtil.getResResourcePath(SpringFiles.BANDWIDTH_DATADELIVERY_WFO_XML) };
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
|
@ -60,6 +60,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
|
|||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.EVENTBUS_COMMON_XML,
|
||||
SpringFiles.RETRIEVAL_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_DAOS_XML,
|
||||
SpringFiles.BANDWIDTH_DATADELIVERY_XML,
|
||||
|
|
|
@ -78,6 +78,7 @@ import com.raytheon.uf.edex.database.dao.DatabaseUtil;
|
|||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.EVENTBUS_COMMON_XML,
|
||||
SpringFiles.EBXML_XML, SpringFiles.EBXML_IMPL_XML,
|
||||
SpringFiles.EBXML_QUERYTYPES_XML, SpringFiles.EBXML_REGISTRY_DAO_XML,
|
||||
SpringFiles.EBXML_WEBSERVICES_XML, SpringFiles.EBXML_XACML_XML,
|
||||
|
|
|
@ -74,6 +74,7 @@ import com.raytheon.uf.edex.registry.ebxml.util.EbxmlObjectUtil;
|
|||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { DatabaseUtil.UNIT_TEST_DB_BEANS_XML,
|
||||
SpringFiles.EVENTBUS_COMMON_XML,
|
||||
SpringFiles.EBXML_XML, SpringFiles.EBXML_XACML_XML,
|
||||
SpringFiles.EBXML_SUBSCRIPTION_XML,
|
||||
SpringFiles.EBXML_WEBSERVICES_XML,
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthSyncEventBusFactory
|
|
@ -0,0 +1 @@
|
|||
com.raytheon.uf.edex.datadelivery.bandwidth.notification.TestBandwidthEventBusHandler
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.common.datadelivery.registry.handlers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -40,6 +41,7 @@ import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
|||
* Oct 17, 2012 0726 djohnson Initial creation
|
||||
* Feb 20, 2013 1543 djohnson Implement route filtering.
|
||||
* May 15, 2013 1040 mpduff Office Id now a set.
|
||||
* May 28, 2013 1650 djohnson Add getByNames.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,8 +54,6 @@ public class BaseMemorySubscriptionHandler<T extends Subscription> extends
|
|||
IBaseSubscriptionHandler<T> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* @throws RegistryHandlerException
|
||||
*/
|
||||
@Override
|
||||
public T getByName(String name) throws RegistryHandlerException {
|
||||
|
@ -66,6 +66,22 @@ public class BaseMemorySubscriptionHandler<T extends Subscription> extends
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<T> getByNames(Collection<String> names)
|
||||
throws RegistryHandlerException {
|
||||
List<T> retVal = new ArrayList<T>();
|
||||
for (T obj : getAll()) {
|
||||
if (names.contains(obj.getName())) {
|
||||
retVal.add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
|
121
tests/unit/com/raytheon/uf/common/event/BaseEventBusTest.java
Normal file
121
tests/unit/com/raytheon/uf/common/event/BaseEventBusTest.java
Normal file
|
@ -0,0 +1,121 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.event;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
||||
/**
|
||||
* Base test for {@link EventBus} implementations.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 28, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@Ignore
|
||||
public abstract class BaseEventBusTest<EVENT_TYPE, EVENT_BUS extends IBaseEventBusHandler<EVENT_TYPE>> {
|
||||
|
||||
private final EVENT_BUS eventBus = getEventBus();
|
||||
|
||||
private int eventsReceived;
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
eventBus.unregister(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subscriberReceivesEventWhileRegistered() {
|
||||
eventBus.register(this);
|
||||
|
||||
eventBus.publish(getEvent());
|
||||
|
||||
assertThat(eventsReceived, is(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subscriberDoesNotReceiveEventWhileNotRegistered() {
|
||||
eventBus.publish(getEvent());
|
||||
|
||||
assertThat(eventsReceived, is(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subscriberRegisteredMultipleTimesStillReceivesOneEvent() {
|
||||
eventBus.register(this);
|
||||
eventBus.register(this);
|
||||
eventBus.register(this);
|
||||
|
||||
eventBus.publish(getEvent());
|
||||
|
||||
assertThat(eventsReceived, is(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subscriberRegisteredMultipleTimesOnlyHasToUnregisterOnce() {
|
||||
eventBus.register(this);
|
||||
eventBus.register(this);
|
||||
eventBus.register(this);
|
||||
|
||||
eventBus.unregister(this);
|
||||
eventBus.publish(getEvent());
|
||||
|
||||
assertThat(eventsReceived, is(0));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void publishNullEventThrowsException() {
|
||||
eventBus.publish(null);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void receivedEvent(EVENT_TYPE event) {
|
||||
eventsReceived++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the event bus under test.
|
||||
*
|
||||
* @return the event bus
|
||||
*/
|
||||
protected abstract EVENT_BUS getEventBus();
|
||||
|
||||
/**
|
||||
* Get an event that can be used with the event bus.
|
||||
*
|
||||
* @return the event
|
||||
*/
|
||||
protected abstract EVENT_TYPE getEvent();
|
||||
}
|
60
tests/unit/com/raytheon/uf/common/event/EventBusTest.java
Normal file
60
tests/unit/com/raytheon/uf/common/event/EventBusTest.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.common.event;
|
||||
|
||||
import com.raytheon.uf.common.stats.ProcessEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Test {@link EventBus}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 28, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class EventBusTest extends BaseEventBusTest<Event, IEventBusHandler> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected IEventBusHandler getEventBus() {
|
||||
return new EventBusBean();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Event getEvent() {
|
||||
return new ProcessEvent();
|
||||
}
|
||||
|
||||
}
|
|
@ -33,6 +33,7 @@ import org.junit.Ignore;
|
|||
* Feb 12, 2013 1543 djohnson Initial creation
|
||||
* Apr 23, 2013 1910 djohnson Add constants for ebxml spring files.
|
||||
* May 02, 2013 1910 djohnson Add validator plugins spring file.
|
||||
* May 28, 2013 1650 djohnson Add event bus spring files.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -52,6 +53,8 @@ public class SpringFiles {
|
|||
|
||||
public static final String BANDWIDTH_DATADELIVERY_DAOS_XML = "/spring/bandwidth-datadelivery-daos.xml";
|
||||
|
||||
public static final String BANDWIDTH_DATADELIVERY_EVENTBUS_XML = "/spring/bandwidth-datadelivery-eventbus.xml";
|
||||
|
||||
public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-impl.xml";
|
||||
|
||||
public static final String BANDWIDTH_DATADELIVERY_INTEGRATION_TEST_NCF_XML = "/bandwidth/bandwidth-datadelivery-integrationtest-ncf-impl.xml";
|
||||
|
@ -82,6 +85,8 @@ public class SpringFiles {
|
|||
|
||||
public static final String EBXML_VALIDATOR_PLUGINS_XML = "/spring/ebxml-validator-plugins.xml";
|
||||
|
||||
public static final String EVENTBUS_COMMON_XML = "/spring/eventbus-common.xml";
|
||||
|
||||
public static final String UNIT_TEST_LOCALIZATION_BEANS_XML = "/unit-test-localization-beans.xml";
|
||||
|
||||
public static final String UNIT_TEST_EBXML_BEANS_XML = "/ebxml/unit-test-ebxml-beans.xml";
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
||||
|
||||
import com.raytheon.uf.common.datadelivery.registry.OpenDapGriddedDataSetMetaData;
|
||||
import com.raytheon.uf.common.event.BaseEventBusTest;
|
||||
|
||||
/**
|
||||
* Test {@link BandwidthEventBus}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 28, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class BandwidthEventBusTest extends
|
||||
BaseEventBusTest<Object, IBandwidthEventBusHandler> {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected IBandwidthEventBusHandler getEventBus() {
|
||||
return new BandwidthEventBusBean();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected Object getEvent() {
|
||||
return new OpenDapGriddedDataSetMetaData();
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,9 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
|
@ -31,6 +34,7 @@ import com.google.common.eventbus.EventBus;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 06, 2013 1543 djohnson Initial creation
|
||||
* May 28, 2013 1650 djohnson Add getEventBuses.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -40,12 +44,18 @@ import com.google.common.eventbus.EventBus;
|
|||
|
||||
public class BandwidthSyncEventBusFactory implements BandwidthEventBusFactory {
|
||||
|
||||
private final EventBus dataSetBus = new EventBus();
|
||||
|
||||
private final EventBus subscriptionBus = new EventBus();
|
||||
|
||||
private final EventBus retrievalBus = new EventBus();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public EventBus getSubscriptionBus() {
|
||||
return new EventBus();
|
||||
return subscriptionBus;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,7 +63,7 @@ public class BandwidthSyncEventBusFactory implements BandwidthEventBusFactory {
|
|||
*/
|
||||
@Override
|
||||
public EventBus getRetrievalBus() {
|
||||
return new EventBus();
|
||||
return retrievalBus;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +71,15 @@ public class BandwidthSyncEventBusFactory implements BandwidthEventBusFactory {
|
|||
*/
|
||||
@Override
|
||||
public EventBus getDataSetBus() {
|
||||
return new EventBus();
|
||||
return dataSetBus;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public List<EventBus> getEventBuses() {
|
||||
return Arrays.<EventBus> asList(dataSetBus, retrievalBus,
|
||||
subscriptionBus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
|
||||
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
* {@link IBandwidthEventBusHandler} used for test code.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 28, 2013 1650 djohnson Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author djohnson
|
||||
* @version 1.0
|
||||
*/
|
||||
@Ignore
|
||||
public class TestBandwidthEventBusHandler extends EdexBandwidthEventBusHandler {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public TestBandwidthEventBusHandler() {
|
||||
super(new BandwidthSyncEventBusFactory());
|
||||
}
|
||||
|
||||
}
|
|
@ -19,6 +19,11 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
|
||||
/**
|
||||
* Test event bus handler.
|
||||
*
|
||||
|
@ -29,6 +34,7 @@ package com.raytheon.uf.edex.event;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 5, 2013 1580 mpduff Initial creation
|
||||
* May 28, 2013 1650 djohnson Add getEventBuses.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -40,9 +46,10 @@ public class TestEventBusHandler extends EdexEventBusHandler {
|
|||
private static class SynchronousEventBusFactory implements
|
||||
GoogleEventBusFactory {
|
||||
@Override
|
||||
public com.google.common.eventbus.EventBus getEventBus() {
|
||||
return new com.google.common.eventbus.EventBus(
|
||||
AsynchronousEventBusFactory.EVENT_BUS_NAME);
|
||||
public List<EventBus> getEventBuses() {
|
||||
return Arrays
|
||||
.<EventBus> asList(new com.google.common.eventbus.EventBus(
|
||||
AsynchronousEventBusFactory.EVENT_BUS_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public abstract class AbstractSubscriptionServiceSingleSubscriptionTest extends
|
|||
subscriptionHandler.store(sub2);
|
||||
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
returnRequiredLatencyWhenProposeScheduleCalled();
|
||||
returnRequiredSubscriptionValuesWhenProposeScheduleCalled();
|
||||
whenForceApplyPromptedUserSelectsIncreaseLatency();
|
||||
|
||||
performServiceInteraction();
|
||||
|
|
|
@ -26,6 +26,7 @@ import static org.junit.Assert.fail;
|
|||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyListOf;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
@ -53,6 +54,7 @@ import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandle
|
|||
import com.raytheon.uf.common.datadelivery.service.ISubscriptionNotificationService;
|
||||
import com.raytheon.uf.common.datadelivery.service.subscription.ISubscriptionOverlapService;
|
||||
import com.raytheon.uf.common.datadelivery.service.subscription.ISubscriptionOverlapService.ISubscriptionOverlapResponse;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
|
||||
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
|
@ -87,6 +89,8 @@ public abstract class AbstractSubscriptionServiceTest {
|
|||
|
||||
protected static final int REQUIRED_LATENCY = 2;
|
||||
|
||||
protected static final long REQUIRED_DATASET_SIZE = 1024l;
|
||||
|
||||
final Subscription sub1 = SubscriptionFixture.INSTANCE.get(1);
|
||||
|
||||
final Subscription sub2 = SubscriptionFixture.INSTANCE.get(2);
|
||||
|
@ -125,6 +129,7 @@ public abstract class AbstractSubscriptionServiceTest {
|
|||
|
||||
@Before
|
||||
public void setUp() throws RegistryHandlerException {
|
||||
PathManagerFactoryTest.initLocalization();
|
||||
RegistryObjectHandlersUtil.initMemory();
|
||||
|
||||
when(
|
||||
|
@ -200,18 +205,16 @@ public abstract class AbstractSubscriptionServiceTest {
|
|||
public void testFailedProposeSchedulePromptsUserForForceApply()
|
||||
throws RegistryHandlerException {
|
||||
returnTwoSubscriptionNamesWhenProposeScheduleCalled();
|
||||
returnRequiredLatencyWhenProposeScheduleCalled();
|
||||
returnRequiredSubscriptionValuesWhenProposeScheduleCalled();
|
||||
|
||||
whenForceApplyPromptedUserSelectsCancel();
|
||||
|
||||
performServiceInteraction();
|
||||
|
||||
final String expected = getExpectedForceApplyMessage();
|
||||
final ForceApplyPromptConfiguration expectedForceApplyConfiguration = getExpectedForceApplyPromptConfiguration();
|
||||
|
||||
verify(mockDisplay).displayForceApplyPrompt(service.TITLE, expected,
|
||||
REQUIRED_LATENCY, mockPromptDisplayText,
|
||||
getExpectedDisplayForceApplyPromptSubscription(),
|
||||
subNameResults);
|
||||
verify(mockDisplay).displayForceApplyPrompt(
|
||||
eq(expectedForceApplyConfiguration));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -364,8 +367,7 @@ public abstract class AbstractSubscriptionServiceTest {
|
|||
verify(mockDisplay).displayMessage(
|
||||
mockPromptDisplayText,
|
||||
ISubscriptionOverlapService.OVERLAPPING_SUBSCRIPTIONS
|
||||
+ FileUtil.EOL
|
||||
+ duplicateSub.getName());
|
||||
+ FileUtil.EOL + duplicateSub.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -420,9 +422,11 @@ public abstract class AbstractSubscriptionServiceTest {
|
|||
* Returns the value of {@link #REQUIRED_LATENCY} as the required latency
|
||||
* when propose schedule is called.
|
||||
*/
|
||||
void returnRequiredLatencyWhenProposeScheduleCalled() {
|
||||
void returnRequiredSubscriptionValuesWhenProposeScheduleCalled() {
|
||||
when(mockProposeScheduleResponse.getRequiredLatency()).thenReturn(
|
||||
REQUIRED_LATENCY);
|
||||
when(mockProposeScheduleResponse.getRequiredDataSetSize()).thenReturn(
|
||||
REQUIRED_DATASET_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -513,4 +517,12 @@ public abstract class AbstractSubscriptionServiceTest {
|
|||
* @return the subscription argument
|
||||
*/
|
||||
abstract Subscription getExpectedDisplayForceApplyPromptSubscription();
|
||||
|
||||
/**
|
||||
* Return the expected force apply prompt configuration.
|
||||
*
|
||||
* @return the configuration
|
||||
*/
|
||||
abstract ForceApplyPromptConfiguration getExpectedForceApplyPromptConfiguration();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
|
||||
import com.raytheon.uf.common.auth.user.IUser;
|
||||
import com.raytheon.uf.common.datadelivery.bandwidth.IProposeScheduleResponse;
|
||||
import com.raytheon.uf.common.datadelivery.registry.InitialPendingSiteSubscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.Subscription;
|
||||
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
|
||||
|
@ -243,8 +244,7 @@ public class SubscriptionServiceMassUpdateTest extends
|
|||
*/
|
||||
@Override
|
||||
String getExpectedForceApplyMessage() {
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:\n"
|
||||
+ sub1Name + "\n" + sub2Name + "\n\nWhat would you like to do?";
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,4 +342,19 @@ public class SubscriptionServiceMassUpdateTest extends
|
|||
.getBySubscription(subscription)).thenReturn(
|
||||
new InitialPendingSiteSubscription());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
ForceApplyPromptConfiguration getExpectedForceApplyPromptConfiguration() {
|
||||
return new ForceApplyPromptConfiguration(service.TITLE,
|
||||
getExpectedForceApplyMessage(),
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
IProposeScheduleResponse.VALUE_NOT_SET,
|
||||
mockPromptDisplayText,
|
||||
getExpectedDisplayForceApplyPromptSubscription(),
|
||||
subNameResults);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,8 +118,7 @@ public class SubscriptionServiceStoreAdhocTest extends
|
|||
|
||||
@Override
|
||||
String getExpectedForceApplyMessage() {
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:\n"
|
||||
+ sub1Name + "\n" + sub2Name + "\n\nWhat would you like to do?";
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,4 +165,16 @@ public class SubscriptionServiceStoreAdhocTest extends
|
|||
return adhoc;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
ForceApplyPromptConfiguration getExpectedForceApplyPromptConfiguration() {
|
||||
return new ForceApplyPromptConfiguration(service.TITLE,
|
||||
getExpectedForceApplyMessage(), REQUIRED_LATENCY, 40,
|
||||
REQUIRED_DATASET_SIZE, mockPromptDisplayText,
|
||||
getExpectedDisplayForceApplyPromptSubscription(),
|
||||
subNameResults);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,8 +113,7 @@ public class SubscriptionServiceStoreTest extends
|
|||
|
||||
@Override
|
||||
String getExpectedForceApplyMessage() {
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:\n"
|
||||
+ sub1Name + "\n" + sub2Name + "\n\nWhat would you like to do?";
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,8 +128,7 @@ public class SubscriptionServiceStoreTest extends
|
|||
}
|
||||
|
||||
@Override
|
||||
void verifySubscriptionLatencyIsIncreasedToRequiredAmount()
|
||||
{
|
||||
void verifySubscriptionLatencyIsIncreasedToRequiredAmount() {
|
||||
assertEquals(
|
||||
"Expected the latency to have been set to the required amount!",
|
||||
REQUIRED_LATENCY, sub1.getLatencyInMinutes());
|
||||
|
@ -161,4 +159,16 @@ public class SubscriptionServiceStoreTest extends
|
|||
Subscription getExpectedDisplayForceApplyPromptSubscription() {
|
||||
return sub1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
ForceApplyPromptConfiguration getExpectedForceApplyPromptConfiguration() {
|
||||
return new ForceApplyPromptConfiguration(service.TITLE,
|
||||
getExpectedForceApplyMessage(), REQUIRED_LATENCY, 40,
|
||||
REQUIRED_DATASET_SIZE, mockPromptDisplayText,
|
||||
getExpectedDisplayForceApplyPromptSubscription(),
|
||||
subNameResults);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,8 +61,7 @@ public class SubscriptionServiceUpdateTest extends SubscriptionServiceStoreTest
|
|||
|
||||
@Override
|
||||
String getExpectedForceApplyMessage() {
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:\n"
|
||||
+ sub1Name + "\n" + sub2Name + "\n\nWhat would you like to do?";
|
||||
return "The following subscriptions would not fully schedule with the bandwidth management system if this action were performed:";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue