use of com.bonree.brfs.duplication.storageregion.exception.StorageNameExistException in project BRFS by zhangnianli.
the class DefaultStorageRegionManager method createStorageRegion.
@Override
public StorageRegion createStorageRegion(String regionName, StorageRegionConfig config) throws Exception {
if (exists(regionName)) {
throw new StorageNameExistException(regionName);
}
String regionPath = buildRegionPath(regionName);
try {
StorageRegion region = StorageRegion.newBuilder().setName(regionName).setId(idBuilder.createRegionId()).setCreateTime(System.currentTimeMillis()).setEnable(true).setReplicateNum(config.getReplicateNum()).setDataTtl(config.getDataTtl()).setFileCapacity(config.getFileCapacity()).setFilePartitionDuration(config.getFilePartitionDuration()).build();
zkClient.create().forPath(regionPath, JsonUtils.toJsonBytes(region));
return region;
} catch (NodeExistsException e) {
throw new StorageNameExistException(regionName);
} catch (Exception e) {
LOG.error("create storage name node error", e);
throw e;
}
}
Aggregations