Java Code Examples for org.apache.brooklyn.util.collections.MutableList#addAll()
The following examples show how to use
org.apache.brooklyn.util.collections.MutableList#addAll() .
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: KnifeTaskFactory.java From brooklyn-library with Apache License 2.0 | 5 votes |
/** creates the command for running knife. * in some cases knife may be added multiple times, * and in that case the parameter here tells which time it is being added, * on a single run. */ protected String buildKnifeCommand(int knifeCommandIndex) { MutableList<String> words = new MutableList<String>(); words.add(knifeExecutable()); words.addAll(initialKnifeParameters()); words.addAll(knifeParameters()); String x = knifeConfigFileOption(); if (Strings.isNonBlank(x)) words.add(knifeConfigFileOption()); return Strings.join(words, " "); }
Example 2
Source File: KnifeConvergeTaskFactory.java From brooklyn-library with Apache License 2.0 | 5 votes |
/** construct the knife command, based on the settings on other methods * (called when instantiating the script, after all parameters sent) */ @Override protected List<String> initialKnifeParameters() { // runs inside the task so can detect entity/machine at runtime MutableList<String> result = new MutableList<String>(); SshMachineLocation machine = EffectorTasks.findSshMachine(); result.add("bootstrap"); result.addAll(extraBootstrapParameters); HostAndPort hostAndPort = machine.getSshHostAndPort(); result.add(wrapBash(hostAndPort.getHostText())); Integer whichPort = knifeWhichPort(hostAndPort); if (whichPort!=null) result.add("-p "+whichPort); result.add("-x "+wrapBash(checkNotNull(machine.getUser(), "user"))); File keyfile = ChefServerTasks.extractKeyFile(machine); if (keyfile!=null) result.add("-i "+keyfile.getPath()); else result.add("-P "+checkNotNull(machine.findPassword(), "No password or private key data for "+machine)); result.add("--no-host-key-verify"); if (sudo != Boolean.FALSE) result.add("--sudo"); if (!Strings.isNullOrEmpty(nodeName)) { result.add("--node-name"); result.add(nodeName); } result.add("-r "+wrapBash(runList.apply(entity()))); if (!knifeAttributes.isEmpty()) result.add("-j "+wrapBash(new GsonBuilder().create() .toJson(knifeAttributes))); return result; }
Example 3
Source File: ListConfigKey.java From brooklyn-server with Apache License 2.0 | 5 votes |
@Override protected List<Object> merge(boolean unmodifiable, Iterable<?>... sets) { MutableList<Object> result = MutableList.of(); for (Iterable<?> set: sets) result.addAll(set); if (unmodifiable) return result.asUnmodifiable(); return result; }
Example 4
Source File: TopologyTemplateFacade.java From SeaCloudsPlatform with Apache License 2.0 | 5 votes |
private List<PaasNodeTemplateFacade> generatedPaasFacades(Map<HostNodeTemplate, List<NodeTemplate>> hostAndChildren) { MutableList<PaasNodeTemplateFacade> paasNodeTemplateFacades = MutableList.of(); for (Map.Entry<HostNodeTemplate, List<NodeTemplate>> entry : hostAndChildren.entrySet()) { paasNodeTemplateFacades.addAll( generatePaasFacadesFromAPlatform( (PlatformNodeTemplate) entry.getKey(), entry.getValue())); } return paasNodeTemplateFacades; }
Example 5
Source File: ApplicationResourceTest.java From brooklyn-server with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "rawtypes", "unchecked" }) @Test(dependsOnMethods = "testDeployApplication") public void testApplicationDetailsAndEntity() { Collection apps = client().path("/applications/details").get(Collection.class); log.info("Application details are: " + apps); Map app = ((Collection<Map>)apps).stream().filter(m -> "simple-app".equals(m.get("name"))).findFirst().orElse(null); Assert.assertNotNull(app, "did not find 'simple-app'"); Asserts.assertThat((String) app.get("applicationId"), StringPredicates.isNonBlank(), "expected value for applicationId"); Asserts.assertThat((String) app.get("serviceState"), StringPredicates.isNonBlank(), "expected value for serviceState"); Asserts.assertThat(app.get("serviceUp"), Predicates.not(Predicates.isNull()), "expected non-null for serviceUp"); Collection children = (Collection) app.get("children"); Asserts.assertSize(children, 2); Map entitySummary = (Map) Iterables.find(children, withValueForKey("name", "simple-ent"), null); Map groupSummary = (Map) Iterables.find(children, withValueForKey("name", "simple-group"), null); Assert.assertNotNull(entitySummary); Assert.assertNotNull(groupSummary); Asserts.assertThat( ((Collection<Map>)apps).stream().filter(m -> ImmutableSet.of("simple-ent", "simple-group").contains(m.get("name"))).collect(Collectors.toList()), CollectionFunctionals.empty(), "Some entities should not be listed at high level"); String itemIds = entitySummary.get("id") + "," + groupSummary.get("id"); Collection entities1 = client().path("/applications/details") .query("items", itemIds) .query("includeAllApps", false) .query("sensors", "[ service.state.expected, \"host.address\" ]") .query("config", "*") .get(Collection.class); log.info("Applications+Entities details are: " + entities1); Predicate<Collection> check = (entities) -> { Asserts.assertSize(entities, 3); Map entityDetails = (Map) Iterables.find(entities, withValueForKey("name", "simple-ent"), null); Map groupDetails = (Map) Iterables.find(entities, withValueForKey("name", "simple-group"), null); Assert.assertNotNull(entityDetails); Assert.assertNotNull(groupDetails); Assert.assertEquals(entityDetails.get("parentId"), app.get("id")); Assert.assertNull(entityDetails.get("children")); Assert.assertEquals(groupDetails.get("parentId"), app.get("id")); Assert.assertNull(groupDetails.get("children")); Collection entityGroupIds = (Collection) entityDetails.get("groupIds"); Assert.assertNotNull(entityGroupIds); Assert.assertEquals(entityGroupIds.size(), 1); Assert.assertEquals(entityGroupIds.iterator().next(), groupDetails.get("id")); Collection groupMembers = (Collection) groupDetails.get("members"); Assert.assertNotNull(groupMembers); log.info("MEMBERS: " + groupMembers); Assert.assertEquals(groupMembers.size(), 1); Map entityMemberDetails = (Map) Iterables.find(groupMembers, withValueForKey("name", "simple-ent"), null); Assert.assertNotNull(entityMemberDetails); Assert.assertEquals(entityMemberDetails.get("id"), entityDetails.get("id")); Map<String,Object> simpleEntSensors = Preconditions.checkNotNull(Map.class.cast(entityDetails.get("sensors")), "sensors"); org.apache.brooklyn.api.entity.Entity simpleEnt = Preconditions.checkNotNull(getManagementContext().<org.apache.brooklyn.api.entity.Entity>lookup( EntityPredicates.displayNameEqualTo("simple-ent"))); Assert.assertEquals(simpleEntSensors.get("host.address"), simpleEnt.sensors().get(Attributes.ADDRESS)); Transition expected = simpleEnt.sensors().get(Attributes.SERVICE_STATE_EXPECTED); Assert.assertEquals(simpleEntSensors.get("service.state.expected"), MutableMap.of("state", expected.getState().name(), "timestampUtc", expected.getTimestamp().getTime())); // and config also present Assert.assertEquals( ((Map)groupDetails.get("config")).get("namematchergroup.regex"), "simple-ent" ); Assert.assertEquals( ((Map)entityDetails.get("config")).get("namematchergroup.regex"), null ); return true; }; check.apply(entities1); Collection entities2 = client().path("/applications/details") .query("items", app.get("id")) .query("includeAllApps", false) .query("sensors", "[ service.state.expected, \"host.address\" ]") .query("config", "n*") .query("depth", 2) .get(Collection.class); log.info("Applications+Entities details 2 are: " + entities2); // in order to reuse the check, copy the children from the single app to the list MutableList entities2b = MutableList.copyOf(entities2); entities2b.addAll((Iterable) ((Map)Iterables.getOnlyElement(entities2)).get("children")); check.apply(entities2b); }