Search in sources :

Example 1 with PreviewAttribute

use of org.jboss.hal.core.finder.PreviewAttributes.PreviewAttribute in project console by hal.

the class DeploymentPreview method hash.

void hash(PreviewAttributes<T> attributes, Deployment deployment) {
    // for compatibility reasons "content" is a list but there is only one element in it
    ModelNode content = deployment.get(CONTENT);
    byte[] hashBytes = content.get(0).get(HASH).asBytes();
    StringBuilder hashString = new StringBuilder();
    for (byte b : hashBytes) {
        int i = b;
        if (i < 0) {
            i = i & 0xff;
        }
        String hex = Integer.toHexString(i);
        if (hex.length() == 1) {
            hashString.append('0');
        }
        hashString.append(hex);
    }
    attributes.append(model -> new PreviewAttribute(labelBuilder.label(HASH), hashString.toString()));
}
Also used : PreviewAttribute(org.jboss.hal.core.finder.PreviewAttributes.PreviewAttribute) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 2 with PreviewAttribute

use of org.jboss.hal.core.finder.PreviewAttributes.PreviewAttribute in project console by hal.

the class WorkerPreview method update.

@Override
public void update(NamedNode worker) {
    ResourceAddress address = WORKER_TEMPLATE.resolve(statementContext, worker.getName());
    Operation operation = new Operation.Builder(address, READ_RESOURCE_OPERATION).param(INCLUDE_RUNTIME, true).param(RECURSIVE, true).build();
    dispatcher.execute(operation, result -> {
        corePoolSize.update(result.get(CORE_POOL_SIZE).asLong(), result.get(TASK_MAX_THREADS).asLong());
        maxPoolSize.update(result.get(MAX_POOL_SIZE).asLong(), result.get(TASK_MAX_THREADS).asLong());
        busyWorkerThreadCount.update(result.get(BUSY_WORKER_THREAD_COUNT).asLong(), result.get(TASK_MAX_THREADS).asLong());
        ioThreadCount.update(result.get(IO_THREAD_COUNT).asLong(), result.get(IO_THREADS).asLong());
        List<Property> serverConnections = failSafePropertyList(result, SERVER);
        Elements.removeChildrenFrom(connectionsContainer);
        if (!serverConnections.isEmpty()) {
            NamedNode dummy = new NamedNode(new ModelNode());
            PreviewAttributes<NamedNode> attributes = new PreviewAttributes<>(dummy, Names.CONNECTIONS);
            for (Property property : serverConnections) {
                ModelNode serverConnection = property.getValue();
                attributes.append(unused -> {
                    int connectionCount = serverConnection.get(CONNECTION_COUNT).asInt();
                    int lowWaterMark = serverConnection.get(CONNECTION_LIMIT_LOW_WATER_MARK).asInt();
                    int highWaterMark = serverConnection.get(CONNECTION_LIMIT_HIGH_WATER_MARK).asInt();
                    HTMLElement element = span().add(span().title(labelBuilder.label(CONNECTION_COUNT)).textContent(String.valueOf(connectionCount))).add(// NON-NLS
                    span().style("color: " + PatternFly.colors.black500).add(" (").add(span().title(labelBuilder.label(CONNECTION_LIMIT_LOW_WATER_MARK)).textContent(String.valueOf(lowWaterMark))).add(" / ").add(span().title(labelBuilder.label(CONNECTION_LIMIT_HIGH_WATER_MARK)).textContent(String.valueOf(highWaterMark))).add(")")).element();
                    return new PreviewAttribute(property.getName(), element);
                });
            }
            attributes.forEach(connectionsContainer::appendChild);
        }
    });
}
Also used : HTMLElement(elemental2.dom.HTMLElement) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) PreviewAttributes(org.jboss.hal.core.finder.PreviewAttributes) NamedNode(org.jboss.hal.dmr.NamedNode) Operation(org.jboss.hal.dmr.Operation) PreviewAttribute(org.jboss.hal.core.finder.PreviewAttributes.PreviewAttribute) ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property)

Aggregations

PreviewAttribute (org.jboss.hal.core.finder.PreviewAttributes.PreviewAttribute)2 ModelNode (org.jboss.hal.dmr.ModelNode)2 HTMLElement (elemental2.dom.HTMLElement)1 PreviewAttributes (org.jboss.hal.core.finder.PreviewAttributes)1 NamedNode (org.jboss.hal.dmr.NamedNode)1 Operation (org.jboss.hal.dmr.Operation)1 Property (org.jboss.hal.dmr.Property)1 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)1