Search in sources :

Example 1 with HandleResult

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);
}
Also used : HandleResult(com.bonree.brfs.duplication.server.handler.HandleResult)

Example 2 with HandleResult

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);
}
Also used : StorageNameNode(com.bonree.brfs.duplication.storagename.StorageNameNode) HandleResult(com.bonree.brfs.duplication.server.handler.HandleResult) IOException(java.io.IOException)

Example 3 with HandleResult

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);
}
Also used : HandleResult(com.bonree.brfs.duplication.server.handler.HandleResult)

Example 4 with HandleResult

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);
}
Also used : StorageNameNode(com.bonree.brfs.duplication.storagename.StorageNameNode) HandleResult(com.bonree.brfs.duplication.server.handler.HandleResult) IOException(java.io.IOException)

Aggregations

HandleResult (com.bonree.brfs.duplication.server.handler.HandleResult)4 StorageNameNode (com.bonree.brfs.duplication.storagename.StorageNameNode)2 IOException (java.io.IOException)2