Package com.hp.ucmdb.api.topology
Interface Topology
- All Superinterfaces:
Graph
- All Known Subinterfaces:
LiveTopology
Result of a topology query execution.
You can retrieve CIs and relations from this result by query node name or as a flat collection. If each CI matches exactly one node, the two techniques give the same result. If a CI matches more than one node, the topology structure holds n+1 instances of the CI where n is the number of nodes that contain the CI. When a CI is retrieved from the collection returned by
You can retrieve CIs and relations from this result by query node name or as a flat collection. If each CI matches exactly one node, the two techniques give the same result. If a CI matches more than one node, the topology structure holds n+1 instances of the CI where n is the number of nodes that contain the CI. When a CI is retrieved from the collection returned by
getCIsByName(java.lang.String)
,
its properties and relations are defined by the node with the specified name.
When a CI is retrieved from the collection returned by getAllCIs()
, the CI
has all of the of the queried properties and connected relations of all instances of that CI.
Similarly, when a Relations relation is matched by more than one query link node, the
relation appears in this structure more than once.
When traversing the resulting graph with TopologyCI.getOutgoingRelations()
and TopologyCI.getIncomingRelations()
, the relations are consistent with the connected CIs.
If the CI is taken from a node, the relation will be the one connected to that node.
When the CI is taken from the collection of all CIs, it is associated with all the relations
to which the CI is connected from all nodes.
Examples:
List all hosts in UCMDB:
QueryDefinition queryDefinition = factory.createQueryDefinition("Get all hosts"); queryDefinition.addNode("Hosts").ofType("host").queryProperty("host_dnsname"); Topology topology = topologyQueryService.executeQuery(queryDefinition); for (TopologyCI host : topology.getAllCIs()) { System.out.println("Host key:" + host.getPropertyValue("host_dnsname"); }List all hosts with their contained resources
QueryDefinition queryDefinition = factory.createQueryDefinition("Get hosts' resources"); String hostsNodeName = "Hosts"; QueryNode hostsNode = queryDefinition.addNode(cisNodeName).ofType("host"); QueryNode resourcesNode = queryDefinition.addNode("Resources").ofType("hostresource").queryKeyProperties(); hostsNode.linkedTo(resourcesNode).withLinkOfType("composition"); Topology topology = topologyQueryService.executeQuery(queryDefinition); for (TopologyCI host : topology.getCIsByName(hostsNodeName)) { System.out.println("Host:"); printElement(host); for (Relation relation : host.getOutgoingRelations()) { System.out.println("\tResource:"); printElement(relation.getEnd2CI(), "\t"); } }
-
Method Summary
Modifier and TypeMethodDescriptionReturns the collection of all CIs in this result.Returns the CIs in this result as a map from ID to CI.Returns the collection of all Relations in this result.Returns the CI from this result having the specified ID.getCIsByName
(String nodeName) Returns the CIs associated with the specified node.getCIsByNameAsMap
(String nodeName) Returns the map of the CIs associated with the specified node.Returns the node names associated with the id.Returns a map of IDs to their associated node names.Returns the next partial result of a query result.The version of this topology.getRelation
(UcmdbId ucmdbId) Returns the Relation from this result having the specified ID.getRelationsByName
(String linkName) Returns the CIs associated with the specified link.getRelationsByNameAsMap
(String linkName) Returns the map of the CIs associated with the specified link.boolean
Indicates whether more topologies must be retrieved to complete a query result.boolean
isEmpty()
Returns true if the topology is empty.void
Call this method to make the internal topology structure safe to access by multiple threads.boolean
Returns true if the query that generated this topology supports the "has changes" question.Methods inherited from interface com.hp.ucmdb.api.topology.Graph
getAllRelationsAsMap
-
Method Details
-
getCIsByName
Returns the CIs associated with the specified node. -
getCIsByNameAsMap
Returns the map of the CIs associated with the specified node.- Returns:
- a map of IDs to CIs
-
getRelationsByName
Returns the CIs associated with the specified link. -
getRelationsByNameAsMap
Returns the map of the CIs associated with the specified link.- Returns:
- a map of IDs to Relations
-
getAllCIs
Collection<TopologyCI> getAllCIs()Returns the collection of all CIs in this result.
A CI is returned only once. A CI that matches more than one node, is returned with the properties and relations of all instances of the CI. -
getAllCIsAsMap
Map<UcmdbId,TopologyCI> getAllCIsAsMap()Returns the CIs in this result as a map from ID to CI.- Specified by:
getAllCIsAsMap
in interfaceGraph
- See Also:
-
getCI
Returns the CI from this result having the specified ID. The CI returned is from the collection returned bygetAllCIs()
. If no CI with the specified ID if found in the collection,getCI
returns null. -
getRelation
Returns the Relation from this result having the specified ID. The Relation returned is from the collection returned bygetAllRelations()
. If no Relation with the specified ID if found in the collection,getRelation
returns null.- Specified by:
getRelation
in interfaceGraph
-
getAllRelations
Collection<TopologyRelation> getAllRelations()Returns the collection of all Relations in this result.
A Relation is returned only once. A Relation that matches more than one node is returned with the properties of all instances of the Relation.- Specified by:
getAllRelations
in interfaceGraph
-
getContainingNodes
Returns the node names associated with the id. -
getContainingNodesMap
Returns a map of IDs to their associated node names. -
hasNextChunk
boolean hasNextChunk()Indicates whether more topologies must be retrieved to complete a query result. -
getNextChunk
Topology getNextChunk()Returns the next partial result of a query result. Usage:
Please note that calling "getNextChunk()" on a Topology object twice might result in an exception.Topology topology = ... //get initial topology //process initial topology while (topology.hasNextChunk()) { topology = topology.getNextChunk(); //process topology chunk }
-
getQueryResultVersion
The version of this topology.- Returns:
- the version of this topology
-
isEmpty
boolean isEmpty()Returns true if the topology is empty. Equivalent togetAllCIs().isEmpty() && getAllRelations().isEmpty()
- Returns:
- true if the topology is empty.
-
querySupportsHasChanges
Returns true if the query that generated this topology supports the "has changes" question. To support "has changes" questions, a query must be:- saved and not parameterized, though properties carrier changes are allowed
- active (not
QueryDefinitionRecalcPriority.NOT_ACTIVE
)
TopologyQueryService.hasChanges
method with the query name and the query result version attached to this topology.- Returns:
- true if hasChanges is supported by this topology.
- See Also:
-
makeThreadSafe
void makeThreadSafe()Call this method to make the internal topology structure safe to access by multiple threads. As this inflict penalties on single-threaded usage, it must be called explicitly. This method may be called only before any other topology call. Calling this method after calling any other method may yield an exception. Multiple calls to this method are ignored. The Topology is treated as thread-safe only after this method returns.
-