public class AssignmentMonitor extends Object implements Monitor
An implementation of the Monitor
interface that loads its information
about the underlying nodes from an XML file called nodes.xml
.
This implementation additionally uses an in-memory hash map to monitor the
load on a given set of ResourceNode
s.
Constructor and Description |
---|
AssignmentMonitor(List<ResourceNode> nodes) |
Modifier and Type | Method and Description |
---|---|
void |
addNode(ResourceNode node)
Adds a new
ResourceNode for this Monitor to manage (if
node already exist, then should perform update) |
boolean |
assignLoad(ResourceNode node,
int loadValue) |
int |
getLoad(ResourceNode node)
Gets the load on a resource node available to the resource manager.
|
ResourceNode |
getNodeById(String nodeId)
Gets the
ResourceNode with the given nodeId . |
ResourceNode |
getNodeByURL(URL ipAddr)
Returns the
ResourceNode with the given ipAddr . |
List<ResourceNode> |
getNodes() |
boolean |
reduceLoad(ResourceNode node,
int loadValue)
Reduces the load on a particular
ResourceNode by the given
loadValue . |
void |
removeNodeById(String nodeId)
Remove
ResourceNode from this Monitor |
public AssignmentMonitor(List<ResourceNode> nodes)
public boolean assignLoad(ResourceNode node, int loadValue) throws MonitorException
assignLoad
in interface Monitor
node
- The ResourceNode
to assign load to.loadValue
- The integer load to assign to the given ResourceNode
.MonitorException
- If any error occurs assigning the load.public boolean reduceLoad(ResourceNode node, int loadValue) throws MonitorException
Monitor
ResourceNode
by the given
loadValue
.reduceLoad
in interface Monitor
node
- The ResourceNode
to reduce the load on.loadValue
- The amount of reduction.MonitorException
- If any error occurs.public int getLoad(ResourceNode node) throws MonitorException
Monitor
getLoad
in interface Monitor
node
- The ResourceNode
to obtain the load for.ResourceNode
.MonitorException
- If there is any error obtaining the load.public List<ResourceNode> getNodes() throws MonitorException
getNodes
in interface Monitor
List
of the ResourceNode
s known to the resource
manager.MonitorException
- If any error occurs getting the List
of
ResourceNode
s.public ResourceNode getNodeById(String nodeId) throws MonitorException
Monitor
ResourceNode
with the given nodeId
.getNodeById
in interface Monitor
ResourceNode
for the corresponding nodeId
.MonitorException
- If any error occurs.public ResourceNode getNodeByURL(URL ipAddr) throws MonitorException
Monitor
ResourceNode
with the given ipAddr
.getNodeByURL
in interface Monitor
ipAddr
- The URL of the ResourceNode to return.ResourceNode
with the given ipAddr.MonitorException
- If any error occurs.public void addNode(ResourceNode node) throws MonitorException
Monitor
ResourceNode
for this Monitor
to manage (if
node already exist, then should perform update)addNode
in interface Monitor
node
- The new ResourceNode
to manageMonitorException
public void removeNodeById(String nodeId) throws MonitorException
Monitor
ResourceNode
from this Monitor
removeNodeById
in interface Monitor
nodeId
- The id of the ResourceNode
to removeMonitorException
Copyright © 1999–2017 Apache OODT. All rights reserved.