private static final class ContainerBackupIndex.ContainerBackupIndexImplementation extends Object
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 File |
_file |
private Object |
_fileLock |
private static HashMap<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 |
ContainerBackupIndex.ContainerBackupIndexImplementation(File file) |
| Modifier and Type | Method and Description |
|---|---|
private void |
addReference() |
void |
appendContainerID(long containerID)
Fügt einen Container hinzu
|
static ContainerBackupIndex.ContainerBackupIndexImplementation |
createNewContainerBackupIndex(File path)
Erstellt eine neuen, leeren ContainerBackupIndexImplementation im angegebenen Verzeichnis.
|
static boolean |
deleteContainerBackupIndex(File path)
Löscht einen ContainerBackupIndex aus dem angegeben Verzeichnis
|
static ContainerBackupIndex.ContainerBackupIndexImplementation |
getContainerBackupIndex(File path)
Gibt eine ContainerBackupIndexImplementation aus einem angegebenen Verzeichnis zurück
|
static ContainerBackupIndex.ContainerBackupIndexImplementation |
getContainerBackupIndex(String path)
Gibt eine ContainerBackupIndexImplementation aus einem angegebenen Verzeichnis zurück
|
List<Long> |
getContainerIDs()
Gibt alle ContainerIDs im Index zurück
|
private static ContainerBackupIndex.ContainerBackupIndexImplementation |
getInstance(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,
RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
Markiert einen Container-Eintrag als ungültig
|
private boolean |
removeContainerIDInSortedArea(long containerID,
RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
Löscht einen Container-Eintrag aus dem sortierten Bereich
|
private boolean |
removeContainerIDInUnsortedArea(long containerID,
RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
Löscht einen Container-Eintrag aus dem unsortierten Bereich
|
private boolean |
removeContainerIDWithRebuild(long containerIdToRemove,
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) |
String |
toString() |
private static final int CURRENT_FILE_VERSION
private File _file
private final Object _fileLock
private static final int CONTAINER_TO_SAVE
private static final int CONTAINER_DELETED_FROM_INDEX
private static final HashMap<File,ContainerBackupIndex.ContainerBackupIndexImplementation> _openFiles
private int _referenceCount
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 ContainerBackupIndex.ContainerBackupIndexImplementation(File file)
private void addReference()
private void removeReference()
public static ContainerBackupIndex.ContainerBackupIndexImplementation getContainerBackupIndex(File path)
path - Verzeichnispublic static ContainerBackupIndex.ContainerBackupIndexImplementation getContainerBackupIndex(String path)
path - Verzeichnisprivate static ContainerBackupIndex.ContainerBackupIndexImplementation getInstance(File file)
file - Dateipublic static ContainerBackupIndex.ContainerBackupIndexImplementation createNewContainerBackupIndex(File path) throws IOException
path - VerzeichnisIOException - IO-Fehlerpublic static boolean deleteContainerBackupIndex(File path)
path - Verzeichnisprivate void reset()
throws IOException
IOException - IO-Fehlerpublic void appendContainerID(long containerID)
throws IOException
containerID - Container-IDIOException - IO-Fehlerpublic boolean removeContainerID(long containerID,
int mediumID)
throws IOException
containerID - ContainerID die zu entfernen ist.mediumID - MediumID im Header, die evtl. erhöht werden mussIOException - IO-Fehlerpublic int getMaxMedienID()
throws IOException
IOExceptionpublic void setMaxMedienID(int mediumID)
throws IOException
IOExceptionprivate boolean removeContainerIDFast(long containerID,
RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
throws IOException
containerID - ContainerIDrandomAccessFile - geöffnete DateinumOfSortedEntries - Anzahl Sortierte EinträgenumOfGaps - Anzahl ungültige EinträgeIOException - IO-Fehlerprivate boolean removeContainerIDInSortedArea(long containerID,
RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
throws IOException
containerID - ContainerIDrandomAccessFile - geöffnete DateinumOfSortedEntries - Anzahl Sortierte EinträgenumOfGaps - Anzahl ungültige EinträgeIOException - IO-Fehlerprivate boolean removeContainerIDInUnsortedArea(long containerID,
RandomAccessFile randomAccessFile,
int numOfSortedEntries,
int numOfGaps)
throws IOException
containerID - ContainerIDrandomAccessFile - geöffnete DateinumOfSortedEntries - Anzahl Sortierte EinträgenumOfGaps - Anzahl ungültige EinträgeIOException - IO-Fehlerprivate boolean removeContainerIDWithRebuild(long containerIdToRemove,
RandomAccessFile randomAccessFile)
throws IOException
containerIdToRemove - ContainerIDrandomAccessFile - geöffnete DateiIOException - IO-Fehlerpublic List<Long> getContainerIDs() throws IOException
IOException - IO-Fehler