Package org.rhq.cassandra

Examples of org.rhq.cassandra.DeploymentOptions


        }
    }

    private InstallerInfo install(CommandLine cmdLine) throws StorageInstallerException {
        DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
        DeploymentOptions deploymentOptions = factory.newDeploymentOptions();
        InstallerInfo installerInfo = new InstallerInfo();

        if (cmdLine.hasOption("dir")) {
            installerInfo.basedir = new File(cmdLine.getOptionValue("dir"));
            deploymentOptions.setBasedir(installerInfo.basedir.getAbsolutePath());
        } else {
            installerInfo.basedir = new File(serverBasedir, "rhq-storage");
            deploymentOptions.setBasedir(installerInfo.basedir.getAbsolutePath());
        }

        try {
            if (cmdLine.hasOption("n")) {
                installerInfo.hostname = cmdLine.getOptionValue("n");
                // Make sure it is a reachable address
                InetAddress.getByName(installerInfo.hostname);
            } else {
                installerInfo.hostname = InetAddress.getLocalHost().getHostName();
            }

            if (InetAddress.getByName(installerInfo.hostname).isLoopbackAddress()) {
                log.warn("This Storage Node is bound to the loopback address " + installerInfo.hostname + " . "
                    + "It will not be able to communicate with Storage Nodes on other machines,"
                    + " and it can only receive client requests from this machine.");
            }

            deploymentOptions.setListenAddress(installerInfo.hostname);
            deploymentOptions.setRpcAddress(installerInfo.hostname);

            String seeds = cmdLine.getOptionValue(StorageProperty.SEEDS.property(), installerInfo.hostname);
            deploymentOptions.setSeeds(seeds);

            String commitlogDir = cmdLine
                .getOptionValue(StorageProperty.COMMITLOG.property(), getDefaultCommitLogDir());
            String dataDir = cmdLine.getOptionValue(StorageProperty.DATA.property(), getDefaultDataDir());
            String savedCachesDir = cmdLine.getOptionValue(StorageProperty.SAVED_CACHES.property(),
                getDefaultSavedCachesDir());

            File commitLogDirFile = new File(commitlogDir);
            File dataDirFile = new File(dataDir);
            File savedCachesDirFile = new File(savedCachesDir);

            boolean verifyDataDirsEmpty = Boolean.valueOf(cmdLine.getOptionValue(
                StorageProperty.VERIFY_DATA_DIRS_EMPTY.property(), "true"));
            if (verifyDataDirsEmpty) {
                // validate the three data directories are empty - if they are not, we are probably stepping on
                // another storage node
                if (!isDirectoryEmpty(commitLogDirFile)) {
                    log.error("Commitlog directory is not empty. It should not exist for a new Storage Node ["
                        + commitLogDirFile.getAbsolutePath() + "]");
                    throw new StorageInstallerException("Installation cannot proceed. The commit log directory "
                        + commitLogDirFile + " is not empty", STATUS_DATA_DIR_NOT_EMPTY);
                }
                if (!isDirectoryEmpty(dataDirFile)) {
                    log.error("Data directory is not empty. It should not exist for a new Storage Node ["
                        + dataDirFile.getAbsolutePath() + "]");
                    throw new StorageInstallerException("Installation cannot proceed. The data directory "
                        + dataDirFile + " is not empty", STATUS_DATA_DIR_NOT_EMPTY);
                }
                if (!isDirectoryEmpty(savedCachesDirFile)) {
                    log.error("Saved caches directory is not empty. It should not exist for a new Storage Node ["
                        + savedCachesDirFile.getAbsolutePath() + "]");
                    throw new StorageInstallerException("Installation cannot proceed. The saved caches directory "
                        + savedCachesDirFile + " is not empty", STATUS_DATA_DIR_NOT_EMPTY);
                }
            }

            verifyPortStatus(cmdLine, installerInfo);

            deploymentOptions.setCommitLogDir(commitlogDir);
            // TODO add support for specifying multiple dirs
            deploymentOptions.setDataDir(dataDirFile.getPath());
            deploymentOptions.setSavedCachesDir(savedCachesDir);

            deploymentOptions.setLogFileName(installerInfo.logFile);
            deploymentOptions.setLoggingLevel("INFO");

            deploymentOptions.setRpcPort(RPC_PORT);
            deploymentOptions.setCqlPort(installerInfo.cqlPort);
            deploymentOptions.setGossipPort(installerInfo.gossipPort);
            deploymentOptions.setJmxPort(installerInfo.jmxPort);

            deploymentOptions
                .setHeapSize(cmdLine.getOptionValue(StorageProperty.HEAP_SIZE.property(), defaultHeapSize));
            deploymentOptions.setHeapNewSize(cmdLine.getOptionValue(StorageProperty.HEAP_NEW_SIZE.property(),
                defaultHeapNewSize));
            if (cmdLine.hasOption(StorageProperty.STACK_SIZE.property())) {
                deploymentOptions.setStackSize(cmdLine.getOptionValue(StorageProperty.STACK_SIZE.property()));
            }

            // The out of box default for native_transport_max_threads is 128. We default
            // to 64 for dev/test environments so we need to update it here.
            deploymentOptions.setNativeTransportMaxThreads(128);

            deploymentOptions.load();

            List<String> errors = new ArrayList<String>();
            checkPerms(options.getOption(StorageProperty.SAVED_CACHES.property()), savedCachesDir, errors);
            checkPerms(options.getOption(StorageProperty.COMMITLOG.property()), commitlogDir, errors);
            checkPerms(options.getOption(StorageProperty.DATA.property()), dataDir, errors);
View Full Code Here


        return new Deployer();
    }

    private InstallerInfo upgrade(File upgradeFromDir) throws StorageInstallerException {
        DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
        DeploymentOptions deploymentOptions = factory.newDeploymentOptions();
        InstallerInfo installerInfo = new InstallerInfo();

        File existingStorageDir;

        if (!upgradeFromDir.isDirectory()) {
            log.error("The value passed to the upgrade option is not a directory. The value must be a valid "
                + "path that points to the base directory of an existing RHQ server installation.");
            throw new StorageInstallerException("The upgrade cannot proceed. The value passed to the upgrade option "
                + "is invalid.", STATUS_INVALID_UPGRADE);
        }
        existingStorageDir = new File(upgradeFromDir, "rhq-storage");
        if (!(existingStorageDir.exists() && existingStorageDir.isDirectory())) {
            log.error(existingStorageDir + " does not appear to be an existing RHQ storage node installation. "
                + "Check the value that was passed to the upgrade option and make sure it specifies the base "
                + "directory of an existing RHQ server installation.");
            throw new StorageInstallerException("The upgrade cannot proceed. " + existingStorageDir + " is not an "
                + "existing RHQ storage node installation", STATUS_INVALID_UPGRADE);
        }

        try {
            File oldConfDir = new File(existingStorageDir, "conf");
            File oldYamlFile = new File(oldConfDir, "cassandra.yaml");
            File newConfDir = new File(storageBasedir, "conf");
            File newYamlFile = new File(newConfDir, "cassandra.yaml");
            File cassandraEnvFile = new File(oldConfDir, "cassandra-env.sh");
            File cassandraJvmPropsFile = new File(newConfDir, "cassandra-jvm.properties");

            installerInfo.basedir = storageBasedir;

            boolean isRHQ48Install;
            if (cassandraEnvFile.exists()) {
                isRHQ48Install = true;
                installerInfo.jmxPort = parseJmxPortFromCassandrEnv(cassandraEnvFile);
            } else {
                isRHQ48Install = false;
                installerInfo.jmxPort = parseJmxPort(new File(oldConfDir, "cassandra-jvm.properties"));
            }

            deploymentOptions.setBasedir(storageBasedir.getAbsolutePath());
            deploymentOptions.setLogFileName(installerInfo.logFile);
            deploymentOptions.setLoggingLevel("INFO");
            deploymentOptions.setJmxPort(installerInfo.jmxPort);
            deploymentOptions.setHeapSize(defaultHeapSize);
            deploymentOptions.setHeapNewSize(defaultHeapNewSize);

            deploymentOptions.load();

            Deployer deployer = new Deployer();
            deployer.setDeploymentOptions(deploymentOptions);
            storageBasedir.mkdirs();
            deployer.unzipDistro();
View Full Code Here

    private Integer numNodes;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
        DeploymentOptions deploymentOptions = factory.newDeploymentOptions();
        deploymentOptions.setClusterDir(clusterDir.getAbsolutePath());
        deploymentOptions.setNumNodes(numNodes);

        CassandraClusterManager ccm = new CassandraClusterManager(deploymentOptions);

        long start = System.currentTimeMillis();
        getLog().info("Creating " + numNodes + " cluster in " + clusterDir);
        ccm.createCluster();

        getLog().info("Starting cluster nodes");
        ccm.startCluster();

        getLog().info("Installing RHQ schema");
        SchemaManager schemaManager = new SchemaManager(deploymentOptions.getUsername(),
            deploymentOptions.getPassword(), ccm.getNodes(), ccm.getCqlPort());

        try {
            schemaManager.install();
            schemaManager.updateTopology();
        } catch (Exception e) {
View Full Code Here

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        getLog().info("Shutting down cluster in " + clusterDir);
        DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
        DeploymentOptions deploymentOptions = factory.newDeploymentOptions();
        deploymentOptions.setClusterDir(clusterDir.getAbsolutePath());

        long start = System.currentTimeMillis();
        CassandraClusterManager ccm = new CassandraClusterManager(deploymentOptions);
        ccm.shutdownCluster();
        long end = System.currentTimeMillis();
View Full Code Here

                        int cqlPort = -1;

                        if (!Boolean.valueOf(System.getProperty("itest.use-external-storage-node", "false"))) {

                            DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
                            DeploymentOptions options = factory.newDeploymentOptions();
                            File basedir = new File("target");
                            File clusterDir = new File(basedir, "cassandra");

                            options.setUsername("rhqadmin");
                            options.setPassword("1eeb2f255e832171df8592078de921bc");
                            options.setClusterDir(clusterDir.getAbsolutePath());
                            options.setHeapSize("256M");
                            options.setHeapNewSize("64M");
                            options.setStartRpc(true);

                            ccm = new CassandraClusterManager(options);
                            ccm.createCluster();

                            nodes = ccm.getNodes();
View Full Code Here

        initPluginContainer();
    }

    private void deployStorageNode() throws Exception {
        DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
        DeploymentOptions deploymentOptions = factory.newDeploymentOptions();
        String address = "127.0.0.1";

        deploymentOptions.setSeeds(address);
        deploymentOptions.setListenAddress(address);
        deploymentOptions.setRpcAddress(address);
        deploymentOptions.setBasedir(basedir.getAbsolutePath());
        deploymentOptions.setCommitLogDir(new File(basedir, "commit_log").getAbsolutePath());
        deploymentOptions.setDataDir(new File(basedir, "data").getAbsolutePath());
        deploymentOptions.setSavedCachesDir(new File(basedir, "saved_caches").getAbsolutePath());
        deploymentOptions.setCommitLogDir(new File(basedir, "logs").getAbsolutePath());
        deploymentOptions.setLoggingLevel("DEBUG");
        deploymentOptions.setGossipPort(7200);
        deploymentOptions.setCqlPort(9142);
        deploymentOptions.setJmxPort(7399);
        deploymentOptions.setHeapSize("256M");
        deploymentOptions.setHeapNewSize("64M");

        deploymentOptions.load();
        doDeployment(deploymentOptions);

        String[] addresses = new String[] {"127.0.0.1"};
        int[] jmxPorts = new int[] {7399};
View Full Code Here

    @Test(dependsOnMethods = "restartStorageNode", priority = 100)
    public void prepareForBootstrap() throws Exception {
        File node2Basedir = new File(basedir.getParentFile(), "rhq-storage-2");

        try {
            DeploymentOptions deploymentOptions = new DeploymentOptionsFactory().newDeploymentOptions();
            deploymentOptions.setSeeds("127.0.0.1");
            deploymentOptions.setListenAddress("127.0.0.2");
            deploymentOptions.setRpcAddress("127.0.0.2");
            deploymentOptions.setBasedir(node2Basedir.getAbsolutePath());
            deploymentOptions.setCommitLogDir(new File(node2Basedir, "commit_log").getAbsolutePath());
            deploymentOptions.setDataDir(new File(node2Basedir, "data").getAbsolutePath());
            deploymentOptions.setSavedCachesDir(new File(node2Basedir, "saved_caches").getAbsolutePath());
            deploymentOptions.setCommitLogDir(new File(node2Basedir, "logs").getAbsolutePath());
            deploymentOptions.setLoggingLevel("DEBUG");
            deploymentOptions.setGossipPort(7200);
            deploymentOptions.setCqlPort(9142);
            deploymentOptions.setJmxPort(7400);
            deploymentOptions.setHeapSize("256M");
            deploymentOptions.setHeapNewSize("64M");
            deploymentOptions.load();

            doDeployment(deploymentOptions);
            ClusterInitService clusterInitService = new ClusterInitService();
            clusterInitService.waitForClusterToStart(new String [] {"127.0.0.2"}, new int[] {7400});
View Full Code Here

    private CassandraClusterManager ccm;

    @BeforeSuite
    public void deployStorageCluster() {
        DeploymentOptionsFactory factory = new DeploymentOptionsFactory();
        DeploymentOptions deploymentOptions = factory.newDeploymentOptions();
        deploymentOptions.setClusterDir("target/cassandra");
        deploymentOptions.setNumNodes(1);
        deploymentOptions.setUsername("rhqadmin");
        deploymentOptions.setPassword("rhqadmin");
        deploymentOptions.setStartRpc(true);
        deploymentOptions.setHeapSize("256M");
        deploymentOptions.setHeapNewSize("64M");
        deploymentOptions.setJmxPort(8399);

        ccm = new CassandraClusterManager(deploymentOptions);

        if (!Boolean.valueOf(System.getProperty("rhq.storage.deploy", "true"))) {
            return;
View Full Code Here

TOP

Related Classes of org.rhq.cassandra.DeploymentOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.