Search in sources :

Example 1 with ConnectorNamespaceList

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

the class SyncTestSupport method namespaceList.

public static ObjectNode namespaceList(ConnectorNamespace... namespaces) {
    var items = new ConnectorNamespaceList();
    items.page(1);
    items.size(namespaces.length);
    items.total(namespaces.length);
    for (ConnectorNamespace namespace : namespaces) {
        items.addItemsItem(namespace);
    }
    return Serialization.jsonMapper().convertValue(items, ObjectNode.class);
}
Also used : ConnectorNamespace(org.bf2.cos.fleet.manager.model.ConnectorNamespace) ConnectorNamespaceList(org.bf2.cos.fleet.manager.model.ConnectorNamespaceList)

Example 2 with ConnectorNamespaceList

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

the class FleetManagerClient method getNamespaces.

public void getNamespaces(long gv, Consumer<Collection<ConnectorNamespace>> consumer) {
    RestClientHelper.run(() -> {
        LOGGER.debug("polling namespaces with gv: {}", gv);
        final AtomicInteger counter = new AtomicInteger();
        final List<ConnectorNamespace> items = new ArrayList<>();
        for (int i = 1; i < Integer.MAX_VALUE; i++) {
            ConnectorNamespaceList list = controlPlane.getConnectorNamespaces(config.cluster().id(), Integer.toString(i), null, gv);
            if (list == null || list.getItems() == null || list.getItems().isEmpty()) {
                LOGGER.info("No namespace for cluster {}", config.cluster().id());
                break;
            }
            items.addAll(list.getItems());
            consumer.accept(items);
            if (counter.addAndGet(items.size()) >= list.getTotal()) {
                break;
            }
        }
    });
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ConnectorNamespace(org.bf2.cos.fleet.manager.model.ConnectorNamespace) ArrayList(java.util.ArrayList) ConnectorNamespaceList(org.bf2.cos.fleet.manager.model.ConnectorNamespaceList)

Aggregations

ConnectorNamespace (org.bf2.cos.fleet.manager.model.ConnectorNamespace)2 ConnectorNamespaceList (org.bf2.cos.fleet.manager.model.ConnectorNamespaceList)2 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1