Search in sources :

Example 31 with MetadataStorageManagerException

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

the class ZookeeperMetadataStorageManager method start.

public synchronized void start(boolean formatIfNeeded) throws MetadataStorageManagerException {
    if (started) {
        return;
    }
    LOGGER.log(Level.SEVERE, "start, zkAddress " + zkAddress + ", zkSessionTimeout:" + zkSessionTimeout + ", basePath:" + basePath);
    try {
        restartZooKeeper();
        if (formatIfNeeded) {
            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)

Example 32 with MetadataStorageManagerException

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

the class ZookeeperMetadataStorageManager method getTableSpaceReplicaState.

@Override
public List<TableSpaceReplicaState> getTableSpaceReplicaState(String tableSpaceUuid) throws MetadataStorageManagerException {
    try {
        List<String> children;
        try {
            children = ensureZooKeeper().getChildren(tableSpacesReplicasPath + "/" + tableSpaceUuid, false);
        } catch (KeeperException.NoNodeException err) {
            return Collections.emptyList();
        }
        List<TableSpaceReplicaState> result = new ArrayList<>();
        for (String child : children) {
            String path = tableSpacesReplicasPath + "/" + tableSpaceUuid + "/" + child;
            try {
                byte[] data = ensureZooKeeper().getData(path, false, null);
                TableSpaceReplicaState nodeMetadata = TableSpaceReplicaState.deserialize(data);
                result.add(nodeMetadata);
            } catch (IOException deserializeError) {
                LOGGER.log(Level.SEVERE, "error reading " + path, deserializeError);
            }
        }
        return result;
    } catch (KeeperException | InterruptedException | IOException err) {
        handleSessionExpiredError(err);
        throw new MetadataStorageManagerException(err);
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) ArrayList(java.util.ArrayList) TableSpaceReplicaState(herddb.model.TableSpaceReplicaState) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 33 with MetadataStorageManagerException

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

the class ZookeeperMetadataStorageManager method describeTableSpace.

@Override
public TableSpace describeTableSpace(String name) throws MetadataStorageManagerException {
    name = name.toLowerCase();
    try {
        Stat stat = new Stat();
        byte[] result = ensureZooKeeper().getData(tableSpacesPath + "/" + name.toLowerCase(), mainWatcher, stat);
        return TableSpace.deserialize(result, stat.getVersion(), stat.getCtime());
    } catch (KeeperException.NoNodeException ex) {
        return null;
    } catch (KeeperException | InterruptedException | IOException ex) {
        handleSessionExpiredError(ex);
        throw new MetadataStorageManagerException(ex);
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) Stat(org.apache.zookeeper.data.Stat) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 34 with MetadataStorageManagerException

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

the class ZookeeperMetadataStorageManager method registerTableSpace.

@Override
public void registerTableSpace(TableSpace tableSpace) throws DDLException, MetadataStorageManagerException {
    try {
        createTableSpaceNode(tableSpace);
        notifyMetadataChanged("registerTableSpace " + tableSpace);
    } catch (KeeperException | InterruptedException | IOException ex) {
        handleSessionExpiredError(ex);
        throw new MetadataStorageManagerException(ex);
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 35 with MetadataStorageManagerException

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

the class ZookeeperMetadataStorageManager method clear.

@Override
public void clear() throws MetadataStorageManagerException {
    try {
        List<String> children = ensureZooKeeper().getChildren(nodesPath, false);
        for (String child : children) {
            ensureZooKeeper().delete(nodesPath + "/" + child, -1);
        }
        children = ensureZooKeeper().getChildren(tableSpacesPath, false);
        for (String child : children) {
            ensureZooKeeper().delete(tableSpacesPath + "/" + child, -1);
        }
        children = ensureZooKeeper().getChildren(ledgersPath, false);
        for (String child : children) {
            ensureZooKeeper().delete(ledgersPath + "/" + child, -1);
        }
    } catch (InterruptedException | KeeperException | IOException error) {
        LOGGER.log(Level.SEVERE, "Cannot clear metadata", error);
        throw new MetadataStorageManagerException(error);
    }
}
Also used : MetadataStorageManagerException(herddb.metadata.MetadataStorageManagerException) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

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