All Downloads are FREE. Search and download functionalities are using the official Maven repository.

oracle.kv.impl.util.KVStoreMain Maven / Gradle / Ivy

Go to download

NoSQL Database Server - supplies build and runtime support for the server (store) side of the Oracle NoSQL Database.

There is a newer version: 18.3.10
Show newest version
/*-
 * Copyright (C) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This file was distributed by Oracle as part of a version of Oracle NoSQL
 * Database made available at:
 *
 * http://www.oracle.com/technetwork/database/database-technologies/nosqldb/downloads/index.html
 *
 * Please see the LICENSE file included in the top-level directory of the
 * appropriate version of Oracle NoSQL Database for a copy of the license and
 * additional information.
 */

package oracle.kv.impl.util;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import oracle.kv.KVVersion;
import oracle.kv.impl.admin.client.CommandShell;
import oracle.kv.impl.admin.param.BootstrapParams;
import oracle.kv.impl.admin.param.SecurityParams;
import oracle.kv.impl.as.AggregationService;
import oracle.kv.impl.diagnostic.BootConfigVerifier;
import oracle.kv.impl.diagnostic.JavaVersionVerifier;
import oracle.kv.impl.mgmt.MgmtUtil;
import oracle.kv.impl.sna.StorageNodeAgent;
import oracle.kv.impl.sna.StorageNodeAgentImpl;
import oracle.kv.impl.util.SecurityConfigCreator.GenericIOHelper;
import oracle.kv.impl.util.SecurityConfigCreator.ParsedConfig;
import oracle.kv.util.GenerateConfig;
import oracle.kv.util.Load;
import oracle.kv.util.Ping;
import oracle.kv.util.kvlite.KVLite;

/**
 * Used as main class in Jar manifest for kvstore.jar and kvstoretest.jar.
 * Implements certain minor commands here: help, version, makebootconfig.
 * Delegates all other commands to the main() method of other classes.
 *
 * Delegation of parameters is not strictly a pass through:
 * + The first param, the command, is always removed before delegating.
 * + The -shutdown flag is added to the stop command args, since a single class
 *   (StorageNodeAgent/StorageNodeAgentImpl) handles both start and stop.
 *
 * As long as the kvctl and kvlite scripts are supported, for backward
 * compatibility, the CLI of the delegate classes cannot be changed, because
 * these classes are called directly by the scripts.
 */
public class KVStoreMain {

    private static final String HELP_COMMAND_NAME = "help";
    private static final String HELP_COMMAND_DESC = "prints usage info";
    private static final String HELP_COMMANDS_COMMAND = "commands";
    private static final String VERSION_COMMAND_NAME = "version";
    private static final String VERSION_COMMAND_DESC = "prints version";
    private static final String MAKECONFIG_COMMAND_NAME = "makebootconfig";
    private static final String MAKECONFIG_COMMAND_DESC =
        "creates configuration files required in kvroot";
    private static final String HARANGE_FLAG = "-harange";
    private static final String HAHOST_FLAG = "-hahost";
    private static final String SECURITY_CONFIGURE = "configure";
    private static final String SECURITY_ENABLE = "enable";
    private static final String SECURITY_NONE = "none";

