Search in sources :

Example 1 with DomainList

use of oracle.kubernetes.weblogic.domain.v1.DomainList in project weblogic-kubernetes-operator by oracle.

the class Main method begin.

private static void begin() {
    // read the operator configuration
    String namespace = System.getenv("OPERATOR_NAMESPACE");
    if (namespace == null) {
        namespace = "default";
    }
    Collection<String> targetNamespaces = getTargetNamespaces(namespace);
    String serviceAccountName = tuningAndConfig.get("serviceaccount");
    if (serviceAccountName == null) {
        serviceAccountName = "default";
    }
    principal = "system:serviceaccount:" + namespace + ":" + serviceAccountName;
    LOGGER.info(MessageKeys.OP_CONFIG_NAMESPACE, namespace);
    StringBuilder tns = new StringBuilder();
    Iterator<String> it = targetNamespaces.iterator();
    while (it.hasNext()) {
        tns.append(it.next());
        if (it.hasNext()) {
            tns.append(", ");
        }
    }
    LOGGER.info(MessageKeys.OP_CONFIG_TARGET_NAMESPACES, tns.toString());
    LOGGER.info(MessageKeys.OP_CONFIG_SERVICE_ACCOUNT, serviceAccountName);
    try {
        // Initialize logging factory with JSON serializer for later logging
        // that includes k8s objects
        LoggingFactory.setJSON(new JSON());
        // start the REST server
        startRestServer(principal, targetNamespaces);
        // create the Custom Resource Definitions if they are not already there
        CRDHelper.checkAndCreateCustomResourceDefinition();
        try {
            HealthCheckHelper healthCheck = new HealthCheckHelper(namespace, targetNamespaces);
            version = healthCheck.performK8sVersionCheck();
            healthCheck.performNonSecurityChecks();
            healthCheck.performSecurityChecks(serviceAccountName);
        } catch (ApiException e) {
            LOGGER.warning(MessageKeys.EXCEPTION, e);
        }
        // check for any existing resources and add the watches on them
        // this would happen when the Domain was running BEFORE the Operator starts up
        LOGGER.info(MessageKeys.LISTING_DOMAINS);
        for (String ns : targetNamespaces) {
            initialized.put(ns, Boolean.TRUE);
            Step domainList = callBuilderFactory.create().listDomainAsync(ns, new ResponseStep<DomainList>(null) {

                @Override
                public NextAction onFailure(Packet packet, ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
                    if (statusCode == CallBuilder.NOT_FOUND) {
                        return onSuccess(packet, null, statusCode, responseHeaders);
                    }
                    return super.onFailure(packet, e, statusCode, responseHeaders);
                }

                @Override
                public NextAction onSuccess(Packet packet, DomainList result, int statusCode, Map<String, List<String>> responseHeaders) {
                    if (result != null) {
                        for (Domain dom : result.getItems()) {
                            doCheckAndCreateDomainPresence(dom);
                        }
                    }
                    // main logic now happens in the watch handlers
                    domainWatchers.put(ns, createDomainWatcher(ns, result != null ? result.getMetadata().getResourceVersion() : ""));
                    return doNext(packet);
                }
            });
            Step initialize = ConfigMapHelper.createScriptConfigMapStep(ns, new ConfigMapAfterStep(ns, callBuilderFactory.create().with($ -> {
                $.labelSelector = LabelConstants.DOMAINUID_LABEL + "," + LabelConstants.CREATEDBYOPERATOR_LABEL;
            }).listPodAsync(ns, new ResponseStep<V1PodList>(callBuilderFactory.create().with($ -> {
                $.labelSelector = LabelConstants.DOMAINUID_LABEL + "," + LabelConstants.CREATEDBYOPERATOR_LABEL;
            }).listServiceAsync(ns, new ResponseStep<V1ServiceList>(callBuilderFactory.create().with($ -> {
                $.labelSelector = LabelConstants.DOMAINUID_LABEL + "," + LabelConstants.CREATEDBYOPERATOR_LABEL;
            }).listIngressAsync(ns, new ResponseStep<V1beta1IngressList>(domainList) {

                @Override
                public NextAction onFailure(Packet packet, ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
                    if (statusCode == CallBuilder.NOT_FOUND) {
                        return onSuccess(packet, null, statusCode, responseHeaders);
                    }
                    return super.onFailure(packet, e, statusCode, responseHeaders);
                }

                @Override
                public NextAction onSuccess(Packet packet, V1beta1IngressList result, int statusCode, Map<String, List<String>> responseHeaders) {
                    if (result != null) {
                        for (V1beta1Ingress ingress : result.getItems()) {
                            String domainUID = IngressWatcher.getIngressDomainUID(ingress);
                            String clusterName = IngressWatcher.getIngressClusterName(ingress);
                            if (domainUID != null && clusterName != null) {
                                DomainPresenceInfo created = new DomainPresenceInfo(ns);
                                DomainPresenceInfo info = domains.putIfAbsent(domainUID, created);
                                if (info == null) {
                                    info = created;
                                }
                                info.getIngresses().put(clusterName, ingress);
                            }
                        }
                    }
                    ingressWatchers.put(ns, createIngressWatcher(ns, result != null ? result.getMetadata().getResourceVersion() : ""));
                    return doNext(packet);
                }
            })) {

                @Override
                public NextAction onFailure(Packet packet, ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
                    if (statusCode == CallBuilder.NOT_FOUND) {
                        return onSuccess(packet, null, statusCode, responseHeaders);
                    }
                    return super.onFailure(packet, e, statusCode, responseHeaders);
                }

                @Override
                public NextAction onSuccess(Packet packet, V1ServiceList result, int statusCode, Map<String, List<String>> responseHeaders) {
                    if (result != null) {
                        for (V1Service service : result.getItems()) {
                            String domainUID = ServiceWatcher.getServiceDomainUID(service);
                            String serverName = ServiceWatcher.getServiceServerName(service);
                            String channelName = ServiceWatcher.getServiceChannelName(service);
                            if (domainUID != null && serverName != null) {
                                DomainPresenceInfo created = new DomainPresenceInfo(ns);
                                DomainPresenceInfo info = domains.putIfAbsent(domainUID, created);
                                if (info == null) {
                                    info = created;
                                }
                                ServerKubernetesObjects csko = new ServerKubernetesObjects();
                                ServerKubernetesObjects current = info.getServers().putIfAbsent(serverName, csko);
                                ServerKubernetesObjects sko = current != null ? current : csko;
                                if (channelName != null) {
                                    sko.getChannels().put(channelName, service);
                                } else {
                                    sko.getService().set(service);
                                }
                            }
                        }
                    }
                    serviceWatchers.put(ns, createServiceWatcher(ns, result != null ? result.getMetadata().getResourceVersion() : ""));
                    return doNext(packet);
                }
            })) {

                @Override
                public NextAction onFailure(Packet packet, ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
                    if (statusCode == CallBuilder.NOT_FOUND) {
                        return onSuccess(packet, null, statusCode, responseHeaders);
                    }
                    return super.onFailure(packet, e, statusCode, responseHeaders);
                }

                @Override
                public NextAction onSuccess(Packet packet, V1PodList result, int statusCode, Map<String, List<String>> responseHeaders) {
                    if (result != null) {
                        for (V1Pod pod : result.getItems()) {
                            String domainUID = PodWatcher.getPodDomainUID(pod);
                            String serverName = PodWatcher.getPodServerName(pod);
                            if (domainUID != null && serverName != null) {
                                DomainPresenceInfo created = new DomainPresenceInfo(ns);
                                DomainPresenceInfo info = domains.putIfAbsent(domainUID, created);
                                if (info == null) {
                                    info = created;
                                }
                                ServerKubernetesObjects csko = new ServerKubernetesObjects();
                                ServerKubernetesObjects current = info.getServers().putIfAbsent(serverName, csko);
                                ServerKubernetesObjects sko = current != null ? current : csko;
                                sko.getPod().set(pod);
                            }
                        }
                    }
                    podWatchers.put(ns, createPodWatcher(ns, result != null ? result.getMetadata().getResourceVersion() : ""));
                    return doNext(packet);
                }
            })));
            engine.createFiber().start(initialize, new Packet(), new CompletionCallback() {

                @Override
                public void onCompletion(Packet packet) {
                // no-op
                }

                @Override
                public void onThrowable(Packet packet, Throwable throwable) {
                    LOGGER.severe(MessageKeys.EXCEPTION, throwable);
                }
            });
        }
        // delete stranded resources
        for (Map.Entry<String, DomainPresenceInfo> entry : domains.entrySet()) {
            String domainUID = entry.getKey();
            DomainPresenceInfo info = entry.getValue();
            if (info != null) {
                if (info.getDomain() == null) {
                    // no domain resource
                    deleteDomainPresence(info.getNamespace(), domainUID);
                }
            }
        }
    } catch (Throwable e) {
        LOGGER.warning(MessageKeys.EXCEPTION, e);
    } finally {
        LOGGER.info(MessageKeys.OPERATOR_SHUTTING_DOWN);
    }
}
Also used : PodHelper(oracle.kubernetes.operator.helpers.PodHelper) ScheduledFuture(java.util.concurrent.ScheduledFuture) Engine(oracle.kubernetes.operator.work.Engine) ConfigMapHelper(oracle.kubernetes.operator.helpers.ConfigMapHelper) V1beta1IngressList(io.kubernetes.client.models.V1beta1IngressList) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList) CallBuilder(oracle.kubernetes.operator.helpers.CallBuilder) CompletionCallback(oracle.kubernetes.operator.work.Fiber.CompletionCallback) ServerStartupInfo(oracle.kubernetes.operator.helpers.DomainPresenceInfo.ServerStartupInfo) NextAction(oracle.kubernetes.operator.work.NextAction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Component(oracle.kubernetes.operator.work.Component) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta) ThreadFactory(java.util.concurrent.ThreadFactory) V1EnvVar(io.kubernetes.client.models.V1EnvVar) NetworkAccessPoint(oracle.kubernetes.operator.wlsconfig.NetworkAccessPoint) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) KubernetesVersion(oracle.kubernetes.operator.helpers.HealthCheckHelper.KubernetesVersion) WlsDomainConfig(oracle.kubernetes.operator.wlsconfig.WlsDomainConfig) Executors(java.util.concurrent.Executors) List(java.util.List) V1beta1Ingress(io.kubernetes.client.models.V1beta1Ingress) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) MessageKeys(oracle.kubernetes.operator.logging.MessageKeys) CRDHelper(oracle.kubernetes.operator.helpers.CRDHelper) Fiber(oracle.kubernetes.operator.work.Fiber) JSON(io.kubernetes.client.JSON) ServiceHelper(oracle.kubernetes.operator.helpers.ServiceHelper) WlsServerConfig(oracle.kubernetes.operator.wlsconfig.WlsServerConfig) V1PersistentVolumeClaimList(io.kubernetes.client.models.V1PersistentVolumeClaimList) ServerKubernetesObjects(oracle.kubernetes.operator.helpers.ServerKubernetesObjects) CallBuilderFactory(oracle.kubernetes.operator.helpers.CallBuilderFactory) ApiException(io.kubernetes.client.ApiException) V1Pod(io.kubernetes.client.models.V1Pod) Packet(oracle.kubernetes.operator.work.Packet) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Watch(io.kubernetes.client.util.Watch) Step(oracle.kubernetes.operator.work.Step) HashMap(java.util.HashMap) WlsRetriever(oracle.kubernetes.operator.wlsconfig.WlsRetriever) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) DomainPresenceInfo(oracle.kubernetes.operator.helpers.DomainPresenceInfo) V1PodList(io.kubernetes.client.models.V1PodList) StringTokenizer(java.util.StringTokenizer) LoggingFactory(oracle.kubernetes.operator.logging.LoggingFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Iterator(java.util.Iterator) LoggingFacade(oracle.kubernetes.operator.logging.LoggingFacade) WlsClusterConfig(oracle.kubernetes.operator.wlsconfig.WlsClusterConfig) V1Service(io.kubernetes.client.models.V1Service) HealthCheckHelper(oracle.kubernetes.operator.helpers.HealthCheckHelper) RestConfigImpl(oracle.kubernetes.operator.rest.RestConfigImpl) DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) IOException(java.io.IOException) MainTuning(oracle.kubernetes.operator.TuningParameters.MainTuning) Container(oracle.kubernetes.operator.work.Container) FiberGate(oracle.kubernetes.operator.work.FiberGate) TimeUnit(java.util.concurrent.TimeUnit) V1ConfigMap(io.kubernetes.client.models.V1ConfigMap) ServerStartup(oracle.kubernetes.weblogic.domain.v1.ServerStartup) V1Status(io.kubernetes.client.models.V1Status) RestServer(oracle.kubernetes.operator.rest.RestServer) V1DeleteOptions(io.kubernetes.client.models.V1DeleteOptions) V1ServiceList(io.kubernetes.client.models.V1ServiceList) RollingHelper(oracle.kubernetes.operator.helpers.RollingHelper) Collections(java.util.Collections) ClusterStartup(oracle.kubernetes.weblogic.domain.v1.ClusterStartup) IngressHelper(oracle.kubernetes.operator.helpers.IngressHelper) ResponseStep(oracle.kubernetes.operator.helpers.ResponseStep) ServerKubernetesObjects(oracle.kubernetes.operator.helpers.ServerKubernetesObjects) V1Service(io.kubernetes.client.models.V1Service) JSON(io.kubernetes.client.JSON) HealthCheckHelper(oracle.kubernetes.operator.helpers.HealthCheckHelper) Step(oracle.kubernetes.operator.work.Step) ResponseStep(oracle.kubernetes.operator.helpers.ResponseStep) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList) V1beta1Ingress(io.kubernetes.client.models.V1beta1Ingress) V1beta1IngressList(io.kubernetes.client.models.V1beta1IngressList) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList) List(java.util.List) V1PersistentVolumeClaimList(io.kubernetes.client.models.V1PersistentVolumeClaimList) ArrayList(java.util.ArrayList) V1PodList(io.kubernetes.client.models.V1PodList) V1ServiceList(io.kubernetes.client.models.V1ServiceList) Packet(oracle.kubernetes.operator.work.Packet) V1ServiceList(io.kubernetes.client.models.V1ServiceList) NetworkAccessPoint(oracle.kubernetes.operator.wlsconfig.NetworkAccessPoint) DomainPresenceInfo(oracle.kubernetes.operator.helpers.DomainPresenceInfo) V1PodList(io.kubernetes.client.models.V1PodList) CompletionCallback(oracle.kubernetes.operator.work.Fiber.CompletionCallback) V1Pod(io.kubernetes.client.models.V1Pod) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) NextAction(oracle.kubernetes.operator.work.NextAction) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) V1ConfigMap(io.kubernetes.client.models.V1ConfigMap) ApiException(io.kubernetes.client.ApiException) V1beta1IngressList(io.kubernetes.client.models.V1beta1IngressList)

