use of voldemort.VoldemortException in project voldemort by voldemort.
the class AdminServiceRequestHandler method handleSetMetadata.
public VAdminProto.UpdateMetadataResponse handleSetMetadata(VAdminProto.UpdateMetadataRequest request) {
VAdminProto.UpdateMetadataResponse.Builder response = VAdminProto.UpdateMetadataResponse.newBuilder();
try {
ByteArray keyBytes = ProtoUtils.decodeBytes(request.getKey());
String keyString = ByteUtils.getString(keyBytes.get(), "UTF-8");
if (MetadataStore.METADATA_KEYS.contains(keyString)) {
Versioned<byte[]> versionedValue = ProtoUtils.decodeVersioned(request.getVersioned());
logger.info("Updating metadata for key '" + keyString + "'");
metadataStore.validate(keyBytes, versionedValue, null);
metadataStore.put(keyBytes, versionedValue, null);
if (MetadataStore.CLUSTER_KEY.equals(keyString)) {
server.handleClusterUpdate();
} else if (MetadataStore.NODE_ID_KEY.endsWith(keyString)) {
server.refreshNodeIdFromMetadata();
}
logger.info("Successfully updated metadata for key '" + keyString + "'");
}
} catch (VoldemortException e) {
response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
logger.error("handleUpdateMetadata failed for request(" + request.toString() + ")", e);
}
return response.build();
}
use of voldemort.VoldemortException in project voldemort by voldemort.
the class AdminServiceRequestHandler method handleDeleteStoreRebalanceState.
private VAdminProto.DeleteStoreRebalanceStateResponse handleDeleteStoreRebalanceState(VAdminProto.DeleteStoreRebalanceStateRequest request) {
VAdminProto.DeleteStoreRebalanceStateResponse.Builder response = VAdminProto.DeleteStoreRebalanceStateResponse.newBuilder();
synchronized (rebalancer) {
try {
int nodeId = request.getNodeId();
String storeName = request.getStoreName();
logger.info("Removing rebalancing state for donor node " + nodeId + " and store " + storeName + " from stealer node " + metadataStore.getNodeId());
RebalanceTaskInfo info = metadataStore.getRebalancerState().find(nodeId);
if (info == null) {
throw new VoldemortException("Could not find state for donor node " + nodeId);
}
List<Integer> partitionIds = info.getPartitionIds(storeName);
if (partitionIds.size() == 0) {
throw new VoldemortException("Could not find state for donor node " + nodeId + " and store " + storeName);
}
info.removeStore(storeName);
logger.info("Removed rebalancing state for donor node " + nodeId + " and store " + storeName + " from stealer node " + metadataStore.getNodeId());
if (info.getPartitionStores().isEmpty()) {
metadataStore.deleteRebalancingState(info);
logger.info("Removed entire rebalancing state for donor node " + nodeId + " from stealer node " + metadataStore.getNodeId());
}
} catch (VoldemortException e) {
response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
logger.error("handleDeleteStoreRebalanceState failed for request(" + request.toString() + ")", e);
}
}
return response.build();
}
use of voldemort.VoldemortException in project voldemort by voldemort.
the class AdminServiceRequestHandler method handleGetROStorageFileList.
public VAdminProto.GetROStorageFileListResponse handleGetROStorageFileList(VAdminProto.GetROStorageFileListRequest request) {
String storeName = request.getStoreName();
VAdminProto.GetROStorageFileListResponse.Builder response = VAdminProto.GetROStorageFileListResponse.newBuilder();
try {
ReadOnlyStorageEngine store = getReadOnlyStorageEngine(metadataStore, storeRepository, storeName);
ChunkedFileSet chunkedFileSet = store.getChunkedFileSet();
response.addAllFileName(chunkedFileSet.getFileNames());
response.addAllIndexFileSize(chunkedFileSet.getIndexFileSizes());
response.addAllDataFileSize(chunkedFileSet.getDataFileSizes());
} catch (VoldemortException e) {
response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
logger.error("handleGetROStorageFileList failed for request(" + request.toString() + ")", e);
}
return response.build();
}
use of voldemort.VoldemortException in project voldemort by voldemort.
the class ProtoBuffRequestHandler method handleRequest.
@Override
public StreamRequestHandler handleRequest(final DataInputStream inputStream, final DataOutputStream outputStream, final ByteBufferContainer outputContainer) throws IOException {
VoldemortRequest.Builder request = ProtoUtils.readToBuilder(inputStream, VoldemortRequest.newBuilder());
boolean shouldRoute = request.getShouldRoute();
RequestRoutingType type = RequestRoutingType.getRequestRoutingType(shouldRoute, false);
if (request.hasRequestRouteType()) {
type = RequestRoutingType.getRequestRoutingType(request.getRequestRouteType());
}
String storeName = request.getStore();
Store<ByteArray, byte[], byte[]> store = getStore(storeName, type);
Message response;
if (store == null) {
response = unknownStore(storeName, request.getType());
} else {
switch(request.getType()) {
case GET:
response = handleGet(request.getGet(), store);
break;
case GET_ALL:
response = handleGetAll(request.getGetAll(), store);
break;
case PUT:
response = handlePut(request.getPut(), store);
break;
case DELETE:
response = handleDelete(request.getDelete(), store);
break;
case GET_VERSION:
response = handleGetVersion(request.getGet(), store);
break;
default:
throw new VoldemortException("Unknown operation " + request.getType());
}
}
if (outputContainer != null) {
outputContainer.getBuffer().clear();
outputContainer.ensureSpace(response.getSerializedSize());
}
ProtoUtils.writeMessage(outputStream, response);
return null;
}
use of voldemort.VoldemortException in project voldemort by voldemort.
the class ProtoBuffRequestHandler method handlePut.
private VProto.PutResponse handlePut(VProto.PutRequest request, Store<ByteArray, byte[], byte[]> store) {
VProto.PutResponse.Builder response = VProto.PutResponse.newBuilder();
try {
ByteArray key = ProtoUtils.decodeBytes(request.getKey());
Versioned<byte[]> value = ProtoUtils.decodeVersioned(request.getVersioned());
store.put(key, value, request.hasTransforms() ? ProtoUtils.decodeBytes(request.getTransforms()).get() : null);
} catch (VoldemortException e) {
response.setError(ProtoUtils.encodeError(getErrorMapper(), e));
}
return response.build();
}
Aggregations