Search in sources :

Example 6 with Server

use of org.jboss.hal.core.runtime.server.Server in project console by hal.

the class TopologyPreview method statusCss.

private String[] statusCss(Server server) {
    Set<String> status = new HashSet<>();
    ServerStatusSwitch sss = new ServerStatusSwitch(serverActions) {

        @Override
        protected void onPending(Server server) {
        }

        @Override
        protected void onBootErrors(Server server) {
            status.add(error);
        }

        @Override
        protected void onFailed(Server server) {
            status.add(error);
        }

        @Override
        protected void onAdminMode(Server server) {
            status.add(inactive);
        }

        @Override
        protected void onStarting(Server server) {
        }

        @Override
        protected void onSuspended(Server server) {
            status.add(suspended);
        }

        @Override
        protected void onNeedsReload(Server server) {
            status.add(warning);
        }

        @Override
        protected void onNeedsRestart(Server server) {
            status.add(warning);
        }

        @Override
        protected void onRunning(Server server) {
            status.add(ok);
        }

        @Override
        protected void onStopped(Server server) {
            status.add(inactive);
        }

        @Override
        protected void onUnknown(Server server) {
        }
    };
    sss.accept(server);
    if (serverActions.isPending(server) || server.isStandalone()) {
        status.add(withProgress);
    }
    return status.toArray(new String[0]);
}
Also used : ServerStatusSwitch(org.jboss.hal.client.runtime.server.ServerStatusSwitch) Server(org.jboss.hal.core.runtime.server.Server) HashSet(java.util.HashSet)

Example 7 with Server

use of org.jboss.hal.core.runtime.server.Server in project console by hal.

the class TopologyPreview method onServerAction.

@Override
public void onServerAction(ServerActionEvent event) {
    if (isVisible()) {
        Server server = event.getServer();
        disableDropdown(server.getId(), server.getName());
        startProgress(serverSelector(server));
    }
}
Also used : Server(org.jboss.hal.core.runtime.server.Server)

Example 8 with Server

use of org.jboss.hal.core.runtime.server.Server in project console by hal.

the class ServerPreview method update.

