-
Notifications
You must be signed in to change notification settings - Fork 5
Profile
A Profile is an identifiable set of configuration and resource items that can be applied to a Container.
A Profile has the following properties.
- It is uniquely identified in the cluster by a String
- It has a set of typed Attributes
- It is associated with a Profile Version
- It contains a set of ProfileItems
- It may be associated with a set of Containers
- It may have multiple parent Profiles
Clients can obtain instances of profiles from the ProfileManager.
The ProfileManager is the central entry point for working with profiles. It contains operations to
- Add, update, remove profiles
- Find profiles by given identifiers
Profile instances returned by the ProfileManager are shallow immutable objects. They represent the state of physical profile at a moment in time.
There is the notion of LinkedProfile which gives access to the complete hierarchy of a given Profile (including its parent profiles). LinkedProfileVersion gives access to the complete hierarchy of all Profiles associated with a given version.
To create a profile, a client would use a ProfileBuilder and pass the so built Profile to the ProfileManager like this
// Building the profile
Profile profile = ProfileBuilder.Factory.create("foo")
.addConfigurationItem("some.pid", Collections.singletonMap("foo", "bar"))
.getProfile();
// Adding the profile to a version
ProfileManager manager = ProfileManagerLocator.getProfileManager();
profile = manager.addProfile(version, profile);
Every builder (not just for Profiles) supports the use of OptionsProvider. An OptionsProvider can take its information from an arbitrary source and invoke methods on a builder. This decouples data format from the Fabric8 builders.
Here is an example that builds a profile from JMX composite data.
Profile profile = ProfileBuilder.Factory.create()
.addOptions(new CompositeDataOptionsProvider(cdata));
profileBuilder.getProfile();
class CompositeDataOptionsProvider implements OptionsProvider<ProfileBuilder> {
@Override
public ProfileBuilder addBuilderOptions(ProfileBuilder builder) {
Profile profile = ProfileOpenType.getProfile(cdata);
builder.identity(profile.getIdentity());
builder.addAttributes(profile.getAttributes());
return builder;
}
}
From the ProfileManager you can obtain the effective profile for a given profile. This would be the flat profile representation of a given profile and the transitive tree of its parents. Child items override parent items based on identity.
ProfileManager manager = ProfileManagerLocator.getProfileManager();
Profile effectiveFoo = manager.getEffectiveProfile(version, "foo");
// Removing the profile to a version
ProfileManager manager = ProfileManagerLocator.getProfileManager();
manager.removeProfile(version, profile.getIdentity());
A profile that is associated with an active container cannot be removed.