    private static final String MAKECONFIG_COMMAND_ARGS =
        CommandParser.getRootUsage() + " " +
        CommandParser.getHostUsage() + " " +
        HARANGE_FLAG + " " + "\n\t" +
        CommandParser.getPortUsage() + "\n\t" +
        CommandParser.optional(MakeConfigParser.STORE_SECURITY_FLAG +
            " ") + "\n\t" +
        CommandParser.optional(CommandParser.getNoAdminUsage()) + "\n\t" +
        CommandParser.optional(MakeConfigParser.FORCE_MAKE_CONFIG_FLAG) +
        CommandParser.optional(CommandParser.getDnsCacheTTLUsage()) +
        CommandParser.optional(StorageNodeAgent.CONFIG_FLAG +
                               " ") + "\n\t" +
        CommandParser.optional(MakeConfigParser.STORAGE_DIR_FLAG +
                               " ") +
        CommandParser.optional(MakeConfigParser.STORAGE_DIR_SIZE_FLAG +
                               " ") + "\n\t" +
        CommandParser.optional(MakeConfigParser.ADMIN_DIR_FLAG +
                               " ") +
        CommandParser.optional(MakeConfigParser.ADMIN_DIR_SIZE_FLAG +
                               " ") + "\n\t" +
        CommandParser.optional(MakeConfigParser.RNLOG_DIR_FLAG +
                               " ") + "\n\t" +
        CommandParser.optional(MakeConfigParser.CAPACITY_FLAG +
                               " ") + "\n\t" +
        CommandParser.optional(MakeConfigParser.CPU_FLAG +
                               " ") +
        CommandParser.optional(MakeConfigParser.MEMORY_FLAG +
                               " ") + "\n\t" +
        CommandParser.optional(MakeConfigParser.SERVICERANGE_FLAG +
                               " ") + "\n\t" +
        CommandParser.optional(MakeConfigParser.ADMIN_WEB_SERVICE_PORT +
                               " ") + "\n\t" +
        CommandParser.optional(HAHOST_FLAG +
                               " ") + "\n\t" +
        SecurityConfigCommand.ConfigParserHelper.getConfigUsage() + "\n\t" +
        MgmtUtil.getMgmtUsage();

    private static final String FLAG_DESCRIPTIONS =
      "\n  -root " +
      "\n\t# the root directory for the store" +
      "\n  -host " +
      "\n\t# the hostname to use" +
      "\n  -port " +
      "\n\t# the registry port to use" +
      "\n  -store " +
      "\n\t# the target store (used by load)" +
      "\n  -source " +
      "\n\t# the snapshot source for load" +
      "\n  -status " +
      "\n\t# the status file used by load" +
      "\n  -noadmin" +
      "\n\t# suppress the starting of a bootstrap admin by an undeployed SNA" +
      "\n  -hahost " +
      "\n\t# the hostname to be used by HA. It defaults to the -host value." +
      "\n  -harange " +
      "\n\t# the range of ports for replicated services to use. " +
      "E.g. \"5030,5040\"" +
      "\n  -servicerange " +
      "\n\t# the range of ports for use by RMI services. " +
      "\n\t# E.g. \"5050,5060\" or \"0\" for unconstrained use of ports" +
      "\n  -config " +
      "\n\t# the configuration file in kvroot, defaults to \"config.xml\"" +
      "\n  -storagedir " +
      "\n\t# directory to use for the Replication Nodes hosted by this SN, " +
      "\n\t# more than one set of -storagedir  flags may be " +
             "specified." +
      "\n  -storagedirsize " +
      "\n\t# size of the directory specified by the -storagedir flag. " +
      "\n\t# If specified, there must be one for each -storagedir flag." +
      "\n\t# An optional unit may be included, where the unit is MB, GB, or TB"+
      "\n\t# separated by a space, \"-\", or \"_\". " +
      "\n  -admindir " +
      "\n\t# directory to use for the Admin node hosted by this SN, " +
      "\n  -admindirsize " +
      "\n\t# size of the directory specified by the -admindir flag. " +
      "\n\t# If specified, there must be one for -admindir flag." +
      "\n\t# An optional unit may be included, where the unit is MB, GB, or TB"+
      "\n\t# separated by a space, \"-\", or \"_\". " +
      "\n  -rnlogdir " +
      "\n\t# directory to use for the logs of Rep Nodes hosted by this SN, " +
      "\n\t# more than one set of -rnlogdir  flags may be " +
             "specified." +
      "\n  -capacity " +
      "\n\t# the number of RepNodes this Storage Node can handle." +
      "\n  -num_cpus " +
      "\n\t# the number of CPUs on the Storage Node." +
      "\n  -memory_mb " +
      "\n\t# the amount of memory available to use." +
      "\n  -script " +
      "\n\t# the admin script file to execute" +
      "\n  -dns-cachettl 




© 2015 - 2025 Weber Informatics LLC | Privacy Policy