public class StationTracker extends java.lang.Object implements java.lang.Iterable<StationState>, AprsMessageListener, ParsedAX25MessageListener
Modifier and Type | Class and Description |
---|---|
static class |
StationTracker.AddressStatistics<K,C extends StationTracker.AddressStatistics<K,C>>
This abstract class collects the occurrence counts for a particular type of station.
|
static class |
StationTracker.DestinationStatistics
Usage statistics for a particular tocall (destination) callsign in AX.25 traffic.
|
static class |
StationTracker.DigipeatStatistics
Address statistics for a particular digipeater.
|
Modifier and Type | Field and Description |
---|---|
static int |
HEAP_UPPER_PERCENT_THRESHOLD
How close the consumption of the JVM heap can get to the maximum (-Xmx option to JVM) before YAAC starts
reducing retention intervals and taking other actions to prevent heap starvation, specified as a percentage.
|
static java.lang.String |
IGATE
Capability string included in capabilities if local station functioning as an I-Gate.
|
Modifier and Type | Method and Description |
---|---|
void |
add1stDigiListener(DigipeatListener l)
Register a listener that wants to know when a new first digipeater is recorded.
|
static void |
addCapabilitiesProvider(CapabilitiesProvider p)
Register a CapabilitiesProvider instance.
|
void |
addDestinationListener(DestinationListener l)
Register a listener that wants to know when a new tocall or explicit network destination is recorded.
|
StationState |
addMessage(java.lang.String identifier,
AX25Message msg,
AX25Callsign[] digipeaters,
boolean isStationName)
Register a message with the appropriate sending station.
|
void |
addNewDestination(java.lang.String dest)
Add a new destination to the map of destination callsigns and statistics.
|
StationState |
addNewStationIfNeeded(java.lang.String callsign)
Get the current StationState record for the specified station or object,
creating a new record if one doesn't currently exist.
|
void |
addPurgeListener(PurgeListener l)
Register to be informed when purging should be performed.
|
void |
addRelayListener(DigipeatListener l)
Register a listener that wants to know when a new last digipeater is recorded.
|
void |
addTrackerListener(TrackerListener l)
Register a listener to be informed of changes to the station histories.
|
void |
aprsMessageReceived(Message msg)
Delivers the next message received by YAAC that is an APRS message.
|
static java.util.List<java.lang.String> |
buildLocalCapabilities()
Build a list of APRS capabilities this station has, suitable for a
response to a "?IGATE" query.
|
void |
deleteStation(StationState ss)
Remove the specified station or object from the tracked history immediately.
|
Connector |
findBestConnectorForStation(java.lang.String callsign)
Calculate the best Connector to use to reach a particular specified
remote station, based on what has been collected about that station's transmissions
to the local station.
|
protected void |
fireMessageAdded(StationState ss,
int index,
AX25Message msg)
Inform all registered TrackerListener instances that a new message has arrived
from the specified station or about the specified object.
|
protected void |
fireMessageDeleted(StationState ss,
int index,
AX25Message msg)
Inform all registered TrackerListener instances that an old message has been
deleted from the specified station or about the specified object.
|
protected void |
fireStationAdded(StationState ss,
int index)
Inform all registered TrackerListener instances that a new station or object
has been added to the tracker.
|
void |
fireStationDeleted(StationState ss,
int index)
Inform all registered TrackerListener instances that a station or object's state is being
deleted due to lack of activity,
|
void |
fireStationUpdated(StationState ss)
Inform all registered TrackerListener instances that a station's status is being updated.
|
java.util.Set<java.lang.String> |
getCurrentNameSet()
Get a Set of all the identifiers of stations and objects currently known.
|
StationState[] |
getCurrentTrackedObjectArray()
Get an array of all the known StationState objects.
|
StationState[] |
getCurrentTrackedObjectArray(boolean includeStations,
boolean includeObjects,
boolean includeSelf,
Filter filter,
java.util.Comparator<StationState> sortComparator)
Get an array of a selected filtered subset of the known StationState instances.
|
StationState[] |
getCurrentTrackedObjectArray(StationState[] oldArray,
boolean includeStations,
boolean includeObjects,
boolean includeSelf,
Filter filter,
java.util.Comparator<StationState> sortComparator)
Get an array of a selected filtered subset of the known StationState instances, recycling an existing array
if it is long enough.
|
java.util.ArrayList<StationState> |
getCurrentTrackedObjectList()
Get a list of all the known StationState objects.
|
java.util.ArrayList<StationState> |
getCurrentTrackedObjectList(boolean includeStations,
boolean includeObjects,
boolean includeSelf)
Get a list of selected members of the known StationState objects.
|
java.util.ArrayList<StationState> |
getCurrentTrackedObjectList(boolean includeStations,
boolean includeObjects,
boolean includeSelf,
Filter filter)
Get a list of selected members of the known StationState objects.
|
java.util.HashMap<java.lang.String,StationTracker.DestinationStatistics> |
getDestinationsMap()
Get the raw Map of destination callsigns to statistics counters.
|
java.util.Set<java.lang.String> |
getDestinationsStringSet()
Get the sorted set of all destination callsign strings.
|
java.util.HashMap<java.lang.String,StationTracker.DigipeatStatistics> |
getDigipeatersMap()
Get the map of first/last digipeater statistics.
|
java.util.Set<java.lang.String> |
getDigipeatersSet()
Get all the callsigns of the first and last digipeaters used by all stations in the history.
|
StationTracker.DigipeatStatistics |
getDigipeaterStatisticsFor(java.lang.String callsign)
Get the DigipeatStatistics record for the specified callsign if it has ever been used
as a first or last digipeater (or last I-gate).
|
java.lang.String[] |
getDirectStationList(long now)
Get a list of all stations heard directly by this station.
|
java.util.Set<java.lang.String> |
getFinalSendersSet()
Get all the callsigns of the final digipeaters/I-gates used by all stations in the history.
|
static StationTracker |
getInstance()
Get the singleton instance of the StationTracker.
|
RadiusFilter |
getRangeLimitFilter()
Get a reference to the RadiusFilter used for deciding if a station or object has changed between being in-range
and out-of-range.
|
StationState |
getStationByAlias(java.lang.String alias)
Search for the first Station with the specified alias (tactical name).
|
int |
getStationTypeCount(char symTableId,
char symbolCode)
Count the number of known stations of a specified type.
|
StationState |
getTrackedObject(java.lang.String name)
Get the state object for the specified station or object.
|
boolean |
hasTacticalAliases(boolean onlyLocal)
Test if this station has any tactical aliases defined.
|
boolean |
is1stDigiListener(DigipeatListener l)
Test if the specified DigipeatListener is registered for first digipeater updates.
|
static boolean |
isOptimizeTransmits()
Report whether port optimization of locally-originated message transmits should be performed.
|
boolean |
isRelayListener(DigipeatListener l)
Test if the specified DigipeatListener is registered for last digipeater updates.
|
java.util.Iterator<StationState> |
iterator()
Returns an iterator over a set of elements of type StationState.
|
void |
parsedAX25MessageReceived(byte pid,
AX25Message msg)
Delivers the next message received by YAAC that is some sort of parsed AX.25 higher-level message.
|
void |
purgeStaleTraffic()
Delete all cached messages older than the purge threshold.
|
void |
remove1stDigiListener(DigipeatListener l)
Unregister a listener that no longer wants to know when a new first digipeater is recorded.
|
static void |
removeCapabilitiesProvider(CapabilitiesProvider p)
Unregister a CapabilitiesProvider instance.
|
void |
removeDestinationListener(DestinationListener l)
Remove a listener that no longer wants to know when a new tocall or explicit network destination is recorded.
|
void |
removePurgeListener(PurgeListener l)
Unregister from being informed when purging should be performed.
|
void |
removeRelayListener(DigipeatListener l)
Unregister a listener that no longer wants to know when a new last digipeater is recorded.
|
void |
removeTrackerListener(TrackerListener l)
Unregister a listener.
|
static void |
setOptimizeTransmits(boolean optimizeTransmits)
Specify whether port optimization of locally-originated message transmits should be performed.
|
java.lang.String |
toString()
Return String describing the StationTracker object.
|
public static final java.lang.String IGATE
buildLocalCapabilities()
,
Constant Field Valuespublic static final int HEAP_UPPER_PERCENT_THRESHOLD
public static java.util.List<java.lang.String> buildLocalCapabilities()
StationCapabilities
,
IGateQueryHandler
public static void addCapabilitiesProvider(CapabilitiesProvider p)
p
- CapabilitiesProvider instancepublic static void removeCapabilitiesProvider(CapabilitiesProvider p)
p
- CapabilitiesProvider instancepublic static boolean isOptimizeTransmits()
public static void setOptimizeTransmits(boolean optimizeTransmits)
optimizeTransmits
- boolean true if port optimization should be performedpublic Connector findBestConnectorForStation(java.lang.String callsign)
callsign
- String of callsign-SSID to lookuppublic void purgeStaleTraffic()
public void addPurgeListener(PurgeListener l)
l
- PurgeListener to notify when pruning is occurringpublic void removePurgeListener(PurgeListener l)
l
- PurgeListener that no longer wants to be notified when pruning is occurringpublic StationState getTrackedObject(java.lang.String name)
name
- callsign or identifier for the desired station or objectpublic java.util.Set<java.lang.String> getCurrentNameSet()
public java.util.ArrayList<StationState> getCurrentTrackedObjectList()
public java.util.ArrayList<StationState> getCurrentTrackedObjectList(boolean includeStations, boolean includeObjects, boolean includeSelf)
includeStations
- boolean true if stations (message originators) should be includedincludeObjects
- boolean true if objects (non-transmitting) should be includedincludeSelf
- boolean true if own station should be included, regardless of filters and other include flagspublic java.util.ArrayList<StationState> getCurrentTrackedObjectList(boolean includeStations, boolean includeObjects, boolean includeSelf, Filter filter)
includeStations
- boolean true if stations (message originators) should be includedincludeObjects
- boolean true if objects (non-transmitting) should be includedincludeSelf
- boolean true if own station should be included, regardless of filters and other include flagsfilter
- Filter tree to apply to decide which StationStates to choose, or null to not filterpublic StationState getStationByAlias(java.lang.String alias)
alias
- String of tactical name to search forpublic StationState[] getCurrentTrackedObjectArray()
public StationState[] getCurrentTrackedObjectArray(boolean includeStations, boolean includeObjects, boolean includeSelf, Filter filter, java.util.Comparator<StationState> sortComparator)
includeStations
- boolean true if stations (message originators) should be includedincludeObjects
- boolean true if objects (non-transmitting) should be includedincludeSelf
- boolean true if own station should be included, regardless of filters and other include flagsfilter
- a Filter to decide which StationState instances should be included, or null if no filtering should be donesortComparator
- if non-null, a Comparator to use to sort the StationState objects in a desired order while
the mutex is being held, to prevent the StationState objects from changing while the
sort is in progresspublic StationState[] getCurrentTrackedObjectArray(StationState[] oldArray, boolean includeStations, boolean includeObjects, boolean includeSelf, Filter filter, java.util.Comparator<StationState> sortComparator)
oldArray
- StationState array to be filled with the data if it is long enough (and null-padded)includeStations
- boolean true if stations (message originators) should be includedincludeObjects
- boolean true if objects (non-transmitting) should be includedincludeSelf
- boolean true if own station should be included, regardless of filters and other include flagsfilter
- a Filter to decide which StationState instances should be included, or null if no filtering should be donesortComparator
- if non-null, a Comparator to use to sort the StationState objects in a desired order while
the mutex is being held, to prevent the StationState objects from changing while the
sort is in progresspublic boolean hasTacticalAliases(boolean onlyLocal)
onlyLocal
- boolean true if they must be from this station, not heard from some other stationpublic void addTrackerListener(TrackerListener l)
l
- TrackerListener to registerpublic void removeTrackerListener(TrackerListener l)
l
- TrackerListener to unregisterprotected void fireStationAdded(StationState ss, int index)
ss
- newly-added StationStateindex
- index in tracker list of the new StationStatepublic void fireStationUpdated(StationState ss)
ss
- StationState receiving updatepublic void fireStationDeleted(StationState ss, int index)
ss
- StationState instance being deletedindex
- index in tracker list of the station being deletedprotected void fireMessageAdded(StationState ss, int index, AX25Message msg)
ss
- StationState instance adding a new messageindex
- index within StationState object of the added messagemsg
- the AX25Message being added to the station/objectprotected void fireMessageDeleted(StationState ss, int index, AX25Message msg)
ss
- StationState instance deleting an old messageindex
- index within StationState object of the deleted messagemsg
- the AX25Message being deleted from the station/objectpublic java.lang.String toString()
toString
in class java.lang.Object
public void deleteStation(StationState ss)
ss
- StationState to removepublic static StationTracker getInstance()
public void aprsMessageReceived(Message msg)
aprsMessageReceived
in interface AprsMessageListener
msg
- some subclass of Message containing the message contents; the message should have
an AX25Frame connected to itAX25Frame
,
AX25Message.ax25Frame
,
AX25Message.getAx25Frame()
public void parsedAX25MessageReceived(byte pid, AX25Message msg)
parsedAX25MessageReceived
in interface ParsedAX25MessageListener
pid
- AX.25 protocol IDmsg
- some subclass of Message containing the message contents; the message should have
an AX25Frame connected to itAX25Frame
public StationState addMessage(java.lang.String identifier, AX25Message msg, AX25Callsign[] digipeaters, boolean isStationName)
identifier
- String identifier of station or object sending the messagemsg
- the AX25Message to be recordeddigipeaters
- any digipeater stations associated with the message's transmissionisStationName
- boolean true if identifier should be forced to upper case (i.e., is a station
callsign, not an object identifier)public void addNewDestination(java.lang.String dest)
dest
- String callsign of destinationpublic StationState addNewStationIfNeeded(java.lang.String callsign)
callsign
- String identifier for the station/object record to find or createpublic int getStationTypeCount(char symTableId, char symbolCode)
symTableId
- code identifying the table or overlay being used (only valid primary or alternate
table, or APRS 1.2 extensions known to YAAC)symbolCode
- code identifying the station symbolpublic java.util.Iterator<StationState> iterator()
iterator
in interface java.lang.Iterable<StationState>
public java.lang.String[] getDirectStationList(long now)
now
- reference time (in milliseconds since Java epoch) that messages must
not be more than 30 minutes olderpublic java.util.Set<java.lang.String> getDigipeatersSet()
public java.util.HashMap<java.lang.String,StationTracker.DigipeatStatistics> getDigipeatersMap()
public java.util.Set<java.lang.String> getFinalSendersSet()
public StationTracker.DigipeatStatistics getDigipeaterStatisticsFor(java.lang.String callsign)
callsign
- String digipeater callsignpublic java.util.Set<java.lang.String> getDestinationsStringSet()
public java.util.HashMap<java.lang.String,StationTracker.DestinationStatistics> getDestinationsMap()
public void addRelayListener(DigipeatListener l)
l
- DigipeatListener to registerpublic void removeRelayListener(DigipeatListener l)
l
- DigipeatListener to unregisterpublic boolean isRelayListener(DigipeatListener l)
l
- DigipeatListener to look forpublic void add1stDigiListener(DigipeatListener l)
l
- DigipeatListener to registerpublic void remove1stDigiListener(DigipeatListener l)
l
- DigipeatListener to unregisterpublic boolean is1stDigiListener(DigipeatListener l)
l
- DigipeatListener to look forpublic void addDestinationListener(DestinationListener l)
l
- DestinationListener to registerpublic void removeDestinationListener(DestinationListener l)
l
- DestinationListener to unregisterpublic RadiusFilter getRangeLimitFilter()