2 * Copyright © 2018-2019 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.core.service
19 import java.time.Duration
21 interface BluePrintClusterService {
23 /** Start the cluster with [clusterInfo], By default clustering service is disabled.
24 * Application module has to start cluster */
25 suspend fun startCluster(clusterInfo: ClusterInfo)
27 fun clusterJoined(): Boolean
29 /** Returns [partitionGroup] master member */
30 suspend fun masterMember(partitionGroup: String): ClusterMember
32 /** Returns all the data cluster members */
33 suspend fun allMembers(): Set<ClusterMember>
35 /** Returns data cluster members starting with prefix */
36 suspend fun clusterMembersForPrefix(memberPrefix: String): Set<ClusterMember>
38 /** Create and get or get the distributed data map store with [name] */
39 suspend fun <T> clusterMapStore(name: String): MutableMap<String, T>
41 /** Create and get the distributed lock with [name] */
42 suspend fun clusterLock(name: String): ClusterLock
44 /** Shut down the cluster with [duration] */
45 suspend fun shutDown(duration: Duration)
48 data class ClusterInfo(
50 var configFile: String? = null,
52 val nodeAddress: String,
53 var clusterMembers: List<String>,
54 var storagePath: String
57 data class ClusterMember(val id: String, val memberAddress: String?, val state: String? = null)
59 interface ClusterLock {
61 suspend fun tryLock(timeout: Long): Boolean
63 fun isLocked(): Boolean