removing more GFE service backup and ISC server classes

This commit is contained in:
mjames-upc 2017-12-21 09:25:18 -07:00
parent d83fce1d01
commit bcdb4dda06
58 changed files with 1 additions and 12344 deletions

View file

@ -1,75 +0,0 @@
/**
* 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.viz.gfe;
import com.raytheon.viz.gfe.dialogs.sbu.ServiceBackupDlg;
import com.raytheon.viz.ui.personalities.awips.AbstractAWIPSComponent;
/**
* Bring up the Service Backup Dialog in stand alone mode as a blocking dialog.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 12, 2011 bphillip Initial creation
* Oct 26, 2012 1287 rferrel Change to force blocking of ServiceBackupDlg.
* Mar 21, 2013 1447 dgilling Fix dialog construction so this dialog
* is created as a top-level shell.
* Jun 11, 2014 DR-17401 lshi
* Mar 19, 2015 4300 randerso Changes to support updated ServiceBackupDlg
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public class ServiceBackupComponent extends AbstractAWIPSComponent {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent#startInternal
* (java.lang.String)
*/
@Override
protected void startInternal(String componentName) throws Exception {
ServiceBackupDlg svcBuDlg = new ServiceBackupDlg();
svcBuDlg.setBlockOnOpen(true);
svcBuDlg.open();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent#getRuntimeModes
* ()
*/
@Override
protected int getRuntimeModes() {
return ALERT_VIZ;
}
}

View file

@ -59,7 +59,7 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
public class CheckPermissions {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ServiceBackupDlg.class);
.getHandler(CheckPermissions.class);
/**
* A private constructor so that Java does not attempt to create one for us.

View file

@ -1,481 +0,0 @@
/**
* 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.viz.gfe.dialogs.sbu;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
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.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.progress.UIJob;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.viz.gfe.dialogs.sbu.jobs.AbstractSbuTask;
import com.raytheon.viz.gfe.dialogs.sbu.jobs.ServiceBackupTaskExecutor;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
/**
* Display Service Backup job status for a site
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 19, 2015 #4300 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class ServiceBackupStatusDlg extends CaveJFACEDialog {
private final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ServiceBackupStatusDlg.class);
private static enum StatusIcons {
NOT_STARTED("", "Not started", SWT.COLOR_WIDGET_FOREGROUND), //
IN_PROGRESS("", "In progress", SWT.COLOR_WIDGET_FOREGROUND), //
SUCCESS("", "Successful", SWT.COLOR_GREEN), //
FAILED("", "Failed", SWT.COLOR_RED); //
private String symbol;
private String toolTip;
private int color;
private int cycle = 0;
private StatusIcons(String symbol, String toolTip, int color) {
this.symbol = symbol;
this.toolTip = toolTip;
this.color = color;
}
public char getSymbol() {
cycle = (cycle + 1) % this.symbol.length();
return this.symbol.charAt(cycle);
}
public String getToolTip() {
return this.toolTip;
}
public int getColor() {
return this.color;
}
}
private String site;
private List<AbstractSbuTask> tasks;
private ServiceBackupTaskExecutor executor;
private Font bigFont;
private Map<String, Label[]> controls;
private Group statusGroup;
private UIJob updateJob;
/**
* @param parentShell
*/
public ServiceBackupStatusDlg(Shell parentShell, String site) {
super(parentShell);
this.site = site;
this.setShellStyle(SWT.DIALOG_TRIM | SWT.MODELESS | SWT.MIN);
updateJob = new UIJob("SvcbuUpdateJob") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
if (!getShell().isDisposed()) {
doRefresh();
if (executor.isAlive()) {
this.schedule(1000);
} else {
getButton(IDialogConstants.CANCEL_ID).setEnabled(false);
}
return Status.OK_STATUS;
} else {
return Status.CANCEL_STATUS;
}
}
};
updateJob.setSystem(true);
}
/**
* @param tasks
*/
public void setTasks(List<AbstractSbuTask> tasks) {
if ((this.executor != null) && this.executor.isAlive()) {
statusHandler.error("Service Backup job already in progress");
return;
}
this.tasks = tasks;
this.executor = new ServiceBackupTaskExecutor(tasks);
if (this.isOpen()) {
for (Control control : statusGroup.getChildren()) {
control.dispose();
}
createStatusControls();
statusGroup.pack();
statusGroup.layout();
Shell shell = getShell();
shell.pack();
shell.layout();
startJob();
}
}
/**
* @return the site
*/
public String getSite() {
return site;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets
* .Shell)
*/
@Override
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(this.site + " Service Backup Status");
newShell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (bigFont != null) {
bigFont.dispose();
}
if (executor != null) {
executor.cancel();
}
}
});
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.dialogs.Dialog#getInitialLocation(org.eclipse.swt.graphics
* .Point)
*/
@Override
protected Point getInitialLocation(Point initialSize) {
Rectangle bounds = getParentShell().getBounds();
int x = bounds.x + bounds.width;
int y = bounds.y;
Rectangle myBounds = new Rectangle(x, y, initialSize.x, initialSize.y);
for (Shell child : getParentShell().getShells()) {
if (!child.equals(getShell()) && !child.isDisposed()) {
Rectangle childBounds = child.getBounds();
if (myBounds.contains(childBounds.x, childBounds.y)) {
Rectangle clientArea = child.getClientArea();
int delta = childBounds.height - clientArea.height;
y += delta;
}
}
}
Point location = new Point(x, y);
return location;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveJFACEDialog#createDialogArea(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
final Composite comp = (Composite) super.createDialogArea(parent);
final Button bigFontButton = new Button(comp, SWT.CHECK);
GridData layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
bigFontButton.setLayoutData(layoutData);
bigFontButton.setText("Use large font");
bigFontButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (bigFontButton.getSelection()) {
FontData fontData = comp.getFont().getFontData()[0];
fontData.setHeight(18);
fontData.setStyle(SWT.BOLD);
bigFont = new Font(comp.getDisplay(), fontData);
setFont(bigFont);
} else {
Font font = comp.getFont();
setFont(font);
if (bigFont != null) {
bigFont.dispose();
bigFont = null;
}
}
}
});
controls = new HashMap<>();
statusGroup = new Group(comp, SWT.SHADOW_NONE);
statusGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
statusGroup.setLayout(new GridLayout(3, false));
statusGroup.setText("Job Status");
createStatusControls();
comp.pack();
comp.layout();
return comp;
}
/**
*
*/
private void createStatusControls() {
controls.clear();
for (AbstractSbuTask task : tasks) {
String status = task.getStatusFileName();
String text = task.getGuiDescription();
Label statusIcon = new Label(statusGroup, SWT.HORIZONTAL
| SWT.CENTER);
statusIcon.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true,
false));
StatusIcons icon = StatusIcons.NOT_STARTED;
statusIcon.setForeground(statusIcon.getDisplay().getSystemColor(
icon.getColor()));
statusIcon.setText(Character.toString(icon.getSymbol()));
statusIcon.setToolTipText(icon.getToolTip());
Label time = new Label(statusGroup, SWT.HORIZONTAL);
time.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
time.setText("00:00:00 ");
Label label = new Label(statusGroup, SWT.HORIZONTAL);
label.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
label.setText(String.format(text, site));
if (bigFont != null) {
statusIcon.setFont(bigFont);
time.setFont(bigFont);
label.setFont(bigFont);
}
controls.put(status, new Label[] { statusIcon, time, label });
}
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse
* .swt.widgets.Composite)
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.CANCEL_ID,
IDialogConstants.CANCEL_LABEL, false).setEnabled(false);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
*/
@Override
protected void cancelPressed() {
cancelJob();
getButton(IDialogConstants.CANCEL_ID).setEnabled(false);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveJFACEDialog#open()
*/
@Override
public int open() {
int status = super.open();
startJob();
return status;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#close()
*/
@Override
public boolean close() {
if (executor.isAlive()) {
MessageDialog
.openWarning(getShell(), this.site
+ " Service Backup Status",
"You cannot close this dialog while tasks are in progress!");
return false;
}
cancelJob();
return super.close();
}
private void startJob() {
this.executor.start();
updateJob.schedule(1000);
getButton(IDialogConstants.CANCEL_ID).setEnabled(true);
}
private void cancelJob() {
this.executor.cancel();
}
private void setFont(Font font) {
for (Label[] labels : controls.values()) {
for (Label label : labels) {
label.setFont(font);
}
}
getShell().pack(true);
}
private void updateStatus(final AbstractSbuTask task) {
String key = task.getStatusFileName();
JobProgress jobProgress = task.getStatus();
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
Date statusTime = task.getStatusTime();
Label[] labels = controls.get(key);
if (labels != null) {
Label statusIcon = labels[0];
Label timeLabel = labels[1];
StatusIcons icon;
switch (jobProgress) {
case IN_PROGRESS:
icon = StatusIcons.IN_PROGRESS;
statusTime = new Date(System.currentTimeMillis()
- statusTime.getTime());
break;
case SUCCESS:
icon = StatusIcons.SUCCESS;
break;
case FAILED:
icon = StatusIcons.FAILED;
break;
case UNKNOWN:
icon = StatusIcons.NOT_STARTED;
break;
default:
statusHandler.error("Unknown JobProgress value received: "
+ jobProgress.name());
icon = StatusIcons.IN_PROGRESS;
}
if (!statusIcon.isDisposed()) {
statusIcon.setForeground(statusIcon.getDisplay()
.getSystemColor(icon.getColor()));
statusIcon.setText(Character.toString(icon.getSymbol()));
statusIcon.setToolTipText(icon.getToolTip());
}
if (!timeLabel.isDisposed()) {
timeLabel.setText(sdf.format(statusTime));
}
}
}
private void doRefresh() {
for (AbstractSbuTask task : tasks) {
updateStatus(task);
}
}
public void reset() {
StatusIcons icon = StatusIcons.NOT_STARTED;
for (Label[] labels : controls.values()) {
Label statusIcon = labels[0];
Label timeLabel = labels[1];
if (!statusIcon.isDisposed()) {
statusIcon.setForeground(statusIcon.getDisplay()
.getSystemColor(icon.getColor()));
statusIcon.setText(Character.toString(icon.getSymbol()));
statusIcon.setToolTipText(icon.getToolTip());
}
if (!timeLabel.isDisposed()) {
timeLabel.setText("00:00:00");
}
}
}
}

View file

@ -1,129 +0,0 @@
/**
* 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.viz.gfe.dialogs.sbu.jobs;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Abstract base class for Service Backup tasks
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 9, 2015 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public abstract class AbstractSbuTask {
protected final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AbstractSbuTask.class);
private String statusFileName;
private String guiDescription;
private JobProgress status;
private Date statusTime;
private Set<ITaskCompleteCallBack> callBacks;
public AbstractSbuTask(String statusFileName, String guiDescription) {
this.statusFileName = statusFileName;
this.guiDescription = guiDescription;
this.callBacks = new HashSet<>();
setStatus(JobProgress.UNKNOWN);
}
/**
* @return the statusFileName
*/
public String getStatusFileName() {
return statusFileName;
}
/**
* @return the guiDescription
*/
public String getGuiDescription() {
return guiDescription;
}
/**
* @return the status
*/
public JobProgress getStatus() {
return status;
}
private void setStatus(JobProgress status) {
this.status = status;
if (status.equals(JobProgress.UNKNOWN)) {
this.statusTime = new Date(0);
} else {
this.statusTime = new Date();
}
for (ITaskCompleteCallBack callBack : callBacks) {
callBack.taskComplete(this);
}
}
public Date getStatusTime() {
return this.statusTime;
}
public void addCallBack(ITaskCompleteCallBack callBack) {
this.callBacks.add(callBack);
}
public void removeCallBack(ITaskCompleteCallBack callBack) {
this.callBacks.remove(callBack);
}
public final void run() {
setStatus(JobProgress.IN_PROGRESS);
try {
setStatus(runTask());
} catch (VizException e) {
statusHandler.error(e.getLocalizedMessage(), e);
setStatus(JobProgress.FAILED);
}
}
protected abstract JobProgress runTask() throws VizException;
}

View file

@ -1,190 +0,0 @@
/**
* 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.viz.gfe.dialogs.sbu.jobs;
import java.util.List;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.GfeNotification;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.ServiceBackupJobStatusNotification;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.jms.notification.INotificationObserver;
import com.raytheon.uf.common.jms.notification.NotificationException;
import com.raytheon.uf.common.jms.notification.NotificationMessage;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.util.TimeUtil;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob;
/**
* Service Backup Task to wait for a particular
* ServiceBackupJobStatusNotification
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 18, 2015 #4300 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class AwaitNotificationSbuTask extends AbstractSbuTask implements
INotificationObserver {
private static final String NOTIFICATION_TOPIC = "edex.alerts.gfe";
private String siteID;
private String name;
private long timeout;
private Shell parent;
private volatile JobProgress status;
private long startTime;
/**
* @param siteID
* site ID to wait for
* @param taskName
* taskName to wait for
* @param timeout
* in milliseconds
* @param statusFileName
* @param guiDescription
*/
public AwaitNotificationSbuTask(String siteID, String taskName,
long timeout, Shell parent, String statusFileName,
String guiDescription) {
super(statusFileName, guiDescription);
this.siteID = siteID;
this.name = taskName;
this.timeout = timeout;
this.parent = parent;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.gfe.dialogs.sbu.jobs.AbstractSbuTask#runTask()
*/
@Override
protected JobProgress runTask() throws VizException {
NotificationManagerJob.addObserver(NOTIFICATION_TOPIC, this);
try {
status = JobProgress.IN_PROGRESS;
startTime = System.currentTimeMillis();
while (status.equals(JobProgress.IN_PROGRESS)) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
status = JobProgress.FAILED;
}
if ((this.timeout > 0)
&& ((System.currentTimeMillis() - startTime) > this.timeout)) {
parent.getDisplay().syncExec(new Runnable() {
@Override
public void run() {
String message = "Task " + name
+ " has not completed after "
+ TimeUtil.prettyDuration(timeout)
+ ".\nDo you wish to continue waiting?";
if (MessageDialog.openQuestion(parent, "Timeout",
message)) {
startTime = System.currentTimeMillis();
} else {
synchronized (status) {
if (status.equals(JobProgress.IN_PROGRESS)) {
status = JobProgress.FAILED;
}
}
}
}
});
}
}
} finally {
NotificationManagerJob.removeObserver(NOTIFICATION_TOPIC, this);
}
return status;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.common.jms.notification.INotificationObserver#
* notificationArrived
* (com.raytheon.uf.common.jms.notification.NotificationMessage[])
*/
@Override
public void notificationArrived(NotificationMessage[] messages) {
for (NotificationMessage msg : messages) {
Object obj;
try {
obj = msg.getMessagePayload();
if (obj instanceof ServiceBackupJobStatusNotification) {
handleNotification((ServiceBackupJobStatusNotification) obj);
} else if (obj instanceof List) {
@SuppressWarnings("unchecked")
List<GfeNotification> notifList = (List<GfeNotification>) obj;
for (GfeNotification notif : notifList) {
if (notif instanceof ServiceBackupJobStatusNotification) {
handleNotification((ServiceBackupJobStatusNotification) notif);
}
}
}
} catch (NotificationException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to read incoming notification", e);
continue;
}
}
}
/**
* @param notif
*/
private void handleNotification(ServiceBackupJobStatusNotification notif) {
if (this.siteID.equals(notif.getSiteID())) {
if (notif.getName().equals(this.name)) {
synchronized (status) {
status = notif.getState();
}
}
}
}
}

View file

@ -1,40 +0,0 @@
/**
* 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.viz.gfe.dialogs.sbu.jobs;
/**
* Interface for Service Backup Task Completion
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 18, 2015 #4300 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public interface ITaskCompleteCallBack {
public void taskComplete(AbstractSbuTask task);
}

View file

@ -1,81 +0,0 @@
/**
* 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.viz.gfe.dialogs.sbu.jobs;
import com.raytheon.uf.common.dataplugin.gfe.request.AbstractGfeRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.gfe.GFEServerException;
/**
* Service Backup Task to run a server request
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 9, 2015 #4300 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class ServerRequestSbuTask extends AbstractSbuTask {
protected IServerRequest request;
public ServerRequestSbuTask(String statusFileName, String guiDescription,
IServerRequest request) {
super(statusFileName, guiDescription);
this.request = request;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.gfe.dialogs.sbu.jobs.AbstractSbuTask#runInternal()
*/
@Override
public JobProgress runTask() throws VizException {
JobProgress rval = JobProgress.FAILED;
if (request instanceof AbstractGfeRequest) {
((AbstractGfeRequest) request).setWorkstationID(VizApp.getWsId());
}
Object obj = ThriftClient.sendRequest(request);
if (obj instanceof JobProgress) {
rval = (JobProgress) obj;
} else {
throw new GFEServerException(
"Received invalid response object from GFE Server. Received ["
+ obj.getClass().getName() + "] excepted ["
+ JobProgress.class.getName());
}
return rval;
}
}

View file

@ -1,95 +0,0 @@
/**
* 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.viz.gfe.dialogs.sbu.jobs;
import java.util.List;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
/**
* Service Backup Task Executor
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 9, 2015 #4300 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class ServiceBackupTaskExecutor extends Thread {
private List<AbstractSbuTask> tasks;
private boolean cancelled;
private JobProgress jobStatus;
/**
*
*/
public ServiceBackupTaskExecutor(List<AbstractSbuTask> tasks) {
this.tasks = tasks;
}
public void cancel() {
this.cancelled = true;
this.interrupt();
}
/*
* (non-Javadoc)
*
* @see java.lang.Thread#start()
*/
@Override
public synchronized void start() {
this.jobStatus = JobProgress.IN_PROGRESS;
this.cancelled = false;
super.start();
}
@Override
public void run() {
for (AbstractSbuTask task : tasks) {
if (cancelled) {
break;
}
task.run();
if (!task.getStatus().equals(JobProgress.SUCCESS)) {
cancelled = true;
jobStatus = JobProgress.FAILED;
}
}
jobStatus = JobProgress.SUCCESS;
}
public JobProgress getJobStatus() {
return this.jobStatus;
}
}

View file

@ -1,152 +0,0 @@
/**
* 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.viz.gfe.dialogs.sbu.jobs;
import com.raytheon.uf.common.dataplugin.gfe.request.AbstractGfeRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.jms.notification.INotificationObserver;
import com.raytheon.uf.common.jms.notification.NotificationException;
import com.raytheon.uf.common.jms.notification.NotificationMessage;
import com.raytheon.uf.common.site.notify.ClusterActivationNotification;
import com.raytheon.uf.common.site.notify.SiteActivationNotification.ACTIVATIONSTATUS;
import com.raytheon.uf.common.site.notify.SiteActivationNotification.ACTIVATIONTYPE;
import com.raytheon.uf.common.site.requests.ActivateSiteRequest;
import com.raytheon.uf.common.site.requests.DeactivateSiteRequest;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob;
import com.raytheon.uf.viz.core.requests.ThriftClient;
/**
* Service Backup Task to activate/deactivate a GFE site
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 18, 2015 #4300 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class SiteActivationSbuTask extends ServerRequestSbuTask implements
INotificationObserver {
private static final String SITE_ACTIVATION_TOPIC = "edex.alerts.siteActivate";
private JobProgress status;
private String siteID;
private ACTIVATIONTYPE type;
/**
* @param siteID
* @param activate
* true to activate, false to deactivate
* @param statusFileName
* @param guiDescription
*/
public SiteActivationSbuTask(String siteID, ACTIVATIONTYPE type,
String statusFileName, String guiDescription) {
super(statusFileName, guiDescription, (type
.equals(ACTIVATIONTYPE.ACTIVATE) ? new ActivateSiteRequest(
siteID, "gfe") : new DeactivateSiteRequest(siteID, "gfe")));
this.siteID = siteID;
this.type = type;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.gfe.dialogs.sbu.jobs.ServerRequestSbuTask#runTask()
*/
@Override
public JobProgress runTask() throws VizException {
status = JobProgress.FAILED;
if (request instanceof AbstractGfeRequest) {
((AbstractGfeRequest) request).setWorkstationID(VizApp.getWsId());
}
NotificationManagerJob.addObserver(SITE_ACTIVATION_TOPIC, this);
try {
ThriftClient.sendRequest(request);
status = JobProgress.IN_PROGRESS;
while (status.equals(JobProgress.IN_PROGRESS)) {
// TODO: add timeout
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
status = JobProgress.FAILED;
}
}
} finally {
NotificationManagerJob.removeObserver(SITE_ACTIVATION_TOPIC, this);
}
return status;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.common.jms.notification.INotificationObserver#
* notificationArrived
* (com.raytheon.uf.common.jms.notification.NotificationMessage[])
*/
@Override
public void notificationArrived(NotificationMessage[] messages) {
for (NotificationMessage msg : messages) {
Object obj;
try {
obj = msg.getMessagePayload();
if (obj instanceof ClusterActivationNotification) {
ClusterActivationNotification notif = (ClusterActivationNotification) obj;
if (this.siteID.equals(notif.getModifiedSite())) {
if (notif.getType().equals(this.type)) {
if (notif.getStatus().equals(
ACTIVATIONSTATUS.SUCCESS)) {
status = JobProgress.SUCCESS;
} else if (notif.getStatus().equals(
ACTIVATIONSTATUS.FAILURE)) {
status = JobProgress.FAILED;
} else {
status = JobProgress.FAILED;
}
}
}
}
} catch (NotificationException e) {
statusHandler.handle(Priority.PROBLEM,
"Unable to read incoming notification", e);
continue;
}
}
}
}

View file

@ -1,106 +0,0 @@
/**
* 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.viz.gfe.dialogs.sbu.jobs;
import java.io.IOException;
import com.raytheon.uf.common.dataplugin.gfe.request.AbstractGfeRequest;
import com.raytheon.uf.common.dataplugin.gfe.request.GetGfeStartCmdRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.util.RunProcess;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.gfe.GFEException;
import com.raytheon.viz.gfe.GFEServerException;
/**
* Service backup task to start a GFE session
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 18, 2015 #4300 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class StartGfeSbuTask extends ServerRequestSbuTask {
private String site;
/**
* @param site
* @param statusFileName
* @param guiDescription
*/
public StartGfeSbuTask(String site, String statusFileName,
String guiDescription) {
super(statusFileName, guiDescription, new GetGfeStartCmdRequest(site));
this.site = site;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.gfe.dialogs.sbu.jobs.ServerRequestSbuTask#runTask()
*/
@Override
public JobProgress runTask() throws VizException {
JobProgress rval = JobProgress.FAILED;
if (request instanceof AbstractGfeRequest) {
((AbstractGfeRequest) request).setWorkstationID(VizApp.getWsId());
}
Object obj = ThriftClient.sendRequest(request);
if (obj instanceof String) {
String cmd = (String) obj;
if (cmd != null) {
statusHandler
.info("Attempting to start GFE using the following command: "
+ cmd);
// start GFE session
try {
RunProcess.getRunProcess().exec(cmd.split(" "));
rval = JobProgress.SUCCESS;
} catch (IOException e) {
throw new GFEException("Error starting GFE session for "
+ this.site, e);
}
}
} else {
throw new GFEServerException(
"Received invalid response object from GFE Server. Received ["
+ obj.getClass().getName() + "] excepted ["
+ String.class.getName());
}
return rval;
}
}

View file

@ -1,8 +1,4 @@
esbDir=${install.dir}/../edex
feature=../com.raytheon.edex.feature.uframe/feature.xml
working.dir=edex/tmp/plugins
deploy.data=true
svcbudir=${install.dir}/../GFESuite

View file

