Search in sources :

Example 6 with HostGroupTable

use of com.ms.silverking.cloud.config.HostGroupTable in project SilverKing by Morgan-Stanley.

the class SKAdmin method execClusterCommandGroup.

private boolean execClusterCommandGroup(SKAdminCommand[] commands) throws IOException, KeeperException {
    /*
		 * Each DHT consists of active + passive nodes
		 * Filter active&passive by particular host groups
		 * 	any servers that aren't in the included host groups won't be used
		 * Fetch all host group tables
		 * Fetch all class variables for the host groups
		 * For ChecSKFS, fetch the skfs environment
		 * Wait for all fetches to complete
		 * Create map of servers->commands to run
		 * Pass the command map to TwoLevelParallelSSH and run
		 * Run/wait until complete
		 */
    // Map<String,HostGroupTable>	hostGroupTables;
    // hostGroupTables = getHostGroupTables(hostGroups, dhtMC.getZooKeeper().getZKConfig());
    Set<String> activeHostGroupNames;
    Map<String, ClassVars> hostGroupToClassVars;
    HostGroupTable hostGroupTable;
    Set<String> validActiveServers;
    Set<String> validPassiveServers;
    String hostGroupTableName;
    Map<String, String[]> serverCommands;
    Set<String> passiveNodeHostGroupNames;
    boolean result;
    Set<String> targetServers;
    Set<String> passiveTargetServers;
    targetServers = CollectionUtil.parseSet(options.targets, ",");
    activeHostGroupNames = dhtConfig.getHostGroups();
    Log.warning("hostGroupNames: ", CollectionUtil.toString(activeHostGroupNames));
    hostGroupToClassVars = getHostGroupToClassVarsMap(dhtConfig);
    Log.warning("hostGroupToClassVars: ", CollectionUtil.mapToString(hostGroupToClassVars));
    Log.warning("ringConfig: ", ringConfig);
    hostGroupTableName = ringConfig.getCloudConfiguration().getHostGroupTableName();
    Log.warning("hostGroupTableName: ", hostGroupTableName);
    hostGroupTable = getHostGroupTable(hostGroupTableName, dhtMC.getZooKeeper().getZKConfig());
    // FUTURE - Do more validation of configuration. E.g. prevent a server from being both
    // active and passive, the ring from containing servers without class vars, etc.
    validActiveServers = findValidActiveServers(activeHostGroupNames, hostGroupTable, ringTree);
    validActiveServers = retainOnlySpecifiedAndNonExcludedServers(validActiveServers, targetServers);
    verifyServerEligibility(validActiveServers, commands);
    Log.warning("validActiveServers: ", CollectionUtil.toString(validActiveServers));
    // Allow StopNodes with empty validActiveServers if the target is activeDaemons
    if (options.targetsEqualsActiveDaemonsTarget() && validActiveServers.isEmpty()) {
        boolean exitOK;
        exitOK = true;
        for (SKAdminCommand command : commands) {
            if (command != SKAdminCommand.StopNodes) {
                exitOK = false;
            }
        }
        if (exitOK) {
            return true;
        }
    }
    passiveTargetServers = new HashSet<>();
    passiveTargetServers.addAll(targetServers);
    passiveTargetServers.removeAll(validActiveServers);
    passiveNodeHostGroupNames = dhtConfig.getPassiveNodeHostGroupsAsSet();
    Log.warning("passiveNodeHostGroupNames: ", CollectionUtil.toString(passiveNodeHostGroupNames));
    if (passiveTargetServers.size() > 0) {
        validPassiveServers = ImmutableSet.copyOf(passiveTargetServers);
    } else {
        validPassiveServers = findValidPassiveServers(passiveNodeHostGroupNames, hostGroupTable);
    }
    validPassiveServers = retainOnlySpecifiedAndNonExcludedServers(validPassiveServers, passiveTargetServers);
    Log.warning("validPassiveServers: ", CollectionUtil.toString(validPassiveServers));
    if (Arrays.contains(commands, SKAdminCommand.ClearData) && !options.targetsEqualsExclusionsTarget()) {
        Log.countdownWarning("*** Clearing ALL data ***", unsafeWarningCountdown);
    }
    result = true;
    for (SKAdminCommand command : commands) {
        boolean _result;
        Log.warning("Executing cluster command: ", command);
        serverCommands = createServerCommands(command, validActiveServers, validPassiveServers, hostGroupTable, hostGroupToClassVars, activeHostGroupNames, passiveNodeHostGroupNames);
        displayCommandMap(serverCommands);
        if (!options.displayOnly) {
            _result = execCommandMap(serverCommands, validActiveServers.size() > 0 ? validActiveServers : validPassiveServers, hostGroupTable);
            result = result && _result;
            if (!result) {
                break;
            }
        }
        if (command.equals(SKAdminCommand.StartNodes)) {
            int[] timeouts;
            boolean running;
            int attemptIndex;
            Log.warning("Waiting for nodes to enter running state...");
            timeouts = NumUtil.parseIntArray(options.timeoutSeconds, ",");
            running = false;
            attemptIndex = 0;
            do {
                Pair<Set<IPAndPort>, Boolean> waitResult;
                Set<IPAndPort> failedServers;
                Log.warningf("attemptIndex: %d\ttimeout: %d", attemptIndex, timeouts[attemptIndex]);
                if (replicaSetExcludedByExclusions(exclusionSet)) {
                    return false;
                }
                waitResult = waitUntilRunning(IPAndPort.set(validActiveServers, dhtConfig.getPort()), timeouts[attemptIndex]);
                failedServers = waitResult.getV1();
                if (waitResult.getV2()) {
                    running = true;
                } else {
                    ++attemptIndex;
                    if (attemptIndex < timeouts.length) {
                        Log.warningf("Adding to instance exclusion set: %s", failedServers);
                        if (options.excludeInstanceExclusions) {
                            exclusionSet = exclusionSet.addByIPAndPort(failedServers);
                        }
                        addToInstanceExclusions(failedServers);
                        validActiveServers = removeServers(validActiveServers, failedServers);
                    }
                }
            } while (!running && attemptIndex < timeouts.length);
            if (!running) {
                return false;
            }
        }
    }
    return result;
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) HashSet(java.util.HashSet) ExclusionSet(com.ms.silverking.cloud.meta.ExclusionSet) HostGroupTable(com.ms.silverking.cloud.config.HostGroupTable) ClassVars(com.ms.silverking.cloud.dht.meta.ClassVars)

