Search in sources :

Example 91 with Predicate

use of java.util.function.Predicate in project n4js by eclipse.

the class ScriptApiTracker method _computeMissingApiGetterSetter.

/**
 * Internal algorithm.
 */
private List<AccessorTuple> _computeMissingApiGetterSetter(TN4Classifier declaration, List<AccessorTuple> concreteAccessorTuples, Predicate<ProjectComparisonEntry> filterPredicate, boolean recursive) {
    Optional<ProjectComparisonAdapter> optAdapt = firstProjectComparisonAdapter(declaration.eResource());
    if (optAdapt.isPresent()) {
        ProjectComparisonAdapter projectComparisonAdapter = optAdapt.get();
        ProjectComparisonEntry compareEntry = projectComparisonAdapter.getEntryFor(EcoreUtil2.getContainerOfType(declaration, TModule.class));
        ProjectComparisonEntry typeCompare = compareEntry.getChildForElementImpl(declaration);
        if (typeCompare == null) {
            return Collections.emptyList();
        }
        Predicate<ProjectComparisonEntry> filter = (pce -> (pce.getElementAPI() instanceof TGetter) || (pce.getElementAPI() instanceof TSetter));
        filter = filter.and(pce -> pce.getElementImpl()[0] == null).and(filterPredicate);
        ArrayList<ProjectComparisonEntry> collectedPCEofGetterOrSetter = new ArrayList<>();
        Function<TN4Classifier, Consumer<? super ProjectComparisonEntry>> actionProvider = pivot -> pce -> {
            // Get or Set ??
            collectedPCEofGetterOrSetter.add(pce);
        };
        // recursive Extension will generate a stream of compareEntries.
        if (recursive)
            interfaceApiSupertypeWalker(filter, actionProvider, projectComparisonAdapter, (TN4Classifier) typeCompare.getElementAPI(), TN4Classifier.class);
        // ----
        /*-
				Cases of the Implementation: A getter or setter can
				- be given as AST (x)
				- be missing (m)
				- were not required by API (/)
				So we have 3*3=9 cases:
				get set
				(x) (x) --> all fine, pair will be transpiled
				(x) (m) --> code for getter will be transpiled, need to inject virtual setter code into existing tuple.
				(x) (/) --> all fine, getter will be transpiled
				(m) (x) --> code for setter will be transpiled, need to inject virtual getter code into existing tuple.
				(m) (m) --> need to create virtual accessor tuple (similar to missing field) with setter & getter
				(m) (/) --> need to create virtual accessor tuple with getter only
				(/) (x) --> all fine
				(/) (m) --> need to create virtual accessor tuple with setter only
				(/) (/) --> all fine nothing to be done.
			 */
        List<ProjectComparisonEntry> getSetList;
        if (recursive)
            getSetList = collectedPCEofGetterOrSetter;
        else
            getSetList = typeCompare.allChildren().filter(pce -> (pce.getElementAPI() instanceof TGetter) || (pce.getElementAPI() instanceof TSetter)).filter(filterPredicate).collect(Collectors.toList());
        HashMap<Pair<String, Boolean>, GetSetGroup> hmName2getset = new HashMap<>();
        for (ProjectComparisonEntry pce : getSetList) {
            TMember apiAsMember = ((TMember) pce.getElementAPI());
            String name = apiAsMember.getName();
            boolean staticCase = apiAsMember.isStatic();
            Pair<String, Boolean> key = Pair.of(name, staticCase);
            GetSetGroup group = hmName2getset.get(key);
            if (group == null) {
                group = new GetSetGroup(name, staticCase);
                hmName2getset.put(key, group);
            }
            if (pce.getElementAPI() instanceof TGetter) {
                // case getter:
                TGetter apiGetter = (TGetter) pce.getElementAPI();
                if (pce.getElementImpl(0) != null) {
                    // case (x) for getter-
                    group.getterIsInAST = true;
                } else {
                    // case (m) for getter-
                    group.getterIsInAST = false;
                    group.getter = new VirtualApiTGetter(name, apiGetter);
                }
            } else if (pce.getElementAPI() instanceof TSetter) {
                // case setter:
                TSetter apiSetter = (TSetter) pce.getElementAPI();
                if (pce.getElementImpl(0) != null) {
                    // case (x) for setter -
                    group.setterIsInAST = true;
                } else {
                    // case (m) for setter:
                    group.setterIsInAST = false;
                    group.setter = new VirtualApiTSetter(name, apiSetter);
                }
            }
        }
        // go over the list of known AccessorTupels and enhance them by adding virtual things.
        for (AccessorTuple conAccTupel : concreteAccessorTuples) {
            GetSetGroup getset = hmName2getset.remove(Pair.of(conAccTupel.getName(), conAccTupel.isStatic()));
            if (getset != null) {
                // some missings found:
                if (getset.hasGetter() && !getset.getterIsInAST && // could be mixed in by interface-default-impl different
                conAccTupel.getGetter() == null) // to the intended API-path c.f. GHOLD-212
                {
                    conAccTupel.setGetter(getset.getter);
                }
                if (getset.hasSetter() && !getset.setterIsInAST && // could be mixed in by interface-default-impl different
                conAccTupel.getSetter() == null) // to the intended API-path c.f. GHOLD-212
                {
                    conAccTupel.setSetter(getset.setter);
                }
            }
        }
        // remaining entries in hmName2getset need to translated into VirtualApiAccessors.
        List<AccessorTuple> ret = new ArrayList<>();
        for (GetSetGroup getset : hmName2getset.values()) {
            VirtualApiAccessorTuple vAccessTupel = new VirtualApiAccessorTuple(getset.name, getset.staticCases);
            if (getset.getter != null)
                vAccessTupel.setGetter(getset.getter);
            if (getset.setter != null)
                vAccessTupel.setSetter(getset.setter);
            ret.add(vAccessTupel);
        }
        return ret;
    }
    return emptyList();
}
Also used : TSetter(org.eclipse.n4js.ts.types.TSetter) ProjectComparisonEntry(org.eclipse.n4js.compare.ProjectComparisonEntry) Inject(com.google.inject.Inject) TClass(org.eclipse.n4js.ts.types.TClass) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) TSetter(org.eclipse.n4js.ts.types.TSetter) Logger(org.apache.log4j.Logger) TGetterImpl(org.eclipse.n4js.ts.types.impl.TGetterImpl) TMethodImpl(org.eclipse.n4js.ts.types.impl.TMethodImpl) Type(org.eclipse.n4js.ts.types.Type) MemberList(org.eclipse.n4js.ts.types.util.MemberList) N4InterfaceDeclaration(org.eclipse.n4js.n4JS.N4InterfaceDeclaration) TFieldImpl(org.eclipse.n4js.ts.types.impl.TFieldImpl) LinkedHashMultimap(com.google.common.collect.LinkedHashMultimap) Collections.emptyList(java.util.Collections.emptyList) Predicate(java.util.function.Predicate) TField(org.eclipse.n4js.ts.types.TField) EObject(org.eclipse.emf.ecore.EObject) PROVIDES_DEFAULT_IMPLEMENTATION(org.eclipse.n4js.AnnotationDefinition.PROVIDES_DEFAULT_IMPLEMENTATION) PROVIDES_INITIALZER(org.eclipse.n4js.AnnotationDefinition.PROVIDES_INITIALZER) TMethod(org.eclipse.n4js.ts.types.TMethod) Collectors(java.util.stream.Collectors) TGetter(org.eclipse.n4js.ts.types.TGetter) List(java.util.List) Stream(java.util.stream.Stream) TClassifier(org.eclipse.n4js.ts.types.TClassifier) Resource(org.eclipse.emf.ecore.resource.Resource) Optional(java.util.Optional) Pair(org.eclipse.xtext.xbase.lib.Pair) TypesFactory(org.eclipse.n4js.ts.types.TypesFactory) Singleton(com.google.inject.Singleton) HashMap(java.util.HashMap) TypeUtils(org.eclipse.n4js.ts.utils.TypeUtils) AccessorTuple(org.eclipse.n4js.ts.types.util.AccessorTuple) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) TModule(org.eclipse.n4js.ts.types.TModule) TN4Classifier(org.eclipse.n4js.ts.types.TN4Classifier) TInterface(org.eclipse.n4js.ts.types.TInterface) ProjectCompareHelper(org.eclipse.n4js.compare.ProjectCompareHelper) EcoreUtil2(org.eclipse.xtext.EcoreUtil2) TAnnotableElement(org.eclipse.n4js.ts.types.TAnnotableElement) MemberCollector(org.eclipse.n4js.utils.ContainerTypesHelper.MemberCollector) LinkedHashSet(java.util.LinkedHashSet) Iterator(java.util.Iterator) TMember(org.eclipse.n4js.ts.types.TMember) Script(org.eclipse.n4js.n4JS.Script) Consumer(java.util.function.Consumer) TypesPackage(org.eclipse.n4js.ts.types.TypesPackage) AdapterImpl(org.eclipse.emf.common.notify.impl.AdapterImpl) TSetterImpl(org.eclipse.n4js.ts.types.impl.TSetterImpl) Collections(java.util.Collections) HashMap(java.util.HashMap) TGetter(org.eclipse.n4js.ts.types.TGetter) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) AccessorTuple(org.eclipse.n4js.ts.types.util.AccessorTuple) TModule(org.eclipse.n4js.ts.types.TModule) ProjectComparisonEntry(org.eclipse.n4js.compare.ProjectComparisonEntry) Pair(org.eclipse.xtext.xbase.lib.Pair) TN4Classifier(org.eclipse.n4js.ts.types.TN4Classifier) TMember(org.eclipse.n4js.ts.types.TMember)