@ -50,13 +50,6 @@
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GetDbInventoryRequest"/>
<constructor-arg ref="dbInventoryHandler"/>
</bean>
<bean id="executeIscMosaicHandler" class="com.raytheon.edex.plugin.gfe.server.handler.ExecuteIscMosaicRequestHandler">
<constructor-arg ref="iscMosaicPythonThreadPool"/>
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.ExecuteIscMosaicRequest"/>
<constructor-arg ref="executeIscMosaicHandler"/>
</bean>
<bean id="discreteDefinitionHandler" class="com.raytheon.edex.plugin.gfe.server.handler.GetDiscreteDefinitionHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GetDiscreteDefinitionRequest"/>
@ -99,13 +92,6 @@
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GetLockTablesRequest"/>
<constructor-arg ref="lockTablesHandler"/>
</bean>
<bean id="netCDFHandler" class="com.raytheon.edex.plugin.gfe.server.handler.ExecuteIfpNetCDFGridRequestHandler">
<constructor-arg ref="ifpnetCDFPythonThreadPool"/>
</bean>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.ExecuteIfpNetCDFGridRequest"/>
<constructor-arg ref="netCDFHandler"/>
</bean>
<bean id="purgeGfeGridsHandler" class="com.raytheon.edex.plugin.gfe.server.handler.PurgeGfeGridsRequestHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.PurgeGfeGridsRequest"/>
@ -141,31 +127,6 @@
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.GridLocRequest"/>
<constructor-arg ref="gridLocHandler"/>
</bean>
<bean id="iscCreateDomainDictHandler" class="com.raytheon.edex.plugin.gfe.server.handler.IscCreateDomainDictHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.IscCreateDomainDictRequest"/>
<constructor-arg ref="iscCreateDomainDictHandler"/>
</bean>
<bean id="iscDataRecHandler" class="com.raytheon.edex.plugin.gfe.server.handler.IscDataRecRequestHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.IscDataRecRequest"/>
<constructor-arg ref="iscDataRecHandler"/>
</bean>
<bean id="iscGetRequestXmlHandler" class="com.raytheon.edex.plugin.gfe.server.handler.IscGetRequestXmlHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.IscGetRequestXmlRequest"/>
<constructor-arg ref="iscGetRequestXmlHandler"/>
</bean>
<bean id="iscMakeRequestHandler" class="com.raytheon.edex.plugin.gfe.server.handler.IscMakeRequestHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.IscMakeRequest"/>
<constructor-arg ref="iscMakeRequestHandler"/>
</bean>
<bean id="iscRequestQueryHandler" class="com.raytheon.edex.plugin.gfe.server.handler.IscRequestQueryHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.IscRequestQueryRequest"/>
<constructor-arg ref="iscRequestQueryHandler"/>
</bean>
<bean id="lockChangeHandler" class="com.raytheon.edex.plugin.gfe.server.handler.LockChangeHandler"/>
<bean factory-bean="handlerRegistry" factory-method="register">
<constructor-arg value="com.raytheon.uf.common.dataplugin.gfe.request.LockChangeRequest"/>
@ -230,42 +191,8 @@
<property name="provider" ref="brokerConnectionsProvider" />
</bean>
<bean id="ifpnetCDFFactory" class="com.raytheon.edex.plugin.gfe.isc.IscScriptFactory">
<constructor-arg value="ifpnetCDF"/>
</bean>
<bean id="ifpnetCDFPythonThreadPool" class="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator">
<constructor-arg value="2" />
<constructor-arg value="ifpnetCDF" />
<constructor-arg ref="ifpnetCDFFactory"/>
</bean>
<bean id="iscMosaicFactory" class="com.raytheon.edex.plugin.gfe.isc.IscScriptFactory">
<constructor-arg value="iscMosaic"/>
</bean>
<bean id="iscMosaicPythonThreadPool" class="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator">
<constructor-arg value="2" />
<constructor-arg value="iscMosaic" />
<constructor-arg ref="iscMosaicFactory" />
</bean>
<bean id="iscDataRecFactory" class="com.raytheon.edex.plugin.gfe.isc.IscScriptFactory">
<constructor-arg value="iscDataRec"/>
</bean>
<bean id="iscDataRecPythonThreadPool" class="com.raytheon.uf.common.python.concurrent.PythonJobCoordinator">
<constructor-arg value="2" />
<constructor-arg value="iscDataRec" />
<constructor-arg ref="iscDataRecFactory" />
</bean>
<!-- End Additional ISC Beans -->
<bean id="logPurger" class="com.raytheon.edex.plugin.gfe.log.LogPurger"/>
<bean id="productIscPurger" class="com.raytheon.uf.common.dataplugin.gfe.util.FilePurger">
<constructor-arg value="/awips2/GFESuite/products/ISC"/> <!-- directory to be purged -->
<constructor-arg value="2419200000"/> <!-- purge age: 28 days in milliseconds -->
</bean>
<bean id="productAtblPurger" class="com.raytheon.uf.common.dataplugin.gfe.util.FilePurger">
<constructor-arg value="/awips2/GFESuite/products/ATBL"/> <!-- directory to be purged -->
<constructor-arg value="2419200000"/> <!-- purge age: 28 days in milliseconds -->
@ -275,7 +202,6 @@
<endpoint id="exportDigitalDataCron" uri="clusteredquartz://gfe/exportDigitalData/?cron=${gfe.cron}"/>
<endpoint id="gfeLogPurgeCron" uri="clusteredquartz://gfe/purgeGfeLogs/?cron=${purge.gfe.logs.cron}"/>
<endpoint id="gfeProductIscPurgeCron" uri="clusteredquartz://gfe/purgeGfeProductsIsc/?cron=${purge.gfe.products.isc.cron}"/>
<endpoint id="gfeProductAtblPurgeCron" uri="clusteredquartz://gfe/purgeGfeProductsAtbl/?cron=${purge.gfe.products.atbl.cron}"/>
<endpoint id="gfeClearOrphanedLocksCron" uri="clusteredquartz://gfe/clearGfeOrhpanedLocks/?cron=${clear.gfe.orphaned.locks.cron}"/>
@ -300,22 +226,6 @@
</doTry>
</route>
<route id="purgeGfeProductsIsc">
<from uri="gfeProductIscPurgeCron"/>
<to uri="jms-generic:queue:purgeGfeProductIscWork"/>
</route>
<route id="purgeGfeProductIscWork">
<from uri="jms-generic:queue:purgeGfeProductIscWork"/>
<doTry>
<bean ref="productIscPurger" method="purge"/>
<doCatch>
<exception>java.lang.Throwable</exception>
<to
uri="log:svcBackup?level=ERROR"/>
</doCatch>
</doTry>
</route>
<route id="purgeGfeProductsAtbl">
<from uri="gfeProductAtblPurgeCron"/>
<to uri="jms-generic:queue:purgeGfeProductAtblWork"/>
@ -347,33 +257,6 @@
</doTry>
</route>
</camelContext>
<!-- ISC Services Beans -->
<bean id="iscProvider" class="com.raytheon.edex.plugin.gfe.isc.IscServiceProvider" />
<bean id="fetchATSrv" class="com.raytheon.edex.plugin.gfe.isc.FetchActiveTableSrv" />
<bean factory-bean="iscProvider" factory-method="addISCService">
<constructor-arg ref="fetchATSrv"/>
</bean>
<bean id="requestTCVSrv" class="com.raytheon.edex.plugin.gfe.isc.RequestTCVSrv" />
<bean factory-bean="iscProvider" factory-method="addISCService">
<constructor-arg ref="requestTCVSrv"/>
</bean>
<bean factory-bean="contextManager" factory-method="registerContextStateProcessor">
<constructor-arg ref="clusteredIscBeans" />
<constructor-arg ref="iscProvider" />
</bean>
<camelContext id="clusteredIscBeans" xmlns="http://camel.apache.org/schema/spring"
errorHandlerRef="errorHandler">
<route id="activateISC">
<from uri="timer://activateISCServices?repeatCount=1"/>
<bean ref="iscProvider" method="activateInstance"/>
</route>
</camelContext>
<bean factory-bean="contextManager" factory-method="registerClusteredContext">
<constructor-arg ref="clusteredIscBeans"/>
</bean>
</beans>

View file

@ -1,122 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
import com.raytheon.edex.plugin.gfe.isc.IscScript;
import com.raytheon.edex.plugin.gfe.isc.IscScriptExecutor;
import com.raytheon.edex.plugin.gfe.server.IFPServer;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.request.ExecuteIfpNetCDFGridRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* {@link IRequestHandler} class for {@link ExecuteIfpNetCDFGridRequest} that
* executes the python script ifpnetCDF to export GFE grids to the NetCDF file
* format.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 24, 2010 dgilling Initial creation
* Mar 11, 2013 #1759 dgilling Re-write using new IscScript classes.
* Nov 20, 2014 #98 lshi ifpnetCDF no longer gives an error code in some cases
* May 13, 2015 #4427 dgilling Add siteIdOverride field.
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class ExecuteIfpNetCDFGridRequestHandler implements
IRequestHandler<ExecuteIfpNetCDFGridRequest> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(ExecuteIfpNetCDFGridRequestHandler.class);
private static final String METHOD_NAME = "main";
private final PythonJobCoordinator<IscScript> threadPool;
public ExecuteIfpNetCDFGridRequestHandler(
PythonJobCoordinator<IscScript> threadPool) {
this.threadPool = threadPool;
}
@Override
public ServerResponse<Boolean> handleRequest(
ExecuteIfpNetCDFGridRequest request) throws Exception {
ServerResponse<Boolean> sr = new ServerResponse<Boolean>();
sr.setPayload(Boolean.FALSE);
// #98 verify requested database exists
IFPServer ifpServer = IFPServer.getActiveServer(request.getDatabaseID()
.getSiteId());
ServerResponse<java.util.List<DatabaseID>> ssr = ifpServer
.getGridParmMgr().getDbInventory();
if (!ssr.isOkay()) {
sr.addMessages(ssr);
return sr;
} else if (!ssr.getPayload().contains(request.getDatabaseID())) {
sr.addMessage(request.getDatabaseID() + " does not exist");
return sr;
}
statusHandler.debug("Received ifpnetCDF request: " + request);
Map<String, Object> args = new HashMap<String, Object>();
args.put("outputFilename", request.getOutputFilename());
args.put("parmList", request.getParmList());
args.put("databaseID", request.getDatabaseID().toString());
args.put("startTime", request.getStartTime());
args.put("endTime", request.getEndTime());
args.put("mask", request.getMask());
args.put("geoInfo", request.isGeoInfo());
args.put("compressFileFlag", request.isCompressFile());
args.put("configFileName", request.getConfigFileName());
args.put("compressFileFactor", request.getCompressFileFactor());
args.put("trim", request.isTrim());
args.put("krunch", request.isKrunch());
args.put("userID", request.getUserID());
args.put("logFileName", request.getLogFileName());
args.put("siteIdOverride", request.getSiteIdOverride());
IscScriptExecutor executor = new IscScriptExecutor(METHOD_NAME,
request.getSiteID(), args);
Future<String> task = threadPool.submitJob(executor);
String retVal = task.get();
if (retVal != null) {
sr.addMessage(retVal);
return sr;
}
sr.setPayload(Boolean.TRUE);
return sr;
}
}

View file

@ -1,99 +0,0 @@
package com.raytheon.edex.plugin.gfe.server.handler;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Future;
import com.raytheon.edex.plugin.gfe.isc.IscScript;
import com.raytheon.edex.plugin.gfe.isc.IscScriptExecutor;
import com.raytheon.edex.site.SiteUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.ExecuteIscMosaicRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* {@link IRequestHandler} class for {@link ExecuteIscMosaicRequest} that
* executes the python script iscMosaic, which imports GFE grids from a NetCDF
* file.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 15, 2010 dgilling Initial creation
* Mar 12, 2013 #1759 dgilling Re-write using new IscScript classes.
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class ExecuteIscMosaicRequestHandler implements
IRequestHandler<ExecuteIscMosaicRequest> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(ExecuteIscMosaicRequest.class);
private static final String METHOD_NAME = "main";
private final PythonJobCoordinator<IscScript> threadPool;
public ExecuteIscMosaicRequestHandler(
PythonJobCoordinator<IscScript> threadPool) {
this.threadPool = threadPool;
}
@Override
public ServerResponse<Boolean> handleRequest(ExecuteIscMosaicRequest request)
throws Exception {
ServerResponse<Boolean> sr = new ServerResponse<Boolean>();
sr.setPayload(Boolean.FALSE);
statusHandler.debug("Received iscMosaic request: " + request);
Map<String, Object> args = new HashMap<String, Object>();
args.put("siteID", determineSiteId(request.getSiteID()));
args.put("userID", request.getUserID());
args.put("databaseID", request.getDatabaseID().toString());
args.put("parmsToProcess", request.getParmsToProcess());
args.put("blankOtherPeriods", request.isBlankOtherPeriods());
args.put("startTime", request.getStartTime());
args.put("endTime", request.getEndTime());
args.put("altMask", request.getAltMask());
args.put("replaceOnly", request.isReplaceOnly());
args.put("eraseFirst", request.isEraseFirst());
args.put("announce", request.getAnnounce());
args.put("renameWE", request.isRenameWE());
args.put("iscSends", request.isIscSends());
args.put("inFiles", request.getInFiles());
args.put("ignoreMask", request.isIgnoreMask());
args.put("adjustTranslate", request.isAdjustTranslate());
args.put("deleteInput", request.isDeleteInput());
args.put("parmsToIgnore", request.getParmsToIgnore());
args.put("gridDelay", request.getGridDelay());
args.put("logFileName", request.getLogFileName());
IscScriptExecutor executor = new IscScriptExecutor(METHOD_NAME,
request.getSiteID(), args);
Future<String> task = threadPool.submitJob(executor);
String retVal = task.get();
if (retVal != null) {
sr.addMessage(retVal);
return sr;
}
sr.setPayload(Boolean.TRUE);
return sr;
}
private String determineSiteId(String inputSite) {
if ((inputSite == null) || inputSite.isEmpty()) {
return SiteUtil.getSite();
} else {
return inputSite;
}
}
}

View file

@ -1,88 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
import com.raytheon.edex.plugin.gfe.server.IFPServer;
import com.raytheon.uf.common.dataplugin.gfe.request.GetIscSendStatusRequest;
import com.raytheon.uf.common.dataplugin.gfe.request.GetIscSendStatusRequest.IscSendStatus;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* GFE request handler for getting ISC send statuses
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 21, 2011 4686 randerso Initial creation
* Jun 13, 2013 2044 randerso Refactored to use IFPServer
* Dec 15, 2015 5166 kbisanz Update logging to use SLF4J
*
* </pre>
*
* @author randerso
* @version 1.0
*/
public class GetIscSendStatusHandler extends BaseGfeRequestHandler implements
IRequestHandler<GetIscSendStatusRequest> {
protected final transient Logger logger = LoggerFactory
.getLogger(getClass());
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
*/
@Override
public ServerResponse<IscSendStatus> handleRequest(
GetIscSendStatusRequest request) throws Exception {
ServerResponse<IscSendStatus> sr = null;
try {
IFPServer ifpServer = getIfpServer(request);
IFPServerConfig config = ifpServer.getConfig();
boolean sendISConSave = config.sendiscOnSave();
boolean sendISConPublish = config.sendiscOnPublish();
boolean requestISC = config.requestISC();
sr = new ServerResponse<IscSendStatus>();
IscSendStatus iscSendStatus = new IscSendStatus(sendISConSave,
sendISConPublish, requestISC);
sr.setPayload(iscSendStatus);
} catch (Exception e) {
logger.error("Error ISC send status", e);
sr = new ServerResponse<IscSendStatus>();
sr.addMessage("Error ISC send status");
}
return sr;
}
}

View file

@ -1,97 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler;
import java.util.HashMap;
import java.util.Map;
import jep.JepException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.IscCreateDomainDictRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationUtil;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* Task used to correctly construct the ISC Request/Reply Dialog
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/06/09 1995 bphillip Initial port
* 09/22/09 3058 rjpeter Converted to IRequestHandler
* 09/05/13 2307 dgilling Use better PythonScript constructor.
* 12/15/15 5166 kbisanz Update logging to use SLF4J
* 07/14/16 5747 dgilling Move edex_static to common_static.
* </pre>
*
* @author bphillip
*/
public class IscCreateDomainDictHandler implements
IRequestHandler<IscCreateDomainDictRequest> {
protected final transient Logger logger = LoggerFactory
.getLogger(getClass());
private static final String SCRIPT_PATH = LocalizationUtil.join("gfe",
"python", "isc", "iscUtil.py");
@Override
public ServerResponse<Object> handleRequest(
IscCreateDomainDictRequest request) throws Exception {
ServerResponse<Object> response = new ServerResponse<>();
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
String scriptFile = pathMgr.getFile(cx, SCRIPT_PATH).getPath();
String includePath = PyUtil.buildJepIncludePath(
GfePyIncludeUtil.getCommonPythonIncludePath(),
GfePyIncludeUtil.getIscScriptsIncludePath(),
GfePyIncludeUtil.getGfeConfigIncludePath(request.getSiteID()));
try (PythonScript script = new PythonScript(scriptFile, includePath,
this.getClass().getClassLoader())) {
Map<String, Object> args = new HashMap<>();
args.put("xml", request.getXml());
Object obj = script.execute("createDomainDict", args);
response.setPayload(obj);
} catch (JepException e) {
logger.error("Error occurred creating Isc Domain Dict", e);
}
return response;
}
}

View file

@ -1,68 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler;
import com.raytheon.uf.common.dataplugin.gfe.request.IscDataRecRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.edex.core.EDEXUtil;
/**
* Thrift request handler for <code>IscDataRecRequest</code>. Takes request and
* places it on a queue to be executed by <code>IscReceiveSrv</code> .
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 26, 2010 dgilling Initial creation
* Mar 05, 2012 #361 dgilling Make call to iscDataRec
* asynchronous.
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class IscDataRecRequestHandler implements
IRequestHandler<IscDataRecRequest> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
*/
@Override
public ServerResponse<String> handleRequest(IscDataRecRequest request)
throws Exception {
ServerResponse<String> sr = new ServerResponse<String>();
byte[] message = SerializationUtil.transformToThrift(request);
EDEXUtil.getMessageProducer().sendAsync("iscReceiveRoute", message);
return sr;
}
}

View file

@ -1,98 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler;
import java.util.HashMap;
import java.util.Map;
import jep.JepException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.IscGetRequestXmlRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationUtil;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* Class used to generate the request ISC grid xml
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 08/21/09 1995 bphillip Initial port
* 09/22/09 3058 rjpeter Converted to IRequestHandler
* 09/05/13 2307 dgilling Use better PythonScript constructor.
* 07/14/16 5747 dgilling Move edex_static to common_static.
* </pre>
*
* @author bphillip
*/
public class IscGetRequestXmlHandler implements
IRequestHandler<IscGetRequestXmlRequest> {
private final transient Logger logger = LoggerFactory.getLogger(getClass());
private static final String SCRIPT_PATH = LocalizationUtil.join("gfe",
"python", "isc", "iscUtil.py");
@Override
public ServerResponse<String> handleRequest(IscGetRequestXmlRequest request)
throws Exception {
ServerResponse<String> response = new ServerResponse<>();
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
String scriptFile = pathMgr.getFile(cx, SCRIPT_PATH).getPath();
String includePath = PyUtil.buildJepIncludePath(
GfePyIncludeUtil.getCommonPythonIncludePath(),
GfePyIncludeUtil.getIscScriptsIncludePath(),
GfePyIncludeUtil.getGfeConfigIncludePath(request.getSiteID()));
try (PythonScript script = new PythonScript(scriptFile, includePath,
this.getClass().getClassLoader())) {
Map<String, Object> args = new HashMap<>();
args.put("xml", request.getXml());
args.put("selectedServers", request.getSelectedServers());
args.put("selectedWEList", request.getSelectedWEList());
String xmlResponse = (String) script.execute("getRequestXML", args);
response.setPayload(xmlResponse);
} catch (JepException e) {
logger.error("Error occurred calling getRequestXML", e);
}
return response;
}
}

View file

@ -1,177 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import jep.JepException;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager;
import com.raytheon.edex.plugin.gfe.exception.GfeConfigurationException;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.IscMakeRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationUtil;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* Processes an ISC grid request from the client
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 08/21/09 1995 bphillip Initial port
* 09/22/09 3058 rjpeter Converted to IRequestHandler
* 03/07/13 1759 dgilling Refactor to not use GfeScript.
* 09/05/13 2307 dgilling Use better PythonScript constructor.
* 07/14/16 5747 dgilling Move edex_static to common_static.
*
* </pre>
*
* @author bphillip
*/
public class IscMakeRequestHandler implements IRequestHandler<IscMakeRequest> {
private static final String SCRIPT_PATH = LocalizationUtil.join("gfe",
"python", "isc", "IrtServer.py");
private static final String METHOD_NAME = "makeISCrequest";
private static final ExecutorService scriptRunner = Executors
.newCachedThreadPool();
@Override
public ServerResponse<Boolean> handleRequest(IscMakeRequest request)
throws Exception {
ServerResponse<Boolean> response = new ServerResponse<>();
response.setPayload(Boolean.FALSE);
final String siteID = request.getSiteID();
IFPServerConfig config = null;
try {
config = IFPServerConfigManager.getServerConfig(siteID);
} catch (GfeConfigurationException e) {
response.addMessage("Unable to get server config for site ["
+ siteID + "]");
return response;
}
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
final String scriptPath = pathMgr.getFile(cx, SCRIPT_PATH).getPath();
final String includePath = PyUtil.buildJepIncludePath(
GfePyIncludeUtil.getCommonPythonIncludePath(),
GfePyIncludeUtil.getIscScriptsIncludePath(),
GfePyIncludeUtil.getGfeConfigIncludePath(siteID));
GridLocation domain = config.dbDomain();
List<Integer> gridDims = new ArrayList<>();
gridDims.add(domain.getNy());
gridDims.add(domain.getNx());
List<Double> gridBoundBox = new ArrayList<>();
gridBoundBox.add(domain.getOrigin().x);
gridBoundBox.add(domain.getOrigin().y);
gridBoundBox.add(domain.getExtent().x);
gridBoundBox.add(domain.getExtent().y);
final Map<String, Object> args = new HashMap<>();
args.put("xmlRequest", request.getXml());
args.put("gridDims", gridDims);
args.put("gridProj", domain.getProjection().getProjectionID()
.toString());
args.put("gridBoundBox", gridBoundBox);
args.put("mhs", config.getMhsid());
args.put("host", config.getServerHost());
args.put("port", config.getRpcPort());
args.put("protocol", String.valueOf(config.getProtocolVersion()));
args.put("site", siteID);
args.put("xmtScript", config.transmitScript());
Callable<String> scriptJob = new Callable<String>() {
@Override
public String call() throws Exception {
try {
try (PythonScript script = new PythonScript(scriptPath,
includePath,
IscMakeRequestHandler.class.getClassLoader())) {
try {
script.execute(METHOD_NAME, args);
} catch (JepException e) {
String msg = "Error servicing IscMakeRequest from site ["
+ siteID + "]: " + e.getLocalizedMessage();
return msg;
}
} catch (JepException e) {
String msg = "Error initializing IrtServer python script: "
+ e.getLocalizedMessage();
return msg;
}
} catch (Throwable t) {
String msg = "Error servicing IscMakeRequest from site ["
+ siteID + "]: " + t.getLocalizedMessage();
return msg;
}
return null;
}
};
try {
Future<String> result = scriptRunner.submit(scriptJob);
String errorMessage = result.get();
if (errorMessage != null) {
response.addMessage(errorMessage);
return response;
}
} catch (RejectedExecutionException e) {
String msg = "IscMakeRequest job was rejected: "
+ e.getLocalizedMessage();
response.addMessage(msg);
return response;
}
response.setPayload(Boolean.TRUE);
return response;
}
}

View file

@ -1,168 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jep.JepException;
import org.apache.commons.lang3.StringUtils;
import com.raytheon.edex.plugin.gfe.config.IFPServerConfig;
import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.IscRequestQueryRequest;
import com.raytheon.uf.common.dataplugin.gfe.request.IscRequestQueryRequest.IscQueryResponse;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationUtil;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.python.PyUtil;
import com.raytheon.uf.common.python.PythonScript;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Port of the requestQuery from AWIPS I
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 07/06/09 1995 bphillip Initial port
* 09/22/09 3058 rjpeter Converted to IRequestHandler
* 09/05/13 2307 dgilling Use better PythonScript constructor.
* 08/14/15 4750 dgilling Send domainDicts back as Maps, not
* python pickled strings.
* 11/30/15 5129 dgilling Code cleanup.
* 07/14/16 5747 dgilling Move edex_static to common_static.
* 08/04/16 5788 dgilling Throw error when empty response received from
* IRT.
* </pre>
*
* @author bphillip
*/
public class IscRequestQueryHandler extends BaseGfeRequestHandler implements
IRequestHandler<IscRequestQueryRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(getClass());
private static final String IRT_SERVER = LocalizationUtil.join("gfe",
"python", "isc", "IrtServer.py");
private static final String ISC_UTIL = LocalizationUtil.join("gfe",
"python", "isc", "iscUtil.py");
@Override
public ServerResponse<IscQueryResponse> handleRequest(
IscRequestQueryRequest request) throws Exception {
ServerResponse<IscQueryResponse> sr = new ServerResponse<>();
// init return values
String xmlResponse = StringUtils.EMPTY;
Collection<String> parmsWanted = Collections.emptyList();
Map<String, Map<String, List<Map<String, String>>>> domainDict = Collections
.emptyMap();
Map<String, Map<String, String>> serverDictT2S = Collections.emptyMap();
// ensure there is a routing table
IFPServerConfig config = getIfpServer(request).getConfig();
String ancf = config.iscRoutingTableAddress().get("ANCF");
String bncf = config.iscRoutingTableAddress().get("BNCF");
if ((StringUtils.isBlank(ancf)) || (StringUtils.isBlank(bncf))
|| (!config.requestISC())) {
sr.addMessage("IRT Address/requestISC not enabled. No ISC data available.");
} else {
// calculate XML
try (PythonScript script = new PythonScript(
getScriptPath(IRT_SERVER),
getIncludePath(request.getSiteID()), getClass()
.getClassLoader())) {
Map<String, Object> args = new HashMap<>();
args.put("ancfURL", ancf);
args.put("bncfURL", bncf);
args.put("iscWfosWanted", config.requestedISCsites());
String xml = (String) script.execute("irtGetServers", args);
xmlResponse = xml;
parmsWanted = config.requestedISCparms();
} catch (JepException e) {
statusHandler.error("Can't create IrtAccess instance: ", e);
sr.addMessage("No ISC data available due to inability to access Irt");
}
if (xmlResponse.isEmpty()) {
statusHandler
.warn("Empty response returned from IRT for irtGetServers.");
sr.addMessage("No ISC data available due to inability to process Irt server response.");
return sr;
}
try (PythonScript script = new PythonScript(
getScriptPath(ISC_UTIL),
getIncludePath(request.getSiteID()), getClass()
.getClassLoader())) {
Map<String, Object> args = new HashMap<>();
args.put("xml", xmlResponse);
Map<String, Object> objectDict = (Map<String, Object>) script
.execute("createDomainDict", args);
domainDict = (Map<String, Map<String, List<Map<String, String>>>>) objectDict
.get("domains");
serverDictT2S = (Map<String, Map<String, String>>) objectDict
.get("serverDictT2S");
} catch (JepException e) {
statusHandler.error("Error occurred creating Isc Domain Dict",
e);
sr.addMessage("No ISC data available due to inability to process Irt server response.");
return sr;
}
}
sr.setPayload(new IscQueryResponse(domainDict, serverDictT2S,
parmsWanted));
return sr;
}
private static String getScriptPath(String locPath) {
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationContext cx = pathMgr.getContext(
LocalizationType.COMMON_STATIC, LocalizationLevel.BASE);
String scriptFile = pathMgr.getFile(cx, locPath).getPath();
return scriptFile;
}
private static String getIncludePath(String siteID) {
String includePath = PyUtil.buildJepIncludePath(
GfePyIncludeUtil.getCommonPythonIncludePath(),
GfePyIncludeUtil.getIscScriptsIncludePath(),
GfePyIncludeUtil.getGfeConfigIncludePath(siteID));
return includePath;
}
}

