Search in sources :

Example 26 with Domain

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

the class Main method deleteDomainPresence.

private static void deleteDomainPresence(Domain dom) {
    V1ObjectMeta meta = dom.getMetadata();
    DomainSpec spec = dom.getSpec();
    String namespace = meta.getNamespace();
    String domainUID = spec.getDomainUID();
    deleteDomainPresence(namespace, domainUID);
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) V1ObjectMeta(io.kubernetes.client.models.V1ObjectMeta)

Example 27 with Domain

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

the class Main method dispatchDomainWatch.

/**
 * Dispatch the Domain event to the appropriate handler.
 *
 * @param item  An item received from a Watch response.
 * @param principal The name of the principal that will be used in this watch.
 */
private static void dispatchDomainWatch(Watch.Response<Domain> item) {
    Domain d;
    String domainUID;
    switch(item.type) {
        case "ADDED":
        case "MODIFIED":
            d = item.object;
            domainUID = d.getSpec().getDomainUID();
            LOGGER.info(MessageKeys.WATCH_DOMAIN, domainUID);
            doCheckAndCreateDomainPresence(d);
            break;
        case "DELETED":
            d = item.object;
            domainUID = d.getSpec().getDomainUID();
            LOGGER.info(MessageKeys.WATCH_DOMAIN_DELETED, domainUID);
            deleteDomainPresence(d);
            break;
        case "ERROR":
        default:
    }
}
Also used : Domain(oracle.kubernetes.weblogic.domain.v1.Domain)

Example 28 with Domain

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

the class Main method scaleDownIfNecessary.

private static Step scaleDownIfNecessary(DomainPresenceInfo info, Collection<String> servers, Step next) {
    Domain dom = info.getDomain();
    DomainSpec spec = dom.getSpec();
    boolean shouldStopAdmin = false;
    String sc = spec.getStartupControl();
    if (sc != null && StartupControlConstants.NONE_STARTUPCONTROL.equals(sc.toUpperCase())) {
        shouldStopAdmin = true;
        next = DomainStatusUpdater.createAvailableStep(DomainStatusUpdater.ALL_STOPPED_AVAILABLE_REASON, next);
    }
    String adminName = spec.getAsName();
    Map<String, ServerKubernetesObjects> currentServers = info.getServers();
    Collection<Map.Entry<String, ServerKubernetesObjects>> serversToStop = new ArrayList<>();
    for (Map.Entry<String, ServerKubernetesObjects> entry : currentServers.entrySet()) {
        if ((shouldStopAdmin || !entry.getKey().equals(adminName)) && !servers.contains(entry.getKey())) {
            serversToStop.add(entry);
        }
    }
    if (!serversToStop.isEmpty()) {
        return new ServerDownIteratorStep(serversToStop, next);
    }
    return next;
}
Also used : DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) ServerKubernetesObjects(oracle.kubernetes.operator.helpers.ServerKubernetesObjects) ArrayList(java.util.ArrayList) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) V1ConfigMap(io.kubernetes.client.models.V1ConfigMap)

Example 29 with Domain

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

the class Main method doCheckAndCreateDomainPresence.