Example 2 with DomainList

use of oracle.kubernetes.weblogic.domain.v1.DomainList in project weblogic-kubernetes-operator by oracle.

the class WeblogicApi method listWebLogicOracleV1NamespacedDomainWithHttpInfo.

/**
 * list or watch objects of kind Domain
 *
 * @param namespace
 *          object name and auth scope, such as for teams and projects
 *          (required)
 * @param pretty
 *          If &#39;true&#39;, then the output is pretty printed. (optional)
 * @param _continue
 *          The continue option should be set when retrieving more results from
 *          the server. Since this value is server defined, clients may only use
 *          the continue value from a previous query result with identical query
 *          parameters (except for the value of continue) and the server may
 *          reject a continue value it does not recognize. If the specified
 *          continue value is no longer valid whether due to expiration
 *          (generally five to fifteen minutes) or a configuration change on the
 *          server the server will respond with a 410 ResourceExpired error
 *          indicating the client must restart their list without the continue
 *          field. This field is not supported when watch is true. Clients may
 *          start a watch from the last resourceVersion value returned by the
 *          server and not miss any modifications. (optional)
 * @param fieldSelector
 *          A selector to restrict the list of returned objects by their fields.
 *          Defaults to everything. (optional)
 * @param includeUninitialized
 *          If true, partially initialized resources are included in the
 *          response. (optional)
 * @param labelSelector
 *          A selector to restrict the list of returned objects by their labels.
 *          Defaults to everything. (optional)
 * @param limit
 *          limit is a maximum number of responses to return for a list call. If
 *          more items exist, the server will set the &#x60;continue&#x60; field
 *          on the list metadata to a value that can be used with the same
 *          initial query to retrieve the next set of results. Setting a limit
 *          may return fewer than the requested amount of items (up to zero
 *          items) in the event all requested objects are filtered out and
 *          clients should only use the presence of the continue field to
 *          determine whether more results are available. Servers may choose not
 *          to support the limit argument and will return all of the available
 *          results. If limit is specified and the continue field is empty,
 *          clients may assume that no more results are available. This field is
 *          not supported if watch is true. The server guarantees that the
 *          objects returned when using continue will be identical to issuing a
 *          single list call without a limit - that is, no objects created,
 *          modified, or deleted after the first request is issued will be
 *          included in any subsequent continued requests. This is sometimes
 *          referred to as a consistent snapshot, and ensures that a client that
 *          is using limit to receive smaller chunks of a very large result can
 *          ensure they see all possible objects. If objects are updated during
 *          a chunked list the version of the object that was present at the
 *          time the first list result was calculated is returned. (optional)
 * @param resourceVersion
 *          When specified with a watch call, shows changes that occur after
 *          that particular version of a resource. Defaults to changes from the
 *          beginning of history. When specified for list: - if unset, then the
 *          result is returned from remote storage based on quorum-read flag; -
 *          if it&#39;s 0, then we simply return what we currently have in
 *          cache, no guarantee; - if set to non zero, then the result is at
 *          least as fresh as given rv. (optional)
 * @param timeoutSeconds
 *          Timeout for the list/watch call. (optional)
 * @param watch
 *          Watch for changes to the described resources and return them as a
 *          stream of add, update, and remove notifications. Specify
 *          resourceVersion. (optional)
 * @return ApiResponse&lt;DomainList&gt;
 * @throws ApiException
 *           If fail to call the API, e.g. server error or cannot deserialize
 *           the response body
 */
