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