public class EntryStore extends Object
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 |
private List<AddeEntry> |
lastAdded
The last
AddeEntry s added to the manager. |
private static String |
localPort
Which port is this particular manager operating on
|
private static org.slf4j.Logger |
logger |
private String |
MCTRACE |
private static String |
PREF_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 boolean |
restartingMcserv |
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) |
Modifier and Type | Method and Description |
---|---|
void |
addEntries(Collection<? extends AddeEntry> newEntries)
|
boolean |
checkLocalServer()
check to see if the thread is running
|
private Set<AddeEntry> |
extractFromPreferences(IdvObjectStore store)
Returns the
AddeEntrys stored
in the user's preferences. |
private Set<AddeEntry> |
extractResourceEntries(AddeEntry.EntrySource source,
XmlResourceCollection xmlResources)
Process all of the "IDV-style" XML resources.
|
private Set<AddeEntry> |
extractUserEntries(XmlResourceCollection xmlResources)
Process all of the "user" XML resources.
|
AddeAccount |
getAccountingFor(AddeServer idvServer,
String 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() |
static String |
getAddeRootDirectory()
Returns the path to where the root directory of the user's McIDAS-X
binaries should be.
|
Set<String> |
getAddresses()
|
protected Set<AddeEntry> |
getEntrySet()
|
Set<String> |
getGroups(String address)
Returns the
Set of "groups" associated with the
given address . |
Set<String> |
getGroupsFor(String address,
AddeEntry.EntryType type)
|
protected IdvObjectStore |
getIdvStore() |
List<AddeServer> |
getIdvStyleEntries() |
Set<AddeServer> |
getIdvStyleEntries(AddeEntry.EntryType type) |
Set<AddeServer> |
getIdvStyleEntries(String typeAsStr) |
Set<AddeServer.Group> |
getIdvStyleLocalGroups() |
Set<AddeServer.Group> |
getIdvStyleRemoteGroups(String server,
AddeEntry.EntryType type) |
Set<AddeServer.Group> |
getIdvStyleRemoteGroups(String server,
String typeAsStr) |
List<AddeEntry> |
getLastAdded() |
List<AddeEntry> |
getLastAddedByType(AddeEntry.EntryType type)
Searches the newest entries for the entries of the given
EntryType . |
List<AddeEntry> |
getLastAddedByTypes(EnumSet<AddeEntry.EntryType> types) |
protected Set<LocalAddeEntry> |
getLocalEntries()
Returns the complete
Set of LocalAddeEntry s. |
static String |
getLocalPort()
Ask for the port we are listening on
|
protected Set<RemoteAddeEntry> |
getRemoteEntries()
Returns the complete
Set of RemoteAddeEntry s. |
protected Set<String> |
getRemoteEntryTexts()
|
boolean |
getRestarting() |
Set<AddeEntry.EntryType> |
getTypes(String address,
String group)
|
protected String[] |
getUnixAddeEnv() |
Set<AddeEntry> |
getVerifiedEntries(AddeEntry.EntryType type)
|
Map<AddeEntry.EntryType,Set<AddeEntry>> |
getVerifiedEntriesByTypes() |
protected String[] |
getWindowsAddeEnv() |
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) |
protected boolean |
removeEntries(Collection<? extends AddeEntry> removedEntries) |
protected boolean |
removeEntry(AddeEntry entry) |
void |
replaceEntries(Collection<? extends AddeEntry> oldEntries,
Collection<? extends AddeEntry> newEntries)
|
void |
restartLocalServer()
restart the thread
|
void |
saveEntries()
Saves the current set of ADDE servers to the user's preferences.
|
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(boolean restarting)
start addeMcservl if it exists
|
void |
stopLocalServer(boolean restarting)
stop the thread if it is running
|
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 static AddeThread thread
private final IdvObjectStore idvStore
private boolean restartingMcserv
public EntryStore(IdvObjectStore store, IdvResourceManager rscManager)
private static void putEntries(PatriciaTrie<String,AddeEntry> trie, Collection<? extends AddeEntry> newEntries)
protected IdvObjectStore getIdvStore()
protected String[] getWindowsAddeEnv()
protected String[] getUnixAddeEnv()
protected String[] getAddeCommands()
public static boolean isInvalidEntry(AddeEntry entry)
AddeEntry
.entry
- Entry to check. Cannot be null
.true
if entry
is invalid or false
otherwise.AssertionError
- if entry
is somehow neither a RemoteAddeEntry
or LocalAddeEntry
.LocalAddeEntry.INVALID_ENTRY
,
RemoteAddeEntry.INVALID_ENTRY
private Set<AddeEntry> extractFromPreferences(IdvObjectStore store)
AddeEntrys
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.public void saveEntries()
public List<AddeEntry> getLastAddedByType(AddeEntry.EntryType type)
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)
public List<AddeEntry> getLastAdded()
public Set<AddeEntry> getVerifiedEntries(AddeEntry.EntryType type)
type
- The EntryType
you are interested in.Set
of matching RemoteAddeEntry
s. If there
were no matches, an empty Set
is returned.public Map<AddeEntry.EntryType,Set<AddeEntry>> getVerifiedEntriesByTypes()
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
.public List<AddeEntry> searchWithPrefix(String prefix)
prefix
.prefix
- String
to match.List
containing matching entries. If there were no
matches the List
will be empty.AddeEntry.asStringId()
public Set<String> getAddresses()
Set
containing all of the stored addresses. If no
addresses are stored, an empty Set
is returned.protected 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)
protected Set<AddeEntry> getEntrySet()
protected Set<RemoteAddeEntry> getRemoteEntries()
Set
of RemoteAddeEntry
s.RemoteAddeEntry
s stored within #entries
.protected Set<LocalAddeEntry> getLocalEntries()
Set
of LocalAddeEntry
s.LocalAddeEntry
s stored within #entries
.protected boolean removeEntries(Collection<? extends AddeEntry> removedEntries)
protected boolean removeEntry(AddeEntry entry)
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()
public Set<AddeServer.Group> getIdvStyleRemoteGroups(String server, String typeAsStr)
public Set<AddeServer.Group> getIdvStyleRemoteGroups(String server, AddeEntry.EntryType type)
public List<AddeServer> getIdvStyleEntries()
public Set<AddeServer> getIdvStyleEntries(AddeEntry.EntryType type)
public Set<AddeServer> getIdvStyleEntries(String typeAsStr)
private Set<AddeEntry> extractResourceEntries(AddeEntry.EntrySource source, XmlResourceCollection xmlResources)
source
- xmlResources
- private Set<AddeEntry> extractUserEntries(XmlResourceCollection xmlResources)
xmlResources
- Resource collection. Cannot be null
.Set
of RemoteAddeEntry
s 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_LOCALROOT
public 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_ADDEURL
public 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_ADDEURL
public static void setLocalPort(String port)
port
- New port number.public static String getLocalPort()
protected static String nextLocalPort()
public void startLocalServer(boolean restarting)
public void stopLocalServer(boolean restarting)
public void restartLocalServer()
public boolean getRestarting()
public boolean checkLocalServer()