Search in sources :

Example 1 with SharedDomainEntity

use of org.cloudfoundry.client.v2.shareddomains.SharedDomainEntity in project promregator by promregator.

the class ReactiveAppInstanceScanner method getDomain.

private Mono<String> getDomain(String domainIdString) {
    String key = domainIdString;
    synchronized (key.intern()) {
        Mono<String> cached = this.domainMap.get(key);
        if (cached != null) {
            this.internalMetrics.countHit("appinstancescanner.domain");
            return cached;
        }
        this.internalMetrics.countMiss("appinstancescanner.domain");
        ReactiveTimer reactiveTimer = new ReactiveTimer(this.internalMetrics, "domain");
        cached = Mono.just(domainIdString).zipWith(Mono.just(reactiveTimer)).map(tuple -> {
            tuple.getT2().start();
            return tuple.getT1();
        }).flatMap(domainId -> {
            return this.cfAccessor.retrieveSharedDomain(domainId);
        }).map(response -> {
            SharedDomainEntity sharedDomain = response.getEntity();
            return sharedDomain.getName();
        }).zipWith(Mono.just(reactiveTimer)).map(tuple -> {
            tuple.getT2().stop();
            return tuple.getT1();
        }).cache();
        this.domainMap.put(key, cached);
        return cached;
    }
}
Also used : RouteEntity(org.cloudfoundry.client.v2.routes.RouteEntity) Target(org.cloudfoundry.promregator.config.Target) Autowired(org.springframework.beans.factory.annotation.Autowired) SharedDomainEntity(org.cloudfoundry.client.v2.shareddomains.SharedDomainEntity) ListProcessesResponse(org.cloudfoundry.client.v3.processes.ListProcessesResponse) Mono(reactor.core.publisher.Mono) CFAccessor(org.cloudfoundry.promregator.cfaccessor.CFAccessor) SpaceResource(org.cloudfoundry.client.v2.spaces.SpaceResource) TimeUnit(java.util.concurrent.TimeUnit) Value(org.springframework.beans.factory.annotation.Value) PassiveExpiringMap(org.apache.commons.collections4.map.PassiveExpiringMap) Logger(org.apache.log4j.Logger) Flux(reactor.core.publisher.Flux) List(java.util.List) Component(org.springframework.stereotype.Component) ApplicationResource(org.cloudfoundry.client.v2.applications.ApplicationResource) Timer(io.prometheus.client.Histogram.Timer) ProcessResource(org.cloudfoundry.client.v3.processes.ProcessResource) PostConstruct(javax.annotation.PostConstruct) OrganizationResource(org.cloudfoundry.client.v2.organizations.OrganizationResource) LinkedList(java.util.LinkedList) InternalMetrics(org.cloudfoundry.promregator.internalmetrics.InternalMetrics) RouteMappingResource(org.cloudfoundry.client.v2.routemappings.RouteMappingResource) SharedDomainEntity(org.cloudfoundry.client.v2.shareddomains.SharedDomainEntity)

Example 2 with SharedDomainEntity

use of org.cloudfoundry.client.v2.shareddomains.SharedDomainEntity in project promregator by promregator.

the class CFAccessorMock method retrieveSharedDomain.

@Override
public Mono<GetSharedDomainResponse> retrieveSharedDomain(String domainId) {
    if (domainId.equals(UNITTEST_SHARED_DOMAIN_UUID)) {
        SharedDomainEntity entity = SharedDomainEntity.builder().name(UNITTEST_SHARED_DOMAIN).build();
        GetSharedDomainResponse resp = GetSharedDomainResponse.builder().entity(entity).build();
        return Mono.just(resp);
    }
    Assert.fail("Invalid shared domain request");
    return null;
}
Also used : SharedDomainEntity(org.cloudfoundry.client.v2.shareddomains.SharedDomainEntity) GetSharedDomainResponse(org.cloudfoundry.client.v2.shareddomains.GetSharedDomainResponse)

Aggregations

SharedDomainEntity (org.cloudfoundry.client.v2.shareddomains.SharedDomainEntity)2 Timer (io.prometheus.client.Histogram.Timer)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 TimeUnit (java.util.concurrent.TimeUnit)1 PostConstruct (javax.annotation.PostConstruct)1 PassiveExpiringMap (org.apache.commons.collections4.map.PassiveExpiringMap)1 Logger (org.apache.log4j.Logger)1 ApplicationResource (org.cloudfoundry.client.v2.applications.ApplicationResource)1 OrganizationResource (org.cloudfoundry.client.v2.organizations.OrganizationResource)1 RouteMappingResource (org.cloudfoundry.client.v2.routemappings.RouteMappingResource)1 RouteEntity (org.cloudfoundry.client.v2.routes.RouteEntity)1 GetSharedDomainResponse (org.cloudfoundry.client.v2.shareddomains.GetSharedDomainResponse)1 SpaceResource (org.cloudfoundry.client.v2.spaces.SpaceResource)1 ListProcessesResponse (org.cloudfoundry.client.v3.processes.ListProcessesResponse)1 ProcessResource (org.cloudfoundry.client.v3.processes.ProcessResource)1 CFAccessor (org.cloudfoundry.promregator.cfaccessor.CFAccessor)1 Target (org.cloudfoundry.promregator.config.Target)1 InternalMetrics (org.cloudfoundry.promregator.internalmetrics.InternalMetrics)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1