Commit 20336dc4 authored by Jonathan Haas's avatar Jonathan Haas

Merge branch 'bugfix/findbugs' into 'develop'

Diverse Kosmetik-Korrekturen

See merge request ERZ/SWE_de.bsvrz.ars.ars!16
parents ae2f9c85 9e21922b
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match><Bug pattern="MS_MUTABLE_ARRAY"/></Match>
<Match><Bug pattern="MS_SHOULD_BE_FINAL"/></Match>
<!-- Tests -->
......
......@@ -111,7 +111,7 @@ public abstract class ArchiveTest {
/** Für die Methoden {@link #waitTillDone()} und {@link #iAmDone()} */
private boolean iAmDone = false;
protected String[] objs = ArchiveTestApplication.testObjectPids;
protected String[] objs = ArchiveTestApplication.getTestObjectPids();
/**
* @param time Anmeldezeit Quelle
......
......@@ -77,7 +77,7 @@ public class TestSubscriptionDelay {
_archiveApplication.archSettings(getStdSettings());
_archiveApplication.archContSettings(200, TEN_MB, ONE_DAY);
_archiveApplication.archParam(new ArSRemoteControl.ParamSatz(E, new ArSRemoteControl.Datenspez(Arrays.copyOf(_archiveApplication.testObjectPids, 100), TEST_ATG, TEST_ASP), new ArSRemoteControl.Einst(true, null, true, null, 2)));
_archiveApplication.archParam(new ArSRemoteControl.ParamSatz(E, new ArSRemoteControl.Datenspez(Arrays.copyOf(getTestObjectPids(), 100), TEST_ATG, TEST_ASP), new ArSRemoteControl.Einst(true, null, true, null, 2)));
long current = System.nanoTime();
_archiveApplication.startAndWaitUntilReady(); // Auf Fertigmeldung warten
......
......@@ -37,6 +37,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Paths;
/**
* JUnit-Test der Klasse {@link PersistenceManager}.
......@@ -68,7 +69,8 @@ public class TestPersistenceManagerRebuildIndex {
@Before
public void setUp() throws Exception {
tempDir = _davTestEnvironment.getTemporaryDirectory();
persistenceManager = new PersistenceManager(null, tempDir.getAbsolutePath() + File.separator + "archiv");
String archPath = Paths.get(tempDir.getAbsolutePath(), "archiv").toString();
persistenceManager = new PersistenceManager(null, archPath);
}
@After
......@@ -79,7 +81,8 @@ public class TestPersistenceManagerRebuildIndex {
/** Testet die Methode {@link PersistenceManager#getLastContainerID()}. */
@Test(timeout = 200000)
public void testRebuildIndex() throws IndexException, PersistenceException, IOException {
final String dataIdentificationPath = persistenceManager.getArchivePath() + File.separator + "obj309/obj622/obj474/obj381/obj862/obj255/atg291/asp700/sv0/oa";
final String dataIdentificationPath =
Paths.get(persistenceManager.getArchivePath(),"obj309/obj622/obj474/obj381/obj862/obj255/atg291/asp700/sv0/oa").toString();
final String[] allFiles = {
"dc0000000056564.dat", "dc0000000063573.dat", "dc0000000144288.dat", "dc0000000451336.dat", "dc0000000451338.dat",
......
......@@ -235,7 +235,7 @@ public class ArchiveTestApplication extends DafApplication<ArchiveManager> {
public static final String[] E = new String[0];
public static final String[] testObjectPids = new String[NUM_TESTMQ];
private static final String[] testObjectPids = new String[NUM_TESTMQ];
static {
for(int i = 0; i < testObjectPids.length; i++) {
......@@ -243,6 +243,10 @@ public class ArchiveTestApplication extends DafApplication<ArchiveManager> {
}
}
public static String[] getTestObjectPids() {
return testObjectPids.clone();
}
/**
* @param time Anmeldezeit Quelle
*
......
......@@ -52,12 +52,6 @@ import static de.bsvrz.ars.ars.persistence.ContainerFile.*;
*/
public class ArchiveDataSerializer {
/** Gibt an, ob gerade ein Performance-Test mit Dummy-Daten (um den Overhead durch Deserialisieren/Serialisieren zu vermeiden) läuft. */
public static boolean IS_PERFORMANCE_TEST = false;
/** Dummy-Daten für den Performance-Test. */
public static byte[] PERF_TESTDATA = null;
/**
* Referenz auf den tatsaechlichen, von {@link #serializeData(ResultData, long, Deflater)} verwendeten Puffer, der von {@link #writeBuf}
* abweicht, falls dieser zu klein ist). Notwendig, da Daten vorserialisiert werden müssen, um deren Länge zu bestimmen.
......@@ -100,10 +94,7 @@ public class ArchiveDataSerializer {
createWriteBuffers(); // Puffer (nur für schreibende Tasks) lazy anlegen
byte[] data;
if(IS_PERFORMANCE_TEST) {
data = PERF_TESTDATA;
}
else if(rd.hasData()) {
if(rd.hasData()) {
// normaler Datensatz
bos.reset();
try {
......@@ -130,7 +121,7 @@ public class ArchiveDataSerializer {
* @param desiredSize Gewuenschte PufferGröße
* @return Byte-Array-Puffer
*/
public static byte[] getBuf(byte[] defaultBuffer, int desiredSize) {
private static byte[] getBuf(byte[] defaultBuffer, int desiredSize) {
return (desiredSize <= defaultBuffer.length) ? defaultBuffer : new byte[desiredSize];
}
......@@ -156,7 +147,7 @@ public class ArchiveDataSerializer {
return NO_RIGHTS;
}
else {
return null;
throw new IllegalArgumentException("Unbekannter Zustand: " + rd.getDataState());
}
}
......
......@@ -55,6 +55,8 @@ public class TaskScheduler {
private static final ThreadLocal<DateFormat> dateFormat = ThreadLocal.withInitial(() -> new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"));
private static final int ONE_MINUTE = 60 * 1000;
private static final long ONE_HOUR = 60 * ONE_MINUTE;
private static Debug logger;
......@@ -117,13 +119,13 @@ public class TaskScheduler {
/** Startet den Timer, der die Tasks steuert */
public void start() {
// Timer zur nächsten vollen Minute starten
long start = ((System.currentTimeMillis() / 60000) * 60000 + 60000) - System.currentTimeMillis();
long start = ONE_MINUTE - (System.currentTimeMillis() % ONE_MINUTE);
start = start < 100 ? 0 : start;
timer.scheduleAtFixedRate(backupCronTask, start, ONE_MINUTE);
timer.scheduleAtFixedRate(deleteCronTask, start, ONE_MINUTE);
timer.scheduleAtFixedRate(deletePermanentlyCronTask, start, ONE_MINUTE);
timer.scheduleAtFixedRate(requestCronTask, start, ONE_MINUTE);
timer.scheduleAtFixedRate(saveUnsubscriptionTimeTask, start, 60 * ONE_MINUTE);
timer.scheduleAtFixedRate(saveUnsubscriptionTimeTask, start, ONE_HOUR);
}
......@@ -365,11 +367,11 @@ public class TaskScheduler {
if(capacityCheckInterval == 0) {
return "";
}
else if(capacityCheckInterval < (60 * ONE_MINUTE)) {
else if(capacityCheckInterval < ONE_HOUR) {
return (capacityCheckInterval / ONE_MINUTE) + " Minuten";
}
else {
return (capacityCheckInterval / (60 * ONE_MINUTE)) + " Stunden";
return (capacityCheckInterval / ONE_HOUR) + " Stunden";
}
}
......
......@@ -158,17 +158,6 @@ public class ContainerFile {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Wenn diese Methode aufgerufen wird, können keine Daten archiviert werden. Stattdessen werden Dummy-Daten mit bekannter Länge archiviert, um die
* Performance des Speichersystems testen zu können.
*
* @param testDat Daten, die pro Datensatz in die Container geschrieben werden.
*/
public static void prepareForPerformanceTest(byte[] testDat) {
ArchiveDataSerializer.IS_PERFORMANCE_TEST = true;
ArchiveDataSerializer.PERF_TESTDATA = testDat;
}
/*
* @see java.lang.Object#toString()
*/
......
......@@ -46,7 +46,6 @@ import de.bsvrz.ars.ars.persistence.index.backend.management.LongRange;
import de.bsvrz.ars.ars.persistence.index.result.IndexResult;
import de.bsvrz.ars.ars.persistence.iter.DataIterator;
import de.bsvrz.ars.ars.persistence.iter.DeletedTreatment;
import de.bsvrz.ars.ars.persistence.walk.ContainerAction;
import de.bsvrz.ars.ars.persistence.walk.internal.StatusPrinter;
import de.bsvrz.dav.daf.main.DataDescription;
import de.bsvrz.dav.daf.main.archive.ArchiveDataKind;
......@@ -1155,17 +1154,17 @@ public final class PersistenceManager {
return result;
}
private void deleteIndexFiles(final String didPath) throws PersistenceException {
File monoIdxIdxFile = new File(didPath, ATimeMonotoneIndex.IDX_FILENAME);
File dataTimeIdxFile = new File(didPath, DataTimeIndex.IDX_FILENAME);
File managementIdxFile = new File(didPath, ContainerManagementIndex.IDX_FILENAME);
private static void deleteIndexFiles(final String didPath) throws PersistenceException {
Path monoIdxIdxFile = Paths.get(didPath, ATimeMonotoneIndex.IDX_FILENAME);
Path dataTimeIdxFile = Paths.get(didPath, DataTimeIndex.IDX_FILENAME);
Path managementIdxFile = Paths.get(didPath, ContainerManagementIndex.IDX_FILENAME);
final boolean dataTimeIndexFileDeleted = Util.deleteIfExists(dataTimeIdxFile);
final boolean monoIdxIdxFileDeleted = Util.deleteIfExists(monoIdxIdxFile);
final boolean managementIdxFileDeleted = Util.deleteIfExists(managementIdxFile);
if(!monoIdxIdxFileDeleted || !dataTimeIndexFileDeleted || !managementIdxFileDeleted) {
throw new PersistenceException("Loeschen der alten Indexdateien fehlgeschlagen: " + didPath);
try {
Files.deleteIfExists(dataTimeIdxFile);
Files.deleteIfExists(monoIdxIdxFile);
Files.deleteIfExists(managementIdxFile);
} catch(IOException e) {
throw new PersistenceException("Loeschen der alten Indexdateien fehlgeschlagen: " + didPath, e);
}
}
......@@ -1772,14 +1771,15 @@ public final class PersistenceManager {
for(int i = 0; i < headers.size(); i++) {
if(headers.getBoolean(i, ContainerManagementInformation.CHP_DELETED)) {
long containerId = headers.get(i, ContainerManagementInformation.CHP_CONT_ID);
ContainerFileHandle handle = accessContainer(node, archiveDataKind, containerId);
if(!handle.existsContainer()) continue;
executeOnContainer(handle.getFile().toPath(), () -> {
handle.readContainerHeader();
// Datei öffnen und Datenindexbereiche in neue Datei übernehmen
deletedContainerFile.addDeletedContainer(handle);
contsToDelete.add(containerId);
});
try (ContainerFileHandle handle = accessContainer(node, archiveDataKind, containerId)) {
if(!handle.existsContainer()) continue;
executeOnContainer(handle.getFile().toPath(), () -> {
handle.readContainerHeader();
// Datei öffnen und Datenindexbereiche in neue Datei übernehmen
deletedContainerFile.addDeletedContainer(handle);
contsToDelete.add(containerId);
});
}
}
}
deletedContainerFile.write();
......
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