public ApiResponse<DomainList> listWebLogicOracleV1NamespacedDomainWithHttpInfo(String namespace, String pretty, String _continue, String fieldSelector, Boolean includeUninitialized, String labelSelector, Integer limit, String resourceVersion, Integer timeoutSeconds, Boolean watch) throws ApiException {
    com.squareup.okhttp.Call call = listWebLogicOracleV1NamespacedDomainValidateBeforeCall(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch, null, null);
    Type localVarReturnType = new TypeToken<DomainList>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList)

Example 3 with DomainList

use of oracle.kubernetes.weblogic.domain.v1.DomainList in project weblogic-kubernetes-operator by oracle.

the class WeblogicApi method listWebLogicOracleV1DomainForAllNamespacesWithHttpInfo.

/**
 * list or watch objects of kind Domain
 *
 * @param _continue
 *          The continue option should be set when retrieving more results from
 *          the server. Since this value is server defined, clients may only use
 *          the continue value from a previous query result with identical query
 *          parameters (except for the value of continue) and the server may
 *          reject a continue value it does not recognize. If the specified
 *          continue value is no longer valid whether due to expiration
 *          (generally five to fifteen minutes) or a configuration change on the
 *          server the server will respond with a 410 ResourceExpired error
 *          indicating the client must restart their list without the continue
 *          field. This field is not supported when watch is true. Clients may
 *          start a watch from the last resourceVersion value returned by the
 *          server and not miss any modifications. (optional)
 * @param fieldSelector
 *          A selector to restrict the list of returned objects by their fields.
 *          Defaults to everything. (optional)
 * @param includeUninitialized
 *          If true, partially initialized resources are included in the
 *          response. (optional)
 * @param labelSelector
 *          A selector to restrict the list of returned objects by their labels.
 *          Defaults to everything. (optional)
 * @param limit
 *          limit is a maximum number of responses to return for a list call. If
 *          more items exist, the server will set the &#x60;continue&#x60; field
 *          on the list metadata to a value that can be used with the same
 *          initial query to retrieve the next set of results. Setting a limit
 *          may return fewer than the requested amount of items (up to zero
 *          items) in the event all requested objects are filtered out and
 *          clients should only use the presence of the continue field to
 *          determine whether more results are available. Servers may choose not
 *          to support the limit argument and will return all of the available
 *          results. If limit is specified and the continue field is empty,
 *          clients may assume that no more results are available. This field is
 *          not supported if watch is true. The server guarantees that the
 *          objects returned when using continue will be identical to issuing a
 *          single list call without a limit - that is, no objects created,
 *          modified, or deleted after the first request is issued will be
 *          included in any subsequent continued requests. This is sometimes
 *          referred to as a consistent snapshot, and ensures that a client that
 *          is using limit to receive smaller chunks of a very large result can
 *          ensure they see all possible objects. If objects are updated during
 *          a chunked list the version of the object that was present at the
 *          time the first list result was calculated is returned. (optional)
 * @param pretty
 *          If &#39;true&#39;, then the output is pretty printed. (optional)
 * @param resourceVersion
 *          When specified with a watch call, shows changes that occur after
 *          that particular version of a resource. Defaults to changes from the
 *          beginning of history. When specified for list: - if unset, then the
 *          result is returned from remote storage based on quorum-read flag; -
 *          if it&#39;s 0, then we simply return what we currently have in
 *          cache, no guarantee; - if set to non zero, then the result is at
 *          least as fresh as given rv. (optional)
 * @param timeoutSeconds
 *          Timeout for the list/watch call. (optional)
 * @param watch
 *          Watch for changes to the described resources and return them as a
 *          stream of add, update, and remove notifications. Specify
 *          resourceVersion. (optional)
 * @return ApiResponse&lt;DomainList&gt;
 * @throws ApiException
 *           If fail to call the API, e.g. server error or cannot deserialize
 *           the response body
 */