Example 92 with Predicate

use of java.util.function.Predicate in project herd by FINRAOS.

the class TagServiceImpl method indexValidateTagsList.

/**
 * A helper method that will validate a list of tags
 *
 * @param tagEntityList the list of tags that will be validated
 *
 * @return true all of the tags are valid in the index
 */
private boolean indexValidateTagsList(final List<TagEntity> tagEntityList) {
    final String indexName = SearchIndexTypeEntity.SearchIndexTypes.TAG.name().toLowerCase();
    final String documentType = configurationHelper.getProperty(ConfigurationValue.ELASTICSEARCH_BDEF_DOCUMENT_TYPE, String.class);
    Predicate<TagEntity> validInIndexPredicate = tagEntity -> {
        // Fetch Join with .size()
        tagEntity.getChildrenTagEntities().size();
        // Convert the tag entity to a JSON string
        final String jsonString = tagHelper.safeObjectMapperWriteValueAsString(tagEntity);
        return this.indexFunctionsDao.isValidDocumentIndex(indexName, documentType, tagEntity.getId().toString(), jsonString);
    // searchFunctions.getIsValidFunction().test(indexName, documentType, tagEntity.getId().toString(), jsonString);
    };
    boolean isValid = true;
    for (TagEntity tagEntity : tagEntityList) {
        if (!validInIndexPredicate.test(tagEntity)) {
            isValid = false;
        }
    }
    return isValid;
}
Also used : SEARCH_INDEX_UPDATE_TYPE_CREATE(org.finra.herd.model.dto.SearchIndexUpdateDto.SEARCH_INDEX_UPDATE_TYPE_CREATE) LoggerFactory(org.slf4j.LoggerFactory) TagTypeDaoHelper(org.finra.herd.service.helper.TagTypeDaoHelper) Autowired(org.springframework.beans.factory.annotation.Autowired) TagCreateRequest(org.finra.herd.model.api.xml.TagCreateRequest) StringUtils(org.apache.commons.lang3.StringUtils) SearchIndexUpdateDto(org.finra.herd.model.dto.SearchIndexUpdateDto) Tag(org.finra.herd.model.api.xml.Tag) BigDecimal(java.math.BigDecimal) Future(java.util.concurrent.Future) TagSearchKey(org.finra.herd.model.api.xml.TagSearchKey) Map(java.util.Map) BusinessObjectDefinitionEntity(org.finra.herd.model.jpa.BusinessObjectDefinitionEntity) AsyncResult(org.springframework.scheduling.annotation.AsyncResult) TagTypeEntity(org.finra.herd.model.jpa.TagTypeEntity) ConfigurationValue(org.finra.herd.model.dto.ConfigurationValue) ImmutableSet(com.google.common.collect.ImmutableSet) Predicate(java.util.function.Predicate) TagUpdateRequest(org.finra.herd.model.api.xml.TagUpdateRequest) Set(java.util.Set) List(java.util.List) ConfigurationHelper(org.finra.herd.core.helper.ConfigurationHelper) TagListResponse(org.finra.herd.model.api.xml.TagListResponse) TagTypeKey(org.finra.herd.model.api.xml.TagTypeKey) IndexFunctionsDao(org.finra.herd.dao.IndexFunctionsDao) Async(org.springframework.scheduling.annotation.Async) TagSearchFilter(org.finra.herd.model.api.xml.TagSearchFilter) TagHelper(org.finra.herd.service.helper.TagHelper) TagSearchRequest(org.finra.herd.model.api.xml.TagSearchRequest) HashMap(java.util.HashMap) BooleanUtils(org.apache.commons.lang3.BooleanUtils) DaoSpringModuleConfig(org.finra.herd.dao.config.DaoSpringModuleConfig) CollectionUtils(org.apache.commons.collections4.CollectionUtils) SearchIndexUpdateHelper(org.finra.herd.service.helper.SearchIndexUpdateHelper) ArrayList(java.util.ArrayList) AlreadyExistsException(org.finra.herd.model.AlreadyExistsException) TagSearchResponse(org.finra.herd.model.api.xml.TagSearchResponse) SEARCH_INDEX_UPDATE_TYPE_UPDATE(org.finra.herd.model.dto.SearchIndexUpdateDto.SEARCH_INDEX_UPDATE_TYPE_UPDATE) Service(org.springframework.stereotype.Service) TagChild(org.finra.herd.model.api.xml.TagChild) TagKey(org.finra.herd.model.api.xml.TagKey) TagDao(org.finra.herd.dao.TagDao) Logger(org.slf4j.Logger) AlternateKeyHelper(org.finra.herd.service.helper.AlternateKeyHelper) SearchableService(org.finra.herd.service.SearchableService) HerdDateUtils(org.finra.herd.core.HerdDateUtils) TagEntity(org.finra.herd.model.jpa.TagEntity) BusinessObjectDefinitionDao(org.finra.herd.dao.BusinessObjectDefinitionDao) TagService(org.finra.herd.service.TagService) SEARCH_INDEX_UPDATE_TYPE_DELETE(org.finra.herd.model.dto.SearchIndexUpdateDto.SEARCH_INDEX_UPDATE_TYPE_DELETE) TagDaoHelper(org.finra.herd.service.helper.TagDaoHelper) Collections(java.util.Collections) SearchIndexTypeEntity(org.finra.herd.model.jpa.SearchIndexTypeEntity) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) TagEntity(org.finra.herd.model.jpa.TagEntity)