View file

@ -1,74 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.edex.plugin.gfe.isc.IscSendQueue;
import com.raytheon.edex.plugin.gfe.isc.IscSendRecord;
import com.raytheon.uf.common.dataplugin.gfe.request.SendIscGridRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.dataplugin.gfe.server.request.SendISCRequest;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* Task for send ISC grids from a client
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 08/19/09 1995 bphillip Initial creation
* 09/22/09 3058 rjpeter Converted to IRequestHandler
* </pre>
*
* @author bphillip
* @version 1
*/
public class SendIscGridHandler implements IRequestHandler<SendIscGridRequest> {
@Override
public ServerResponse<?> handleRequest(SendIscGridRequest request)
throws Exception {
ServerResponse<String> response = new ServerResponse<String>();
// String siteID = request.getSiteID();
List<IscSendRecord> newReqs = new ArrayList<IscSendRecord>(request
.getRequests().size());
for (SendISCRequest sendReq : request.getRequests()) {
if (sendReq.getParmId() == null && sendReq.getTimeRange() == null) {
IscSendQueue.getInstance().sendPending(request.getSiteID());
} else {
IscSendRecord rec = new IscSendRecord(sendReq.getParmId(),
sendReq.getTimeRange(), "", true);
newReqs.add(rec);
}
}
if (!newReqs.isEmpty()) {
IscSendQueue.sendToQueue(newReqs);
}
return response;
}
}

View file

@ -1,65 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import java.nio.file.Files;
import java.nio.file.Path;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.AbortOperationRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 12, 2011 bphillip Initial creation
* Feb 13, 2015 #4103 dgilling Use site id.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class AbortOperationRequestHandler implements
IRequestHandler<AbortOperationRequest> {
@Override
public ServerResponse<Object> handleRequest(AbortOperationRequest request)
throws Exception {
ServerResponse<Object> sr = new ServerResponse<>();
Path lockFilePath = SvcBackupUtil.getLockDir(request.getSiteID())
.resolve(request.getOperation());
if (!Files.deleteIfExists(lockFilePath)) {
sr.addMessage("Unable to delete lock file: "
+ request.getOperation());
}
return sr;
}
}

View file

@ -1,67 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.dataplugin.gfe.request.CheckPermissionsRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 4, 2011 bphillip Initial creation
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public class CheckPermissionsRequestHandler extends
AbstractPrivilegedRequestHandler<CheckPermissionsRequest> {
@Override
public Object handleRequest(CheckPermissionsRequest request)
throws Exception {
AuthorizationResponse response = authorized(request.getUser(), request);
ServerResponse<String> sr = new ServerResponse<String>();
if (!response.isAuthorized()) {
sr.addMessage(response.getResponseMessage());
}
return sr;
}
@Override
public AuthorizationResponse authorized(IUser user,
CheckPermissionsRequest request) throws AuthorizationException {
return SvcBackupUtil.authorizeWithLocalization(user, request);
}
}

View file

@ -1,65 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.CheckServiceBackupPrimarySiteRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* Handler for <code>CheckServiceBackupPrimarySiteRequest</code>. Determines
* whether the specified site id has been configured as one of service backup's
* primary sites.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 02, 2013 dgilling Initial creation
*
* </pre>
*
* @author dgilling
* @version 1.0
*/
public class CheckServiceBackupPrimarySiteHandler implements
IRequestHandler<CheckServiceBackupPrimarySiteRequest> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
*/
@Override
public ServerResponse<Boolean> handleRequest(
CheckServiceBackupPrimarySiteRequest request) throws Exception {
ServerResponse<Boolean> sr = new ServerResponse<Boolean>();
boolean isPrimarySite = SvcBackupUtil.getPrimarySites().contains(
request.getSiteID());
sr.setPayload(isPrimarySite);
return sr;
}
}

View file

@ -1,113 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import java.io.File;
import com.raytheon.edex.plugin.gfe.db.dao.GFEDao;
import com.raytheon.edex.plugin.gfe.server.database.GridDatabase;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.dataplugin.gfe.request.CleanupSvcBuRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.datastorage.DataStoreFactory;
import com.raytheon.uf.common.datastorage.IDataStore;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.database.DataAccessLayerException;
/**
* Request handler for {@code CleanupSvcBuRequest}. This handler will delete all
* data for the failed site from the local server.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 10, 2011 bphillip Initial creation
* Feb 12, 2015 #4103 dgilling Move lock deletion to cleanup script.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class CleanupSvcBuRequestHandler implements
IRequestHandler<CleanupSvcBuRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(CleanupSvcBuRequestHandler.class);
@Override
public JobProgress handleRequest(final CleanupSvcBuRequest request) {
JobProgress progress = JobProgress.SUCCESS;
try {
statusHandler.info("Running cleanup script for for "
+ request.getFailedSite());
SvcBackupUtil.execute("cleanup_svcbk", request.getFailedSite()
.toLowerCase());
} catch (Exception e) {
statusHandler.error("Error executing cleanup script!", e);
progress = JobProgress.FAILED;
}
try {
statusHandler.info("Purging database for "
+ request.getFailedSite());
new GFEDao().purgeDatabaseForSite(request.getFailedSite());
} catch (DataAccessLayerException e) {
statusHandler.error(
"Error purging GFE data for site "
+ request.getFailedSite(), e);
progress = JobProgress.FAILED;
} catch (PluginException e) {
statusHandler.error("Error instantiating GFEDao!", e);
progress = JobProgress.FAILED;
}
try {
statusHandler.info("Purging HDF5 for " + request.getFailedSite());
purgeHDF5(request.getFailedSite());
} catch (DataAccessLayerException e) {
statusHandler.error("Error purging GFE HDF5 data for site "
+ request.getFailedSite(), e);
progress = JobProgress.FAILED;
}
return progress;
}
private void purgeHDF5(String failedSite) throws DataAccessLayerException {
File siteDataStoreFile = new File(GridDatabase.gfeBaseDataDir
+ failedSite.toUpperCase());
IDataStore ds = DataStoreFactory.getDataStore(siteDataStoreFile);
try {
ds.deleteFiles(null);
} catch (Exception e) {
throw new DataAccessLayerException(
"Error deleting HDF5 files for site " + failedSite, e);
}
}
}

View file

@ -1,89 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.dataplugin.gfe.request.ExportConfRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
/**
* Request handler for {@code ExportConfRequest}. This handler will export the
* local site's configuration data to the central server for use in a service
* backup scenario.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 04, 2011 bphillip Initial creation
* Mar 17, 2015 #4103 dgilling Stop using ServiceBackupNotificationManager,
* supoprt new Service Backup GUI.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class ExportConfRequestHandler extends
AbstractPrivilegedRequestHandler<ExportConfRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ExportConfRequestHandler.class);
@Override
public JobProgress handleRequest(final ExportConfRequest request)
throws Exception {
AuthorizationResponse response = authorized(request.getUser(), request);
if (!response.isAuthorized()) {
statusHandler.error("User " + request.getUser()
+ " is not export configuration for site "
+ request.getSite());
return JobProgress.FAILED;
}
try {
SvcBackupUtil.execute("export_configuration", request.getSite()
.toLowerCase());
statusHandler
.info("Configuration successfully sent to central server");
} catch (Exception e) {
statusHandler.error("Error exporting configuration for site "
+ request.getSite(), e);
return JobProgress.FAILED;
}
return JobProgress.SUCCESS;
}
@Override
public AuthorizationResponse authorized(IUser user,
ExportConfRequest request) throws AuthorizationException {
return SvcBackupUtil.authorizeWithLocalization(user, request);
}
}

View file

@ -1,69 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.ExportDataToFailedSiteRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code ExportDataToFailedSiteRequest}. This handler will
* export the GFE grids for a failed site running in service backup mode and
* send them directly to the failed site.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 04, 2011 bphillip Initial creation
* Mar 17, 2015 #4103 dgilling Support new Service Backup GUI.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class ExportDataToFailedSiteRequestHandler implements
IRequestHandler<ExportDataToFailedSiteRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ExportDataToFailedSiteRequestHandler.class);
@Override
public JobProgress handleRequest(final ExportDataToFailedSiteRequest request)
throws Exception {
try {
SvcBackupUtil.execute("export_grids_to_failed_site", request
.getFailedSite().toLowerCase());
} catch (Exception e) {
statusHandler.error(
"Error running export_grids_to_failed_site for site "
+ request.getFailedSite(), e);
return JobProgress.FAILED;
}
return JobProgress.SUCCESS;
}
}

View file

@ -1,69 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.ExportFailedSiteDataToCCRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code ExportFailedSiteDataToCCRequestHandler}. This
* handler will export the GFE grids for a failed site running in service backup
* mode and send them directly to the central server.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 04, 2011 bphillip Initial creation
* Mar 17, 2015 #4103 dgilling Support new Service Backup GUI.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class ExportFailedSiteDataToCCRequestHandler implements
IRequestHandler<ExportFailedSiteDataToCCRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ExportFailedSiteDataToCCRequestHandler.class);
@Override
public JobProgress handleRequest(
final ExportFailedSiteDataToCCRequest request) throws Exception {
try {
SvcBackupUtil.execute("export_bksite_grids", request
.getFailedSite().toLowerCase());
} catch (Exception e) {
statusHandler.error("Error running export_bksite_grids for site "
+ request.getFailedSite(), e);
return JobProgress.FAILED;
}
return JobProgress.SUCCESS;
}
}

View file

@ -1,91 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import java.util.Date;
import java.util.Random;
import java.util.Timer;
import com.raytheon.edex.plugin.gfe.svcbackup.ExportGridsTask;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code ExportGridsRequest}. This handler will export the
* GFE grids for a site and leaves them in the GFESuite/exportgrids folder for
* the central server to download via rsync.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 04, 2011 bphillip Initial creation
* Apr 30, 2013 #1761 dgilling Support changes made to
* ExportGridsRequest.
* Mar 17, 2015 #4103 dgilling Stop using ServiceBackupNotificationManager,
* supoprt new Service Backup GUI.
* Oct 24, 2016 #5951 dgilling Clean up error log message.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class ExportGridsRequestHandler
implements IRequestHandler<ExportGridsRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ExportGridsRequestHandler.class);
private static Timer exportGridsTimer = new Timer(true);
@Override
public JobProgress handleRequest(final ExportGridsRequest request)
throws Exception {
JobProgress progress = JobProgress.SUCCESS;
try {
SvcBackupUtil.execute("export_grids",
request.getMode().getCmdLineArg(),
request.getSite().toLowerCase());
statusHandler.info("Digital data successfully exported.");
} catch (Exception e) {
statusHandler.error("Error exporting digital data for site "
+ request.getSite(), e);
}
return progress;
}
public void exportGridsCron() throws Exception {
Random rand = new Random(System.currentTimeMillis());
Date executionDate = new Date(System.currentTimeMillis()
+ Math.abs(rand.nextInt() % 45) * 60 * 1000);
exportGridsTimer.schedule(new ExportGridsTask(executionDate),
executionDate);
}
}

View file

@ -1,82 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import java.util.Properties;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.GetGfeStartCmdRequest;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code GetGfeStartCmdRequest}. Using the configuration
* file svcbu.properties, this determines the command needed to launch GFE as
* the failed site and returns it to the requester.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 09, 2011 bphillip Initial creation
* Feb 13, 2015 #4103 dgilling Rewrite to stop using createGFEStartScript.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class GetGfeStartCmdRequestHandler implements
IRequestHandler<GetGfeStartCmdRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(CleanupSvcBuRequestHandler.class);
@Override
public String handleRequest(final GetGfeStartCmdRequest request)
throws Exception {
Properties svcbuProps = SvcBackupUtil.getSvcBackupProperties();
String svcbuUser = (svcbuProps.getProperty("SVCBU_USER") != null) ? svcbuProps
.getProperty("SVCBU_USER").trim() : "0";
String svcbuUserName = (svcbuProps.getProperty("SVCBU_USER_ID") != null) ? svcbuProps
.getProperty("SVCBU_USER_ID").trim() : "";
if (svcbuUser.equals("1") && svcbuUserName.isEmpty()) {
statusHandler
.info("You do not have a user id configured for ServiceBackup");
statusHandler.info("GFE will start with your regular user id");
}
StringBuilder cmdLine = new StringBuilder(
svcbuProps.getProperty("CAVE_LAUNCH_SCRIPT"));
cmdLine.append(" -site ").append(request.getSite());
if ((svcbuUser.equals("1")) && (!svcbuUserName.isEmpty())) {
cmdLine.append(" -u ").append(svcbuUserName);
}
cmdLine.append(" -perspective GFE");
return cmdLine.toString();
}
}

View file

@ -1,198 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.GetServiceBackupJobStatusRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.ServiceBackupJobStatus;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code GetServiceBackupJobStatusRequest}. This handler
* will return the current status of service backup for the requested site (or
* alternatively all sites currently in service backup mode) by finding all
* service backup lock files in the file system and getting their internal
* status.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 10, 2011 bphillip Initial creation
* Feb 12, 2015 #4103 dgilling Renamed from GetSbLockFilesRequestHandler,
* rewrite using Java7 nio.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class GetServiceBackupJobStatusHandler implements
IRequestHandler<GetServiceBackupJobStatusRequest> {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(GetServiceBackupJobStatusHandler.class);
private static final class ListLockFiles extends SimpleFileVisitor<Path> {
private final Map<String, Collection<ServiceBackupJobStatus>> locksBySite;
private final Collection<Path> requestedLockDirs;
public ListLockFiles(Collection<String> siteIds) {
super();
this.locksBySite = new HashMap<>();
this.requestedLockDirs = new HashSet<>(siteIds.size());
for (String siteId : siteIds) {
this.requestedLockDirs.add(SvcBackupUtil.getLockDir(siteId));
}
}
/*
* (non-Javadoc)
*
* @see java.nio.file.SimpleFileVisitor#visitFile(java.lang.Object,
* java.nio.file.attribute.BasicFileAttributes)
*/
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException {
super.visitFile(file, attrs);
String siteId = file.getParent().getFileName().toString()
.toUpperCase();
String lockName = file.getFileName().toString();
Collection<ServiceBackupJobStatus> siteLocks = locksBySite
.get(siteId);
if (siteLocks == null) {
siteLocks = new ArrayList<>();
locksBySite.put(siteId, siteLocks);
}
JobProgress status = getLockStatus(file);
Date lastModifiedTime = new Date(attrs.lastModifiedTime()
.toMillis());
siteLocks.add(new ServiceBackupJobStatus(lockName, status,
lastModifiedTime));
return FileVisitResult.CONTINUE;
}
/*
* (non-Javadoc)
*
* @see
* java.nio.file.SimpleFileVisitor#preVisitDirectory(java.lang.Object,
* java.nio.file.attribute.BasicFileAttributes)
*/
@Override
public FileVisitResult preVisitDirectory(Path dir,
BasicFileAttributes attrs) throws IOException {
super.preVisitDirectory(dir, attrs);
if ((requestedLockDirs.contains(dir))
|| (requestedLockDirs.isEmpty())
|| (dir.equals(SvcBackupUtil.getLockDir()))) {
return FileVisitResult.CONTINUE;
} else {
return FileVisitResult.SKIP_SUBTREE;
}
}
/*
* (non-Javadoc)
*
* @see
* java.nio.file.SimpleFileVisitor#visitFileFailed(java.lang.Object,
* java.io.IOException)
*/
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc)
throws IOException {
statusHandler.error("Unable to read service backup lock file: "
+ file.toString(), exc);
return FileVisitResult.CONTINUE;
}
private JobProgress getLockStatus(final Path lockFile) {
JobProgress retVal = JobProgress.UNKNOWN;
try {
List<String> fileContents = Files.readAllLines(lockFile,
StandardCharsets.US_ASCII);
if (!fileContents.isEmpty()) {
retVal = JobProgress.valueOf(fileContents.get(0).trim());
}
} catch (IOException e) {
statusHandler.error("Unable to read lock status from file ["
+ lockFile.toString() + "].", e);
} catch (IllegalArgumentException e) {
statusHandler.error(
"Invalid status value specified in lock file ["
+ lockFile.toString() + "].", e);
}
return retVal;
}
public Map<String, Collection<ServiceBackupJobStatus>> getLocksBySite() {
return locksBySite;
}
}
@Override
public ServerResponse<Map<String, Collection<ServiceBackupJobStatus>>> handleRequest(
final GetServiceBackupJobStatusRequest request) throws Exception {
ServerResponse<Map<String, Collection<ServiceBackupJobStatus>>> sr = new ServerResponse<>();
sr.setPayload(getLockFiles(request.getRequestedSiteIds()));
return sr;
}
private static Map<String, Collection<ServiceBackupJobStatus>> getLockFiles(
final Collection<String> siteIds) throws IOException {
Path lockDir = SvcBackupUtil.getLockDir();
ListLockFiles lockFileLister = new ListLockFiles(siteIds);
Files.walkFileTree(lockDir, EnumSet.of(FileVisitOption.FOLLOW_LINKS),
2, lockFileLister);
return lockFileLister.getLocksBySite();
}
}

View file

@ -1,68 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import java.util.Set;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.GetServiceBackupPrimarySiteRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* Handler for <code>CheckServiceBackupPrimarySiteRequest</code>. Determines
* whether the specified site id has been configured as one of service backup's
* primary sites.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 10, 2014 DR-17401 lshi Initial creation
*
* </pre>
*
* @author lshi
* @version 1.0
*/
public class GetServiceBackupPrimarySiteHandler implements
IRequestHandler<GetServiceBackupPrimarySiteRequest> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
*/
@Override
public ServerResponse<Set<String>> handleRequest(
GetServiceBackupPrimarySiteRequest request) throws Exception {
ServerResponse<Set<String>> sr = new ServerResponse<Set<String>>();
Set<String> primarySites = SvcBackupUtil.getPrimarySites();
sr.setPayload(primarySites);
return sr;
}
}

View file

@ -1,60 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.GetServiceBackupServerRequest;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 12, 2011 bphillip Initial creation
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public class GetServiceBackupServerRequestHandler implements
IRequestHandler<GetServiceBackupServerRequest> {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
*/
@Override
public Object handleRequest(GetServiceBackupServerRequest request)
throws Exception {
return (String) SvcBackupUtil.getSvcBackupProperties()
.get("SVCBU_HOST");
}
}

View file

@ -1,77 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import org.apache.commons.lang3.BooleanUtils;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.ImportConfRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code ImportConfRequest}. Causes an MHS request to be
* sent to have the configuration data for the specified site to be sent to this
* server. Should be used only during service backup mode.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 04, 2011 bphillip Initial creation
* Mar 20, 2013 1447 dgilling Support troubleshooting mode
* added to match A1 DR 21404.
* Mar 17, 2015 4103 dgilling Support new Service Backup GUI.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class ImportConfRequestHandler implements
IRequestHandler<ImportConfRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ImportConfRequestHandler.class);
@Override
public JobProgress handleRequest(final ImportConfRequest request)
throws Exception {
try {
statusHandler.info("Requesting GFE configuration for site "
+ request.getFailedSite());
SvcBackupUtil.execute("request_configuration", request
.getFailedSite().toLowerCase(), Integer
.toString(BooleanUtils.toInteger(request.isTrMode())));
} catch (Exception e) {
statusHandler.error(
"Error executing request_configuration for site "
+ request.getFailedSite(), e);
return JobProgress.FAILED;
}
return JobProgress.SUCCESS;
}
}

View file

@ -1,71 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.uf.common.dataplugin.gfe.request.ImportDigitalDataRequest;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code ImportDigitalDataRequest}. Causes an MHS request
* to be sent to have the GFE grids for the specified site to be sent to this
* server. Should be used only during service backup mode.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 04, 2011 bphillip Initial creation
* Mar 17, 2015 4103 dgilling Support new Service Backup GUI.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class ImportDigitalDataRequestHandler implements
IRequestHandler<ImportDigitalDataRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ImportDigitalDataRequestHandler.class);
@Override
public JobProgress handleRequest(final ImportDigitalDataRequest request)
throws Exception {
try {
statusHandler.info("Requesting GFE grids for site "
+ request.getFailedSite());
SvcBackupUtil.execute("request_grids", request.getFailedSite()
.toLowerCase());
} catch (Exception e) {
statusHandler.error("Error executing request_grids for site "
+ request.getFailedSite(), e);
return JobProgress.FAILED;
}
return JobProgress.SUCCESS;
}
}

View file

@ -1,82 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.edex.plugin.gfe.util.SendNotifications;
import com.raytheon.uf.common.dataplugin.gfe.request.ProcessReceivedConfRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.ServiceBackupJobStatusNotification;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code ProcessReceivedConfRequest}. Triggered when MHS
* sends the requested configuration data from {@code ImportConfRequestHandler}
* to this server. Will call the service backup script process_configuration to
* validate and install the site's configuration data.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 04, 2011 bphillip Initial creation
* Feb 13, 2015 #4103 dgilling Pass site id to process_configuration.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class ProcessReceivedConfRequestHandler implements
IRequestHandler<ProcessReceivedConfRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ProcessReceivedConfRequestHandler.class);
@Override
public JobProgress handleRequest(final ProcessReceivedConfRequest request)
throws Exception {
try {
SvcBackupUtil.execute("process_configuration",
request.getReceivedConfFile(), request.getSiteID());
statusHandler.info("Import Configuration Complete for site "
+ request.getSiteID());
} catch (Exception e) {
statusHandler.error("Error Processing Configuration Data for site "
+ request.getSiteID(), e);
SendNotifications.send(new ServiceBackupJobStatusNotification(
"importConfiguration", JobProgress.FAILED, request
.getSiteID()));
return JobProgress.FAILED;
}
SendNotifications
.send(new ServiceBackupJobStatusNotification(
"importConfiguration", JobProgress.SUCCESS, request
.getSiteID()));
return JobProgress.SUCCESS;
}
}

View file

@ -1,79 +0,0 @@
/**
* 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.edex.plugin.gfe.server.handler.svcbu;
import com.raytheon.edex.plugin.gfe.svcbackup.SvcBackupUtil;
import com.raytheon.edex.plugin.gfe.util.SendNotifications;
import com.raytheon.uf.common.dataplugin.gfe.request.ProcessReceivedDigitalDataRequest;
import com.raytheon.uf.common.dataplugin.gfe.server.notify.ServiceBackupJobStatusNotification;
import com.raytheon.uf.common.dataplugin.gfe.svcbu.JobProgress;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Request handler for {@code ProcessReceivedDigitalDataRequest}. Triggered when
* MHS sends the requested GFE grids from
* {@code ImportDigitalDataRequestHandler} to this server. Will call the service
* backup script process_grids to import the site's grids.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 04, 2011 bphillip Initial creation
* Feb 13, 2015 #4103 dgilling Pass site id to process_grids.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public final class ProcessReceivedDigitalDataRequestHandler implements
IRequestHandler<ProcessReceivedDigitalDataRequest> {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ProcessReceivedDigitalDataRequestHandler.class);
@Override
public JobProgress handleRequest(
final ProcessReceivedDigitalDataRequest request) throws Exception {
try {
SvcBackupUtil.execute("process_grids",
request.getReceivedDataFile(), request.getSiteID());
statusHandler.info("Import Data Complete for site "
+ request.getSiteID());
} catch (Exception e) {
statusHandler.error("Error Processing Digital Data for site "
+ request.getSiteID(), e);
SendNotifications.send(new ServiceBackupJobStatusNotification(
"importGrids", JobProgress.FAILED, request.getSiteID()));
return JobProgress.FAILED;
}
SendNotifications.send(new ServiceBackupJobStatusNotification(
"importGrids", JobProgress.SUCCESS, request.getSiteID()));
return JobProgress.SUCCESS;
}
}

View file

@ -1,88 +0,0 @@
/**
* 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.edex.plugin.gfe.svcbackup;
import java.util.Date;
import java.util.TimerTask;
import com.raytheon.edex.plugin.gfe.server.handler.svcbu.ExportGridsRequestHandler;
import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest;
import com.raytheon.uf.common.dataplugin.gfe.request.ExportGridsRequest.ExportGridsMode;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* Cron job that exports GFE's primary sites' grids. Primary sites are
* determined by a combination of the env. variable AW_SITE_IDENTIFIER and the
* PRIMARY_SITES entry in svcbu.properties.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 03, 2011 bphillip Initial creation
* Apr 30, 2013 #1761 dgilling Read list of sites to export grids
* for from svcbu.properties.
* May 02, 2013 #1762 dgilling Move code to read PRIMARY_SITES setting
* to SvcBackupUtil.
* Mar 17, 2015 #4103 dgilling Stop using ServiceBackupNotificationManager.
*
* </pre>
*
* @author bphillip
* @version 1.0
*/
public class ExportGridsTask extends TimerTask {
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(ExportGridsTask.class);
public ExportGridsTask(Date executionTime) {
statusHandler.info("Export grids cron scheduled for execution at: "
+ executionTime);
}
/*
* (non-Javadoc)
*
* @see java.util.TimerTask#run()
*/
@Override
public void run() {
final ExportGridsRequestHandler reqHandler = new ExportGridsRequestHandler();
for (String site : SvcBackupUtil.getPrimarySites()) {
statusHandler
.info("Export Grids to central server cron started for site "
+ site + ".");
try {
reqHandler.handleRequest(new ExportGridsRequest(site,
ExportGridsMode.CRON));
} catch (Exception e) {
statusHandler.error(
"Export Grids to central server cron failed to execute for site "
+ site + ".", e);
}
}
}
}

