|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlive.cache.Cache
Cache uses live's DTOs to cache data obtained from the z/VM server. Updates to the data within (e.g. calling #addGuest(Guest)) does not update anything on the server. This data is meant to be a model of what is on the z/VM instance being managed. This data should be updated to reflect successful changes made to the actual server. The cache is the source of data for the pages listing guests/group (except for marking active and inactive guests), networks, and (later) shared storage. Other pages, such as member lists for networks and information about guests, is queried live when those pages are loaded.
Field Summary | |
static int |
ERROR
|
(package private) Map |
groupList
Maps cached group names to a group DTO |
(package private) Map |
guestList
Maps cached guest names to a guest DTO |
(package private) LinkedList |
networkList
Stores the cached networks as network DTOs |
(package private) LinkedList |
sharedStorageList
|
private int |
state
|
(package private) ZVMTasks |
tasks
This is the tasks object used when updating the cache from the server |
static int |
UNSET
|
static int |
UPDATING
|
static int |
VALID
|
Constructor Summary | |
Cache(String hostName,
int port,
String userName,
String password)
Creates a new instance of Cache that will connect to hostName on port port with the specified userName and password. |
Method Summary | |
private void |
addGroupsToList(LinkedList groups)
Adds all of the groups in groups to the cache, while at the same time updating all of the guests in each so that they know about what group they are in. |
void |
addGuest(String guestName)
Adds a guest to the cache and leaves it ungrouped. |
void |
addGuest(String guestName,
String groupName)
Adds a guest to the cache and caches his group name as groupName. |
private void |
addGuestsToList(LinkedList guests)
Adds everyone in guests to the cache. |
void |
addNetwork(Network net)
Adds a network to the cache |
void |
addNetwork(String networkName,
int networkType)
Adds a network to the cache by name and type |
void |
addSavedSegment(String ssName)
Add a saved segment to the cache |
private void |
addUngroupedGuestsToUngrouped()
This function goes through the list of guests and adds any that do not belong to a group to the member list of the ungrouped list. |
void |
changeGuestsGroup(String guestName,
String newGroupName)
Change the group that a cached guest belongs to. |
private void |
clearCache()
Removes all cached data from the cache. |
private void |
clearGuestList()
Remove all guests and groups from the cache |
private void |
clearNetworks()
Remove all the networks from the cache |
void |
clearSavedSegments()
Remove all shared storage objects from the shared storage list. |
LinkedList |
getGroupNames()
Returns a LinkedList holding names (as Strings) of all groups in the cache. |
LinkedList |
getGroups()
Returns a list of Group objects corresponding to all groups in the cache. |
Guest |
getGuest(String name)
Gets a specific Guest object |
LinkedList |
getGuestNamesInGroup(String groupName)
Gets all guest names corresponding to the guests in a given group. |
ListIterator |
getGuests()
Get an ListIterator that can be used to visit all
guests in the cache. |
LinkedList |
getGuestsInGroup(String groupName)
Gets all guest objects corresponding to the guests in a given group. |
ListIterator |
getNetworks()
Returns an iterator that can be used to visit all of the networks in the cache. |
ListIterator |
getSavedSegments()
Returns an iterator that can be used to see all the saved segments in the cache |
int |
getState()
|
LinkedList |
getUngroupedGuests()
Gets all guest objects that are not in a group. |
void |
removeGuest(Guest guest)
Removes a guest from the cached list. |
void |
removeGuest(String guestName)
Removes a guest (given by its name) from the cached list. |
void |
removeNetwork(String networkName)
Removes the network with the given name from the cache. |
void |
removeSavedSegment(String ssName)
Remove a saved segment from the cache |
protected void |
setState(int newState)
|
protected void |
swap(Cache c)
Swaps out the current cache for an updated one, updates with the new information puts the current cache into the old one, synchronized to avoid cache problems |
void |
updateCacheFromServer()
Refreshes the cache so that it is consistent with the server |
private void |
updateGuestsGroupsFromServer()
Refreshes the list of guests and groups from the server. |
private void |
updateNetworksFromServer()
Refreshes the network list from the server |
private void |
updateSharedStorageFromServer()
Refreshes the saved segment list from the server |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int VALID
public static final int UPDATING
public static final int ERROR
public static final int UNSET
private int state
Map groupList
Map guestList
LinkedList networkList
LinkedList sharedStorageList
ZVMTasks tasks
Constructor Detail |
public Cache(String hostName, int port, String userName, String password)
Method Detail |
public int getState()
protected void setState(int newState)
public void addGuest(String guestName, String groupName)
CacheException
saying so.
guestName
- The name of the new cached guest entry.groupName
- The group to associate with the guest in the new entry.public void addGuest(String guestName)
guestName
- The name of the new cached guest entry.public void removeGuest(Guest guest)
guest
- The guest object to remove from the cached lists.public void removeGuest(String guestName)
guestName
- The name of the guest to remove from the cached lists.public void changeGuestsGroup(String guestName, String newGroupName)
guestName
- The name of the guest we wish to change.newGroupName
- The name we wish to set as this guests group.public ListIterator getGuests()
ListIterator
that can be used to visit all
guests in the cache.
ListIterator
that can be used to visit all
guests in the cache.private void clearGuestList()
public LinkedList getGroupNames()
public LinkedList getGroups()
public LinkedList getGuestsInGroup(String groupName)
groupName
- The group to search for.
public LinkedList getGuestNamesInGroup(String groupName)
groupName
- The group to search for.
public LinkedList getUngroupedGuests()
public Guest getGuest(String name)
Guest
object
name
- The name of the guest to return
Guest
of that guestpublic void addNetwork(String networkName, int networkType)
networkName
- The name of the networknetworkType
- The type of the network (see Network
for constants you'll probably want to use)public void addNetwork(Network net)
net
- The network to addpublic void removeNetwork(String networkName)
networkName
- The name of the network to removepublic ListIterator getNetworks()
private void clearNetworks()
public void addSavedSegment(String ssName)
ssName
- Name of the saved segment to addpublic void removeSavedSegment(String ssName)
ssName
- Name of the saved segment to removepublic ListIterator getSavedSegments()
ListIterator
An iterator for the cache's saved segment collectionpublic void clearSavedSegments()
private void clearCache()
public void updateCacheFromServer() throws CacheException
CacheException
private void updateGuestsGroupsFromServer() throws CacheException
CacheException
private void addGuestsToList(LinkedList guests)
guests
- The list of guests to add to the cacheprivate void addGroupsToList(LinkedList groups)
groups
- The groups to add to the cache (as Group
s)private void addUngroupedGuestsToUngrouped()
private void updateNetworksFromServer() throws CacheException
CacheException
- If there's a problem. (Use getCause() to determine
what the problem actually is.)private void updateSharedStorageFromServer() throws CacheException
CacheException
- If there's a problem. (Use getCause() to determine
what the problem actually is.)protected void swap(Cache c)
c
- New cache to swap in
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |