Search in sources :

Example 1 with SERVLET

use of org.jboss.hal.dmr.ModelDescriptionConstants.SERVLET in project console by hal.

the class DeploymentPresenter method reload.

@Override
protected void reload() {
    ResourceAddress address = deploymentAddress();
    // task 1: read sessions ids, servlets and websockets
    Operation readResourceOp = new Operation.Builder(address, READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).param(RECURSIVE, true).build();
    Operation listSessionsOp = new Operation.Builder(address, LIST_SESSIONS).build();
    Task<FlowContext> task1 = context -> dispatcher.execute(new Composite(readResourceOp, listSessionsOp)).doOnSuccess((CompositeResult result) -> {
        ModelNode readResourceResult = result.step(0).get(RESULT);
        List<NamedNode> servlets = asNamedNodes(failSafePropertyList(readResourceResult, SERVLET));
        List<NamedNode> websockets = asNamedNodes(failSafePropertyList(readResourceResult, WEBSOCKET));
        // sorted session ids (important for step 2!)
        ModelNode listSessionsResult = result.step(1).get(RESULT);
        List<String> sessionIds = listSessionsResult.isDefined() ? listSessionsResult.asList().stream().map(ModelNode::asString).sorted().collect(toList()) : Collections.emptyList();
        context.set(SERVLETS, servlets);
        context.set(WEBSOCKETS, websockets);
        context.set(SESSION_IDS, sessionIds);
    }).toCompletable();
    // task 2: read session creation and last access times
    Task<FlowContext> task2 = context -> {
        List<String> sessionIds = context.get(SESSION_IDS);
        if (sessionIds.isEmpty()) {
            context.set(SESSIONS, Collections.emptyList());
            return Completable.complete();
        } else {
            List<Operation> operations = new ArrayList<>();
            for (String id : sessionIds) {
                operations.add(new Operation.Builder(address, GET_SESSION_CREATION_TIME).param(SESSION_ID, id).build());
                operations.add(new Operation.Builder(address, GET_SESSION_LAST_ACCESSED_TIME).param(SESSION_ID, id).build());
            }
            return dispatcher.execute(new Composite(operations)).doOnSuccess((CompositeResult result) -> {
                int i = 0;
                List<Session> sessions = new ArrayList<>();
                for (String sessionId : sessionIds) {
                    ModelNode modelNode = new ModelNode();
                    if (result.step(i).isDefined() && result.step(i).get(RESULT).isDefined()) {
                        modelNode.get(CREATION_TIME).set(result.step(i).get(RESULT));
                    }
                    i++;
                    if (result.step(i).isDefined() && result.step(i).get(RESULT).isDefined()) {
                        modelNode.get(LAST_ACCESSED_TIME).set(result.step(i).get(RESULT));
                    }
                    i++;
                    sessions.add(new Session(sessionId, modelNode));
                }
                context.set(SESSIONS, sessions);
            }).toCompletable();
        }
    };
    series(new FlowContext(progress.get()), task1, task2).subscribe(new SuccessfulOutcome<FlowContext>(getEventBus(), resources) {

        @Override
        public void onSuccess(FlowContext context) {
            List<Session> sessions = context.get(SESSIONS);
            List<NamedNode> servlets = context.get(SERVLETS);
            List<NamedNode> websockets = context.get(WEBSOCKETS);
            getView().updateSessions(sessions);
            getView().updateServlets(servlets);
            getView().updateWebsockets(websockets);
        }
    });
}
Also used : INCLUDE_RUNTIME(org.jboss.hal.dmr.ModelDescriptionConstants.INCLUDE_RUNTIME) LIST_SESSIONS(org.jboss.hal.dmr.ModelDescriptionConstants.LIST_SESSIONS) Provider(javax.inject.Provider) CREATION_TIME(org.jboss.hal.dmr.ModelDescriptionConstants.CREATION_TIME) StatementContext(org.jboss.hal.meta.StatementContext) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LAST_ACCESSED_TIME(org.jboss.hal.dmr.ModelDescriptionConstants.LAST_ACCESSED_TIME) Message(org.jboss.hal.spi.Message) READ_RESOURCE_OPERATION(org.jboss.hal.dmr.ModelDescriptionConstants.READ_RESOURCE_OPERATION) HasPresenter(org.jboss.hal.core.mvp.HasPresenter) Names(org.jboss.hal.resources.Names) LIST_SESSION_ATTRIBUTES(org.jboss.hal.dmr.ModelDescriptionConstants.LIST_SESSION_ATTRIBUTES) ModelNodeHelper.asNamedNodes(org.jboss.hal.dmr.ModelNodeHelper.asNamedNodes) NameToken(com.gwtplatform.mvp.client.annotations.NameToken) FinderPath(org.jboss.hal.core.finder.FinderPath) List(java.util.List) RESULT(org.jboss.hal.dmr.ModelDescriptionConstants.RESULT) WEB_SUBDEPLOYMENT_TEMPLATE(org.jboss.hal.client.runtime.subsystem.undertow.AddressTemplates.WEB_SUBDEPLOYMENT_TEMPLATE) HalView(org.jboss.hal.core.mvp.HalView) Flow.series(org.jboss.hal.flow.Flow.series) Finder(org.jboss.hal.core.finder.Finder) Footer(org.jboss.hal.spi.Footer) SupportsExpertMode(org.jboss.hal.core.mvp.SupportsExpertMode) ModelNode(org.jboss.hal.dmr.ModelNode) Completable(rx.Completable) MessageEvent(org.jboss.hal.spi.MessageEvent) ProxyPlace(com.gwtplatform.mvp.client.proxy.ProxyPlace) SuccessfulOutcome(org.jboss.hal.core.SuccessfulOutcome) FlowContext(org.jboss.hal.flow.FlowContext) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) Property(org.jboss.hal.dmr.Property) DEPLOYMENT(org.jboss.hal.dmr.ModelDescriptionConstants.DEPLOYMENT) Task(org.jboss.hal.flow.Task) WEB_DEPLOYMENT_ADDRESS(org.jboss.hal.client.runtime.subsystem.undertow.AddressTemplates.WEB_DEPLOYMENT_ADDRESS) Progress(org.jboss.hal.flow.Progress) INVALIDATE_SESSION(org.jboss.hal.dmr.ModelDescriptionConstants.INVALIDATE_SESSION) ApplicationFinderPresenter(org.jboss.hal.core.mvp.ApplicationFinderPresenter) Requires(org.jboss.hal.spi.Requires) RECURSIVE(org.jboss.hal.dmr.ModelDescriptionConstants.RECURSIVE) WEBSOCKET(org.jboss.hal.dmr.ModelDescriptionConstants.WEBSOCKET) GET_SESSION_CREATION_TIME(org.jboss.hal.dmr.ModelDescriptionConstants.GET_SESSION_CREATION_TIME) CompositeResult(org.jboss.hal.dmr.CompositeResult) ProxyCodeSplit(com.gwtplatform.mvp.client.annotations.ProxyCodeSplit) 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) SESSION_ID(org.jboss.hal.dmr.ModelDescriptionConstants.SESSION_ID) PlaceRequest(com.gwtplatform.mvp.shared.proxy.PlaceRequest) GET_SESSION_LAST_ACCESSED_TIME(org.jboss.hal.dmr.ModelDescriptionConstants.GET_SESSION_LAST_ACCESSED_TIME) DialogFactory(org.jboss.hal.ballroom.dialog.DialogFactory) WEB_DEPLOYMENT_TEMPLATE(org.jboss.hal.client.runtime.subsystem.undertow.AddressTemplates.WEB_DEPLOYMENT_TEMPLATE) SERVLET(org.jboss.hal.dmr.ModelDescriptionConstants.SERVLET) Composite(org.jboss.hal.dmr.Composite) SUBDEPLOYMENT(org.jboss.hal.dmr.ModelDescriptionConstants.SUBDEPLOYMENT) ModelNodeHelper.failSafePropertyList(org.jboss.hal.dmr.ModelNodeHelper.failSafePropertyList) Dispatcher(org.jboss.hal.dmr.dispatch.Dispatcher) Collectors.toList(java.util.stream.Collectors.toList) NameTokens(org.jboss.hal.meta.token.NameTokens) WEB_SUBDEPLOYMENT_ADDRESS(org.jboss.hal.client.runtime.subsystem.undertow.AddressTemplates.WEB_SUBDEPLOYMENT_ADDRESS) Resources(org.jboss.hal.resources.Resources) NamedNode(org.jboss.hal.dmr.NamedNode) UNDERTOW(org.jboss.hal.dmr.ModelDescriptionConstants.UNDERTOW) Collections(java.util.Collections) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) ArrayList(java.util.ArrayList) Operation(org.jboss.hal.dmr.Operation) FlowContext(org.jboss.hal.flow.FlowContext) List(java.util.List) ArrayList(java.util.ArrayList) ModelNodeHelper.failSafePropertyList(org.jboss.hal.dmr.ModelNodeHelper.failSafePropertyList) Collectors.toList(java.util.stream.Collectors.toList) ModelNode(org.jboss.hal.dmr.ModelNode)

