use of io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec in project strimzi-kafka-operator by strimzi.
the class KafkaMirrorMaker2Cluster method fromCrd.
/**
* Creates instance of KafkaMirrorMaker2Cluster from CRD definition.
*
* @param reconciliation The reconciliation
* @param kafkaMirrorMaker2 The Custom Resource based on which the cluster model should be created.
* @param versions The image versions for MirrorMaker 2.0 clusters.
* @return The MirrorMaker 2.0 cluster model.
*/
public static KafkaMirrorMaker2Cluster fromCrd(Reconciliation reconciliation, KafkaMirrorMaker2 kafkaMirrorMaker2, KafkaVersion.Lookup versions) {
KafkaMirrorMaker2Cluster cluster = new KafkaMirrorMaker2Cluster(reconciliation, kafkaMirrorMaker2);
KafkaMirrorMaker2Spec spec = kafkaMirrorMaker2.getSpec();
cluster.setOwnerReference(kafkaMirrorMaker2);
cluster.setImage(versions.kafkaMirrorMaker2Version(spec.getImage(), spec.getVersion()));
List<KafkaMirrorMaker2ClusterSpec> clustersList = ModelUtils.asListOrEmptyList(spec.getClusters());
cluster.setClusters(clustersList);
KafkaMirrorMaker2ClusterSpec connectCluster = new KafkaMirrorMaker2ClusterSpecBuilder().build();
String connectClusterAlias = spec.getConnectCluster();
if (connectClusterAlias != null) {
connectCluster = clustersList.stream().filter(clustersListItem -> spec.getConnectCluster().equals(clustersListItem.getAlias())).findFirst().orElseThrow(() -> new InvalidResourceException("connectCluster with alias " + connectClusterAlias + " cannot be found in the list of clusters at spec.clusters"));
}
cluster.setConfiguration(new KafkaMirrorMaker2Configuration(reconciliation, connectCluster.getConfig().entrySet()));
KafkaMirrorMaker2Cluster mm2 = fromSpec(reconciliation, buildKafkaConnectSpec(spec, connectCluster), versions, cluster);
mm2.templatePodLabels = Util.mergeLabelsOrAnnotations(mm2.templatePodLabels, DEFAULT_POD_LABELS);
return mm2;
}
use of io.strimzi.api.kafka.model.KafkaMirrorMaker2Spec in project strimzi by strimzi.
the class KafkaMirrorMaker2Cluster method fromCrd.
/**
* Creates instance of KafkaMirrorMaker2Cluster from CRD definition.
*
* @param reconciliation The reconciliation
* @param kafkaMirrorMaker2 The Custom Resource based on which the cluster model should be created.
* @param versions The image versions for MirrorMaker 2.0 clusters.
* @return The MirrorMaker 2.0 cluster model.
*/
public static KafkaMirrorMaker2Cluster fromCrd(Reconciliation reconciliation, KafkaMirrorMaker2 kafkaMirrorMaker2, KafkaVersion.Lookup versions) {
KafkaMirrorMaker2Cluster cluster = new KafkaMirrorMaker2Cluster(reconciliation, kafkaMirrorMaker2);
KafkaMirrorMaker2Spec spec = kafkaMirrorMaker2.getSpec();
cluster.setOwnerReference(kafkaMirrorMaker2);
cluster.setImage(versions.kafkaMirrorMaker2Version(spec.getImage(), spec.getVersion()));
List<KafkaMirrorMaker2ClusterSpec> clustersList = ModelUtils.asListOrEmptyList(spec.getClusters());
cluster.setClusters(clustersList);
KafkaMirrorMaker2ClusterSpec connectCluster = new KafkaMirrorMaker2ClusterSpecBuilder().build();
String connectClusterAlias = spec.getConnectCluster();
if (connectClusterAlias != null) {
connectCluster = clustersList.stream().filter(clustersListItem -> spec.getConnectCluster().equals(clustersListItem.getAlias())).findFirst().orElseThrow(() -> new InvalidResourceException("connectCluster with alias " + connectClusterAlias + " cannot be found in the list of clusters at spec.clusters"));
}
cluster.setConfiguration(new KafkaMirrorMaker2Configuration(reconciliation, connectCluster.getConfig().entrySet()));
KafkaMirrorMaker2Cluster mm2 = fromSpec(reconciliation, buildKafkaConnectSpec(spec, connectCluster), versions, cluster);
mm2.templatePodLabels = Util.mergeLabelsOrAnnotations(mm2.templatePodLabels, DEFAULT_POD_LABELS);
return mm2;
}
Aggregations