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 all the data cluster members */
30 suspend fun allMembers(): Set<ClusterMember>
32 /** Returns data cluster members starting with prefix */
33 suspend fun clusterMembersForPrefix(memberPrefix: String): Set<ClusterMember>
35 /** Create and get or get the distributed data map store with [name] */
36 suspend fun <T> clusterMapStore(name: String): MutableMap<String, T>
38 /** Create and get the distributed lock with [name] */
39 suspend fun clusterLock(name: String): ClusterLock
41 /** Shut down the cluster with [duration] */
42 suspend fun shutDown(duration: Duration)
45 data class ClusterInfo(
47 var configFile: String? = null,
49 val nodeAddress: String,
50 var clusterMembers: List<String>,
51 var storagePath: String
54 data class ClusterMember(val id: String, val memberAddress: String?, val state: String? = null)
56 interface ClusterLock {
58 suspend fun tryLock(timeout: Long): Boolean
60 fun isLocked(): Boolean