Example 7 with HostGroupTable

use of com.ms.silverking.cloud.config.HostGroupTable in project SilverKing by Morgan-Stanley.

the class CentralConvergenceController method getPassiveNodes.

private Set<IPAndPort> getPassiveNodes() throws ConvergenceException {
    try {
        HostGroupTable hostGroupTable;
        Set<IPAndPort> validPassiveServers;
        String hostGroupTableName;
        Set<String> passiveNodeHostGroupNames;
        Set<IPAndPort> currentReplicas;
        Set<IPAndPort> targetReplicas;
        Set<IPAndPort> currentButNonTargetReplicas;
        hostGroupTableName = currentRingConfig.getCloudConfiguration().getHostGroupTableName();
        Log.warningAsync("hostGroupTableName: ", hostGroupTableName);
        hostGroupTable = getHostGroupTable(hostGroupTableName, ringMC.getZooKeeper().getZKConfig());
        // FUTURE - Do more validation of configuration. E.g. prevent a server from being both
        // active and passive, the ring from containing servers without class vars, etc.
        passiveNodeHostGroupNames = dhtConfig.getPassiveNodeHostGroupsAsSet();
        Log.warningAsync("passiveNodeHostGroupNames: ", CollectionUtil.toString(passiveNodeHostGroupNames));
        currentReplicas = getCurrentReplicasWithPorts();
        targetReplicas = getTargetReplicasWithPorts();
        currentButNonTargetReplicas = new HashSet<>(currentReplicas);
        currentButNonTargetReplicas.removeAll(targetReplicas);
        validPassiveServers = new HashSet<>(findValidPassiveServers(passiveNodeHostGroupNames, hostGroupTable));
        validPassiveServers.addAll(currentButNonTargetReplicas);
        validPassiveServers.removeAll(IPAndPort.set(exclusionSet.getServers(), dhtConfig.getPort()));
        validPassiveServers.removeAll(targetReplicas);
        Log.warningAsync("validPassiveServers: ", CollectionUtil.toString(validPassiveServers));
        return validPassiveServers;
    } catch (IOException | KeeperException e) {
        throw new ConvergenceException("Exception reading passive nodes", e);
    }
}
Also used : IPAndPort(com.ms.silverking.net.IPAndPort) HostGroupTable(com.ms.silverking.cloud.config.HostGroupTable) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 8 with HostGroupTable

