Commit 4ff1259e authored by Jonathan Haas's avatar Jonathan Haas

Memory-Info

parent a746075f
......@@ -791,6 +791,8 @@ public class ArchivConfig extends QueueTask<ArchivConfig.SubscrMarker> {
DataIdentTreeIterator it = didTree.createIterator();
ClientDavInterface davCon = archMgr.getDavCon();
_debug.warning(subscrMarker.toString());
long i = 0, t = Util.startTimer();
while(it.getNext()) {
if(shouldTerminate()) return;
......@@ -1135,7 +1137,7 @@ public class ArchivConfig extends QueueTask<ArchivConfig.SubscrMarker> {
* @param din
*/
public void newParamArch(DataIdentNode din) {
marker.put(din, SI_NEW_PARAM_ARCH);
marker.put(din, SI_NEW_PARAM_ARCH);
}
/**
......@@ -1231,8 +1233,14 @@ public class ArchivConfig extends QueueTask<ArchivConfig.SubscrMarker> {
/** Ausgabe der gespeicherten Markierungen. */
private void printStatistics() {
String text = toString();
if(text.equals("[]")) return;
_debug.info("An/Abmeldungen abgeschlossen:\n " + text);
}
public String toString() {
int newparam_arch = 0, newparam_noarch = 0, reparam_param = 0, reparam_subscr = 0, reparam_unsubscr = 0, unparam = 0, closeCont = 0;
if(marker.isEmpty()) return;
if(marker.isEmpty()) return "[]";
for(SubscrInfo si : marker.values()) {
if(si.kind == SubscrInfo.NEW_PARAM_ARCH) {
......@@ -1259,7 +1267,7 @@ public class ArchivConfig extends QueueTask<ArchivConfig.SubscrMarker> {
}
}
String text = "An/Abmeldungen abgeschlossen:\n " + Util.leadBlank(newparam_arch + newparam_noarch, 6) + " Zugaenge (" + newparam_arch + " arch / "
return Util.leadBlank(newparam_arch + newparam_noarch, 6) + " Zugaenge (" + newparam_arch + " arch / "
+ newparam_noarch + " noarch), " + unparam + " Abgaenge, " + (reparam_param + reparam_unsubscr + reparam_subscr) + " Aenderungen ("
+ reparam_subscr + "->arch / " + reparam_unsubscr + "->noarch / " + reparam_param + " andere)" + ", insgesamt " + marker.size() + "\n "
+ Util.leadBlank(closeCont, 6) + " Datenidentifikationen abzuschliessen" + "\n " + Util.leadBlank(subscrFaults, 6)
......@@ -1267,7 +1275,6 @@ public class ArchivConfig extends QueueTask<ArchivConfig.SubscrMarker> {
+ " Fehler bei Abmeldungen von Datenidentifikationen" + "\n " + Util.leadBlank(qSubscrTotal, 6) + " Anmeldungen von Quittierungen, davon "
+ qSubscrFault + " Fehler" + "\n " + Util.leadBlank(qUnsubscrTotal, 6) + " Abmeldungen von Quittierungen, davon " + qUnsubscrFault
+ " Fehler";
_debug.info(text);
}
}
......
......@@ -254,6 +254,9 @@ public class ArSCmdInterface {
}
);
subMenu.addCmd(new MemoryDumpCmd("Arbeitsspeicher", "", archMgr));
subMenu.addCmd(new MemoryDumpCmd("Festplattenspeicher", "", archMgr));
subMenu = new CmdMenu("System Info", "");
root.addNode(subMenu);
......
/*
* Copyright 2019 by Kappich Systemberatung Aachen
* ALL RIGHTS RESERVED.
*/
package de.bsvrz.ars.ars.mgmt.commands;
import com.google.common.collect.ImmutableList;
import de.bsvrz.ars.ars.mgmt.ArchiveManager;
import de.bsvrz.ars.ars.mgmt.datatree.DataIdentNode;
import de.bsvrz.ars.ars.mgmt.datatree.DataIdentTreeIterator;
import de.bsvrz.ars.ars.mgmt.datatree.Stat;
import de.bsvrz.ars.ars.persistence.ContainerFileDir;
import de.bsvrz.ars.ars.persistence.walk.ContainerDirCollector;
import de.bsvrz.ars.ars.persistence.walk.ContainerDirWalk;
import de.bsvrz.dav.daf.main.archive.ArchiveDataKindCombination;
import de.bsvrz.sys.funclib.losb.util.cmdinterface.Command;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* TBD Dokumentation
*
* @author Kappich Systemberatung
*/
public class MemoryDumpCmd extends Command {
private final ArchiveManager _archMgr;
/**
* Kommando für {@link CmdInterpreter}
* @param desc die Beschreibung
* @param help der Hilfetext
* @param archMgr
*/
public MemoryDumpCmd(final String desc, final String help, final ArchiveManager archMgr) {
super(desc, help);
_archMgr = archMgr;
}
@Override
public void execute() throws Exception {
ContainerDirWalk walk = ContainerDirWalk.create(_archMgr.getPersMgr(), _archMgr.getDataIdentTree(), ArchiveDataKindCombination.all());
Optional<Stat> stat = walk.collect(getDesc(), 10, (ContainerDirCollector<Stat>) (containerFileDir, builder) -> {
DataIdentNode dataIdentNode = containerFileDir.getDataIdentNode();
if(dataIdentNode == null) return;
builder.add(dataIdentNode.getMemoryStats());
}).reduce((a,b) -> new Stat(a.getIndexMem() + b.getIndexMem(), a.getManagementIndexMem() + b.getManagementIndexMem(), a.getCacheMemory() + b.getCacheMemory()));
stat.ifPresent(System.err::println);
}
}
......@@ -36,9 +36,11 @@ import de.bsvrz.ars.ars.persistence.index.*;
import de.bsvrz.ars.ars.persistence.index.backend.management.AbstractIndex;
import de.bsvrz.ars.ars.persistence.index.backend.management.IndexStartMode;
import de.bsvrz.ars.ars.persistence.index.backend.management.LongRange;
import de.bsvrz.ars.ars.persistence.index.backend.storage.HybridStorage;
import de.bsvrz.ars.ars.persistence.index.result.IndexResult;
import de.bsvrz.dav.daf.main.Data;
import de.bsvrz.dav.daf.main.archive.ArchiveDataKind;
import de.bsvrz.dav.daf.main.archive.ArchiveDataKindCombination;
import de.bsvrz.dav.daf.main.archive.ArchiveTimeSpecification;
import de.bsvrz.dav.daf.main.archive.TimingType;
import de.bsvrz.dav.daf.main.config.SystemObject;
......@@ -1394,4 +1396,37 @@ public final class DataIdentNode {
headerIdx.removeAll(ImmutableMap.of(ContainerManagementInformation.CHP_CONT_ID, new LongRange(containerId, containerId)));
}
}
public Stat getMemoryStats() {
long indexMem = getIndexMemory(_indexes);
long managementIndexMem = getIndexMemory(_containerHeaderIndexes);
long cacheMemory = 0;
for(ArchiveDataKind archiveDataKind : ArchiveDataKindCombination.all()) {
if(indexesAssigned(archiveDataKind)) {
long openContID;
try {
openContID = getOpenContID(archiveDataKind);
}
catch(IndexException ignored) {
continue;
}
CacheManager.Cache cache = CacheManager.getInstance().getCache(openContID);
if(cache == null) continue;
cacheMemory += cache.getBufferSize();
}
}
return new Stat(indexMem, managementIndexMem, cacheMemory);
}
public long getIndexMemory(final AbstractIndex<?>[] indexes) {
if(indexes == null) return 0L;
long indexMem;
indexMem = 0;
for(AbstractIndex<?> index : indexes) {
if(index == null) continue;
HybridStorage storage = index.getStorage();
indexMem += storage.memoryEntries() * storage.entryByteSize();
}
return indexMem;
}
}
/*
* Copyright 2019 by Kappich Systemberatung Aachen
* ALL RIGHTS RESERVED.
*/
package de.bsvrz.ars.ars.mgmt.datatree;
/**
* TBD Dokumentation
*
* @author Kappich Systemberatung
*/
public class Stat {
private final long _indexMem;
private final long _managementIndexMem;
private final long _cacheMemory;
public Stat(final long indexMem, final long managementIndexMem, final long cacheMemory) {
_indexMem = indexMem;
_managementIndexMem = managementIndexMem;
_cacheMemory = cacheMemory;
}
public long getIndexMem() {
return _indexMem;
}
public long getManagementIndexMem() {
return _managementIndexMem;
}
public long getCacheMemory() {
return _cacheMemory;
}
@Override
public String toString() {
return "Stat{" +
"_indexMem=" + _indexMem +
", _managementIndexMem=" + _managementIndexMem +
", _cacheMemory=" + _cacheMemory +
'}';
}
}
......@@ -261,9 +261,20 @@ public class CacheManager {
* @return Cache des Containers oder {@code null}, wenn der Container keinen Cache hat.
*/
public Cache getCache(final ContainerFile containerFile) {
if(DEBUG_CALLS) debugPrint("CacheManager.getCache " + containerFile.getContainerId());
return getCache(containerFile.getContainerId());
}
/**
* Liefert den Cache für den angegebenen Container zurück.
*
* @param containerId Container, dessen Cache bestimmt werden soll
*
* @return Cache des Containers oder {@code null}, wenn der Container keinen Cache hat.
*/
public Cache getCache(final long containerId) {
if(DEBUG_CALLS) debugPrint("CacheManager.getCache " + containerId);
synchronized(_containerId2Cache) {
return _containerId2Cache.get(containerFile.getContainerId());
return _containerId2Cache.get(containerId);
}
}
......@@ -452,7 +463,7 @@ public class CacheManager {
}
/** @return Kapazität des Zwischenspeichers in Byte */
int getBufferSize() {
public int getBufferSize() {
return _bufferSize;
}
......
......@@ -60,11 +60,13 @@ public class DataIdentTreeDirs implements ContainerDirGetter {
_persistenceManager = persistenceManager;
_dataIdentTreeIterator = new DataIdentTreeIterator(dataIdentTree);
_archiveDataKinds = new ArrayList<>(archiveDataKinds);
_dataIdentTreeIterator.getNext();
}
@Nullable
@Override
public ContainerFileDir poll() {
if(_dataIdentTreeIterator.getDataIdentNode() == null) return null;
if(_adkIndex == _archiveDataKinds.size()) {
_adkIndex = 0;
if(_dataIdentTreeIterator.getNext()) {
......@@ -73,8 +75,9 @@ public class DataIdentTreeDirs implements ContainerDirGetter {
return null;
}
else {
ContainerFileDir containerFileDir = new ContainerFileDir(_persistenceManager, _dataIdentTreeIterator.getDataIdentNode(), _archiveDataKinds.get(_adkIndex));
_adkIndex++;
return new ContainerFileDir(_persistenceManager, _dataIdentTreeIterator.getDataIdentNode(), _archiveDataKinds.get(_adkIndex));
return containerFileDir;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment