use of org.jboss.hal.core.runtime.server.Server in project console by hal.
the class ServerGroupActions method destroy.
public void destroy(ServerGroup serverGroup) {
List<Server> startedServers = serverGroup.getServers(Server::isStarted);
DialogFactory.showConfirmation(resources.messages().destroy(serverGroup.getName()), resources.messages().destroyServerGroupQuestion(serverGroup.getName()), () -> {
prepare(serverGroup, startedServers, Action.DESTROY);
Operation operation = new Operation.Builder(serverGroup.getAddress(), DESTROY_SERVERS).build();
dispatcher.execute(operation, result -> repeatCompositeUntil(dispatcher, serverGroupTimeout(serverGroup, Action.DESTROY), readServerConfigStatus(startedServers), checkServerConfigStatus(startedServers.size(), STOPPED, DISABLED)).subscribe(new ServerGroupTimeoutCallback(serverGroup, startedServers, resources.messages().destroyServerGroupSuccess(serverGroup.getName()))), new ServerGroupFailedCallback(serverGroup, startedServers, resources.messages().destroyServerError(serverGroup.getName())), new ServerGroupExceptionCallback(serverGroup, startedServers, resources.messages().destroyServerError(serverGroup.getName())));
});
}
use of org.jboss.hal.core.runtime.server.Server in project console by hal.
the class TestStep method testConnection.
private void testConnection() {
Context context = wizard().getContext();
List<Task<FlowContext>> tasks = new ArrayList<>();
if (!context.isCreated()) {
// add data source
tasks.add(flowContext -> dispatcher.execute(addOperation(context, statementContext)).doOnSuccess((CompositeResult result) -> context.setCreated(true)).doOnError(throwable -> {
flowContext.set(WIZARD_TITLE, resources.constants().testConnectionError());
flowContext.set(WIZARD_TEXT, resources.messages().dataSourceAddError());
}).toCompletable());
}
// check running server(s)
tasks.addAll(runningServers(environment, dispatcher, properties(PROFILE_NAME, statementContext.selectedProfile())));
// test connection
tasks.add(flowContext -> {
List<Server> servers = flowContext.get(TopologyTasks.SERVERS);
ResourceAddress address;
if (!servers.isEmpty()) {
Server server = servers.get(0);
address = server.getServerAddress();
} else if (environment.isStandalone()) {
address = ResourceAddress.root();
} else {
flowContext.set(WIZARD_TITLE, resources.constants().testConnectionError());
flowContext.set(WIZARD_TEXT, SafeHtmlUtils.fromString(resources.constants().noRunningServers()));
return Completable.error(new FlowException(resources.messages().testConnectionErrorDomain(), flowContext));
}
address.add(SUBSYSTEM, DATASOURCES).add(context.dataSource.isXa() ? XA_DATA_SOURCE : DATA_SOURCE, context.dataSource.getName());
Operation operation = new Operation.Builder(address, TEST_CONNECTION_IN_POOL).build();
return dispatcher.execute(operation).doOnError(throwable -> {
flowContext.set(WIZARD_TITLE, resources.constants().testConnectionError());
flowContext.set(WIZARD_TEXT, resources.messages().testConnectionError(context.dataSource.getName()));
}).toCompletable();
});
series(new FlowContext(progress.get()), tasks).subscribe(new Outcome<FlowContext>() {
@Override
public void onError(FlowContext flowContext, Throwable error) {
String title;
SafeHtml text;
if (flowContext == null) {
title = resources.constants().unknownError();
text = resources.messages().unknownError();
} else {
title = flowContext.get(WIZARD_TITLE);
text = flowContext.get(WIZARD_TEXT);
}
wizard().showError(title, text, error.getMessage(), false);
}
@Override
public void onSuccess(FlowContext flowContext) {
wizard().showSuccess(resources.constants().testConnectionSuccess(), resources.messages().testConnectionSuccess(context.dataSource.getName()), false);
}
});
}
use of org.jboss.hal.core.runtime.server.Server in project console by hal.
the class ServerColumn method addServer.
private void addServer(boolean browseByHost) {
if (browseByHost) {
AddressTemplate template = serverConfigTemplate(statementContext.selectedHost());
String id = Ids.build(HOST, statementContext.selectedHost(), SERVER, Ids.ADD);
List<String> attributes = asList(AUTO_START, GROUP, SOCKET_BINDING_DEFAULT_INTERFACE, SOCKET_BINDING_GROUP, SOCKET_BINDING_PORT_OFFSET, UPDATE_AUTO_START_WITH_SERVER_STATUS);
crud.add(id, Names.SERVER, template, attributes, createUniqueValidation(), (name, address) -> refresh(RESTORE_SELECTION));
} else {
// load all available hosts to show in the copy dialog
Operation operation = new Operation.Builder(ResourceAddress.root(), READ_CHILDREN_NAMES_OPERATION).param(CHILD_TYPE, HOST).build();
dispatcher.execute(operation, result -> {
List<String> hosts = new ArrayList<>();
result.asList().forEach(m -> hosts.add(m.asString()));
// get the first host, only to retrieve the r-r-d for server-config
// as /host=*/server-config=*:read-operation-description(name=add) does not work
AddressTemplate template = serverConfigTemplate(hosts.get(0));
metadataProcessor.lookup(template, progress.get(), new SuccessfulMetadataCallback(eventBus, resources) {
@Override
public void onMetadata(Metadata metadata) {
String id = Ids.build(SERVER_GROUP, statementContext.selectedServerGroup(), SERVER, FORM);
SingleSelectBoxItem hostFormItem = new SingleSelectBoxItem(HOST, Names.HOST, hosts, false);
hostFormItem.setRequired(true);
NameItem nameItem = new NameItem();
ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).unboundFormItem(nameItem, 0).unboundFormItem(hostFormItem, 1, resources.messages().addServerHostHelp()).customFormItem(GROUP, attributeDescription -> {
TextBoxItem groupItem = new TextBoxItem(GROUP, resources.constants().group());
groupItem.setEnabled(false);
return groupItem;
}).fromRequestProperties().build();
AddResourceDialog dialog = new AddResourceDialog(resources.messages().addServerTitle(), form, (resource, payload) -> {
payload.get(GROUP).set(statementContext.selectedServerGroup());
String serverName = nameItem.getValue();
ResourceAddress address = serverConfigTemplate(hostFormItem.getValue()).resolve(statementContext, serverName);
crud.add(serverName, address, payload, resources.messages().addResourceSuccess(Names.SERVER, serverName), (name, address1) -> refresh(RESTORE_SELECTION));
});
dialog.getForm().<String>getFormItem(NAME).addValidationHandler(createUniqueValidation());
dialog.show();
form.<String>getFormItem(GROUP).setValue(statementContext.selectedServerGroup());
}
});
});
}
}
use of org.jboss.hal.core.runtime.server.Server in project console by hal.
the class ServerPresenter method reload.
@Override
protected void reload() {
ResourceAddress serverAddress = AddressTemplate.of(SERVER_CONFIG_ADDRESS).resolve(statementContext);
Operation serverOp = new Operation.Builder(serverAddress, READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).build();
Operation interfacesOp = new Operation.Builder(serverAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, INTERFACE).param(INCLUDE_RUNTIME, true).build();
Operation jvmsOp = new Operation.Builder(serverAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, JVM).param(INCLUDE_RUNTIME, true).build();
Operation pathsOp = new Operation.Builder(serverAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, PATH).param(INCLUDE_RUNTIME, true).build();
Operation systemPropertiesOp = new Operation.Builder(serverAddress, READ_CHILDREN_RESOURCES_OPERATION).param(CHILD_TYPE, SYSTEM_PROPERTY).param(INCLUDE_RUNTIME, true).build();
dispatcher.execute(new Composite(serverOp, interfacesOp, jvmsOp, pathsOp, systemPropertiesOp), (CompositeResult result) -> {
Server server = new Server(statementContext.selectedHost(), result.step(0).get(RESULT));
getView().updateServer(server);
getView().updateInterfaces(asNamedNodes(result.step(1).get(RESULT).asPropertyList()));
getView().updateJvms(asNamedNodes(result.step(2).get(RESULT).asPropertyList()));
getView().updatePaths(asNamedNodes(result.step(3).get(RESULT).asPropertyList()));
getView().updateSystemProperties(asNamedNodes(result.step(4).get(RESULT).asPropertyList()));
});
}
use of org.jboss.hal.core.runtime.server.Server in project console by hal.
the class TopologyPreview method buildTable.
// ------------------------------------------------------ UI methods
private HTMLElement buildTable(List<Host> hosts, List<ServerGroup> serverGroups, List<Server> servers) {
HTMLTableElement table = table().css(topology).element();
// <colgroup>
double width = 100.0 / (serverGroups.size() + 1);
HtmlContentBuilder<HTMLTableColElement> colgroup = colgroup().add(col().attr("width", width + "%"));
for (int i = 0; i < serverGroups.size(); i++) {
colgroup.add(col().attr("width", width + "%"));
}
table.appendChild(colgroup.element());
// </colgroup>
// <thead>
HtmlContentBuilder<HTMLTableSectionElement> thead = thead().add(tr().add(th().css(empty).innerHtml(new SafeHtmlBuilder().appendEscaped(Names.SERVER_GROUPS + " ").appendHtmlConstant("→").appendHtmlConstant("<br/>").appendEscaped(Names.HOSTS + " ").appendHtmlConstant("↓").toSafeHtml())).addAll(serverGroups.stream().map(this::serverGroupElement).collect(toList())));
table.appendChild(thead.element());
// </thead>
// <tbody>
HTMLElement tbody = tbody().element();
for (Host host : hosts) {
HTMLElement tr;
tbody.appendChild(tr = tr().element());
tr.appendChild(hostElement(host));
for (ServerGroup serverGroup : serverGroups) {
List<HTMLElement> matchingServers = servers.stream().filter(sc -> host.getName().equals(sc.getHost()) && serverGroup.getName().equals(sc.getServerGroup())).sorted(comparing(Server::getName)).map(this::serverElement).collect(toList());
if (matchingServers.isEmpty()) {
tr.appendChild(td().css(empty).element());
} else {
tr.appendChild(td().add(div().css(CSS.servers).addAll(matchingServers)).element());
}
}
}
table.appendChild(tbody);
return table;
}
Aggregations