Search in sources :

Example 1 with ZookeeperScaler

use of io.strimzi.operator.cluster.operator.resource.ZookeeperScaler in project strimzi-kafka-operator by strimzi.

the class ZooKeeperReconciler method zkScaler.

/**
 * Helper method for getting the required secrets with certificates and creating the ZookeeperScaler instance
 * for the given cluster. The ZookeeperScaler instance created by this method should be closed manually after
 * it is not used anymore.
 *
 * @param connectToReplicas     Number of pods from the Zookeeper STS which the scaler should use
 *
 * @return                      Zookeeper scaler instance.
 */
private Future<ZookeeperScaler> zkScaler(int connectToReplicas) {
    return ReconcilerUtils.clientSecrets(reconciliation, secretOperator).compose(compositeFuture -> {
        Secret clusterCaCertSecret = compositeFuture.resultAt(0);
        Secret coKeySecret = compositeFuture.resultAt(1);
        Function<Integer, String> zkNodeAddress = (Integer i) -> DnsNameGenerator.podDnsNameWithoutClusterDomain(reconciliation.namespace(), KafkaResources.zookeeperHeadlessServiceName(reconciliation.name()), KafkaResources.zookeeperPodName(reconciliation.name(), i));
        ZookeeperScaler zkScaler = zooScalerProvider.createZookeeperScaler(reconciliation, vertx, zkConnectionString(connectToReplicas, zkNodeAddress), zkNodeAddress, clusterCaCertSecret, coKeySecret, operationTimeoutMs, adminSessionTimeoutMs);
        return Future.succeededFuture(zkScaler);
    });
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ZookeeperScaler(io.strimzi.operator.cluster.operator.resource.ZookeeperScaler)

Example 2 with ZookeeperScaler

use of io.strimzi.operator.cluster.operator.resource.ZookeeperScaler in project strimzi by strimzi.

the class ZooKeeperReconciler method zkScaler.

/**
 * Helper method for getting the required secrets with certificates and creating the ZookeeperScaler instance
 * for the given cluster. The ZookeeperScaler instance created by this method should be closed manually after
 * it is not used anymore.
 *
 * @param connectToReplicas     Number of pods from the Zookeeper STS which the scaler should use
 *
 * @return                      Zookeeper scaler instance.
 */
private Future<ZookeeperScaler> zkScaler(int connectToReplicas) {
    return ReconcilerUtils.clientSecrets(reconciliation, secretOperator).compose(compositeFuture -> {
        Secret clusterCaCertSecret = compositeFuture.resultAt(0);
        Secret coKeySecret = compositeFuture.resultAt(1);
        Function<Integer, String> zkNodeAddress = (Integer i) -> DnsNameGenerator.podDnsNameWithoutClusterDomain(reconciliation.namespace(), KafkaResources.zookeeperHeadlessServiceName(reconciliation.name()), KafkaResources.zookeeperPodName(reconciliation.name(), i));
        ZookeeperScaler zkScaler = zooScalerProvider.createZookeeperScaler(reconciliation, vertx, zkConnectionString(connectToReplicas, zkNodeAddress), zkNodeAddress, clusterCaCertSecret, coKeySecret, operationTimeoutMs, adminSessionTimeoutMs);
        return Future.succeededFuture(zkScaler);
    });
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) ZookeeperScaler(io.strimzi.operator.cluster.operator.resource.ZookeeperScaler)

Example 3 with ZookeeperScaler

use of io.strimzi.operator.cluster.operator.resource.ZookeeperScaler in project strimzi by strimzi.

the class ResourceUtils method zookeeperScalerProvider.

public static ZookeeperScalerProvider zookeeperScalerProvider() {
    return new ZookeeperScalerProvider() {

        @Override
        public ZookeeperScaler createZookeeperScaler(Reconciliation reconciliation, Vertx vertx, String zookeeperConnectionString, Function<Integer, String> zkNodeAddress, Secret clusterCaCertSecret, Secret coKeySecret, long operationTimeoutMs, int zkAdminSessionTimoutMs) {
            ZookeeperScaler mockZooScaler = mock(ZookeeperScaler.class);
            when(mockZooScaler.scale(anyInt())).thenReturn(Future.succeededFuture());
            return mockZooScaler;
        }
    };
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) Function(java.util.function.Function) ZookeeperScaler(io.strimzi.operator.cluster.operator.resource.ZookeeperScaler) Reconciliation(io.strimzi.operator.common.Reconciliation) ZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.ZookeeperScalerProvider) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Vertx(io.vertx.core.Vertx)

Example 4 with ZookeeperScaler

use of io.strimzi.operator.cluster.operator.resource.ZookeeperScaler in project strimzi-kafka-operator by strimzi.

the class ResourceUtils method zookeeperScalerProvider.

public static ZookeeperScalerProvider zookeeperScalerProvider() {
    return new ZookeeperScalerProvider() {

        @Override
        public ZookeeperScaler createZookeeperScaler(Reconciliation reconciliation, Vertx vertx, String zookeeperConnectionString, Function<Integer, String> zkNodeAddress, Secret clusterCaCertSecret, Secret coKeySecret, long operationTimeoutMs, int zkAdminSessionTimoutMs) {
            ZookeeperScaler mockZooScaler = mock(ZookeeperScaler.class);
            when(mockZooScaler.scale(anyInt())).thenReturn(Future.succeededFuture());
            return mockZooScaler;
        }
    };
}
Also used : Secret(io.fabric8.kubernetes.api.model.Secret) Function(java.util.function.Function) ZookeeperScaler(io.strimzi.operator.cluster.operator.resource.ZookeeperScaler) Reconciliation(io.strimzi.operator.common.Reconciliation) ZookeeperScalerProvider(io.strimzi.operator.cluster.operator.resource.ZookeeperScalerProvider) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Vertx(io.vertx.core.Vertx)

Aggregations

Secret (io.fabric8.kubernetes.api.model.Secret)4 ZookeeperScaler (io.strimzi.operator.cluster.operator.resource.ZookeeperScaler)4 ZookeeperScalerProvider (io.strimzi.operator.cluster.operator.resource.ZookeeperScalerProvider)2 Reconciliation (io.strimzi.operator.common.Reconciliation)2 Vertx (io.vertx.core.Vertx)2 Function (java.util.function.Function)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2