Search in sources :

Example 1 with IneligibleServerException

use of com.ms.silverking.cloud.dht.meta.IneligibleServerException in project SilverKing by Morgan-Stanley.

the class SKAdmin method verifyServerEligibility.

private void verifyServerEligibility(Set<String> servers, SKAdminCommand[] commands) throws KeeperException {
    if (Arrays.contains(commands, SKAdminCommand.StartNodes)) {
        Set<String> candidateServers;
        Set<String> ineligibleServers;
        DHTRingCurTargetZK dhtRingCurTargetZK;
        InstanceExclusionZK instanceExclusionZK;
        dhtRingCurTargetZK = new DHTRingCurTargetZK(dhtMC, dhtMC.getDHTConfiguration());
        instanceExclusionZK = new InstanceExclusionZK(dhtMC);
        Log.warning("Verifying server eligibility for start");
        candidateServers = new HashSet<>(servers);
        ineligibleServers = HealthMonitor.removeIneligibleServers(candidateServers, dhtRingCurTargetZK, instanceExclusionZK);
        if (ineligibleServers.size() > 0) {
            for (String ineligibleServer : ineligibleServers) {
                Log.warning("Ineligible server: ", ineligibleServer);
            }
            if (!options.forceInclusionOfUnsafeExcludedServers) {
                throw new IneligibleServerException("Attempted to start ineligible servers: " + CollectionUtil.toString(ineligibleServers, ','));
            } else {
                Log.countdownWarning("*** Including unsafe excluded servers. This may result in data loss ***", unsafeWarningCountdown);
            }
        } else {
            Log.warning("Server eligibility verified");
        }
    }
}
Also used : DHTRingCurTargetZK(com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK) IneligibleServerException(com.ms.silverking.cloud.dht.meta.IneligibleServerException) InstanceExclusionZK(com.ms.silverking.cloud.dht.meta.InstanceExclusionZK)

Example 2 with IneligibleServerException

use of com.ms.silverking.cloud.dht.meta.IneligibleServerException in project SilverKing by Morgan-Stanley.

the class SKAdmin method main.

// /////////////////////////////////////////
public static void main(String[] args) {
    boolean success;
    success = false;
    try {
        SKAdmin skAdmin;
        SKAdminOptions options;
        CmdLineParser parser;
        SKGridConfiguration gc;
        SKAdminCommand[] commands;
        LWTPoolProvider.createDefaultWorkPools();
        LWTThreadUtil.setLWTThread();
        options = new SKAdminOptions();
        parser = new CmdLineParser(options);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException cle) {
            System.err.println(cle.getMessage());
            parser.printUsage(System.err);
            System.exit(-1);
        }
        fillDefaultOptions(options);
        sanityCheckOptions(options);
        if (options.gridConfigBase != null) {
            gc = SKGridConfiguration.parseFile(new File(options.gridConfigBase), options.gridConfig);
        } else {
            gc = SKGridConfiguration.parseFile(options.gridConfig);
        }
        if (options.forceInclusionOfUnsafeExcludedServers) {
            Log.countdownWarning("Options requesting unsafe excluded servers. This may result in data loss", unsafeWarningCountdown);
        }
        skAdmin = new SKAdmin(gc, options);
        commands = SKAdminCommand.parseCommands(options.commands);
        success = skAdmin.execCommand(commands);
    } catch (IneligibleServerException ise) {
        throw ise;
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }
    Log.warning("SKAdmin exiting success=" + success);
    if (exitOnCompletion) {
        System.exit(success ? 0 : -1);
    }
}
Also used : CmdLineParser(org.kohsuke.args4j.CmdLineParser) SKGridConfiguration(com.ms.silverking.cloud.dht.gridconfig.SKGridConfiguration) IneligibleServerException(com.ms.silverking.cloud.dht.meta.IneligibleServerException) File(java.io.File) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdLineException(org.kohsuke.args4j.CmdLineException) IneligibleServerException(com.ms.silverking.cloud.dht.meta.IneligibleServerException) ClientException(com.ms.silverking.cloud.dht.client.ClientException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException)

Aggregations

IneligibleServerException (com.ms.silverking.cloud.dht.meta.IneligibleServerException)2 ClientException (com.ms.silverking.cloud.dht.client.ClientException)1 SKGridConfiguration (com.ms.silverking.cloud.dht.gridconfig.SKGridConfiguration)1 DHTRingCurTargetZK (com.ms.silverking.cloud.dht.meta.DHTRingCurTargetZK)1 InstanceExclusionZK (com.ms.silverking.cloud.dht.meta.InstanceExclusionZK)1 File (java.io.File)1 IOException (java.io.IOException)1 KeeperException (org.apache.zookeeper.KeeperException)1 CmdLineException (org.kohsuke.args4j.CmdLineException)1 CmdLineParser (org.kohsuke.args4j.CmdLineParser)1