Search in sources :

Example 16 with MetadataStorageManagerException

use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.

the class ZookeeperMetadataStorageManager method updateTableSpaceReplicaState.

@Override
public void updateTableSpaceReplicaState(TableSpaceReplicaState state) throws MetadataStorageManagerException {
    try {
        String tableSpacePath = tableSpacesReplicasPath + "/" + state.uuid;
        byte[] data = state.serialize();
        try {
            ensureZooKeeper().setData(tableSpacePath + "/" + state.nodeId, data, -1);
        } catch (KeeperException.NoNodeException notExists) {
            try {
                ensureZooKeeper().create(tableSpacePath, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
            } catch (KeeperException.NodeExistsException existsRoot) {
            }
            ensureZooKeeper().create(tableSpacePath + "/" + state.nodeId, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
        }
    } catch (InterruptedException | KeeperException | IOException err) {
        handleSessionExpiredError(err);
        throw new MetadataStorageManagerException(err);
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 17 with MetadataStorageManagerException

use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.

the class ZookeeperMetadataStorageManager method ensureDefaultTableSpace.

@Override
public void ensureDefaultTableSpace(String localNodeId) throws MetadataStorageManagerException {
    try {
        TableSpaceList list = listTablesSpaces();
        if (!list.tableSpaces.contains(TableSpace.DEFAULT)) {
            TableSpace tableSpace = TableSpace.builder().leader(localNodeId).replica(localNodeId).expectedReplicaCount(1).maxLeaderInactivityTime(0).name(TableSpace.DEFAULT).build();
            createTableSpaceNode(tableSpace);
        }
    } catch (TableSpaceAlreadyExistsException err) {
    // not a problem
    } catch (InterruptedException | KeeperException | IOException err) {
        handleSessionExpiredError(err);
        throw new MetadataStorageManagerException(err);
    }
}
Also used : TableSpaceAlreadyExistsException(herddb.model.TableSpaceAlreadyExistsException) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) TableSpace(herddb.model.TableSpace) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 18 with MetadataStorageManagerException

use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.

the class ZookeeperMetadataStorageManager method start.

@Override
@SuppressFBWarnings("RV_RETURN_VALUE_IGNORED")
public synchronized void start() throws MetadataStorageManagerException {
    if (started) {
        return;
    }
    LOGGER.log(Level.SEVERE, "start, zkAddress " + zkAddress + ", zkSessionTimeout:" + zkSessionTimeout + ", basePath:" + basePath);
    try {
        restartZooKeeper();
        ensureRoot();
        started = true;
    } catch (IOException | InterruptedException | KeeperException err) {
        throw new MetadataStorageManagerException(err);
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 19 with MetadataStorageManagerException

use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.

the class FileMetadataStorageManager 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 20 with MetadataStorageManagerException

use of herddb.metadata.MetadataStorageManagerException in project herddb by diennea.

the class SysnodesTableManager method buildVirtualRecordList.

@Override
protected Iterable<Record> buildVirtualRecordList() throws StatementExecutionException {
    try {
        Collection<NodeMetadata> nodes = tableSpaceManager.getMetadataStorageManager().listNodes();
        List<Record> result = new ArrayList<>();
        for (NodeMetadata t : nodes) {
            result.add(RecordSerializer.makeRecord(table, "nodeid", t.nodeId, "address", t.host + ":" + t.port, "ssl", t.ssl ? 1 : 0));
        }
        return result;
    } catch (MetadataStorageManagerException error) {
        throw new StatementExecutionException(error);
    }
}
Also used : NodeMetadata(herddb.model.NodeMetadata) MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) ArrayList(java.util.ArrayList) Record(herddb.model.Record) StatementExecutionException(herddb.model.StatementExecutionException)

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