Example 93 with Predicate

use of java.util.function.Predicate in project com.revolsys.open by revolsys.

the class Graph method getNodes.

public List<Node<T>> getNodes(final Predicate<Node<T>> filter, final Geometry geometry, final double maxDistance) {
    final BoundingBox boundingBox = geometry.getBoundingBox().expand(maxDistance);
    final Predicate<Node<T>> distanceFilter = (node) -> {
        return filter.test(node) && node.distance(geometry) <= maxDistance;
    };
    return getNodes(boundingBox, distanceFilter, null);
}
Also used : Arrays(java.util.Arrays) ComparatorProxy(com.revolsys.comparator.ComparatorProxy) IdObjectIndex(com.revolsys.geometry.index.IdObjectIndex) LineSegmentUtil(com.revolsys.geometry.model.coordinates.LineSegmentUtil) EdgeEvent(com.revolsys.geometry.graph.event.EdgeEvent) PreDestroy(javax.annotation.PreDestroy) GeometryFactoryProxy(com.revolsys.geometry.model.GeometryFactoryProxy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) PredicateProxy(com.revolsys.predicate.PredicateProxy) Method(java.lang.reflect.Method) PointComparators(com.revolsys.geometry.model.coordinates.comparator.PointComparators) NodeProperties(com.revolsys.geometry.graph.attribute.NodeProperties) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) IntHashMap(com.revolsys.collection.map.IntHashMap) EdgeEventListenerList(com.revolsys.geometry.graph.event.EdgeEventListenerList) PointDoubleXYZ(com.revolsys.geometry.model.impl.PointDoubleXYZ) List(java.util.List) NodeEventListener(com.revolsys.geometry.graph.event.NodeEventListener) Entry(java.util.Map.Entry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ExitLoopException(com.revolsys.util.ExitLoopException) Point(com.revolsys.geometry.model.Point) EdgeEventListener(com.revolsys.geometry.graph.event.EdgeEventListener) NodeWithinBoundingBoxVisitor(com.revolsys.geometry.graph.visitor.NodeWithinBoundingBoxVisitor) LineString(com.revolsys.geometry.model.LineString) HashMap(java.util.HashMap) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Record(com.revolsys.record.Record) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BPlusTreeMap(com.revolsys.collection.bplus.BPlusTreeMap) CoordinatesDistanceComparator(com.revolsys.geometry.model.coordinates.comparator.CoordinatesDistanceComparator) MapEx(com.revolsys.collection.map.MapEx) SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) Iterator(java.util.Iterator) PageValueManager(com.revolsys.io.page.PageValueManager) IsPointOnLineEdgeFilter(com.revolsys.geometry.graph.filter.IsPointOnLineEdgeFilter) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble) NodeEvent(com.revolsys.geometry.graph.event.NodeEvent) Consumer(java.util.function.Consumer) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) TreeMap(java.util.TreeMap) BoundingBoxProxy(com.revolsys.geometry.model.BoundingBoxProxy) Predicates(com.revolsys.predicate.Predicates) NodeDistanceComparator(com.revolsys.geometry.graph.comparator.NodeDistanceComparator) Comparator(java.util.Comparator) NodeEventListenerList(com.revolsys.geometry.graph.event.NodeEventListenerList) Geometry(com.revolsys.geometry.model.Geometry) BaseObjectWithProperties(com.revolsys.properties.BaseObjectWithProperties) Collections(java.util.Collections) BoundingBox(com.revolsys.geometry.model.BoundingBox) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 94 with Predicate

