Commit 06e879d1 authored by Jonathan Haas's avatar Jonathan Haas

Merge branch 'bugfix/speicher' into 'develop'

Telnetausgabe

See merge request ERZ/SWE_de.bsvrz.ars.ars!21
parents a746075f 41eadc02
......@@ -22,7 +22,7 @@ nerzswe {
//--------------------------------------------------------------------
// Abhängigkeiten
//--------------------------------------------------------------------
String kernsoftware_version = '3.12.0'
String kernsoftware_version = '3.13.0'
dependencies {
compile group: 'de.bsvrz.dav', name: 'de.bsvrz.dav.daf', version: kernsoftware_version
compile group: 'de.bsvrz.sys', name: 'de.bsvrz.sys.funclib.losb', version: kernsoftware_version
......@@ -33,7 +33,7 @@ dependencies {
compile group: 'de.bsvrz.sys', name: 'de.bsvrz.sys.funclib.commandLineArgs', version: kernsoftware_version
compile group: 'de.bsvrz.sys', name: 'de.bsvrz.sys.funclib.communicationStreams', version: kernsoftware_version
compile group: 'de.bsvrz.sys', name: 'de.bsvrz.sys.funclib.kappich', version: kernsoftware_version
compile group: 'com.google.guava', name: 'guava', version: '21.0'
compile group: 'com.google.guava', name: 'guava', version: '27.1-jre'
// Abhängigkeiten Integrationstests
testCompile group: 'de.kappich.pat', name: 'de.kappich.pat.testumg', version: kernsoftware_version
......
......@@ -33,6 +33,7 @@ import de.bsvrz.dav.daf.main.config.DataModel;
import de.bsvrz.sys.funclib.losb.exceptions.FailureException;
import de.bsvrz.sys.funclib.losb.exceptions.SenderException;
import de.bsvrz.sys.funclib.losb.kernsoftware.Sender;
import de.bsvrz.sys.funclib.losb.util.Util;
import org.junit.*;
import java.io.IOException;
......@@ -89,6 +90,7 @@ public class TestPidArchiveRequest extends ArchiveTest {
_daf=null;
}
_davTestEnvironment.stop();
Util.deleteDir(am.getArchivePath().toFile());
}
private void sendDataSets(final int i) throws Exception {
......
......@@ -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,8 @@ public class ArSCmdInterface {
}
);
subMenu.addCmd(new MemoryDumpCmd("Arbeitsspeicher-Analyse", "", 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.ContainerDirAction;
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 de.bsvrz.sys.funclib.losb.util.cmdinterface.CmdInterpreter}
*
* @param desc die Beschreibung
* @param help der Hilfetext
* @param archMgr Archivmanager
*/
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()));
if(stat.isPresent()) {
printlnPlain(stat.get().toString());
}
}
}
......@@ -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;
......@@ -248,7 +250,7 @@ public final class DataIdentNode {
public float getIndexFillRatio(ArchiveDataKind adk) {
ATimeMonotoneIndex idx = getATimeMonoIdx(adk);
return idx != null ? idx.memoryEntries() / idx.memoryCapacity() : -1;
return idx != null ? idx.memoryEntries() / (float)idx.memoryCapacity() : 0;
}
/**
......@@ -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;
}
......
......@@ -192,7 +192,7 @@ public class RestorePersDirTsk extends Task {
}
// maximale Archivzeit. Medien- und Container-ID ermitteln
DataIdentNode din = didTree.existsCreate(dataIdentification);
DataIdentNode din = new DataIdentNode(dataIdentification);
if(!din.indexesAssigned(archiveDataKind)) {
persMgr.assignIndexes(archiveDataKind, din);
}
......@@ -206,6 +206,7 @@ public class RestorePersDirTsk extends Task {
maxArchiveTime.updateAndGet(old -> Math.max(old, aTime));
maxMedienID.updateAndGet(old -> Math.max(old, medienID));
}
din.closeIndexes(archiveDataKind);
}
catch(Exception e) {
badDID.getAndIncrement();
......
......@@ -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