Search in sources :

Example 1 with Status

use of voldemort.utils.ConsistencyFix.Status in project voldemort by voldemort.

the class AbstractConsistencyFixer method doConsistencyFix.

public Status doConsistencyFix() {
    // Initialization.
    byte[] keyInBytes;
    List<Integer> nodeIdList = null;
    int masterPartitionId = -1;
    try {
        keyInBytes = ByteUtils.fromHexString(badKey.getKeyInHexFormat());
        masterPartitionId = this.storeInstance.getMasterPartitionId(keyInBytes);
        nodeIdList = this.storeInstance.getReplicationNodeList(masterPartitionId);
    } catch (Exception exception) {
        logger.info("Aborting fixKey due to bad init.");
        if (logger.isDebugEnabled()) {
            exception.printStackTrace();
        }
        return Status.BAD_INIT;
    }
    ByteArray keyAsByteArray = new ByteArray(keyInBytes);
    // Do the reads
    Map<Integer, QueryKeyResult> nodeIdToKeyValues = doReads(nodeIdList, keyInBytes, badKey.getKeyInHexFormat());
    // Process read replies (i.e., nodeIdToKeyValues)
    ProcessReadRepliesResult result = processReadReplies(nodeIdList, keyAsByteArray, badKey.getKeyInHexFormat(), nodeIdToKeyValues);
    if (result.status != Status.SUCCESS) {
        return result.status;
    }
    // Resolve conflicts indicated in nodeValues
    List<NodeValue<ByteArray, byte[]>> toReadRepair = resolveReadConflicts(result.nodeValues);
    if (logger.isTraceEnabled()) {
        if (toReadRepair.size() == 0) {
            logger.trace("Nothing to repair");
        }
        for (NodeValue<ByteArray, byte[]> nodeValue : toReadRepair) {
            logger.trace(nodeValue.getNodeId() + " --- " + nodeValue.getKey().toString());
        }
    }
    // Do the repairs
    Status status = doRepairPut(toReadRepair);
    // return status of last operation (success or otherwise)
    return status;
}
Also used : Status(voldemort.utils.ConsistencyFix.Status) NodeValue(voldemort.store.routed.NodeValue) VoldemortException(voldemort.VoldemortException) QueryKeyResult(voldemort.client.protocol.admin.QueryKeyResult)

Example 2 with Status

use of voldemort.utils.ConsistencyFix.Status in project voldemort by voldemort.

the class ConsistencyFixWorker method run.

@Override
public void run() {
    logger.trace("About to process key " + badKey + " (" + myName() + ")");
    Status status = doConsistencyFix();
    logger.trace("Finished processing key " + badKey + " (" + myName() + ")");
    consistencyFix.getStats().incrementFixCount();
    if (status != Status.SUCCESS) {
        try {
            badKeyQOut.put(new BadKeyStatus(badKey, status));
        } catch (InterruptedException ie) {
            logger.warn("Worker thread " + myName() + " interrupted.");
        }
        consistencyFix.getStats().incrementFailures(status);
    }
}
Also used : Status(voldemort.utils.ConsistencyFix.Status) BadKeyStatus(voldemort.utils.ConsistencyFix.BadKeyStatus) BadKeyStatus(voldemort.utils.ConsistencyFix.BadKeyStatus)

Aggregations

Status (voldemort.utils.ConsistencyFix.Status)2 VoldemortException (voldemort.VoldemortException)1 QueryKeyResult (voldemort.client.protocol.admin.QueryKeyResult)1 NodeValue (voldemort.store.routed.NodeValue)1 BadKeyStatus (voldemort.utils.ConsistencyFix.BadKeyStatus)1