/** * Returns a {@code String} containing CQL queries representing the schema of this cluster. * * <p>In other words, this method returns the queries that would allow to recreate the schema of * this cluster. * * <p>Note that the returned String is formatted to be human readable (for some definition of * human readable at least). * * <p>It might be stale or empty if metadata was explicitly disabled with {@link * QueryOptions#setMetadataEnabled(boolean)}. * * @return the CQL queries representing this cluster schema as a {code String}. */ public String exportSchemaAsString() { StringBuilder sb = new StringBuilder(); for (KeyspaceMetadata ksm : keyspaces.values()) sb.append(ksm.exportAsString()).append('\n'); return sb.toString(); }
/** * Returns a {@code String} containing CQL queries representing the schema * of this cluster. * * In other words, this method returns the queries that would allow to * recreate the schema of this cluster. * * Note that the returned String is formatted to be human readable (for * some definition of human readable at least). * * @return the CQL queries representing this cluster schema as a {code * String}. */ public String exportSchemaAsString() { StringBuilder sb = new StringBuilder(); for (KeyspaceMetadata ksm : keyspaces.values()) sb.append(ksm.exportAsString()).append('\n'); return sb.toString(); }
/** * Returns a {@code String} containing CQL queries representing the schema * of this cluster. * <p/> * In other words, this method returns the queries that would allow to * recreate the schema of this cluster. * <p/> * Note that the returned String is formatted to be human readable (for * some definition of human readable at least). * <p/> * It might be stale or empty if metadata was explicitly disabled with * {@link QueryOptions#setMetadataEnabled(boolean)}. * * @return the CQL queries representing this cluster schema as a {code * String}. */ public String exportSchemaAsString() { StringBuilder sb = new StringBuilder(); for (KeyspaceMetadata ksm : keyspaces.values()) sb.append(ksm.exportAsString()).append('\n'); return sb.toString(); }
/** * Returns a {@code String} containing CQL queries representing the schema * of this cluster. * <p/> * In other words, this method returns the queries that would allow to * recreate the schema of this cluster. * <p/> * Note that the returned String is formatted to be human readable (for * some definition of human readable at least). * <p/> * It might be stale or empty if metadata was explicitly disabled with * {@link QueryOptions#setMetadataEnabled(boolean)}. * * @return the CQL queries representing this cluster schema as a {code * String}. */ public String exportSchemaAsString() { StringBuilder sb = new StringBuilder(); for (KeyspaceMetadata ksm : keyspaces.values()) sb.append(ksm.exportAsString()).append('\n'); return sb.toString(); }
/** * Returns a {@code String} containing CQL queries representing the schema * of this cluster. * <p/> * In other words, this method returns the queries that would allow to * recreate the schema of this cluster. * <p/> * Note that the returned String is formatted to be human readable (for * some definition of human readable at least). * <p/> * It might be stale or empty if metadata was explicitly disabled with * {@link QueryOptions#setMetadataEnabled(boolean)}. * * @return the CQL queries representing this cluster schema as a {code * String}. */ public String exportSchemaAsString() { StringBuilder sb = new StringBuilder(); for (KeyspaceMetadata ksm : keyspaces.values()) sb.append(ksm.exportAsString()).append('\n'); return sb.toString(); }
assertThat(userTypes.subList(7, 8)).containsOnly(a); String script = keyspaceMetadata.exportAsString();
assertThat(ks.exportAsString().trim()).isEqualTo(getExpectedCqlString()); newCluster.init(); ks = newCluster.getMetadata().getKeyspace(keyspace); assertThat(ks.exportAsString().trim()).isEqualTo(getExpectedCqlString()); } finally { newCluster.close();
@Override public void run() { Cluster cluster = null; try { // Send TASK_RUNNING sendStatus(driver, Protos.TaskState.TASK_RUNNING, "Started taking schema backup"); cluster = Cluster.builder().addContactPoint(daemon.getProbe().getEndpoint()).build(); final List<String> keyspaces = StorageUtil.filterSystemKeyspaces(daemon.getNonSystemKeySpaces()); if (keyspaces.size() > 0) { StringBuilder sb = new StringBuilder(); for (String keyspace : keyspaces) { LOGGER.info("Taking schema backup for keyspace: {}", keyspace); KeyspaceMetadata ksm = cluster.getMetadata().getKeyspace(keyspace); sb.append(ksm.exportAsString()).append(System.getProperty("line.separator")); } backupStorageDriver.uploadSchema(context, sb.toString()); } // Send TASK_FINISHED sendStatus(driver, Protos.TaskState.TASK_FINISHED, "Finished taking schema backup for keyspaces: " + keyspaces); } catch (Throwable t){ LOGGER.error("Schema backup failed. Reason: ", t); sendStatus(driver, Protos.TaskState.TASK_FAILED, t.getMessage()); } finally { if (cluster != null) cluster.close(); } }
result = Result.createExecutionErrorResult("KEYSPACE " + keyspace + " was not found"); } else { result = CommandResult.createCommandResult(ksInfo.exportAsString());
assertThat(userTypes.subList(7, 8)).containsOnly(a); String script = keyspaceMetadata.exportAsString();
assertThat(ks.exportAsString().trim()).isEqualTo(getExpectedCqlString()); newCluster.init(); ks = newCluster.getMetadata().getKeyspace(keyspace); assertThat(ks.exportAsString().trim()).isEqualTo(getExpectedCqlString()); } finally { newCluster.close();