public class EntryStore extends Object
AddeThread| Modifier and Type | Class and Description |
|---|---|
static class |
EntryStore.Event
Enumeration of the various server manager events.
|
| Modifier and Type | Field and Description |
|---|---|
private String |
ADDE_BIN
Path to local server binaries.
|
private String |
ADDE_DATA
Path to local server data.
|
private String |
ADDE_DIRECTORY
"Root" local server directory.
|
private String |
ADDE_MCSERVL
Path to mcservl.
|
private String |
ADDE_RESOLV
Path to the user's "RESOLV.SRV".
|
private IdvObjectStore |
idvStore
McIDAS-V preferences store.
|
private List<AddeEntry> |
lastAdded
Last
AddeEntries added to the manager. |
private static String |
localPort
Which port is this particular manager operating on
|
private static org.slf4j.Logger |
logger
Logging object.
|
private String |
MCTRACE
Value of "MCTRACE" environment variable for mcservl.
|
private static String |
PREF_ADDE_ENTRIES
Preference key for ADDE entries.
|
private static String |
PROP_DEBUG_ADDEURL
Property that allows users to control debug output from ADDE requests.
|
private static String |
PROP_DEBUG_LOCALROOT
Property that allows users to supply arbitrary paths to McIDAS-X
binaries used by mcservl.
|
private static AddeThread |
thread
Thread that monitors the mcservl process.
|
private PatriciaTrie<String,AddeEntry> |
trie
The ADDE servers known to McIDAS-V.
|
private String |
USER_DIRECTORY
Path to the user's "userpath" directory.
|
| Constructor and Description |
|---|
EntryStore(IdvObjectStore store,
IdvResourceManager rscManager)
Constructs a server manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addEntries(Collection<? extends AddeEntry> newEntries)
|
void |
addEntry(AddeEntry entry)
|
boolean |
checkLocalServer()
Check to see if the thread is running.
|
private Set<AddeEntry> |
extractPreferencesEntries(IdvObjectStore store)
Returns the
AddeEntries stored in the user's
preferences. |
private Set<AddeEntry> |
extractResourceEntries(AddeEntry.EntrySource source,
XmlResourceCollection xmlResources)
Process all of the "IDV-style" XML resources for a given
"source".
|
private Set<AddeEntry> |
extractUserEntries(XmlResourceCollection xmlResources)
Process all of the "user" XML resources.
|
private Set<LocalAddeEntry> |
filterLocalEntriesByTemporaryStatus(boolean getTemporaryEntries)
Filters the local entries by whether or not they are set as
"temporary".
|
AddeAccount |
getAccountingFor(AddeServer idvServer,
String typeAsStr)
Returns the accounting for the given
idvServer and
typeAsStr. |
AddeAccount |
getAccountingFor(String address,
String group,
AddeEntry.EntryType type)
Searches the set of servers in an attempt to locate the accounting
information for the matching server.
|
protected String[] |
getAddeCommands()
Returns command line used to launch mcservl.
|
static String |
getAddeRootDirectory()
Returns the path to where the root directory of the user's McIDAS-X
binaries should be.
|
Set<String> |
getAddresses()
|
Set<AddeEntry> |
getEntrySet()
Returns the complete
Set of AddeEntries. |
Set<String> |
getGroups(String address)
Returns the
Set of "groups" associated with the
given address. |
Set<String> |
getGroupsFor(String address,
AddeEntry.EntryType type)
|
IdvObjectStore |
getIdvStore()
Returns the
IdvObjectStore used to save user preferences. |
List<AddeServer> |
getIdvStyleEntries()
Returns a list of all available ADDE datasets, converted to IDV
AddeServer objects. |
Set<AddeServer> |
getIdvStyleEntries(AddeEntry.EntryType type)
Returns a list that consists of the available ADDE datasets for a given
AddeEntry.EntryType, converted to IDV AddeServer objects. |
Set<AddeServer> |
getIdvStyleEntries(String typeAsStr)
Returns a list that consists of the available ADDE datasets for a given
AddeEntry.EntryType, converted to IDV AddeServer objects. |
Set<AddeServer.Group> |
getIdvStyleLocalGroups()
Returns all enabled, valid
LocalAddeEntries as a
collection of "IDV style"
AddeServer.Group
objects. |
Set<AddeServer.Group> |
getIdvStyleRemoteGroups(String server,
AddeEntry.EntryType type)
Returns the entries matching the given
server and
type parameters as a collection of
AddeServer.Group
objects. |
Set<AddeServer.Group> |
getIdvStyleRemoteGroups(String server,
String typeAsStr)
Returns the entries matching the given
server and
typeAsStr parameters as a collection of
AddeServer.Group
objects. |
List<AddeEntry> |
getLastAdded()
Returns the
AddeEntries that were added last. |
List<AddeEntry> |
getLastAddedByType(AddeEntry.EntryType type)
Searches the newest entries for the entries of the given
AddeEntry.EntryType. |
List<AddeEntry> |
getLastAddedByTypes(EnumSet<AddeEntry.EntryType> types)
Returns the
AddeEntries that were added last, filtered
by the given EntryTypes. |
Set<LocalAddeEntry> |
getLocalEntries()
Returns the complete
Set of
LocalAddeEntries. |
static String |
getLocalPort()
Ask for the port we are listening on.
|
Set<AddeEntry> |
getPersistedEntrySet()
Returns all non-temporary
AddeEntries. |
Set<LocalAddeEntry> |
getPersistedLocalEntries()
Returns the
Set of LocalAddeEntries that
will be saved between McIDAS-V sessions. |
Set<RemoteAddeEntry> |
getRemoteEntries()
Returns the complete
Set of
RemoteAddeEntries. |
Set<String> |
getRemoteEntryTexts()
|
Set<LocalAddeEntry> |
getTemporaryLocalEntries()
Returns any
LocalAddeEntries that will be removed
at the end of the current McIDAS-V session. |
Set<AddeEntry.EntryType> |
getTypes(String address,
String group)
|
protected String[] |
getUnixAddeEnv()
Returns environment variables that allow mcservl to run on
"unix-like" systems.
|
Set<AddeEntry> |
getVerifiedEntries(AddeEntry.EntryType type)
|
Map<AddeEntry.EntryType,Set<AddeEntry>> |
getVerifiedEntriesByTypes()
Returns the available
AddeEntries, grouped by
AddeEntry.EntryType. |
protected String[] |
getWindowsAddeEnv()
Returns environment variables that allow mcservl to run on Windows.
|
static boolean |
isAddeDebugEnabled(boolean defaultValue)
Checks the value of the
debug.adde.reqs system property to
determine whether or not the user has requested ADDE URL debugging
output. |
static boolean |
isInvalidEntry(AddeEntry entry)
Determine the validity of a given
AddeEntry. |
protected static String |
nextLocalPort()
Get the next port by incrementing current port.
|
void |
onEvent(EntryStore.Event evt)
Responds to server manager events being passed with the event bus.
|
private static void |
putEntries(PatriciaTrie<String,AddeEntry> trie,
Collection<? extends AddeEntry> newEntries)
Adds
AddeEntry objects to a given PatriciaTrie. |
private static Set<AddeEntry> |
removeDeletedSystemEntries(Collection<? extends AddeEntry> entries,
Collection<? extends AddeEntry> systemEntries)
Searches
entries for AddeEntry objects with two characteristics:
the object source is AddeEntry.EntrySource.SYSTEM
the object is not in systemEntries
The intent behind this method is to safely remove "system"
entries that have been stored to a user's preferences. |
boolean |
removeEntries(Collection<? extends AddeEntry> removedEntries)
Removes the given
AddeEntries. |
boolean |
removeEntry(AddeEntry entry)
Removes a single
AddeEntry from the set of available entries. |
void |
replaceEntries(Collection<? extends AddeEntry> oldEntries,
Collection<? extends AddeEntry> newEntries)
|
void |
saveEntries()
Saves the current set of ADDE servers to the user's preferences and
ADDE_RESOLV. |
void |
saveForShutdown()
Saves the list of ADDE entries to both the user's preferences and
ADDE_RESOLV. |
List<AddeEntry> |
searchWithPrefix(String prefix)
Search the server manager for entries that match
prefix. |
static boolean |
setAddeDebugEnabled(boolean value)
Sets the value of the
debug.adde.reqs system property so
that debugging output can be controlled without restarting McIDAS-V. |
static void |
setLocalPort(String port)
Change the port we are listening on.
|
void |
startLocalServer()
Starts the local server thread (if it isn't already running).
|
void |
stopLocalServer()
Stops the local server thread if it is running.
|
boolean |
testLocalServer()
Test to see if the thread can access userpath
|
private static final String PROP_DEBUG_LOCALROOT
getAddeRootDirectory(),
Constant Field Valuesprivate static final String PROP_DEBUG_ADDEURL
private static final org.slf4j.Logger logger
private static final String PREF_ADDE_ENTRIES
private final PatriciaTrie<String,AddeEntry> trie
private final String ADDE_DIRECTORY
private final String ADDE_MCSERVL
private final String USER_DIRECTORY
private final String ADDE_RESOLV
private final String MCTRACE
EntryStore(ucar.unidata.idv.IdvObjectStore, ucar.unidata.idv.IdvResourceManager).private static AddeThread thread
private final List<AddeEntry> lastAdded
AddeEntries added to the manager.private final IdvObjectStore idvStore
public EntryStore(IdvObjectStore store, IdvResourceManager rscManager)
store - McIDAS-V's preferences store. Cannot be null.rscManager - McIDAS-V's resource manager. Cannot be null.NullPointerException - if either of store or
rscManager is null.private static Set<AddeEntry> removeDeletedSystemEntries(Collection<? extends AddeEntry> entries, Collection<? extends AddeEntry> systemEntries)
entries for AddeEntry objects with two characteristics:
AddeEntry.EntrySource.SYSTEMsystemEntriesThe intent behind this method is to safely remove "system"
entries that have been stored to a user's preferences. entries
can be generated from anywhere you like, but systemEntries should
almost always be created from "addeservers.xml".
entries - Cannot be null.systemEntries - Cannot be null.Set of entries that are not system resources that have
been removed, or an empty Set.private static void putEntries(PatriciaTrie<String,AddeEntry> trie, Collection<? extends AddeEntry> newEntries)
AddeEntry objects to a given PatriciaTrie.trie - Cannot be null.newEntries - Cannot be null.public IdvObjectStore getIdvStore()
IdvObjectStore used to save user preferences.IdvObjectStore used by the rest of McIDAS-V.protected String[] getWindowsAddeEnv()
String array containing mcservl's environment variables.protected String[] getUnixAddeEnv()
String array containing mcservl's environment variables.protected String[] getAddeCommands()
String array that represents an invocation of mcservl.public static boolean isInvalidEntry(AddeEntry entry)
AddeEntry.entry - Entry to check. Cannot be null.true if entry is invalid or false
otherwise.NullPointerException - if entry is null.AssertionError - if entry is somehow neither a
RemoteAddeEntry or LocalAddeEntry.LocalAddeEntry.INVALID_ENTRY,
RemoteAddeEntry.INVALID_ENTRYprivate Set<AddeEntry> extractPreferencesEntries(IdvObjectStore store)
AddeEntries stored in the user's
preferences.store - Object store that represents the user's preferences.
Cannot be null.AddeEntrys stored in the prefs or an empty Set.public void onEvent(EntryStore.Event evt)
evt - Event to which this method is responding. Cannot be null.NullPointerException - if evt is null.public void saveEntries()
ADDE_RESOLV.public void saveForShutdown()
ADDE_RESOLV.public List<AddeEntry> getLastAddedByType(AddeEntry.EntryType type)
AddeEntry.EntryType.type - Look for entries matching this EntryType.
Cannot be null.List of entries or an empty
List.NullPointerException - if type is null.public List<AddeEntry> getLastAddedByTypes(EnumSet<AddeEntry.EntryType> types)
AddeEntries that were added last, filtered
by the given EntryTypes.types - Filter the last added entries by these entry type.
Cannot be null.List of the last added entries, filtered by
types.NullPointerException - if types is null.public List<AddeEntry> getLastAdded()
AddeEntries that were added last. Note
that this value is not preserved between sessions.List of the last ADDE entries that were added. May be
empty.public Set<AddeEntry> getVerifiedEntries(AddeEntry.EntryType type)
type - The EntryType you are interested in. Cannot be
null.Set of matching remote ADDE entries. If there were no
matches, an empty Set is returned.NullPointerException - if type is null.public Map<AddeEntry.EntryType,Set<AddeEntry>> getVerifiedEntriesByTypes()
AddeEntries, grouped by
AddeEntry.EntryType.public Set<String> getGroupsFor(String address, AddeEntry.EntryType type)
address - ADDE server address whose groups are needed.
Cannot be null.type - Only include groups that match AddeEntry.EntryType.
Cannot be null.NullPointerException - if either address or type
is null.public List<AddeEntry> searchWithPrefix(String prefix)
prefix.prefix - String to match. Cannot be null.List containing matching entries. If there were no
matches the List will be empty.NullPointerException - if prefix is null.AddeEntry.asStringId()public Set<String> getAddresses()
Set containing all of the stored addresses. If no
addresses are stored, an empty Set is returned.public Set<String> getRemoteEntryTexts()
RemoteAddeEntry.RemoteAddeEntry.getEntryText()public Set<String> getGroups(String address)
Set of "groups" associated with the
given address.address - Address of a server.address or an
empty Set.public Set<AddeEntry.EntryType> getTypes(String address, String group)
address - Address of a server.group - Group whose "types" you want.address and
group or an empty Set if there were no matches.public AddeAccount getAccountingFor(String address, String group, AddeEntry.EntryType type)
Set, there cannot be duplicate entries,
so there is no need to worry about our criteria finding multiple
matches.
Also note that none of the given parameters accept null
values.
address - Address of the server.group - Dataset.type - Group type.AddeAccount for the given criteria, or
AddeEntry.DEFAULT_ACCOUNT if there was no match.RemoteAddeEntry.equals(Object)public AddeAccount getAccountingFor(AddeServer idvServer, String typeAsStr)
idvServer and
typeAsStr.idvServer - Server to search for.typeAsStr - One of "IMAGE", "POINT",
"GRID", "TEXT", "NAV",
"RADAR", "UNKNOWN", or "INVALID".AddeAccount associated with idvServer and
typeAsStr.public Set<AddeEntry> getEntrySet()
Set of AddeEntries.public Set<AddeEntry> getPersistedEntrySet()
AddeEntries.Set of ADDE entries that stick around between McIDAS-V
sessions.public Set<RemoteAddeEntry> getRemoteEntries()
Set of
RemoteAddeEntries.Set of remote ADDE entries stored within the available
entries.public Set<LocalAddeEntry> getLocalEntries()
Set of
LocalAddeEntries.Set of local ADDE entries stored within the available
entries.public Set<LocalAddeEntry> getPersistedLocalEntries()
Set of LocalAddeEntries that
will be saved between McIDAS-V sessions.
Note: all this does is check LocalAddeEntry.isTemporary field.
public Set<LocalAddeEntry> getTemporaryLocalEntries()
LocalAddeEntries that will be removed
at the end of the current McIDAS-V session.Set of all the temporary local ADDE entries.private Set<LocalAddeEntry> filterLocalEntriesByTemporaryStatus(boolean getTemporaryEntries)
getTemporaryEntries - true returns temporary local
entries; false returns local entries that are permanent.Set of filtered local ADDE entries.public boolean removeEntries(Collection<? extends AddeEntry> removedEntries)
AddeEntries.removedEntries - AddeEntry objects to remove.
Cannot be null.removeEntries were removed.NullPointerException - if removedEntries is null.public boolean removeEntry(AddeEntry entry)
AddeEntry from the set of available entries.entry - Entry to remove. Cannot be null.true if something was removed, false otherwise.NullPointerException - if entry is null.public void addEntry(AddeEntry entry)
entry - Entry to add. Cannot be null.NullPointerException - if entry is null.public void addEntries(Collection<? extends AddeEntry> newEntries)
newEntries - New entries to add to the server manager. Cannot be
null.NullPointerException - if newEntries is null.public void replaceEntries(Collection<? extends AddeEntry> oldEntries, Collection<? extends AddeEntry> newEntries)
oldEntries - Entries to be replaced. Cannot be null.newEntries - Entries to use as replacements. Cannot be
null.NullPointerException - if either of oldEntries or
newEntries is null.public Set<AddeServer.Group> getIdvStyleLocalGroups()
LocalAddeEntries as a
collection of "IDV style"
AddeServer.Group
objects.Set of AddeServer.Group objects that corresponds
with the enabled, valid local ADDE entries.public Set<AddeServer.Group> getIdvStyleRemoteGroups(String server, String typeAsStr)
server and
typeAsStr parameters as a collection of
AddeServer.Group
objects.server - Remote ADDE server. Should not be null.typeAsStr - Entry type. One of "IMAGE",
"POINT", "GRID", "TEXT",
"NAV", "RADAR", "UNKNOWN", or
"INVALID". Should not be null.Set of AddeServer.Group objects that corresponds
to the entries associated with server and typeAsStr.public Set<AddeServer.Group> getIdvStyleRemoteGroups(String server, AddeEntry.EntryType type)
server and
type parameters as a collection of
AddeServer.Group
objects.server - Remote ADDE server. Should not be null.type - Entry type. Should not be null.Set of AddeServer.Group objects that corresponds
to the entries associated with server and type.public List<AddeServer> getIdvStyleEntries()
AddeServer objects.AddeServer objects for each ADDE entry.public Set<AddeServer> getIdvStyleEntries(AddeEntry.EntryType type)
AddeEntry.EntryType, converted to IDV AddeServer objects.type - Only add entries with this type to the returned list.
Cannot be null.AddeServer objects for each ADDE entry of the given type.public Set<AddeServer> getIdvStyleEntries(String typeAsStr)
AddeEntry.EntryType, converted to IDV AddeServer objects.typeAsStr - Only add entries with this type to the returned list.
Cannot be null and must be a value that works with
EntryTransforms.strToEntryType(String).AddeServer objects for each ADDE entry of the given type.EntryTransforms.strToEntryType(String)private Set<AddeEntry> extractResourceEntries(AddeEntry.EntrySource source, XmlResourceCollection xmlResources)
source - Origin of the XML resources.xmlResources - Actual XML resources.Set of the AddeEntrys extracted from
xmlResources.private Set<AddeEntry> extractUserEntries(XmlResourceCollection xmlResources)
xmlResources - Resource collection. Cannot be null.Set of RemoteAddeEntries
contained within resource.public static String getAddeRootDirectory()
The default path is determined like so:
System.getProperty("user.dir") + File.separatorChar + "adde"
Users can provide an arbitrary path at runtime by setting the
debug.localadde.rootdir system property.
String containing the path to the McIDAS-X root directory.PROP_DEBUG_LOCALROOTpublic static boolean isAddeDebugEnabled(boolean defaultValue)
debug.adde.reqs system property to
determine whether or not the user has requested ADDE URL debugging
output. Output is sent to System.out.
Please keep in mind that the debug.adde.reqs can not
force debugging for all ADDE requests. To do so will require
updates to the VisAD ADDE library.
defaultValue - Value to return if debug.adde.reqs has
not been set.debug.adde.reqs.
Otherwise debug.adde.reqs.AddeURL,
PROP_DEBUG_ADDEURLpublic static boolean setAddeDebugEnabled(boolean value)
debug.adde.reqs system property so
that debugging output can be controlled without restarting McIDAS-V.
Please keep in mind that the debug.adde.reqs can not
force debugging for all ADDE requests. To do so will require
updates to the VisAD ADDE library.
value - New value of debug.adde.reqs.debug.adde.reqs.AddeURL,
PROP_DEBUG_ADDEURLpublic static void setLocalPort(String port)
port - New port number.public static String getLocalPort()
protected static String nextLocalPort()
public void startLocalServer()
public void stopLocalServer()
public boolean testLocalServer()
true if the local server can access userpath,
false otherwise.public boolean checkLocalServer()
true if the local server thread is running;
false otherwise.