private static final class ContainerBackupIndex.ContainerBackupIndexImplementation
extends java.lang.Object
Eigentliche Implementierung des ContainerBackupIndex. wird von der ContainerBackupIndex
-Klasse gekapselt um einen sicheren Referenzzähler zu ermöglichen. Zu den Zwecken der Threadsicherheit wird für jede ContainerBackupIndex-Datei maximal eine Instanz erzeugt und verwaltet. Jede Instanz kann von mehreren ContainerBackupIndex-Objekten verwendet werden. Zu diesem Zweck implementiert diese Klasse einen Referenzzähler.
Modifier and Type | Class and Description |
---|---|
private static class |
ContainerBackupIndex.ContainerBackupIndexImplementation.IndexEntry
Hilfsklasse die einen einzelnen Dateneintrag speichert.
|
Modifier and Type | Field and Description |
---|---|
private java.io.File |
_file |
private java.lang.Object |
_fileLock |
private static java.util.HashMap<java.io.File,ContainerBackupIndex.ContainerBackupIndexImplementation> |
_openFiles
Aus Synchronitätsgründen muss sichergestellt sein, dass wenn eine Indexdatei an zwei verschiedenen Stellen gleichzeitig angefragt wird, beide Threads das selbe Objekt erhalten.
|
private int |
_referenceCount
Anzahl der Referenzen
|
private static int |
CONTAINER_DELETED_FROM_INDEX
Markiert einen ungültigen Index-Eintrag.
|
private static int |
CONTAINER_TO_SAVE
Legt fest, dass der Container im Index geschlossen ist und gesichert werden kann (z.B. wenn die Parametrierung es verlangt)
|
private static int |
CURRENT_FILE_VERSION |
private static int |
ENTRY_SIZE |
private static int |
HEADER_MEDIUM_ID_SIZE |
private static int |
HEADER_NUM_GAPS_SIZE |
private static int |
HEADER_NUM_SORTED_ENTRIES_SIZE |
private static int |
HEADER_POS_MEDIUM_ID |
private static int |
HEADER_POS_NUM_GAPS |
private static int |
HEADER_POS_NUM_SORTED_ENTRIES |
private static int |
HEADER_SIZE |
private static int |
HEADER_VERSION_SIZE |
private static int |
SIZE_BYTE |
private static int |
SIZE_INTEGER |
private static int |
SIZE_LONG |
Modifier | Constructor and Description |
---|---|
private |
ContainerBackupIndexImplementation(java.io.File file) |
Modifier and Type | Method and Description |
---|---|
private void |
addReference() |
void |
appendContainerID(long containerID)
Fügt einen Container hinzu
|
boolean |
containsContainerID(long containerID)
Gibt zurück, ob eine Container-ID im Index enthalten ist
|
private boolean |
containsContainerID(long containerID,
java.io.RandomAccessFile randomAccessFile,
int numOfSortedEntries)
Markiert einen Container-Eintrag als ungültig
|
private boolean |
containsContainerIDInSortedArea(long containerID,
java.io.RandomAccessFile randomAccessFile,
int numOfSortedEntries)
Löscht einen Container-Eintrag aus dem sortierten Bereich
|
private boolean |
containsContainerIDInUnsortedArea(long containerID,
java.io.RandomAccessFile randomAccessFile,
int numOfSortedEntries)
Löscht einen Container-Eintrag aus dem unsortierten Bereich
|
static ContainerBackupIndex.ContainerBackupIndexImplementation |
createNewContainerBackupIndex(java.io.File path)
Erstellt eine neuen, leeren ContainerBackupIndexImplementation im angegebenen Verzeichnis.
|
static boolean |
deleteContainerBackupIndex(java.io.File path)
Löscht einen ContainerBackupIndex aus dem angegeben Verzeichnis
|
static ContainerBackupIndex.ContainerBackupIndexImplementation |
getContainerBackupIndex(java.io.File path)
Gibt eine ContainerBackupIndexImplementation aus einem angegebenen Verzeichnis zurück
|
static ContainerBackupIndex.ContainerBackupIndexImplementation |
getContainerBackupIndex(java.lang.String path)
Gibt eine ContainerBackupIndexImplementation aus einem angegebenen Verzeichnis zurück
|
java.util.List<java.lang.Long> |
getContainerIDs()
Gibt alle ContainerIDs im Index zurück
|
private static ContainerBackupIndex.ContainerBackupIndexImplementation |
getInstance(java.io.File file)
Holt zu einer angegebenen Datei eine ContainerBackupIndexImplementation-Instanz.
|
int |
getMaxMedienID() |
boolean |
removeContainerID(long containerID,
int mediumID)
Entfernt eine ContainerID aus dem Index
|
private boolean |
removeContainerIDFast(long containerID,
java.io.RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
Markiert einen Container-Eintrag als ungültig
|
private boolean |
removeContainerIDInSortedArea(long containerID,
java.io.RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
Löscht einen Container-Eintrag aus dem sortierten Bereich
|
private boolean |
removeContainerIDInUnsortedArea(long containerID,
java.io.RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
Löscht einen Container-Eintrag aus dem unsortierten Bereich
|
private boolean |
removeContainerIDWithRebuild(long containerIdToRemove,
java.io.RandomAccessFile randomAccessFile)
Löscht einen Container-Eintrag aus der Datei und sortiert dabei den kompletten Datenbereich neu
|
private void |
removeReference() |
private void |
reset()
Entfernt alle Daten aus der ContainerBackupIndexImplementation
|
void |
setMaxMedienID(int mediumID) |
java.lang.String |
toString() |
private static final int CURRENT_FILE_VERSION
private static final int CONTAINER_TO_SAVE
Legt fest, dass der Container im Index geschlossen ist und gesichert werden kann (z.B. wenn die Parametrierung es verlangt)
private static final int CONTAINER_DELETED_FROM_INDEX
Markiert einen ungültigen Index-Eintrag. Wenn ein Container aus dem Index gelöscht wird, wird er zunächst mit diesem Flag markiert Erst wenn die Anzahl der ungültigen Einträge einen bestimmten Wert überschreitet, wird die gesamte Datei neu geschrieben/komprimiert.
private static final java.util.HashMap<java.io.File,ContainerBackupIndex.ContainerBackupIndexImplementation> _openFiles
Aus Synchronitätsgründen muss sichergestellt sein, dass wenn eine Indexdatei an zwei verschiedenen Stellen gleichzeitig angefragt wird, beide Threads das selbe Objekt erhalten. Daher werden hier die offenen Indexdateien verwaltet.
private static final int SIZE_INTEGER
private static final int SIZE_BYTE
private static final int SIZE_LONG
private static final int HEADER_VERSION_SIZE
private static final int HEADER_MEDIUM_ID_SIZE
private static final int HEADER_NUM_SORTED_ENTRIES_SIZE
private static final int HEADER_NUM_GAPS_SIZE
private static final int HEADER_POS_MEDIUM_ID
private static final int HEADER_POS_NUM_SORTED_ENTRIES
private static final int HEADER_POS_NUM_GAPS
private static final int HEADER_SIZE
private static final int ENTRY_SIZE
private final java.lang.Object _fileLock
private java.io.File _file
private int _referenceCount
Anzahl der Referenzen
private ContainerBackupIndexImplementation(java.io.File file)
public static ContainerBackupIndex.ContainerBackupIndexImplementation getContainerBackupIndex(java.io.File path)
Gibt eine ContainerBackupIndexImplementation aus einem angegebenen Verzeichnis zurück
path
- Verzeichnispublic static ContainerBackupIndex.ContainerBackupIndexImplementation getContainerBackupIndex(java.lang.String path)
Gibt eine ContainerBackupIndexImplementation aus einem angegebenen Verzeichnis zurück
path
- Verzeichnisprivate static ContainerBackupIndex.ContainerBackupIndexImplementation getInstance(java.io.File file)
Holt zu einer angegebenen Datei eine ContainerBackupIndexImplementation-Instanz. Entweder aus der _openFiles-HashMap oder es wird ein neues Objekt erstellt
file
- Dateipublic static ContainerBackupIndex.ContainerBackupIndexImplementation createNewContainerBackupIndex(java.io.File path) throws java.io.IOException
Erstellt eine neuen, leeren ContainerBackupIndexImplementation im angegebenen Verzeichnis. Ein eventuell bereits vorhandener wird überschrieben.
path
- Verzeichnisjava.io.IOException
- IO-Fehlerpublic static boolean deleteContainerBackupIndex(java.io.File path)
Löscht einen ContainerBackupIndex aus dem angegeben Verzeichnis
path
- Verzeichnisprivate void addReference()
private void removeReference()
private void reset() throws java.io.IOException
Entfernt alle Daten aus der ContainerBackupIndexImplementation
java.io.IOException
- IO-Fehlerpublic void appendContainerID(long containerID) throws java.io.IOException
Fügt einen Container hinzu
containerID
- Container-IDjava.io.IOException
- IO-Fehlerpublic boolean removeContainerID(long containerID, int mediumID) throws java.io.IOException
Entfernt eine ContainerID aus dem Index
containerID
- ContainerID die zu entfernen ist.mediumID
- MediumID im Header, die evtl. erhöht werden mussjava.io.IOException
- IO-Fehlerpublic boolean containsContainerID(long containerID) throws java.io.IOException
Gibt zurück, ob eine Container-ID im Index enthalten ist
containerID
- ContainerID die zu entfernen ist.java.io.IOException
- IO-Fehlerpublic int getMaxMedienID() throws java.io.IOException
java.io.IOException
public void setMaxMedienID(int mediumID) throws java.io.IOException
java.io.IOException
private boolean removeContainerIDFast(long containerID, java.io.RandomAccessFile randomAccessFile, int numOfSortedEntries, int numOfGaps) throws java.io.IOException
Markiert einen Container-Eintrag als ungültig
containerID
- ContainerIDrandomAccessFile
- geöffnete DateinumOfSortedEntries
- Anzahl Sortierte EinträgenumOfGaps
- Anzahl ungültige Einträgejava.io.IOException
- IO-Fehlerprivate boolean containsContainerID(long containerID, java.io.RandomAccessFile randomAccessFile, int numOfSortedEntries) throws java.io.IOException
Markiert einen Container-Eintrag als ungültig
containerID
- ContainerIDrandomAccessFile
- geöffnete DateinumOfSortedEntries
- Anzahl Sortierte Einträgejava.io.IOException
- IO-Fehlerprivate boolean containsContainerIDInSortedArea(long containerID, java.io.RandomAccessFile randomAccessFile, int numOfSortedEntries) throws java.io.IOException
Löscht einen Container-Eintrag aus dem sortierten Bereich
containerID
- ContainerIDrandomAccessFile
- geöffnete DateinumOfSortedEntries
- Anzahl Sortierte Einträgejava.io.IOException
- IO-Fehlerprivate boolean containsContainerIDInUnsortedArea(long containerID, java.io.RandomAccessFile randomAccessFile, int numOfSortedEntries) throws java.io.IOException
Löscht einen Container-Eintrag aus dem unsortierten Bereich
containerID
- ContainerIDrandomAccessFile
- geöffnete DateinumOfSortedEntries
- Anzahl Sortierte Einträgejava.io.IOException
- IO-Fehlerprivate boolean removeContainerIDInSortedArea(long containerID, java.io.RandomAccessFile randomAccessFile, int numOfSortedEntries, int numOfGaps) throws java.io.IOException
Löscht einen Container-Eintrag aus dem sortierten Bereich
containerID
- ContainerIDrandomAccessFile
- geöffnete DateinumOfSortedEntries
- Anzahl Sortierte EinträgenumOfGaps
- Anzahl ungültige Einträgejava.io.IOException
- IO-Fehlerprivate boolean removeContainerIDInUnsortedArea(long containerID, java.io.RandomAccessFile randomAccessFile, int numOfSortedEntries, int numOfGaps) throws java.io.IOException
Löscht einen Container-Eintrag aus dem unsortierten Bereich
containerID
- ContainerIDrandomAccessFile
- geöffnete DateinumOfSortedEntries
- Anzahl Sortierte EinträgenumOfGaps
- Anzahl ungültige Einträgejava.io.IOException
- IO-Fehlerprivate boolean removeContainerIDWithRebuild(long containerIdToRemove, java.io.RandomAccessFile randomAccessFile) throws java.io.IOException
Löscht einen Container-Eintrag aus der Datei und sortiert dabei den kompletten Datenbereich neu
containerIdToRemove
- ContainerIDrandomAccessFile
- geöffnete Dateijava.io.IOException
- IO-Fehlerpublic java.lang.String toString()
toString
in class java.lang.Object
public java.util.List<java.lang.Long> getContainerIDs() throws java.io.IOException
Gibt alle ContainerIDs im Index zurück
java.io.IOException
- IO-Fehler