use of com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType 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();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType in project midpoint by Evolveum.
the class LocalRepoCacheCollection method getStateInformation.
public void getStateInformation(List<SingleCacheStateInformationType> rv) {
rv.add(new SingleCacheStateInformationType(prismContext).name(LocalObjectCache.class.getName()).size(LocalObjectCache.getTotalSize(LOCAL_OBJECT_CACHE_INSTANCE)));
rv.add(new SingleCacheStateInformationType(prismContext).name(LocalVersionCache.class.getName()).size(LocalVersionCache.getTotalSize(LOCAL_VERSION_CACHE_INSTANCE)));
rv.add(new SingleCacheStateInformationType(prismContext).name(LocalQueryCache.class.getName()).size(LocalQueryCache.getTotalSize(LOCAL_QUERY_CACHE_INSTANCE)).secondarySize(LocalQueryCache.getTotalCachedObjects(LOCAL_QUERY_CACHE_INSTANCE)));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType in project midpoint by Evolveum.
the class GlobalQueryCache method getStateInformation.
public Collection<SingleCacheStateInformationType> getStateInformation() {
Map<Class<?>, MutablePair<Integer, Integer>> counts = new HashMap<>();
AtomicInteger queries = new AtomicInteger(0);
AtomicInteger objects = new AtomicInteger(0);
if (cache != null) {
cache.invokeAll(cache.keys(), e -> {
QueryKey queryKey = e.getKey();
Class<?> objectType = queryKey.getType();
int resultingObjects = e.getValue().getResult().size();
MutablePair<Integer, Integer> value = counts.get(objectType);
if (value == null) {
value = new MutablePair<>(0, 0);
counts.put(objectType, value);
}
value.setLeft(value.getLeft() + 1);
value.setRight(value.getRight() + resultingObjects);
queries.incrementAndGet();
objects.addAndGet(resultingObjects);
return null;
});
SingleCacheStateInformationType info = new SingleCacheStateInformationType(prismContext).name(GlobalQueryCache.class.getName()).size(queries.get()).secondarySize(objects.get());
counts.forEach((type, pair) -> info.beginComponent().name(type.getSimpleName()).size(pair.getLeft()).secondarySize(pair.getRight()));
return Collections.singleton(info);
} else {
return Collections.emptySet();
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType in project midpoint by Evolveum.
the class GlobalObjectCache method getStateInformation.
public Collection<SingleCacheStateInformationType> getStateInformation() {
Map<Class<?>, Integer> counts = new HashMap<>();
AtomicInteger size = new AtomicInteger(0);
if (cache != null) {
cache.invokeAll(cache.keys(), e -> {
Class<?> objectType = e.getValue().getObjectType();
counts.compute(objectType, (type, count) -> count != null ? count + 1 : 1);
size.incrementAndGet();
return null;
});
SingleCacheStateInformationType info = new SingleCacheStateInformationType(prismContext).name(GlobalObjectCache.class.getName()).size(size.get());
counts.forEach((type, count) -> info.beginComponent().name(type.getSimpleName()).size(count));
return Collections.singleton(info);
} else {
return Collections.emptySet();
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SingleCacheStateInformationType in project midpoint by Evolveum.
the class GlobalVersionCache method getStateInformation.
public Collection<SingleCacheStateInformationType> getStateInformation() {
Map<Class<?>, Integer> counts = new HashMap<>();
AtomicInteger size = new AtomicInteger(0);
if (cache != null) {
cache.invokeAll(cache.keys(), e -> {
Class<?> objectType = e.getValue().getObjectType();
counts.compute(objectType, (type, count) -> count != null ? count + 1 : 1);
size.incrementAndGet();
return null;
});
SingleCacheStateInformationType info = new SingleCacheStateInformationType(prismContext).name(GlobalVersionCache.class.getName()).size(size.get());
counts.forEach((type, count) -> info.beginComponent().name(type.getSimpleName()).size(count));
return Collections.singleton(info);
} else {
return Collections.emptySet();
}
}
Aggregations