View file

@ -1,319 +0,0 @@
/**
* 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.edex.plugin.gfe.svcbackup;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.Sets;
import com.raytheon.uf.common.auth.exception.AuthorizationException;
import com.raytheon.uf.common.auth.user.IUser;
import com.raytheon.uf.common.dataplugin.gfe.exception.GfeException;
import com.raytheon.uf.common.dataplugin.gfe.request.AbstractGfePrivilegedRequest;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.LocalizationUtil;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.localization.exception.LocalizationException;
import com.raytheon.uf.common.util.RunProcess;
import com.raytheon.uf.edex.auth.AuthManager;
import com.raytheon.uf.edex.auth.AuthManagerFactory;
import com.raytheon.uf.edex.auth.authorization.IAuthorizer;
import com.raytheon.uf.edex.auth.resp.AuthorizationResponse;
import com.raytheon.uf.edex.core.EDEXUtil;
import com.raytheon.uf.edex.site.SiteAwareRegistry;
/**
*
* Utility class for Service Backup
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 09, 2009 bphillip Initial creation
* Sep 19, 2011 10955 rferrel make sure process destroy is called.
* Jun 12, 2012 00609 djohnson Use EDEXUtil for EDEX_HOME.
* Nov 15, 2012 15614 jdynina Added check for national center
* May 02, 2013 #1762 dgilling Remove check for national center, add
* method to retrieve list of svcbu
* sites.
* May 28, 2014 3211 njensen Use IAuthorizer instead of IRoleStorage
* Jul 10, 2014 2914 garmendariz Remove EnvProperties
* Feb 17, 2015 4103 dgilling Add getLockDir for specific site, code
* cleanup.
* Mar 27, 2015 4103 dgilling Support new location for svcbu.properties.
* Dec 15, 2015 5166 kbisanz Update logging to use SLF4J
* Jul 15, 2016 5747 dgilling Move edex_static to common_static.
* Oct 24, 2016 5951 dgilling Cleanup logging in executeProcess.
*
* </pre>
*
* @author bphillip
*/
public class SvcBackupUtil {
private static final String LOCALIZATION = "Localization";
public static final String OPERATION_FAIL = "Failure";
public static final String OPERATION_SUCCESS = "Success";
private static final String SVCBU_PROPS_PATH = LocalizationUtil.join("gfe",
"config", "svcbu.properties");
/** The logger instance */
protected static transient Logger logger = LoggerFactory
.getLogger(SvcBackupUtil.class);
/**
* A private constructor so that Java does not attempt to create one for us.
* As this class should not be instantiated, do not attempt to ever call
* this constructor; it will simply throw an AssertionError.
*
*/
private SvcBackupUtil() {
throw new AssertionError();
}
public static String execute(String... args) throws Exception {
String[] newArgs = new String[args.length + 1];
newArgs[0] = "sh";
System.arraycopy(args, 0, newArgs, 1, newArgs.length - 1);
return executeProcess(newArgs);
}
/**
* Executes a process using the java.lang.ProcessBuilder.
* <p>
* The first argument is the command to execute. The proceeding arguments
* are the arguments to pass to the command for execution
*
* @param args
* First argument is the command. The proceeding arguments are
* the arguments to pass to the command for execution
* @return The output of the process
* @throws GfeException
* If errors occur while executing the process
*/
private static String executeProcess(String... args) throws GfeException {
RunProcess proc = RunProcess.getRunProcess();
ProcessBuilder pBuilder = new ProcessBuilder();
pBuilder.environment().put("LOCALIZATION_PATH",
EDEXUtil.getEdexUtility());
pBuilder.environment().put("AWIPS_HOME", "/awips2/");
pBuilder.redirectErrorStream(true);
pBuilder.command(args);
try {
proc.setProcess(pBuilder.start());
} catch (IOException e) {
throw new GfeException("Error executing process", e);
}
int exitValue = 0;
String processOutput = "";
exitValue = proc.waitFor();
if (proc.isProcessInterrupted()) {
throw new GfeException("Process interrupted");
}
processOutput = proc.getStdout();
if (exitValue != 0) {
if (StringUtils.isNotBlank(processOutput)) {
String msg = String.format(
"Command [%s] terminated abnormally: \n%s",
StringUtils.join(args, ' '), processOutput);
logger.error(msg);
}
throw new GfeException("Process terminated abnormally");
}
return processOutput;
}
/**
* Examines the InputStream of a process and extracts any output into a
* String
*
* @param p
* The process to get the output from
* @return The output
* @throws GfeException
* If problems occur reading the process output
*/
public static String getProcessOutput(Process p) throws GfeException {
String retVal = null;
InputStream in = p.getInputStream();
StringBuilder out = new StringBuilder();
int read = 0;
final byte[] buffer = new byte[0x10000];
try {
do {
read = in.read(buffer, 0, buffer.length);
if (read > 0) {
out.append(new String(buffer), 0, read);
}
} while (read >= 0);
} catch (IOException e) {
throw new GfeException("Error reading process output", e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
logger.error("Unable to close process input stream!", e);
}
}
try {
p.getOutputStream().close();
} catch (IOException e1) {
logger.error("Unable to close process output stream!", e1);
}
try {
p.getErrorStream().close();
} catch (IOException e1) {
logger.error("Unable to close process error stream!", e1);
}
}
retVal = out.toString();
if (retVal.endsWith("\n")) {
retVal = retVal.substring(0, retVal.length() - 1);
}
return retVal;
}
public static Properties getSvcBackupProperties() {
Properties svcbuProperties = new Properties();
IPathManager pathMgr = PathManagerFactory.getPathManager();
LocalizationFile basePropsFile = pathMgr.getLocalizationFile(pathMgr
.getContext(LocalizationType.COMMON_STATIC,
LocalizationLevel.BASE),
SVCBU_PROPS_PATH);
try (InputStream input = basePropsFile.openInputStream()) {
svcbuProperties.load(input);
} catch (IOException | LocalizationException e) {
logger.error("Unable to load BASE level svcbu.properties file.", e);
}
LocalizationFile sitePropsFile = pathMgr.getLocalizationFile(pathMgr
.getContextForSite(LocalizationType.COMMON_STATIC,
EDEXUtil.getEdexSite()),
SVCBU_PROPS_PATH);
if (sitePropsFile.exists()) {
try (InputStream input = sitePropsFile.openInputStream()) {
svcbuProperties.load(input);
} catch (IOException | LocalizationException e) {
logger.error(
"Unable to load SITE level svcbu.properties file.", e);
}
}
return svcbuProperties;
}
/**
* Returns the base lock directory for service backup. All site specific
* lock directories will be children to this directory.
*
* @return The {@code Path} that represents the base directory for service
* backup locks.
*/
public static Path getLockDir() {
String lockDir = SvcBackupUtil.getSvcBackupProperties()
.getProperty("LOCK_DIR");
return Paths.get(lockDir);
}
/**
* Returns the site-specific lock directory for service backup.
*
* @param siteID
* The 3-character site identifier.
* @return he {@code Path} that represents the site-specific directory for
* service backup locks.
*/
public static Path getLockDir(final String siteID) {
return getLockDir().resolve(siteID.toUpperCase());
}
public static AuthorizationResponse authorizeWithLocalization(IUser user,
AbstractGfePrivilegedRequest request)
throws AuthorizationException {
AuthManager manager = AuthManagerFactory.getInstance().getManager();
IAuthorizer auth = manager.getAuthorizer();
String roleId = request.getRoleId();
if (auth.isAuthorized(roleId, user.uniqueId().toString(),
LOCALIZATION)) {
return new AuthorizationResponse(true);
}
return new AuthorizationResponse(false,
"User, " + user
+ ", is not authorized to perform request needing role: "
+ roleId);
}
public static Set<String> getPrimarySites() {
Properties svcbuProps = SvcBackupUtil.getSvcBackupProperties();
String siteList = EDEXUtil.getEdexSite();
if (svcbuProps != null) {
String propVal = svcbuProps.getProperty("PRIMARY_SITES", "").trim();
if (!propVal.isEmpty()) {
siteList = propVal;
}
}
String[] sites = siteList.split(",");
Set<String> retVal = new HashSet<>(sites.length, 1.0f);
Set<String> validSites = Sets
.newHashSet(SiteAwareRegistry.getInstance().getActiveSites());
for (String site : sites) {
String siteId = site.trim().toUpperCase();
if (!siteId.isEmpty()) {
if (validSites.contains(siteId)) {
retVal.add(siteId);
} else {
final String msg = "Service backup primary site " + site
+ " is not a currently activated site. Service backup and export grids tasks cannot be run for this site. Check the PRIMARY_SITES setting in svcbu.properties.";
logger.warn(msg);
}
}
}
return retVal;
}
}

View file

@ -1,74 +0,0 @@
/**
* 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.edex.plugin.gfe.svcbackup;
import com.raytheon.uf.common.dataplugin.gfe.util.FilePurger;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.util.TimeUtil;
/**
* Bean to purge outdated log files from service backup logs directory. Expected
* to be scheduled by camel using a cron job. Can set the number of days to
* retain logs via the setting purge.svcbu.logs.retention in
* com.raytheon.edex.plugin.gfe.properties.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 03, 2013 jdynina Initial creation
* Feb 24, 2015 #4103 dgilling Rewrite to use FilePurger.
*
* </pre>
*
* @author jdynina
* @version 1.0
*/
public final class SvcbuCleanupLogsTask {
private static final String DEFAULT_LOG_DIR = "/awips2/GFESuite/ServiceBackup/logs";
private final IUFStatusHandler statusHandler = UFStatus
.getHandler(SvcbuCleanupLogsTask.class);
private final FilePurger logPurger;
public SvcbuCleanupLogsTask(int daysToRetain) {
long purgeAge = daysToRetain * TimeUtil.MILLIS_PER_DAY;
String logDirectory = SvcBackupUtil.getSvcBackupProperties()
.getProperty("IFPS_LOG", DEFAULT_LOG_DIR);
this.logPurger = new FilePurger(logDirectory, purgeAge);
}
public void run() {
statusHandler.info("Cleanup service backup logs cron started.");
try {
logPurger.purge();
} catch (Exception e) {
statusHandler
.error("Cleanup service backup logs cron threw an unhandled exception.",
e);
}
}
}

View file

@ -1,144 +0,0 @@
# ----------------------------------------------------------------------------
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 10/22/2015 DR #17873 lshi remove quotes from default
# SVCBU_USER_ID
#
#################################################################
#Variables used by service backup:
#
# AWIPS_HOME: The AWIPS II installation directory.
#
# GFESUITE_HOME: The server directory containing files and programs
# used by GFE during Service Backup
#
# GFESUITE_BIN: Directory containing GFE server side utility
# programs including ifpnetCDF and iscMosaic
#
# SVCBU_HOME: Directory used by service backup as a sandbox for
# constructing files to be sent and for processing
# received files.
#
# LOCALIZATION_PATH: This is the path to the root of the localization
# directory. This path is used for properly importing
# and exporting configuration data
#
# IFPS_LOG: Directory containing logs for the service backup
# operations.
#
# IFPS_DATA: Directory containing the svcbu_export_elements file.
# This file is used to specify which weather elements are
# packaged and sent when exporting digital data for a
# site.
#
# LOCK_DIR: Directory used for lock files. Each Service Backup
# operation maintains a lock file during its execution.
# The lock remains for the duration of the operation and
# is erased upon completion to prevent simultaneous
# operations from occurring.
#
# SCRIPTS_DIR: Directory containing the scripts used by service
# backup
#
# CAVE_LAUNCH_SCRIPT: This path points to the script which starts GFE. This
# variable is read when the user hits the 'Enable' button
# On the service backup GUI.
#
# SVCBU_HOST: Server where the service backup scripts will be
# executed.
#
# MSG_SEND_COMMAND: The command executed to send a message via the message handling
# system. This value will usually be msg_send. But, it can be
# changed to a different command in a test environment.
#
# CDSPORT: This is the port on which the Thrift Client listens
# for script execution events.
#
# SVCBU_DB: Defines which database to use for exporting
# grids to central server for service backup.
# VALID VALUES: Fcst
# Official (default)
#
# SVCBU_TRIM_ELEMS: Indication of whether ifpnetCDF needs to trim
# off elements while exporting grids to central
# server.
# VALID VALUES: 1 - To do element trimming
# 0 - To disable element trimming
# Note: ${IFPS_DATA}/svcbu_export_elements.ccc
# file has to be present for this to work. This file
# will contain list of elements to include in the
# netcdf file that's being sent over to central srv.
#
# SVCBU_FAILED_SITE_PORT: Unused
#
# SVCBU_GRIDAREA: The name of the edit area used when exporting grids
# to the central server for service backup and
# imported to the Restore databse after service backup.
# DEFUALT VALUE: ISC_Send_Area
#
# SVCBU_ADDRESSEE: The name of the msg_send addressee. Will be used to
# pass with -a flag of msg_send. (NCF use only).
#
# SVCBU_WMO_HEADER: The WMO header that will be used to pass in calls to
# msg_send with -i argument. This will be empty to
# begin with. Should not be changed. (NCF use only)
#
# EXPORT_GRID Indicate the ways of grid being exported
# VALID VALUES: 0 = do not export grids
# 1 = grids are exported by quartz timer
# at 15 after each hour, the service
# backup GUI, and from GFE via the
# 'Send Grids to NDFD...' script
# 2 = grids are exported only by the service backup GUI and from GFE via the 'Send
# Grids to NDFD...' script'
#
# SVCBU_USER Indicates that the site can configure a special user to
# run GFE when in service backup
# VALID VALUES: 0 = do not use a designated user to run
# GFE when in service backup
# 1 = use a designated user to run GFE
# when in service backup
#
# SVCBU_USER_ID The user id of the designated user to run GFE when
# in service backup
#
# PRIMARY_SITES (Optional) For dual-domain sites, a comma-separated
# list of sites for the export grids cron to run for
# instead of the site defined as AW_SITE_IDENTIFIER. If
# this setting is empty or not defined, cron will only
# export grids for site set as AW_SITE_IDENTIFIER.
#
#
# Directories used by Service Backup
GFESUITE_HOME=/awips2/GFESuite
GFESUITE_BIN=/awips2/GFESuite/bin
SVCBU_HOME=/awips2/GFESuite/ServiceBackup/svcbu
LOCALIZATION_PATH=/awips2/edex/data/utility
IFPS_LOG=/awips2/GFESuite/ServiceBackup/logs
IFPS_DATA=/awips2/GFESuite/ServiceBackup/data
LOCK_DIR=/awips2/GFESuite/ServiceBackup/locks
SCRIPTS_DIR=/awips2/GFESuite/ServiceBackup/scripts
CAVE_LAUNCH_SCRIPT=/awips2/cave/cave.sh
SVCBU_HOST=ec
MSG_SEND_COMMAND=msg_send
CDSPORT=9581
SVCBU_DB=Official
SVCBU_TRIM_ELEMS=1
SVCBU_FAILED_SITE_PORT=98000001
SVCBU_GRIDAREA=ISC_Send_Area
SVCBU_ADDRESSEE="ANCF"
SVCBU_WMO_HEADER=SVCBKPIFP
SVCBU_USER=0
# Do not use quotes when setting SVCBU_USER_ID
# Example syntax: SVCBU_USER_ID=backuser
SVCBU_USER_ID=
EXPORT_GRID=1
PRIMARY_SITES=

View file

