use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.
the class MemoryMetadataStorageManager method ensureDefaultTableSpace.
@Override
public void ensureDefaultTableSpace(String localNodeId) throws MetadataStorageManagerException {
lock.writeLock().lock();
try {
TableSpace exists = tableSpaces.get(TableSpace.DEFAULT);
if (exists == null) {
TableSpace defaultTableSpace = TableSpace.builder().leader(localNodeId).replica(localNodeId).name(TableSpace.DEFAULT).build();
registerTableSpace(defaultTableSpace);
}
} catch (DDLException err) {
throw new MetadataStorageManagerException(err);
} finally {
lock.writeLock().unlock();
}
}
use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.
the class SystablespacereplicastateTableManager method buildVirtualRecordList.
@Override
protected Iterable<Record> buildVirtualRecordList(Transaction transaction) throws StatementExecutionException {
try {
Collection<String> names = tableSpaceManager.getMetadataStorageManager().listTableSpaces();
long now = System.currentTimeMillis();
List<Record> result = new ArrayList<>();
for (String name : names) {
TableSpace t = tableSpaceManager.getMetadataStorageManager().describeTableSpace(name);
if (t != null) {
List<TableSpaceReplicaState> tableSpaceReplicaStates = tableSpaceManager.getMetadataStorageManager().getTableSpaceReplicaState(t.uuid);
for (TableSpaceReplicaState state : tableSpaceReplicaStates) {
result.add(RecordSerializer.makeRecord(table, "tablespace_name", t.name, "uuid", t.uuid, "nodeid", state.nodeId, "timestamp", new java.sql.Timestamp(state.timestamp), "maxleaderinactivitytime", t.maxLeaderInactivityTime, "inactivitytime", now - state.timestamp, "mode", TableSpaceReplicaState.modeToSQLString(state.mode)));
}
}
}
return result;
} catch (MetadataStorageManagerException error) {
throw new StatementExecutionException(error);
}
}
use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.
the class FileMetadataStorageManager method removeTableSpaceFromDisk.
private void removeTableSpaceFromDisk(String tableSpace) throws MetadataStorageManagerException {
try {
Path file = baseDirectory.resolve(tableSpace + ".metadata");
Files.deleteIfExists(file);
} catch (IOException error) {
throw new MetadataStorageManagerException(error);
}
}
use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.
the class FileMetadataStorageManager method start.
@Override
public void start() throws MetadataStorageManagerException {
if (started) {
return;
}
try {
Files.createDirectories(baseDirectory);
reloadFromDisk();
started = true;
} catch (IOException err) {
throw new MetadataStorageManagerException(err);
}
}
use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.
the class MemoryMetadataStorageManager method ensureDefaultTableSpace.
@Override
public boolean ensureDefaultTableSpace(String localNodeId, String initialReplicaList, long maxLeaderInactivityTime, int expectedReplicaCount) throws MetadataStorageManagerException {
lock.writeLock().lock();
try {
TableSpace exists = tableSpaces.get(TableSpace.DEFAULT);
if (exists == null) {
TableSpace defaultTableSpace = TableSpace.builder().leader(localNodeId).replica(localNodeId).name(TableSpace.DEFAULT).build();
registerTableSpace(defaultTableSpace);
return true;
} else {
return false;
}
} catch (DDLException err) {
throw new MetadataStorageManagerException(err);
} finally {
lock.writeLock().unlock();
}
}
Aggregations