Merge branch 'master_14.3.1' into master_14.3.2
Former-commit-id:d2f4ae19cb
[formerly62eb3e7a36
[formerly dea7e3843165baa43bde3eeafd94329dc7fd98a7]] Former-commit-id:62eb3e7a36
Former-commit-id:9c374de355
This commit is contained in:
commit
6d00765e77
3 changed files with 130 additions and 111 deletions
|
@ -124,7 +124,7 @@ public class RadarServer implements RadarEventListener {
|
||||||
addListener(new DedicatedRadarActivator(this));
|
addListener(new DedicatedRadarActivator(this));
|
||||||
addListener(new RequestScheduler(this));
|
addListener(new RequestScheduler(this));
|
||||||
addListener(new RadarServerAvailable(this));
|
addListener(new RadarServerAvailable(this));
|
||||||
addListener(new RadarWatchdogListener(configuration));
|
addListener(new RadarWatchdogListener(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(RadarEventListener l) {
|
public void addListener(RadarEventListener l) {
|
||||||
|
|
|
@ -29,7 +29,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import com.raytheon.rcm.config.Configuration;
|
import com.raytheon.rcm.config.RadarConfig;
|
||||||
|
import com.raytheon.rcm.server.StatusManager.RadarStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -43,6 +44,8 @@ import com.raytheon.rcm.config.Configuration;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------- ---------- ----------- --------------------------
|
* ------------- ---------- ----------- --------------------------
|
||||||
* May 12, 2014 DR 16319 dhuffman Initial creation.
|
* May 12, 2014 DR 16319 dhuffman Initial creation.
|
||||||
|
* Feb 10, 2015 DR 17112 D. Friedman Only alarm on dedicated radars and
|
||||||
|
* once per detected failure.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -56,18 +59,16 @@ public class RadarWatchdog extends Thread {
|
||||||
|
|
||||||
protected static class GsmItem {
|
protected static class GsmItem {
|
||||||
protected String radarID;
|
protected String radarID;
|
||||||
protected int vcp;
|
protected int trackedVcp;
|
||||||
protected long time;
|
protected int currentVcp;
|
||||||
protected long alarmTime;
|
protected boolean failed;
|
||||||
protected long nextAlarmTime;
|
|
||||||
|
|
||||||
protected GsmItem() {
|
protected GsmItem() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static class RadarItem {
|
protected static class RadarItem {
|
||||||
protected String radarID;
|
protected boolean isNew;
|
||||||
protected String mnemonic;
|
|
||||||
protected long time;
|
protected long time;
|
||||||
protected long messageTime;
|
protected long messageTime;
|
||||||
|
|
||||||
|
@ -75,7 +76,10 @@ public class RadarWatchdog extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long startTime = 0;
|
protected static class WatchedRadar {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private long shortestWait = 0;
|
private long shortestWait = 0;
|
||||||
private static final long fudgeTime = 30;
|
private static final long fudgeTime = 30;
|
||||||
|
|
||||||
|
@ -84,13 +88,13 @@ public class RadarWatchdog extends Thread {
|
||||||
private static Map<Integer, Integer> mapDuration = new ConcurrentHashMap<Integer, Integer>();
|
private static Map<Integer, Integer> mapDuration = new ConcurrentHashMap<Integer, Integer>();
|
||||||
private static List<String> mapMnemonicProducts = new ArrayList<String>();
|
private static List<String> mapMnemonicProducts = new ArrayList<String>();
|
||||||
|
|
||||||
protected Configuration configuration;
|
protected RadarServer radarServer;
|
||||||
private static String configFileName = "radarWatchdog.txt";
|
private static String configFileName = "radarWatchdog.txt";
|
||||||
|
|
||||||
protected RadarWatchdog(Configuration conf) {
|
protected RadarWatchdog(RadarServer radarServer) {
|
||||||
|
super("Watchdog");
|
||||||
setDaemon(true);
|
setDaemon(true);
|
||||||
startTime = System.currentTimeMillis();
|
this.radarServer = radarServer;
|
||||||
configuration = conf;
|
|
||||||
|
|
||||||
loadConfigFile(configFileName);
|
loadConfigFile(configFileName);
|
||||||
|
|
||||||
|
@ -102,112 +106,145 @@ public class RadarWatchdog extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GsmItem getGSMItem(final String radarID) {
|
public synchronized void notifyGsm(String radarID, int vcp) {
|
||||||
return mapGSM.get(radarID);
|
GsmItem item = mapGSM.get(radarID);
|
||||||
}
|
if (item != null) {
|
||||||
|
item.currentVcp = vcp;
|
||||||
public void putGSMItem(GsmItem gi) {
|
notifyWatchdog();
|
||||||
if (gi != null) {
|
} else {
|
||||||
mapGSM.put(gi.radarID, gi);
|
if (isTrackedRadar(radarID)) {
|
||||||
}
|
item = new GsmItem();
|
||||||
}
|
item.radarID = radarID;
|
||||||
|
item.currentVcp = vcp;
|
||||||
public RadarItem getRadarItem(final String Mnemonic, final String radarID) {
|
mapGSM.put(radarID, item);
|
||||||
Map<String, RadarItem> mapRadar = mapMnemonic.get(Mnemonic);
|
notifyWatchdog();
|
||||||
if (mapRadar != null)
|
|
||||||
return mapRadar.get(radarID);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void putRadarItem(RadarItem ri) {
|
|
||||||
if (ri != null) {
|
|
||||||
Map<String, RadarItem> mapRadar = mapMnemonic.get(ri.mnemonic);
|
|
||||||
if (mapRadar != null) {
|
|
||||||
mapRadar.put(ri.radarID, ri);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isTrackedRadar(String radarID) {
|
||||||
|
RadarConfig rc = radarServer.getConfiguration().getConfigForRadar(radarID);
|
||||||
|
return rc != null && rc.isDedicated();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void notifyRadarItem(String radarID, String mnemonic, long messageTime, long time) {
|
||||||
|
if (! isTrackedRadar(radarID))
|
||||||
|
return;
|
||||||
|
|
||||||
|
RadarItem ri = getRadarItem(mnemonic, radarID);
|
||||||
|
if (ri != null) {
|
||||||
|
ri.isNew = false;
|
||||||
|
ri.messageTime = messageTime;
|
||||||
|
ri.time = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RadarItem getRadarItem(final String mnemonic, final String radarID) {
|
||||||
|
Map<String, RadarItem> mapRadar = mapMnemonic.get(mnemonic);
|
||||||
|
if (mapRadar != null) {
|
||||||
|
RadarItem ri = mapRadar.get(radarID);
|
||||||
|
if (ri == null) {
|
||||||
|
ri = new RadarItem();
|
||||||
|
ri.isNew = true;
|
||||||
|
mapRadar.put(radarID, ri);
|
||||||
|
}
|
||||||
|
return ri;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long currentTime = 0;
|
|
||||||
shortestWait = 0;
|
shortestWait = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
synchronized (semifore) {
|
synchronized (semifore) {
|
||||||
semifore.wait(shortestWait < 800 ? 800 : shortestWait);
|
semifore.wait(shortestWait < 800 ? 800 : shortestWait);
|
||||||
currentTime = System.currentTimeMillis();
|
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
patrol(currentTime);
|
patrol(System.currentTimeMillis());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void patrol(long currentTime) {
|
private synchronized void patrol(long currentTime) {
|
||||||
long duration = 0;
|
long duration = 0;
|
||||||
long adjustedTime = currentTime - fudgeTime;
|
long earliestCheckTime = 0;
|
||||||
shortestWait = 0;
|
|
||||||
Iterator<GsmItem> git = mapGSM.values().iterator();
|
Iterator<GsmItem> git = mapGSM.values().iterator();
|
||||||
while (git.hasNext()) {
|
while (git.hasNext()) {
|
||||||
GsmItem gi = git.next();
|
GsmItem gi = git.next();
|
||||||
if (mapDuration.get(gi.vcp) != null) {
|
|
||||||
duration = mapDuration.get(gi.vcp) * 1000;
|
|
||||||
|
|
||||||
Iterator<String> mnem = mapMnemonicProducts.iterator();
|
if (! isTrackedRadar(gi.radarID)) {
|
||||||
while (mnem.hasNext()) {
|
git.remove();
|
||||||
String mn = mnem.next();
|
continue;
|
||||||
Map<String, RadarItem> mapRadar = mapMnemonic.get(mn);
|
}
|
||||||
if (mapRadar == null)
|
|
||||||
continue;
|
|
||||||
RadarItem ri = mapRadar.get(gi.radarID);
|
|
||||||
|
|
||||||
if (ri == null) {
|
/* There will be an alarm when the radar connection goes down, so
|
||||||
if (duration + startTime < adjustedTime
|
* do not do any additional alarming.
|
||||||
&& gi.alarmTime != startTime) {
|
*/
|
||||||
alert(duration, gi, mn);
|
RadarStatus rs = radarServer.getStatusManager().getRadarStatus(gi.radarID);
|
||||||
gi.alarmTime = startTime;
|
if (rs != null && rs.getCurrentGSM() == null) {
|
||||||
gi.nextAlarmTime = startTime + duration;
|
gi.trackedVcp = 0;
|
||||||
}
|
continue;
|
||||||
|
}
|
||||||
if (shortestWait < 1 || duration < shortestWait)
|
|
||||||
shortestWait = duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (gi.currentVcp != gi.trackedVcp) {
|
||||||
|
for (String mn : mapMnemonicProducts) {
|
||||||
|
RadarItem ri = getRadarItem(mn, gi.radarID);
|
||||||
if (ri != null) {
|
if (ri != null) {
|
||||||
|
ri.isNew = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gi.trackedVcp = gi.currentVcp;
|
||||||
|
}
|
||||||
|
|
||||||
if (ri.time + duration < adjustedTime) {
|
if (mapDuration.get(gi.trackedVcp) != null) {
|
||||||
if (ri.time <= gi.alarmTime
|
boolean allOk = true;
|
||||||
&& gi.nextAlarmTime < currentTime) {
|
duration = (mapDuration.get(gi.trackedVcp) + fudgeTime) * 1000;
|
||||||
alert(duration, gi, ri.mnemonic);
|
|
||||||
gi.alarmTime = ri.time;
|
|
||||||
gi.nextAlarmTime = currentTime + duration;
|
|
||||||
}
|
|
||||||
if (gi.nextAlarmTime < currentTime)
|
|
||||||
gi.alarmTime = ri.time;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((duration + ri.time) - adjustedTime < shortestWait
|
for (String mn : mapMnemonicProducts) {
|
||||||
&& 1 <= (duration + ri.time) - adjustedTime)
|
RadarItem ri = getRadarItem(mn, gi.radarID);
|
||||||
shortestWait = (duration + ri.time) - adjustedTime;
|
if (ri == null) {
|
||||||
if (shortestWait < 1)
|
continue;
|
||||||
shortestWait = duration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ri.isNew) {
|
||||||
|
ri.isNew = false;
|
||||||
|
ri.time = currentTime;
|
||||||
|
} else {
|
||||||
|
long diff = currentTime - ri.time;
|
||||||
|
if (diff < duration) {
|
||||||
|
long nextTime = ri.time + duration;
|
||||||
|
if (earliestCheckTime == 0 || nextTime < earliestCheckTime) {
|
||||||
|
earliestCheckTime = nextTime;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
allOk = false;
|
||||||
|
alert(duration, gi, mn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (allOk) {
|
||||||
|
gi.failed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shortestWait = earliestCheckTime > 0 ? earliestCheckTime - currentTime : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void alert(final long duration, final GsmItem gi, final String mn) {
|
private void alert(final long duration, final GsmItem gi, final String mn) {
|
||||||
String AlertVizMessage = "Watchdog: Radar ";
|
if (! gi.failed) {
|
||||||
AlertVizMessage += gi.radarID + " has not produced a '" + mn
|
gi.failed = true;
|
||||||
+ "' product in the last " + duration / 1000 + " seconds.";
|
String AlertVizMessage = "Watchdog: Radar ";
|
||||||
RadarServerAvailable.sendNotification(gi.radarID, AlertVizMessage);
|
AlertVizMessage += gi.radarID + " has not produced a '" + mn
|
||||||
|
+ "' product in the last " + duration / 1000 + " seconds.";
|
||||||
|
RadarServerAvailable.sendNotification(gi.radarID, AlertVizMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void notifyWatchdog() {
|
public void notifyWatchdog() {
|
||||||
|
@ -218,7 +255,8 @@ public class RadarWatchdog extends Thread {
|
||||||
|
|
||||||
private boolean loadConfigFile(final String filename) {
|
private boolean loadConfigFile(final String filename) {
|
||||||
try {
|
try {
|
||||||
InputStream inFile = configuration.getDropInData(filename);
|
InputStream inFile = radarServer.getConfiguration().
|
||||||
|
getDropInData(filename);
|
||||||
InputStreamReader reader = new InputStreamReader(inFile);
|
InputStreamReader reader = new InputStreamReader(inFile);
|
||||||
BufferedReader in = new BufferedReader(reader);
|
BufferedReader in = new BufferedReader(reader);
|
||||||
String line;
|
String line;
|
||||||
|
|
|
@ -44,6 +44,8 @@ import com.raytheon.rcm.server.RadarWatchdog;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------- ---------- ----------- --------------------------
|
* ------------- ---------- ----------- --------------------------
|
||||||
* May 12, 2014 DR 16319 dhuffman Initial creation.
|
* May 12, 2014 DR 16319 dhuffman Initial creation.
|
||||||
|
* Feb 10, 2015 DR 17112 D. Friedman Only alarm on dedicated radars and
|
||||||
|
* once per detected failure.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -61,8 +63,8 @@ public class RadarWatchdogListener extends RadarEventAdapter {
|
||||||
mnemonicMap.put("HSW", "SW");
|
mnemonicMap.put("HSW", "SW");
|
||||||
}
|
}
|
||||||
|
|
||||||
public RadarWatchdogListener(Configuration configuration) {
|
public RadarWatchdogListener(RadarServer radarServer) {
|
||||||
radarWatchdog = new RadarWatchdog(configuration);
|
radarWatchdog = new RadarWatchdog(radarServer);
|
||||||
radarWatchdog.start();
|
radarWatchdog.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,25 +83,14 @@ public class RadarWatchdogListener extends RadarEventAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gsm != null) {
|
if (gsm != null) {
|
||||||
RadarWatchdog.GsmItem gi = new RadarWatchdog.GsmItem();
|
radarWatchdog.notifyGsm(event.getRadarID(), gsm.vcp);
|
||||||
gi.radarID = event.getRadarID();
|
|
||||||
gi.vcp = gsm.vcp;
|
|
||||||
gi.time = gsm.time.getTimeInMillis();
|
|
||||||
|
|
||||||
RadarWatchdog.GsmItem oldgi = radarWatchdog
|
|
||||||
.getGSMItem(gi.radarID);
|
|
||||||
if (oldgi == null
|
|
||||||
|| (oldgi != null && oldgi.time <= gi.time)) {
|
|
||||||
radarWatchdog.putGSMItem(gi);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (16 <= messageCode) {
|
} else if (16 <= messageCode) {
|
||||||
int mcode = 0;
|
int mcode = 0;
|
||||||
PDB pdb = null;
|
PDB pdb = null;
|
||||||
RadarWatchdog.RadarItem ri = new RadarWatchdog.RadarItem();
|
|
||||||
mcode = Message.messageCodeOf(msg);
|
mcode = Message.messageCodeOf(msg);
|
||||||
ri.messageTime = (Message.decodeHeader(msg).time)
|
long messageTime = (Message.decodeHeader(msg).time)
|
||||||
.getTimeInMillis();
|
.getTimeInMillis();
|
||||||
|
|
||||||
RadarProduct rp = ProductInfo.getInstance().getPoductForCode(
|
RadarProduct rp = ProductInfo.getInstance().getPoductForCode(
|
||||||
|
@ -107,10 +98,9 @@ public class RadarWatchdogListener extends RadarEventAdapter {
|
||||||
if (rp == null)
|
if (rp == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ri.mnemonic = rp.mnemonic;
|
String mnemonic = mnemonicMap.get(rp.mnemonic);
|
||||||
String newMnemonic = mnemonicMap.get(ri.mnemonic);
|
if (mnemonic == null)
|
||||||
if (newMnemonic != null)
|
mnemonic = rp.mnemonic;
|
||||||
ri.mnemonic = newMnemonic;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pdb = GraphicProduct.pdbOfMessage(msg);
|
pdb = GraphicProduct.pdbOfMessage(msg);
|
||||||
|
@ -120,17 +110,8 @@ public class RadarWatchdogListener extends RadarEventAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdb != null) {
|
if (pdb != null) {
|
||||||
ri.radarID = event.getRadarID();
|
radarWatchdog.notifyRadarItem(event.getRadarID(), mnemonic,
|
||||||
ri.time = System.currentTimeMillis();
|
messageTime, System.currentTimeMillis());
|
||||||
|
|
||||||
RadarWatchdog.RadarItem oldri = radarWatchdog.getRadarItem(
|
|
||||||
ri.mnemonic, ri.radarID);
|
|
||||||
|
|
||||||
if (oldri == null
|
|
||||||
|| (oldri != null && oldri.messageTime <= ri.messageTime)) {
|
|
||||||
radarWatchdog.putRadarItem(ri);
|
|
||||||
radarWatchdog.notifyWatchdog();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue