use of com.bonree.brfs.duplication.server.handler.HandleResult in project BRFS by zhangnianli.
the class DeleteStorageNameMessageHandler method handle.
@Override
public void handle(StorageNameMessage msg, HandleResultCallback callback) {
boolean deleted = storageNameManager.removeStorageName(msg.getName());
HandleResult result = new HandleResult();
result.setSuccess(deleted);
if (!deleted) {
result.setData(StringUtils.toUtf8Bytes("errorCode:224"));
}
callback.completed(result);
}
use of com.bonree.brfs.duplication.server.handler.HandleResult in project BRFS by zhangnianli.
the class OpenStorageNameMessageHandler method handle.
@Override
public void handle(StorageNameMessage msg, HandleResultCallback callback) {
StorageNameNode node = storageNameManager.findStorageName(msg.getName());
HandleResult result = new HandleResult();
if (node == null) {
result.setSuccess(false);
result.setData(StringUtils.toUtf8Bytes("errorCode:225"));
} else {
result.setSuccess(true);
byte[] nodeBytes = null;
try {
nodeBytes = ProtoStuffUtils.serialize(node);
} catch (IOException e) {
e.printStackTrace();
}
result.setData(nodeBytes);
}
callback.completed(result);
}
use of com.bonree.brfs.duplication.server.handler.HandleResult in project BRFS by zhangnianli.
the class UpdateStorageNameMessageHandler method handle.
@Override
public void handle(StorageNameMessage msg, HandleResultCallback callback) {
boolean success = storageNameManager.updateStorageName(msg.getName(), msg.getTtl());
HandleResult result = new HandleResult();
result.setSuccess(success);
if (!success) {
result.setData(StringUtils.toUtf8Bytes("errorCode:223"));
}
callback.completed(result);
}
use of com.bonree.brfs.duplication.server.handler.HandleResult in project BRFS by zhangnianli.
the class CreateStorageNameMessageHandler method handle.
@Override
public void handle(StorageNameMessage msg, HandleResultCallback callback) {
StorageNameNode node = storageNameManager.createStorageName(msg.getName(), msg.getReplicas(), msg.getTtl());
HandleResult result = new HandleResult();
if (node == null) {
result.setSuccess(false);
result.setData(StringUtils.toUtf8Bytes("errorCode:222"));
} else {
result.setSuccess(true);
byte[] nodeBytes = null;
try {
nodeBytes = ProtoStuffUtils.serialize(node);
} catch (IOException e) {
e.printStackTrace();
}
result.setData(nodeBytes);
}
callback.completed(result);
}
Aggregations