-
Notifications
You must be signed in to change notification settings - Fork 5
Container
A Container is an instance of a Gravia Runtime.
The set of supported target containers includes but is not limited to
A Container has the following properties.
- It is uniquely identified in the cluster by a ContainerIdentity
- It has a current runtime State
- It has a set of typed Attributes
- It is associated with a specific Host
- It may have a parent Container
- It is associated with a ProfileVersion
- It is associated with a list of Profiles
- It has a set of Management Domains
- It has a set of ServiceEndpoints
Clients can obtain instances of containers from the ContainerManager.
The ContainerManager is the central entry point for working with containers. It containers operations to
- Create, start, stop and destroy containers
- Find containers by given identifiers
- Associate a container with a given ProfileVersion
- Associate a container with a list of given Profiles
- Join/leave the Fabric8 cluster
Container instances returned by the ContainerManager are shallow immutable objects. They represent the state of physical containers at a moment in time.
When Fabric8 bootstraps it automatically creates the current container. This would be a Tomcat, WildFly, Karaf container depending on the Fabric8 distribution that you bootstrap.
To create another Container from the current Container, you would use a ContainerBuilder and pass the so built CreateOptions to the ContainerManager like this
// Building the create options
KarafContainerBuilder builder = KarafContainerBuilder.create();
CreateOptions options = builder.build();
ContainerManager manager = ContainerManagerLocator.getContainerManager();
Container container = manager.createContainer(options);
The set of supported managed containers is
Creating a container provisions the default Profile
// Starting the container
ContainerManager manager = ContainerManagerLocator.getContainerManager();
container = manager.startContainer(container.getIdentity());
// Stopping the container
container = manager.stopContainer(container.getIdentity());
// Destroying the container
ContainerManager manager = ContainerManagerLocator.getContainerManager();
container = manager.destroyContainer(container.getIdentity());
A container that has associated child containers cannot be destroyed.
- Read access to Containers can happen concurrently.
- Each Container supports the notion of a read-write lock.
- A client may explicitly acquire a write lock for a Container.
- Obtaining a write lock for a Container also obtains a write lock on the associated ProfileVersion
Obtaining an exclusive lock on a Container is necessary when consistent access to Container content is required over a number of calls. For example when a Container is provisioned with Profile content it must be guaranteed that the Profile does not change and that no other lifecycle operations can be called on the Container.