@ -1,656 +0,0 @@
##
# 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.
##
# ----------------------------------------------------------------------------
# This software is in the public domain, furnished "as is", without technical
# support, and with no warranty, express or implied, as to its usefulness for
# any purpose.
#
# Author: mathewson
# ----------------------------------------------------------------------------
##
#
# This class provides interfaces to the ISC Routing Table Web Service.
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 12/10/14 #4953 randerso Cleaned up imports,
# improved spawning of shell cmd
# 03/10/2015 #4129 randerso Refactored server selection code into a reusable method
# 07/11/2016 #5774 randerso Change to send WFO message to all active
# IFP servers, not just "best"
#
##
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
import socket
import urllib, urllib2, time, os, copy, string
import LogStream
import JUtil
import iscUtil
class IrtAccess():
#Constructor taking the web URL for the ISC Routing Table
def __init__(self, ancfURL=None, bncfURL=None, logger=None):
self.__addrs = {}
self.__addrs['ANCF'] = ancfURL
self.__addrs['BNCF'] = bncfURL
self.__registered = None #flag to indicate whether we registered
if logger is not None:
self.__logger=logger
else:
self.__logger=iscUtil.getLogger("irtAccess","irtServer.log")
def logEvent(self,*msg):
self.__logger.info(iscUtil.tupleToString(*msg))
def logProblem(self,*msg):
self.__logger.error(iscUtil.tupleToString(*msg))
def logException(self,*msg):
self.__logger.exception(iscUtil.tupleToString(*msg))
def logVerbose(self,*msg):
self.__logger.debug(iscUtil.tupleToString(*msg))
def logDebug(self,*msg):
self.logVerbose(iscUtil.tupleToString(*msg))
def __checkArgs(self,parmsWanted, gridDims,gridBoundBox, iscWfosWanted):
if type(parmsWanted) is not list:
parmsWanted = JUtil.javaStringListToPylist(parmsWanted)
if type(gridDims) is not list:
pylist = []
size = gridDims.size()
for i in range(size):
pylist.append(gridDims.get(i).intValue())
gridDims = pylist
if type(gridBoundBox) is not tuple:
gridBoundBox = ((gridBoundBox.get(0).doubleValue(),gridBoundBox.get(1).doubleValue()),(gridBoundBox.get(2).doubleValue(),gridBoundBox.get(3).doubleValue()))
if type(iscWfosWanted) is not list:
iscWfosWanted = JUtil.javaStringListToPylist(iscWfosWanted)
return parmsWanted, gridDims, gridBoundBox, iscWfosWanted
# Registration call for the ISC Routing Table. Returns True if okay, i.e.,
# you are registered.
def register(self, mhsid, serverHost, serverPort, serverProtocol,
site, parmsWanted, gridDims, gridProj, gridBoundBox, iscWfosWanted):
parmsWanted, gridDims,gridBoundBox, iscWfosWanted = self.__checkArgs(parmsWanted, gridDims,gridBoundBox, iscWfosWanted)
if self.__registered is not None:
self.unregister(self.__registered) #unregister, then reset table
self.__regInfo = None
self.__timeToReRegister = None
# shorten parmsWanted list, i.e., don't need the "_SFC".
for x in xrange(len(parmsWanted)):
idx = parmsWanted[x].find("_SFC")
if idx != -1:
parmsWanted[x] = parmsWanted[x][0:idx]
# set up registration information
self.__regInfo = {'mhsid': mhsid, 'server': serverHost,
'port': serverPort, 'protocol': serverProtocol, 'site': site,
'parms': ",".join(parmsWanted), 'dims': self.__listConvert(gridDims),
'proj': gridProj, 'Bbox': self.__nestedTupleConvert(gridBoundBox),
'wfos': ",".join(iscWfosWanted)}
# set up unregistration information
self.__unregInfo = {'mhsid': mhsid, 'server': serverHost,
'port': serverPort, 'protocol': serverProtocol,
'wfos': ",".join(iscWfosWanted), 'site': site}
okay = self.__doRegister() #perform registration
return okay
# Call made by ifpServer to check and perform re-registration.
# Returns True if no errors.
def checkForReregister(self):
if not self.__registered:
return True #do nothing if not registered
# check for change of IRT web service
if self.__baseURL() != self.__registered:
self.unregister(self.__registered)
return self.__doRegister()
# check for time to re-register
if time.time() >= self.__timeToReRegister:
return self.__doRegister()
return True
# Call to unregister from the ISC Routing Table. Returns True if
# successful, false otherwise. The irtAddress overrides the calculated
# IRT web address if present.
def unregister(self, irtAddress=None):
if not self.__registered:
return True #do nothing if never registered
#now unregister
status, xml, transIRT = self.__callIRT('unregister', self.__unregInfo,
irtAddress)
if status is False:
return False
# decode XML, read status
try:
tree = ElementTree.ElementTree(ElementTree.XML(xml))
except:
self.logProblem("Malformed XML on unregister: ", xml)
return False
element = tree.getroot()
if element is None:
self.logProblem("status tag missing in XML for unregister")
return False
status = None
for attr, value in element.items():
if attr == 'ok':
status = value
break
if status is None:
self.logProblem("ok attr missing in status tag for unregister")
return False
if status == "1":
self.__registered = None #reset registration flag
self.logEvent("Unregistered from IRT")
return True
else:
self.logProblem("Error on unregistration", element.text)
return False
# routing to get the list of destination servers that are active for
# the given domain. Returns status flag and XML string.
def getSendAddrs(self, sourceDomain):
sourceDomainDict = {'wfoid': sourceDomain}
status, xml, transIRT = self.__callIRT('getaddrs', sourceDomainDict)
return status, xml
# routine to get the list of servers that are active for the given list
# of domains. Returns status flag and XML string.
def getServers(self, wfos):
if type(wfos) is not list:
wfos = JUtil.javaStringListToPylist(wfos)
wfoDict = {'wfoids': ",".join(wfos)}
status, xml, transIRT = self.__callIRT('getservers', wfoDict)
return status, xml
# registers with the ISC routing table. Returns True if successful,
# False otherwise.
def __doRegister(self):
status, xml, transIRT = self.__callIRT('register', self.__regInfo)
if status is False:
return False
# decode XML
try:
tree = ElementTree.ElementTree(ElementTree.XML(xml))
except:
self.logProblem("Malformed XML on register: ", xml)
return False
element = tree.getroot() #status tag is the root tag
if element is None:
self.logProblem("status tag missing in XML for register")
return False
ok = None
for attr, value in element.items():
if attr == 'ok':
ok = value
break
if ok is None:
self.logProblem("ok field missing in status tag for register")
return False
# get the ok flag
if ok == "1":
isoTimeStr = element.text
idx = isoTimeStr.find(".")
if idx != -1:
isoTimeStr = isoTimeStr[0:idx] #eliminate sub-seconds if any
try:
# switch to GMT0 for time conversions
prevTZ = os.environ.get('TZ', None)
os.environ['TZ'] = "GMT0"
time.tzset()
# Fix to correct importing of the time.strptime method
importError = True
while importError:
try:
self.__timeToReRegister = time.mktime(time.strptime(isoTimeStr,"%Y-%m-%dT%H:%M:%S"))
importError=False
except ImportError:
importError = True
# reset TZ environment variable to previous state
if prevTZ:
os.environ['TZ'] = prevTZ
time.tzset()
except ValueError:
self.logProblem("time string has bad format", isoTimeStr)
return False
self.__registered = transIRT #set registration flag
self.logEvent("IRT Registration Successful. ",
"Re-register time: ",
time.asctime(time.gmtime(float(self.__timeToReRegister))))
return True #okay registration
else:
self.logProblem("Error on registration: ", element.text)
return False
# returns the appropriate (id, url) for the IRT web service.
def __baseURL(self):
statusFile = '/data/mhs/ncfstatus'
#statusFile = '/scratch/ncfstatus'
ncf = "ANCF"
try:
fp = open(statusFile, 'rb')
ncf = fp.read()
ncf = ncf.strip().upper()
except IOError, e:
pass
#self.logProblem("Can't read NCF status file: ", statusFile,
# "assuming ANCF...")
return ncf, self.__addrs.get(ncf)
# makes call to ISC routing Table service, calling the given function,
# with the given attributes (dictionary). Returns the status of the
# call (bool), the XML returned, and the IRT address (id, url).
# The optional IRTAddress is used to force the call to a specific
# IRT (id, url).
def __callIRT(self, function, attributes, irtAddress=None):
retries = 0
tDuration = 0.000
startT = time.time()
#use normal method to calculate IRT address
if irtAddress is None:
irtid, url = self.__baseURL()
acturl = url + "/" + function
else:
irtid, url = irtAddress
acturl = url + "/" + function
data = urllib.urlencode(attributes)
while True:
try:
prevtimeout = socket.setdefaulttimeout(60.0)
#check for update of ANCF/BNCF
if irtAddress is None:
irtid, url = self.__baseURL()
acturl = url + "/" + function
fd = urllib2.urlopen(acturl, data)
xml = fd.read()
fd.close()
socket.setdefaulttimeout(prevtimeout)
break
except urllib2.URLError, e:
problem = "URLError"
problem1 = e
except urllib2.HTTPError, e:
problem = "HTTPError"
problem1 = e
except IOError, e:
problem = "IOError"
problem1 = e
except Exception, e:
problem = "Exception"
problem1 = e
#failed transaction
endT = time.time()
tDuration = endT - startT
self.logProblem("IRT access: ", problem, function,
"t=%-7.3f" % tDuration, "retries=%-1d" % retries,
"IRT=[%s %s]" % (irtid, url), attributes, problem1)
#try again?
retries = retries + 1
if retries > 5:
socket.setdefaulttimeout(prevtimeout)
return False, "", (irtid, url) #complete failure
#successful transaction
endT = time.time()
tDuration = endT - startT
self.logEvent("IRT access: okay", function,
"t=%-7.3f" % tDuration, "retries=%-1d" % retries,
"IRT=[%s %s]" % (irtid, url), attributes)
self.logDebug("XML: ", xml)
return True, xml, (irtid, url)
# list convert to comma-deliminated string
def __listConvert(self, a):
s = ""
for x in xrange(len(a)):
if len(s):
s += "," + `a[x]`
else:
s += `a[x]`
return s
# domain (x,y),(xe,ye) convert to comma-deliminated string
def __nestedTupleConvert(self, a):
s = ''
for x in xrange(len(a)):
for y in xrange(len(a[x])):
if len(s):
s += "," + `a[x][y]`
else:
s += `a[x][y]`
return s
#----------------------------------------------------------------------
# Utility Routines ----------------------------------------------------
#----------------------------------------------------------------------
def addAddressXML(self, root, serverInfo):
#adds the address XML with the source server information
#to the root XML tree. Input server information is a dict with
#following keys: "mhsid",'host','port','protocol','site'
# Returns element for address (in case additional info is required)
addressE = SubElement(root, 'address')
mhsidE = SubElement(addressE, 'mhsid')
mhsidE.text = serverInfo.get('mhsid', "?")
serverE = SubElement(addressE, 'server')
serverE.text = serverInfo.get('host', "?")
portE = SubElement(addressE, 'port')
portE.text = str(serverInfo.get('port', "?"))
protocolE = SubElement(addressE, 'protocol')
protocolE.text = str(serverInfo.get('protocol', "?"))
siteE = SubElement(addressE, 'site')
siteE.text = serverInfo.get('site', "?")
#optional components "location" "area" "welist"
if serverInfo.has_key('domain') and serverInfo['domain'] is not None:
d = serverInfo['domain']
locationE = SubElement(addressE, 'location', proj=d['proj'],
origx=str(d['origx']), origy=str(d['origy']),
extx=str(d['extx']), exty=str(d['exty']))
if serverInfo.has_key('area') and serverInfo['area'] is not None:
d = serverInfo['area']
areaE = SubElement(addressE, 'area', xdim=str(d['xdim']),
ydim=str(d['ydim']))
if serverInfo.has_key('parms') and serverInfo['parms'] is not None:
parms = serverInfo['parms']
self.addWelistXML(addressE, parms)
return addressE
def addSourceXML(self, root, serverInfo):
#adds the source XML with the source server information to the root
#XML tree. Input server information is a dict with
#following keys: "mhsid",'host','port','protocol','site'
#Returns the "source" element and the "address" element.
sourcesE = SubElement(root, 'source')
addressE = self.addAddressXML(sourcesE, serverInfo)
return sourcesE, addressE
def addDestinationXML(self, root, serverInfos):
#adds the destinationXML and server information to the XML root.
# Input server information is a list of dicts with
#following keys: "mhsid",'host','port','protocol','site'
# Returns the destinations elment.
destinationsE= SubElement(root, 'destinations')
for serverInfo in serverInfos:
self.addAddressXML(destinationsE, serverInfo)
return destinationsE
def addWelistXML(self, root, parms):
#adds the welist and parms to the XML root. Returns the welist
#element.
welistE = SubElement(root, 'welist')
for parm in parms:
parmE = SubElement(welistE, 'parm')
parmE.text = parm
return welistE
def decodeXMLAddress(self, element):
#decodes the address element which identifies the server
#Returns None if not address tag, returns None as part of the
#tuple return if that value is not defined. Otherwise returns
#a dict with keys "mhsid",'host','port','protocol','site','parms',
#'domain'.
dict = {}
if element.tag != "address":
return None #not address tag
parms = None
for attrE in element:
if attrE.tag == "mhsid":
dict['mhsid'] = attrE.text
elif attrE.tag == "server":
dict['host'] = attrE.text
elif attrE.tag == "port":
dict['port'] = attrE.text
elif attrE.tag == "protocol":
dict['protocol'] = attrE.text
elif attrE.tag == "site":
dict['site'] = attrE.text
elif attrE.tag == "welist":
parmsE = attrE.getchildren()
for parmE in parmsE:
if parms is None:
parms = []
if parmE.tag not in parms:
parms.append(parmE.text)
elif attrE.tag == "location":
domain = {}
for key, value in attrE.items():
domain[key] = value
dict['domain'] = domain
elif attrE.tag == "area":
size = {}
for key, value in attrE.items():
size[key] = value
dict['area'] = size
dict['parms'] = parms
return dict
def transmitFiles(self, subject, addresses, sourceWfo, attachments,
xmtScript):
# assembles the command and executes it.
# determine MHS WMO id for this message
wmoid = "TTAA00 "
if sourceWfo in ['SJU']:
wmoid += "TJSJ"
elif sourceWfo in ['AFG', 'AJK', 'HFO', 'GUM']:
wmoid += "P" + sourceWfo
elif sourceWfo in ['AER', 'ALU']:
wmoid += "PAFC"
elif len(sourceWfo) == 3:
wmoid += "K" + sourceWfo
elif len(sourceWfo) == 4:
wmoid += sourceWfo
else:
wmoid += "XXXX"
wmoid += " " + time.strftime("%d%H%M", time.gmtime(time.time()))
# Transmit files - do string substitution
if xmtScript is not None:
cmd = copy.deepcopy(xmtScript)
cmd = string.replace(cmd, "%SUBJECT", subject)
cmd = string.replace(cmd, "%ADDRESSES", ",".join(addresses))
cmd = string.replace(cmd, "%WMOID", "'" + wmoid + "'")
cmd = string.replace(cmd, "%ATTACHMENTS", ",".join(attachments))
self.logEvent("Transmit: ", cmd)
import siteConfig
from subprocess import Popen,PIPE
output,err = Popen(cmd, shell=True, stdout=PIPE,stderr=PIPE).communicate()
if output.find(siteConfig.GFESUITE_MHSID+"-") == -1:
alertMsg = "ISC Send failed transmission to : "+",".join(addresses)+" --> "+output+" "+err
self.logProblem(alertMsg)
else:
self.logEvent(output.rstrip())
if len(err) > 0:
self.logProblem(err.rstrip())
alertMsg="ISC data successfully transmitted to: "+",".join(addresses)
self.logEvent(alertMsg)
for file in attachments:
try:
os.remove(file)
except OSError:
self.logException("Error removing file: "+file)
def printServerInfo(self, serverInfo):
# assembles a string to print out the server information. serverInfo
# is a dict with keys "mhsid",'host','port','protocol','site'.
# Returns the string to print. All input values are strings.
mhsid = serverInfo.get('mhsid', '?')
host = serverInfo.get('host', '?')
port = serverInfo.get('port', '?')
protocol = serverInfo.get('protocol', '?')
site = serverInfo.get('site', '?')
s = "mhs=" + mhsid + ",host=" + host + ",port=" + port +\
",proto=" + protocol + ",site=" + site
return s
def createDestinationXML(self, destSites, requestingServer, findBestMatch=True):
#--------------------------------------------------------------------
# Assemble XML source/destination document
#--------------------------------------------------------------------
iscE = ElementTree.Element('isc')
self.addSourceXML(iscE, requestingServer)
self.logEvent("Requesting Server:", self.printServerInfo(requestingServer))
# who is running the domains requested?
status, xml = self.getServers(destSites)
if not status:
raise Exception('Failure to getServers from IRT')
# decode the XML
try:
serverTree = ElementTree.ElementTree(ElementTree.XML(xml))
serversE = serverTree.getroot()
except:
self.logException("Malformed XML from getServers()")
raise
if serversE.tag != "servers":
raise Exception("Servers packet missing from web server")
# process each requested domain returned to us
msgSendDest = []
chosenServers = []
matchingServers = []
for domainE in serversE:
if domainE.tag != "domain":
continue
domain = domainE.get('site')
servers = [] #list of servers for this domain
# decode each server in the domain
for addressE in domainE.getchildren():
info = self.decodeXMLAddress(addressE)
if info is None:
continue #not address tag
servers.append(info)
matchingServers.append(info)
# server search list in priority. The px3 entries are used for
# dual domain for AFC.
hp = [('dx4','98000000'),('px3', '98000000'), ('dx4','98000001'),
('px3', '98000001')]
if findBestMatch:
# choose one server from this domain, find first dx4, 98000000
# try to use one with the same mhsidDest as the site, which
# would be the primary operational GFE. Note that the px3 entries
# are for AFC.
found = False
for matchServer, matchPort in hp:
if found:
break
for server in servers:
if server['host'][0:3] == matchServer and \
server['port'] == matchPort and server['mhsid'] == domain:
chosenServers.append(server)
if server['mhsid'] not in msgSendDest:
msgSendDest.append(server['mhsid'])
found = True
break
# find first dx4, 98000000, but perhaps a different mhsid
# this is probably not the primary operational GFE
for matchServer, matchPort in hp:
if found:
break
for server in servers:
if server['host'][0:3] == matchServer and \
server['port'] == matchPort:
chosenServers.append(server)
if server['mhsid'] not in msgSendDest:
msgSendDest.append(server['mhsid'])
found = True
break
# if didn't find standard one, then take the first one, but don't
# take ourselves unless we are the only one.
if not found and servers:
for server in servers:
if server['mhsid'] != requestingServer['mhsid'] \
and server['host'] != requestingServer['host'] \
and server['port'] != requestingServer['port'] \
and server['site'] != requestingServer['site']:
chosenServers.append(server)
if server['mhsid'] not in msgSendDest:
msgSendDest.append(server['mhsid'])
found = True
break;
if not found:
chosenServers.append(servers[0])
if servers[0]['mhsid'] not in msgSendDest:
msgSendDest.append(servers[0]['mhsid'])
else:
for server in matchingServers:
chosenServers.append(server)
if server['mhsid'] not in msgSendDest:
msgSendDest.append(server['mhsid'])
# Display the set of matching servers
s = "Matching Servers:"
for x in matchingServers:
s += "\n" + self.printServerInfo(x)
self.logEvent(s)
# Display the chosen set of servers
s = "Chosen Servers:"
for x in chosenServers:
s += "\n" + self.printServerInfo(x)
self.logEvent(s)
self.addDestinationXML(iscE, chosenServers)
return msgSendDest, iscE

View file

@ -1,573 +0,0 @@
##
# 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.
##
#
# Port of IRT functionality from legacy ifpServer
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 07/14/09 1995 bphillip Initial Creation.
# 01/25/13 1447 dgilling Implement routines needed by
# iscDataRec for VTEC table
# sharing.
# 03/13/13 1759 dgilling Move siteConfig imports into
# functions where module is used
# to interact better with IscScript.
# 05/22/13 1759 dgilling Add missing import to
# makeISCrequest().
# 10/16/13 2475 dgilling Remove unneeded code to handle
# registration with IRT.
# 12/08/2014 4953 randerso Added support for sending/receiving TCV files
# Additional code clean up
# 03/05/2015 4129 randerso Fix exception handling on subprocess calls
# Fixed error when no TCV files were found
# 02/22/2016 5374 randerso Added support for sendWFOMessage
#
##
import cPickle
import LogStream, tempfile, os, sys, JUtil, subprocess, traceback, errno
import time, copy, string, iscUtil
from com.raytheon.edex.plugin.gfe.isc import IRTManager
from subprocess import CalledProcessError
PURGE_AGE = 30 * 24 * 60 * 60 # 30 days in seconds
def getLogger():
import logging
return iscUtil.getLogger("irtServer", logLevel=logging.DEBUG)
def logEvent(*msg):
getLogger().info(iscUtil.tupleToString(*msg))
def logProblem(*msg):
getLogger().error(iscUtil.tupleToString(*msg))
def logException(*msg):
getLogger().exception(iscUtil.tupleToString(*msg))
def logDebug(*msg):
getLogger().debug(iscUtil.tupleToString(*msg))
# called by iscDataRec when another site has requested the active table
# returns the active table, filtered, pickled.
def getVTECActiveTable(dataFile, xmlPacket):
import siteConfig
import VTECPartners
if not VTECPartners.VTEC_RESPOND_TO_TABLE_REQUESTS:
return #respond is disabled
#decode the data (pickled)
with open(dataFile, "rb") as fp:
info = cPickle.load(fp)
(mhsSite, reqsite, filterSites, countDict, issueTime) = info
#get the active table, and write it to a temporary file
from com.raytheon.uf.common.site import SiteMap
from com.raytheon.uf.edex.activetable import ActiveTable
from com.raytheon.uf.common.activetable import ActiveTableMode
from com.raytheon.uf.common.activetable import ActiveTableUtil
site4Id = SiteMap.getInstance().getSite4LetterId(siteConfig.GFESUITE_SITEID)
javaTable = ActiveTable.getActiveTable(site4Id, ActiveTableMode.OPERATIONAL)
dictTable = ActiveTableUtil.convertToDict(javaTable, siteConfig.GFESUITE_SITEID)
# we must convert this to a python hash using the A1 field naming conventions
# for cross-version compatibility
table = []
for i in xrange(dictTable.size()):
convRecord = JUtil.javaObjToPyVal(dictTable.get(i))
convRecord['oid'] = convRecord['officeid']
convRecord['vstr'] = convRecord['vtecstr']
convRecord['end'] = convRecord['endTime']
convRecord['start'] = convRecord['startTime']
convRecord['key'] = convRecord['phensig']
# remove new fields so we don't pickle two copies
del convRecord['officeid']
del convRecord['vtecstr']
del convRecord['endTime']
del convRecord['phensig']
del convRecord['startTime']
if convRecord.has_key('segText'):
convRecord['text'] = convRecord['segText']
del convRecord['segText']
table.append(convRecord)
# additionally, we'll need to pickle our output to match the A1 file
# format
pickledTable = cPickle.dumps(table)
outDir = os.path.join(siteConfig.GFESUITE_PRDDIR, "ATBL")
with tempfile.NamedTemporaryFile(suffix='.ato', dir=outDir, delete=False) as fp:
fname = fp.name
fp.write(pickledTable)
#write the xmlpacket to a temporary file, if one was passed
if xmlPacket is not None:
with tempfile.NamedTemporaryFile(suffix='.xml', dir=outDir, delete=False) as fp:
fnameXML = fp.name
fp.write(xmlPacket)
from com.raytheon.edex.plugin.gfe.config import IFPServerConfigManager
config = IFPServerConfigManager.getServerConfig(siteConfig.GFESUITE_SITEID)
ServerHost = siteConfig.GFESUITE_SERVER
ServerPort = str(siteConfig.GFESUITE_PORT)
ServerProtocol = str(config.getProtocolVersion())
ServerMHS = siteConfig.GFESUITE_MHSID
ServerSite = siteConfig.GFESUITE_SITEID
XmtScript = config.transmitScript()
#call sendAT to send the table to the requestor
cmd = os.path.join(siteConfig.GFESUITE_HOME, "bin", "sendAT")
args = [cmd, '-s', reqsite, '-a', mhsSite, '-H', ServerHost,
'-P', ServerPort, '-L', ServerProtocol, '-M', ServerMHS,
'-S', ServerSite, '-x', XmtScript]
if filterSites is not None:
for fs in filterSites:
args.append('-f')
args.append(fs)
if countDict is not None:
args.append('-c')
args.append(`countDict`)
if issueTime is not None:
args.append('-t')
args.append(`issueTime`)
args.append('-v')
args.append(fname)
if xmlPacket is not None:
args.append('-X')
args.append(fnameXML)
try:
output = subprocess.check_output(args, stderr=subprocess.STDOUT)
logEvent("sendAT command output: ", output)
except subprocess.CalledProcessError as e:
logProblem("sendAT returned error code: ", e.returncode, e.output)
except:
logProblem("Error executing sendAT: ", traceback.format_exc())
#when we receive a requested active table from another site, this function
#is called from iscDataRec
def putVTECActiveTable(dataFile, xmlPacket):
import siteConfig
with open(dataFile, "rb") as fp:
strTable = fp.read()
#write the xmlpacket to a temporary file, if one was passed
inDir = os.path.join(siteConfig.GFESUITE_PRDDIR, "ATBL")
if xmlPacket is not None:
with tempfile.NamedTemporaryFile(suffix='.xml', dir=inDir, delete=False) as fp:
fnameXML = fp.name
fp.write(xmlPacket)
with tempfile.NamedTemporaryFile(suffix='.ati', dir=inDir, delete=False) as fp:
fname = fp.name
fp.write(strTable)
cmd = os.path.join(siteConfig.GFESUITE_HOME, "bin", "ingestAT")
args = []
args.append(cmd)
args.append("-s")
args.append(siteConfig.GFESUITE_SITEID)
args.append("-f")
args.append(fname)
if xmlPacket is not None:
args.append('-X')
args.append(fnameXML)
try:
output = subprocess.check_output(args, stderr=subprocess.STDOUT)
logEvent("ingestAT command output: ", output)
except subprocess.CalledProcessError as e:
logProblem("ingestAT returned error code: ", e.returncode, e.output)
except:
logProblem("Error executing ingestAT: ", traceback.format_exc())
def sendWfoMessage(siteID, msgFile):
with open(msgFile, 'r') as fp:
message = fp.read()
logEvent("Message received from site: %s\n%s" % (siteID, message))
# send to AlertViz
from awips import NotificationMessage
msg = NotificationMessage.NotificationMessage(port='9581', message=message,
category='GFE', priority='SIGNIFICANT', source='GFE')
msg.send()
def putTCVFiles(siteID, tarFile):
import LocalizationSupport
import glob
import TCVUtil
logEvent("Receiving TCV files from " + siteID)
siteDir = LocalizationSupport.getLocalizationFile(LocalizationSupport.CAVE_STATIC,
LocalizationSupport.SITE,
siteID, "gfe").getFile()
siteDir = siteDir.getParentFile().getParentFile().getAbsolutePath()
logDebug("siteDir: "+siteDir)
try:
tmpDir = tempfile.mkdtemp(dir="/tmp")
logDebug("tmpDir: "+tmpDir)
subprocess.check_call(["cd " + tmpDir + "; tar xvzf " + tarFile], shell=True)
except:
logException('Error untarring TCV files from site: ' + siteID)
raise
TCVUtil.purgeAllCanFiles(getLogger())
# create the new allCAN files
for tmpFile in glob.iglob(os.path.join(tmpDir, "*/gfe/tcvAdvisories/*.allCAN")):
# create tcvDir if necessary
tcvDir = os.path.dirname(tmpFile).replace(tmpDir, siteDir)
logDebug("tcvDir: "+tcvDir)
try:
os.makedirs(tcvDir, 0755)
except OSError, e:
if e.errno != errno.EEXIST:
logProblem("%s: '%s'" % (e.strerror,e.filename))
basename = os.path.basename(tmpFile)
stormName = basename.replace(".allCAN", "")
allCanPath = os.path.join(tcvDir, basename)
logDebug("copying "+tmpFile+" to "+allCanPath)
try:
# just create the empty allCan file
with open(allCanPath, 'w'):
pass
except:
logException("Error creating: "+ allCanPath)
try:
# delete all JSON files starting with stormName
for fn in glob.iglob(os.path.join(tcvDir, stormName + "*.json")):
try:
site = fn.replace(siteDir,"").split("/")[1]
basename = os.path.basename(fn)
logDebug("removing canceled file: ", os.path.join(site, "gfe/tcvAdvisories", basename))
LocalizationSupport.deleteFile(LocalizationSupport.CAVE_STATIC,
LocalizationSupport.SITE, site,
"gfe/tcvAdvisories/" + basename)
except:
logException("Error removing " + fn)
os.remove(tmpFile)
except:
logException("Error removing JSON files for " + stormName)
# copy in the json files
for tmpFile in glob.iglob(os.path.join(tmpDir, "*/gfe/tcvAdvisories/*.json")):
site = tmpFile.replace(tmpDir,"").split("/")[1]
jsonFile = "gfe/tcvAdvisories/" + os.path.basename(tmpFile)
logDebug("copying "+tmpFile+" to "+jsonFile)
try:
with open(tmpFile, 'r') as tf:
jsonData = tf.read()
LocalizationSupport.writeFile(LocalizationSupport.CAVE_STATIC,
LocalizationSupport.SITE,
site, jsonFile, jsonData)
os.remove(tmpFile)
except:
logException("Error copying JSON file: "+jsonFile)
# delete tmpDir
try:
for dirpath, dirs, files in os.walk(tmpDir, topdown=False):
os.rmdir(dirpath)
except:
logException("Unable to remove "+ tmpDir)
def getTCVFiles(ourMhsID, srcServer, destE):
import IrtAccess
import TCVUtil
import siteConfig
irt = IrtAccess.IrtAccess("")
localSites = [srcServer['site']]
for addressE in destE:
if addressE.tag != "address":
continue
destServer = irt.decodeXMLAddress(addressE)
if destServer['mhsid'] == ourMhsID:
localSites.append(destServer['site'])
logEvent("Sending TCV files for " + str(localSites) + " to " + srcServer['mhsid'])
tcvProductsDir = os.path.join(siteConfig.GFESUITE_HOME, "products", "TCV")
# create tcvProductsDir if necessary
try:
os.makedirs(tcvProductsDir, 0755)
except OSError, e:
if e.errno != errno.EEXIST:
logger.warn("%s: '%s'" % (e.strerror,e.filename))
# get temporary file name for packaged TCV files
with tempfile.NamedTemporaryFile(suffix='.sendtcv', dir=tcvProductsDir, delete=False) as fp:
fname = fp.name
try:
if TCVUtil.packageTCVFiles(localSites, fname, getLogger()):
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
iscE = ElementTree.Element('isc')
irt.addSourceXML(iscE, destServer)
irt.addDestinationXML(iscE, [srcServer])
# create the XML file
with tempfile.NamedTemporaryFile(suffix='.xml', dir=tcvProductsDir, delete=False) as fd:
fnameXML = fd.name
fd.write(ElementTree.tostring(iscE))
# send the files to srcServer
sendMHSMessage("PUT_TCV_FILES", srcServer['mhsid'], [fname, fnameXML])
else:
logEvent('No TCV files to send')
except:
logException('Error sending TCV files for ' + str(localSites))
# get servers direct call for IRT
def irtGetServers(ancfURL, bncfURL, iscWfosWanted):
import IrtAccess
irt = IrtAccess.IrtAccess(ancfURL, bncfURL)
xml = None
status, xml = irt.getServers(iscWfosWanted)
return xml
# make a request for ISC (support for IFPServer.C)
# xmlRequest is the original request from the GFE's ISCRequestDialog.
def makeISCrequest(xmlRequest, gridDims, gridProj, gridBoundBox, mhs, host, port, protocol, site, xmtScript):
import IrtAccess
import siteConfig
import xml
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
ServerMHS = mhs
ServerHost = host
ServerPort = port
ServerProtocol = protocol
ServerSite = site
if type(gridDims) != "list":
pylist = []
size = gridDims.size()
for i in range(size):
pylist.append(gridDims.get(i).intValue())
gridDims = pylist
if type(gridBoundBox) != "tuple":
gridBoundBox = ((gridBoundBox.get(0).doubleValue(),gridBoundBox.get(1).doubleValue()),(gridBoundBox.get(2).doubleValue(),gridBoundBox.get(3).doubleValue()))
irt = IrtAccess.IrtAccess(None)
logEvent("ISC Request (makeISCrequest)")
# we need to modify the incoming xmlRequest and add the <source>
# and move the <welist> into the <source> <address>
requestE = ElementTree.fromstring(xmlRequest)
ourServer = {'mhsid': ServerMHS,
'host': ServerHost,
'port': ServerPort,
'protocol': ServerProtocol,
'site': ServerSite,
'area': {'xdim': gridDims[0],
'ydim': gridDims[1]
},
'domain': {'proj': gridProj,
'origx': gridBoundBox[0][0],
'origy': gridBoundBox[0][1],
'extx': gridBoundBox[1][0],
'exty': gridBoundBox[1][1]
}
}
sourcesE, addressE = irt.addSourceXML(requestE, ourServer)
#find the <welist> and move it
welistE = requestE.find('welist')
requestE.remove(welistE)
addressE.append(welistE)
# we need to decode the <destinations> to determine which sites should
# get this request
mhsSites = []
for destE in requestE.getchildren():
if destE.tag == "destinations":
for addrE in destE:
if addrE.tag != "address":
continue #not expecting something different, so ignore
serverInfo = irt.decodeXMLAddress(addrE)
logEvent("Destination:",
irt.printServerInfo(serverInfo))
if serverInfo['mhsid'] not in mhsSites:
mhsSites.append(serverInfo['mhsid'])
# convert XML tree to a string and write out packet to send via MHS
dir = siteConfig.GFESUITE_PRDDIR + "/ISC"
#create the directories if they don't exist
try:
os.makedirs(dir)
except:
pass
tempfile.tempdir = dir
fname = tempfile.mktemp(".iscRequest")
fp = open(fname, "wb")
buf = ElementTree.tostring(requestE)
fp.write(buf)
fp.close()
# Transmit the request -- do string substitution
#if XmtScript is not None:
# create the required wfmoid
wmoid = "TTAA00 "
if ServerMHS in ['SJU']:
wmoid += "TJSJ"
elif ServerMHS in ['AFG', 'AJK', 'HFO', 'GUM']:
wmoid += "P" + ServerMHS
elif ServerMHS in ['AER', 'ALU']:
wmoid += "PAFC"
elif len(ServerMHS) == 3:
wmoid += "K" + ServerMHS
elif len(ServerMHS) == 4:
wmoid += ServerMHS
else:
wmoid = "XXXX"
wmoid += " " + time.strftime("%d%H%M", time.gmtime(time.time()))
cmd = copy.deepcopy(xmtScript)
args = cmd.split(" ") #break down into separate entries
for s1, s2 in [("%SUBJECT", "ISCREQUEST"),
("%ADDRESSES", ",".join(mhsSites)), ("%WMOID", wmoid),
("%ATTACHMENTS", fname)]:
for x in xrange(len(args)):
args[x] = string.replace(args[x], s1, s2)
logEvent("ISCRequest xml: ", args)
# start subprocess to actually make the call
pid = os.fork()
if pid == 0:
try:
os.execvp(args[0], args)
except:
pass
finally:
os.remove(fname)
os._exit(0)
def serviceISCRequest(dataFile):
# function called by iscDataRec with an isc request to be serviced.
# We take this information, convert it into a different format,
# and queue the request via the IFPServer to the SendISCMgr
import IrtAccess
import siteConfig
import xml
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
irt = IrtAccess.IrtAccess(None)
logEvent("serviceISCRequest.....")
# validate xml
inTree = ElementTree.parse(dataFile)
inE = inTree.getroot()
if inE.tag != "iscrequest":
raise Exception, "iscrequest packet missing from request"
# prepare output XML file - emulating the IRT getSendAddr() format
iscE = Element('destinations')
# process the input request file. Look for source, destinations.
sourceE = None
for sdwE in inE:
if sdwE.tag == "source":
for addrE in sdwE:
if addrE.tag == "address": #should only be 1
info = irt.decodeXMLAddress(addrE) #requestor information
logEvent("ISC requestor:",
irt.printServerInfo(info))
irt.addAddressXML(iscE, info) #into the destinations
elif sdwE.tag == "destinations":
continue #we don't care about these destinations since they are
#where the request went (which is our own server)
# pass request into C++ IFPServer
xmlDestinations = ElementTree.tostring(iscE) #convert to string
from com.raytheon.edex.plugin.gfe.isc import ServiceISCRequest
ServiceISCRequest.serviceRequest(JUtil.pyValToJavaObj(info['parms']),xmlDestinations,siteConfig.GFESUITE_SITEID)
# ifpServer.serviceISCRequest(info['parms'], xmlDestinations)
def sendMHSMessage(subject, adressees, attachments, xmtScript=None):
# Transmit the request -- do string substitution
import siteConfig
from com.raytheon.edex.plugin.gfe.config import IFPServerConfigManager
config = IFPServerConfigManager.getServerConfig(siteConfig.GFESUITE_SITEID)
ourMHS = siteConfig.GFESUITE_MHSID
if xmtScript is None:
xmtScript = config.transmitScript()
# create the required wmoid
wmoid = "TTAA00 "
if ourMHS in ['SJU']:
wmoid += "TJSJ"
elif ourMHS in ['AFG', 'AJK', 'HFO', 'GUM']:
wmoid += "P" + ourMHS
elif ourMHS in ['AER', 'ALU']:
wmoid += "PAFC"
elif len(ourMHS) == 3:
wmoid += "K" + ourMHS
elif len(ourMHS) == 4:
wmoid += ourMHS
else:
wmoid = "XXXX"
wmoid += " " + time.strftime("%d%H%M", time.gmtime(time.time()))
if type(adressees) in [list, tuple]:
adressees = ",".join(addresses)
if type(attachments) in [list, tuple]:
attachments = ",".join(attachments)
cmd = copy.deepcopy(xmtScript)
for s1, s2 in [("%SUBJECT", subject),
("%ADDRESSES", adressees),
("%WMOID", wmoid),
("%ATTACHMENTS", attachments)]:
cmd = cmd.replace(s1, s2)
logDebug("cmd: "+ cmd)
# start subprocess to actually make the call
try:
subprocess.check_call([cmd], shell=True)
except:
logException("Error running cmd: " + cmd)