use of java.util.function.Predicate in project com.revolsys.open by revolsys.

the class Graph method getEdges.

public List<Edge<T>> getEdges(final Point point, final double maxDistance) {
    if (point == null) {
        return Collections.emptyList();
    } else {
        BoundingBox boundingBox = point.getBoundingBox();
        boundingBox = boundingBox.expand(maxDistance);
        final double x = point.getX();
        final double y = point.getY();
        final Predicate<Edge<T>> filter = (edge) -> {
            final LineString line = edge.getLineString();
            final double distance = line.distance(x, y);
            if (distance <= maxDistance) {
                return true;
            } else {
                return false;
            }
        };
        return BoundingBox.newArraySorted(this::forEachEdge, boundingBox, filter);
    }
}
Also used : Arrays(java.util.Arrays) ComparatorProxy(com.revolsys.comparator.ComparatorProxy) IdObjectIndex(com.revolsys.geometry.index.IdObjectIndex) LineSegmentUtil(com.revolsys.geometry.model.coordinates.LineSegmentUtil) EdgeEvent(com.revolsys.geometry.graph.event.EdgeEvent) PreDestroy(javax.annotation.PreDestroy) GeometryFactoryProxy(com.revolsys.geometry.model.GeometryFactoryProxy) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) PredicateProxy(com.revolsys.predicate.PredicateProxy) Method(java.lang.reflect.Method) PointComparators(com.revolsys.geometry.model.coordinates.comparator.PointComparators) NodeProperties(com.revolsys.geometry.graph.attribute.NodeProperties) Predicate(java.util.function.Predicate) Collection(java.util.Collection) Set(java.util.Set) IntHashMap(com.revolsys.collection.map.IntHashMap) EdgeEventListenerList(com.revolsys.geometry.graph.event.EdgeEventListenerList) PointDoubleXYZ(com.revolsys.geometry.model.impl.PointDoubleXYZ) List(java.util.List) NodeEventListener(com.revolsys.geometry.graph.event.NodeEventListener) Entry(java.util.Map.Entry) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ExitLoopException(com.revolsys.util.ExitLoopException) Point(com.revolsys.geometry.model.Point) EdgeEventListener(com.revolsys.geometry.graph.event.EdgeEventListener) NodeWithinBoundingBoxVisitor(com.revolsys.geometry.graph.visitor.NodeWithinBoundingBoxVisitor) LineString(com.revolsys.geometry.model.LineString) HashMap(java.util.HashMap) CreateListVisitor(com.revolsys.visitor.CreateListVisitor) Record(com.revolsys.record.Record) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BPlusTreeMap(com.revolsys.collection.bplus.BPlusTreeMap) CoordinatesDistanceComparator(com.revolsys.geometry.model.coordinates.comparator.CoordinatesDistanceComparator) MapEx(com.revolsys.collection.map.MapEx) SerializablePageValueManager(com.revolsys.io.page.SerializablePageValueManager) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) Iterator(java.util.Iterator) PageValueManager(com.revolsys.io.page.PageValueManager) IsPointOnLineEdgeFilter(com.revolsys.geometry.graph.filter.IsPointOnLineEdgeFilter) LineStringDouble(com.revolsys.geometry.model.impl.LineStringDouble) NodeEvent(com.revolsys.geometry.graph.event.NodeEvent) Consumer(java.util.function.Consumer) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) TreeMap(java.util.TreeMap) BoundingBoxProxy(com.revolsys.geometry.model.BoundingBoxProxy) Predicates(com.revolsys.predicate.Predicates) NodeDistanceComparator(com.revolsys.geometry.graph.comparator.NodeDistanceComparator) Comparator(java.util.Comparator) NodeEventListenerList(com.revolsys.geometry.graph.event.NodeEventListenerList) Geometry(com.revolsys.geometry.model.Geometry) BaseObjectWithProperties(com.revolsys.properties.BaseObjectWithProperties) Collections(java.util.Collections) BoundingBox(com.revolsys.geometry.model.BoundingBox) LineString(com.revolsys.geometry.model.LineString) BoundingBox(com.revolsys.geometry.model.BoundingBox)

