Search in sources :

Example 1 with RingCreationResults

use of com.ms.silverking.cloud.toporing.StaticRingCreator.RingCreationResults in project SilverKing by Morgan-Stanley.

the class StaticDHTCreator method createStaticDHT.

public void createStaticDHT(UUIDBase uuid, int initialHeapSize, int maxHeapSize, String skInstanceLogBaseVar, String dataBaseVar, String skfsConfigurationFile) throws IOException, KeeperException {
    String ringName;
    String classVarsName;
    RingCreationResults rcResults;
    MetaClient mc;
    mc = new MetaClient(dhtName, zkConfig);
    // Create Ring
    ringName = ringNameBase + uuid.toString();
    rcResults = StaticRingCreator.createStaticRing(ringName, zkConfig, servers, replication, uuid);
    // Create class vars
    ClassVars classVars;
    Map<String, String> varsMap;
    MetaToolOptions mto;
    classVarsName = "classVars." + uuid.toString();
    varsMap = new HashMap<>();
    varsMap.put(DHTConstants.initialHeapSizeVar, Integer.toString(initialHeapSize));
    varsMap.put(DHTConstants.maxHeapSizeVar, Integer.toString(maxHeapSize));
    if (skInstanceLogBaseVar != null) {
        varsMap.put(DHTConstants.skInstanceLogBaseVar, skInstanceLogBaseVar);
    }
    if (dataBaseVar != null) {
        varsMap.put(DHTConstants.dataBaseVar, dataBaseVar);
    }
    classVars = new ClassVars(varsMap, VersionedDefinition.NO_VERSION);
    new ClassVarsZK(mc).writeToZK(classVars, classVarsName);
    // Create DHTConfig
    DHTConfiguration dhtConfig;
    dhtConfig = new DHTConfiguration(ringName, port, passiveNodes, nsCreationOptions, ImmutableMap.of(rcResults.hostGroupName, classVarsName), 0, Long.MIN_VALUE, null);
    new DHTConfigurationZK(mc).writeToZK(dhtConfig, null);
    // Write out curRingAndVersion
    new DHTRingCurTargetZK(mc, dhtConfig).setCurRingAndVersionPair(ringName, 0, 0);
    new DHTRingCurTargetZK(mc, dhtConfig).setTargetRingAndVersionPair(ringName, 0, 0);
    // Write skfs configuration if present
    if (skfsConfigurationFile != null) {
        writeSKFSConfig(gcName, new File(skfsConfigurationFile));
    }
    // Write GridConfig
    Map<String, String> envMap;
    envMap = new HashMap<>();
    envMap.put(ClientDHTConfiguration.nameVar, dhtName);
    envMap.put(ClientDHTConfiguration.portVar, Integer.toString(port));
    envMap.put(ClientDHTConfiguration.zkLocVar, zkConfig.getConnectString());
    writeGridConfig(new SKGridConfiguration(gcName, envMap), gridConfigDir, gcName);
    System.out.println(gcName);
}
Also used : ClientDHTConfiguration(com.ms.silverking.cloud.dht.client.ClientDHTConfiguration) SKGridConfiguration(com.ms.silverking.cloud.dht.gridconfig.SKGridConfiguration) MetaToolOptions(com.ms.silverking.cloud.management.MetaToolOptions) RingCreationResults(com.ms.silverking.cloud.toporing.StaticRingCreator.RingCreationResults) File(java.io.File)

Aggregations

ClientDHTConfiguration (com.ms.silverking.cloud.dht.client.ClientDHTConfiguration)1 SKGridConfiguration (com.ms.silverking.cloud.dht.gridconfig.SKGridConfiguration)1 MetaToolOptions (com.ms.silverking.cloud.management.MetaToolOptions)1 RingCreationResults (com.ms.silverking.cloud.toporing.StaticRingCreator.RingCreationResults)1 File (java.io.File)1