View file

@ -1,313 +0,0 @@
#! /bin/sh
# -*-python-*-
##
# 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.
##
#
# Port of iscDataRec.py
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 07/06/09 1995 bphillip Initial Creation.
# 01/29/13 1447 dgilling Implement VTEC table sharing.
# 03/12/13 1759 dgilling Bypass command-line processing
# for iscMosaic, support changes
# to IscReceiveSrv.
# 01/24/14 2504 randerso removed obsolete A1 comments
# 12/08/2014 4953 randerso Added support for sending/receiving TCV files
# Additional code cleanup
# 04/08/2015 4383 dgilling Support FireWx ISC.
# 04/23/2015 4383 randerso Fixed exception logging
# 02/22/2016 5374 randerso Added support for sendWFOMessage
#
##
import iscMosaic,iscUtil
import os, stat, sys, re, string, types
import time, xml, LogStream, IrtAccess
import IrtServer
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
from java.util import ArrayList
iscDataRecLogger=None
## Logging methods ##
def initLogger(logFile=None):
global iscDataRecLogger
import logging, siteConfig
iscDataRecLogger = iscUtil.getLogger("iscDataRec",logFile)
def logEvent(*msg):
iscDataRecLogger.info(iscUtil.tupleToString(*msg))
def logProblem(*msg):
iscDataRecLogger.error(iscUtil.tupleToString(*msg))
def logException(*msg):
iscDataRecLogger.exception(iscUtil.tupleToString(*msg))
def logVerbose(*msg):
iscDataRecLogger.debug(iscUtil.tupleToString(*msg))
def logDebug(*msg):
logVerbose(iscUtil.tupleToString(*msg))
# File Purging Routing
def purgeFiles(msgid, files):
for file in files:
try:
os.remove(file)
except:
logException("iscDataRec Failed to remove file %s: ", str(file))
def execIscDataRec(MSGID,SUBJECT,FILES):
import siteConfig
try:
# logEvent('*** iscDataRec ***', sys.argv[1:])
logEvent('SUBJECT:', SUBJECT, 'MSGID:', MSGID,"FILES:",FILES)
time1 = time.clock()
#get our MHS id
ourMhsID = siteConfig.GFESUITE_MHSID
# for most transactions, first attachment is the data file, 2nd file is the
# XML destinations. ISCREQUEST and GET_TCV_FILES have only 1 file being the
# XML destinations. We simulate two files naming them the same.
if SUBJECT in ["ISCREQUEST", "GET_TCV_FILES"]:
FILES.append(FILES[0])
dataFile = FILES[0] #first attachment is always the data file
if len(FILES) > 1:
xmlFile = FILES[1] #second attachment is the xml destinations file
fd = open(xmlFile,'rb')
xmlFileBuf = fd.read()
fd.close()
try:
destTree = ElementTree.ElementTree(ElementTree.XML(xmlFileBuf))
iscE = destTree.getroot()
except:
logException("Malformed XML received")
return
#no XML destination information. Default to dx4f,px3 98000000, 98000001
else:
# create a xml element tree to replace the missing one. This will
# occur when OB8.2 sites send ISC data to OB8.3 sites, and also when
# active table exchanges occur. We default to 98000000 and 98000001
# on dx4 since that is where the primary and svcbu servers are located.
# This will cause log errors until everyone is on OB8.3.
iscE = Element('isc')
destinationsE = SubElement(iscE, 'destinations')
for x in xrange(98000000, 98000002):
for shost in ['dx4f','px3f']:
addressE = SubElement(destinationsE, 'address')
serverE = SubElement(addressE, 'server')
serverE.text = shost
portE = SubElement(addressE, 'port')
portE.text = str(x)
protocolE = SubElement(addressE, 'protocol')
protocolE.text = "20070723" #match this from IFPProtocol.C
mhsE = SubElement(addressE, 'mhsid')
mhsE.text = siteConfig.GFESUITE_MHSID
irt = IrtAccess.IrtAccess("")
# find source xml
found = False
for srcE in iscE.getchildren():
if srcE.tag == "source":
for addressE in srcE:
srcServer = irt.decodeXMLAddress(addressE)
if srcServer is None:
continue
found = True
logEvent("Source:",irt.printServerInfo(srcServer))
break
if not found:
logEvent("Source: <unknown>")
# find destinations xml
found = False
for destE in iscE.getchildren():
if destE.tag == "destinations":
found = True
break
if not found:
logProblem("destinations packet missing from xml")
return
# Handle GET_TCV_FILES out side the loop as it needs to do it's own loop
if SUBJECT == 'GET_TCV_FILES':
IrtServer.getTCVFiles(ourMhsID, srcServer, destE)
else:
# decode and print the source server (if present)
for addressE in destE:
if addressE.tag != "address":
continue
destServer = irt.decodeXMLAddress(addressE)
# find destination server information
mhsidDest=serverDest=portDest=protocolDest=None
for attrE in addressE.getchildren():
if attrE.tag == "mhsid":
mhsidDest = attrE.text
elif attrE.tag == "server":
serverDest = attrE.text
elif attrE.tag == "port":
portDest = attrE.text
elif attrE.tag == "protocol":
protocolDest = attrE.text
if destServer['mhsid'].upper() != ourMhsID.upper():
logDebug(SUBJECT, 'Not our mhs of ' + ourMhsID + \
', so skipped:', irt.printServerInfo(destServer))
continue #this destination is for someone else.
# transmit the data to the ifpServer
time2 = time.clock()
if SUBJECT == 'PUT_ACTIVE_TABLE':
IrtServer.putVTECActiveTable(dataFile, None)
elif SUBJECT == 'PUT_ACTIVE_TABLE2':
IrtServer.putVTECActiveTable(dataFile, xmlFileBuf)
elif SUBJECT == 'GET_ACTIVE_TABLE':
IrtServer.getVTECActiveTable(dataFile, None)
elif SUBJECT == 'GET_ACTIVE_TABLE2':
IrtServer.getVTECActiveTable(dataFile, xmlFileBuf)
elif SUBJECT in ['ISCGRIDS', 'ISCGRIDS2']:
import serverConfig
additionalISCRouting = []
if serverConfig.AdditionalISCRouting:
additionalISCRouting = serverConfig.AdditionalISCRouting
putISCGrids(dataFile, siteConfig.GFESUITE_SITEID, srcServer.get('site'), additionalISCRouting)
elif SUBJECT == 'ISCREQUEST':
IrtServer.serviceISCRequest(dataFile)
elif SUBJECT == 'PUT_TCV_FILES':
IrtServer.putTCVFiles(srcServer.get('site'), dataFile)
elif SUBJECT == 'SEND_WFO_MESSAGE':
IrtServer.sendWfoMessage(srcServer.get('site'), dataFile)
else:
nosend = True
logProblem("unknown subject: ", SUBJECT)
continue
time3 = time.clock()
delta1 = time2-time1
delta2 = time3-time2
logEvent('Sent to:',
irt.printServerInfo(destServer), "connectT=", delta1, "xmtT=", delta2)
except:
logException("iscDataRec failed!")
finally:
# cleanup
purgeFiles(MSGID, FILES)
def putISCGrids(dataFile, destSite, srcSite, additionalISCRouting):
# iscMosaic now executes multiple times--once for the primary ISC database,
# and once more for each additional ISC database defined in the localConfig
args = {"siteID": destSite,
"userID": 'SITE',
"databaseID": destSite+"_GRID__ISC_00000000_0000",
"parmsToProcess": [],
"blankOtherPeriods": True,
"startTime": None,
"endTime": None,
"altMask": None,
"replaceOnly": False,
"eraseFirst": False,
"announce": "ISC: ",
"renameWE": True,
"iscSends": False,
"inFiles": [dataFile],
"ignoreMask": False,
"adjustTranslate": True,
"deleteInput": False,
"parmsToIgnore": [],
"gridDelay": 0.0,
"logFileName": None}
mosaic = iscMosaic.IscMosaic(args)
mosaic.execute()
for entry in additionalISCRouting:
(parms, dbName, editAreaPrefix) = entry
parmNameList = [parm[0] + "_SFC" for parm in parms]
args['parmsToProcess'] = parmNameList
args['databaseID'] = destSite + "_GRID__" + dbName + "_00000000_0000"
args['altMask'] = editAreaPrefix + srcSite
mosaic = iscMosaic.IscMosaic(args)
mosaic.execute()
#--------------------------------------------------------------------
# Main Routine
#--------------------------------------------------------------------
# The following keywords prefaced by the '%' character cause the
# value from the current message to be inserted into the
# specification string.
#
# MSGID: Unique ID of message
# MSGTYPE: Sender assigned message type
# MSGCODE: Sender assigned message code
# SUBJECT: Sender assigned message subject
# SENDER: Sending site name
# PRIORITY: Sender assigned message priority
# BODY: Path to file containing body of message.
# ENCLIST: List of paths to files for each enclosure.
# ENCLOSE(N): Path to file containing Nth enclosure.
# NUMENC: Total number of enclosures.
# X400DOC: Path to X.400 document file.
#
# /data/adapt/GFESuite/iscDataRec SYS /awips/adapt/GFESUITE/bin/iscDataRec
# %MSGID %SUBJECT %ENCLIST
def main(argv):
initLogger()
try:
if type(argv) is not list:
import JUtil
argv = JUtil.javaObjToPyVal(argv)
logEvent('*** iscDataRec ***', argv)
try:
MSGID = argv[0]
SUBJECT = argv[1]
FILES = argv[2].split(',')
logEvent('SUBJECT:', SUBJECT, 'MSGID:', MSGID)
#log the incoming files and size
for file in FILES:
filesize = os.stat(file)[stat.ST_SIZE]
logEvent('Received:', file, filesize, "bytes")
execIscDataRec(MSGID,SUBJECT,FILES)
except:
logException('Failure:')
except:
logException("FAIL: ")

View file

@ -1,486 +0,0 @@
#!/common/bphillip/awips/bin/python
##
# 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.
##
#
# Port of iscExtract.py
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- ------------------------------------------
# Jul 06, 2009 1995 bphillip Initial Creation.
# Mar 12, 2013 1759 dgilling Change how ifpnetCDF is called.
# Apr 25, 2015 4952 njensen Updated for new JEP API
# May 21, 2015 4427 dgilling Add new ifpnetCDF argument.
# Feb 22, 2017 6143 randerso Set area to none for fewer transmissions.
#
##
import JUtil
import ifpnetCDF, iscUtil
import numpy
import tempfile, os, stat, getopt, sys, cPickle, siteConfig
import LogStream, time, traceback, string, IrtAccess, urllib, urllib2
import xml, copy, string
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
from java.io import File
from java.awt import Point
from com.vividsolutions.jts.geom import Coordinate
from java.util import ArrayList
from com.raytheon.edex.plugin.gfe.config import IFPServerConfig
from com.raytheon.edex.plugin.gfe.config import IFPServerConfigManager
from com.raytheon.edex.plugin.gfe.util import CartDomain2D
from com.raytheon.uf.common.dataplugin.gfe.db.objects import GridLocation
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceData
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceID
CoordinateType = ReferenceData.CoordinateType
from com.vividsolutions.jts.geom import Coordinate
parms = [] #parm names
dbid = None #database identifier
startTR = None #ifpnetCDF start time
endTR = None #ifpnetCDF start time
xmlDestinations = None #XML destinations information
ancf = None #IRT web address
bncf = None
xmtScript = None #transmit script
serverHost = None #server host
serverPort = None #server port
serverProtocol = None #serverProtocol
mhsid = None #MHS site identifier
siteID = None #our site id
startT = None
iscExtractLogger=None
def logEvent(*msg):
iscUtil.getLogger("iscExtract").info(iscUtil.tupleToString(*msg))
def logProblem(*msg):
iscUtil.getLogger("iscExtract").error(iscUtil.tupleToString(*msg))
def logException(*msg):
iscUtil.getLogger("iscExtract").exception(iscUtil.tupleToString(*msg))
def logVerbose(*msg):
iscUtil.getLogger("iscExtract").debug(iscUtil.tupleToString(*msg))
def logDebug(*msg):
logVerbose(iscUtil.tupleToString(*msg))
def executeIscExtract(parmNames, databaseName, startTime, endTime,
irtTableAddressA, irtTableAddressB, transmitScript, ourServerHost,
ourServerPort, ourServerProtocol, ourMHSid, ourSiteID, destinations=None):
startT = time.time()
parms = parmNames
dbid = databaseName
startTR = startTime
endTR = endTime
xmlDestinations = destinations
ancf = irtTableAddressA
bncf = irtTableAddressB
xmtScript = transmitScript
serverHost = ourServerHost
serverPort = ourServerPort
serverProtocol = ourServerProtocol
mhsid = ourMHSid
siteID = ourSiteID
myOfficeType = IFPServerConfigManager.getServerConfig(siteID).officeType()
#--------------------------------------------------------------------
# determine the list of destination servers
#--------------------------------------------------------------------
try:
nowT = time.time() #current time
useUntilTime = None #cached use until time
cacheFilename = "/tmp/" + serverHost + serverPort + ".iscExtract"
cachedXmlDestinations = None
#if xmlDestinations is None: #destinations not on command line
# # check the cache
# try:
# fd = open(cacheFilename, 'rb')
# buf = fd.read()
# fd.close()
# useUntilTime, cachedXmlDestinations = cPickle.loads(buf)
# nowT = time.time() #current time
# if nowT > useUntilTime:
# xmlDestinations = None #cache is too old
# useUntilTime = None
# else:
# logEvent('Using xmlDestinations cache')
# xmlDestinations = cachedXmlDestinations
# except:
# pass
# need to contact IRT to get destinations
irt = IrtAccess.IrtAccess(ancf, bncf)
if xmlDestinations is None:
logEvent('contacting IRT to get destinations')
count = 1
while True:
status, xmlDestinations = irt.getSendAddrs(siteID)
logEvent('IRT getSendAddrs status:', status)
if status:
# if we obtained XML destinations from IRT, then decode
# the useUntilTime field
try:
d = ElementTree.ElementTree(ElementTree.XML(xmlDestinations))
dE = d.getroot()
for e in dE:
if e.tag == "useuntil":
isoTimeStr = e.text
idx = isoTimeStr.find(".")
if idx != - 1:
isoTimeStr = isoTimeStr[0:idx] #eliminate subseconds
useUntilTime = time.mktime(time.strptime(isoTimeStr,
"%Y-%m-%dT%H:%M:%S"))
logEvent("Use Until: ", isoTimeStr)
except:
logProblem("Malformed XML on getSendAddrs()")
logProblem("XML=", xmlDestinations)
return
if useUntilTime is None:
useUntilTime = time.time() + 180.0 #3 minutes default
logEvent("Using default 180 second useUntilTime")
# write the cache
fd = open(cacheFilename, 'wb')
buf = cPickle.dumps((useUntilTime, xmlDestinations))
fd.write(buf)
fd.close()
break #success from the irt
else:
# try again and again for 10 minutes, then use cache
# if available and alert GFE users
if time.time() - nowT > 600.00:
logProblem("Unable to access IRT for send addrs")
if cachedXmlDestinations is None:
s = "Unable to access IRT for send addrs. Previous" + \
" cache not available."
logProblem(s)
return
# use cached value, even if out of date
else:
xmlDestinations = cachedXmlDestinations
if useUntilTime is not None:
s = time.asctime(time.gmtime(useUntilTime))
else:
s = "Unknown"
logProblem("Using expired cache. Date=", s)
#determine when we issued our last GFE alert
#we alert every 30 minutes.
try:
fd = open(cacheFilename + "-warn", 'rb')
buf = fd.read()
fd.close()
lastAlertTime = cPickle.loads(buf)
except:
lastAlertTime = 0 #for way long ago
if time.time() - lastAlertTime > 1800.0:
logProblem("Sending GFE notification")
msg = """
Contact NCF. ifpServer is unable to contact IRT central server. ISC
traffic routing information is old and possibly incorrect."""
os.system("sendGfeMessage -u -c GFE -m '" + \
msg + "'")
fd = open(cacheFilename + "-warn", 'wb')
fd.write(cPickle.dumps(time.time()))
fd.close()
break
time.sleep(15.0) #sleep awhile and then try again
count = count + 1
logProblem("Retrying to getSendAddrs()", count)
# qc the XML
try:
destTree = ElementTree.ElementTree(ElementTree.XML(xmlDestinations))
destE = destTree.getroot()
except:
logProblem("Malformed XML on getSendAddrs() or provided xmlDest")
logProblem("XML=", xmlDestinations)
return
#--------------------------------------------------------------------
# determine how many transmissions are necessary
#--------------------------------------------------------------------
xmt = []
logEvent("XML dest:", xmlDestinations)
if destE.tag != "destinations":
logProblem("Destinations packet missing from web service")
return
# create list of individual transmissions (before attempting to combine
doClip = 1 #0 to send entire domain, 1 to do destination clipping (default)
destStr = "Destination Servers:\n"
for addressE in destE:
if addressE.tag == "doclip":
for name, value in addressE.items():
if name == "clip":
if value == "1":
doClip = 1
elif value == "0":
doClip = 0
logEvent("Clipping State: ", doClip)
for addressE in destE:
if addressE.tag != "address":
continue
# find destination server info and domain information
serverInfo = irt.decodeXMLAddress(addressE)
if doClip == 0:
serverInfo['domain'] = None
serverInfo['area'] = None
keycheckfail = False
for key in ['mhsid', 'host', 'port', 'protocol', 'site']:
if not serverInfo.has_key(key):
logProblem("Fail to decode XML. Skipping serverInfo:",
serverInfo)
keycheckfail = True
continue
if keycheckfail:
continue #skipping this destination due to insufficient info
# get the destination office type
try:
siteIndex = IFPServerConfigManager.getServerConfig(siteID).allSites().indexOf(serverInfo['site'])
destOfficeType = str(IFPServerConfigManager.getServerConfig(siteID).officeTypes().get(siteIndex))
except:
logProblem("Unknown site id to get office type. ",
"Skipping serverInfo:", serverInfo)
continue #skipping this destination due to unknown site id
# find weather elements that remote ifpServer wants
# that is available in our server and in the -p parm switches
any = False
for parm in serverInfo['parms']:
p1 = string.replace(parm, "_SFC", "") #remove _SFC if exists
# translation of parm name needed, also if no office type, then
# not wanted from this office.
# example: changes QPFwfo to QPF if we are wfo
# example: discards T if we are wfo and site is non-wfo
if myOfficeType != destOfficeType:
if p1.find(myOfficeType) != - 1:
p1 = string.replace(p1, myOfficeType, "") #remove type
else:
continue #no type, so not intended for our type
# see if parm was listed in the command line switches
if parms.contains(p1):
xmt.append({'serverInfo':[serverInfo], 'parms':[p1],
'domain': serverInfo['domain'], 'area': serverInfo['area']})
if not any:
destStr += irt.printServerInfo(serverInfo) + "\n"
any = True
logEvent(destStr)
# now combine transmissions
# find same domains, same parms, to combine servers/destinations
i = 0
while i < len(xmt):
j = i + 1
while j < len(xmt):
if xmt[i]['domain'] == xmt[j]['domain'] and \
xmt[i]['area'] == xmt[j]['area'] and \
xmt[i]['parms'] == xmt[j]['parms']:
for si in xmt[j]['serverInfo']:
if si not in xmt[i]['serverInfo']:
dests = xmt[i]['serverInfo']
dests.append(si)
xmt[j]['serverInfo'] = dests
del xmt[j] #delete the entry
j = j - 1 #redo this entry index next loop
j = j + 1
i = i + 1
# now try to combine common parm lists (same domain, same servers/destinations)
i = 0
while i < len(xmt):
j = i + 1
while j < len(xmt):
if xmt[i]['domain'] == xmt[j]['domain'] and \
xmt[i]['area'] == xmt[j]['area'] and \
xmt[i]['serverInfo'] == xmt[j]['serverInfo'] :
iparms = xmt[i]['parms']
for p in xmt[j]['parms']:
if p not in iparms:
iparms.append(p)
xmt[i]['parms'] = iparms
del xmt[j] #delete the entry
j = j - 1 #redo this entry index for next loop
j = j + 1
i = i + 1
# if doClip, gather some required information
if doClip:
#get the isc send area and grid domain from the ifpServer
iscSendAreaGrid = iscUtil.getEditArea("ISC_Send_Area",siteID)
sourceDomain = IFPServerConfigManager.getServerConfig(siteID).dbDomain()
iscSendAreaGrid.setGloc(sourceDomain)
iscSendAreaGrid = iscSendAreaGrid.getGrid()
#--------------------------------------------------------------------
# prepare output files
#--------------------------------------------------------------------
for dest in xmt:
s = "Processing Xmt Pass:\n"
for sv in dest['serverInfo']:
s += irt.printServerInfo(sv) + '\n'
s += "Domain:" + `dest['domain']` + '\n'
s += "Area:" + `dest['area']` + '\n'
s += "Parms:" + `dest['parms']` + '\n\n'
logEvent(s)
# extract the data using ifpnetCDF
if os.path.exists(siteConfig.GFESUITE_HOME + "/products/ISC") == False:
os.makedirs(siteConfig.GFESUITE_HOME + "/products/ISC")
tempfile.tempdir = siteConfig.GFESUITE_HOME + "/products/ISC"
fname = tempfile.mktemp(".isc")
# Determine domain edit area.
if doClip == 1 and dest['domain'] is not None and \
dest['domain']['proj'] == sourceDomain.getProjection().getProjectionID():
#make a GridLocation for our domain
gridSize = Coordinate(float(str(sourceDomain.getNx())), float(str(sourceDomain.getNy())))
origin = sourceDomain.getOrigin()
extent = sourceDomain.getExtent()
domain = CartDomain2D(origin, extent)
gloc = sourceDomain
#make a GridLocation covering the area for the destination, expanded
#by 1/2 grid cell
dd = dest['domain']
da = dest['area']
cellsizeX = float(dd['extx']) / (float(da['xdim']) - 1.0)
cellsizeY = float(dd['exty']) / (float(da['ydim']) - 1.0)
originD = Coordinate(float(dd['origx']) - cellsizeX / 2.0,
float(dd['origy']) - cellsizeY / 2.0)
extentD = Coordinate(float(dd['extx']) + cellsizeX,
float(dd['exty']) + cellsizeY)
domainD = CartDomain2D(originD, extentD)
#check for overlap
if not domainD.overlaps(domain):
logEvent("No intersection of domain box, skipping....")
continue #no bits set in the resulting mask, no intersect
domainD.trim(domain) #trim it to just the overlapping section
gridSize = Point(int(da['xdim']),int(da['ydim']))
destGridLocation = GridLocation("Dest",sourceDomain.getProjection(),
gridSize,domainD.getOrigin(),domainD.getExtent(),"GMT")
# make a Reference Set
refid = ReferenceID("jibberish")
refSet = ReferenceData(gloc, refid, destGridLocation.getGeometry(), CoordinateType.LATLON)
# convert destination site's domain to gridpoints
iscMask = refSet.getGrid()
# "and" it with our ISC_Send_Area
iscMask.andEquals(iscSendAreaGrid)
if not iscMask.isAnyBitsSet():
logEvent("No intersection of domain points, skipping....")
continue #no bits set in the resulting mask, no intersect
# store the grid back into the ifpServer
maskName = "iscExtract" + `time.time()`
refSet.setGrid(iscMask)
iscUtil.saveEditAreaGrid(maskName, refSet, siteID)
else: #no clipping, or different projection
maskName = "ISC_Send_Area"
# Run ifpnetCDF for the data
argv = {"outputFilename": fname,
"parmList": dest['parms'],
"databaseID": dbid,
"startTime": startTR,
"endTime": endTR,
"mask": maskName,
"geoInfo": False,
"compressFileFlag": True,
"configFileName": "iscSendSampleDef",
"compressFileFactor": 6,
"trim": True,
"krunch": True,
"userID": "iscExtract",
"logFileName": None,
"siteIdOverride": None}
ifpnetCDF.main(**argv)
fname = fname + '.gz'
size = os.stat(fname)[stat.ST_SIZE]
endT = time.time()
logEvent('File Size: ', size)
logEvent('After ifpnetCDF, ,wctime:', "%-6.2f" % (endT - startT),
',cputime:', "%-6.2f" % time.clock())
# create XML destinations file for this output
iscE = Element('isc') #create the XML tree root
sourceServer = {'mhsid': mhsid, 'host': serverHost, 'port': serverPort,
'protocol': serverProtocol, 'site': siteID}
irt.addSourceXML(iscE, sourceServer)
irt.addDestinationXML(iscE, dest['serverInfo'])
#get the unique list of mhs sites
mhsSites = []
for si in dest['serverInfo']:
if si['mhsid'] not in mhsSites:
mhsSites.append(si['mhsid'])
# create the XML file
fnameXML = tempfile.mktemp(".xml")
fd = open(fnameXML, 'wb')
fd.write(ElementTree.tostring(iscE))
fd.close()
# Transmit files - do string substitution
irt.transmitFiles("ISCGRIDS2", mhsSites, mhsid, [fname,fnameXML], xmtScript)
# Delete temporary files
if maskName != "ISC_Send_Area":
iscUtil.deleteEditArea(maskName,siteID)
endT = time.time()
logEvent('After transmission pass, ,wctime:',
"%-6.2f" % (endT - startT), ',cputime:', "%-6.2f" % time.clock())
except:
logProblem("Failure", traceback.format_exc())

