use of io.strimzi.operator.common.AdminClientProvider in project strimzi by strimzi.
the class ResourceUtils method adminClientProvider.
public static AdminClientProvider adminClientProvider() {
return new AdminClientProvider() {
@Override
public Admin createAdminClient(String bootstrapHostnames, Secret clusterCaCertSecret, Secret keyCertSecret, String keyCertName) {
Admin mock = mock(AdminClient.class);
DescribeClusterResult dcr;
try {
Constructor<DescribeClusterResult> declaredConstructor = DescribeClusterResult.class.getDeclaredConstructor(KafkaFuture.class, KafkaFuture.class, KafkaFuture.class, KafkaFuture.class);
declaredConstructor.setAccessible(true);
KafkaFuture<Node> objectKafkaFuture = KafkaFutureImpl.completedFuture(new Node(0, "localhost", 9091));
KafkaFuture<String> stringKafkaFuture = KafkaFutureImpl.completedFuture("CLUSTERID");
dcr = declaredConstructor.newInstance(null, objectKafkaFuture, stringKafkaFuture, null);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
when(mock.describeCluster()).thenReturn(dcr);
ListTopicsResult ltr;
try {
Constructor<ListTopicsResult> declaredConstructor = ListTopicsResult.class.getDeclaredConstructor(KafkaFuture.class);
declaredConstructor.setAccessible(true);
KafkaFuture<Map<String, TopicListing>> future = KafkaFutureImpl.completedFuture(emptyMap());
ltr = declaredConstructor.newInstance(future);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
when(mock.listTopics(any())).thenReturn(ltr);
DescribeTopicsResult dtr;
try {
Constructor<DescribeTopicsResult> declaredConstructor = DescribeTopicsResult.class.getDeclaredConstructor(Map.class);
declaredConstructor.setAccessible(true);
dtr = declaredConstructor.newInstance(emptyMap());
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
when(mock.describeTopics(any(Collection.class))).thenReturn(dtr);
DescribeConfigsResult dcfr;
try {
Constructor<DescribeConfigsResult> declaredConstructor = DescribeConfigsResult.class.getDeclaredConstructor(Map.class);
declaredConstructor.setAccessible(true);
dcfr = declaredConstructor.newInstance(emptyMap());
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
when(mock.describeConfigs(any())).thenReturn(dcfr);
return mock;
}
};
}
use of io.strimzi.operator.common.AdminClientProvider in project strimzi-kafka-operator by strimzi.
the class ResourceUtils method adminClientProvider.
public static AdminClientProvider adminClientProvider() {
return new AdminClientProvider() {
@Override
public Admin createAdminClient(String bootstrapHostnames, Secret clusterCaCertSecret, Secret keyCertSecret, String keyCertName) {
Admin mock = mock(AdminClient.class);
DescribeClusterResult dcr;
try {
Constructor<DescribeClusterResult> declaredConstructor = DescribeClusterResult.class.getDeclaredConstructor(KafkaFuture.class, KafkaFuture.class, KafkaFuture.class, KafkaFuture.class);
declaredConstructor.setAccessible(true);
KafkaFuture<Node> objectKafkaFuture = KafkaFutureImpl.completedFuture(new Node(0, "localhost", 9091));
KafkaFuture<String> stringKafkaFuture = KafkaFutureImpl.completedFuture("CLUSTERID");
dcr = declaredConstructor.newInstance(null, objectKafkaFuture, stringKafkaFuture, null);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
when(mock.describeCluster()).thenReturn(dcr);
ListTopicsResult ltr;
try {
Constructor<ListTopicsResult> declaredConstructor = ListTopicsResult.class.getDeclaredConstructor(KafkaFuture.class);
declaredConstructor.setAccessible(true);
KafkaFuture<Map<String, TopicListing>> future = KafkaFutureImpl.completedFuture(emptyMap());
ltr = declaredConstructor.newInstance(future);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
when(mock.listTopics(any())).thenReturn(ltr);
DescribeTopicsResult dtr;
try {
Constructor<DescribeTopicsResult> declaredConstructor = DescribeTopicsResult.class.getDeclaredConstructor(Map.class);
declaredConstructor.setAccessible(true);
dtr = declaredConstructor.newInstance(emptyMap());
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
when(mock.describeTopics(any(Collection.class))).thenReturn(dtr);
DescribeConfigsResult dcfr;
try {
Constructor<DescribeConfigsResult> declaredConstructor = DescribeConfigsResult.class.getDeclaredConstructor(Map.class);
declaredConstructor.setAccessible(true);
dcfr = declaredConstructor.newInstance(emptyMap());
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
when(mock.describeConfigs(any())).thenReturn(dcfr);
return mock;
}
};
}
use of io.strimzi.operator.common.AdminClientProvider in project strimzi by strimzi.
the class Main method main.
public static void main(String[] args) {
LOGGER.info("UserOperator {} is starting", Main.class.getPackage().getImplementationVersion());
UserOperatorConfig config = UserOperatorConfig.fromMap(System.getenv());
// Setup Micrometer metrics options
VertxOptions options = new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)).setJvmMetricsEnabled(true).setEnabled(true));
Vertx vertx = Vertx.vertx(options);
KubernetesClient client = new DefaultKubernetesClient();
AdminClientProvider adminClientProvider = new DefaultAdminClientProvider();
run(vertx, client, adminClientProvider, config).onComplete(ar -> {
if (ar.failed()) {
LOGGER.error("Unable to start operator", ar.cause());
System.exit(1);
}
});
}
use of io.strimzi.operator.common.AdminClientProvider in project strimzi-kafka-operator by strimzi.
the class Main method main.
public static void main(String[] args) {
LOGGER.info("UserOperator {} is starting", Main.class.getPackage().getImplementationVersion());
UserOperatorConfig config = UserOperatorConfig.fromMap(System.getenv());
// Setup Micrometer metrics options
VertxOptions options = new VertxOptions().setMetricsOptions(new MicrometerMetricsOptions().setPrometheusOptions(new VertxPrometheusOptions().setEnabled(true)).setJvmMetricsEnabled(true).setEnabled(true));
Vertx vertx = Vertx.vertx(options);
KubernetesClient client = new DefaultKubernetesClient();
AdminClientProvider adminClientProvider = new DefaultAdminClientProvider();
run(vertx, client, adminClientProvider, config).onComplete(ar -> {
if (ar.failed()) {
LOGGER.error("Unable to start operator", ar.cause());
System.exit(1);
}
});
}
Aggregations