Search in sources :

Example 16 with UUIDBase

use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.

the class DHTRingMaster method setTarget.

public void setTarget(Pair<UUIDBase, Quadruple<String, Long, Long, Long>> idAndRing) {
    UUIDBase uuid;
    Quadruple<String, Long, Long, Long> ring;
    uuid = idAndRing.getV1();
    ring = idAndRing.getV2();
    Log.warningAsyncf("DHTRingMaster.setTarget %s %s", uuid, ring.getV1());
    convergenceLock.lock();
    try {
        if (!isValidTarget(ring)) {
            // FUTURE - could improve this sanity check to look at zk info
            Log.warningAsync("Ignoring invalid target ring: ", ring);
        } else {
            if (currentRing == null) {
                try {
                    currentRing = ring.getTripleAt1();
                    dhtRingCurTargetZK.setCurRingAndVersionPair(ring.getV1(), ring.getPairAt2());
                } catch (KeeperException ke) {
                    Log.logErrorWarning(ke);
                }
            } else {
                if (enableLogging) {
                    Log.warningAsync("New ring: ", ring);
                }
                try {
                    CentralConvergenceController.RequestedSyncMode syncMode;
                    // Stop old convergence
                    if (targetConvergenceController != null) {
                        if (enableLogging) {
                            Log.warningAsync("Abandoning old convergence: ", targetRing);
                        }
                        targetConvergenceController.abandon();
                    }
                    // Start new convergence
                    dhtRingCurTargetZK.setTargetRingAndVersionPair(ring.getV1(), ring.getPairAt2());
                    targetRing = ring.getTripleAt1();
                    targetCP = new ConvergencePoint(dhtConfig.getVersion(), RingIDAndVersionPair.fromRingNameAndVersionPair(ring.getTripleAt1()), ring.getV4());
                    if (enableLogging) {
                        Log.warningAsync("New targetRing: ", targetRing);
                    }
                    if (mode == Mode.ManualNoSync) {
                        syncMode = CentralConvergenceController.RequestedSyncMode.SetStateOnly;
                    } else {
                        syncMode = CentralConvergenceController.RequestedSyncMode.SyncAndSetStateUnlessSubset;
                    }
                    try {
                        targetConvergenceController = new CentralConvergenceController(uuid, dhtMetaReader, currentCP, targetCP, readExclusions(ring), mgBase, syncUnchangedOwners, syncMode);
                        convergenceControllers.put(targetConvergenceController.getUUID(), targetConvergenceController);
                    } catch (IOException ioe) {
                        Log.logErrorWarning(ioe, "Unable to start convergence");
                        return;
                    }
                    try {
                        convergenceLock.unlock();
                        try {
                            if (enableLogging) {
                                Log.warningAsync("Calling converge(): ", targetRing);
                            }
                            ((CentralConvergenceController) targetConvergenceController).converge(CentralConvergenceController.SyncTargets.Primary);
                        } finally {
                            convergenceLock.lock();
                        }
                        // Convergence was successful
                        // Set the cur -> target, target -> null?
                        currentRing = targetRing;
                        currentCP = targetCP;
                        dhtRingCurTargetZK.setCurRingAndVersionPair(currentRing.getHead(), currentRing.getTail());
                        targetRing = null;
                        targetCP = null;
                        targetConvergenceController = null;
                        if (enableLogging) {
                            Log.warningAsync("Convergence complete: ", targetRing);
                        }
                    } catch (ConvergenceException ce) {
                        // Convergence failed
                        if (!ce.getAbandoned()) {
                            // Failed due to an exception
                            Log.logErrorWarning(ce, "Convergence failed due to exception");
                        } else {
                            // Failed due to a new target causing the old convergence to be abandoned
                            // In this case, the new convergence will take over the cur and target pointers
                            Log.warningAsync("Previous convergence abandoned");
                        }
                    }
                } catch (KeeperException ke) {
                    // Retries are internal to DHTringCurTargetZK. If we got here, those
                    // retries failed.
                    // FUTURE - relay to alerting
                    Log.logErrorWarning(ke, "Unexpected exception during peerStateMet handling");
                }
            }
        }
    } finally {
        convergenceLock.unlock();
    }
}
Also used : ConvergencePoint(com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint) UUIDBase(com.ms.silverking.id.UUIDBase) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 17 with UUIDBase

use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.

the class NamespaceRequest method sendNamespaceRequest.

private void sendNamespaceRequest(IPAndPort dest) {
    ProtoNamespaceRequestMessageGroup protoMG;
    if (debug) {
        Log.warning("Requesting namespaces from: ", dest);
    }
    protoMG = new ProtoNamespaceRequestMessageGroup(new UUIDBase(), mgBase.getMyID());
    nsRequests.put(protoMG.getUUID(), this);
    mgBase.send(protoMG.toMessageGroup(), dest);
}
Also used : ProtoNamespaceRequestMessageGroup(com.ms.silverking.cloud.dht.net.ProtoNamespaceRequestMessageGroup) UUIDBase(com.ms.silverking.id.UUIDBase)

Example 18 with UUIDBase

use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.

the class ReplicaSyncRequest method of.

