Package org.rhq.cassandra.schema

Examples of org.rhq.cassandra.schema.SchemaManager


        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) {
            throw new MojoExecutionException("Schema installation failed.", e);
        }

        long end = System.currentTimeMillis();
View Full Code Here


        for (int index = 0; index < storageNodes.size(); index++) {
            nodes[index] = storageNodes.get(index).getAddress();
        }
        int cqlPort = storageNodes.get(0).getCqlPort();

        SchemaManager schemaManager = new SchemaManager(username, password, nodes, cqlPort);
        try {
            schemaManager.checkCompatibility();
        } catch (NoHostAvailableException e) {
            throw e;
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        } finally {
            schemaManager.shutdown();
        }
    }
View Full Code Here

        try {
            info.append("Checking Storage Cluster Schema Version...");
            info.append("\n\n");

            SchemaManager storageNodeSchemaManager = createStorageNodeSchemaManager(serverProperties);
            storageNodeSchemaManager.checkCompatibility();
            info.append("  ==> The Storage Cluster version is up to date. No update required.");

        } catch (NoHostAvailableException e1) {
            info.append("  ==> Could not connect to Storage Cluster.\n");
            info.append("  ==> To check Storage Cluster schema version start all nodes of the Storage Cluster and execute 'rhqctl uprade --list-versions'.");
View Full Code Here

    }

    private Set<String> prepareStorageSchema(HashMap<String, String> serverProperties, String clearTextDbPassword,
        ExistingSchemaOption existingSchemaOptionEnum) throws Exception {

        SchemaManager storageNodeSchemaManager = null;
        Set<String> storageNodeAddresses = Collections.emptySet();
        try {
            storageNodeSchemaManager = createStorageNodeSchemaManager(serverProperties);
            if (ExistingSchemaOption.SKIP != existingSchemaOptionEnum) {
                if (ExistingSchemaOption.OVERWRITE == existingSchemaOptionEnum) {
                    log("Storage cluster schema exists but the installer was told to overwrite it - dropping existing schema...");
                    storageNodeSchemaManager.drop();
                }

                final String dbPassword = clearTextDbPassword;
                final String dbUrl = serverProperties.get(ServerProperties.PROP_DATABASE_CONNECTION_URL);
                final String dbUsername = serverProperties.get(ServerProperties.PROP_DATABASE_USERNAME);
                DBConnectionFactory connectionFactory = new DBConnectionFactory() {
                    @Override
                    public Connection newConnection() throws SQLException {
                        return DbUtil.getConnection(dbUrl, dbUsername, dbPassword);
                    }
                };
                Properties schemaProperties = new Properties();
                schemaProperties.put(SchemaManager.RELATIONAL_DB_CONNECTION_FACTORY_PROP, connectionFactory);
                schemaProperties.put(SchemaManager.DATA_DIR, getAppServerDataDir());

                try {
                    storageNodeSchemaManager.checkCompatibility();

                } catch (AuthenticationException e1) {
                    log("Storage user does not exist. Installing Storage Cluster schema along with updates to storage nodes.");
                    storageNodeSchemaManager.install(schemaProperties);
                    storageNodeSchemaManager.updateTopology();
                } catch (SchemaNotInstalledException e2) {
                    log("Storage cluster Schema does not exist. Installing Storage Cluster schema along with updates to storage nodes.");
                    storageNodeSchemaManager.install(schemaProperties);
                    storageNodeSchemaManager.updateTopology();
                } catch (InstalledSchemaTooOldException e3) {
                    log("Storage cluster Schema out of date. Applying Storage Cluster schema updates.");
                    storageNodeSchemaManager.install(schemaProperties);
                }
                storageNodeAddresses = storageNodeSchemaManager.getStorageNodeAddresses();
                storageNodeSchemaManager.shutdown();
            } else {
                log("Ignoring storage cluster schema - installer will assume it exists and is already up-to-date.");
            }
        } catch (NoHostAvailableException e) {
            log.error("Failed to connect to the storage cluster. Please check the following:\n"
View Full Code Here

        for (int index = 0; index < storageNodes.size(); index++) {
            nodes[index] = storageNodes.get(index).getAddress();
        }
        int cqlPort = storageNodes.get(0).getCqlPort();

        return new SchemaManager(username, password, nodes, cqlPort);
    }
View Full Code Here

        }
        log.info(serviceName + " shut down complete");
    }

    private void createSchema(String[] nodes, int cqlPort) {
        SchemaManager schemaManager = new SchemaManager("rhqadmin", "1eeb2f255e832171df8592078de921bc", nodes,
            cqlPort);
        try {
            log.info("Creating schema");
            schemaManager.install();
        } catch (Exception e) {
            throw new RuntimeException("Failed to start simulator. An error occurred during schema creation.", e);
        } finally {
            schemaManager.shutdown();
        }
    }