@Override
public void update(Server server) {
    ServerStatusSwitch sss = new ServerStatusSwitch(serverActions) {

        @Override
        protected void onPending(Server server) {
            pending(resources.messages().serverPending(server.getName()));
            disableAllLinks();
        }

        @Override
        protected void onBootErrors(Server server) {
            error(resources.messages().serverBootErrors(server.getName()));
            disableAllLinksBut(bootErrorsLink);
        }

        @Override
        protected void onFailed(Server server) {
            error(resources.messages().serverFailed(server.getName()));
            if (server.isStandalone()) {
                disableAllLinks();
            } else {
                disableAllLinksBut(startLink);
            }
        }

        @Override
        protected void onAdminMode(Server server) {
            adminOnly(resources.messages().serverAdminMode(server.getName()));
            disableAllLinks();
        }

        @Override
        protected void onStarting(Server server) {
            adminOnly(resources.messages().serverAdminMode(server.getName()));
            disableAllLinks();
        }

        @Override
        protected void onSuspended(Server server) {
            suspended(resources.messages().serverSuspended(server.getName()));
            disableAllLinksBut(resumeLink);
        }

        @Override
        protected void onNeedsReload(Server server) {
            needsReload(resources.messages().serverNeedsReload(server.getName()));
            disableAllLinksBut(reloadLink);
        }

        @Override
        protected void onNeedsRestart(Server server) {
            needsRestart(resources.messages().serverNeedsRestart(server.getName()));
            disableAllLinksBut(restartLink);
        }

        @Override
        protected void onRunning(Server server) {
            running(resources.messages().serverRunning(server.getName()));
            if (server.isStandalone()) {
                disableAllLinks();
            } else {
                disableAllLinksBut(stopLink);
            }
        }

        @Override
        protected void onStopped(Server server) {
            alertContainer.className = alert + " " + alertInfo;
            alertIcon.className = Icons.STOPPED;
            alertText.innerHTML = resources.messages().serverStopped(server.getName()).asString();
            if (server.isStandalone()) {
                disableAllLinks();
            } else {
                disableAllLinksBut(startLink);
            }
        }

        @Override
        protected void onUnknown(Server server) {
            unknown(resources.messages().serverUndefined(server.getName()));
            disableAllLinks();
        }
    };
    sss.accept(server);
    ServerPreviewAttributes.refresh(server, attributes);
    boolean displayOpenPorts = server.isRunning() || server.needsRestart() || server.needsReload();
    if (displayOpenPorts) {
        List<Task<FlowContext>> tasks = new ArrayList<>();
        tasks.add(flowContext -> {
            ResourceAddress address = SELECTED_SERVER.resolve(statementContext);
            Operation operation = new Operation.Builder(address, READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, SOCKET_BINDING_GROUP).build();
            return dispatcher.execute(operation).doOnSuccess(result -> flowContext.push(result.get(0).asString())).toCompletable();
        });
        tasks.add(flowContext -> {
            String socketBnding = flowContext.pop();
            ResourceAddress address = SELECTED_SERVER.resolve(statementContext).add(SOCKET_BINDING_GROUP, socketBnding).add(SOCKET_BINDING, "*");
            ModelNode select = new ModelNode();
            select.add("bound-port").add(NAME);
            ModelNode where = new ModelNode();
            where.set("bound", true);
            Operation operation = new Operation.Builder(address, QUERY).param(SELECT, select).param(WHERE, where).build();
            return dispatcher.execute(operation).doOnSuccess(result -> {
                ModelNode openPortsModel = new ModelNode();
                result.asList().forEach(m -> {
                    ModelNode sbModel = m.get(RESULT);
                    openPortsModel.add(sbModel.get(NAME).asString(), sbModel.get("bound-port").asInt());
                    flowContext.push(openPortsModel);
                });
            }).toCompletable();
        });
        series(new FlowContext(progress.get()), tasks).subscribe(new SuccessfulOutcome<FlowContext>(eventBus, resources) {

            @Override
            public void onSuccess(FlowContext flowContext) {
                ModelNode openPorts = flowContext.pop();
                buildOpenPortsElement(openPorts);
            }
        });
        serverActions.readUrl(server, serverUrl);
    }
    Elements.setVisible(headerOpenPorts, displayOpenPorts);
    Elements.setVisible(ulOpenPorts, displayOpenPorts);
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Provider(javax.inject.Provider) Constraint(org.jboss.hal.meta.security.Constraint) StatementContext(org.jboss.hal.meta.StatementContext) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Icons(org.jboss.hal.resources.Icons) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) Task(org.jboss.hal.flow.Task) Progress(org.jboss.hal.flow.Progress) AddressTemplate(org.jboss.hal.meta.AddressTemplate) HTMLElement(elemental2.dom.HTMLElement) PreviewAttribute(org.jboss.hal.core.finder.PreviewAttributes.PreviewAttribute) PlaceManager(com.gwtplatform.mvp.client.proxy.PlaceManager) PreviewAttributes(org.jboss.hal.core.finder.PreviewAttributes) Server(org.jboss.hal.core.runtime.server.Server) Places(org.jboss.hal.core.mvp.Places) Names(org.jboss.hal.resources.Names) ServerActions(org.jboss.hal.core.runtime.server.ServerActions) PreviewAttributeFunction(org.jboss.hal.core.finder.PreviewAttributes.PreviewAttributeFunction) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) FinderPathFactory(org.jboss.hal.core.finder.FinderPathFactory) EventBus(com.google.web.bindery.event.shared.EventBus) CSS(org.jboss.hal.resources.CSS) EventType.click(org.jboss.gwt.elemento.core.EventType.click) FinderPath(org.jboss.hal.core.finder.FinderPath) ServerPreviewAttributes(org.jboss.hal.core.runtime.server.ServerPreviewAttributes) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) UIConstants(org.jboss.hal.resources.UIConstants) HTMLLIElement(elemental2.dom.HTMLLIElement) NameTokens(org.jboss.hal.meta.token.NameTokens) Resources(org.jboss.hal.resources.Resources) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Flow.series(org.jboss.hal.flow.Flow.series) RuntimePreview(org.jboss.hal.client.runtime.RuntimePreview) ServerColumn.serverConfigTemplate(org.jboss.hal.client.runtime.server.ServerColumn.serverConfigTemplate) Elements(org.jboss.gwt.elemento.core.Elements) Task(org.jboss.hal.flow.Task) Server(org.jboss.hal.core.runtime.server.Server) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ArrayList(java.util.ArrayList) Operation(org.jboss.hal.dmr.Operation) FlowContext(org.jboss.hal.flow.FlowContext) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 9 with Server

