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;
}
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;
}
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();
}
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);
}
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);
}
}
Aggregations