Search in sources :

Example 1 with StorageRegionConfig

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));
    }
}
Also used : StorageRegionConfig(com.bonree.brfs.duplication.storageregion.StorageRegionConfig) HandleResult(com.bonree.brfs.common.net.http.HandleResult) StorageRegion(com.bonree.brfs.duplication.storageregion.StorageRegion)

Example 2 with StorageRegionConfig

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));
    }
}
Also used : StorageRegionConfig(com.bonree.brfs.duplication.storageregion.StorageRegionConfig) HandleResult(com.bonree.brfs.common.net.http.HandleResult) StorageRegion(com.bonree.brfs.duplication.storageregion.StorageRegion)

Aggregations

HandleResult (com.bonree.brfs.common.net.http.HandleResult)2 StorageRegion (com.bonree.brfs.duplication.storageregion.StorageRegion)2 StorageRegionConfig (com.bonree.brfs.duplication.storageregion.StorageRegionConfig)2