Issue #3317 Fix issue with obsolete D2DGridDatabases not getting purged.

Change-Id: If792327215bb9f8db470c95099463e735c462d46

Former-commit-id: 898b30fadb [formerly 2a84ea1af7bb767e9e85387de1fd90c662f9f91d]
Former-commit-id: 2ac9cd84ec
This commit is contained in:
Ron Anderson 2014-06-25 13:06:02 -05:00
parent 1f033d22e6
commit ff5c0f2c33
2 changed files with 243 additions and 279 deletions

View file

@ -101,7 +101,7 @@ import com.raytheon.uf.edex.database.purge.PurgeLogger;
* D2DGridDatabase constructor
* 04/23/13 #1949 rjpeter Added inventory retrieval for a given time range.
* 05/02/13 #1969 randerso Fixed possible null pointer in getParmList
* Removed inventory from DBInvChangedNotification
* Removed inventory from DBInvChangeNotification
* 05/03/13 #1974 randerso Fixed error logging to include stack trace
* 05/14/13 #2004 randerso Added methods to synch GridParmManager across JVMs
* 05/30/13 #2044 randerso Refactored to better match A1 design. Removed D2DParmIDCache.
@ -119,6 +119,9 @@ import com.raytheon.uf.edex.database.purge.PurgeLogger;
* the same parm simultaneously.
* Added code to check the purge times when publishing and not publish
* data that is eligible to be purged.
* 06/24/2014 #3317 randerso Send DBInvChangeNotification when database is created, unless it's
* created in response to another DBInvChangeNotification so IFPServers stay in synch.
* Cleaned up commented code.
*
* </pre>
*
@ -832,6 +835,10 @@ public class GridParmManager {
* @return GridDatabase or null if not available
*/
public GridDatabase getDatabase(DatabaseID dbId) {
return getDatabase(dbId, true);
}
private GridDatabase getDatabase(DatabaseID dbId, boolean notify) {
// look up the database in the map
GridDatabase db = this.dbMap.get(dbId);
@ -846,12 +853,14 @@ public class GridParmManager {
ServerResponse<GridDatabase> status = createDB(dbId);
if (status.isOkay()) {
db = status.getPayload();
createDbNotification(Arrays.asList(dbId), null);
}
}
if (db != null) {
this.addDB(db);
if (notify) {
createDbNotification(Arrays.asList(dbId), null);
}
}
}
@ -1208,11 +1217,6 @@ public class GridParmManager {
ClusterTask ct = ClusterLockUtils.lookupLock(SMART_INIT_TASK_NAME,
SMART_INIT_TASK_DETAILS + siteID);
// TODO: reconsider this as changes to localConfig may change what
// smartInits should be run
// TODO: re-enable check
// if ((ct.getLastExecution() + SMART_INIT_TIMEOUT) < System
// .currentTimeMillis()) {
ct = ClusterLockUtils
.lock(SMART_INIT_TASK_NAME, SMART_INIT_TASK_DETAILS
+ siteID, SMART_INIT_TIMEOUT, false);
@ -1495,25 +1499,7 @@ public class GridParmManager {
ServerResponse<GridDatabase> sr = new ServerResponse<GridDatabase>();
for (DatabaseID dbId : invChanged.getAdditions()) {
// TODO: This is pretty much just a duplicate of what's in
// getDatabase.
// Verify this works and then remove this commented code
// if (dbId.getDbType().equals("D2D")) {
// String d2dModelName = config.d2dModelNameMapping(dbId
// .getModelName());
// D2DGridDatabase db = D2DGridDatabase.getDatabase(config,
// d2dModelName, dbId.getModelDate());
// if (db != null) {
// this.addDB(db);
// }
// statusHandler
// .info("handleGfeNotification new D2D database: "
// + dbId);
// } else {
// sr = this.createDB(dbId);
// }
this.getDatabase(dbId);
this.getDatabase(dbId, false);
}
if (!sr.isOkay()) {
statusHandler.error("Error updating GridParmManager: "
@ -1574,31 +1560,6 @@ public class GridParmManager {
DatabaseID satDbid = D2DSatDatabase.getDbId(siteID);
// TODO why are we processing adds in a purge method. We should get adds
// via other means
// Verify and remove the commented code
// List<DatabaseID> added = new ArrayList<DatabaseID>(newInventory);
// added.removeAll(currentInventory);
// Iterator<DatabaseID> iter = added.iterator();
// while (iter.hasNext()) {
// DatabaseID dbid = iter.next();
// // remove satellite database and non-D2D databases from adds
// if (!dbid.getDbType().equals("D2D") || dbid.equals(satDbid)) {
// iter.remove();
// } else {
// // add the new database
// try {
// D2DGridDatabase db = new D2DGridDatabase(config, dbid);
// addDB(db);
// statusHandler.info("d2dGridDataPurged new D2D database: "
// + dbid);
// } catch (Exception e) {
// statusHandler.handle(Priority.PROBLEM,
// e.getLocalizedMessage(), e);
// }
// }
// }
List<DatabaseID> deleted = new ArrayList<DatabaseID>(currentInventory);
deleted.removeAll(newInventory);
Iterator<DatabaseID> iter = deleted.iterator();

View file

@ -114,6 +114,8 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
* Added function to create a D2DGridDatabase object only if there is
* data in postgres for the desired model/reftime
* 04/17/2014 #2934 dgilling Change getGridParmInfo to use D2DParm's GridParmInfo.
* 06/24/2014 #3317 randerso Don't allow database to be created if it exceeds D2DDBVERSIONS and
* should be purged.
*
* </pre>
*
@ -176,8 +178,9 @@ public class D2DGridDatabase extends VGridDatabase {
String d2dModelName, Date refTime) {
try {
GFED2DDao dao = new GFED2DDao();
// TODO create query for single refTime
List<Date> result = dao.getModelRunTimes(d2dModelName, -1);
int dbVersions = config.desiredDbVersions(getDbId(d2dModelName,
refTime, config));
List<Date> result = dao.getModelRunTimes(d2dModelName, dbVersions);
if (result.contains(refTime)) {
D2DGridDatabase db = new D2DGridDatabase(config, d2dModelName,