Search in sources :

Example 71 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project camel by apache.

the class KubernetesBuildsProducer method doListBuildByLabels.

protected void doListBuildByLabels(Exchange exchange, String operation) throws Exception {
    BuildList buildList = null;
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_BUILDS_LABELS, Map.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (!ObjectHelper.isEmpty(namespaceName)) {
        NonNamespaceOperation<Build, BuildList, DoneableBuild, BuildResource<Build, DoneableBuild, String, LogWatch>> builds = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).builds().inNamespace(namespaceName);
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            builds.withLabel(entry.getKey(), entry.getValue());
        }
        buildList = builds.list();
    } else {
        MixedOperation<Build, BuildList, DoneableBuild, BuildResource<Build, DoneableBuild, String, LogWatch>> builds = getEndpoint().getKubernetesClient().adapt(OpenShiftClient.class).builds();
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            builds.withLabel(entry.getKey(), entry.getValue());
        }
        buildList = builds.list();
    }
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(buildList.getItems());
}
Also used : BuildList(io.fabric8.openshift.api.model.BuildList) DoneableBuild(io.fabric8.openshift.api.model.DoneableBuild) DoneableBuild(io.fabric8.openshift.api.model.DoneableBuild) Build(io.fabric8.openshift.api.model.Build) OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) Map(java.util.Map) BuildResource(io.fabric8.openshift.client.dsl.BuildResource)

Example 72 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project camel by apache.

the class KubernetesReplicationControllersProducer method doListReplicationControllersByLabels.

protected void doListReplicationControllersByLabels(Exchange exchange, String operation) throws Exception {
    ReplicationControllerList rcList = null;
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_REPLICATION_CONTROLLERS_LABELS, Map.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (!ObjectHelper.isEmpty(namespaceName)) {
        NonNamespaceOperation<ReplicationController, ReplicationControllerList, DoneableReplicationController, RollableScallableResource<ReplicationController, DoneableReplicationController>> replicationControllers;
        replicationControllers = getEndpoint().getKubernetesClient().replicationControllers().inNamespace(namespaceName);
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            replicationControllers.withLabel(entry.getKey(), entry.getValue());
        }
        rcList = replicationControllers.list();
    } else {
        MixedOperation<ReplicationController, ReplicationControllerList, DoneableReplicationController, RollableScallableResource<ReplicationController, DoneableReplicationController>> replicationControllers;
        replicationControllers = getEndpoint().getKubernetesClient().replicationControllers();
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            replicationControllers.withLabel(entry.getKey(), entry.getValue());
        }
        rcList = replicationControllers.list();
    }
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(rcList.getItems());
}
Also used : DoneableReplicationController(io.fabric8.kubernetes.api.model.DoneableReplicationController) ReplicationController(io.fabric8.kubernetes.api.model.ReplicationController) RollableScallableResource(io.fabric8.kubernetes.client.dsl.RollableScallableResource) Map(java.util.Map) ReplicationControllerList(io.fabric8.kubernetes.api.model.ReplicationControllerList) DoneableReplicationController(io.fabric8.kubernetes.api.model.DoneableReplicationController)

Example 73 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project camel by apache.

the class KubernetesResourcesQuotaProducer method doListResourceQuotasByLabels.

protected void doListResourceQuotasByLabels(Exchange exchange, String operation) throws Exception {
    ResourceQuotaList resList = null;
    Map<String, String> labels = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_RESOURCES_QUOTA_LABELS, Map.class);
    String namespaceName = exchange.getIn().getHeader(KubernetesConstants.KUBERNETES_NAMESPACE_NAME, String.class);
    if (!ObjectHelper.isEmpty(namespaceName)) {
        NonNamespaceOperation<ResourceQuota, ResourceQuotaList, DoneableResourceQuota, Resource<ResourceQuota, DoneableResourceQuota>> resQuota;
        resQuota = getEndpoint().getKubernetesClient().resourceQuotas().inNamespace(namespaceName);
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            resQuota.withLabel(entry.getKey(), entry.getValue());
        }
        resList = resQuota.list();
    } else {
        MixedOperation<ResourceQuota, ResourceQuotaList, DoneableResourceQuota, Resource<ResourceQuota, DoneableResourceQuota>> resQuota;
        resQuota = getEndpoint().getKubernetesClient().resourceQuotas();
        for (Map.Entry<String, String> entry : labels.entrySet()) {
            resQuota.withLabel(entry.getKey(), entry.getValue());
        }
        resList = resQuota.list();
    }
    MessageHelper.copyHeaders(exchange.getIn(), exchange.getOut(), true);
    exchange.getOut().setBody(resList.getItems());
}
Also used : ResourceQuotaList(io.fabric8.kubernetes.api.model.ResourceQuotaList) DoneableResourceQuota(io.fabric8.kubernetes.api.model.DoneableResourceQuota) ResourceQuota(io.fabric8.kubernetes.api.model.ResourceQuota) Resource(io.fabric8.kubernetes.client.dsl.Resource) DoneableResourceQuota(io.fabric8.kubernetes.api.model.DoneableResourceQuota) Map(java.util.Map)

Example 74 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project vertx-openshift-it by cescoffier.

the class WebSessionIT method testClusteredWebSession.