View file

@ -1,296 +0,0 @@
##
# 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.
##
import string, IrtAccess, JUtil, logging
import xml, pickle, tempfile, os, socket
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
import LogStream
from datetime import datetime
from time import gmtime, strftime
from java.io import File
from com.raytheon.uf.common.time import TimeRange
from com.raytheon.uf.common.dataplugin.gfe.db.objects import GridLocation
from com.raytheon.uf.common.dataplugin.gfe.reference import ReferenceData
CoordinateType = ReferenceData.CoordinateType
from com.raytheon.edex.plugin.gfe.config import IFPServerConfig
from com.raytheon.edex.plugin.gfe.config import IFPServerConfigManager
from com.raytheon.uf.common.localization import LocalizationFile
from com.raytheon.uf.common.localization import PathManagerFactory
from com.raytheon.uf.common.localization import LocalizationContext
LocalizationType = LocalizationContext.LocalizationType
LocalizationLevel = LocalizationContext.LocalizationLevel
#
# Utility module of isc functions
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 07/06/09 1995 bphillip Initial Creation.
# 02/19/13 1637 randerso Removed unused import
# 03/11/13 1759 dgilling Move siteConfig import into
# methods where it's needed.
# 11/07/13 2517 randerso Allow getLogger to override logLevel
# 01/22/14/ 2504 randerso Added hostname to log path
# 04/10/2014 17241 David Gillingham (code checked in by zhao)
# Apr 25, 2015 4952 njensen Updated for new JEP API
# 08/14/15 4750 dgilling Stop pickling ISC domainDicts.
#
#
def getEditArea(name, siteID):
pathMgr = PathManagerFactory.getPathManager();
commonStaticConfig = pathMgr.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.SITE)
commonStaticConfig.setContextName(siteID)
file = pathMgr.getFile(commonStaticConfig, "gfe/editAreas" + File.separator + name + ".xml")
if not os.path.exists(file.getPath()):
commonStaticConfig = pathMgr.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.CONFIGURED)
commonStaticConfig.setContextName(siteID)
file = pathMgr.getFile(commonStaticConfig, "gfe/editAreas" + File.separator + name + ".xml")
refData = None
try:
if os.path.exists(file.getPath()):
refData = ReferenceData.getJAXBManager().unmarshalFromXmlFile(file.getPath());
else:
LogStream.logProblem("EDIT AREA NOT FOUND: ", name, " for site ", siteID)
except:
LogStream.logProblem("Unable to unmarshal " + name + " in iscExtract")
return refData
def saveEditAreaGrid(maskName, iscMask, siteID):
iscMask.getPolygons(CoordinateType.LATLON);
pathMgr = PathManagerFactory.getPathManager();
commonStaticConfig = pathMgr.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.CONFIGURED)
commonStaticConfig.setContextName(siteID)
sitePath = pathMgr.getFile(commonStaticConfig, "gfe/editAreas").getPath()
editAreaPath = str(sitePath) + "/" + maskName + ".xml"
ReferenceData.getJAXBManager().marshalToXmlFile(iscMask, editAreaPath)
def deleteEditArea(name, siteID):
pathMgr = PathManagerFactory.getPathManager()
commonStaticConfig = pathMgr.getContext(LocalizationType.COMMON_STATIC, LocalizationLevel.CONFIGURED)
commonStaticConfig.setContextName(siteID)
file = pathMgr.getFile(commonStaticConfig, "gfe/editAreas" + File.separator + name + ".xml")
file.delete()
def transformTime(tr):
return (int(tr.getStart().getTime() / 1000), int(tr.getEnd().getTime() / 1000))
def toJavaTimeRange(tr):
return TimeRange(long(tr[0]) * long(1000), long(tr[1]) * long(1000))
def swapCoord(coord):
temp = coord.y
coord.y = coord.x
coord.x = temp
return coord
def serverBoxText(server):
#returns text based on the server dictionary that should be placed
#into the dialog
hostport = None
if server['host'][0:3] in ['dx4', 'px3'] and server['port'] in \
['98000000', '98000001']:
if server['port'] == "98000000":
hostport = server['host'] + "-primary"
elif server['port'] == "98000001":
hostport = server['host'] + "-svcbu"
if hostport is None:
hostport = server['host'] + "/" + server['port']
return server['site'] + "-> " + hostport + "@" + \
server['mhsid'].lower()
def sortServers(a, b):
# sort function for the list of servers. Sorts in priority order for
# most likely to have the data. Order is:
# dx4 or px3 98000000 site==mhsid
# dx4 or px3 98000001 site==mhsid
# dx4 or px3 98000000 site!=mhsid
# dx4 or px3 98000001 site!=mhsid
# all others in random order.
sameSiteA = (a['mhsid'] == a['site'])
sameSiteB = (b['mhsid'] == b['site'])
if sameSiteA and not sameSiteB:
return -1
elif not sameSiteA and sameSiteB:
return 1
#both are same sites, check for host next
else:
regHostA = (a['host'][0:3] in ['dx4', 'px3'])
regHostB = (b['host'][0:3] in ['dx4', 'px3'])
if regHostA and not regHostB:
return -1
elif not regHostA and regHostB:
return 1
# same host, but not preferred host
else:
regPortA = (a['port'] == "98000000")
regPortB = (b['port'] == "98000000")
if regPortA and not regPortB:
return -1
elif not regPortA and regPortB:
return 1
return 1 #must be non-standard, put at end of list
def createDomainDict(xml):
irt = IrtAccess.IrtAccess("")
#decodes the packet of information from the ISC_REQUEST_QUERY call
#to the ifpServer. This info will be used for creating the dialog.
# Returns the domainDict, which is keyed by domain, and contains
# a list of servers (each server in a dictionary with keys of
# mhsid, host, port, protocol, site.
try:
serverTree = ElementTree.ElementTree(ElementTree.XML(xml))
serversE = serverTree.getroot()
except:
LogStream.logProblem('Malformed XML in createDomainDict')
return None
if serversE.tag != "servers":
LogStream.logEvent('servers tag not found in createDomainDict')
return None #invalid xml
#decode XML and create dictionary and parms list
domains = {}
welist = []
serverDictS2T = {} #key=serverinfo, value=text on GUI
serverDictT2S = {} #key=text on GUI, value=serverinfo
for domainE in serversE:
if domainE.tag == "domain":
site = None
for name, value in domainE.items():
if name == "site":
site = value
break
if site is None:
LogStream.logProblem('Malformed domain site XML')
continue
for addressE in domainE.getchildren():
info = irt.decodeXMLAddress(addressE)
if not domains.has_key(site):
domains[site] = []
list = domains[site]
list.append(info)
guiText = serverBoxText(info)
serverDictT2S[guiText] = info
serverDictS2T[str(info)] = guiText
list.sort(sortServers)
domains[site] = list
elif domainE.tag == "welist":
for parmE in domainE.getchildren():
welist.append(parmE.text)
welist.sort()
retVal = {}
retVal['serverDictS2T'] = serverDictS2T
retVal['serverDictT2S'] = serverDictT2S
retVal['domains'] = domains
return retVal
def getRequestXML(xml, selectedServers, selectedWEList):
irt = IrtAccess.IrtAccess("")
selectedServers = JUtil.javaStringListToPylist(selectedServers)
selectedWElist = JUtil.javaStringListToPylist(selectedWEList)
response = createDomainDict(xml)
serverDictT2S = response['serverDictT2S']
domainDict = response['domains']
iscReqE = Element('iscrequest')
servers = []
for serverT in selectedServers:
server = serverDictT2S[serverT]
servers.append(server)
irt.addDestinationXML(iscReqE, servers)
welistE = SubElement(iscReqE, 'welist')
for we in selectedWElist:
weE = SubElement(welistE, 'parm')
weE.text = we
# output the list of servers and their priority
s = '\n'
for key in domainDict.keys():
s += "DOMAIN=" + key + '\n'
servers = selectedServers
for serverT in servers:
server = serverDictT2S[serverT]
if server['site'] == key:
s += " mhs=" + server['mhsid'] + " host=" + \
server['host'] + " port=" + server['port'] + "\n"
#LogStream.logEvent("Chosen request servers:", s)
# send to ifpServer
xmlreq = ElementTree.tostring(iscReqE)
return xmlreq;
def getLogger(scriptName, logName=None, logLevel=logging.INFO):
# be relocating this import here we allow
# com.raytheon.edex.plugin.gfe.isc.IscScript to dynamically
# modify its include path with the proper siteConfig just before
# execution time
import siteConfig
hostname = socket.gethostname().split('.')[0]
logPath = os.path.join(siteConfig.GFESUITE_LOGDIR, strftime("%Y%m%d", gmtime()), hostname)
if logName is None:
logName = scriptName + ".log"
else:
logDir = os.path.dirname(logName)
if len(logDir) > 0:
logPath = logDir
logName = os.path.basename(logName)
logFile = os.path.join(logPath, logName)
try:
os.makedirs(logPath)
except OSError as e:
import errno
if e.errno != errno.EEXIST:
raise e
theLog = logging.getLogger(scriptName)
theLog.setLevel(logLevel)
ch = logging.FileHandler(logFile)
ch.setLevel(logLevel)
formatter = logging.Formatter("%(levelname)s %(asctime)s [%(process)d:%(thread)d] %(filename)s: %(message)s")
ch.setFormatter(formatter)
for h in theLog.handlers:
theLog.removeHandler(h)
theLog.addHandler(ch)
return theLog
def tupleToString(*msg):
concatMsg = ""
for m in msg:
concatMsg = concatMsg + " " + str(m)
return concatMsg

View file

@ -1,99 +0,0 @@
#!/usr/bin/env python
##
# 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.
##
#
# Send Message to a list of WFOs
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 02/22/2016 5374 randerso Initial Creation.
# 07/11/2016 5774 randerso Change to send WFO message to all active
# IFP servers, not just "best"
#
##
import os, errno, tempfile
import xml
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
import IrtAccess
logger = None
def init_logging():
import iscUtil
import logging
global logger
logger = iscUtil.getLogger("sendWFOMessage", logLevel=logging.INFO)
def runFromJava(siteID, config, destSites, message):
import siteConfig
host = str(config.getServerHost())
port = str(config.getRpcPort())
protocol = str(config.getProtocolVersion())
mhsid = str(config.getMhsid())
ancf = str(config.iscRoutingTableAddress().get("ANCF"))
bncf = str(config.iscRoutingTableAddress().get("BNCF"))
xmtScript = str(config.transmitScript())
init_logging()
iscProductsDir = os.path.join(siteConfig.GFESUITE_HOME, "products", "ISC")
# get temporary file name for WFO message
with tempfile.NamedTemporaryFile(suffix='.sendWFOMessage', dir=iscProductsDir, delete=False) as fp:
fp.write(message)
fname = fp.name
sourceServer = {'mhsid' : mhsid,
'host' : host,
'port' : port,
'protocol': protocol,
'site' : siteID}
try:
if not destSites:
raise RuntimeError('No destSites supplied')
if not message:
raise RuntimeError('No message supplied')
irt = IrtAccess.IrtAccess(ancf, bncf, logger=logger)
msgSendDest, xml = irt.createDestinationXML(destSites, sourceServer, findBestMatch=False)
# create the XML file
with tempfile.NamedTemporaryFile(suffix='.xml', dir=iscProductsDir, delete=False) as fd:
fnameXML = fd.name
fd.write(ElementTree.tostring(xml))
if len(msgSendDest) > 0:
# Now send the message
logger.debug("msgSendDest: "+ str(msgSendDest))
irt.transmitFiles("SEND_WFO_MESSAGE", msgSendDest, mhsid, [fname, fnameXML], xmtScript)
except:
logger.exception('Error sending WFO message to sites:' + destSites + "\n" + message)

View file

@ -1,452 +0,0 @@
##
# 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.
##
# MergeVTEC - merges two "active" tables together.
# Originally written by Mark Mathewson FSL
#
# Port of MergeVTEC code from AWIPS1
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 01/25/13 1447 dgilling Initial Creation.
# 03/19/13 1447 dgilling Merge A1 DR 21434.
# 06/11/13 #2083 randerso Move backups to edex_static
# 01/24/14 #2504 randerso change to use iscUtil.getLogger for consistency
# 03/25/14 #2884 randerso Added xxxid to VTECChange
# 05/15/14 #3157 dgilling Support multiple TPC and SPC sites.
# 03/04/2015 #4129 randerso Log the active table changes at info level
# in the active table change log
# Apr 25, 2015 4952 njensen Updated for new JEP API
# May 22, 2015 4522 randerso Create proper primary key for ActiveTableRecord
# 06/21/16 #5709 dgilling Use TropicalCycloneUtil to bin tropical storms
# when comparing records.
# 08/04/16 #5747 dgilling Remove references to edex_static.
# 09/01/16 5872 dgilling Fix error-handling in previous revision.
# 02/01/17 6107 dgilling Ensure backups are written outside of localization.
#
##
import copy
import cPickle
import gzip
import os
import time
import iscUtil
import ActiveTableRecord
import siteConfig
import TropicalCycloneUtil
import VTECPartners
import VTECTableSqueeze
import VTECTableUtil
import JUtil
from java.util import ArrayList
from com.raytheon.uf.common.activetable import MergeResult
from com.raytheon.uf.common.activetable import VTECChange
from com.raytheon.uf.common.site import SiteMap
from com.raytheon.uf.common.activetable import VTECPartners as JavaVTECPartners
from com.raytheon.uf.edex.core import EDEXUtil
class MergeVTEC(VTECTableUtil.VTECTableUtil):
def __init__(self, activeTable, activeTableMode, newRecords, offsetSecs=0.0,
makeBackups=True, logger=None, atChangeLog=None):
# activeTable - current activeTable records
# activeTableMode - which table is being modified--OPERATIONAL or PRACTICE
# newRecords - records to merge in to activeTable
# inputIsGZIP (0,1) - remote input file is gzipped
# offsetSecs - Number of seconds +/- current time
# makeBackups (False, True) - make backups of previous table
# logger - python logging object to send all logs to
if logger is not None:
self._log = logger
else:
self._log = self.__initLogging()
# get our site
siteid = siteConfig.GFESUITE_SITEID
self._ourSite = self._get4ID(siteid)
# create a dummy name to simplify the file access code in VTECTableUtil
filePath = os.path.join(EDEXUtil.getEdexData(), "activetable", siteid)
fileName = os.path.join(filePath, activeTableMode + ".tbl")
# to ensure time calls are based on Zulu
os.environ['TZ'] = "GMT0"
self._time = time.time() + offsetSecs #present time
self._makeBackups = makeBackups
VTECTableUtil.VTECTableUtil.__init__(self, fileName)
# get the SPC site id from the configuration file
self._spcSite = JUtil.javaObjToPyVal(JavaVTECPartners.getInstance(siteid).getSpcSites("KWNS"))
self._tpcSite = JUtil.javaObjToPyVal(JavaVTECPartners.getInstance(siteid).getTpcSites("KNHC"))
self._siteFilter = self._getFilterSites()
self._log.info("MergeVTEC Starting")
self._log.info("localFN= " + self._activeTableFilename + " sites= "
+ repr(self._siteFilter))
#read table to merge
otherTable = newRecords
self._log.info("Remote Table size: %d", len(otherTable))
#read active table
self._log.info("Active Table size: %d", len(activeTable))
#save a copy for later backup purposes
oldActiveTable = copy.deepcopy(activeTable)
#delete "obsolete" records from our table and the other table
vts = VTECTableSqueeze.VTECTableSqueeze(self._time)
activeTable, tossRecords = vts.squeeze(activeTable)
self._log.info("Active Table squeezed size: %d", len(activeTable))
self._log.info("Other Table size: %d", len(otherTable))
otherTable, tossRecordsOther = vts.squeeze(otherTable)
self._log.info("Other Table squeezed size: %d", len(otherTable))
#merge the tables
updatedTable, toDelete, changes = self._mergeTable(activeTable, otherTable, atChangeLog)
self._log.info("Updated Active Table size: %d", len(updatedTable))
updatedTable, tossRecordsMerged = vts.squeeze(updatedTable)
self._log.info("Updated Active Table squeeze size: %d",
len(updatedTable))
del vts
self._updatedTable = []
self._purgedTable = []
self._changes = []
#notify the ifpServer of changes, save a backup copy
if tossRecords or tossRecordsMerged or changes:
self._log.debug("#tossRecords: %d", len(tossRecords))
self._log.debug("#tossRecordsMerged: %d", len(tossRecordsMerged))
self._log.debug("#changes: %d", len(changes))
# save lists for later retrieval
self._updatedTable = updatedTable
self._purgedTable.extend(tossRecords)
self._purgedTable.extend(toDelete)
self._purgedTable.extend([rec for rec in tossRecordsMerged if rec in oldActiveTable])
self._changes = changes
#save backup copy
if self._makeBackups:
oldActiveTable = self._convertTableToPurePython(oldActiveTable, siteid)
self.saveOldActiveTable(oldActiveTable)
pTime = getattr(VTECPartners, "VTEC_BACKUP_TABLE_PURGE_TIME",
168)
self.purgeOldSavedTables(pTime)
self._log.info("MergeVTEC Finished")
# merges the active and other table together and returns the merged
# table along with the list of changes that occurred.
def _mergeTable(self, activeTable, otherTable, atChangeLog):
changes = []
purges = []
compare = ['id', 'phen', 'sig', 'officeid', 'etn', 'pil']
compare1 = ['phen', 'sig', 'officeid']
compare2 = ['officeid', 'pil', 'phen', 'sig', 'etn']
missingEntriesPast = []
missingEntriesAct = []
newReplaceEntriesPast = []
oldReplaceEntriesPast = []
newReplaceEntriesAct = []
oldReplaceEntriesAct = []
ignoredNewReplaceAct = []
ignoredOldReplaceAct = []
currentYear = time.gmtime(self._time)[0]
terminations = ('CAN', 'EXP', 'UPG')
# Remove all records from the received table for events that
# have been cancelled and compacted in our active table
for rec in activeTable:
if rec['act'] not in terminations:
continue
recYear = time.gmtime(rec['issueTime'])[0]
# check if there are other related records
single = True
for rec2 in activeTable:
if self.hazardCompare(rec2, rec, compare2):
rec2Year = time.gmtime(rec2['issueTime'])[0]
if recYear == rec2Year and rec != rec2:
single = False
break
if single:
# remove all records for this event from the received table
for othRec in otherTable[::-1]:
if self.hazardCompare(rec, othRec, compare2):
othRecYear = time.gmtime(othRec['issueTime'])[0]
if othRecYear == recYear:
otherTable.remove(othRec)
# we process each entry in the other (received) table
for othRec in otherTable:
# filter out all other sites we aren't interested in
if self._siteFilter is not None and \
othRec['officeid'] not in self._siteFilter:
continue
# filter out ROU and COR codes
if othRec['act'] in ["ROU","COR"]:
continue
othRecYear = time.gmtime(othRec['issueTime'])[0]
# if the remote table has a single canceled record,
# copy the record if needed and remove the rest for the event
canceled = othRec['act'] in terminations
if canceled:
# determine if the remote table has a single record
for othRec2 in otherTable:
if self.hazardCompare(othRec2, othRec, compare2):
recYear = time.gmtime(othRec2['issueTime'])[0]
if recYear == othRecYear and othRec2['id'] != othRec['id']:
canceled = False
break
if canceled:
# find all the record in our active table for this event
matches = []
for i, rec in enumerate(activeTable):
if self.hazardCompare(rec, othRec, compare2):
atRecYear = time.gmtime(rec['issueTime'])[0]
if othRecYear == atRecYear:
matches.append(i)
changed = False
found = False
matches.reverse()
for i in matches:
rec = activeTable[i]
if rec['id'] == othRec['id']:
found = True
# replace record if not the same
if rec != othRec:
newReplaceEntriesAct.append(othRec)
oldReplaceEntriesAct.append(rec)
activeTable[i] = othRec
changed = True
else:
# remove other records for this event
oldReplaceEntriesAct.append(rec)
del activeTable[i]
changed = True
if not found:
# add the remote record
missingEntriesAct.append(othRec)
activeTable.append(othRec)
changed = True
if changed:
chgRec = (othRec['officeid'], othRec['pil'], othRec['phensig'], othRec['xxxid'])
if chgRec not in changes:
changes.append(chgRec)
# currently active events
elif othRec['endTime'] >= self._time:
# find a match in otherTable that is in our active table
# and replace it if newer, but only if it is from the same
# issuance year.
found = 0
for i in xrange(len(activeTable)):
if self.hazardCompare(activeTable[i], othRec, compare):
found = 1
atRecYear = time.gmtime(activeTable[i]['issueTime'])[0]
if othRec['issueTime'] > activeTable[i]['issueTime']:
if othRecYear == atRecYear:
newReplaceEntriesAct.append(othRec)
oldReplaceEntriesAct.append(activeTable[i])
activeTable[i] = othRec #replace the record
chgRec = (activeTable[i]['officeid'],
activeTable[i]['pil'], activeTable[i]['phensig'], activeTable[i]['xxxid'])
if chgRec not in changes:
changes.append(chgRec)
else:
ignoredNewReplaceAct.append(othRec)
ignoredOldReplaceAct.append(activeTable[i])
break
# if a match wasn't found, then we may need to add the record
# into our active table
if found == 0:
missingEntriesAct.append(othRec)
activeTable.append(othRec) #add the record
chgRec = (othRec['officeid'], othRec['pil'], othRec['phensig'], othRec['xxxid'])
if chgRec not in changes:
changes.append(chgRec)
# past events
else:
othRecYear = time.gmtime(othRec['issueTime'])[0]
if currentYear != othRecYear:
continue #only care about this year
# find the highest ETN for the current year per phen/sig
# in active table and compare to the other table. If found
# higher 'remote' record, replace the record.
maxETN = None
maxETNIndex = None
for i in xrange(len(activeTable)):
a = activeTable[i]
if self.hazardCompare(a, othRec, compare1) and \
time.gmtime(a['issueTime'])[0] == currentYear:
# special case for tropical storms
# ensure we have the same "class" of tropical storm
# class is determined by ETN
if a['phen'] in TropicalCycloneUtil.TROPICAL_PHENS:
othRecBasin = None
aRecBasin = None
try:
othRecBasin = TropicalCycloneUtil.get_tropical_storm_basin(othRec)
except ValueError:
self._log.error("Tropical Hazard record has invalid ETN: " + self.printEntry(othRec))
continue
try:
aRecBasin = TropicalCycloneUtil.get_tropical_storm_basin(a)
except ValueError:
self._log.error("Tropical Hazard record has invalid ETN: " + self.printEntry(a))
continue
if not aRecBasin or not othRecBasin or aRecBasin != othRecBasin:
continue
if maxETN is None or a['etn'] > maxETN:
maxETN = a['etn'] #save maxETN
maxETNIndex = i #save the index
if maxETN is not None and othRec['etn'] > maxETN:
newReplaceEntriesPast.append(othRec)
oldReplaceEntriesPast.append(activeTable[maxETNIndex])
activeTable[maxETNIndex] = othRec #replace record
chgRec = (othRec['officeid'], othRec['pil'], othRec['phensig'], othRec['xxxid'])
if chgRec not in changes:
changes.append(chgRec)
#if phen/sig not found, then add it
if maxETN is None:
missingEntriesPast.append(othRec)
activeTable.append(othRec) #add the record
chgRec = (othRec['officeid'], othRec['pil'], othRec['phensig'], othRec['xxxid'])
if chgRec not in changes:
changes.append(chgRec)
# log the changes
if atChangeLog is not None:
if len(missingEntriesAct):
atChangeLog.info("Active Missing entries added: " +
self.printActiveTable(missingEntriesAct, 1))
if len(newReplaceEntriesAct):
atChangeLog.info("Active Replacement entries (new): " +
self.printActiveTable(newReplaceEntriesAct, 1))
if len(oldReplaceEntriesAct):
atChangeLog.info("Active Entries Replaced (old): " +
self.printActiveTable(oldReplaceEntriesAct, 1))
if len(missingEntriesPast):
atChangeLog.info("Past Missing entries added " +
self.printActiveTable(missingEntriesPast, 1))
if len(newReplaceEntriesPast):
atChangeLog.info("Past Replacement entries (new): " +
self.printActiveTable(newReplaceEntriesPast, 1))
if len(oldReplaceEntriesPast):
atChangeLog.info("Past Entries Replaced (old): " +
self.printActiveTable(oldReplaceEntriesPast, 1))
if len(ignoredNewReplaceAct):
atChangeLog.info("Ignored Different Year Issuance (new): " +
self.printActiveTable(ignoredNewReplaceAct, 1))
atChangeLog.info("Ignored Different Year Issuance (old): " +
self.printActiveTable(ignoredOldReplaceAct, 1))
atChangeLog.info("Table Changes: " + str(changes))
return activeTable, purges, changes
def getMergeResults(self):
if not self._updatedTable and not self._purgedTable and not self._changes:
return None
updatedList = ArrayList()
for rec in self._updatedTable:
updatedList.add(rec.javaRecord())
purgedList = ArrayList()
for rec in self._purgedTable:
purgedList.add(rec.javaRecord())
changeList = ArrayList()
for c in self._changes:
changeList.add(VTECChange(c[0],c[1],c[2],c[3]))
result = MergeResult(updatedList, purgedList, changeList)
return result
def _getFilterSites(self):
#gets the list of filter sites, which is the list specified, plus
#SPC plus our own site. Returns None for no-filtering.
sites = getattr(VTECPartners, "VTEC_MERGE_SITES", [])
if sites is None:
return None
sites.extend(self._spcSite)
sites.extend(self._tpcSite)
sites.append(self._ourSite)
self._log.debug("Filter Sites: %s", sites)
return sites
#convert 3 letter to 4 letter site ids
def _get4ID(self, id):
return SiteMap.getInstance().getSite4LetterId(id)
def __initLogging(self):
import logging
return iscUtil.getLogger("MergeVTEC", logLevel=logging.INFO)
def merge(activeTable, activeTableMode, newRecords, drt=0.0, makeBackups=True,
logger=None, atChangeLog=None):
pyActive = []
for i in range(activeTable.size()):
pyActive.append(ActiveTableRecord.ActiveTableRecord(activeTable.get(i)))
pyNew = []
for i in range(newRecords.size()):
pyNew.append(ActiveTableRecord.ActiveTableRecord(newRecords.get(i)))
decoder = MergeVTEC(pyActive, activeTableMode, pyNew, drt, makeBackups, logger, atChangeLog)
mergeResults = decoder.getMergeResults()
decoder = None
return mergeResults