View Full Code Here

        }
        ccm.startCluster(false);

        clusterInitService.waitForClusterToStart(nodes, jmxPorts, nodes.length, 2000, 20, 10);

        SchemaManager schemaManager = new SchemaManager(annotation.username(), annotation.password(), nodes,
            ccm.getCqlPort());
        try {
            schemaManager.install();
            if (annotation.waitForSchemaAgreement()) {
                clusterInitService.waitForSchemaAgreement(nodes, jmxPorts);
            }
            schemaManager.updateTopology();
        } finally {
            schemaManager.shutdown();
        }
    }
View Full Code Here

        public void initCassandra(@Observes(precedence = -100)
        final BeforeStart event, ArquillianDescriptor descriptor) {

            executeInClassScope(new Callable<Void>() {
                public Void call() throws Exception {
                    SchemaManager schemaManager = null;
                    try {
                        ClusterInitService clusterInitService = new ClusterInitService();

                        String[] nodes = null;
                        int[] jmxPorts = null;
                        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();
                            jmxPorts = ccm.getJmxPorts();
                            cqlPort = ccm.getCqlPort();

                            ccm.startCluster(false);

                            try {
                                clusterInitService.waitForClusterToStart(nodes, jmxPorts, nodes.length, 2000, 20, 10);
                                schemaManager = new SchemaManager("rhqadmin", "1eeb2f255e832171df8592078de921bc", nodes,
                                    cqlPort);
                            } catch (Exception e) {
                                if (null != ccm) {
                                    ccm.shutdownCluster();
                                }
                                throw new RuntimeException("Cassandra cluster initialization failed", e);
                            }
                        } else {
                            try {
                                String nodesString = System.getProperty("rhq.storage.nodes", "127.0.0.1");
                                nodes = nodesString.split(",");

                                String cqlPortString = System.getProperty("rhq.storage.cql-port", "9042");
                                cqlPort = Integer.parseInt(cqlPortString);

                                String jmxPortString = System.getProperty("rhq.storage.jmx-port", "7299");
                                jmxPorts = new int[] { Integer.parseInt(jmxPortString) };

                                schemaManager = new SchemaManager("rhqadmin", "1eeb2f255e832171df8592078de921bc", nodes, cqlPort);

                            } catch (Exception e) {
                                throw new RuntimeException("External Cassandra initialization failed", e);
                            }
                        }
                        try {
                            schemaManager.install();
                            clusterInitService.waitForSchemaAgreement(nodes, jmxPorts);
                            schemaManager.updateTopology();
                        } catch (Exception e) {
                            if (null != ccm) {
                                ccm.shutdownCluster();
                            }
                            throw new RuntimeException("Cassandra schema initialization failed", e);
                        }
                        return null;
                    } finally {
                        if (schemaManager != null) {
                            schemaManager.shutdown();
                        }
                    }
                }
            });
        }
View Full Code Here

        int[] jmxPorts = new int[] {7399};

        ClusterInitService clusterInitService = new ClusterInitService();
        clusterInitService.waitForClusterToStart(addresses, jmxPorts);

        SchemaManager schemaManager = new SchemaManager("rhqadmin", "1eeb2f255e832171df8592078de921bc",
            addresses, 9142);
        try {
            schemaManager.install();
            schemaManager.updateTopology();
        } finally {
            schemaManager.shutdown();
        }
    }
View Full Code Here

TOP

Related Classes of org.rhq.cassandra.schema.SchemaManager

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.