Class EntryStore
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enumeration of the various server manager events. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
Path to local server binaries.private final String
Path to local server data.private final String
"Root" local server directory.private final String
Path to mcservl.private final String
Path to the user's "RESOLV.SRV".private static final String
"Userpath" not writable error message.private static final String
"Userpath" not writable error message.private final IdvObjectStore
McIDAS-V preferences store.LastAddeEntries
added to the manager.private static String
Which port is this particular manager operating onprivate static final org.slf4j.Logger
Logging object.private static final String
Preference key for ADDE entries.private static final String
Property that allows users to control debug output from ADDE requests.private static final String
Property that allows users to supply arbitrary paths to McIDAS-X binaries used by mcservl.private static AddeThread
Thread that monitors the mcservl process.private final org.apache.commons.collections4.trie.PatriciaTrie
<AddeEntry> The ADDE servers known to McIDAS-V.private final String
Path to the user's "userpath" directory.private static final String
SLF4J-style formatting string for use whenRESOLV.SRV
can not be found. . -
Constructor Summary
ConstructorsConstructorDescriptionEntryStore
(IdvObjectStore store, IdvResourceManager rscManager) Constructs a server manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEntries
(Collection<? extends AddeEntry> newEntries) void
boolean
Check to see if the thread is running.Returns theAddeEntries
stored in the user's preferences.extractResourceEntries
(AddeEntry.EntrySource source, XmlResourceCollection xmlResources) Process all of the "IDV-style" XML resources for a given "source".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".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.getAccountingFor
(AddeServer idvServer, String typeAsStr) Returns the accounting for the givenidvServer
andtypeAsStr
.protected String[]
Returns command line used to launch mcservl.static String
Returns the path to where the root directory of the user's McIDAS-X binaries should be.Returns the completeSet
ofAddeEntries
.Returns theSet
of "groups" associated with the givenaddress
.getGroupsFor
(String address, AddeEntry.EntryType type) Returns theIdvObjectStore
used to save user preferences.Returns a list of all available ADDE datasets, converted to IDVAddeServer
objects.Returns a list that consists of the available ADDE datasets for a givenAddeEntry.EntryType
, converted to IDVAddeServer
objects.getIdvStyleEntries
(String typeAsStr) Returns a list that consists of the available ADDE datasets for a givenAddeEntry.EntryType
, converted to IDVAddeServer
objects.Returns all enabled, validLocalAddeEntries
as a collection of "IDV style"AddeServer.Group
objects.getIdvStyleRemoteGroups
(String server, AddeEntry.EntryType type) Returns the entries matching the givenserver
andtype
parameters as a collection ofAddeServer.Group
objects.getIdvStyleRemoteGroups
(String server, String typeAsStr) Returns the entries matching the givenserver
andtypeAsStr
parameters as a collection ofAddeServer.Group
objects.Returns theAddeEntries
that were added last.Searches the newest entries for the entries of the givenAddeEntry.EntryType
.Returns theAddeEntries
that were added last, filtered by the givenEntryTypes
.Returns the completeSet
ofLocalAddeEntries
.static String
Ask for the port we are listening on.Returns all non-temporaryAddeEntries
.Returns theSet
ofLocalAddeEntries
that will be saved between McIDAS-V sessions.Returns the completeSet
ofRemoteAddeEntries
.Returns anyLocalAddeEntries
that will be removed at the end of the current McIDAS-V session.protected String[]
Returns environment variables that allow mcservl to run on "unix-like" systems.Returns the availableAddeEntries
, grouped byAddeEntry.EntryType
.protected String[]
Returns environment variables that allow mcservl to run on Windows.static boolean
isAddeDebugEnabled
(boolean defValue) Checks the value of thedebug.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 givenAddeEntry
.protected static String
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
(org.apache.commons.collections4.trie.PatriciaTrie<AddeEntry> trie, Collection<? extends AddeEntry> newEntries) AddsAddeEntry
objects to a givenPatriciaTrie
.removeDeletedSystemEntries
(Collection<? extends AddeEntry> entries, Collection<? extends AddeEntry> systemEntries) Searchesentries
forAddeEntry
objects with two characteristics: the object source isAddeEntry.EntrySource.SYSTEM
the object is not insystemEntries
boolean
removeEntries
(Collection<? extends AddeEntry> removedEntries) Removes the givenAddeEntries
.boolean
removeEntry
(AddeEntry entry) Removes a singleAddeEntry
from the set of available entries.void
replaceEntries
(Collection<? extends AddeEntry> oldEntries, Collection<? extends AddeEntry> newEntries) void
Saves the current set of ADDE servers to the user's preferences andADDE_RESOLV
.void
Saves the list of ADDE entries to both the user's preferences andADDE_RESOLV
.searchWithPrefix
(String prefix) Search the server manager for entries that matchprefix
.static boolean
setAddeDebugEnabled
(boolean value) Sets the value of thedebug.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
Starts the local server thread (if it isn't already running).void
Stops the local server thread if it is running.boolean
Test to see if the thread can access userpath
-
Field Details
-
PROP_DEBUG_LOCALROOT
Property that allows users to supply arbitrary paths to McIDAS-X binaries used by mcservl.- See Also:
-
PROP_DEBUG_ADDEURL
Property that allows users to control debug output from ADDE requests.- See Also:
-
ERROR_LOGUTIL_USERPATH
"Userpath" not writable error message. This is the one that is shown in the GUI viaLogUtil.userErrorMessage(String)
.- See Also:
-
ERROR_USERPATH
"Userpath" not writable error message. This one is used by the logging system.- See Also:
-
WARN_NO_RESOLVSRV
SLF4J-style formatting string for use whenRESOLV.SRV
can not be found. .- See Also:
-
logger
Logging object. -
PREF_ADDE_ENTRIES
Preference key for ADDE entries.- See Also:
-
trie
The ADDE servers known to McIDAS-V. -
ADDE_DIRECTORY
"Root" local server directory. -
ADDE_BIN
Path to local server binaries. -
ADDE_DATA
Path to local server data. -
ADDE_MCSERVL
Path to mcservl. -
USER_DIRECTORY
Path to the user's "userpath" directory. -
ADDE_RESOLV
Path to the user's "RESOLV.SRV". -
localPort
Which port is this particular manager operating on -
thread
Thread that monitors the mcservl process. -
lastAdded
LastAddeEntries
added to the manager. -
idvStore
McIDAS-V preferences store.
-
-
Constructor Details
-
EntryStore
Constructs a server manager.- Parameters:
store
- McIDAS-V's preferences store. Cannot benull
.rscManager
- McIDAS-V's resource manager. Cannot benull
.- Throws:
NullPointerException
- if either ofstore
orrscManager
isnull
.
-
-
Method Details
-
removeDeletedSystemEntries
private static Set<AddeEntry> removeDeletedSystemEntries(Collection<? extends AddeEntry> entries, Collection<? extends AddeEntry> systemEntries) Searchesentries
forAddeEntry
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.
entries
can be generated from anywhere you like, butsystemEntries
should almost always be created from "addeservers.xml".- Parameters:
entries
- Cannot benull
.systemEntries
- Cannot benull
.- Returns:
Set
of entries that are not system resources that have been removed, or an emptySet
.
- the object source is
-
putEntries
private static void putEntries(org.apache.commons.collections4.trie.PatriciaTrie<AddeEntry> trie, Collection<? extends AddeEntry> newEntries) AddsAddeEntry
objects to a givenPatriciaTrie
.- Parameters:
trie
- Cannot benull
.newEntries
- Cannot benull
.
-
getIdvStore
Returns theIdvObjectStore
used to save user preferences.- Returns:
IdvObjectStore
used by the rest of McIDAS-V.
-
getWindowsAddeEnv
Returns environment variables that allow mcservl to run on Windows.- Returns:
String
array containing mcservl's environment variables.
-
getUnixAddeEnv
Returns environment variables that allow mcservl to run on "unix-like" systems.- Returns:
String
array containing mcservl's environment variables.
-
getAddeCommands
Returns command line used to launch mcservl.- Returns:
String
array that represents an invocation of mcservl.
-
isInvalidEntry
Determine the validity of a givenAddeEntry
.- Parameters:
entry
- Entry to check. Cannot benull
.- Returns:
true
ifentry
is invalid orfalse
otherwise.- Throws:
NullPointerException
- ifentry
isnull
.AssertionError
- ifentry
is somehow neither aRemoteAddeEntry
orLocalAddeEntry
.- See Also:
-
extractPreferencesEntries
Returns theAddeEntries
stored in the user's preferences.- Parameters:
store
- Object store that represents the user's preferences. Cannot benull
.- Returns:
- Either the
AddeEntrys
stored in the prefs or an emptySet
.
-
onEvent
Responds to server manager events being passed with the event bus.- Parameters:
evt
- Event to which this method is responding. Cannot benull
.- Throws:
NullPointerException
- ifevt
isnull
.
-
saveEntries
Saves the current set of ADDE servers to the user's preferences andADDE_RESOLV
. -
saveForShutdown
Saves the list of ADDE entries to both the user's preferences andADDE_RESOLV
. -
getLastAddedByType
Searches the newest entries for the entries of the givenAddeEntry.EntryType
.- Parameters:
type
- Look for entries matching thisEntryType
. Cannot benull
.- Returns:
- Either a
List
of entries or an emptyList
. - Throws:
NullPointerException
- iftype
isnull
.
-
getLastAddedByTypes
Returns theAddeEntries
that were added last, filtered by the givenEntryTypes
.- Parameters:
types
- Filter the last added entries by these entry type. Cannot benull
.- Returns:
List
of the last added entries, filtered bytypes
.- Throws:
NullPointerException
- iftypes
isnull
.
-
getLastAdded
Returns theAddeEntries
that were added last. Note that this value is not preserved between sessions.- Returns:
List
of the last ADDE entries that were added. May be empty.
-
getVerifiedEntries
- Parameters:
type
- TheEntryType
you are interested in. Cannot benull
.- Returns:
- A
Set
of matching remote ADDE entries. If there were no matches, an emptySet
is returned. - Throws:
NullPointerException
- iftype
isnull
.
-
getVerifiedEntriesByTypes
Returns the availableAddeEntries
, grouped byAddeEntry.EntryType
. -
getGroupsFor
- Parameters:
address
- ADDE server address whose groups are needed. Cannot benull
.type
- Only include groups that matchAddeEntry.EntryType
. Cannot benull
.- Returns:
- Either a set containing the desired groups, or an empty set if there were no matches.
- Throws:
NullPointerException
- if eitheraddress
ortype
isnull
.
-
searchWithPrefix
Search the server manager for entries that matchprefix
.- Parameters:
prefix
-String
to match. Cannot benull
.- Returns:
List
containing matching entries. If there were no matches theList
will be empty.- Throws:
NullPointerException
- ifprefix
isnull
.- See Also:
-
getAddresses
- Returns:
Set
containing all of the stored addresses. If no addresses are stored, an emptySet
is returned.
-
getRemoteEntryTexts
- Returns:
- The "entry text" representations of each
RemoteAddeEntry
. - See Also:
-
getGroups
Returns theSet
of "groups" associated with the givenaddress
.- Parameters:
address
- Address of a server.- Returns:
- Either all of the "groups" on
address
or an emptySet
.
-
getTypes
- Parameters:
address
- Address of a server.group
- Group whose "types" you want.- Returns:
- Either of all the types for a given
address
andgroup
or an emptySet
if there were no matches.
-
getAccountingFor
Searches the set of servers in an attempt to locate the accounting information for the matching server. Note that because the data structure is aSet
, 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.- Parameters:
address
- Address of the server.group
- Dataset.type
- Group type.- Returns:
- Either the
AddeAccount
for the given criteria, orAddeEntry.DEFAULT_ACCOUNT
if there was no match. - See Also:
-
getAccountingFor
Returns the accounting for the givenidvServer
andtypeAsStr
.- Parameters:
idvServer
- Server to search for.typeAsStr
- One of "IMAGE", "POINT", "GRID", "TEXT", "NAV", "RADAR", "UNKNOWN", or "INVALID".- Returns:
AddeAccount
associated withidvServer
andtypeAsStr
.
-
getEntrySet
Returns the completeSet
ofAddeEntries
.- Returns:
- All of the managed ADDE entries.
-
getPersistedEntrySet
Returns all non-temporaryAddeEntries
.- Returns:
Set
of ADDE entries that stick around between McIDAS-V sessions.
-
getRemoteEntries
Returns the completeSet
ofRemoteAddeEntries
.- Returns:
Set
of remote ADDE entries stored within the available entries.
-
getLocalEntries
Returns the completeSet
ofLocalAddeEntries
.- Returns:
Set
of local ADDE entries stored within the available entries.
-
getPersistedLocalEntries
Returns theSet
ofLocalAddeEntries
that will be saved between McIDAS-V sessions.Note: all this does is check
LocalAddeEntry.isEntryTemporary()
.- Returns:
- Local ADDE entries that will be saved for the next session.
-
getTemporaryLocalEntries
Returns anyLocalAddeEntries
that will be removed at the end of the current McIDAS-V session.- Returns:
Set
of all the temporary local ADDE entries.
-
filterLocalEntriesByTemporaryStatus
Filters the local entries by whether or not they are set as "temporary".- Parameters:
getTemporaryEntries
-true
returns temporary local entries;false
returns local entries that are permanent.- Returns:
Set
of filtered local ADDE entries.
-
removeEntries
Removes the givenAddeEntries
.- Parameters:
removedEntries
-AddeEntry
objects to remove. Cannot benull
.- Returns:
- Whether or not
removeEntries
were removed. - Throws:
NullPointerException
- ifremovedEntries
isnull
.
-
removeEntry
Removes a singleAddeEntry
from the set of available entries.- Parameters:
entry
- Entry to remove. Cannot benull
.- Returns:
true
if something was removed,false
otherwise.- Throws:
NullPointerException
- ifentry
isnull
.
-
addEntry
- Parameters:
entry
- Entry to add. Cannot benull
.- Throws:
NullPointerException
- ifentry
isnull
.
-
addEntries
- Parameters:
newEntries
- New entries to add to the server manager. Cannot benull
.- Throws:
NullPointerException
- ifnewEntries
isnull
.
-
replaceEntries
public void replaceEntries(Collection<? extends AddeEntry> oldEntries, Collection<? extends AddeEntry> newEntries) - Parameters:
oldEntries
- Entries to be replaced. Cannot benull
.newEntries
- Entries to use as replacements. Cannot benull
.- Throws:
NullPointerException
- if either ofoldEntries
ornewEntries
isnull
.
-
getIdvStyleLocalGroups
Returns all enabled, validLocalAddeEntries
as a collection of "IDV style"AddeServer.Group
objects.- Returns:
Set
ofAddeServer.Group
objects that corresponds with the enabled, valid local ADDE entries.
-
getIdvStyleRemoteGroups
Returns the entries matching the givenserver
andtypeAsStr
parameters as a collection ofAddeServer.Group
objects.- Parameters:
server
- Remote ADDE server. Should not benull
.typeAsStr
- Entry type. One of "IMAGE", "POINT", "GRID", "TEXT", "NAV", "RADAR", "UNKNOWN", or "INVALID". Should not benull
.- Returns:
Set
ofAddeServer.Group
objects that corresponds to the entries associated withserver
andtypeAsStr
.
-
getIdvStyleRemoteGroups
Returns the entries matching the givenserver
andtype
parameters as a collection ofAddeServer.Group
objects.- Parameters:
server
- Remote ADDE server. Should not benull
.type
- Entry type. Should not benull
.- Returns:
Set
ofAddeServer.Group
objects that corresponds to the entries associated withserver
andtype
.
-
getIdvStyleEntries
Returns a list of all available ADDE datasets, converted to IDVAddeServer
objects.- Returns:
- List of
AddeServer
objects for each ADDE entry.
-
getIdvStyleEntries
Returns a list that consists of the available ADDE datasets for a givenAddeEntry.EntryType
, converted to IDVAddeServer
objects.- Parameters:
type
- Only add entries with this type to the returned list. Cannot benull
.- Returns:
AddeServer
objects for each ADDE entry of the given type.
-
getIdvStyleEntries
Returns a list that consists of the available ADDE datasets for a givenAddeEntry.EntryType
, converted to IDVAddeServer
objects.- Parameters:
typeAsStr
- Only add entries with this type to the returned list. Cannot benull
and must be a value that works withEntryTransforms.strToEntryType(String)
.- Returns:
AddeServer
objects for each ADDE entry of the given type.- See Also:
-
extractResourceEntries
private Set<AddeEntry> extractResourceEntries(AddeEntry.EntrySource source, XmlResourceCollection xmlResources) Process all of the "IDV-style" XML resources for a given "source".- Parameters:
source
- Origin of the XML resources.xmlResources
- Actual XML resources.- Returns:
Set
of theAddeEntrys
extracted fromxmlResources
.
-
extractUserEntries
Process all of the "user" XML resources.- Parameters:
xmlResources
- Resource collection. Cannot benull
.- Returns:
Set
ofRemoteAddeEntries
contained withinresource
.
-
getAddeRootDirectory
Returns the path to where the root directory of the user's McIDAS-X binaries should be. The path may be invalid.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.- Returns:
String
containing the path to the McIDAS-X root directory.- See Also:
-
isAddeDebugEnabled
Checks the value of thedebug.adde.reqs
system property to determine whether or not the user has requested ADDE URL debugging output. Output is sent toSystem.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.- Parameters:
defValue
- Value to return ifdebug.adde.reqs
has not been set.- Returns:
- If it exists, the value of
debug.adde.reqs
. Otherwisedebug.adde.reqs
. - See Also:
-
setAddeDebugEnabled
Sets the value of thedebug.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.- Parameters:
value
- New value ofdebug.adde.reqs
.- Returns:
- Previous value of
debug.adde.reqs
. - See Also:
-
setLocalPort
Change the port we are listening on.- Parameters:
port
- New port number.
-
getLocalPort
Ask for the port we are listening on.- Returns:
- String representation of the listening port.
-
nextLocalPort
Get the next port by incrementing current port.- Returns:
- The next port that will be tried.
-
startLocalServer
Starts the local server thread (if it isn't already running). -
stopLocalServer
Stops the local server thread if it is running. -
testLocalServer
Test to see if the thread can access userpath- Returns:
true
if the local server can access userpath,false
otherwise.
-
checkLocalServer
Check to see if the thread is running.- Returns:
true
if the local server thread is running;false
otherwise.
-