public interface Inventory extends AutoCloseable
The resources are organized by tenant (your company) and environments (i.e. testing, development, staging, production, ...).
Despite their name, tenants are not completely separated and one can easily create relationships between them or between entities underneath different tenants. This is because there are situations where such relationships might make sense but more importantly because at the API level, inventory does not mandate any security model. It is assumed that the true multi-tenancy in the common sense of the word is implemented by a layer on top of the inventory API that also understands some security model to separate the tenants.
Resources are hierarchical - meaning that one can be a parent of others, recursively. One can also say that a resource can contain other resources. Resources can have other kinds of relationships that are not necessarily tree-like.
Resources can have a "resource type" (but they don't have to) which prescribes what kind of data a resource contains. Most prominently a resource can have a list of metrics and a resource type can define what those metrics should be by specifying the set of "metric types".
This interface offers a fluent API to compose a "traversal" over the graph of entities stored in the inventory in a strongly typed fashion.
The inventory implementations are not required to be thread-safe. Instances should therefore be accessed only by a single thread or serially.
Note to implementers:
It is highly recommended to extend the BaseInventory and its SPI instead of
this interface directly. The base is considered the "reference implementation" and any implementation is required to
behave the same.
If you for any reason need to implement the full inventory interface, please consider the following:
The interfaces composing the inventory API are of 2 kinds:
Read, ReadWrite or ReadRelate interfaces, e.g.
Environments.ReadWrite),
Single interfaces that provide methods for navigating from a single entity.
These interfaces generally contain methods that enable modification of the entity or its relationships.
See Environments.Single for an example.
Multiple interfaces that provide methods for navigating from multiple entities at once.
These interfaces strictly offer only read-only access to the entities, because the semantics of what should
be done when modifying or relating multiple entities at once is not uniformly defined on all types of
entities and therefore would make the API more confusing than necessary. See
Environments.Multiple for example.
| Modifier and Type | Method and Description |
|---|---|
boolean |
hasObservers(Interest<?,?> interest)
This method is mainly useful for testing.
|
void |
initialize(Configuration configuration)
Initializes the inventory from the provided configuration object.
|
default <E extends AbstractElement<?,U>,U extends AbstractElement.Update,Single extends ResolvableToSingle<E,U>> |
inspect(CanonicalPath path,
Class<Single> accessInterface)
Another generic version of the inspect method, this time using the
CanonicalPath to an element. |
default <E extends AbstractElement<?,U>,U extends AbstractElement.Update,Single extends ResolvableToSingle<E,U>> |
inspect(E entity,
Class<Single> accessInterface)
A generic version of the
inspect methods that accepts an element and returns the access interface to it. |
default Environments.Single |
inspect(Environment environment)
Provides an access interface for inspecting given environment.
|
default Feeds.Single |
inspect(Feed feed)
Provides an access interface for inspecting given feed.
|
default Metrics.Single |
inspect(Metric metric)
Provides an access interface for inspecting given metric.
|
default MetricTypes.Single |
inspect(MetricType metricType)
Provides an access interface for inspecting given metric type.
|
default Relationships.Single |
inspect(Relationship relationship) |
default Resources.Single |
inspect(Resource resource)
Provides an access interface for inspecting given resource.
|
default ResourceTypes.Single |
inspect(ResourceType resourceType)
Provides an access interface for inspecting given resource type.
|
default Tenants.Single |
inspect(Tenant tenant)
Provides an access interface for inspecting given tenant.
|
<C,E> rx.Observable<C> |
observable(Interest<C,E> interest)
NOTE: The subscribers will receive the notifications even after they failed.
|
Relationships.Read |
relationships()
Global access to all relationships.
|
Tenants.ReadWrite |
tenants()
Entry point into the inventory.
|
closevoid initialize(Configuration configuration)
configuration - the configuration to use.Tenants.ReadWrite tenants()
ResolvingToSingle.get(Object)) or
more (ResolvingToMultiple.getAll(org.hawkular.inventory.api.filters.Filter...))
tenants and navigate further to the entities of interest.Relationships.Read relationships()
To create relationships, first navigate to one of its endpoint entities and create it from there using the API calls.
default Tenants.Single inspect(Tenant tenant) throws EntityNotFoundException
tenant - the tenant to steer to.EntityNotFoundExceptiondefault Environments.Single inspect(Environment environment) throws EntityNotFoundException
environment - the environment to steer to.EntityNotFoundExceptiondefault Feeds.Single inspect(Feed feed) throws EntityNotFoundException
feed - the feed to steer to.EntityNotFoundExceptiondefault Metrics.Single inspect(Metric metric) throws EntityNotFoundException
metric - the metric to steer to.EntityNotFoundExceptiondefault MetricTypes.Single inspect(MetricType metricType) throws EntityNotFoundException
metricType - the metric type to steer to.EntityNotFoundExceptiondefault Resources.Single inspect(Resource resource) throws EntityNotFoundException
resource - the resource to steer to.EntityNotFoundExceptiondefault ResourceTypes.Single inspect(ResourceType resourceType) throws EntityNotFoundException
resourceType - the resource type to steer to.EntityNotFoundExceptiondefault Relationships.Single inspect(Relationship relationship)
default <E extends AbstractElement<?,U>,U extends AbstractElement.Update,Single extends ResolvableToSingle<E,U>> Single inspect(E entity, Class<Single> accessInterface)
inspect methods that accepts an element and returns the access interface to it.
If you don't know the type of element (and therefore cannot deduce access interface type) you can always use
ResolvableToSingle type which is guaranteed to be the super interface of
all access interfaces returned from this method (which makes it almost useless but at least you can get the
instance of it).
E - the type of the elementSingle - the type of the access interfaceentity - the element to inspectaccessInterface - the expected access interfaceClassCastException - if the provided access interface doesn't match the elementdefault <E extends AbstractElement<?,U>,U extends AbstractElement.Update,Single extends ResolvableToSingle<E,U>> Single inspect(CanonicalPath path, Class<Single> accessInterface)
CanonicalPath to an element.
If you don't know the type of element (and therefore cannot deduce access interface type) you can always use
ResolvableToSingle type which is guaranteed to be the super interface of
all access interfaces returned from this method (which makes it almost useless but at least you can get the
instance of it).
Single - the type of the access interfacepath - the path to the element (entity or relationship)accessInterface - the expected access interfaceClassCastException - if the provided access interface doesn't match the elementboolean hasObservers(Interest<?,?> interest)
interest - the interest in changes of some inventory entity type<C,E> rx.Observable<C> observable(Interest<C,E> interest)
C - the type of object that will be passed to the subscribers of the returned observableE - the type of the entity the interest is expressed oninterest - the interest in changes of some inventory entity typeCopyright © 2015 Red Hat, Inc.. All rights reserved.