use of herddb.storage.DataStorageManagerException in project herddb by diennea.
the class FileDataStorageManager method readLogSequenceNumberFromTransactionsFile.
private static LogSequenceNumber readLogSequenceNumberFromTransactionsFile(String tableSpace, Path file) throws DataStorageManagerException {
try (InputStream input = new BufferedInputStream(Files.newInputStream(file, StandardOpenOption.READ), 4 * 1024 * 1024);
ExtendedDataInputStream din = new ExtendedDataInputStream(input)) {
// version
long version = din.readVLong();
// flags for future implementations
long flags = din.readVLong();
if (version != 1 || flags != 0) {
throw new DataStorageManagerException("corrupted transaction list file " + file.toAbsolutePath());
}
String readname = din.readUTF();
if (!readname.equals(tableSpace)) {
throw new DataStorageManagerException("file " + file.toAbsolutePath() + " is not for spablespace " + tableSpace);
}
long ledgerId = din.readZLong();
long offset = din.readZLong();
return new LogSequenceNumber(ledgerId, offset);
} catch (IOException err) {
throw new DataStorageManagerException(err);
}
}
use of herddb.storage.DataStorageManagerException in project herddb by diennea.
the class FileDataStorageManager method dropTable.
@Override
public void dropTable(String tablespace, String tableName) throws DataStorageManagerException {
LOGGER.log(Level.SEVERE, "dropTable {0}.{1}", new Object[] { tablespace, tableName });
Path tableDir = getTableDirectory(tablespace, tableName);
try {
deleteDirectory(tableDir);
} catch (IOException ex) {
throw new DataStorageManagerException(ex);
}
}
use of herddb.storage.DataStorageManagerException in project herddb by diennea.
the class FileDataStorageManager method getTableStatus.
@Override
public TableStatus getTableStatus(String tableSpace, String tableUuid, LogSequenceNumber sequenceNumber) throws DataStorageManagerException {
try {
Path dir = getTableDirectory(tableSpace, tableUuid);
Path checkpointFile = getTableCheckPointsFile(dir, sequenceNumber);
if (!Files.exists(checkpointFile)) {
throw new DataStorageManagerException("no such table checkpoint: " + checkpointFile);
}
return readTableStatusFromFile(checkpointFile);
} catch (IOException err) {
throw new DataStorageManagerException(err);
}
}
use of herddb.storage.DataStorageManagerException in project herddb by diennea.
the class FileDataStorageManager method getLastcheckpointSequenceNumber.
@Override
public LogSequenceNumber getLastcheckpointSequenceNumber(String tableSpace) throws DataStorageManagerException {
try {
Path tableSpaceDirectory = getTablespaceDirectory(tableSpace);
Files.createDirectories(tableSpaceDirectory);
LogSequenceNumber max = LogSequenceNumber.START_OF_TIME;
try (DirectoryStream<Path> stream = Files.newDirectoryStream(tableSpaceDirectory)) {
for (Path p : stream) {
if (isTablespaceCheckPointInfoFile(p)) {
try {
LogSequenceNumber logPositionInFile = readLogSequenceNumberFromCheckpointInfoFile(tableSpace, p);
if (logPositionInFile.after(max)) {
max = logPositionInFile;
}
} catch (DataStorageManagerException ignore) {
LOGGER.log(Level.SEVERE, "unparsable checkpoint info file " + p.toAbsolutePath(), ignore);
}
}
}
} catch (IOException err) {
LOGGER.log(Level.SEVERE, "Could not list dir " + tableSpaceDirectory, err);
}
return max;
} catch (IOException err) {
throw new DataStorageManagerException(err);
}
}
use of herddb.storage.DataStorageManagerException in project herddb by diennea.
the class FileDataStorageManager method start.
@Override
public void start() throws DataStorageManagerException {
try {
LOGGER.log(Level.SEVERE, "ensuring directory {0}", baseDirectory.toAbsolutePath().toString());
Files.createDirectories(baseDirectory);
LOGGER.log(Level.SEVERE, "preparing tmp directory {0}", tmpDirectory.toAbsolutePath().toString());
FileUtils.cleanDirectory(tmpDirectory);
Files.createDirectories(tmpDirectory);
} catch (IOException err) {
throw new DataStorageManagerException(err);
}
}
Aggregations