Search in sources :

Example 1 with CachesStateInformationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CachesStateInformationType in project midpoint by Evolveum.

the class InternalsCachePanel method getCacheInformation.

private String getCacheInformation() {
    StringBuilder sb = new StringBuilder();
    CachesStateInformationType state = MidPointApplication.get().getCacheRegistry().getStateInformation();
    List<KeyValueTreeNode<String, SizeInformation>> trees = new ArrayList<>();
    for (SingleCacheStateInformationType entry : state.getEntry()) {
        KeyValueTreeNode<String, SizeInformation> root = new KeyValueTreeNode<>(entry.getName(), new SizeInformation(entry));
        trees.add(root);
        addComponents(root, entry.getComponent());
    }
    Holder<Integer> maxLabelLength = new Holder<>(0);
    // to avoid issues with log10
    Holder<Integer> maxSize = new Holder<>(1);
    // to avoid issues with log10
    Holder<Integer> maxSecondarySize = new Holder<>(1);
    trees.forEach(tree -> tree.acceptDepthFirst(node -> {
        int labelLength = node.getUserObject().getKey().length() + node.getDepth() * 2;
        int size = node.getUserObject().getValue().size;
        int secondarySize = node.getUserObject().getValue().secondarySize;
        if (labelLength > maxLabelLength.getValue()) {
            maxLabelLength.setValue(labelLength);
        }
        if (size > maxSize.getValue()) {
            maxSize.setValue(size);
        }
        if (secondarySize > maxSecondarySize.getValue()) {
            maxSecondarySize.setValue(secondarySize);
        }
    }));
    int labelSize = Math.max(maxLabelLength.getValue() + 1, 30);
    int sizeSize = Math.max((int) Math.log10(maxSize.getValue()) + 2, 7);
    int secondarySizeSize = Math.max((int) Math.log10(maxSecondarySize.getValue()) + 2, 8);
    int firstPart = labelSize + 3;
    int secondPart = sizeSize + 2;
    int thirdPart = secondarySizeSize + 3;
    String headerFormatString = "  %-" + labelSize + "s | %" + sizeSize + "s | %" + secondarySizeSize + "s\n";
    String valueFormatString = "  %-" + labelSize + "s | %" + sizeSize + "d | %" + secondarySizeSize + "s\n";
    sb.append("\n");
    sb.append(String.format(headerFormatString, "Cache", "Size", "Sec. size"));
    sb.append(StringUtils.repeat("=", firstPart)).append("+").append(StringUtils.repeat("=", secondPart)).append("+").append(StringUtils.repeat("=", thirdPart)).append("\n");
    trees.forEach(tree -> {
        tree.acceptDepthFirst(node -> printNode(sb, valueFormatString, node));
        sb.append(StringUtils.repeat("-", firstPart)).append("+").append(StringUtils.repeat("-", secondPart)).append("+").append(StringUtils.repeat("-", thirdPart)).append("\n");
    });
    return sb.toString();
}
Also used : Holder(com.evolveum.midpoint.util.Holder) SingleCacheStateInformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Trace(com.evolveum.midpoint.util.logging.Trace) ObjectUtils.defaultIfNull(org.apache.commons.lang3.ObjectUtils.defaultIfNull) TreeNode(com.evolveum.midpoint.util.TreeNode) StringUtils(org.apache.commons.lang3.StringUtils) MidPointApplication(com.evolveum.midpoint.web.security.MidPointApplication) CachesStateInformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachesStateInformationType) ComponentSizeInformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ComponentSizeInformationType) ArrayList(java.util.ArrayList) List(java.util.List) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) Pair(org.apache.commons.lang3.tuple.Pair) AceEditor(com.evolveum.midpoint.web.component.AceEditor) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) KeyValueTreeNode(com.evolveum.midpoint.util.KeyValueTreeNode) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) KeyValueTreeNode(com.evolveum.midpoint.util.KeyValueTreeNode) Holder(com.evolveum.midpoint.util.Holder) ArrayList(java.util.ArrayList) CachesStateInformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachesStateInformationType) SingleCacheStateInformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType)

Example 2 with CachesStateInformationType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.CachesStateInformationType in project midpoint by Evolveum.

the class CacheRegistryImpl method getStateInformation.

@Override
public CachesStateInformationType getStateInformation() {
    CachesStateInformationType rv = new CachesStateInformationType(prismContext);
    caches.forEach(cache -> rv.getEntry().addAll(cache.getStateInformation()));
    return rv;
}
Also used : CachesStateInformationType(com.evolveum.midpoint.xml.ns._public.common.common_3.CachesStateInformationType)

Aggregations

CachesStateInformationType (com.evolveum.midpoint.xml.ns._public.common.common_3.CachesStateInformationType)2 BasePanel (com.evolveum.midpoint.gui.api.component.BasePanel)1 Holder (com.evolveum.midpoint.util.Holder)1 KeyValueTreeNode (com.evolveum.midpoint.util.KeyValueTreeNode)1 TreeNode (com.evolveum.midpoint.util.TreeNode)1 Trace (com.evolveum.midpoint.util.logging.Trace)1 TraceManager (com.evolveum.midpoint.util.logging.TraceManager)1 AceEditor (com.evolveum.midpoint.web.component.AceEditor)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)1 ComponentSizeInformationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ComponentSizeInformationType)1 SingleCacheStateInformationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ObjectUtils.defaultIfNull (org.apache.commons.lang3.ObjectUtils.defaultIfNull)1 StringUtils (org.apache.commons.lang3.StringUtils)1 Pair (org.apache.commons.lang3.tuple.Pair)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 IModel (org.apache.wicket.model.IModel)1