Search in sources :

Example 1 with ConnectorDeploymentList

use of org.bf2.cos.fleet.manager.model.ConnectorDeploymentList in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class SyncTestSupport method deploymentList.

public static ObjectNode deploymentList(ConnectorDeployment... deployments) {
    var items = new ConnectorDeploymentList();
    items.page(1);
    items.size(deployments.length);
    items.total(deployments.length);
    for (ConnectorDeployment deployment : deployments) {
        items.addItemsItem(deployment);
    }
    return Serialization.jsonMapper().convertValue(items, ObjectNode.class);
}
Also used : ConnectorDeployment(org.bf2.cos.fleet.manager.model.ConnectorDeployment) ConnectorDeploymentList(org.bf2.cos.fleet.manager.model.ConnectorDeploymentList)

Example 2 with ConnectorDeploymentList

use of org.bf2.cos.fleet.manager.model.ConnectorDeploymentList in project cos-fleetshard by bf2fc6cc711aee1a0c2a.

the class FleetManagerClient method getDeployments.

public void getDeployments(long gv, Consumer<Collection<ConnectorDeployment>> consumer) {
    RestClientHelper.run(() -> {
        LOGGER.debug("polling deployment with gv: {}", gv);
        final AtomicInteger counter = new AtomicInteger();
        final List<ConnectorDeployment> items = new ArrayList<>();
        for (int i = 1; i < Integer.MAX_VALUE; i++) {
            ConnectorDeploymentList list = controlPlane.getConnectorDeployments(config.cluster().id(), Integer.toString(i), null, gv);
            if (list == null || list.getItems() == null || list.getItems().isEmpty()) {
                LOGGER.info("No connectors for cluster {}", config.cluster().id());
                break;
            }
            items.clear();
            items.addAll(list.getItems());
            items.sort(Comparator.comparingLong(d -> d.getMetadata().getResourceVersion()));
            consumer.accept(items);
            if (counter.addAndGet(items.size()) >= list.getTotal()) {
                break;
            }
        }
    });
}
Also used : ConnectorDeploymentStatus(org.bf2.cos.fleet.manager.model.ConnectorDeploymentStatus) ConnectorDeploymentList(org.bf2.cos.fleet.manager.model.ConnectorDeploymentList) Logger(org.slf4j.Logger) Collection(java.util.Collection) ConnectorClusterStatus(org.bf2.cos.fleet.manager.model.ConnectorClusterStatus) LoggerFactory(org.slf4j.LoggerFactory) FleetShardSyncConfig(org.bf2.cos.fleetshard.sync.FleetShardSyncConfig) ConnectorDeployment(org.bf2.cos.fleet.manager.model.ConnectorDeployment) ConnectorNamespace(org.bf2.cos.fleet.manager.model.ConnectorNamespace) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) ConnectorNamespaceStatus(org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Serialization(io.fabric8.kubernetes.client.utils.Serialization) ConnectorNamespaceList(org.bf2.cos.fleet.manager.model.ConnectorNamespaceList) ApplicationScoped(javax.enterprise.context.ApplicationScoped) UriBuilder(javax.ws.rs.core.UriBuilder) Comparator(java.util.Comparator) RestClientBuilder(org.eclipse.microprofile.rest.client.RestClientBuilder) ManagedConnector(org.bf2.cos.fleetshard.api.ManagedConnector) ConnectorDeployment(org.bf2.cos.fleet.manager.model.ConnectorDeployment) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) ConnectorDeploymentList(org.bf2.cos.fleet.manager.model.ConnectorDeploymentList)

Aggregations

ConnectorDeployment (org.bf2.cos.fleet.manager.model.ConnectorDeployment)2 ConnectorDeploymentList (org.bf2.cos.fleet.manager.model.ConnectorDeploymentList)2 Serialization (io.fabric8.kubernetes.client.utils.Serialization)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Consumer (java.util.function.Consumer)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 UriBuilder (javax.ws.rs.core.UriBuilder)1 ConnectorClusterStatus (org.bf2.cos.fleet.manager.model.ConnectorClusterStatus)1 ConnectorDeploymentStatus (org.bf2.cos.fleet.manager.model.ConnectorDeploymentStatus)1 ConnectorNamespace (org.bf2.cos.fleet.manager.model.ConnectorNamespace)1 ConnectorNamespaceList (org.bf2.cos.fleet.manager.model.ConnectorNamespaceList)1 ConnectorNamespaceStatus (org.bf2.cos.fleet.manager.model.ConnectorNamespaceStatus)1 ManagedConnector (org.bf2.cos.fleetshard.api.ManagedConnector)1 FleetShardSyncConfig (org.bf2.cos.fleetshard.sync.FleetShardSyncConfig)1 RestClientBuilder (org.eclipse.microprofile.rest.client.RestClientBuilder)1