Search in sources :

Example 36 with Service

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);
    }
}
Also used : Version(io.fabric8.api.Version) URISyntaxException(java.net.URISyntaxException) BadBinaryOpValueExpException(javax.management.BadBinaryOpValueExpException) BadStringOperationException(javax.management.BadStringOperationException) MalformedObjectNameException(javax.management.MalformedObjectNameException) MalformedURLException(java.net.MalformedURLException) BadAttributeValueExpException(javax.management.BadAttributeValueExpException) IOException(java.io.IOException) InvalidApplicationException(javax.management.InvalidApplicationException)

Example 37 with Service

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();
    }
}
Also used : ProfileService(io.fabric8.api.ProfileService)

Example 38 with Service

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();
    }
}
Also used : ProfileService(io.fabric8.api.ProfileService)

Example 39 with Service

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>();
}
Also used : Container(io.fabric8.api.Container) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FabricServiceImpl(io.fabric8.service.FabricServiceImpl) Profile(io.fabric8.api.Profile)

Example 40 with Service

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;
    }
}
Also used : NodeMetadata(org.jclouds.compute.domain.NodeMetadata) ComputeService(org.jclouds.compute.ComputeService) ToTemplate(io.fabric8.service.jclouds.functions.ToTemplate) Template(org.jclouds.compute.domain.Template)

Aggregations

Service (io.fabric8.kubernetes.api.model.Service)142 Test (org.junit.Test)93 File (java.io.File)60 IOException (java.io.IOException)54 ArrayList (java.util.ArrayList)54 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)48 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)43 HashMap (java.util.HashMap)41 ServiceBuilder (io.fabric8.kubernetes.api.model.ServiceBuilder)38 DefaultKubernetesClient (io.fabric8.kubernetes.client.DefaultKubernetesClient)33 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)33 Pod (io.fabric8.kubernetes.api.model.Pod)31 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)30 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)29 Deployment (io.fabric8.kubernetes.api.model.extensions.Deployment)25 List (java.util.List)25 Map (java.util.Map)25 FileInputStream (java.io.FileInputStream)22 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)20 ServicePortBuilder (io.fabric8.kubernetes.api.model.ServicePortBuilder)20