Skip to content

Commit

Permalink
More logging in delete entries + returns a long instead of int
Browse files Browse the repository at this point in the history
  • Loading branch information
rsumbaly committed May 12, 2011
1 parent 78a2fbf commit ff623f5
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 30 deletions.
4 changes: 2 additions & 2 deletions clients/python/voldemort/protocol/voldemort_admin_pb2.py

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/java/voldemort/client/protocol/admin/AdminClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1078,10 +1078,10 @@ private VAdminProto.VoldemortFilter encodeFilter(VoldemortFilter filter) throws
* should not be deleted.
* @return Number of entries deleted
*/
public int deletePartitions(int nodeId,
String storeName,
List<Integer> partitionList,
VoldemortFilter filter) {
public long deletePartitions(int nodeId,
String storeName,
List<Integer> partitionList,
VoldemortFilter filter) {
return deletePartitions(nodeId,
storeName,
getReplicaToPartitionMap(nodeId, storeName, partitionList),
Expand All @@ -1100,11 +1100,11 @@ public int deletePartitions(int nodeId,
* should not be deleted.
* @return Number of entries deleted
*/
public int deletePartitions(int nodeId,
String storeName,
HashMap<Integer, List<Integer>> replicaToPartitionList,
Cluster initialCluster,
VoldemortFilter filter) {
public long deletePartitions(int nodeId,
String storeName,
HashMap<Integer, List<Integer>> replicaToPartitionList,
Cluster initialCluster,
VoldemortFilter filter) {
VAdminProto.DeletePartitionEntriesRequest.Builder deleteRequest = VAdminProto.DeletePartitionEntriesRequest.newBuilder()
.addAllReplicaToPartition(ProtoUtils.encodePartitionTuple(replicaToPartitionList))
.setStore(storeName);
Expand Down
22 changes: 11 additions & 11 deletions src/java/voldemort/client/protocol/pb/VAdminProto.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,10 @@ public void operate() {
if(isReadOnlyStore) {
ReadOnlyStorageEngine readOnlyStorageEngine = ((ReadOnlyStorageEngine) storageEngine);
String destinationDir = readOnlyStorageEngine.getCurrentDirPath();
updateStatus("Initated fetching of files for RO store " + storeName
+ " from node " + nodeId);
logger.info("Fetching files for RO store " + storeName + " from node "
+ nodeId);
updateStatus("Fetching files for RO store " + storeName + " from node "
+ nodeId);
adminClient.fetchPartitionFiles(nodeId,
storeName,
replicaToPartitionList,
Expand All @@ -699,7 +701,9 @@ public void operate() {
.keySet());

} else {
updateStatus("Initated fetching of entries for RW store " + storeName
logger.info("Fetching entries for RW store " + storeName
+ " from node " + nodeId);
updateStatus("Fetching entries for RW store " + storeName
+ " from node " + nodeId);
Iterator<Pair<ByteArray, Versioned<byte[]>>> entriesIterator = adminClient.fetchEntries(nodeId,
storeName,
Expand All @@ -722,7 +726,7 @@ public void operate() {

throttler.maybeThrottle(key.length() + valueSize(value));
if((i % 1000) == 0) {
updateStatus(i + " entries copied from " + nodeId
updateStatus(i + " entries copied from node " + nodeId
+ " for store " + storeName);
}
}
Expand Down Expand Up @@ -769,6 +773,17 @@ public VAdminProto.DeletePartitionEntriesResponse handleDeletePartitionEntries(V
try {
String storeName = request.getStore();
final HashMap<Integer, List<Integer>> replicaToPartitionList = ProtoUtils.decodePartitionTuple(request.getReplicaToPartitionList());

final boolean isReadWriteStore = metadataStore.getStoreDef(storeName)
.getType()
.compareTo(ReadOnlyStorageConfiguration.TYPE_NAME) != 0;

if(!isReadWriteStore) {
throw new VoldemortException("Cannot delete partitions for store " + storeName
+ " on node " + metadataStore.getNodeId()
+ " since it is not a RW store");
}

StorageEngine<ByteArray, byte[], byte[]> storageEngine = getStorageEngine(storeRepository,
storeName);
VoldemortFilter filter = (request.hasFilter()) ? getFilterFromRequest(request.getFilter(),
Expand All @@ -777,7 +792,9 @@ public VAdminProto.DeletePartitionEntriesResponse handleDeletePartitionEntries(V
: new DefaultVoldemortFilter();
EventThrottler throttler = new EventThrottler(voldemortConfig.getStreamMaxReadBytesPerSec());
iterator = storageEngine.entries();
int deleteSuccess = 0;
long deleteSuccess = 0;
logger.info("Deleting entries for RW store " + storeName + " from node "
+ metadataStore.getNodeId());

while(iterator.hasNext()) {
Pair<ByteArray, Versioned<byte[]>> entry = iterator.next();
Expand All @@ -792,10 +809,16 @@ public VAdminProto.DeletePartitionEntriesResponse handleDeletePartitionEntries(V
: metadataStore.getCluster(),
metadataStore.getStoreDef(storeName))
&& filter.accept(key, value)) {
if(storageEngine.delete(key, value.getVersion()))
if(storageEngine.delete(key, value.getVersion())) {
deleteSuccess++;
if((deleteSuccess % 1000) == 0) {
logger.info(deleteSuccess + " entries deleted from node "
+ metadataStore.getNodeId() + " for store " + storeName);
}
}
}
}

response.setCount(deleteSuccess);
} catch(VoldemortException e) {
response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
Expand Down
2 changes: 1 addition & 1 deletion src/proto/voldemort-admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ message DeletePartitionEntriesRequest {
}

message DeletePartitionEntriesResponse {
optional int32 count = 1;
optional int64 count = 1;
optional Error error = 2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void rebalance() {
node1.getSocketPort(),
node1.getAdminPort(),
ImmutableList.of(0, 1));
int deleted = adminClient.deletePartitions(0, STORE_NAME, ImmutableList.of(0, 1), null);
long deleted = adminClient.deletePartitions(0, STORE_NAME, ImmutableList.of(0, 1), null);
assert deleted > 0;
Cluster newCluster = new Cluster(cluster.getName(),
ImmutableList.of(newNode0, newNode1),
Expand Down

0 comments on commit ff623f5

Please sign in to comment.