use of org.jboss.hal.core.runtime.server.Server in project console by hal.

the class ServerGroupActions method resume.

public void resume(ServerGroup serverGroup) {
    List<Server> suspendedServers = serverGroup.getServers(Server::isSuspended);
    if (!suspendedServers.isEmpty()) {
        prepare(serverGroup, suspendedServers, RESUME);
        Operation operation = new Operation.Builder(serverGroup.getAddress(), RESUME_SERVERS).build();
        dispatcher.execute(operation, result -> repeatCompositeUntil(dispatcher, serverGroupTimeout(serverGroup, RESUME), readSuspendState(suspendedServers), checkSuspendState(suspendedServers.size(), RUNNING)).subscribe(new ServerGroupTimeoutCallback(serverGroup, suspendedServers, resources.messages().resumeServerGroupSuccess(serverGroup.getName()))), new ServerGroupFailedCallback(serverGroup, suspendedServers, resources.messages().resumeServerGroupError(serverGroup.getName())), new ServerGroupExceptionCallback(serverGroup, suspendedServers, resources.messages().resumeServerGroupError(serverGroup.getName())));
    } else {
        MessageEvent.fire(eventBus, Message.warning(resources.messages().serverGroupNoSuspendedServers(serverGroup.getName())));
    }
}
Also used : Server(org.jboss.hal.core.runtime.server.Server) Operation(org.jboss.hal.dmr.Operation)

Example 10 with Server

use of org.jboss.hal.core.runtime.server.Server in project console by hal.

the class ServerGroupActions method kill.

public void kill(ServerGroup serverGroup) {
    List<Server> startedServers = serverGroup.getServers(Server::isStarted);
    DialogFactory.showConfirmation(resources.messages().kill(serverGroup.getName()), resources.messages().killServerGroupQuestion(serverGroup.getName()), () -> {
        prepare(serverGroup, startedServers, Action.KILL);
        Operation operation = new Operation.Builder(serverGroup.getAddress(), KILL_SERVERS).build();
        dispatcher.execute(operation, result -> repeatCompositeUntil(dispatcher, serverGroupTimeout(serverGroup, Action.KILL), readServerConfigStatus(startedServers), checkServerConfigStatus(startedServers.size(), STOPPED, DISABLED)).subscribe(new ServerGroupTimeoutCallback(serverGroup, startedServers, resources.messages().killServerGroupSuccess(serverGroup.getName()))), new ServerGroupFailedCallback(serverGroup, startedServers, resources.messages().killServerError(serverGroup.getName())), new ServerGroupExceptionCallback(serverGroup, startedServers, resources.messages().killServerError(serverGroup.getName())));
    });
}
Also used : Server(org.jboss.hal.core.runtime.server.Server) Operation(org.jboss.hal.dmr.Operation)

Aggregations

Server (org.jboss.hal.core.runtime.server.Server)16 Operation (org.jboss.hal.dmr.Operation)12 List (java.util.List)7 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)7 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)7 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)7 ArrayList (java.util.ArrayList)6 Provider (javax.inject.Provider)6 ModelNode (org.jboss.hal.dmr.ModelNode)6 FlowContext (org.jboss.hal.flow.FlowContext)6 Progress (org.jboss.hal.flow.Progress)6 Ids (org.jboss.hal.resources.Ids)6 Resources (org.jboss.hal.resources.Resources)6 EventBus (com.google.web.bindery.event.shared.EventBus)5 HTMLElement (elemental2.dom.HTMLElement)5 Environment (org.jboss.hal.config.Environment)5 ServerActions (org.jboss.hal.core.runtime.server.ServerActions)5 Flow.series (org.jboss.hal.flow.Flow.series)5 AddressTemplate (org.jboss.hal.meta.AddressTemplate)5 PlaceRequest (com.gwtplatform.mvp.shared.proxy.PlaceRequest)4