Search in sources :

Example 6 with UUIDBase

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

the class DHTRingMaster method setTarget.

public UUIDBase setTarget(Triple<String, Long, Long> target) {
    String ringName;
    long creationTime;
    UUIDBase uuid;
    Log.warningAsyncf("DHTRingMaster.setTarget %s", target);
    ringName = target.getHead();
    creationTime = getCreationTime(ringName, target.getTail().getV1(), target.getTail().getV2());
    if (creationTime < 0) {
        Log.warningAsync("Ignoring setTarget() due to zk exceptions: " + ringName + " " + target.getTail());
        return null;
    }
    uuid = UUIDBase.random();
    ringChangedWorker.addWork(new Quadruple<>(uuid, Quadruple.of(target, creationTime), null, SyncTargets.Primary), 0);
    waitForConvergenceControllerCreation(uuid);
    return uuid;
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase)

Example 7 with UUIDBase

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

the class DHTRingMaster method syncData.

public UUIDBase syncData(Triple<String, Long, Long> source, Triple<String, Long, Long> target, SyncTargets syncTargets) {
    String sourceRingName;
    long sourceCreationTime;
    String targetRingName;
    long targetCreationTime;
    UUIDBase uuid;
    Log.warningAsyncf("DHTRingMaster.syncData %s %s", source, target);
    sourceRingName = source.getHead();
    sourceCreationTime = getCreationTime(sourceRingName, target.getTail().getV1(), target.getTail().getV2());
    if (sourceCreationTime < 0) {
        Log.warningAsync("Ignoring syncData() due to zk exceptions: " + sourceRingName + " " + source.getTail());
        return null;
    }
    targetRingName = target.getHead();
    targetCreationTime = getCreationTime(targetRingName, target.getTail().getV1(), target.getTail().getV2());
    if (targetCreationTime < 0) {
        Log.warningAsync("Ignoring syncData() due to zk exceptions: " + targetRingName + " " + target.getTail());
        return null;
    }
    uuid = UUIDBase.random();
    ringChangedWorker.addWork(new Quadruple<>(uuid, Quadruple.of(source, sourceCreationTime), Quadruple.of(target, targetCreationTime), syncTargets), 0);
    waitForConvergenceControllerCreation(uuid);
    return uuid;
}
Also used : UUIDBase(com.ms.silverking.id.UUIDBase)

Example 8 with UUIDBase

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

the class ActiveRegionSync method incomingChecksumTree.

public void incomingChecksumTree(ConvergencePoint cp, ChecksumNode remoteTree, MessageGroupConnection connection) {
    ChecksumNode localTree;
    MatchResult matchResult;
    Set<DHTKey> keysToFetch;
    List<DHTKey> keysToFetchList;
    boolean initialSRRSent;
    lastUpdateMillis = SystemTimeSource.instance.absTimeMillis();
    if (verbose) {
        Log.warningAsyncf("incomingChecksumTree %s %s %s estimatedKeys %s", uuid, cp, (connection != null ? connection.getRemoteIPAndPort() : "null connection"), (remoteTree != null ? Integer.toString(remoteTree.estimatedKeys()) : "null remoteTree"));
    }
    if (remoteTree == null) {
        if (debug) {
            Log.warning("null incomingChecksumTree");
        }
        checkForCompletion();
        return;
    }
    if (checksumTreeServer != null) {
        localTree = checksumTreeServer.getRegionChecksumTree_Local(cp, remoteTree.getRegion(), new LongInterval(Long.MIN_VALUE, cp.getDataVersion()));
        if (localTree == null) {
            localTree = createEmptyChecksumTree(remoteTree.getRegion());
        }
    } else {
        if (verbose) {
            Log.warningAsync("checksumTreeServer == null\t%s", uuid);
        }
        localTree = createEmptyChecksumTree(remoteTree.getRegion());
    }
    if (debug) {
        System.out.printf("incomingChecksumTree %x\t%s\t%s\t%s\n", namespace, cp, remoteTree.getRegion(), uuid);
    // System.out.println(remoteTree + "\n\nlocalTree\n" + localTree);
    }
    if (localTree == null) {
        checkForCompletion();
        return;
    }
    try {
        matchResult = TreeMatcher.match(localTree, remoteTree);
    } catch (RuntimeException re) {
        System.err.println(localTree);
        System.err.println();
        System.err.println(connection);
        System.err.println(remoteTree);
        throw re;
    }
    if (verbose) {
        Log.warningAsyncf("matchResult %s %s", uuid, matchResult.toSummaryString());
    }
    if (debug) {
        System.out.println(matchResult);
    }
    keysToFetch = new HashSet<>();
    for (KeyAndVersionChecksum kvc : matchResult.getDestNotInSource()) {
        if (debug) {
            System.out.printf("Adding destNotInSource %s\n", kvc.getKey());
        }
        keysToFetch.add(kvc.getKey());
    }
    for (KeyAndVersionChecksum kvc : matchResult.getChecksumMismatch()) {
        if (debug) {
            System.out.printf("Adding checksumMismatch %s\n", kvc.getKey());
        }
        keysToFetch.add(kvc.getKey());
    }
    /*
		 * Queue<DHTKey> keysToFetchQueue;
		 * 
		 * keysToFetchQueue = keysToFetchMap.get(cp); if (keysToFetchQueue ==
		 * null) { Queue<DHTKey> prev;
		 * 
		 * keysToFetchQueue = new ConcurrentLinkedQueue<>(); prev =
		 * keysToFetchMap.putIfAbsent(cp, keysToFetchQueue); if (prev != null) {
		 * keysToFetchQueue = prev; } } keysToFetchQueue.addAll(keysToFetch);
		 */
    initialSRRSent = false;
    keysToFetchList = new LinkedList<>(keysToFetch);
    while (keysToFetchList.size() > 0) {
        Set<DHTKey> batchKeys;
        int batchSize;
        RetrievalOptions retrievalOptions;
        UUIDBase uuid;
        // MessageGroup mg;
        SyncRetrievalRequest srr;
        // batchKeys = new HashSet<>(retrievalBatchSize);
        batchKeys = new ConcurrentSkipListSet<DHTKey>();
        batchSize = 0;
        while (keysToFetchList.size() > 0 && batchSize < retrievalBatchSize) {
            batchKeys.add(keysToFetchList.remove(0));
            ++batchSize;
        }
        // FUTURE - could consider sending SourceNotInDest
        retrievalOptions = OptionsHelper.newRetrievalOptions(RetrievalType.VALUE_AND_META_DATA, WaitMode.GET, checksumVersionConstraint(cp.getDataVersion()));
        // new VersionConstraint(Long.MIN_VALUE + 1, version, Mode.NEWEST));
        uuid = UUIDBase.random();
        srr = new SyncRetrievalRequest(uuid, batchKeys, cp.getDataVersion(), connection);
        activeRegionSyncs.put(uuid, this);
        outstandingSyncRetrievalRequests.put(uuid, srr);
        if (!initialSRRSent) {
            initialSRRSent = true;
            sendSyncRetrievalRequest(srr);
        }
    }
    // checkMGQueue();
    if (debug) {
        System.out.println("no more keysToFetch");
    }
    checkForCompletion();
}
Also used : DHTKey(com.ms.silverking.cloud.dht.common.DHTKey) UUIDBase(com.ms.silverking.id.UUIDBase) VersionConstraint(com.ms.silverking.cloud.dht.VersionConstraint) KeyAndVersionChecksum(com.ms.silverking.cloud.dht.daemon.storage.KeyAndVersionChecksum) RetrievalOptions(com.ms.silverking.cloud.dht.RetrievalOptions) InternalRetrievalOptions(com.ms.silverking.cloud.dht.common.InternalRetrievalOptions) LongInterval(com.ms.silverking.numeric.LongInterval)

