ElasticPlacementZoneConfigurationState pool = pools.get(entry.getKey()); if (pool.epzState == null) { pool.epzState = new ElasticPlacementZoneState();
@Test public void testEpzChanges() throws Throwable { enumerateAllEpzs(); this.epz1.epzState.tagLinksToMatch.add("tag2"); this.epz2.epzState.tagLinksToMatch.remove("tag2"); this.epz3.epzState = new ElasticPlacementZoneState(); this.epz3.epzState.resourcePoolLink = this.epz3.documentSelfLink; this.epz3.epzState.tagLinksToMatch = new HashSet<>(); this.epz3.epzState.tagLinksToMatch.addAll(Arrays.asList("tag1")); doPut(this.epz1.epzState); doPut(this.epz2.epzState); doPost(this.epz3.epzState, ElasticPlacementZoneService.FACTORY_LINK); enumerateAllEpzs(); validateCompute(this.cs1, this.epz3); validateCompute(this.cs2, this.epz3); validateCompute(this.cs3); validateCompute(this.cs4, this.epz3, this.epz1); validateCompute(this.cs5); validateCompute(this.cs6, this.epz3); }
private void updateEpzWithPlacementPolicy() throws Throwable { // Create ElasticPlacementZoneState which follows BINPACK deployment policy. ElasticPlacementZoneState epzState = new ElasticPlacementZoneState(); epzState.placementPolicy = ElasticPlacementZoneService.PlacementPolicy.BINPACK; epzState.resourcePoolLink = resourcePool.documentSelfLink; ElasticPlacementZoneConfigurationState epz = new ElasticPlacementZoneConfigurationState(); epz.documentSelfLink = resourcePool.documentSelfLink; epz.resourcePoolState = resourcePool; epz.epzState = epzState; epz = doOperation(epz, UriUtils.buildUri(host, ElasticPlacementZoneConfigurationService.SELF_LINK), ElasticPlacementZoneConfigurationState.class, false, Action.PATCH); assertEquals(epz.epzState.placementPolicy, ElasticPlacementZoneService.PlacementPolicy.BINPACK); }
private void updateEpzWithPlacementPolicy() throws Throwable { // Create ElasticPlacementZoneState which follows SPREAD deployment policy. ElasticPlacementZoneState epzState = new ElasticPlacementZoneState(); epzState.placementPolicy = ElasticPlacementZoneService.PlacementPolicy.SPREAD; epzState.resourcePoolLink = resourcePool.documentSelfLink; ElasticPlacementZoneConfigurationState epz = new ElasticPlacementZoneConfigurationState(); epz.documentSelfLink = resourcePool.documentSelfLink; epz.resourcePoolState = resourcePool; epz.epzState = epzState; epz = doOperation(epz, UriUtils.buildUri(host, ElasticPlacementZoneConfigurationService.SELF_LINK), ElasticPlacementZoneConfigurationState.class, false, Action.PATCH); assertEquals(epz.epzState.placementPolicy, ElasticPlacementZoneService.PlacementPolicy.SPREAD); }
@Test public void testPatchNoChange() throws Throwable { // create a non-elastic RP ResourcePoolState rp = createRp(); assertEquals(EnumSet.noneOf(ResourcePoolProperty.class), rp.properties); assertTrue(isNonElasticQuery(rp.query)); // create EPZ for the RP String epzLink = createEpz(rp.documentSelfLink, "tag1", "tag2").documentSelfLink; ElasticPlacementZoneState patchState = new ElasticPlacementZoneState(); patchState.tagLinksToMatch = tagSet("tag1"); Operation patchOp = Operation.createPatch(host, epzLink).setBody(patchState).forceRemote(); Operation returnedOp = ((CompletableFuture<Operation>) host.sendWithDeferredResult(patchOp) .toCompletionStage()).get(60, TimeUnit.SECONDS); assertEquals(Operation.STATUS_CODE_NOT_MODIFIED, returnedOp.getStatusCode()); }
private ElasticPlacementZoneState buildEpzState(String rpLink, String... tagLinks) { ElasticPlacementZoneState state = new ElasticPlacementZoneState(); state.resourcePoolLink = rpLink; state.tagLinksToMatch = tagSet(tagLinks); return state; }
private ElasticPlacementZoneState createEpz(String rpLink, String... tagLinks) throws Throwable { ElasticPlacementZoneState initialState = new ElasticPlacementZoneState(); initialState.resourcePoolLink = rpLink; initialState.tagLinksToMatch = tagSet(tagLinks); return doPost(initialState, ElasticPlacementZoneService.FACTORY_LINK); }
private ElasticPlacementZoneConfigurationState createEpz(String ...tags) throws Throwable { ElasticPlacementZoneConfigurationState epz = new ElasticPlacementZoneConfigurationState(); epz.resourcePoolState = new ResourcePoolState(); epz.resourcePoolState.name = UUID.randomUUID().toString(); if (tags.length > 0) { epz.epzState = new ElasticPlacementZoneState(); epz.epzState.tagLinksToMatch = tagSet(tags); } return doOperation(epz, UriUtils.buildUri(host, ElasticPlacementZoneConfigurationService.SELF_LINK), ElasticPlacementZoneConfigurationState.class, false, Action.POST); }
private ElasticPlacementZoneState patchEpz(String epzLink, String... tagLinksToAdd) throws Throwable { ElasticPlacementZoneState patchState = new ElasticPlacementZoneState(); patchState.tagLinksToMatch = tagSet(tagLinksToAdd); return doPatch(patchState, epzLink); }
private ElasticPlacementZoneConfigurationState createState(boolean withEpz) { ElasticPlacementZoneConfigurationState state = new ElasticPlacementZoneConfigurationState(); state.resourcePoolState = new ResourcePoolState(); if (withEpz) { state.epzState = new ElasticPlacementZoneState(); } return state; }