org.cloudfoundry.client.v2.spaces.ListSpacesResponse Java Examples
The following examples show how to use
org.cloudfoundry.client.v2.spaces.ListSpacesResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CFAccessorSimulator.java From promregator with Apache License 2.0 | 6 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceId(String orgId, String spaceName) { if ("simspace".equals(spaceName) && orgId.equals(ORG_UUID)) { SpaceResource sr = SpaceResource.builder().entity( SpaceEntity.builder().name(spaceName).build() ).metadata( Metadata.builder().createdAt(CREATED_AT_TIMESTAMP).id(SPACE_UUID).build() ).build(); List<SpaceResource> list = new LinkedList<>(); list.add(sr); ListSpacesResponse resp = ListSpacesResponse.builder().addAllResources(list).build(); return Mono.just(resp).delayElement(this.getSleepRandomDuration()); } log.error("Invalid SpaceId request"); return null; }
Example #2
Source File: CFAccessorMassMock.java From promregator with Apache License 2.0 | 6 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceId(String orgId, String spaceName) { if ("unittestspace".equals(spaceName) && orgId.equals(UNITTEST_ORG_UUID)) { SpaceResource sr = SpaceResource.builder().entity( SpaceEntity.builder().name(spaceName).build() ).metadata( Metadata.builder().createdAt(CREATED_AT_TIMESTAMP).id(UNITTEST_SPACE_UUID).build() ).build(); List<SpaceResource> list = new LinkedList<>(); list.add(sr); ListSpacesResponse resp = ListSpacesResponse.builder().addAllResources(list).build(); return Mono.just(resp).delayElement(this.getSleepRandomDuration()); } Assert.fail("Invalid SpaceId request"); return null; }
Example #3
Source File: ReactiveCFAccessorImpl.java From promregator with Apache License 2.0 | 6 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId) { PaginatedRequestGeneratorFunction<ListSpacesRequest> requestGenerator = (orderDirection, resultsPerPage, pageNumber) -> ListSpacesRequest.builder() .organizationId(orgId) .orderDirection(orderDirection) .resultsPerPage(resultsPerPage) .page(pageNumber) .build(); PaginatedResponseGeneratorFunction<SpaceResource, ListSpacesResponse> responseGenerator = (list, numberOfPages) -> ListSpacesResponse.builder() .addAllResources(list) .totalPages(numberOfPages) .totalResults(list.size()) .build(); return this.paginatedRequestFetcher.performGenericPagedRetrieval(RequestType.SPACE_IN_ORG, orgId, requestGenerator, r -> this.cloudFoundryClient.spaces().list(r), this.requestTimeoutSpace, responseGenerator); }
Example #4
Source File: ReactiveAppInstanceScanner.java From promregator with Apache License 2.0 | 6 votes |
private Mono<String> getSpaceId(String orgIdString, String spaceNameString) { Mono<ListSpacesResponse> listSpacesResponse = this.cfAccessor.retrieveSpaceId(orgIdString, spaceNameString); return listSpacesResponse.flatMap(response -> { List<SpaceResource> resources = response.getResources(); if (resources == null) { return Mono.just(INVALID_SPACE_ID); } if (resources.isEmpty()) { log.warn(String.format("Received empty result on requesting space %s", spaceNameString)); return Mono.just(INVALID_SPACE_ID); } SpaceResource spaceResource = resources.get(0); return Mono.just(spaceResource.getMetadata().getId()); }).onErrorResume(e -> { log.error(String.format("retrieving space id for org id '%s' and space name '%s' resulted in an exception", orgIdString, spaceNameString), e); return Mono.just(INVALID_SPACE_ID); }).cache(); }
Example #5
Source File: CFAccessorCacheClassic.java From promregator with Apache License 2.0 | 5 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceId(String orgId, String spaceName) { final CacheKeySpace key = new CacheKeySpace(orgId, spaceName); // TODO Unclear if problem: locking in the cache works on object instance level! We just created a new instance there. Separate lock objects? return this.spaceCache.get(key); }
Example #6
Source File: CloudFoundryTaskPlatformFactoryTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private Mono<ListSpacesResponse> listSpacesResponse() { ListSpacesResponse response = ListSpacesResponse.builder() .addAllResources(Collections.<SpaceResource>singletonList( SpaceResource.builder() .metadata(Metadata.builder().id("123").build()).build()) ).build(); return Mono.just(response); }
Example #7
Source File: CloudFoundrySchedulerTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private Mono<ListSpacesResponse> listSpacesResponse() { ListSpacesResponse response = ListSpacesResponse.builder() .addAllResources(Collections.<SpaceResource>singletonList( SpaceResource.builder() .metadata(Metadata.builder().id("123").build()).build()) ).build(); return Mono.just(response); }
Example #8
Source File: MultiplePlatformTypeTests.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private Mono<ListSpacesResponse> listSpacesResponse() { ListSpacesResponse response = ListSpacesResponse.builder() .addAllResources(Collections.<SpaceResource>singletonList( SpaceResource.builder() .metadata(Metadata.builder().id("123").build()).build()) ).build(); return Mono.just(response); }
Example #9
Source File: CloudFoundryTaskLauncherTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
private Mono<ListSpacesResponse> listSpacesResponse() { ListSpacesResponse response = ListSpacesResponse.builder() .addAllResources(Collections.<SpaceResource>singletonList( SpaceResource.builder() .metadata(Metadata.builder().id("123").build()).build()) ).build(); return Mono.just(response); }
Example #10
Source File: CloudFoundryTaskLauncherCachingTests.java From spring-cloud-deployer-cloudfoundry with Apache License 2.0 | 5 votes |
private Mono<ListSpacesResponse> listSpacesResponse(AtomicBoolean error) { // defer so that we can conditionally throw within mono return Mono.defer(() -> { if (error.get()) { throw new RuntimeException(); } ListSpacesResponse response = ListSpacesResponse.builder() .addAllResources(Collections.<SpaceResource>singletonList( SpaceResource.builder() .metadata(Metadata.builder().id("123").build()).build()) ) .build(); return Mono.just(response); }); }
Example #11
Source File: CFAccessorCacheClassicTimeoutTest.java From promregator with Apache License 2.0 | 5 votes |
@Test public void testRetrieveSpaceId() { Mono<ListSpacesResponse> response1 = subject.retrieveSpaceId("dummy1", "dummy2"); response1.subscribe(); Mockito.verify(this.parentMock, Mockito.times(1)).retrieveSpaceId("dummy1", "dummy2"); Mono<ListSpacesResponse> response2 = subject.retrieveSpaceId("dummy1", "dummy2"); response2.subscribe(); assertThat(response1).isNotEqualTo(response2); Mockito.verify(this.parentMock, Mockito.times(2)).retrieveOrgId("dummy"); }
Example #12
Source File: CFAccessorCacheClassicTest.java From promregator with Apache License 2.0 | 5 votes |
@Test public void testRetrieveSpaceId() { Mono<ListSpacesResponse> response1 = subject.retrieveSpaceId("dummy1", "dummy2"); Mockito.verify(this.parentMock, Mockito.times(1)).retrieveSpaceId("dummy1", "dummy2"); Mono<ListSpacesResponse> response2 = subject.retrieveSpaceId("dummy1", "dummy2"); assertThat(response1).isEqualTo(response2); Mockito.verify(this.parentMock, Mockito.times(1)).retrieveOrgId("dummy"); }
Example #13
Source File: CFAccessorCacheCaffeineTimeoutTest.java From promregator with Apache License 2.0 | 5 votes |
@Test public void testRetrieveSpaceId() throws InterruptedException { Mono<ListSpacesResponse> response1 = subject.retrieveSpaceId("dummy1", "dummy2"); response1.subscribe(); Mockito.verify(this.parentMock, Mockito.times(1)).retrieveSpaceId("dummy1", "dummy2"); // required to permit asynchronous updates of caches => test stability Thread.sleep(10); Mono<ListSpacesResponse> response2 = subject.retrieveSpaceId("dummy1", "dummy2"); response2.subscribe(); assertThat(response1).isNotEqualTo(response2); Mockito.verify(this.parentMock, Mockito.times(2)).retrieveSpaceId("dummy1", "dummy2"); }
Example #14
Source File: CFAccessorCacheCaffeineTest.java From promregator with Apache License 2.0 | 5 votes |
@Test public void testRetrieveSpaceId() { Mono<ListSpacesResponse> response1 = subject.retrieveSpaceId("dummy1", "dummy2"); Mockito.verify(this.parentMock, Mockito.times(1)).retrieveSpaceId("dummy1", "dummy2"); Mono<ListSpacesResponse> response2 = subject.retrieveSpaceId("dummy1", "dummy2"); assertThat(response1.block()).isEqualTo(response2.block()); Mockito.verify(this.parentMock, Mockito.times(1)).retrieveOrgId("dummy"); }
Example #15
Source File: CFAccessorSimulatorTest.java From promregator with Apache License 2.0 | 5 votes |
@Test public void testRetrieveSpaceId() { CFAccessorSimulator subject = new CFAccessorSimulator(2); Mono<ListSpacesResponse> mono = subject.retrieveSpaceId(CFAccessorSimulator.ORG_UUID, "simspace"); ListSpacesResponse result = mono.block(); Assert.assertEquals(CFAccessorSimulator.SPACE_UUID, result.getResources().get(0).getMetadata().getId()); }
Example #16
Source File: ReactiveCFAccessorImpl.java From promregator with Apache License 2.0 | 5 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceId(String orgId, String spaceName) { // Note: even though we use the List request here, the number of values returned is either zero or one // ==> No need for a paged request. String key = String.format("%s|%s", orgId, spaceName); ListSpacesRequest spacesRequest = ListSpacesRequest.builder().organizationId(orgId).name(spaceName).build(); return this.paginatedRequestFetcher.performGenericRetrieval(RequestType.SPACE, key, spacesRequest, sr -> this.cloudFoundryClient.spaces().list(sr), this.requestTimeoutSpace); }
Example #17
Source File: CFAccessorCacheCaffeine.java From promregator with Apache License 2.0 | 5 votes |
@Override public @NonNull CompletableFuture<ListSpacesResponse> asyncLoad(@NonNull String key, @NonNull Executor executor) { Mono<ListSpacesResponse> mono = parent.retrieveSpaceIdsInOrg(key) .subscribeOn(Schedulers.fromExecutor(executor)) .cache(); return mono.toFuture(); }
Example #18
Source File: CFAccessorCacheCaffeine.java From promregator with Apache License 2.0 | 5 votes |
@Override public @NonNull CompletableFuture<ListSpacesResponse> asyncLoad(@NonNull CacheKeySpace key, @NonNull Executor executor) { Mono<ListSpacesResponse> mono = parent.retrieveSpaceId(key.getOrgId(), key.getSpaceName()) .subscribeOn(Schedulers.fromExecutor(executor)) .cache(); return mono.toFuture(); }
Example #19
Source File: CFAccessorCacheClassic.java From promregator with Apache License 2.0 | 5 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId) { /* * special case: we don't cache the result here in an own cache, * as we always want to have "fresh data". */ return this.parent.retrieveSpaceIdsInOrg(orgId); }
Example #20
Source File: CFAccessorCacheCaffeineSpringApplication.java From promregator with Apache License 2.0 | 4 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceId(String orgId, String spaceName) { return Mono.just(ListSpacesResponse.builder().build()); }
Example #21
Source File: CFAccessorCacheCaffeineSpringApplication.java From promregator with Apache License 2.0 | 4 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId) { return Mono.just(ListSpacesResponse.builder().build()); }
Example #22
Source File: ReactiveTargetResolver.java From promregator with Apache License 2.0 | 4 votes |
private Flux<IntermediateTarget> resolveSpace(IntermediateTarget it) { /* NB: Now we have to consider three cases: * Case 1: both spaceName and spaceRegex is empty => select all spaces (within the org) * Case 2: spaceName is null, but spaceRegex is filled => filter all spaces with the regex * Case 3: spaceName is filled, but spaceRegex is null => select a single space * In cases 1 and 2, we need the list of all spaces in the org. */ if (it.getConfigTarget().getSpaceRegex() == null && it.getConfigTarget().getSpaceName() != null) { // Case 3: we have the spaceName, but we also need its id Mono<IntermediateTarget> itMono = this.cfAccessor.retrieveSpaceId(it.getResolvedOrgId(), it.getConfigTarget().getSpaceName()) .map(ListSpacesResponse::getResources) .flatMap(resList -> { if (resList == null || resList.isEmpty()) { return Mono.empty(); } return Mono.just(resList.get(0)); }) .map(res -> { it.setResolvedSpaceName(res.getEntity().getName()); it.setResolvedSpaceId(res.getMetadata().getId()); return it; }).doOnError(e -> log.warn(String.format("Error on retrieving space id for org '%s' and space '%s'", it.getResolvedOrgName(), it.getConfigTarget().getSpaceName()), e)) .onErrorResume(__ -> Mono.empty()); return itMono.flux(); } // Case 1 & 2: Get all spaces in the current org Mono<ListSpacesResponse> responseMono = this.cfAccessor.retrieveSpaceIdsInOrg(it.getResolvedOrgId()); Flux<SpaceResource> spaceResFlux = responseMono.map(ListSpacesResponse::getResources) .flatMapMany(Flux::fromIterable); if (it.getConfigTarget().getSpaceRegex() != null) { // Case 2 final Pattern filterPattern = Pattern.compile(it.getConfigTarget().getSpaceRegex(), Pattern.CASE_INSENSITIVE); spaceResFlux = spaceResFlux.filter(spaceRes -> { Matcher m = filterPattern.matcher(spaceRes.getEntity().getName()); return m.matches(); }); } return spaceResFlux.map(spaceRes -> { IntermediateTarget itnew = new IntermediateTarget(it); itnew.setResolvedSpaceId(spaceRes.getMetadata().getId()); itnew.setResolvedSpaceName(spaceRes.getEntity().getName()); return itnew; }); }
Example #23
Source File: CFAccessorMassMock.java From promregator with Apache License 2.0 | 4 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId) { return this.retrieveSpaceId(UNITTEST_ORG_UUID, "unittestspace"); }
Example #24
Source File: CFAccessorSimulator.java From promregator with Apache License 2.0 | 4 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId) { return this.retrieveSpaceId(ORG_UUID, "simspace"); }
Example #25
Source File: CFAccessorCacheCaffeine.java From promregator with Apache License 2.0 | 4 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId) { return Mono.fromFuture(this.spaceIdInOrgCache.get(orgId)); }
Example #26
Source File: CFAccessorMock.java From promregator with Apache License 2.0 | 4 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId) { return this.retrieveSpaceId(UNITTEST_ORG_UUID, "unittestspace"); }
Example #27
Source File: CFAccessorCacheClassic.java From promregator with Apache License 2.0 | 4 votes |
private Mono<ListSpacesResponse> spaceCacheLoader(CacheKeySpace cacheKey) { Mono<ListSpacesResponse> mono = this.parent.retrieveSpaceId(cacheKey.getOrgId(), cacheKey.getSpaceName()).cache(); /* * Note that the mono does not have any subscriber, yet! * The cache which we are using is working "on-stock", i.e. we need to ensure * that the underlying calls to the CF API really is triggered. * Fortunately, we can do this very easily: */ mono.subscribe(); /* * Handling for issue #96: If a timeout of the request to the CF Cloud Controller occurs, * we must make sure that the erroneous Mono is not kept in the cache. Instead we have to displace the item, * which triggers a refresh of the cache. * * Note that subscribe() must be called *before* adding this error handling below. * Otherwise we will run into the situation that the error handling routine is called by this * subscribe() already - but the Mono has not been written into the cache yet! * If we do it in this order, the doOnError method will only be called once the first "real subscriber" * of the Mono will start requesting. */ mono = mono.doOnError(e -> { if (e instanceof TimeoutException) { log.warn(String.format("Timed-out entry using key %s detected, which would get stuck in our space cache; " + "displacing it now to prevent further harm", cacheKey), e); /* * Note that it *might* happen that a different Mono gets displaced than the one we are in here now. * Yet, we can't make use of the * * remove(key, value) * * method, as providing value would lead to a hen-egg problem (we were required to provide the reference * of the Mono instance, which we are just creating). * Instead, we just blindly remove the entry from the cache. This may lead to four cases to consider: * * 1. We hit the correct (erroneous) entry: then this is exactly what we want to do. * 2. We hit another erroneous entry: then we have no harm done, because we fixed yet another case. * 3. We hit a healthy entry: Bad luck; on next iteration, we will get a cache miss, which automatically * fixes the issue (as long this does not happen too often, ...) * 4. The entry has already been deleted by someone else: the remove(key) operation will * simply be a NOOP. => no harm done either. */ this.spaceCache.remove(cacheKey); // Notify metrics of this case if (this.internalMetrics != null) { this.internalMetrics.countAutoRefreshingCacheMapErroneousEntriesDisplaced(this.spaceCache.getName()); } } }); /* * Keep in mind that doOnError is a side-effect: The logic above only removes it from the cache. * The erroneous instance still is used downstream and will trigger subsequent error handling (including * logging) there. * Note that this also holds true during the timeframe of the timeout: This instance of the Mono will * be written to the cache, thus all consumers of the cache will be handed out the cached, not-yet-resolved * object instance. This implicitly makes sure that there can only be one valid pending request is out there. */ return mono; }
Example #28
Source File: CFAccessorCacheCaffeine.java From promregator with Apache License 2.0 | 3 votes |
@Override public Mono<ListSpacesResponse> retrieveSpaceId(String orgId, String spaceName) { final CacheKeySpace key = new CacheKeySpace(orgId, spaceName); return Mono.fromFuture(this.spaceCache.get(key)); }
Example #29
Source File: CFAccessor.java From promregator with Apache License 2.0 | votes |
Mono<ListSpacesResponse> retrieveSpaceIdsInOrg(String orgId);
Example #30
Source File: CFAccessor.java From promregator with Apache License 2.0 | votes |
Mono<ListSpacesResponse> retrieveSpaceId(String orgId, String spaceName);