public ApiResponse<DomainList> listWebLogicOracleV1DomainForAllNamespacesWithHttpInfo(String _continue, String fieldSelector, Boolean includeUninitialized, String labelSelector, Integer limit, String pretty, String resourceVersion, Integer timeoutSeconds, Boolean watch) throws ApiException {
    com.squareup.okhttp.Call call = listWebLogicOracleV1DomainForAllNamespacesValidateBeforeCall(_continue, fieldSelector, includeUninitialized, labelSelector, limit, pretty, resourceVersion, timeoutSeconds, watch, null, null);
    Type localVarReturnType = new TypeToken<DomainList>() {
    }.getType();
    return apiClient.execute(call, localVarReturnType);
}
Also used : Type(java.lang.reflect.Type) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList)

Example 4 with DomainList

use of oracle.kubernetes.weblogic.domain.v1.DomainList in project weblogic-kubernetes-operator by oracle.

the class CallBuilderTest method testListDomains.

@Test
public void testListDomains() throws InterruptedException {
    Step stepline = new SetupStep(null);
    Packet p = new Packet();
    Semaphore signal = new Semaphore(0);
    List<Throwable> throwables = Collections.synchronizedList(new ArrayList<Throwable>());
    p.put(THROW, throwables);
    engine.createFiber().start(stepline, p, new CompletionCallback() {

        @Override
        public void onCompletion(Packet packet) {
            signal.release();
        }

        @Override
        public void onThrowable(Packet packet, Throwable throwable) {
            throwables.add(throwable);
            signal.release();
        }
    });
    boolean result = signal.tryAcquire(20, TimeUnit.MINUTES);
    assertTrue(result);
    assertTrue(throwables.isEmpty());
    DomainList list = (DomainList) p.get(KEY);
    assertNotNull(list);
}
Also used : Packet(oracle.kubernetes.operator.work.Packet) CompletionCallback(oracle.kubernetes.operator.work.Fiber.CompletionCallback) Step(oracle.kubernetes.operator.work.Step) Semaphore(java.util.concurrent.Semaphore) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList) Test(org.junit.Test)