View file

@ -1,90 +0,0 @@
##
# 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.
##
#
# Port of ingestAT code from AWIPS1
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 02/13/13 1447 dgilling Initial Creation.
# 01/24/14 2504 randerso change to use iscUtil.getLogger for consistency
# 03/04/2015 4129 randerso Pass active table change logger through to MergeVtec.merge
#
##
import os
import time
import xml.etree.ElementTree as ET
import IrtAccess
import MergeVTEC
import siteConfig
import iscUtil
logger = None
def init_logging():
import logging
global logger
logger = iscUtil.getLogger("ingestAT", logLevel=logging.INFO)
def execute_ingest_at(incomingRecords, activeTable, atName, ztime, makeBackups, xmlIncoming, atChangeLog):
# log the source of this data
if xmlIncoming is not None:
irt = IrtAccess.IrtAccess("")
xmlTree = ET.ElementTree(ET.XML(xmlIncoming))
sourceE = xmlTree.find('source')
for addressE in sourceE.getchildren():
sourceServer = irt.decodeXMLAddress(addressE)
if sourceServer is None:
continue
logger.info("Source Server: " + irt.printServerInfo(sourceServer))
results = None
try:
results = MergeVTEC.merge(activeTable, atName, incomingRecords, ztime, makeBackups,
logger, atChangeLog)
except:
logger.exception("MergeVTEC fail:")
return results
def runFromJava(activeTable, activeTableMode, newRecords, drt, makeBackups,
xmlIncoming, atChangeLog=None):
init_logging()
logger.info('************* ingestAT ************************')
startT = time.time()
results = execute_ingest_at(newRecords, activeTable, activeTableMode, drt,
makeBackups, xmlIncoming, atChangeLog=atChangeLog)
#--------------------------------------------------------------------
# Finish
#--------------------------------------------------------------------
endT = time.time()
logger.info("Final: wctime: {0:-6.2f}, cputime: {1:-6.2f}".format(endT - startT, time.clock()))
return results

View file

@ -1,163 +0,0 @@
##
# 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.
##
#
# Port of requestAT code from AWIPS1
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 02/06/13 1447 dgilling Initial Creation.
# 01/24/14 2504 randerso change to use iscUtil.getLogger for consistency
# 05/15/14 #3157 dgilling Support multiple TPC and SPC sites.
# 03/10/2015 #4129 randerso Refactored server selection code into a reusable method
# 04/28/2015 #4027 randerso Expunged Calendar from ActiveTableRecord
#
#
import cPickle
import os
import sys
import tempfile
import time
from xml.etree import ElementTree
import IrtAccess
import siteConfig
import VTECPartners
import iscUtil
import JUtil
from com.raytheon.uf.common.activetable import ActiveTableMode
from com.raytheon.uf.common.time.util import TimeUtil
from com.raytheon.uf.edex.activetable import ActiveTable
from com.raytheon.uf.common.activetable import VTECPartners as JavaVTECPartners
logger = None
def init_logging():
import logging
global logger
logger = iscUtil.getLogger("requestAT", logLevel=logging.INFO)
def execute_request_at(serverHost, serverPort, serverProtocol, mhsid, siteID, ancf,
bncf, xmtScript):
#--------------------------------------------------------------------
# Create a message - pickled
# (MHSsiteID, mySiteID, listOfVTECMergeSites, countDict, issueTime)
# Note that VTEC_MERGE_SITES does not contain our site or SPC, TPC.
#--------------------------------------------------------------------
# determine my 4 letter siteid
if siteID in ['SJU']:
mysite4 = "TJSJ"
elif siteID in ['AFG','AJK','HFO','GUM']:
mysite4 = "P" + siteID
elif siteID in ['AER','ALU']:
mysite4 = "PAFC"
else:
mysite4 = "K" + siteID
otherSites = [mysite4]
tpcSites = JUtil.javaObjToPyVal(JavaVTECPartners.getInstance(siteID).getTpcSites())
spcSites = JUtil.javaObjToPyVal(JavaVTECPartners.getInstance(siteID).getSpcSites())
otherSites.extend(tpcSites)
otherSites.extend(spcSites)
# determine the MHS WMO id for this message
wmoid = "TTAA00 " + mysite4
wmoid += " " + time.strftime("%d%H%M", time.gmtime(time.time()))
# connect to ifpServer and retrieve active table
actTab = ActiveTable.getActiveTable(mysite4, ActiveTableMode.OPERATIONAL)
# analyze active table to get counts
countDict = {}
issueTime = 0
for i in xrange(actTab.size()):
rec = actTab.get(i)
# only care about our own sites that we merge
if rec.getOfficeid() not in VTECPartners.VTEC_MERGE_SITES and \
rec.getOfficeid() not in otherSites:
continue
recIssueTime = float(rec.getIssueTime().getTime() / TimeUtil.MILLIS_PER_SECOND)
#track latest
issueTime = max(recIssueTime, issueTime)
cnt = countDict.get(rec.getOfficeid(), 0) #get old count
countDict[rec.getOfficeid()] = cnt + 1
data = (mhsid, siteID, VTECPartners.VTEC_MERGE_SITES, countDict, issueTime)
logger.info("Data: " + repr(data))
tempdir = os.path.join(siteConfig.GFESUITE_HOME, "products", "ATBL")
with tempfile.NamedTemporaryFile(suffix='.reqat', dir=tempdir, delete=False) as fp:
fname = fp.name
buf = cPickle.dumps(data)
fp.write(buf)
sourceServer = {'mhsid' : mhsid,
'host' : serverHost,
'port' : serverPort,
'protocol': serverProtocol,
'site' : siteID}
destSites = VTECPartners.VTEC_TABLE_REQUEST_SITES
if not destSites:
raise Exception('No destSites defined for VTEC_TABLE_REQUEST_SITES')
irt = IrtAccess.IrtAccess(ancf, bncf, logger=logger)
msgSendDest, xml = irt.createDestinationXML(destSites, sourceServer)
# create the XML file
with tempfile.NamedTemporaryFile(suffix='.xml', dir=tempdir, delete=False) as fd:
fnameXML = fd.name
fd.write(ElementTree.tostring(xml))
#--------------------------------------------------------------------
# Now send the message
#--------------------------------------------------------------------
irt.transmitFiles("GET_ACTIVE_TABLE2", msgSendDest, mhsid,
[fname, fnameXML], xmtScript)
def runFromJava(serverHost, serverPort, serverProtocol, mhsid, siteID, ancf,
bncf, xmtScript):
init_logging()
logger.info('*********** requestAT ******************')
startT = time.time()
try:
execute_request_at(serverHost, serverPort, serverProtocol, mhsid,
siteID, ancf, bncf, xmtScript)
except:
logger.exception('Error requesting active table')
#--------------------------------------------------------------------
# Finish
#--------------------------------------------------------------------
endT = time.time()
logger.info("Final: wctime: {0:-6.2f}, cputime: {1:-6.2f}".format(endT - startT, time.clock()))

View file

@ -1,94 +0,0 @@
##
# 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.
##
#
# Request TCV Advisory Files
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 12/05/14 4953 randerso Initial Creation.
# 03/10/2015 #4129 randerso Refactored server selection code into a reusable method
#
##
import os, errno, tempfile
import xml
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
import IrtAccess
import VTECPartners
logger = None
def init_logging():
import iscUtil
import logging
global logger
logger = iscUtil.getLogger("requestTCV", logLevel=logging.INFO)
def runFromJava(siteID, config):
import siteConfig
host = str(config.getServerHost())
port = str(config.getRpcPort())
protocol = str(config.getProtocolVersion())
mhsid = str(config.getMhsid())
ancf = str(config.iscRoutingTableAddress().get("ANCF"))
bncf = str(config.iscRoutingTableAddress().get("BNCF"))
xmtScript = str(config.transmitScript())
init_logging()
tempdir = os.path.join(siteConfig.GFESUITE_HOME, "products", "TCV")
try:
os.makedirs(tempdir, 0755)
except OSError, e:
if e.errno != errno.EEXIST:
logger.warn("%s: '%s'" % (e.strerror,e.filename))
sourceServer = {'mhsid' : mhsid,
'host' : host,
'port' : port,
'protocol': protocol,
'site' : siteID}
try:
destSites = VTECPartners.VTEC_TABLE_REQUEST_SITES
if not destSites:
raise Exception('No destSites defined for VTEC_TABLE_REQUEST_SITES')
irt = IrtAccess.IrtAccess(ancf, bncf, logger=logger)
msgSendDest, xml = irt.createDestinationXML(destSites, sourceServer)
# create the XML file
with tempfile.NamedTemporaryFile(suffix='.xml', dir=tempdir, delete=False) as fd:
fnameXML = fd.name
fd.write(ElementTree.tostring(xml))
# don't send to ourselves
if mhsid in msgSendDest:
msgSendDest.remove(mhsid)
if len(msgSendDest) > 0:
# Now send the message
irt.transmitFiles("GET_TCV_FILES", msgSendDest, mhsid, [fnameXML], xmtScript)
except:
logger.exception('Error requesting TCV files for site: ' + siteID)

View file

@ -1,294 +0,0 @@
##
# 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.
##
#
# Port of sendAT code from AWIPS1
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 02/08/13 1447 dgilling Initial Creation.
# 01/24/14 2504 randerso change to use iscUtil.getLogger for consistency
# 05/15/14 #3157 dgilling Support multiple TPC and SPC sites.
# 03/10/2015 #4129 randerso Removed sys.exit() call
#
#
import cPickle
import gzip
import os
import time
import tempfile
import stat
from xml.etree import ElementTree
import IrtAccess
import JUtil
import siteConfig
import VTECPartners
import VTECTableSqueeze
import iscUtil
from com.raytheon.uf.common.activetable import VTECPartners as JavaVTECPartners
# Configuration Item for Test Purposes
FORCE_SEND = False #Set to True to always send even if no updates required.
logger = None
def init_logging():
import logging
global logger
logger = iscUtil.getLogger("sendAT", logLevel=logging.INFO)
def execute_send_at(myServerHost, myServerPort, myServerProtocol,
myServerMHSID, myServerSite, sites, filterSites, mhsSites,
issueTime, countDict, fname, xmlIncoming, xmtScript):
logger.info('reqSite= ' + repr(sites))
logger.info('filterSites= ' + repr(filterSites))
logger.info('mhsSite= ' + repr(mhsSites))
logger.info('reqCountDict= ' + repr(countDict))
if issueTime is None:
logger.info('reqIssueTime= None')
else:
logger.info('reqIssueTime= ' + str(issueTime) + ' ' +
time.asctime(time.gmtime(issueTime)))
irt = IrtAccess.IrtAccess("")
myServer = {'mhsid': myServerMHSID, 'host': myServerHost, 'port': myServerPort,
'protocol': myServerProtocol, 'site': myServerSite}
logger.info('MyServer: ' + irt.printServerInfo(myServer))
#--------------------------------------------------------------------
# Prepare the file for sending
#--------------------------------------------------------------------
with open(fname, 'rb') as fd:
buf = fd.read()
os.remove(fname)
table = cPickle.loads(buf) #unpickle it
logger.info("Local Table Length= " + str(len(table)))
filtTable = []
# filter by sites listing
if filterSites:
tpcSites = JUtil.javaObjToPyVal(JavaVTECPartners.getInstance(myServerSite).getTpcSites())
spcSites = JUtil.javaObjToPyVal(JavaVTECPartners.getInstance(myServerSite).getSpcSites())
for t in table:
if t['oid'] in filterSites or t['oid'][1:4] in sites or \
t['oid'] in tpcSites or t['oid'] in spcSites:
filtTable.append(t)
else:
filtTable = table #no filtering
logger.info("Site Filtered Table Length= " + str(len(filtTable)))
# eliminate obsolete records
ctime = time.time() #now time
vts = VTECTableSqueeze.VTECTableSqueeze(ctime)
filtTable = rename_fields_for_A2(filtTable)
actTable, tossRecords = vts.squeeze(filtTable)
actTable = rename_fields_for_A1(actTable)
logger.info("Squeezed Table Length= " + str(len(actTable)))
# check issuance time - any times newer in remote table (this table) than
# the local table (requesting site)?
if issueTime is not None:
newerRec = False
newestRec = 0.0
for t in actTable:
if newestRec < t['issueTime']:
newestRec = t['issueTime']
if issueTime < newestRec:
newerRec = True
logger.info("NewestFound= " + str(newestRec) + ' ' +
time.asctime(time.gmtime(newestRec)))
logger.info("IssueTime check. Newer record found= " + str(newerRec))
else:
newerRec = True #just assume there are newer records
# check "counts" for number of records. Any more records means that
# we may be missing some records.
if countDict:
missingRec = False
localCountDict = {}
for t in actTable:
if localCountDict.has_key(t['oid']):
localCountDict[t['oid']] = localCountDict[t['oid']] + 1
else:
localCountDict[t['oid']] = 1
for site in localCountDict:
reqCount = countDict.get(site, 0) #number in requesting site
if reqCount != localCountDict[site]: #records different in request site
missingRec = True
break
logger.info("MissingRec check. Missing record found= " + str(missingRec))
logger.info("lclCountBySite= " + repr(localCountDict))
logger.info("reqCountBySite= " + repr(countDict))
else:
missingRec = True #just assume there are
#should we send?
if missingRec or newerRec or FORCE_SEND:
sendIt = True
else:
sendIt = False
if sendIt:
actTablePickled = cPickle.dumps(actTable) #repickle it
rawSize = len(actTablePickled)
#output it as gzipped
fname = fname + ".gz"
with gzip.open(fname, 'wb', 6) as fd:
fd.write(actTablePickled)
gzipSize = os.stat(fname)[stat.ST_SIZE]
logger.info('#dataSize: ' + str(rawSize) + ', #gzipSize: ' + str(gzipSize))
#--------------------------------------------------------------------
# Create the destination XML file
#--------------------------------------------------------------------
iscOut = ElementTree.Element('isc')
irt.addSourceXML(iscOut, myServer)
destServers = []
if xmlIncoming is not None:
with open(xmlIncoming,'rb') as fd:
xml = fd.read()
os.remove(xmlIncoming)
reqTree = ElementTree.ElementTree(ElementTree.XML(xml))
sourceE = reqTree.find('source')
for addressE in sourceE.getchildren():
destServer = irt.decodeXMLAddress(addressE)
if destServer is None:
continue
destServers.append(destServer)
break
# no XML received on request, this is probably from an older site.
# create a dummy response XML file. Try all combinations. Only
# the mhsid is important for older sites.
else:
servers = []
for mhss in mhsSites:
for port in xrange(98000000, 98000002):
for site in sites:
for host in ['dx4f','px3']:
destServer = {'mhsid': mhss, 'host': host,
'port': port, 'protocol': "20070723",
'site': site}
destServers.append(destServer)
irt.addDestinationXML(iscOut, destServers) #add the dest server xml
# print out destinations
s = "Destinations:"
for destServer in destServers:
s += "\n" + irt.printServerInfo(destServer)
logger.info(s)
# create XML file
tempdir = os.path.join(siteConfig.GFESUITE_HOME, "products", "ATBL")
with tempfile.NamedTemporaryFile(suffix='.xml', dir=tempdir, delete=False) as fd:
fnameXML = fd.name
fd.write(ElementTree.tostring(iscOut))
#--------------------------------------------------------------------
# Send it
#--------------------------------------------------------------------
irt.transmitFiles("PUT_ACTIVE_TABLE2", mhsSites, myServerSite,
[fname, fnameXML], xmtScript)
else:
logger.info("Send has been skipped")
def rename_fields_for_A1(table):
newTable = []
for record in table:
record['oid'] = record['officeid']
del record['officeid']
record['vstr'] = record['vtecstr']
del record['vtecstr']
record['end'] = record['endTime']
del record['endTime']
record['start'] = record['startTime']
del record['startTime']
record['key'] = record['phensig']
del record['phensig']
if record.has_key('segText'):
record['text'] = record['segText']
del record['segText']
newTable.append(record)
return newTable
def rename_fields_for_A2(table):
newTable = []
for record in table:
record['officeid'] = record['oid']
del record['oid']
record['vtecstr'] = record['vstr']
del record['vstr']
record['endTime'] = record['end']
del record['end']
record['startTime'] = record['start']
del record['start']
record['phensig'] = record['key']
del record['key']
if record.has_key('text'):
record['segText'] = record['text']
del record['text']
newTable.append(record)
return newTable
def runFromJava(myServerHost, myServerPort, myServerProtocol, myServerMHSID,
myServerSite, sites, filterSites, mhsSites, issueTime,
countDict, fname, xmlIncoming, xmtScript):
init_logging()
logger.info('*********** sendAT ****************')
startT = time.time()
try:
sites = JUtil.javaObjToPyVal(sites)
filterSites = JUtil.javaObjToPyVal(filterSites)
mhsSites = JUtil.javaObjToPyVal(mhsSites)
countDict = JUtil.javaObjToPyVal(countDict)
execute_send_at(myServerHost, myServerPort, myServerProtocol,
myServerMHSID, myServerSite, sites, filterSites,
mhsSites, issueTime, countDict, fname, xmlIncoming,
xmtScript)
except:
logger.exception('Error in sendAT:')
raise
#--------------------------------------------------------------------
# Finish
#--------------------------------------------------------------------
endT = time.time()
logger.info("Final: wctime: {0:-6.2f}, cputime: {1:-6.2f}".format(endT - startT, time.clock()))

View file

@ -1,111 +0,0 @@
##
# 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.
##
#
# Send TCV Advisory Files to VTEC partners
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 12/05/14 4953 randerso Initial Creation.
# 03/10/2015 #4129 randerso Refactored server selection code into a reusable method
#
##
import os, errno, tempfile
import xml
from xml.etree import ElementTree
from xml.etree.ElementTree import Element, SubElement
import IrtAccess
import TCVUtil
import VTECPartners
logger = None
def init_logging():
import iscUtil
import logging
global logger
logger = iscUtil.getLogger("sendTCV", logLevel=logging.INFO)
def runFromJava(siteID, config):
import siteConfig
host = str(config.getServerHost())
port = str(config.getRpcPort())
protocol = str(config.getProtocolVersion())
mhsid = str(config.getMhsid())
ancf = str(config.iscRoutingTableAddress().get("ANCF"))
bncf = str(config.iscRoutingTableAddress().get("BNCF"))
xmtScript = str(config.transmitScript())
init_logging()
TCVUtil.purgeAllCanFiles(logger)
tcvProductsDir = os.path.join(siteConfig.GFESUITE_HOME, "products", "TCV")
# create tcvProductsDir if necessary
try:
os.makedirs(tcvProductsDir, 0755)
except OSError, e:
if e.errno != errno.EEXIST:
logger.warn("%s: '%s'" % (e.strerror,e.filename))
# get temporary file name for packaged TCV files
with tempfile.NamedTemporaryFile(suffix='.sendtcv', dir=tcvProductsDir, delete=False) as fp:
fname = fp.name
sourceServer = {'mhsid' : mhsid,
'host' : host,
'port' : port,
'protocol': protocol,
'site' : siteID}
try:
if TCVUtil.packageTCVFiles([siteID], fname, logger):
destSites = VTECPartners.VTEC_TABLE_REQUEST_SITES
if not destSites:
raise Exception('No destSites defined for VTEC_TABLE_REQUEST_SITES')
irt = IrtAccess.IrtAccess(ancf, bncf, logger=logger)
msgSendDest, xml = irt.createDestinationXML(destSites, sourceServer)
# create the XML file
with tempfile.NamedTemporaryFile(suffix='.xml', dir=tcvProductsDir, delete=False) as fd:
fnameXML = fd.name
fd.write(ElementTree.tostring(xml))
# don't send to ourselves
if mhsid in msgSendDest:
msgSendDest.remove(mhsid)
if len(msgSendDest) > 0:
# Now send the message
logger.debug("msgSendDest: "+ str(msgSendDest))
irt.transmitFiles("PUT_TCV_FILES", msgSendDest, mhsid, [fname, fnameXML], xmtScript)
else:
logger.info('No TCV files to send')
except:
logger.exception('Error sending TCV files for site: ' + siteID)

View file

@ -1,16 +0,0 @@
<configuration debug="false" scan="true">
<!--
The requestHydro EDEX mode is currently only used by the ALR site.
-->
<include file="${edex.home}/conf/logback-edex-properties.xml"/>
<include file="${edex.home}/conf/logback-edex-appenders.xml" />
<include file="${edex.home}/conf/logback-edex-loggers.xml" />
<include file="${edex.home}/conf/logback-edex-hibernate-logger.xml" />
<!-- default logging -->
<root>
<level value="INFO"/>
<appender-ref ref="asyncConsole"/>
</root>
</configuration>

View file

@ -1,11 +0,0 @@
#!/bin/bash
export MAX_MEM=1536 # in Meg
if [ $HIGH_MEM == "on" ]; then
export MAX_MEM=2048
fi
export SERIALIZE_POOL_MAX_SIZE=24
export SERIALIZE_STREAM_INIT_SIZE_MB=2
export SERIALIZE_STREAM_MAX_SIZE_MB=8
export EDEX_DEBUG_PORT=5005
export EDEX_JMX_PORT=1616
export MGMT_PORT=9601