use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class FabricCxfRegistrationHandler method registerApiEndpoint.
protected void registerApiEndpoint(Container container, ObjectName oName, String address, boolean started) {
String actualEndpointUrl = null;
try {
String url;
String id = container.getId();
if (isFullAddress(address)) {
url = toPublicAddress(id, address);
} else {
String cxfBus = getCxfServletPath(oName);
url = "${zk:" + id + "/http}" + cxfBus + address;
}
actualEndpointUrl = ZooKeeperUtils.getSubstitutedData(curator.get(), url);
// lets assume these locations are hard coded
// may be nice to discover from JMX one day
String apiDocPath = "/api-docs";
String wsdlPath = "?wsdl";
String wadlPath = "?_wadl";
Version version = container.getVersion();
String versionId = version != null ? version.getId() : null;
String json = "{\"id\":" + JsonHelper.jsonEncodeString(id) + ", \"container\":" + JsonHelper.jsonEncodeString(id) + ", \"version\":" + JsonHelper.jsonEncodeString(versionId) + ", \"services\":[" + JsonHelper.jsonEncodeString(url) + "]" + ", \"objectName\":" + JsonHelper.jsonEncodeString(oName.toString()) + "";
boolean rest = false;
if (booleanAttribute(oName, "isWADL")) {
rest = true;
json += ", \"wadl\":" + JsonHelper.jsonEncodeString(wadlPath);
}
if (booleanAttribute(oName, "isSwagger")) {
rest = true;
json += ", \"apidocs\":" + JsonHelper.jsonEncodeString(apiDocPath);
}
if (booleanAttribute(oName, "isWSDL")) {
json += ", \"wsdl\":" + JsonHelper.jsonEncodeString(wsdlPath);
}
json += "}";
String path = getPath(container, oName, address, rest);
LOGGER.info("Registered CXF API at " + path + " JSON: " + json);
if (!started && !rest) {
LOGGER.warn("Since the CXF service isn't started, this could really be a REST endpoint rather than WSDL at " + path);
}
registeredZkPaths.add(path);
registeredUrls.put(oName.toString(), address);
ZooKeeperUtils.setData(curator.get(), path, json, CreateMode.EPHEMERAL);
} catch (Exception e) {
LOGGER.error("Failed to register API endpoint for {}.", actualEndpointUrl, e);
}
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class ProfileManagerImpl method deleteProfile.
@Override
public void deleteProfile(String versionId, String profileId, boolean force) {
Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false);
try {
ProfileService service = permit.getInstance();
service.deleteProfile(versionId, profileId, force);
} finally {
permit.release();
}
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class ProfileManagerImpl method deleteVersion.
@Override
public void deleteVersion(String versionId) {
Permit<ProfileService> permit = permitManager.get().aquirePermit(ProfileService.PERMIT, false);
try {
ProfileService service = permit.getInstance();
service.deleteVersion(versionId);
} finally {
permit.release();
}
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class FabricManager method currentContainerConfigurationFiles.
/**
* Returns a map of all the current configuration files in the profiles of
* the current container with the file name as the key and the profile ID as
* the value
*/
@Override
public Map<String, String> currentContainerConfigurationFiles() {
String containerName = getCurrentContainerName();
FabricServiceImpl service = fabricService;
Container container = service.getContainer(containerName);
if (container != null) {
Profile[] profiles = container.getProfiles();
return Profiles.getConfigurationFileNameMap(profiles);
}
return new HashMap<String, String>();
}
use of io.fabric8.knative.serving.v1.Service in project fabric8 by jboss-fuse.
the class JcloudsContainerProvider method create.
@Override
public CreateJCloudsContainerMetadata create(CreateJCloudsContainerOptions input, CreationStateListener listener) throws MalformedURLException, RunNodesException, URISyntaxException, InterruptedException {
assertValid();
CreateJCloudsContainerOptions options = input.updateComputeService(getOrCreateComputeService(input));
listener.onStateChange("Looking up for compute service.");
ComputeService computeService = getOrCreateComputeService(options);
if (computeService == null) {
throw new IllegalStateException("Compute service could not be found or created.");
}
Template template = ToTemplate.apply(options);
listener.onStateChange(String.format(OVERVIEW_FORMAT, 1, options.getContextName()));
try {
Set<? extends NodeMetadata> metadata = computeService.createNodesInGroup(options.getGroup(), 1, template);
if (metadata == null || metadata.size() != 1) {
throw new IllegalStateException("JClouds created " + metadata.size() + " containers instead of 1");
}
NodeMetadata nodeMetadata = metadata.iterator().next();
switch(nodeMetadata.getStatus()) {
case RUNNING:
listener.onStateChange(String.format(NODE_CREATED_FORMAT, nodeMetadata.getName()));
break;
default:
listener.onStateChange(String.format(NODE_ERROR_FORMAT, nodeMetadata.getStatus()));
}
CloudContainerInstallationTask installationTask = new CloudContainerInstallationTask(options.getName(), nodeMetadata, options, computeService, firewallManagerFactory.get(), template.getOptions(), listener);
return installationTask.install();
} catch (Throwable ex) {
CreateJCloudsContainerMetadata failureMetadata = new CreateJCloudsContainerMetadata();
failureMetadata.setCreateOptions(options);
failureMetadata.setFailure(ex);
return failureMetadata;
}
}
Aggregations