Example 5 with DomainList

use of oracle.kubernetes.weblogic.domain.v1.DomainList in project weblogic-kubernetes-operator by oracle.

the class WeblogicApi method listWebLogicOracleV1NamespacedDomainAsync.

/**
 * (asynchronously) list or watch objects of kind Domain
 *
 * @param namespace
 *          object name and auth scope, such as for teams and projects
 *          (required)
 * @param pretty
 *          If &#39;true&#39;, then the output is pretty printed. (optional)
 * @param _continue
 *          The continue option should be set when retrieving more results from
 *          the server. Since this value is server defined, clients may only use
 *          the continue value from a previous query result with identical query
 *          parameters (except for the value of continue) and the server may
 *          reject a continue value it does not recognize. If the specified
 *          continue value is no longer valid whether due to expiration
 *          (generally five to fifteen minutes) or a configuration change on the
 *          server the server will respond with a 410 ResourceExpired error
 *          indicating the client must restart their list without the continue
 *          field. This field is not supported when watch is true. Clients may
 *          start a watch from the last resourceVersion value returned by the
 *          server and not miss any modifications. (optional)
 * @param fieldSelector
 *          A selector to restrict the list of returned objects by their fields.
 *          Defaults to everything. (optional)
 * @param includeUninitialized
 *          If true, partially initialized resources are included in the
 *          response. (optional)
 * @param labelSelector
 *          A selector to restrict the list of returned objects by their labels.
 *          Defaults to everything. (optional)
 * @param limit
 *          limit is a maximum number of responses to return for a list call. If
 *          more items exist, the server will set the &#x60;continue&#x60; field
 *          on the list metadata to a value that can be used with the same
 *          initial query to retrieve the next set of results. Setting a limit
 *          may return fewer than the requested amount of items (up to zero
 *          items) in the event all requested objects are filtered out and
 *          clients should only use the presence of the continue field to
 *          determine whether more results are available. Servers may choose not
 *          to support the limit argument and will return all of the available
 *          results. If limit is specified and the continue field is empty,
 *          clients may assume that no more results are available. This field is
 *          not supported if watch is true. The server guarantees that the
 *          objects returned when using continue will be identical to issuing a
 *          single list call without a limit - that is, no objects created,
 *          modified, or deleted after the first request is issued will be
 *          included in any subsequent continued requests. This is sometimes
 *          referred to as a consistent snapshot, and ensures that a client that
 *          is using limit to receive smaller chunks of a very large result can
 *          ensure they see all possible objects. If objects are updated during
 *          a chunked list the version of the object that was present at the
 *          time the first list result was calculated is returned. (optional)
 * @param resourceVersion
 *          When specified with a watch call, shows changes that occur after
 *          that particular version of a resource. Defaults to changes from the
 *          beginning of history. When specified for list: - if unset, then the
 *          result is returned from remote storage based on quorum-read flag; -
 *          if it&#39;s 0, then we simply return what we currently have in
 *          cache, no guarantee; - if set to non zero, then the result is at
 *          least as fresh as given rv. (optional)
 * @param timeoutSeconds
 *          Timeout for the list/watch call. (optional)
 * @param watch
 *          Watch for changes to the described resources and return them as a
 *          stream of add, update, and remove notifications. Specify
 *          resourceVersion. (optional)
 * @param callback
 *          The callback to be executed when the API call finishes
 * @return The request call
 * @throws ApiException
 *           If fail to process the API call, e.g. serializing the request body
 *           object
 */
