Search in sources :

Example 21 with MetadataStorageManagerException

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();
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) TableSpace(herddb.model.TableSpace) DDLException(herddb.model.DDLException)

Example 22 with MetadataStorageManagerException

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);
    }
}
Also used : TableSpace(herddb.model.TableSpace) ArrayList(java.util.ArrayList) StatementExecutionException(herddb.model.StatementExecutionException) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) Record(herddb.model.Record) TableSpaceReplicaState(herddb.model.TableSpaceReplicaState)

Example 23 with MetadataStorageManagerException

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);
    }
}
Also used : Path(java.nio.file.Path) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) IOException(java.io.IOException)

Example 24 with MetadataStorageManagerException

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);
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) IOException(java.io.IOException)

Example 25 with MetadataStorageManagerException

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();
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) TableSpace(herddb.model.TableSpace) DDLException(herddb.model.DDLException)

Aggregations

MetadataStorageManagerException (herddb.metadata.MetadataStorageManagerException)35 IOException (java.io.IOException)22 TableSpace (herddb.model.TableSpace)17 ArrayList (java.util.ArrayList)12 KeeperException (org.apache.zookeeper.KeeperException)12 StatementExecutionException (herddb.model.StatementExecutionException)11 DDLException (herddb.model.DDLException)9 NodeMetadata (herddb.model.NodeMetadata)7 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)4 Record (herddb.model.Record)4 ClientConfiguration (herddb.client.ClientConfiguration)3 HDBConnection (herddb.client.HDBConnection)3 LogNotAvailableException (herddb.log.LogNotAvailableException)3 Table (herddb.model.Table)3 TableSpaceReplicaState (herddb.model.TableSpaceReplicaState)3 SQLPlannedOperationStatement (herddb.model.commands.SQLPlannedOperationStatement)3 ScanStatement (herddb.model.commands.ScanStatement)3 DataStorageManagerException (herddb.storage.DataStorageManagerException)3 Path (java.nio.file.Path)3 ExecutionException (java.util.concurrent.ExecutionException)3