use of com.ms.silverking.cloud.dht.meta.DHTConfiguration in project SilverKing by Morgan-Stanley.
the class SKAdminShell method displayRings.
private void displayRings(int displayLimit) throws IOException, KeeperException {
DHTConfiguration dhtConfig;
dhtConfig = DHTConfiguration.parse(rmc.getDHTConfiguration(), 0);
displayRings(dhtConfig.getRingName(), displayLimit);
}
use of com.ms.silverking.cloud.dht.meta.DHTConfiguration in project SilverKing by Morgan-Stanley.
the class EmbeddedSK method createEmbeddedSKInstance.
public static ClientDHTConfiguration createEmbeddedSKInstance(String dhtName, String gridConfigName, String ringName, int replication) {
try {
int zkPort;
Path tempDir;
File zkDir;
File skDir;
ZooKeeperConfig zkConfig;
// 0) Create LWT work pools
LWTPoolProvider.createDefaultWorkPools();
// 1) Start an embedded ZooKeeper
Log.warning("Creating embedded ZooKeeper");
try {
tempDir = Files.createTempDirectory(null);
zkDir = new File(tempDir.toFile(), "zookeeper");
zkDir.mkdirs();
skDir = new File(tempDir.toFile(), "silverking");
skDir.mkdirs();
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
zkPort = LocalZKImpl.startLocalZK(zkDir.getAbsolutePath());
zkConfig = new ZooKeeperConfig(InetAddress.getLoopbackAddress().getHostAddress() + ":" + zkPort);
Log.warning("Embedded ZooKeeper running at: " + zkConfig);
DHTNodeConfiguration.setDataBasePath(skDir.getAbsolutePath() + "/data");
// 2) Create ring in ZK
Log.warning("Creating ring");
StaticRingCreator.createStaticRing(ringName, zkConfig, ImmutableSet.of(IPAddrUtil.localIPString()), replication);
Log.warning("Created: " + ringName);
// 3) Create DHT Config in ZK
DHTConfiguration dhtConfig;
MetaClient dhtMC;
DHTConfigurationZK dhtConfigZK;
ClientDHTConfiguration clientDHTConfig;
int dhtPort;
Log.warning("Creating DHT configuration in ZK");
if (skPort <= 0) {
// FIXME
dhtPort = ThreadLocalRandom.current().nextInt(10000, 20000);
} else {
dhtPort = skPort;
}
clientDHTConfig = new ClientDHTConfiguration(dhtName, dhtPort, zkConfig);
dhtMC = new MetaClient(clientDHTConfig);
dhtConfigZK = new DHTConfigurationZK(dhtMC);
dhtConfig = DHTConfiguration.emptyTemplate.ringName(ringName).port(dhtPort).passiveNodeHostGroups("").hostGroupToClassVarsMap(new HashMap<String, String>());
dhtConfigZK.writeToZK(dhtConfig, null);
Log.warning("Created DHT configuration in ZK");
// 4) Set cur and target rings
DHTRingCurTargetZK curTargetZK;
Log.warning("Setting ring targets");
curTargetZK = new DHTRingCurTargetZK(dhtMC, dhtConfig);
curTargetZK.setCurRingAndVersionPair(ringName, 0, 0);
curTargetZK.setTargetRingAndVersionPair(ringName, 0, 0);
Log.warning("Ring targets set");
// 4) Start DHTNode
Log.warning("Starting DHTNode");
new DHTNode(dhtName, zkConfig, 0, false, false);
Log.warning("DHTNode started");
// 5) Return the configuration to the caller
return clientDHTConfig;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.ms.silverking.cloud.dht.meta.DHTConfiguration in project SilverKing by Morgan-Stanley.
the class LogStreamConfig method configureLogStreams.
public static void configureLogStreams(SKGridConfiguration gc, String logFileName) throws IOException, KeeperException {
MetaClient dhtMC;
DHTConfiguration dhtConfig;
ClassVarsZK classVarsZK;
ClassVars defaultClassVars;
PrintStream logStream;
File logDir;
dhtMC = new com.ms.silverking.cloud.dht.meta.MetaClient(gc);
dhtConfig = dhtMC.getDHTConfiguration();
classVarsZK = new ClassVarsZK(dhtMC);
if (dhtConfig.getDefaultClassVars() != null) {
defaultClassVars = DHTConstants.defaultDefaultClassVars.overrideWith(classVarsZK.getClassVars(dhtConfig.getDefaultClassVars()));
} else {
defaultClassVars = DHTConstants.defaultDefaultClassVars;
}
logDir = new File(DHTConstants.getSKInstanceLogDir(defaultClassVars, gc));
Log.warning("Ensuring created: ", logDir);
logDir.mkdirs();
logStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(new File(logDir, logFileName))), true);
System.setOut(logStream);
System.setErr(logStream);
Log.setPrintStreams(logStream);
}
use of com.ms.silverking.cloud.dht.meta.DHTConfiguration in project SilverKing by Morgan-Stanley.
the class MetaTool method namedDHTConfigurationFor.
private static NamedDHTConfiguration namedDHTConfigurationFor(Tool tool, String name) {
switch(tool) {
case DHTConfiguration:
return new NamedDHTConfiguration(name, null);
case PassiveNodes:
DHTConfiguration dhtConfig;
dhtConfig = DHTConfiguration.forPassiveNodes(name);
return new NamedDHTConfiguration(null, dhtConfig);
case ClassVars:
return new NamedDHTConfiguration(null, DHTConfiguration.emptyTemplate);
default:
throw new RuntimeException("panic");
}
}
use of com.ms.silverking.cloud.dht.meta.DHTConfiguration in project SilverKing by Morgan-Stanley.
the class SKAdminShell method displayDHTConfig.
private void displayDHTConfig() throws RemoteException {
DHTConfiguration dhtConfig;
dhtConfig = DHTConfiguration.parse(rmc.getDHTConfiguration(), 0);
out.printf("%s\n", dhtConfig);
}
Aggregations