use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class ComponentConfigurer method configure.
@Override
public <T> Map<String, ?> configure(final Map<String, ?> configuration, T target, String... ignorePrefix) throws Exception {
assertValid();
Map<String, Object> result = new HashMap<>();
final PropertiesProvider runtimeProperties = new PropertiesProvider() {
@Override
public Object getProperty(String key) {
return bundleContext.getProperty(key);
}
@Override
public Object getRequiredProperty(String key) {
String value = bundleContext.getProperty(key);
IllegalStateAssertion.assertNotNull(value, "Cannot obtain property: " + key);
return value;
}
@Override
public Object getProperty(String key, Object defaultValue) {
String value = bundleContext.getProperty(key);
return value != null ? value : defaultValue;
}
};
final PropertiesProvider configurationProvider = new MapPropertiesProvider((Map<String, Object>) configuration);
final PropertiesProvider[] propertiesProviders = new PropertiesProvider[] { configurationProvider, runtimeProperties };
PropertiesProvider provider = new SubstitutionPropertiesProvider(propertiesProviders);
for (Map.Entry<String, ?> entry : configuration.entrySet()) {
String key = entry.getKey();
Object value = provider.getProperty(key);
result.put(key, value);
}
ConfigInjection.applyConfiguration(result, target, ignorePrefix);
return result;
}
use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class FabricManager method getJvmOpts.
@Override
public /**
* Returns configured jvmOpts only for (local and remote) Karaf containers.
*/
String getJvmOpts(String containerName) {
String result = "";
Container container = fabricService.getContainer(containerName);
CreateContainerBasicMetadata metadata = (CreateContainerBasicMetadata) container.getMetadata();
if (metadata == null) {
return "Inapplicable";
}
switch(metadata.getCreateOptions().getProviderType()) {
case "child":
case "ssh":
CreateContainerOptions createOptions = metadata.getCreateOptions();
result = createOptions.getJvmOpts();
break;
default:
result = "Inapplicable";
}
return result;
}
use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class ContainerLifecycleCommandsTest method testStopGlobMatchingContainers.
@Test
public void testStopGlobMatchingContainers() throws Exception {
// should stop c2 once
// should not touch d1
containers("c*", "c2");
ContainerImpl c1 = newContainer("c1");
ContainerImpl c2 = newContainer("c2");
ContainerImpl c3 = newContainer("c3");
ContainerImpl d1 = newContainer("d1");
expect(this.fabricService.getContainers()).andReturn(new Container[] { c1, c3, c2, d1 }).once();
expect(this.fabricService.adapt(CuratorFramework.class)).andReturn(this.curatorFramework);
expect(this.fabricService.getContainers()).andReturn(new Container[] { c1, c3, c2, d1 }).once();
this.fabricService.stopContainer(c1, false);
expect(this.fabricService.adapt(CuratorFramework.class)).andReturn(this.curatorFramework);
expect(this.fabricService.getContainers()).andReturn(new Container[] { c1, c3, c2, d1 }).once();
this.fabricService.stopContainer(c3, false);
expect(this.fabricService.adapt(CuratorFramework.class)).andReturn(this.curatorFramework);
expect(this.fabricService.getContainers()).andReturn(new Container[] { c1, c3, c2, d1 }).once();
this.fabricService.stopContainer(c2, false);
replay(this.fabricService, this.commandSession);
this.stop.execute(this.commandSession);
verify(this.fabricService);
String result = new String(this.result.toByteArray());
assertThat(result.contains("Container 'c1' stopped successfully."), is(true));
assertThat(result.contains("Container 'c2' stopped successfully."), is(true));
assertThat(result.contains("Container 'c3' stopped successfully."), is(true));
}
use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class JMXCommandActionSupport method asResults.
protected List<JMXResult> asResults(String path, List<String> responses, Class<?> resultClass) throws Exception {
ObjectMapper mapper = getObjectMapper();
List<JMXResult> results = new LinkedList<>();
for (String responsePath : responses) {
byte[] bytes = curator.getData().forPath(path + "/" + responsePath);
String response = PublicStringSerializer.deserialize(bytes);
JMXResult result = mapper.readValue(response, JMXResult.class);
if (result.getResponse() instanceof String) {
try {
result.setResponse(mapper.readValue((String) result.getResponse(), resultClass));
} catch (JsonMappingException | IllegalArgumentException ignore) {
continue;
}
}
results.add(result);
}
mapper.getTypeFactory().clearCache();
return results;
}
use of io.fabric8.insight.metrics.model.Result in project fabric8 by jboss-fuse.
the class BaseRepository method findProviders.
@Override
public Map<Requirement, Collection<Capability>> findProviders(Collection<? extends Requirement> requirements) {
Map<Requirement, Collection<Capability>> result = new HashMap<Requirement, Collection<Capability>>();
for (Requirement requirement : requirements) {
CapabilitySet set = capSets.get(requirement.getNamespace());
if (set != null) {
SimpleFilter sf;
if (requirement instanceof RequirementImpl) {
sf = ((RequirementImpl) requirement).getFilter();
} else {
String filter = requirement.getDirectives().get(Constants.FILTER_DIRECTIVE);
sf = (filter != null) ? SimpleFilter.parse(filter) : new SimpleFilter(null, null, SimpleFilter.MATCH_ALL);
}
result.put(requirement, set.match(sf, true));
} else {
result.put(requirement, Collections.<Capability>emptyList());
}
}
return result;
}
Aggregations