Search in sources :

Example 21 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class JcaPresenter method launchAddThreadPool.

// ------------------------------------------------------ thread pools (for normal and distributed work managers)
/**
 * Used to bring up the dialog to add thread pools for the normal and the distributed work managers.
 * <p>
 * Only one long and one short running thread pool is allowed per (distributed) work manager. This method takes care of
 * showing the right attributes in the dialog. If there are already long and short running thread pools attached to the work
 * manager an error message is shown.
 */
void launchAddThreadPool(AddressTemplate workmanagerTemplate, String workmanager) {
    dispatcher.execute(threadPoolsOperation(workmanagerTemplate, workmanager), (CompositeResult cr) -> {
        boolean lrtPresent = !cr.step(0).get(RESULT).asPropertyList().isEmpty();
        boolean srtPresent = !cr.step(1).get(RESULT).asPropertyList().isEmpty();
        if (lrtPresent && srtPresent) {
            MessageEvent.fire(getEventBus(), Message.error(resources.messages().allThreadPoolsExist()));
        } else {
            FormItem<String> typeItem;
            if (!lrtPresent && !srtPresent) {
                typeItem = new SingleSelectBoxItem(TYPE, resources.constants().type(), asList(Names.LONG_RUNNING, Names.SHORT_RUNNING), false);
                typeItem.setRequired(true);
            } else {
                typeItem = new TextBoxItem(TYPE, resources.constants().type());
                typeItem.setValue(lrtPresent ? Names.SHORT_RUNNING : Names.LONG_RUNNING);
                typeItem.setEnabled(false);
            }
            // for the metadata it doesn't matter whether we use the LRT or SRT template nor
            // whether we use the normal or distributed workmanager version
            Metadata metadata = metadataRegistry.lookup(WORKMANAGER_LRT_TEMPLATE);
            Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.JCA_THREAD_POOL_ADD, metadata).fromRequestProperties().unboundFormItem(typeItem, 0).include(MAX_THREADS, QUEUE_LENGTH, THREAD_FACTORY).unsorted().build();
            AddResourceDialog dialog = new AddResourceDialog(resources.messages().addResourceTitle(THREAD_POOL), form, (name, modelNode) -> {
                String type = typeItem.getValue();
                AddressTemplate tpTemplate = Names.LONG_RUNNING.equals(type) ? workmanagerTemplate.append(WORKMANAGER_LRT_TEMPLATE.lastName() + EQUALS + workmanager) : workmanagerTemplate.append(WORKMANAGER_SRT_TEMPLATE.lastName() + EQUALS + workmanager);
                ResourceAddress address = tpTemplate.resolve(statementContext, workmanager);
                Operation operation = new Operation.Builder(address, ADD).payload(modelNode).build();
                dispatcher.execute(operation, result -> {
                    MessageEvent.fire(getEventBus(), Message.success(resources.messages().addResourceSuccess(THREAD_POOL, name)));
                    loadThreadPools(workmanagerTemplate, workmanager);
                });
            });
            dialog.show();
        }
    });
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) AddressTemplate(org.jboss.hal.meta.AddressTemplate) SingleSelectBoxItem(org.jboss.hal.ballroom.form.SingleSelectBoxItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 22 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class JcaPresenter method resetThreadPool.

void resetThreadPool(AddressTemplate workmanagerTemplate, String workmanager, ThreadPool threadPool, Form<ThreadPool> form) {
    Metadata metadata = metadataRegistry.lookup(threadPool.isLongRunning() ? WORKMANAGER_LRT_TEMPLATE : WORKMANAGER_SRT_TEMPLATE);
    ResourceAddress address = threadPoolAddress(workmanagerTemplate, workmanager, threadPool);
    crud.reset(THREAD_POOL, threadPool.getName(), address, form, metadata, new FinishReset<ThreadPool>(form) {

        @Override
        public void afterReset(Form<ThreadPool> form) {
            loadThreadPools(workmanagerTemplate, workmanager);
        }
    });
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Metadata(org.jboss.hal.meta.Metadata)

Example 23 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class JcaPresenter method saveThreadPool.

void saveThreadPool(AddressTemplate workmanagerTemplate, String workmanager, ThreadPool threadPool, Map<String, Object> changedValues) {
    Metadata metadata = metadataRegistry.lookup(threadPool.isLongRunning() ? WORKMANAGER_LRT_TEMPLATE : WORKMANAGER_SRT_TEMPLATE);
    ResourceAddress address = threadPoolAddress(workmanagerTemplate, workmanager, threadPool);
    crud.save(THREAD_POOL, threadPool.getName(), address, changedValues, metadata, () -> loadThreadPools(workmanagerTemplate, workmanager));
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Metadata(org.jboss.hal.meta.Metadata)

Example 24 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class JGroupsPresenter method addStack.

// stack resources
@SuppressWarnings("ConstantConditions")
void addStack() {
    Metadata metadata = metadataRegistry.lookup(STACK_TEMPLATE);
    Metadata transportMetadata = metadataRegistry.lookup(TRANSPORT_TEMPLATE).forOperation(ADD);
    transportMetadata.copyAttribute(SOCKET_BINDING, metadata);
    metadata.makeWritable(SOCKET_BINDING);
    NameItem nameItem = new NameItem();
    String transportLabel = new LabelBuilder().label(TRANSPORT);
    TextBoxItem transportItem = new TextBoxItem(TRANSPORT, transportLabel);
    transportItem.setRequired(true);
    String id = Ids.build(Ids.JGROUPS_STACK_CONFIG, Ids.ADD);
    ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).unboundFormItem(nameItem, 0).unboundFormItem(transportItem, 2).unsorted().requiredOnly().build();
    AddResourceDialog dialog = new AddResourceDialog(Names.STACK, form, (name, model) -> {
        ResourceAddress stackAddress = STACK_TEMPLATE.resolve(filterStatementContext, name);
        String transport = transportItem.getValue();
        ResourceAddress transportAddress = TRANSPORT_TEMPLATE.resolve(filterStatementContext, name, transport);
        Operation addStackOperation = new Operation.Builder(stackAddress, ADD).build();
        Operation addTransportOperation = new Operation.Builder(transportAddress, ADD).payload(model).build();
        Composite composite = new Composite(addStackOperation, addTransportOperation);
        dispatcher.execute(composite, (CompositeResult result) -> {
            MessageEvent.fire(eventBus, Message.success(resources.messages().addResourceSuccess(Names.STACK, name)));
            reload();
        });
    });
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 25 with Metadata

use of org.jboss.hal.meta.Metadata in project console by hal.

the class LoggingProfileView method addAsyncHandler.

// ------------------------------------------------------ async handler
void addAsyncHandler() {
    AddressTemplate metadataTemplate = LOGGING_PROFILE_TEMPLATE.append(ASYNC_HANDLER + EQ_WILDCARD);
    Metadata metadata = mbuiContext.metadataRegistry().lookup(metadataTemplate);
    AddressTemplate selectionTemplate = SELECTED_LOGGING_PROFILE_TEMPLATE.append(ASYNC_HANDLER + EQ_WILDCARD);
    AddResourceDialog dialog = new AddResourceDialog(Ids.build(Ids.LOGGING_PROFILE, "handler-async", Ids.TABLE, Ids.ADD), mbuiContext.resources().messages().addResourceTitle(Names.ASYNC_ACTION_HANDLER), metadata, asList(LEVEL, "subhandlers", "queue-length", "overflow-action"), (name, modelNode) -> {
        ResourceAddress address = selectionTemplate.resolve(selectionAwareStatementContext, name);
        crud().add(Names.ASYNC_ACTION_HANDLER, name, address, modelNode, (n, a) -> presenter.reload());
    });
    List<AddressTemplate> templates = asList(SELECTED_LOGGING_PROFILE_TEMPLATE.append(CONSOLE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(CUSTOM_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(FILE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(PERIODIC_ROTATING_FILE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(PERIODIC_SIZE_ROTATING_FILE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(SIZE_ROTATING_FILE_HANDLER + EQ_WILDCARD), SELECTED_LOGGING_PROFILE_TEMPLATE.append(SYSLOG_HANDLER + EQ_WILDCARD));
    dialog.getForm().getFormItem("subhandlers").registerSuggestHandler(new ReadChildrenAutoComplete(mbuiContext.dispatcher(), selectionAwareStatementContext, templates));
    dialog.show();
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Metadata(org.jboss.hal.meta.Metadata) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)

Aggregations

Metadata (org.jboss.hal.meta.Metadata)281 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)146 ModelNode (org.jboss.hal.dmr.ModelNode)128 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)95 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)80 NamedNode (org.jboss.hal.dmr.NamedNode)73 Ids (org.jboss.hal.resources.Ids)70 Form (org.jboss.hal.ballroom.form.Form)68 Names (org.jboss.hal.resources.Names)67 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)63 Resources (org.jboss.hal.resources.Resources)60 List (java.util.List)59 Operation (org.jboss.hal.dmr.Operation)59 AddressTemplate (org.jboss.hal.meta.AddressTemplate)59 Inject (javax.inject.Inject)52 Map (java.util.Map)51 StatementContext (org.jboss.hal.meta.StatementContext)51 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)50 EventBus (com.google.web.bindery.event.shared.EventBus)49 MetadataRegistry (org.jboss.hal.meta.MetadataRegistry)46