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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations