use of com.bonree.brfs.duplication.storageregion.StorageRegionConfig in project BRFS by zhangnianli.
the class CreateStorageRegionMessageHandler method handleMessage.
@Override
public void handleMessage(StorageRegionMessage msg, HandleResultCallback callback) {
LOG.info("create storage region[{}] with attrs {}", msg.getName(), msg.getAttributes());
try {
StorageRegionConfig config = new StorageRegionConfig();
config.update(msg.getAttributes());
StorageRegion node = storageRegionManager.createStorageRegion(msg.getName(), config);
LOG.info("created region[{}]", node);
callback.completed(new HandleResult(true));
} catch (Exception e) {
callback.completed(new HandleResult(false));
}
}
use of com.bonree.brfs.duplication.storageregion.StorageRegionConfig in project BRFS by zhangnianli.
the class UpdateStorageRegionMessageHandler method handleMessage.
@Override
public void handleMessage(StorageRegionMessage msg, HandleResultCallback callback) {
LOG.info("update storage region[{}] with attrs {}", msg.getName(), msg.getAttributes());
StorageRegion region = storageRegionManager.findStorageRegionByName(msg.getName());
if (region == null) {
callback.completed(new HandleResult(false));
return;
}
try {
StorageRegionConfig config = new StorageRegionConfig(region);
config.update(msg.getAttributes());
storageRegionManager.updateStorageRegion(msg.getName(), config);
callback.completed(new HandleResult(true));
} catch (Exception e) {
LOG.error("remove nonexist storage region");
callback.completed(new HandleResult(false));
}
}
Aggregations