private static void doCheckAndCreateDomainPresence(Domain dom, boolean explicitRecheck, boolean explicitRestartAdmin, List<String> explicitRestartServers, List<String> explicitRestartClusters) {
    LOGGER.entering();
    boolean hasExplicitRestarts = explicitRestartAdmin || explicitRestartServers != null || explicitRestartClusters != null;
    DomainSpec spec = dom.getSpec();
    normalizeDomainSpec(spec);
    String domainUID = spec.getDomainUID();
    DomainPresenceInfo created = new DomainPresenceInfo(dom);
    DomainPresenceInfo info = domains.putIfAbsent(domainUID, created);
    if (info == null) {
        info = created;
    } else {
        // Has the spec actually changed?  We will get watch events for status updates
        Domain current = info.getDomain();
        if (current != null) {
            if (!explicitRecheck && !hasExplicitRestarts && spec.equals(current.getSpec())) {
                // nothing in the spec has changed
                LOGGER.fine(MessageKeys.NOT_STARTING_DOMAINUID_THREAD, domainUID);
                return;
            }
        }
        info.setDomain(dom);
    }
    String ns = dom.getMetadata().getNamespace();
    if (initialized.getOrDefault(ns, Boolean.FALSE) && !stopping.get()) {
        LOGGER.info(MessageKeys.PROCESSING_DOMAIN, domainUID);
        Step managedServerStrategy = bringManagedServersUp(DomainStatusUpdater.createEndProgressingStep(null));
        Step adminServerStrategy = bringAdminServerUp(connectToAdminAndInspectDomain(managedServerStrategy));
        Step strategy = DomainStatusUpdater.createProgressingStep(DomainStatusUpdater.INSPECTING_DOMAIN_PROGRESS_REASON, true, new DomainPrescenceStep(adminServerStrategy, managedServerStrategy));
        Packet p = new Packet();
        PodWatcher pw = podWatchers.get(ns);
        p.getComponents().put(ProcessingConstants.DOMAIN_COMPONENT_NAME, Component.createFor(info, version, pw));
        p.put(ProcessingConstants.PRINCIPAL, principal);
        if (explicitRestartAdmin) {
            p.put(ProcessingConstants.EXPLICIT_RESTART_ADMIN, Boolean.TRUE);
        }
        p.put(ProcessingConstants.EXPLICIT_RESTART_SERVERS, explicitRestartServers);
        p.put(ProcessingConstants.EXPLICIT_RESTART_CLUSTERS, explicitRestartClusters);
        if (explicitRestartAdmin) {
            LOGGER.info(MessageKeys.RESTART_ADMIN_STARTING, domainUID);
        }
        if (explicitRestartServers != null) {
            LOGGER.info(MessageKeys.RESTART_SERVERS_STARTING, domainUID, explicitRestartServers);
        }
        if (explicitRestartClusters != null) {
            LOGGER.info(MessageKeys.ROLLING_CLUSTERS_STARTING, domainUID, explicitRestartClusters);
        }
        domainUpdaters.startFiber(domainUID, strategy, p, new CompletionCallback() {

            @Override
            public void onCompletion(Packet packet) {
                if (explicitRestartAdmin) {
                    LOGGER.info(MessageKeys.RESTART_ADMIN_COMPLETE, domainUID);
                }
                if (explicitRestartServers != null) {
                    LOGGER.info(MessageKeys.RESTART_SERVERS_COMPLETE, domainUID, explicitRestartServers);
                }
                if (explicitRestartClusters != null) {
                    LOGGER.info(MessageKeys.ROLLING_CLUSTERS_COMPLETE, domainUID, explicitRestartClusters);
                }
            }

            @Override
            public void onThrowable(Packet packet, Throwable throwable) {
                LOGGER.severe(MessageKeys.EXCEPTION, throwable);
                domainUpdaters.startFiberIfLastFiberMatches(domainUID, Fiber.getCurrentIfSet(), DomainStatusUpdater.createFailedStep(throwable, null), p, new CompletionCallback() {

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

                    @Override
                    public void onThrowable(Packet packet, Throwable throwable) {
                        LOGGER.severe(MessageKeys.EXCEPTION, throwable);
                    }
                });
            // TODO: consider retrying domain update after a delay
            }
        });
        scheduleDomainStatusUpdating(info);
    }
    LOGGER.exiting();
}
Also used : Packet(oracle.kubernetes.operator.work.Packet) DomainSpec(oracle.kubernetes.weblogic.domain.v1.DomainSpec) CompletionCallback(oracle.kubernetes.operator.work.Fiber.CompletionCallback) Step(oracle.kubernetes.operator.work.Step) ResponseStep(oracle.kubernetes.operator.helpers.ResponseStep) Domain(oracle.kubernetes.weblogic.domain.v1.Domain) DomainPresenceInfo(oracle.kubernetes.operator.helpers.DomainPresenceInfo)

Example 30 with Domain

use of oracle.kubernetes.weblogic.domain.v1.Domain 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

Domain (oracle.kubernetes.weblogic.domain.v1.Domain)33 Type (java.lang.reflect.Type)18 DomainSpec (oracle.kubernetes.weblogic.domain.v1.DomainSpec)11 ProgressRequestBody (io.kubernetes.client.ProgressRequestBody)9 ProgressResponseBody (io.kubernetes.client.ProgressResponseBody)9 DomainList (oracle.kubernetes.weblogic.domain.v1.DomainList)7 Domain (org.openstack4j.model.identity.v3.Domain)7 V1ObjectMeta (io.kubernetes.client.models.V1ObjectMeta)5 ArrayList (java.util.ArrayList)5 CallBuilderFactory (oracle.kubernetes.operator.helpers.CallBuilderFactory)5 ClusterStartup (oracle.kubernetes.weblogic.domain.v1.ClusterStartup)5 Test (org.junit.Test)5 ApiException (io.kubernetes.client.ApiException)4 Map (java.util.Map)4 V1Service (io.kubernetes.client.models.V1Service)3 HashMap (java.util.HashMap)3 WlsServerConfig (oracle.kubernetes.operator.wlsconfig.WlsServerConfig)3 Packet (oracle.kubernetes.operator.work.Packet)3 HttpUserAgentTest (com.meterware.pseudoserver.HttpUserAgentTest)2 V1ConfigMap (io.kubernetes.client.models.V1ConfigMap)2