2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.context;
25 import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
26 import org.onap.policy.apex.model.basicmodel.concepts.AxConcept;
27 import org.onap.policy.apex.model.contextmodel.concepts.AxContextAlbum;
30 * The Interface ContextAlbum is implemented by all classes that manage context in Apex. Context
31 * albums may store context in memory, on disk, in a repository or in a mechanism such as a
34 * <p>A context album uses plugins to handle its context schemas, its distribution, its locking, and
37 * <p>The schema that defines the items in a context album is interpreted by a plugin that implements
38 * the {@link SchemaHelper} interface. The schema helper uses the schema definition to provide new
39 * instances for a context album. By default, context albums use Java schemas.
41 * <p>Context albums may be shared across an arbitrary number of JVMs using a distribution mechanism.
42 * Apex context distributed context albums using plugins that implement the {@link Distributor}
43 * interface. By default, context albums use JVM local distribution, that is context albums are only
44 * available in a single JVM
46 * <p>Items in a context album may be locked across all distributed instances of an album. Apex locks
47 * instances on context albums using the distributed locking mechanism in a plugin that implements
48 * the {@link LockManager} interface. By default, context albums use Java locking local to a single
49 * JVM on each context album instance.
51 * <p>Context albums may be persisted to disk, database, or any other repository. Apex persists context
52 * albums using the persistence mechanism in a plugin that implements the {@link Persistor}
53 * interface. By default, context albums use a dummy persistor plugin that does not persist context
56 * @author Liam Fallon (liam.fallon@ericsson.com)
58 public interface ContextAlbum extends Map<String, Object> {
60 * Gets the key of the context album instance.
64 AxArtifactKey getKey();
67 * Gets the name of the context album instance.
74 * Get the current context album with values.
76 * @return the current context runtime values
78 AxContextAlbum getAlbumDefinition();
81 * Get the schema helper for the technology that is handling the schema for this album.
83 * @return the schema helper
85 SchemaHelper getSchemaHelper();
88 * Place a read lock on a key in this album across the entire cluster.
90 * @param key The key to lock
91 * @throws ContextException on locking errors
93 void lockForReading(String key) throws ContextException;
96 * Place a write lock on a key in this album across the entire cluster.
98 * @param key The key to lock
99 * @throws ContextException on locking errors
101 void lockForWriting(String key) throws ContextException;
104 * Release the the read lock on a key in this album across the entire cluster.
106 * @param key The key to unlock
107 * @throws ContextException on locking errors
109 void unlockForReading(String key) throws ContextException;
112 * Release the the write lock on a key in this album across the entire cluster.
114 * @param key The key to unlock
115 * @throws ContextException on locking errors
117 void unlockForWriting(String key) throws ContextException;
120 * Get the stack of artifact keys currently using this context item.
122 * @return the keys of the artifacts using the context album at the moment
124 AxConcept[] getUserArtifactStack();
127 * Set the stack of artifact keys currently using this context item.
129 * @param userArtifactStack the keys of the artifacts using the context album at the moment
131 void setUserArtifactStack(AxConcept[] userArtifactStack);
134 * Flush the context album to the distribution and persistence mechanism.
136 * @throws ContextException On context flush errors
138 void flush() throws ContextException;