From 92abcad349fffb45354f63a1ed060725d734c326 Mon Sep 17 00:00:00 2001 From: Ron Anderson Date: Wed, 20 Feb 2013 17:29:38 -0600 Subject: [PATCH] Issue #1597 Code cleanup and logging improvement for GFE Performance metrics Change-Id: Ib4d92b3c5a270e28a75beb5fbb5cf56557165765 Former-commit-id: bfe3c684df83e920821c6745754dfaf72d8c42ed [formerly bfe3c684df83e920821c6745754dfaf72d8c42ed [formerly 0b4b49014598aeb94492d0b713afe17732c6e029]] Former-commit-id: f37999b1eb01f22747364471c19a9205a15feeac Former-commit-id: 77fbbb6a61e80ba13aa459daba92e8b52fd6ebac --- .../textUtilities/headline/FormatterRunner.py | 9 +- .../log4j-viz-core-developer.xml | 69 ++++++++++ .../log4j-viz-core.xml | 10 +- .../uf/viz/core/time/TimeMatchingJob.java | 9 +- cave/com.raytheon.viz.gfe/res/spring/gfe.xml | 17 +++ .../raytheon/viz/gfe/BaseGfePyController.java | 4 +- .../raytheon/viz/gfe/actions/LoadWEGroup.java | 27 +++- .../viz/gfe/core/GfeClientConfig.java | 80 +++++++++++ .../core/internal/ReferenceSetManager.java | 7 +- .../raytheon/viz/gfe/core/parm/DbParm.java | 60 ++++++-- .../com/raytheon/viz/gfe/core/parm/Parm.java | 30 +--- .../raytheon/viz/gfe/core/parm/ParmOp.java | 2 + .../dialogs/AbstractSaveParameterDialog.java | 39 +++--- .../viz/gfe/dialogs/CopyGridsDialog.java | 18 ++- .../viz/gfe/dialogs/ProcessMonitorDialog.java | 63 ++++++--- .../viz/gfe/dialogs/PublishDialog.java | 20 ++- .../formatterlauncher/ProductEditorComp.java | 129 ++++++++++-------- .../gfe/procedures/ProcedureController.java | 19 ++- .../com/raytheon/viz/gfe/smarttool/Tool.java | 41 +++--- .../viz/gfe/textformatter/TextFormatter.java | 17 ++- .../developer.product | 11 +- .../edex_static/base/smartinit/Init.py | 18 +-- .../edex/plugin/gfe/server/GridParm.java | 1 + .../plugin/gfe/server/GridParmManager.java | 4 + .../gfe/server/database/GridDatabase.java | 2 + .../server/handler/SaveGfeGridHandler.java | 43 ++++-- .../uf/common/time/util/TimeUtil.java | 4 + .../com/raytheon/uf/common/util/FileUtil.java | 11 +- 28 files changed, 567 insertions(+), 197 deletions(-) create mode 100644 cave/com.raytheon.uf.viz.core/log4j-viz-core-developer.xml create mode 100644 cave/com.raytheon.viz.gfe/res/spring/gfe.xml create mode 100644 cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GfeClientConfig.java diff --git a/cave/build/static/common/cave/etc/gfe/userPython/textUtilities/headline/FormatterRunner.py b/cave/build/static/common/cave/etc/gfe/userPython/textUtilities/headline/FormatterRunner.py index 62c370af65..8db994740e 100644 --- a/cave/build/static/common/cave/etc/gfe/userPython/textUtilities/headline/FormatterRunner.py +++ b/cave/build/static/common/cave/etc/gfe/userPython/textUtilities/headline/FormatterRunner.py @@ -88,11 +88,17 @@ def executeFromJava(databaseID, site, username, dataMgr, forecastList, logFile, site = str(site) databaseID = str(databaseID) username = str(username) - logger.info("TextFormatter Starting") + + startTime = time.time() + logger.info("Text Formatter Starting") + forecasts = runFormatter(databaseID=databaseID, site=site, forecastList=forecastList, testMode=testMode, cmdLineVarDict=cmdLineVarDict, vtecMode=vtecMode, username=username, dataMgr=dataMgr, drtTime=drtTime) + elapsedTime = (time.time() - startTime)*1000 + logger.info("Text Formatter Finished, took: %d ms",elapsedTime) + RedirectLogging.restore() return forecasts @@ -286,7 +292,6 @@ def runFormatter(databaseID, site, forecastList, cmdLineVarDict, vtecMode, # This also means that you may not import any new modules after this # point!!!!!!!!!!!!!!! - logger.info("Text Formatter Finished") return forecasts def getAbsTime(timeStr): diff --git a/cave/com.raytheon.uf.viz.core/log4j-viz-core-developer.xml b/cave/com.raytheon.uf.viz.core/log4j-viz-core-developer.xml new file mode 100644 index 0000000000..890c5db443 --- /dev/null +++ b/cave/com.raytheon.uf.viz.core/log4j-viz-core-developer.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cave/com.raytheon.uf.viz.core/log4j-viz-core.xml b/cave/com.raytheon.uf.viz.core/log4j-viz-core.xml index 0f3729e653..5227c04b9a 100644 --- a/cave/com.raytheon.uf.viz.core/log4j-viz-core.xml +++ b/cave/com.raytheon.uf.viz.core/log4j-viz-core.xml @@ -43,15 +43,17 @@ - - - - + + + + + + diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/time/TimeMatchingJob.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/time/TimeMatchingJob.java index a5af323e6d..303ceb317b 100644 --- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/time/TimeMatchingJob.java +++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/time/TimeMatchingJob.java @@ -29,7 +29,9 @@ import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.services.IDisposable; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.viz.core.Activator; @@ -58,6 +60,9 @@ public class TimeMatchingJob extends Job { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(TimeMatchingJob.class); + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("Core:"); + static { Activator.getDefault().registerDisposable(new IDisposable() { @Override @@ -121,8 +126,8 @@ public class TimeMatchingJob extends Job { long t0 = System.currentTimeMillis(); request.getTimeMatcher().redoTimeMatching(request); long time = (System.currentTimeMillis() - t0); - if (time > 0) { - System.out.println("time matching took: " + time + "ms"); + if (time > 10) { + perfLog.logDuration("time matching", time); } if (!this.keepAround) { map.remove(request); diff --git a/cave/com.raytheon.viz.gfe/res/spring/gfe.xml b/cave/com.raytheon.viz.gfe/res/spring/gfe.xml new file mode 100644 index 0000000000..be0252e3cd --- /dev/null +++ b/cave/com.raytheon.viz.gfe/res/spring/gfe.xml @@ -0,0 +1,17 @@ + + + + + + + + + \ No newline at end of file diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/BaseGfePyController.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/BaseGfePyController.java index 79627e778d..d80b97f4b0 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/BaseGfePyController.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/BaseGfePyController.java @@ -173,10 +173,10 @@ public abstract class BaseGfePyController extends PythonScriptController { public void garbageCollect() { try { jep.eval("import gc"); - jep.eval("gc.collect()"); + jep.eval("gcResult = gc.collect()"); } catch (JepException e) { statusHandler.handle(Priority.PROBLEM, "Error garbage collecting GFE python interpreter", e); } -} + } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/LoadWEGroup.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/LoadWEGroup.java index 84c10c8029..ce34b400fc 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/LoadWEGroup.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/actions/LoadWEGroup.java @@ -24,7 +24,12 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.DataManagerUIFactory; import com.raytheon.viz.gfe.core.IParmManager; import com.raytheon.viz.gfe.core.IWEGroupManager; @@ -37,7 +42,8 @@ import com.raytheon.viz.gfe.core.IWEGroupManager; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Jun 9, 2008 chammack Initial creation - * Apr 9, 2009 1288 rjpeter Removed explicit refresh of SpatialDisplayManager. + * Apr 9, 2009 #1288 rjpeter Removed explicit refresh of SpatialDisplayManager. + * Feb 12, 2013 #1597 randerso Code cleanup and logging for GFE performance metrics * * * @author chammack @@ -45,25 +51,32 @@ import com.raytheon.viz.gfe.core.IWEGroupManager; */ public class LoadWEGroup extends AbstractHandler { + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); + @Override public Object execute(ExecutionEvent event) throws ExecutionException { + ITimer timer = TimeUtil.getTimer(); + timer.start(); String name = event.getParameter("name"); - if (name == null) + if (name == null) { return null; + } - IWEGroupManager weGroupMgr = DataManager.getCurrentInstance() - .getWEGroupManager(); + DataManager dm = DataManagerUIFactory.getCurrentInstance(); + IWEGroupManager weGroupMgr = dm.getWEGroupManager(); + IParmManager parmMgr = dm.getParmManager(); - IParmManager parmMgr = DataManager.getCurrentInstance() - .getParmManager(); ParmID[] parms = parmMgr.getAllAvailableParms(); - ParmID[] pidsToLoad = weGroupMgr.getParmIDs(name, parms); parmMgr.setDisplayedParms(pidsToLoad); + timer.stop(); + perfLog.logDuration("Load WE Group " + name, timer.getElapsedTime()); + return null; } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GfeClientConfig.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GfeClientConfig.java new file mode 100644 index 0000000000..fa81e168ff --- /dev/null +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GfeClientConfig.java @@ -0,0 +1,80 @@ +/** + * 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.core; + +/** + * Class to hold GFE client configuration settings. Actual settings are in + * com.raytheon.viz.gfe/res/spring/gfe.xml + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 28, 2013            randerso     Initial creation
+ * 
+ * 
+ * + * @author randerso + * @version 1.0 + */ + +public class GfeClientConfig { + + private int maxSaveThreads; + + private long gridSaveThreshold; + + private static final GfeClientConfig instance = new GfeClientConfig(); + + public static GfeClientConfig getInstance() { + return instance; + } + + private GfeClientConfig() { + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("GfeClientConfig:"); + sb.append("\n maxSaveThreads: ").append(maxSaveThreads); + sb.append("\n gridSaveThreshold: ").append(gridSaveThreshold); + return sb.toString(); + } + + public int getMaxSaveThreads() { + return maxSaveThreads; + } + + public void setMaxSaveThreads(int maxSaveThreads) { + this.maxSaveThreads = maxSaveThreads; + } + + public long getGridSaveThreshold() { + return gridSaveThreshold; + } + + public void setGridSaveThreshold(long gridSaveThreshold) { + this.gridSaveThreshold = gridSaveThreshold; + } + +} diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ReferenceSetManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ReferenceSetManager.java index a4067b9c28..60e63aa2bc 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ReferenceSetManager.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/ReferenceSetManager.java @@ -106,7 +106,8 @@ import com.vividsolutions.jts.geom.Envelope; * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- * Apr 1, 2008 #1053 randerso Initial creation - * 2/14/2013 #1506 mnash Move QueryScript to use new Python concurrency implementation + * 02/14/2013 #1506 mnash Move QueryScript to use new Python concurrency implementation + * 02/12/2013 #1597 randerso Improved error message for exceptions evaluating queries * * * @@ -1787,7 +1788,8 @@ public class ReferenceSetManager implements IReferenceSetManager, } } catch (JepException e) { statusHandler.handle(Priority.PROBLEM, - "Error evaluating query", e); + "Error evaluating query \"" + active.getQuery() + + "\" for " + active.getId().getName(), e); } } @@ -1810,6 +1812,7 @@ public class ReferenceSetManager implements IReferenceSetManager, "Unable to finish QueryScript job", e); } + @Override public void jobFinished(ReferenceData result) { getActiveRefSet(); if (!result.getGrid().equals(getActiveRefSet().getGrid())) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java index aa9d2efe9c..eaa89dd046 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java @@ -33,6 +33,7 @@ import org.eclipse.core.runtime.Status; import com.raytheon.uf.common.dataplugin.gfe.GridDataHistory; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord; +import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord.GridType; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation; import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridParmInfo; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; @@ -50,14 +51,19 @@ import com.raytheon.uf.common.dataplugin.gfe.slice.ScalarGridSlice; import com.raytheon.uf.common.dataplugin.gfe.slice.VectorGridSlice; import com.raytheon.uf.common.dataplugin.gfe.slice.WeatherGridSlice; import com.raytheon.uf.common.dataplugin.gfe.weather.WeatherKey; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.GFEOperationFailedException; import com.raytheon.viz.gfe.GFEServerException; import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.GfeClientConfig; import com.raytheon.viz.gfe.core.griddata.AbstractGridData; import com.raytheon.viz.gfe.core.griddata.IGridData; @@ -74,6 +80,8 @@ import com.raytheon.viz.gfe.core.griddata.IGridData; * 02/23/12 #346 dgilling Implement a dispose method. * 03/01/12 #346 dgilling Re-order dispose method. * 01/21/12 #1504 randerso Cleaned up old debug logging to improve performance + * 02/12/13 #1597 randerso Made save threshold a configurable value. Added detailed + * logging for save performance * * * @@ -85,8 +93,8 @@ public class DbParm extends Parm { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(DbParm.class); - // save if we accumulate more than 16 MB - private static final long MAX_SAVE_SIZE = 16 * 1024 * 1024; + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); public DbParm(ParmID parmID, GridParmInfo gridInfo, boolean mutable, boolean displayable, DataManager dataMgr) throws GFEServerException { @@ -475,6 +483,8 @@ public class DbParm extends Parm { return true; } + ITimer timer = TimeUtil.getTimer(); + timer.start(); ServerResponse> sr; try { sr = this.dataManager.getClient().requestLockChange(lreq); @@ -483,7 +493,12 @@ public class DbParm extends Parm { "Error requesting lock change", e); return false; } + timer.stop(); + perfLog.logDuration("Server lock change for " + this.getParmID() + " " + + lreq.size() + " time rangess", timer.getElapsedTime()); + timer.reset(); + timer.start(); List lockTableList = sr.getPayload(); for (LockTable lt : lockTableList) { // it is for our parm @@ -499,6 +514,8 @@ public class DbParm extends Parm { } } } + timer.stop(); + perfLog.logDuration("Processing lock tables", timer.getElapsedTime()); for (ServerMsg msg : sr.getMessages()) { statusHandler.error(msg.getMessage()); } @@ -509,23 +526,24 @@ public class DbParm extends Parm { @Override protected boolean saveParameterSubClass(List trs) { + ITimer timer = TimeUtil.getTimer(); + timer.start(); List myLocks = lockTable.lockedByMe(); if (myLocks.isEmpty()) { + timer.stop(); + perfLog.logDuration("Saving " + getParmID().getParmName() + ": " + + " no grids to save ", timer.getElapsedTime()); return true; } // FIXME: Purge functionality purgeUndoGrids(); - // assemble the save grid request and lock requests - // List gridsSaved = new ArrayList(); - List sgr = new ArrayList(); - List lreq = new ArrayList(); - List pendingUnlocks = new ArrayList(); - + // compute grid size in bytes GridLocation gloc = this.getGridInfo().getGridLoc(); + GridType gridType = this.getGridInfo().getGridType(); int gridSize = gloc.getNx() * gloc.getNy(); - switch (this.getGridInfo().getGridType()) { + switch (gridType) { case SCALAR: gridSize *= 4; // 4 bytes per grid cell break; @@ -538,7 +556,15 @@ public class DbParm extends Parm { // ignoring size of keys for now } + // assemble the save grid request and lock requests + List sgr = new ArrayList(); + List lreq = new ArrayList(); + List pendingUnlocks = new ArrayList(); + boolean success = true; + int gridCount = 0; + int totalGrids = 0; + long totalSize = 0; long size = 0; for (int i = 0; i < trs.size(); i++) { // ensure we have a lock for the time period @@ -582,10 +608,10 @@ public class DbParm extends Parm { record.setGridHistory(data.getHistory()); record.setMessageData(data.getGridSlice()); records.add(record); + gridCount += (gridType.equals(GridType.VECTOR) ? 2 : 1); size += gridSize; - if (size > MAX_SAVE_SIZE) { - // time range being saved in this chunk + if (size > GfeClientConfig.getInstance().getGridSaveThreshold()) { TimeRange tr = new TimeRange(saveTime.getStart(), data .getGridTime().getEnd()); sgr.add(new SaveGridRequest(getParmID(), tr, records, @@ -602,8 +628,12 @@ public class DbParm extends Parm { allSaved = false; } + totalGrids += gridCount; + totalSize += size; + pendingUnlocks.clear(); sgr.clear(); + gridCount = 0; records.clear(); size = 0; saveTime.setStart(tr.getEnd()); @@ -633,6 +663,9 @@ public class DbParm extends Parm { } else { success = false; } + + totalSize += size; + totalGrids += gridCount; pendingUnlocks.clear(); } @@ -650,6 +683,11 @@ public class DbParm extends Parm { purgeUndoGrids(); } + timer.stop(); + perfLog.logDuration("Save Grids " + getParmID().getParmName() + ": " + + totalGrids + " grids (" + totalSize + " bytes) ", + timer.getElapsedTime()); + return success; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/Parm.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/Parm.java index c1677cc3f0..6008a454ad 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/Parm.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/Parm.java @@ -176,6 +176,7 @@ import com.vividsolutions.jts.geom.Coordinate; * 03/02/2012 #346 dgilling Create a disposed flag to help ensure * no interaction with Parms after dispose * is called. + * 02/13/13 #1597 randerso Removed debug logging to improve performance * * * @author chammack @@ -293,11 +294,7 @@ public abstract class Parm implements Comparable { if (req != null) { this.setName("Interpolating " + req.parm.getParmID().getParmName() + "..."); - System.out.println("Starting interpolatation for " - + req.parm + " on job " + this); req.parm.doInterpolation(false); - System.out.println("Finished interpolatation for " - + req.parm + " on job " + this); this.schedule(); } return Status.OK_STATUS; @@ -1969,10 +1966,10 @@ public abstract class Parm implements Comparable { for (i = 0; i < this.undoBuffers.size(); i++) { UndoBuffer undoBuffer = this.undoBuffers.get(i); - String msg = "Undoing " + getParmID() + " tr=" - + undoBuffer.getUndoTimeRange(); - statusHandler.handle(Priority.DEBUG, msg, new Exception("Debug: " - + msg)); + // String msg = "Undoing " + getParmID() + " tr=" + // + undoBuffer.getUndoTimeRange(); + // statusHandler.handle(Priority.DEBUG, msg, new Exception("Debug: " + // + msg)); baffectedTR[i] = undoBuffer.getUndoTimeRange(); bgridCopies[i] = new ArrayList(); @@ -4287,23 +4284,6 @@ public abstract class Parm implements Comparable { // We will do the real work in a job for ASYNC mode else { InterpolateJob.request(this); - // Job job = new Job("Interpolating...") { - // - // @Override - // protected IStatus run(IProgressMonitor monitor) { - // try { - // doInterpolation(false); - // return Status.OK_STATUS; - // } catch (GFEOperationFailedException e) { - // return new Status(IStatus.ERROR, Activator.PLUGIN_ID, - // "Interpolation failed", e); - // } - // } - // - // }; - // job.setSystem(false); - // job.schedule(); - } return true; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmOp.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmOp.java index 0af5718f08..21d34e4792 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmOp.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/ParmOp.java @@ -80,6 +80,7 @@ import com.raytheon.viz.gfe.core.wxvalue.WxValue; * 06/24/2009 1876 njensen Publish updates inventory * 02/23/2012 1876 dgilling Implement missing clearUndoParmList * function. + * 02/13/2013 #1597 randerso Added logging to support GFE Performance metrics * * * @@ -386,6 +387,7 @@ public class ParmOp { */ public void interpolateSelected(InterpMode interpMode, InterpState interpState, int interval, int duration) { + statusHandler.debug("Interpolation started"); Parm[] allParms = this.dataManager.getParmManager().getAllParms(); for (Parm parm : allParms) { if (parm.getParmState().isSelected() && parm.isMutable()) { diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/AbstractSaveParameterDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/AbstractSaveParameterDialog.java index 7a6660917c..46cb855de0 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/AbstractSaveParameterDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/AbstractSaveParameterDialog.java @@ -40,11 +40,16 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.viz.gfe.core.DataManager; +import com.raytheon.viz.gfe.core.GfeClientConfig; import com.raytheon.viz.gfe.core.parm.Parm; import com.raytheon.viz.gfe.ui.HazardUIUtils; import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; @@ -60,6 +65,8 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * ------------ ---------- ----------- -------------------------- * Oct 26, 2011 randerso Initial creation * Oct 30, 2012 1298 rferrel Code clean for non-blocking dialog. + * 02/13/2013 #1597 randerso Made number of concurrent save threads a configurable value. + * Added logging to support GFE Performance metrics * * * @@ -72,7 +79,8 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog private final transient IUFStatusHandler statusHandler = UFStatus .getHandler(AbstractSaveParameterDialog.class); - private final int MAX_CONCURRENT_SAVES = 5; + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); protected DataManager dataManager; @@ -88,6 +96,8 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog protected Font font; + private ITimer saveTimer; + protected AbstractSaveParameterDialog(Shell parentShell, DataManager dataManager) { super(parentShell); @@ -101,7 +111,7 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog // see if Hazards WE is modified and if so save it this.hazParm = HazardUIUtils.hazardsWEModified(this.dataManager); this.hazardsModified = this.hazParm != null; - + this.saveTimer = TimeUtil.getTimer(); } /* @@ -145,6 +155,8 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog * Callback for saving the parameters */ protected void saveParms(List parmsToSave) { + saveTimer.reset(); + saveTimer.start(); this.getShell().setEnabled(false); final Cursor origCursor = this.getShell().getCursor(); this.getShell().setCursor( @@ -158,14 +170,14 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog @Override protected IStatus run(IProgressMonitor monitor) { - long t0 = System.currentTimeMillis(); final AtomicBoolean allSuccessful = new AtomicBoolean(true); try { - final CountDownLatch latch = new CountDownLatch( - MAX_CONCURRENT_SAVES); + GfeClientConfig cfg = GfeClientConfig.getInstance(); + int saveThreads = cfg.getMaxSaveThreads(); + final CountDownLatch latch = new CountDownLatch(saveThreads); // spawn separate jobs top save parms - for (int i = 0; i < MAX_CONCURRENT_SAVES; i++) { + for (int i = 0; i < saveThreads; i++) { new Job("Saving Parms") { @Override protected IStatus run(IProgressMonitor monitor) { @@ -176,12 +188,6 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog .toString(); try { // save data - if (statusHandler - .isPriorityEnabled(Priority.DEBUG)) { - statusHandler.handle( - Priority.DEBUG, - "Save: " + parmString); - } if (!parm.saveParameter(true)) { allSuccessful.set(false); } @@ -216,8 +222,6 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog statusHandler .handle(Priority.PROBLEM, "Some grids were not saved. See log for details."); - } else { - statusHandler.handle(Priority.DEBUG, "Save Complete"); } VizApp.runAsync(new Runnable() { @@ -230,10 +234,6 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog .saveFinished(allSuccessful.get()); } }); - - long t1 = System.currentTimeMillis(); - System.out.println("GFE Save Forecast took: " + (t1 - t0) - + " ms"); } return Status.OK_STATUS; } @@ -249,6 +249,9 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog } else { super.cancelPressed(); } + + saveTimer.stop(); + perfLog.logDuration("Save Forecast", saveTimer.getElapsedTime()); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/CopyGridsDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/CopyGridsDialog.java index fa7a0c5bfe..4a869696a2 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/CopyGridsDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/CopyGridsDialog.java @@ -32,6 +32,10 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.IParmManager; import com.raytheon.viz.gfe.core.UIFormat; @@ -45,8 +49,9 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Feb 26, 2008 Eric Babin Initial Creation + * Feb 26, 2008 Eric Babin Initial Creation * Oct 23, 2012 1287 rferrel Made dialog modal like AWIPS 1. + * 02/12/2013 #1597 randerso Adde logging to support GFE Performance metrics * * * @@ -55,6 +60,8 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; */ public class CopyGridsDialog extends CaveJFACEDialog { + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); private Composite top; @@ -173,16 +180,19 @@ public class CopyGridsDialog extends CaveJFACEDialog { } private void copyGrids() { + ITimer timer = TimeUtil.getTimer(); + timer.start(); + String s = groupList.getSelection()[0]; DatabaseID model = (DatabaseID) groupList.getData(s); - long t0 = System.currentTimeMillis(); if (isSelected) { dataManager.getParmOp().copySelectedFrom(model); } else { dataManager.getParmOp().copyEverythingFrom(model); } - System.out.println("copyGrids took " - + (System.currentTimeMillis() - t0) + " ms"); + + timer.stop(); + perfLog.logDuration("Copy Grids", timer.getElapsedTime()); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProcessMonitorDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProcessMonitorDialog.java index 01fdc2fed9..ce3de81b14 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProcessMonitorDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/ProcessMonitorDialog.java @@ -69,7 +69,8 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog; * SOFTWARE HISTORY * Date Ticket# Engineer Description * ------------ ---------- ----------- -------------------------- - * Mar 7, 2008 Eric Babin Initial Creation + * Mar 7, 2008 Eric Babin Initial Creation + * 02/12/2013 #1597 randerso Modified TaskOutputDialog to support GFE Performance metrics * * * @@ -445,8 +446,9 @@ public class ProcessMonitorDialog extends CaveJFACEDialog implements logText.setText(getLogFileContents()); Composite timeComp = new Composite(comp, SWT.NONE); - GridLayout layout = new GridLayout(2, true); + GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; + layout.verticalSpacing = 0; timeComp.setLayout(layout); layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); timeComp.setLayoutData(layoutData); @@ -454,32 +456,61 @@ public class ProcessMonitorDialog extends CaveJFACEDialog implements SimpleDateFormat sdf = new SimpleDateFormat( "EEE MMM d HH:mm:ss yyyy"); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); - Text startText = new Text(timeComp, SWT.BORDER | SWT.READ_ONLY - | SWT.WRAP); + + Composite startComp = new Composite(timeComp, SWT.NONE); + layout = new GridLayout(2, false); + layout.marginWidth = 0; + layout.verticalSpacing = 0; + startComp.setLayout(layout); + layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + startComp.setLayoutData(layoutData); + + Label label = new Label(startComp, SWT.NONE); Date date; - String s; if (task.getStartedTime() == null) { - s = "Queue Time: "; + label.setText("Queue Time:"); date = task.getQueuedTime(); } else { - s = "Start Time: "; + label.setText("Start Time:"); date = task.getStartedTime(); } - startText.setText(s + sdf.format(date)); - layoutData = new GridData(SWT.LEFT, SWT.DEFAULT, true, false); + + Text startText = new Text(startComp, SWT.BORDER | SWT.READ_ONLY); + startText.setText(sdf.format(date)); + layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); startText.setLayoutData(layoutData); + Composite elapsedComp = new Composite(timeComp, SWT.NONE); + layout = new GridLayout(2, false); + layout.marginWidth = 0; + layout.verticalSpacing = 0; + elapsedComp.setLayout(layout); + layoutData = new GridData(SWT.FILL, SWT.FILL, true, true); + elapsedComp.setLayoutData(layoutData); if (task.getFinishedTime() != null) { - Text endText = new Text(timeComp, SWT.BORDER | SWT.READ_ONLY - | SWT.WRAP); + label = new Label(elapsedComp, SWT.RIGHT); + layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false); + label.setText("Elapsed:"); + label.setLayoutData(layoutData); + + long delta = task.getFinishedTime().getTime() + - task.getStartedTime().getTime(); + Text elapsedText = new Text(elapsedComp, SWT.BORDER + | SWT.READ_ONLY); + elapsedText.setText(delta + " ms"); + layoutData = new GridData(SWT.RIGHT, SWT.DEFAULT, false, false); + elapsedText.setLayoutData(layoutData); + + label = new Label(startComp, SWT.NONE); if (task.getStatus() == TaskStatus.FINISHED) { - s = "End Time: "; + label.setText("End Time:"); } else { - s = "Canceled Time: "; + label.setText("Canceled Time:"); } - s += sdf.format(task.getFinishedTime()); - endText.setText(s); - layoutData = new GridData(SWT.RIGHT, SWT.DEFAULT, true, false); + + Text endText = new Text(startComp, SWT.BORDER | SWT.READ_ONLY); + endText.setText(sdf.format(task.getFinishedTime())); + layoutData = new GridData(SWT.FILL, SWT.DEFAULT, true, false); endText.setLayoutData(layoutData); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/PublishDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/PublishDialog.java index 92629760fa..b3a95f55e5 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/PublishDialog.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/PublishDialog.java @@ -50,10 +50,14 @@ import org.eclipse.swt.widgets.Shell; import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID; import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID; import com.raytheon.uf.common.dataplugin.gfe.server.request.CommitGridRequest; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.viz.gfe.Activator; import com.raytheon.viz.gfe.PythonPreferenceStore; @@ -77,6 +81,7 @@ import com.raytheon.viz.ui.widgets.ToggleSelectList; * Sep 01, 2009 #1370 randerso Completely reworked * Aug 05, 2010 6698 mpduff Moved Publish work to its own thread. * Oct 25, 2012 1287 rferrel Code cleanup for non-blocking dialog. + * 02/12/2013 #1597 randerso Added logging to support GFE Performance metrics * * * @@ -87,6 +92,9 @@ public class PublishDialog extends CaveJFACEDialog { private final transient IUFStatusHandler statusHandler = UFStatus .getHandler(PublishDialog.class); + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); + private final int MAX_LIST_HEIGHT = 10; private final PythonPreferenceStore prefs = Activator.getDefault() @@ -412,6 +420,9 @@ public class PublishDialog extends CaveJFACEDialog { } private void publishCB() { + final ITimer timer = TimeUtil.getTimer(); + timer.start(); + final Cursor origCursor = getShell().getCursor(); getShell().setCursor( getShell().getDisplay().getSystemCursor(SWT.CURSOR_WAIT)); @@ -435,8 +446,6 @@ public class PublishDialog extends CaveJFACEDialog { @Override protected IStatus run(IProgressMonitor monitor) { - long t0 = System.currentTimeMillis(); - try { // publish the data by calling the dataManager // publish function @@ -455,12 +464,13 @@ public class PublishDialog extends CaveJFACEDialog { public void run() { PublishDialog.this.getShell().setCursor(origCursor); PublishDialog.super.okPressed(); + + timer.stop(); + perfLog.logDuration("Publish Grids", + timer.getElapsedTime()); } }); - long t1 = System.currentTimeMillis(); - System.out.println("GFE Publish took " + (t1 - t0) + " ms"); - return Status.OK_STATUS; } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductEditorComp.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductEditorComp.java index a574bf1d0e..e2a9136500 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductEditorComp.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/formatterlauncher/ProductEditorComp.java @@ -101,6 +101,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.SimulatedTime; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.notification.INotificationObserver; @@ -148,6 +149,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * 08 Feb 2013 12851 jzeng Add menuToAddTo in create*Menu * Create createEditorPopupMenu() * Add mouselistener in createTextControl() for StyledText + * 02/12/2013 #1597 randerso Code cleanup. Fixed possible widget disposed errors on shut down. * * * @@ -171,7 +173,7 @@ public class ProductEditorComp extends Composite implements * Toolbar used to mimic a menu bar. */ private ToolBar toolbar; - + /** * Pop-up Menu */ @@ -515,7 +517,7 @@ public class ProductEditorComp extends Composite implements transLiveImg = getImageRegistry().get("transmitLive"); checkImg = getImageRegistry().get("checkmark"); menuItems = new ArrayList(); - + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); GridLayout gl = new GridLayout(1, false); gl.marginHeight = 1; @@ -576,7 +578,7 @@ public class ProductEditorComp extends Composite implements */ private void createToolbar() { toolbar = new ToolBar(this, SWT.NONE); - + fileMenu = new Menu(parent.getShell(), SWT.POP_UP); createFileMenu(fileMenu); editMenu = new Menu(parent.getShell(), SWT.POP_UP); @@ -643,7 +645,7 @@ public class ProductEditorComp extends Composite implements * Create the file menu. */ private void createFileMenu(Menu menuToAddTo) { - + MenuItem saveFileMI = new MenuItem(menuToAddTo, SWT.PUSH); saveFileMI.setText("Save File..."); saveFileMI.addSelectionListener(new SelectionAdapter() { @@ -662,7 +664,7 @@ public class ProductEditorComp extends Composite implements } }); menuItems.add(storeMI); - + // we can't color the background of the menu item so // we use an image like the tab folder. transmitMI = new MenuItem(menuToAddTo, SWT.PUSH); @@ -675,7 +677,7 @@ public class ProductEditorComp extends Composite implements } }); menuItems.add(transmitMI); - + // Menu Separator new MenuItem(menuToAddTo, SWT.SEPARATOR); @@ -757,7 +759,7 @@ public class ProductEditorComp extends Composite implements * Create the edit menu. */ private void createEditMenu(Menu menuToAddTo) { - + MenuItem undoMI = new MenuItem(menuToAddTo, SWT.PUSH); undoMI.setText("Undo"); undoMI.setEnabled(false); @@ -944,14 +946,14 @@ public class ProductEditorComp extends Composite implements textComp.setAutoWrapMode(wrapMode); createEditorPopupMenu(); - - textComp.getTextEditorST().addMouseListener(new MouseAdapter(){ - @Override - public void mouseDown(MouseEvent e) { - if (e.button == 3){ - popupMenu.setVisible(true); - } - } + + textComp.getTextEditorST().addMouseListener(new MouseAdapter() { + @Override + public void mouseDown(MouseEvent e) { + if (e.button == 3) { + popupMenu.setVisible(true); + } + } }); } @@ -1572,7 +1574,8 @@ public class ProductEditorComp extends Composite implements // check the ending time and transmission time if ((action.equals("EXP") || action.equals("CAN")) && vtecEnd != null) { - vtecEnd.setTime(vtecEnd.getTime() + 30 * 60 * 1000); + vtecEnd.setTime(vtecEnd.getTime() + 30 + * TimeUtil.MILLIS_PER_MINUTE); } if (vtecEnd != null @@ -1904,7 +1907,8 @@ public class ProductEditorComp extends Composite implements } // seconds - long offset = (maxPurgeTime - pitTime.getTime()) / 1000L; + long offset = (maxPurgeTime - pitTime.getTime()) + / TimeUtil.MILLIS_PER_SECOND; // Round up to nearest 15 minutes long extra = offset % 900; @@ -1913,7 +1917,7 @@ public class ProductEditorComp extends Composite implements } // convert to hours and check bounds - Float purgeOffset = offset / 3600.0F; + Float purgeOffset = (float) (offset / TimeUtil.SECONDS_PER_HOUR); purgeOffset = Math.min(purgeOffset, 24F); purgeOffset = Math.max(purgeOffset, 1F); @@ -1982,10 +1986,15 @@ public class ProductEditorComp extends Composite implements } private void updateExpireTime() { + if (textComp.isDisposed() || hoursSpnr.isDisposed() + || dateTimeLbl.isDisposed()) { + return; // we're shutting down just return + } - int hours = hoursSpnr.getSelection() / 100; - int minuteInc = (hoursSpnr.getSelection() % 100) / 25; - int purgeOffset = hours * 60 + minuteInc * 15; // minutes + int sel = hoursSpnr.getSelection(); + int hours = sel / 100; + int minuteInc = (sel % 100) / 25; + int purgeOffset = hours * TimeUtil.MINUTES_PER_HOUR + minuteInc * 15; // minutes Date now = SimulatedTime.getSystemTime().getTime(); Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); @@ -2173,13 +2182,16 @@ public class ProductEditorComp extends Composite implements } // round to next "roundMinutes" - long roundSec = roundMinutes * 60; - long expireTimeSec = expireTime.getTime() / 1000; // converting to - // seconds + long roundSec = roundMinutes * TimeUtil.SECONDS_PER_MINUTE; + + // converting to seconds + long expireTimeSec = expireTime.getTime() / TimeUtil.MILLIS_PER_SECOND; long delta = expireTimeSec % roundSec; - long baseTime = (expireTimeSec / roundSec) * roundSec * 1000; - if (delta / 60 >= 1) { - expireTime.setTime(baseTime + (roundSec * 1000)); + long baseTime = (expireTimeSec / roundSec) * roundSec + * TimeUtil.MILLIS_PER_SECOND; + if (delta / TimeUtil.SECONDS_PER_MINUTE >= 1) { + expireTime.setTime(baseTime + + (roundSec * TimeUtil.MILLIS_PER_SECOND)); } else { // within 1 minute, don't add next increment expireTime.setTime(baseTime); } @@ -2295,13 +2307,15 @@ public class ProductEditorComp extends Composite implements public void doAutoStuff() { int autoWrite = 0; Object autoWrite_obj = productDefinition.get("autoWrite"); - if (autoWrite_obj != null) + if (autoWrite_obj != null) { autoWrite = (Integer) autoWrite_obj; + } int autoStore = 0; Object autoStore_obj = productDefinition.get("autoStore"); - if (autoStore_obj != null) + if (autoStore_obj != null) { autoStore = (Integer) autoStore_obj; + } if (autoWrite == 1) { autoWrite(); @@ -2319,8 +2333,9 @@ public class ProductEditorComp extends Composite implements String fname = null; if (productDefinition.get("outputFile") != null) { fname = getDefString("outputFile"); - if (fname.equals(EMPTY)) + if (fname.equals(EMPTY)) { return; + } } else { return; } @@ -2341,8 +2356,9 @@ public class ProductEditorComp extends Composite implements * Replace {prddir} with siteConfig.GFESUITE_PRDDIR if applicable. */ private String fixfname(String fname) { - if (fname.contains("{prddir}")) + if (fname.contains("{prddir}")) { fname = fname.replace("{prddir}", prdDir); + } return fname; } @@ -2992,8 +3008,9 @@ public class ProductEditorComp extends Composite implements // reschedule job to run at the top of the next minute Calendar cal = Calendar.getInstance(); cal.setTime(SimulatedTime.getSystemTime().getTime()); - int nextMinute = 60 - cal.get(Calendar.SECOND); - schedule(nextMinute * 1000); + int secondsTilNextMinute = TimeUtil.SECONDS_PER_MINUTE + - cal.get(Calendar.SECOND); + schedule(secondsTilNextMinute * TimeUtil.MILLIS_PER_SECOND); return Status.OK_STATUS; } @@ -3015,36 +3032,36 @@ public class ProductEditorComp extends Composite implements return str; } - + /* - * Add Pop-up GUI for File, Edit, Options, and CallToActions - * at the location of mouse, when right click the mouse + * Add Pop-up GUI for File, Edit, Options, and CallToActions at the location + * of mouse, when right click the mouse */ - private void createEditorPopupMenu(){ - popupMenu = new Menu(textComp); - - MenuItem fileMI = new MenuItem(popupMenu, SWT.CASCADE); - fileMI.setText("File"); - Menu fileSubMenu = new Menu(popupMenu); - fileMI.setMenu(fileSubMenu); - createFileMenu(fileSubMenu); - + private void createEditorPopupMenu() { + popupMenu = new Menu(textComp); + + MenuItem fileMI = new MenuItem(popupMenu, SWT.CASCADE); + fileMI.setText("File"); + Menu fileSubMenu = new Menu(popupMenu); + fileMI.setMenu(fileSubMenu); + createFileMenu(fileSubMenu); + MenuItem editMI = new MenuItem(popupMenu, SWT.CASCADE); - editMI.setText("Edit"); + editMI.setText("Edit"); Menu editSubMenu = new Menu(popupMenu); - editMI.setMenu(editSubMenu); + editMI.setMenu(editSubMenu); createEditMenu(editSubMenu); - - MenuItem optionsMI = new MenuItem(popupMenu, SWT.CASCADE); - optionsMI.setText("Options"); + + MenuItem optionsMI = new MenuItem(popupMenu, SWT.CASCADE); + optionsMI.setText("Options"); Menu optionsSubMenu = new Menu(popupMenu); optionsMI.setMenu(optionsSubMenu); - createOptionsMenu(optionsSubMenu); - - MenuItem callToActionsMI = new MenuItem(popupMenu, SWT.CASCADE); - callToActionsMI.setText("CallToActions"); + createOptionsMenu(optionsSubMenu); + + MenuItem callToActionsMI = new MenuItem(popupMenu, SWT.CASCADE); + callToActionsMI.setText("CallToActions"); Menu callToActionsSubMenu = new Menu(popupMenu); - callToActionsMI.setMenu(callToActionsSubMenu); - createCallToActionsMenu(callToActionsSubMenu); + callToActionsMI.setMenu(callToActionsSubMenu); + createCallToActionsMenu(callToActionsSubMenu); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureController.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureController.java index 8c92a67310..595911f39e 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureController.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureController.java @@ -31,10 +31,14 @@ import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.PathManagerFactory; import com.raytheon.uf.common.python.PyConstants; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.viz.gfe.BaseGfePyController; import com.raytheon.viz.gfe.core.DataManager; @@ -47,6 +51,8 @@ import com.raytheon.viz.gfe.core.DataManager; * ------------ ---------- ----------- -------------------------- * Nov 5, 2008 njensen Initial creation * Jan 8, 2013 1486 dgilling Support changes to BaseGfePyController. + * 02/12/2013 #1597 randerso Added logging to support GFE Performance metrics + * * * * @author njensen @@ -57,6 +63,9 @@ public class ProcedureController extends BaseGfePyController { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(ProcedureController.class); + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); + private LocalizationFile proceduresDir; private LocalizationFile utilitiesDir; @@ -120,6 +129,9 @@ public class ProcedureController extends BaseGfePyController { */ public Object executeProcedure(String procedureName, Map args) throws JepException { + ITimer timer = TimeUtil.getTimer(); + timer.start(); + if (!isInstantiated(procedureName)) { instantiatePythonScript(procedureName); } @@ -131,7 +143,12 @@ public class ProcedureController extends BaseGfePyController { + procedureName); internalExecute("runProcedure", INTERFACE, args); - return getExecutionResult(); + Object result = getExecutionResult(); + + timer.stop(); + perfLog.logDuration("Running procedure " + procedureName, + timer.getElapsedTime()); + return result; } @Override diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java index 03255c0cda..b3ad84ad67 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java @@ -37,13 +37,16 @@ import com.raytheon.uf.common.dataplugin.gfe.reference.ReferenceData; import com.raytheon.uf.common.python.concurrent.AbstractPythonScriptFactory; import com.raytheon.uf.common.python.concurrent.IPythonExecutor; import com.raytheon.uf.common.python.concurrent.PythonJobCoordinator; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.TimeRange; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.viz.gfe.GFEOperationFailedException; -import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.core.DataManagerUIFactory; import com.raytheon.viz.gfe.core.IParmManager; import com.raytheon.viz.gfe.core.griddata.IGridData; @@ -66,7 +69,8 @@ import com.raytheon.viz.gfe.smarttool.script.SmartToolController; * ------------ ---------- ----------- -------------------------- * Feb 27, 2007 njensen Initial creation * Jan 08, 2013 1486 dgilling Support changes to BaseGfePyController. - * 2/14/2013 mnash Change QueryScript to use new Python concurrency + * 02/14/2013 mnash Change QueryScript to use new Python concurrency + * 02/20/2013 #1597 randerso Added logging to support GFE Performance metrics * * * @@ -78,6 +82,9 @@ public class Tool { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(Tool.class); + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); + private static final String CANCEL_MSG_START = "jep.JepException: : Cancel: Cancel >>>"; private final IParmManager parmMgr; @@ -98,7 +105,7 @@ public class Tool { */ private ReferenceData trueEditArea; - private PythonJobCoordinator coordinator = null; + private PythonJobCoordinator coordinator = null; /** * Constructor @@ -392,6 +399,9 @@ public class Tool { final ReferenceData editArea, TimeRange timeRange, String varDict, MissingDataMode missingDataMode, IProgressMonitor monitor) throws SmartToolException { + ITimer timer = TimeUtil.getTimer(); + timer.start(); + MissingDataMode dataMode; if (missingDataMode == null) { dataMode = Message.inquireLastMessage(MissingDataModeMsg.class) @@ -437,6 +447,7 @@ public class Tool { throw new SmartToolException(message); // AFPS.UserAlertMsg_send_mh(self.__msgHand, message, "A", "GFE") } + int numberOfGrids = grids.length; // Make sure parm is mutable if (parmToEdit != null) { @@ -458,14 +469,12 @@ public class Tool { // Iterate over time range // Process each grid in the time range. - int numberOfGrids = grids.length; - for (int i = 0; i < numberOfGrids; i++) { + boolean first = true; + for (IGridData grid : grids) { if (monitor.isCanceled()) { return; } - IGridData grid = grids[i]; - int index = i; // # Show progress on a grid basis for numeric and parm-based // if toolType == "numeric" or toolType == "parm-based": // percent = (index+1)/numberOfGrids * 100.0 @@ -479,7 +488,7 @@ public class Tool { } final Date timeInfluence; - Date seTime = DataManager.getCurrentInstance() + Date seTime = DataManagerUIFactory.getCurrentInstance() .getSpatialDisplayManager().getSpatialEditorTime(); if (grids.length == 1 && grid.getGridTime().contains(seTime)) { timeInfluence = seTime; @@ -487,14 +496,6 @@ public class Tool { timeInfluence = grid.getGridTime().getStart(); } TimeRange gridTimeRange = grid.getGridTime(); - boolean first = false; - // boolean last = false; - if (index == 0) { - first = true; - } - // if (index == numberOfGrids - 1) { - // last = true; - // } // Re-evaluate edit area if a query if (editArea.isQuery()) { @@ -505,7 +506,7 @@ public class Tool { IPythonExecutor executor = new QueryScriptExecutor( "evaluate", argMap); try { - Tool.this.trueEditArea = (ReferenceData) coordinator + Tool.this.trueEditArea = coordinator .submitSyncJob(executor); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, @@ -528,6 +529,7 @@ public class Tool { numeric(parmToEdit, first, trueEditArea, gridTimeRange, timeRange, timeInfluence, dataMode); + first = false; if (monitor.isCanceled()) { return; @@ -567,6 +569,11 @@ public class Tool { + toolName + ": " + e.getLocalizedMessage(), e); } finally { cleanUp(parmToEdit, saveParams, toolName, dataMode); + timer.stop(); + perfLog.logDuration("Running smartTool " + toolName + " for " + + numberOfGrids + " " + + this.inputParm.getParmID().getParmName() + " grids", + timer.getElapsedTime()); } } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java index 92de500c8a..137d46ccca 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/textformatter/TextFormatter.java @@ -24,10 +24,14 @@ import java.net.UnknownHostException; import java.util.HashMap; import java.util.UUID; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.common.status.UFStatus.Priority; import com.raytheon.uf.common.time.SimulatedTime; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.viz.core.VizApp; import com.raytheon.viz.gfe.core.DataManager; import com.raytheon.viz.gfe.dialogs.formatterlauncher.ConfigData; @@ -61,6 +65,9 @@ public class TextFormatter extends AbstractGfeTask { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(TextFormatter.class); + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); + private TextProductFinishListener listener; private HashMap argMap; @@ -113,10 +120,14 @@ public class TextFormatter extends AbstractGfeTask { argMap.put("logFile", getLogFile().getAbsolutePath()); script = FormatterScriptFactory.buildFormatterScript(); - long t0 = System.currentTimeMillis(); + ITimer timer = TimeUtil.getTimer(); + timer.start(); forecast = (String) script.execute(argMap); - long t1 = System.currentTimeMillis(); - System.out.println("Total text formatter time: " + (t1 - t0)); + timer.stop(); + String productName = (String) argMap + .get(ArgDictConstants.FORECAST_LIST); + perfLog.logDuration("Text Formatter " + productName, + timer.getElapsedTime()); state = ConfigData.productStateEnum.Finished; } catch (Throwable t) { diff --git a/cave/com.raytheon.viz.product.awips/developer.product b/cave/com.raytheon.viz.product.awips/developer.product index 760b4375e3..5374b87bfb 100644 --- a/cave/com.raytheon.viz.product.awips/developer.product +++ b/cave/com.raytheon.viz.product.awips/developer.product @@ -17,7 +17,14 @@ -data @user.home/caveData -user @user.home/caveData -clean -consoleLog -alertviz -Xincgc -Xmx1024M -Dosgi.instance.area.readOnly=true -Dosgi.hook.configurators.exclude=org.eclipse.core.runtime.internal.adaptor.EclipseLogHook,org.eclipse.core.runtime.internal.adaptor.EclipseErrorHandler --XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass -Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m -Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme -Dawips.mode=pypies -Dqpid.dest_syntax=BURL -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dlog4j.configuration=log4j-viz-core.xml +-XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass +-Dorg.eclipse.update.reconcile=false -XX:MaxPermSize=128m +-Dorg.eclipse.ui/KEY_CONFIGURATION_ID=com.raytheon.viz.ui.awips.scheme +-Dawips.mode=pypies -Dqpid.dest_syntax=BURL +-Dcom.sun.management.jmxremote +-Dcom.sun.management.jmxremote.authenticate=false +-Dcom.sun.management.jmxremote.ssl=false +-Dlog4j.configuration=log4j-viz-core-developer.xml -Dfile.encoding=UTF-8 @@ -35,10 +42,12 @@ + jdk1.6.0 + diff --git a/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py b/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py index bf83a957b9..be5b6c6a1e 100644 --- a/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py +++ b/edexOsgi/build.edex/esb/data/utility/edex_static/base/smartinit/Init.py @@ -1,19 +1,19 @@ ## # 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 +# 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 -# +# 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. ## diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/GridParm.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/GridParm.java index dac517bdbf..b76ae4d73f 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/GridParm.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/GridParm.java @@ -63,6 +63,7 @@ import com.raytheon.uf.edex.database.plugin.PluginFactory; * ------------ ---------- ----------- -------------------------- * 04/08/08 #875 bphillip Initial Creation * 06/17/08 #940 bphillip Implemented GFE Locking + * 02/10/13 #1603 randerso Returned number of records purged from timePurge * * * diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/GridParmManager.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/GridParmManager.java index 1288c3c7a9..f042abeea0 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/GridParmManager.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/GridParmManager.java @@ -81,6 +81,10 @@ import com.raytheon.uf.edex.database.purge.PurgeLogger; * 07/12/12 15162 ryu added check for invalid db * 10/10/12 #1260 randerso Added exception handling for domain not * overlapping the dataset + * 02/10/13 #1603 randerso General code cleanup, improved purge logging, + * fixed a purge inefficiency, + * fixed error which caused D2D purging to remove + * smartInit hdf5 data * * * diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/GridDatabase.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/GridDatabase.java index 96ef9157e7..cb585a4a47 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/GridDatabase.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/database/GridDatabase.java @@ -69,6 +69,8 @@ import com.raytheon.uf.common.time.TimeRange; * 05/04/12 #574 dgilling Update class to better match AWIPS1. * 01/14/13 #1469 bkowal The hdf5 data directory is no longer included * in the gfeBaseDataDir. + * 02/10/13 #1603 randerso Moved removeFromDb, removeFromHDF5 and deleteModelHDF5 + * methods down to IFPGridDatabase * * * diff --git a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/SaveGfeGridHandler.java b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/SaveGfeGridHandler.java index 38f871e7fa..d93986e64b 100644 --- a/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/SaveGfeGridHandler.java +++ b/edexOsgi/com.raytheon.edex.plugin.gfe/src/com/raytheon/edex/plugin/gfe/server/handler/SaveGfeGridHandler.java @@ -19,12 +19,9 @@ **/ package com.raytheon.edex.plugin.gfe.server.handler; -import java.util.Arrays; +import java.util.ArrayList; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import com.raytheon.edex.plugin.gfe.config.IFPServerConfig; import com.raytheon.edex.plugin.gfe.config.IFPServerConfigManager; import com.raytheon.edex.plugin.gfe.isc.IscSendQueue; @@ -39,6 +36,12 @@ import com.raytheon.uf.common.dataplugin.gfe.server.message.ServerResponse; import com.raytheon.uf.common.dataplugin.gfe.server.request.SaveGridRequest; import com.raytheon.uf.common.message.WsId; import com.raytheon.uf.common.serialization.comm.IRequestHandler; +import com.raytheon.uf.common.status.IPerformanceStatusHandler; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.PerformanceStatus; +import com.raytheon.uf.common.status.UFStatus; +import com.raytheon.uf.common.time.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; /** * GFE task for saving grids @@ -51,13 +54,18 @@ import com.raytheon.uf.common.serialization.comm.IRequestHandler; * 01/29/09 #1271 njensen Rewrote for thrift capabilities * 06/24/09 njensen Added sending notifications * 09/22/09 3058 rjpeter Converted to IRequestHandler + * 02/12/2013 #1597 randerso Added logging to support GFE Performance investigation * * * @author bphillip * @version 1.0 */ public class SaveGfeGridHandler implements IRequestHandler { - protected final transient Log logger = LogFactory.getLog(getClass()); + private static final transient IUFStatusHandler statusHandler = UFStatus + .getHandler(SaveGfeGridHandler.class); + + private final IPerformanceStatusHandler perfLog = PerformanceStatus + .getHandler("GFE:"); @Override public ServerResponse handleRequest(SaveGfeGridRequest request) @@ -72,14 +80,23 @@ public class SaveGfeGridHandler implements IRequestHandler { } try { + ITimer timer = TimeUtil.getTimer(); + timer.start(); sr = GridParmManager.saveGridData(saveRequest, workstationID, siteID); + timer.stop(); + perfLog.logDuration("Save Grids: GridParmManager.saveGridData", + timer.getElapsedTime()); // check for sending to ISC + timer.reset(); + timer.start(); IFPServerConfig serverConfig = IFPServerConfigManager .getServerConfig(siteID); String iscrta = serverConfig.iscRoutingTableAddress().get("ANCF"); if (serverConfig.requestISC() && clientSendStatus && iscrta != null) { + List iscSendRequests = new ArrayList( + saveRequest.size()); for (SaveGridRequest save : saveRequest) { DatabaseID dbid = save.getParmId().getDbId(); // ensure Fcst database @@ -91,19 +108,26 @@ public class SaveGfeGridHandler implements IRequestHandler { save.getParmId(), save.getReplacementTimeRange(), "", serverConfig.sendiscOnSave()); - IscSendQueue.sendToQueue(Arrays.asList(sendReq)); + iscSendRequests.add(sendReq); } } + IscSendQueue.sendToQueue(iscSendRequests); + + timer.stop(); + perfLog.logDuration("Save Grids: Queueing ISC send requests", + timer.getElapsedTime()); } } catch (GfeException e) { - logger.error("Error getting discrete or wx definition", e); + statusHandler.error("Error getting discrete or wx definition", e); sr = new ServerResponse(); sr.addMessage("Error getting discrete or wx definition on server"); } if (sr.isOkay()) { try { + ITimer timer = TimeUtil.getTimer(); + timer.start(); ServerResponse notifyResponse = SendNotifications.send(sr .getNotifications()); if (!notifyResponse.isOkay()) { @@ -111,8 +135,11 @@ public class SaveGfeGridHandler implements IRequestHandler { sr.addMessage(msg.getMessage()); } } + timer.stop(); + perfLog.logDuration("Save Grids: Sending notifications", + timer.getElapsedTime()); } catch (Exception e) { - logger.error("Error sending save notification", e); + statusHandler.error("Error sending save notification", e); sr.addMessage("Error sending save notification - " + e.getMessage()); } diff --git a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java index ac04d0011f..11e45ec039 100644 --- a/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java +++ b/edexOsgi/com.raytheon.uf.common.time/src/com/raytheon/uf/common/time/util/TimeUtil.java @@ -47,6 +47,7 @@ import com.raytheon.uf.common.time.domain.api.ITimePoint; * Jan 17, 2013 1357 mpduff Change MILLIS_PER_MONTH to MILLIS_PER_30_DAYS * Jan 22, 2013 1484 mpduff Add HOURS_PER_WEEK. * Jan 22, 2013 1519 djohnson Add MINUTES_PER_DAY. + * Feb 26, 2013 1597 randerso Add SECONDS_PER_HOUR. * * * @@ -96,6 +97,9 @@ public final class TimeUtil { public static final int MINUTES_PER_HOUR = 60; + public static final long SECONDS_PER_HOUR = SECONDS_PER_MINUTE + * MINUTES_PER_HOUR; + public static final int HOURS_PER_DAY = 24; public static final int HOURS_PER_HALF_DAY = HOURS_PER_DAY / 2; diff --git a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java index 1c606eb9e8..acec3776ed 100644 --- a/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java +++ b/edexOsgi/com.raytheon.uf.common.util/src/com/raytheon/uf/common/util/FileUtil.java @@ -52,6 +52,7 @@ import java.util.zip.GZIPOutputStream; * Jun 28, 2012 0819 djohnson Add write method. * Jul 06, 2012 798 jkorman Added more robust {@link #copyFile}. Added methods * to create temporary directories and files. + * 02/15/2013 #1597 randerso Fixed error when copying empty files * * * @@ -619,7 +620,7 @@ public class FileUtil { public static boolean isValidFilename(String fileName) { return VALID_FILENAME.matcher(fileName).matches(); } - + /** * Write the contents of an input stream to a file. * @@ -656,14 +657,15 @@ public class FileUtil { * An error occurred while copying the data. * @throws IllegalArgumentException * The position is less than zero or greater than the length of - * the source file or either of the source, target files are null. + * the source file or either of the source, target files are + * null. */ public static boolean copyFile(File source, File target, int position) throws IOException { boolean status = false; if (source != null) { if (target != null) { - if ((position >= 0) && (position < source.length())) { + if ((position >= 0) && (position <= source.length())) { FileInputStream fis = null; FileOutputStream fos = null; @@ -717,7 +719,8 @@ public class FileUtil { throw new IllegalArgumentException(msg); } } else { - throw new IllegalArgumentException("target file reference is null"); + throw new IllegalArgumentException( + "target file reference is null"); } } else { throw new IllegalArgumentException("source file reference is null");