Search in sources :

Example 1 with UUIDBase

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

the class ActiveVersionedBasicOperations method receivedOpResponse.

public void receivedOpResponse(MessageGroup message) {
    AsyncVersionedBasicOperationImpl op;
    UUIDBase uuid;
    byte resultCode;
    long uuidMSL;
    long uuidLSL;
    uuidMSL = message.getBuffers()[0].getLong(0);
    uuidLSL = message.getBuffers()[0].getLong(NumConversion.BYTES_PER_LONG);
    resultCode = message.getBuffers()[0].get(2 * NumConversion.BYTES_PER_LONG);
    uuid = new UUIDBase(uuidMSL, uuidLSL);
    op = getOp(uuid);
    if (op != null) {
        OpResult result;
        result = EnumValues.opResult[resultCode];
        op.setResult(result);
    } else {
        Log.warning("No operation for response: ", uuid);
    }
}
Also used : OpResult(com.ms.silverking.cloud.dht.common.OpResult) UUIDBase(com.ms.silverking.id.UUIDBase)

Example 2 with UUIDBase

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

the class Connection method sendFailed.

// ////////////////////////////////////////////////////////////////////
/**
 * Must be called if a send fails.
 */
protected void sendFailed(OutgoingData data) {
    ActiveSend activeSend;
    UUIDBase sendUUID;
    if (verbose) {
        Log.warning("sendFailed", remoteSocketAddress);
        data.displayForDebug();
    }
    sendUUID = data.getSendUUID();
    if (sendUUID != null && activeBlockingSends != null) {
        activeSend = activeBlockingSends.get(sendUUID);
    } else {
        activeSend = null;
    }
    if (activeSend != null) {
        activeSend.setException(new IOException("send failed"));
    } else {
        if (Log.levelMet(Level.FINE)) {
            Log.fine("sendFailed() not an active send ", data.getSendUUID() + " " + remoteSocketAddress);
        }
    }
    data.failed();
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase) IOException(java.io.IOException)

Example 3 with UUIDBase

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

the class Connection method sendSucceeded.

/**
 * Must be called if a send succeeds.
 * @param data
 */
protected void sendSucceeded(OutgoingData data) {
    ActiveSend activeSend;
    UUIDBase sendUUID;
    if (AsyncGlobals.debug && debug) {
        Log.fine("sendSucceeded", remoteSocketAddress);
    }
    sendUUID = data.getSendUUID();
    if (sendUUID != null && activeBlockingSends != null) {
        activeSend = activeBlockingSends.get(sendUUID);
    } else {
        activeSend = null;
    }
    if (activeSend != null) {
        activeSend.setSentSuccessfully();
    } else {
        if (AsyncGlobals.debug && debug && Log.levelMet(Level.FINE)) {
            Log.fine("sendSucceeded() not an active send ", data.getSendUUID() + " " + remoteSocketAddress);
        }
    }
    data.successful();
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase)

Example 4 with UUIDBase

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

the class DHTRingMaster method recoverData.

public UUIDBase recoverData() {
    UUIDBase uuid;
    Log.warningAsyncf("DHTRingMaster.recoverData");
    uuid = UUIDBase.random();
    recoverDataWorker.addWork(uuid);
    return uuid;
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase)

Example 5 with UUIDBase

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

the class DHTRingMaster method syncData.

public void syncData(Quadruple<UUIDBase, Quadruple<String, Long, Long, Long>, Quadruple<String, Long, Long, Long>, SyncTargets> idAndRings) {
    UUIDBase uuid;
    Quadruple<String, Long, Long, Long> sourceRing;
    Quadruple<String, Long, Long, Long> targetRing;
    uuid = idAndRings.getV1();
    sourceRing = idAndRings.getV2();
    targetRing = idAndRings.getV3();
    Log.warningAsyncf("DHTRingMaster.syncData %s %s %s", uuid, sourceRing.getV1(), targetRing.getV1());
    convergenceLock.lock();
    try {
        if (/*!isValidTarget(targetRing)*/
        false) {
            // FUTURE think about checking validity
            // FUTURE - could improve this sanity check to look at zk info
            Log.warningAsyncf("Ignoring invalid sync %s %s", sourceRing, targetRing);
        } else {
            if (enableLogging) {
                Log.warningAsync("New ring: ", targetRing);
            }
            try {
                ConvergencePoint _sourceCP;
                ConvergencePoint _targetCP;
                // Check for old convergence
                if (targetConvergenceController != null) {
                    if (enableLogging) {
                        Log.warningAsync("Can't sync due to ongoing convergence: ", targetRing);
                        return;
                    }
                }
                // Start new sync
                _sourceCP = new ConvergencePoint(dhtConfig.getVersion(), RingIDAndVersionPair.fromRingNameAndVersionPair(sourceRing.getTripleAt1()), sourceRing.getV4());
                _targetCP = new ConvergencePoint(dhtConfig.getVersion(), RingIDAndVersionPair.fromRingNameAndVersionPair(targetRing.getTripleAt1()), targetRing.getV4());
                try {
                    targetConvergenceController = new CentralConvergenceController(uuid, dhtMetaReader, _sourceCP, _targetCP, readExclusions(targetRing), mgBase, syncUnchangedOwners, CentralConvergenceController.RequestedSyncMode.SyncOnly);
                    convergenceControllers.put(targetConvergenceController.getUUID(), targetConvergenceController);
                } catch (IOException ioe) {
                    Log.logErrorWarning(ioe, "Unable to start sync");
                    return;
                }
                try {
                    convergenceLock.unlock();
                    try {
                        if (enableLogging) {
                            Log.warningAsync("Calling converge(): ", targetRing);
                        }
                        ((CentralConvergenceController) targetConvergenceController).converge(idAndRings.getV4());
                    } finally {
                        convergenceLock.lock();
                    }
                    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)

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