public com.squareup.okhttp.Call listWebLogicOracleV1NamespacedDomainAsync(String namespace, String pretty, String _continue, String fieldSelector, Boolean includeUninitialized, String labelSelector, Integer limit, String resourceVersion, Integer timeoutSeconds, Boolean watch, final ApiCallback<DomainList> callback) throws ApiException {
    ProgressResponseBody.ProgressListener progressListener = null;
    ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
    if (callback != null) {
        progressListener = (bytesRead, contentLength, done) -> callback.onDownloadProgress(bytesRead, contentLength, done);
        progressRequestListener = (bytesWritten, contentLength, done) -> callback.onUploadProgress(bytesWritten, contentLength, done);
    }
    com.squareup.okhttp.Call call = listWebLogicOracleV1NamespacedDomainValidateBeforeCall(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch, progressListener, progressRequestListener);
    Type localVarReturnType = new TypeToken<DomainList>() {
    }.getType();
    apiClient.executeAsync(call, localVarReturnType, callback);
    return call;
}
Also used : Type(java.lang.reflect.Type) ProgressResponseBody(io.kubernetes.client.ProgressResponseBody) DomainList(oracle.kubernetes.weblogic.domain.v1.DomainList) ProgressRequestBody(io.kubernetes.client.ProgressRequestBody)

Aggregations

DomainList (oracle.kubernetes.weblogic.domain.v1.DomainList)8 Type (java.lang.reflect.Type)4 ApiException (io.kubernetes.client.ApiException)2 ProgressRequestBody (io.kubernetes.client.ProgressRequestBody)2 ProgressResponseBody (io.kubernetes.client.ProgressResponseBody)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 CompletionCallback (oracle.kubernetes.operator.work.Fiber.CompletionCallback)2 Packet (oracle.kubernetes.operator.work.Packet)2 Step (oracle.kubernetes.operator.work.Step)2 Domain (oracle.kubernetes.weblogic.domain.v1.Domain)2 ApiClient (io.kubernetes.client.ApiClient)1 JSON (io.kubernetes.client.JSON)1 V1ConfigMap (io.kubernetes.client.models.V1ConfigMap)1 V1DeleteOptions (io.kubernetes.client.models.V1DeleteOptions)1 V1EnvVar (io.kubernetes.client.models.V1EnvVar)1 V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)1 V1PersistentVolumeClaimList (io.kubernetes.client.models.V1PersistentVolumeClaimList)1 V1Pod (io.kubernetes.client.models.V1Pod)1