public static ReplicaSyncRequest of(long ns, RingRegion region, IPAndPort newOwner, IPAndPort oldOwner, Action upstreamDependency) {
    Action[] upstreamDependencies;
    UUIDBase uuid;
    if (upstreamDependency != null) {
        upstreamDependencies = new Action[1];
        upstreamDependencies[0] = upstreamDependency;
    } else {
        upstreamDependencies = new Action[0];
    }
    // random to allow for easy use in hashCode()
    uuid = UUIDBase.random();
    return new ReplicaSyncRequest(uuid, ns, region, newOwner, oldOwner, upstreamDependencies);
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase)

Example 19 with UUIDBase

use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.

the class CentralConvergenceController method setNodesState.

public void setNodesState(RingState ringState) throws ConvergenceException {
    Set<UUIDBase> msgUUIDs;
    Set<UUIDBase> incompleteUUIDs;
    Set<UUIDBase> failedUUIDs;
    Pair<Set<UUIDBase>, Set<UUIDBase>> result;
    Map<UUIDBase, IPAndPort> replicaMap;
    Set<IPAndPort> targetReplicas;
    Set<IPAndPort> passiveNodes;
    Log.warningAsyncf("setNodesState %s %s", targetRing.getRingIDAndVersionPair(), ringState);
    replicaMap = new HashMap<>();
    msgUUIDs = new HashSet<>();
    // Also, send to source? but don't wait? unless source is now passive?
    // fix passive to include unused?
    targetReplicas = getTargetReplicasWithPorts();
    passiveNodes = getPassiveNodes();
    for (IPAndPort replica : targetReplicas) {
        UUIDBase uuid;
        uuid = new UUIDBase(false);
        opUUIDs.add(uuid);
        uuid = sendSetState(uuid, replica, ringState);
        msgUUIDs.add(uuid);
        replicaMap.put(uuid, replica);
    }
    for (IPAndPort passiveNode : passiveNodes) {
        UUIDBase uuid;
        uuid = new UUIDBase(false);
        opUUIDs.add(uuid);
        uuid = sendSetState(uuid, passiveNode, ringState);
        msgUUIDs.add(uuid);
        replicaMap.put(uuid, passiveNode);
    }
    result = opCompletionTracker.waitForCompletion(msgUUIDs, setStateDeadlineRelativeMillis, TimeUnit.MILLISECONDS);
    opUUIDs.removeAll(msgUUIDs);
    incompleteUUIDs = result.getV1();
    failedUUIDs = result.getV2();
    displayErrors(replicaMap, incompleteUUIDs, "Incomplete");
    displayErrors(replicaMap, failedUUIDs, "Failed");
    if (incompleteUUIDs.size() != 0) {
        throw new ConvergenceException("Incomplete ops: " + incompleteUUIDs.size());
    }
    if (failedUUIDs.size() != 0) {
        throw new ConvergenceException("Failed ops: " + failedUUIDs.size());
    }
    this.ringState = ringState;
    Log.warningAsyncf("setNodesState complete %s %s", targetRing.getRingIDAndVersionPair(), ringState);
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) HashSet(java.util.HashSet) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) ExclusionSet(com.ms.silverking.cloud.meta.ExclusionSet) UUIDBase(com.ms.silverking.id.UUIDBase)

Example 20 with UUIDBase

use of com.ms.silverking.id.UUIDBase in project SilverKing by Morgan-Stanley.

the class CentralConvergenceController method displayErrors.

private void displayErrors(Map<UUIDBase, IPAndPort> replicaMap, Set<UUIDBase> failed, String label) {
    for (UUIDBase uuid : failed) {
        IPAndPort replica;
        replica = replicaMap.get(uuid);
        Log.warningAsyncf("%s: %s", label, replica);
    }
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) UUIDBase(com.ms.silverking.id.UUIDBase)

Aggregations

UUIDBase (com.ms.silverking.id.UUIDBase)26 IOException (java.io.IOException)7 VersionConstraint (com.ms.silverking.cloud.dht.VersionConstraint)3 ByteBuffer (java.nio.ByteBuffer)3 KeeperException (org.apache.zookeeper.KeeperException)3 RetrievalOptions (com.ms.silverking.cloud.dht.RetrievalOptions)2 DHTKey (com.ms.silverking.cloud.dht.common.DHTKey)2 InternalRetrievalOptions (com.ms.silverking.cloud.dht.common.InternalRetrievalOptions)2 KeyAndVersionChecksum (com.ms.silverking.cloud.dht.daemon.storage.KeyAndVersionChecksum)2 ConvergencePoint (com.ms.silverking.cloud.dht.daemon.storage.convergence.ConvergencePoint)2 MessageGroup (com.ms.silverking.cloud.dht.net.MessageGroup)2 ProtoChecksumTreeRequestMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeRequestMessageGroup)2 ProtoNamespaceRequestMessageGroup (com.ms.silverking.cloud.dht.net.ProtoNamespaceRequestMessageGroup)2 IPAndPort (com.ms.silverking.net.IPAndPort)2 LongInterval (com.ms.silverking.numeric.LongInterval)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 NamespaceCreationOptions (com.ms.silverking.cloud.dht.NamespaceCreationOptions)1 ValueCreator (com.ms.silverking.cloud.dht.ValueCreator)1 OpResult (com.ms.silverking.cloud.dht.common.OpResult)1 ProtoChecksumTreeMessageGroup (com.ms.silverking.cloud.dht.net.ProtoChecksumTreeMessageGroup)1