use of io.fabric8.annotations.Path 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.annotations.Path in project fabric8 by jboss-fuse.
the class ContainerCreateCloud method doExecute.
@Override
protected Object doExecute() throws Exception {
// validate input before creating containers
preCreateContainer(name);
FabricValidations.validateProfileNames(profiles);
if (isEnsembleServer && newUserPassword == null) {
newUserPassword = zookeeperPassword != null ? zookeeperPassword : fabricService.getZookeeperPassword();
}
CreateJCloudsContainerOptions.Builder builder = CreateJCloudsContainerOptions.builder().name(name).bindAddress(bindAddress).resolver(resolver).manualIp(manualIp).ensembleServer(isEnsembleServer).credential(credential).group(group).hardwareId(hardwareId).identity(identity).osFamily(osFamily).osVersion(osVersion).imageId(imageId).instanceType(instanceType).locationId(locationId).number(number).nodeOptions(CloudUtils.parseProviderOptions(options)).owner(owner).adminAccess(!disableAdminAccess).publicKeyFile(publicKeyFile).contextName(contextName).providerName(providerName).apiName(apiName).user(user).password(password).proxyUri(proxyUri != null ? proxyUri : fabricService.getMavenRepoURI()).zookeeperUrl(fabricService.getZookeeperUrl()).zookeeperPassword(isEnsembleServer && zookeeperPassword != null ? zookeeperPassword : fabricService.getZookeeperPassword()).jvmOpts(jvmOpts).environmentalVariable(environmentalVariables).version(version).withUser(newUser, newUserPassword, newUserRole).profiles(getProfileNames()).dataStoreProperties(getDataStoreProperties()).uploadDistribution(!distributionUploadDisable);
if (path != null && !path.isEmpty()) {
builder.path(path);
}
CreateContainerMetadata[] metadatas = fabricService.createContainers(builder.build(), new PrintStreamCreationStateListener(System.out));
if (isEnsembleServer && metadatas != null && metadatas.length > 0 && metadatas[0].isSuccess()) {
ShellUtils.storeZookeeperPassword(session, metadatas[0].getCreateOptions().getZookeeperPassword());
}
// display containers
displayContainers(metadatas);
return null;
}
use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.
the class SubsystemResolver method prepare.
public void prepare(Collection<Feature> allFeatures, Map<String, Set<String>> requirements, Map<String, Set<BundleRevision>> system) throws Exception {
// Build subsystems on the fly
for (Map.Entry<String, Set<String>> entry : requirements.entrySet()) {
String[] parts = entry.getKey().split("/");
if (root == null) {
root = new Subsystem(parts[0]);
} else if (!root.getName().equals(parts[0])) {
throw new IllegalArgumentException("Can not use multiple roots: " + root.getName() + ", " + parts[0]);
}
Subsystem ss = root;
for (int i = 1; i < parts.length; i++) {
ss = getOrCreateChild(ss, parts[i]);
}
for (String requirement : entry.getValue()) {
ss.require(requirement);
}
}
if (root == null) {
return;
}
// Pre-resolve
root.build(allFeatures);
// Add system resources
BundleRevision sysBundleRev = null;
boolean hasEeCap = false;
for (Map.Entry<String, Set<BundleRevision>> entry : system.entrySet()) {
Subsystem ss = null;
String[] parts = entry.getKey().split("/");
String path = parts[0];
if (path.equals(root.getName())) {
ss = root;
}
for (int i = 1; ss != null && i < parts.length; i++) {
path += "/" + parts[i];
ss = ss.getChild(path);
}
if (ss != null) {
ResourceImpl dummy = new ResourceImpl("dummy", "dummy", Version.emptyVersion);
for (BundleRevision res : entry.getValue()) {
// We need to explicitely provide service capabilities for bundles
// We use both actual services and services declared from the headers
// TODO: use actual services
Map<String, String> headers = new DictionaryAsMap<>(res.getBundle().getHeaders());
Resource tmp = ResourceBuilder.build(res.getBundle().getLocation(), headers);
for (Capability cap : tmp.getCapabilities(ServiceNamespace.SERVICE_NAMESPACE)) {
dummy.addCapability(new CapabilityImpl(dummy, cap.getNamespace(), cap.getDirectives(), cap.getAttributes()));
}
ss.addSystemResource(res);
for (Capability cap : res.getCapabilities(null)) {
hasEeCap |= cap.getNamespace().equals(EXECUTION_ENVIRONMENT_NAMESPACE);
}
if (res.getBundle().getBundleId() == 0) {
sysBundleRev = res;
}
}
ss.addSystemResource(dummy);
}
}
// Under Equinox, the osgi.ee capabilities are not provided by the system bundle
if (!hasEeCap && sysBundleRev != null) {
String provideCaps = sysBundleRev.getBundle().getHeaders().get(PROVIDE_CAPABILITY);
environmentResource = new ResourceImpl("environment", "karaf.environment", Version.emptyVersion);
environmentResource.addCapabilities(ResourceBuilder.parseCapability(environmentResource, provideCaps));
root.addSystemResource(environmentResource);
}
}
use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.
the class ContainerResource method stop.
/**
* Stops the container
*/
@DELETE
@Path("start")
public void stop() {
FabricService fabricService = getFabricService();
Objects.notNull(fabricService, "fabricService");
fabricService.stopContainer(container);
}
use of io.fabric8.annotations.Path in project fabric8 by jboss-fuse.
the class FabricResource method version.
/**
* Accesses a version resource
*/
@Path("version/{versionId}")
public VersionResource version(@PathParam("versionId") String versionId) {
FabricService fabricService = getFabricService();
if (fabricService != null && Strings.isNotBlank(versionId)) {
ProfileService profileService = fabricService.adapt(ProfileService.class);
Version version = profileService.getRequiredVersion(versionId);
if (version != null) {
return new VersionResource(this, version);
} else {
LOG.warn("No version found for: {}", version);
}
}
return null;
}
Aggregations