@Test
public void testClusteredWebSession() throws Exception {
    HttpClient httpClient = vertx.createHttpClient();
    AtomicReference<Map.Entry<String, String>> cookie = new AtomicReference<>();
    int loops = 30;
    for (int i = 0; i < loops; i++) {
        String key = getKey(i);
        String value = getValue(i);
        URL url = Kube.urlForRoute(client.routes().withName(APPLICATION_NAME).get(), "/web-session/" + key);
        CountDownLatch latch = new CountDownLatch(1);
        HttpClientRequest request = httpClient.putAbs(url.toString());
        Optional.ofNullable(cookie.get()).ifPresent(c -> request.headers().add("cookie", c.getKey() + "=" + c.getValue()));
        request.handler(resp -> {
            resp.cookies().stream().map(c -> c.split("=", 2)).map(split -> new SimpleImmutableEntry<>(split[0], split[1].split(";")[0])).filter(entry -> "vertx-web.session".equals(entry.getKey())).forEach(cookie::set);
            latch.countDown();
        }).exceptionHandler(t -> {
            t.printStackTrace();
            latch.countDown();
        }).end(value);
        latch.await(1, TimeUnit.MINUTES);
        // Give some time to the replication operation
        TimeUnit.SECONDS.sleep(1);
    }
    scaleTo(2);
    // Give some time to the rebalancing process
    TimeUnit.SECONDS.sleep(10);
    assertNotNull("No session cookie", cookie.get());
    for (int i = 0; i < loops; i++) {
        String key = getKey(i);
        String value = getValue(i);
        URL url = Kube.urlForRoute(client.routes().withName(APPLICATION_NAME).get(), "/web-session/" + key);
        given().cookie(cookie.get().getKey(), cookie.get().getValue()).when().get(url).then().assertThat().statusCode(200).body(equalTo(value));
    }
}
Also used : CoreMatchers(org.hamcrest.CoreMatchers) BeforeClass(org.junit.BeforeClass) URL(java.net.URL) OC(io.vertx.it.openshift.utils.OC) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) AtomicReference(java.util.concurrent.atomic.AtomicReference) HttpClientRequest(io.vertx.core.http.HttpClientRequest) Route(io.fabric8.openshift.api.model.Route) OpenShiftHelper(io.vertx.it.openshift.utils.OpenShiftHelper) AbstractTestClass(io.vertx.it.openshift.utils.AbstractTestClass) Ensure(io.vertx.it.openshift.utils.Ensure) After(org.junit.After) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) Service(io.fabric8.kubernetes.api.model.Service) Before(org.junit.Before) Vertx(io.vertx.core.Vertx) Kube(io.vertx.it.openshift.utils.Kube) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) TreeMap(java.util.TreeMap) Optional(java.util.Optional) RestAssured.given(io.restassured.RestAssured.given) RestAssured(io.restassured.RestAssured) Assert(org.junit.Assert) Awaitility(org.awaitility.Awaitility) SortedMap(java.util.SortedMap) HttpClient(io.vertx.core.http.HttpClient) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) HttpClientRequest(io.vertx.core.http.HttpClientRequest) HttpClient(io.vertx.core.http.HttpClient) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) URL(java.net.URL) Test(org.junit.Test)

Example 75 with Entry

use of io.fabric8.maven.docker.config.CopyConfiguration.Entry in project fabric8 by jboss-fuse.

the class ProfileMetadata method addMetaData.

protected void addMetaData(MetaTypeSummaryDTO summary, MetaData metadata, Properties resources) {
    Map<String, Object> map = metadata.getDesignates();
    Map<String, Object> objects = metadata.getObjectClassDefinitions();
    Set<Map.Entry<String, Object>> entries = map.entrySet();
    for (Map.Entry<String, Object> entry : entries) {
        String pid = entry.getKey();
        Object value = objects.get(pid);
        if (value instanceof OCD) {
            OCD ocd = (OCD) value;
            MetaTypeObjectSummaryDTO object = summary.getOrCreateMetaTypeSummaryDTO(pid);
            object.setId(pid);
            object.setName(localize(resources, ocd.getName()));
            object.setDescription(localize(resources, ocd.getDescription()));
        }
    }
}
Also used : OCD(org.apache.felix.metatype.OCD) JarEntry(java.util.jar.JarEntry) MetaTypeObjectSummaryDTO(io.fabric8.api.jmx.MetaTypeObjectSummaryDTO) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

Map (java.util.Map)89 HashMap (java.util.HashMap)57 IOException (java.io.IOException)31 File (java.io.File)30 ArrayList (java.util.ArrayList)26 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)16 List (java.util.List)14 Properties (java.util.Properties)14 HashSet (java.util.HashSet)10 Entry (io.fabric8.maven.docker.config.CopyConfiguration.Entry)9 ZipFile (org.apache.commons.compress.archivers.zip.ZipFile)9 Test (org.junit.Test)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 LinkedHashMap (java.util.LinkedHashMap)8 TreeMap (java.util.TreeMap)8 Resource (io.fabric8.kubernetes.client.dsl.Resource)7 FileInputStream (java.io.FileInputStream)7 Set (java.util.Set)7 Profile (io.fabric8.api.Profile)6 ProfileService (io.fabric8.api.ProfileService)5