use of com.ms.silverking.cloud.config.HostGroupTable in project SilverKing by Morgan-Stanley.

the class SKAdmin method execCreateSKFSns.

private boolean execCreateSKFSns() throws IOException, ClientException, KeeperException {
    SKFSNamespaceCreator nsCreator;
    String preferredServer;
    Pair<RingConfiguration, InstantiatedRingTree> ringConfigAndTree;
    HostGroupTable hostGroupTable;
    String hostGroupTableName;
    ringConfigAndTree = getRing(dhtConfig, dhtMC);
    Log.warning("ringConfig: ", ringConfigAndTree.getV1());
    hostGroupTableName = ringConfigAndTree.getV1().getCloudConfiguration().getHostGroupTableName();
    Log.warning("hostGroupTableName: ", hostGroupTableName);
    hostGroupTable = getHostGroupTable(hostGroupTableName, dhtMC.getZooKeeper().getZKConfig());
    if (options.preferredServer == null) {
        preferredServer = findArbitraryActiveServer(dhtConfig.getHostGroups(), hostGroupTable);
    } else {
        preferredServer = options.preferredServer;
    }
    Log.warning("Using preferredServer ", preferredServer);
    nsCreator = new SKFSNamespaceCreator(gc.getClientDHTConfiguration(), preferredServer);
    nsCreator.createNamespaces(skfsNamespaces, skfsNSOptions);
    nsCreator.createNamespaces(skfsMutableNamespaces, skfsMutableNSOptions);
    nsCreator.createNamespaces(skfsFileBlockNamespaces, skfsFileBlockNSOptions);
    nsCreator.createNamespaces(skfsDirNamespaces, skfsDirNSOptions);
    return true;
}
Also used : SKFSNamespaceCreator(com.ms.silverking.cloud.skfs.management.SKFSNamespaceCreator) RingConfiguration(com.ms.silverking.cloud.toporing.meta.RingConfiguration) NamedRingConfiguration(com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration) HostGroupTable(com.ms.silverking.cloud.config.HostGroupTable) InstantiatedRingTree(com.ms.silverking.cloud.toporing.InstantiatedRingTree)

Aggregations

HostGroupTable (com.ms.silverking.cloud.config.HostGroupTable)8 StoragePolicyGroup (com.ms.silverking.cloud.storagepolicy.StoragePolicyGroup)5 Topology (com.ms.silverking.cloud.topology.Topology)5 WeightSpecifications (com.ms.silverking.cloud.toporing.meta.WeightSpecifications)5 ExclusionSet (com.ms.silverking.cloud.meta.ExclusionSet)3 NamedRingConfiguration (com.ms.silverking.cloud.toporing.meta.NamedRingConfiguration)3 RingConfiguration (com.ms.silverking.cloud.toporing.meta.RingConfiguration)3 File (java.io.File)3 IOException (java.io.IOException)3 KeeperException (org.apache.zookeeper.KeeperException)3 HostGroupTableZK (com.ms.silverking.cloud.meta.HostGroupTableZK)2 PolicyParser (com.ms.silverking.cloud.storagepolicy.PolicyParser)2 TopologyZK (com.ms.silverking.cloud.topology.TopologyZK)2 RingConfigurationZK (com.ms.silverking.cloud.toporing.meta.RingConfigurationZK)2 IPAndPort (com.ms.silverking.net.IPAndPort)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 ClassVars (com.ms.silverking.cloud.dht.meta.ClassVars)1 CloudConfiguration (com.ms.silverking.cloud.meta.CloudConfiguration)1 ExclusionZK (com.ms.silverking.cloud.meta.ExclusionZK)1 ServerSetExtensionZK (com.ms.silverking.cloud.meta.ServerSetExtensionZK)1