Example 9 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 10 with UUIDBase

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

the class StaticDHTCreator method main.

public static void main(String[] args) {
    try {
        StaticDHTCreator sdc;
        StaticDHTCreatorOptions options;
        CmdLineParser parser;
        Set<String> servers;
        String dhtName;
        String gcName;
        int port;
        NamespaceCreationOptions nsCreationOptions;
        UUIDBase uuid;
        options = new StaticDHTCreatorOptions();
        parser = new CmdLineParser(options);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException cle) {
            System.err.println(cle.getMessage());
            parser.printUsage(System.err);
            System.exit(-1);
        }
        if ((options.serverFile == null && options.servers == null) || (options.serverFile != null && options.servers != null)) {
            System.err.println("Exactly one of serverFile and servers should be provided");
            parser.printUsage(System.err);
            System.exit(-1);
        }
        if (options.serverFile != null) {
            servers = ImmutableSet.copyOf(StreamParser.parseFileLines(options.serverFile));
        } else {
            servers = CollectionUtil.parseSet(options.servers, serverDelimiter);
        }
        uuid = new UUIDBase(true);
        if (options.gridConfig != null) {
            gcName = options.gridConfig;
        } else {
            gcName = gcNameBase + uuid.toString();
        }
        if (options.dhtName != null) {
            dhtName = options.dhtName;
        } else {
            dhtName = dhtNameBase + uuid.toString();
        }
        if (options.port == StaticDHTCreatorOptions.defaultPort) {
            port = Util.getFreePort();
        } else {
            port = options.port;
        }
        if (options.nsCreationOptions != null) {
            nsCreationOptions = NamespaceCreationOptions.parse(options.nsCreationOptions);
        } else {
            nsCreationOptions = NamespaceCreationOptions.defaultOptions;
        }
        sdc = new StaticDHTCreator(new ZooKeeperConfig(options.zkEnsemble), servers, options.replication, dhtName, gcName, port, nsCreationOptions, options.gridConfigDir);
        sdc.createStaticDHT(uuid, options.initialHeapSize, options.maxHeapSize, options.skInstanceLogBaseVar, options.dataBaseVar, options.skfsConfigurationFile);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
Also used : ZooKeeperConfig(com.ms.silverking.cloud.zookeeper.ZooKeeperConfig) CmdLineParser(org.kohsuke.args4j.CmdLineParser) UUIDBase(com.ms.silverking.id.UUIDBase) NamespaceCreationOptions(com.ms.silverking.cloud.dht.NamespaceCreationOptions) CmdLineException(org.kohsuke.args4j.CmdLineException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) CmdLineException(org.kohsuke.args4j.CmdLineException)

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