import org.onap.ccsdk.cds.blueprintsprocessor.core.service.BluePrintClusterService
import org.onap.ccsdk.cds.blueprintsprocessor.core.service.ClusterInfo
import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.logger
-import org.onap.ccsdk.cds.controllerblueprints.core.splitCommaAsList
import org.onap.ccsdk.cds.controllerblueprints.core.utils.ClusterUtils
import org.springframework.boot.context.event.ApplicationReadyEvent
import org.springframework.context.event.EventListener
import org.springframework.stereotype.Component
import java.time.Duration
+import java.util.Properties
import javax.annotation.PreDestroy
/**
* 2. Container names should end with sequence number.
* Blueprintprocessor example be : cds-controller-1, cds-controller-2, cds-controller-3
* ResourceResolution example be : resource-resolution-1, resource-resolution-2, resource-resolution-3
- * 3. Each contained, should have environment properties CLUSTER_ID, CLUSTER_NODE_ID, CLUSTER_NODE_ADDRESS,
- * CLUSTER_MEMBERS, CLUSTER_STORAGE_PATH
+ * 3. Each contained, should have environment properties CLUSTER_ID, CLUSTER_NODE_ID, CLUSTER_JOIN_AS_CLIENT,
+ * CLUSTER_CONFIG_FILE
* Example values :
* CLUSTER_ID: cds-cluster
* CLUSTER_NODE_ID: cds-controller-2
- * CLUSTER_NODE_ADDRESS: cds-controller-2
- * CLUSTER_MEMBERS: cds-controller-1,cds-controller-2,cds-controller-3,resource-resolution-1,resource-resolution-2,resource-resolution-3
- * CLUSTER_STORAGE_PATH: /opt/app/onap/config/cluster
- * CLUSTER_CONFIG_FILE: /opt/app/onap/config/atomix/atomix-multicast.conf
+ * CLUSTER_JOIN_AS_CLIENT: "true" or "false"
+ * CLUSTER_CONFIG_FILE: <Config location>
* 4. Cluster will be enabled only all the above properties present in the environments.
* if CLUSTER_ENABLED is present, then it will try to create cluster.
*/
val clusterId = ClusterUtils.clusterId()
val nodeId = ClusterUtils.clusterNodeId()
- val nodeAddress = ClusterUtils.clusterNodeAddress()
- val clusterMembers = System.getenv(BluePrintConstants.PROPERTY_CLUSTER_MEMBERS)
- ?: throw BluePrintProcessorException("couldn't get environment variable ${BluePrintConstants.PROPERTY_CLUSTER_MEMBERS}")
-
- val clusterMemberList = clusterMembers.splitCommaAsList()
-
- val clusterStorage = System.getenv(BluePrintConstants.PROPERTY_CLUSTER_STORAGE_PATH)
- ?: throw BluePrintProcessorException("couldn't get environment variable ${BluePrintConstants.PROPERTY_CLUSTER_STORAGE_PATH}")
+ val joinAsClient =
+ (System.getenv(BluePrintConstants.PROPERTY_CLUSTER_JOIN_AS_CLIENT) ?: "false").toBoolean()
val clusterConfigFile = System.getenv(BluePrintConstants.PROPERTY_CLUSTER_CONFIG_FILE)
+ val properties = Properties()
+ properties["hazelcast.logging.type"] = "slf4j"
+
val clusterInfo = ClusterInfo(
id = clusterId, nodeId = nodeId,
- clusterMembers = clusterMemberList, nodeAddress = nodeAddress,
- storagePath = clusterStorage,
- configFile = clusterConfigFile
+ joinAsClient = joinAsClient,
+ configFile = clusterConfigFile,
+ properties = properties
)
bluePrintClusterService.startCluster(clusterInfo)
} else {