Aggregations

EventBus (com.google.web.bindery.event.shared.EventBus)1 NameToken (com.gwtplatform.mvp.client.annotations.NameToken)1 ProxyCodeSplit (com.gwtplatform.mvp.client.annotations.ProxyCodeSplit)1 ProxyPlace (com.gwtplatform.mvp.client.proxy.ProxyPlace)1 PlaceRequest (com.gwtplatform.mvp.shared.proxy.PlaceRequest)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors.toList (java.util.stream.Collectors.toList)1 Inject (javax.inject.Inject)1 Provider (javax.inject.Provider)1 DialogFactory (org.jboss.hal.ballroom.dialog.DialogFactory)1 WEB_DEPLOYMENT_ADDRESS (org.jboss.hal.client.runtime.subsystem.undertow.AddressTemplates.WEB_DEPLOYMENT_ADDRESS)1 WEB_DEPLOYMENT_TEMPLATE (org.jboss.hal.client.runtime.subsystem.undertow.AddressTemplates.WEB_DEPLOYMENT_TEMPLATE)1 WEB_SUBDEPLOYMENT_ADDRESS (org.jboss.hal.client.runtime.subsystem.undertow.AddressTemplates.WEB_SUBDEPLOYMENT_ADDRESS)1 WEB_SUBDEPLOYMENT_TEMPLATE (org.jboss.hal.client.runtime.subsystem.undertow.AddressTemplates.WEB_SUBDEPLOYMENT_TEMPLATE)1 SuccessfulOutcome (org.jboss.hal.core.SuccessfulOutcome)1 Finder (org.jboss.hal.core.finder.Finder)1 FinderPath (org.jboss.hal.core.finder.FinderPath)1 FinderPathFactory (org.jboss.hal.core.finder.FinderPathFactory)1