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]);
}
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));
}
}
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);
}
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())));
}
}
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())));
});
}
Aggregations