Permalink
Browse files

Converted RepairJob to Async service

  • Loading branch information...
1 parent a543511 commit 6c68ec1bf05954be586ca8c754683964efacdef1 Chinmay Soman committed with vinothchandar Nov 1, 2011
@@ -8,7 +8,7 @@
import voldemort.VoldemortException;
import voldemort.annotations.concurrency.Threadsafe;
-import voldemort.server.scheduler.slop.RepairJob;
+import voldemort.server.storage.RepairJob;
import voldemort.store.StorageEngine;
import voldemort.store.Store;
import voldemort.store.slop.SlopStorageEngine;
@@ -48,7 +48,7 @@
import voldemort.server.protocol.RequestHandler;
import voldemort.server.protocol.StreamRequestHandler;
import voldemort.server.rebalance.Rebalancer;
-import voldemort.server.scheduler.slop.RepairJob;
+import voldemort.server.storage.RepairJob;
import voldemort.server.storage.StorageService;
import voldemort.store.ErrorCodeMapper;
import voldemort.store.StorageEngine;
@@ -543,12 +543,25 @@ public StreamRequestHandler handleUpdatePartitionEntries(VAdminProto.UpdateParti
public VAdminProto.RepairJobResponse handleRepairJob(VAdminProto.RepairJobRequest request) {
VAdminProto.RepairJobResponse.Builder response = VAdminProto.RepairJobResponse.newBuilder();
try {
- RepairJob job = storeRepository.getRepairJob();
- if(job != null) {
- logger.info("Starting the repair job now on ID : " + metadataStore.getNodeId());
- job.run();
- } else
- logger.error("RepairJob is not scheduled.");
+ int requestId = asyncService.getUniqueRequestId();
+ asyncService.submitOperation(requestId, new AsyncOperation(requestId, "Repair Job") {
+
+ @Override
+ public void operate() {
+ RepairJob job = storeRepository.getRepairJob();
+ if(job != null) {
+ logger.info("Starting the repair job now on ID : "
+ + metadataStore.getNodeId());
+ job.run();
+ } else
+ logger.error("RepairJob is not initialized.");
+ }
+
+ @Override
+ public void stop() {
+ status.setException(new VoldemortException("Repair job interrupted"));
+ }
+ });
} catch(VoldemortException e) {
response.setError(ProtoUtils.encodeError(errorCodeMapper, e));
logger.error("Repair job failed for request : " + request.toString() + ")", e);
@@ -1,4 +1,4 @@
-package voldemort.server.scheduler.slop;
+package voldemort.server.storage;
import java.util.Arrays;
import java.util.Date;
@@ -58,7 +58,6 @@
import voldemort.server.scheduler.DataCleanupJob;
import voldemort.server.scheduler.SchedulerService;
import voldemort.server.scheduler.slop.BlockingSlopPusherJob;
-import voldemort.server.scheduler.slop.RepairJob;
import voldemort.server.scheduler.slop.StreamingSlopPusherJob;
import voldemort.store.StorageConfiguration;
import voldemort.store.StorageEngine;

0 comments on commit 6c68ec1

Please sign in to comment.