Example 95 with Predicate

use of java.util.function.Predicate in project strimzi by strimzi.

the class StatefulSetOperator method restartPod.

private Future<Void> restartPod(String namespace, String name, Predicate<String> isReady, String podName) {
    Future<Void> result = Future.future();
    log.info("Roll {}/{}: Rolling pod {}", namespace, name, podName);
    Future<Void> deleted = Future.future();
    Future<CompositeFuture> deleteFinished = Future.future();
    Watcher<Pod> watcher = new RollingUpdateWatcher(deleted);
    Watch watch = podOperations.watch(namespace, podName, watcher);
    // Delete the pod
    log.debug("Roll {}/{}: Waiting for pod {} to be deleted", namespace, name, podName);
    Future podReconcileFuture = podOperations.reconcile(namespace, podName, null);
    CompositeFuture.join(podReconcileFuture, deleted).setHandler(deleteResult -> {
        watch.close();
        if (deleteResult.succeeded()) {
            log.debug("Roll {}/{}: Pod {} was deleted", namespace, name, podName);
        }
        deleteFinished.handle(deleteResult);
    });
    deleteFinished.compose(ix -> {
        log.debug("Roll {}/{}: Waiting for new pod {} to get ready", namespace, name, podName);
        Future<Void> readyFuture = Future.future();
        vertx.setPeriodic(1_000, timerId -> {
            p(isReady, podName).setHandler(x -> {
                if (x.succeeded()) {
                    if (x.result()) {
                        vertx.cancelTimer(timerId);
                        readyFuture.complete();
                    }
                // else not ready
                } else {
                    vertx.cancelTimer(timerId);
                    readyFuture.fail(x.cause());
                }
            });
        });
        return readyFuture;
    }).setHandler(result);
    return result;
}
Also used : CompositeFuture(io.vertx.core.CompositeFuture) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) StatefulSetList(io.fabric8.kubernetes.api.model.extensions.StatefulSetList) MixedOperation(io.fabric8.kubernetes.client.dsl.MixedOperation) DoneableStatefulSet(io.fabric8.kubernetes.api.model.extensions.DoneableStatefulSet) Logger(org.slf4j.Logger) StatefulSet(io.fabric8.kubernetes.api.model.extensions.StatefulSet) Predicate(java.util.function.Predicate) Vertx(io.vertx.core.Vertx) LoggerFactory(org.slf4j.LoggerFactory) Pod(io.fabric8.kubernetes.api.model.Pod) Watcher(io.fabric8.kubernetes.client.Watcher) Watch(io.fabric8.kubernetes.client.Watch) Future(io.vertx.core.Future) ArrayList(java.util.ArrayList) CompositeFuture(io.vertx.core.CompositeFuture) List(java.util.List) RollableScalableResource(io.fabric8.kubernetes.client.dsl.RollableScalableResource) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) Pod(io.fabric8.kubernetes.api.model.Pod) Watch(io.fabric8.kubernetes.client.Watch) Future(io.vertx.core.Future) CompositeFuture(io.vertx.core.CompositeFuture)

Aggregations

Predicate (java.util.function.Predicate)589 List (java.util.List)266 ArrayList (java.util.ArrayList)170 Collectors (java.util.stream.Collectors)167 Map (java.util.Map)164 Set (java.util.Set)137 Test (org.junit.Test)133 IOException (java.io.IOException)122 Collections (java.util.Collections)118 Arrays (java.util.Arrays)110 HashMap (java.util.HashMap)105 Collection (java.util.Collection)93 Optional (java.util.Optional)87 HashSet (java.util.HashSet)85 Stream (java.util.stream.Stream)69 Function (java.util.function.Function)61 File (java.io.File)60 Iterator (java.util.Iterator)55 Logger (org.slf4j.Logger)53 LoggerFactory (org.slf4j.LoggerFactory)52