use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.
the class MigrationManager method announceTableUpdate.
public static void announceTableUpdate(TableMetadata updated, boolean announceLocally) {
updated.validate();
TableMetadata current = Schema.instance.getTableMetadata(updated.keyspace, updated.name);
if (current == null)
throw new ConfigurationException(String.format("Cannot update non existing table '%s' in keyspace '%s'.", updated.name, updated.keyspace));
KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(current.keyspace);
updated.validateCompatibility(current);
long timestamp = FBUtilities.timestampMicros();
logger.info("Update table '{}/{}' From {} To {}", current.keyspace, current.name, current, updated);
Mutation.SimpleBuilder builder = SchemaKeyspace.makeUpdateTableMutation(ksm, current, updated, timestamp);
announce(builder, announceLocally);
}
use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.
the class CompressionParams method removeSstableCompressionClass.
/**
* Removes the option specifying the name of the compression class
*
* @param options the options
* @return the name of the compression class
*/
private static String removeSstableCompressionClass(Map<String, String> options) {
if (options.containsKey(CLASS)) {
if (options.containsKey(SSTABLE_COMPRESSION))
throw new ConfigurationException(format("The '%s' option must not be used if the compression algorithm is already specified by the '%s' option", SSTABLE_COMPRESSION, CLASS));
String clazz = options.remove(CLASS);
if (clazz.isEmpty())
throw new ConfigurationException(format("The '%s' option must not be empty. To disable compression use 'enabled' : false", CLASS));
return clazz;
}
if (options.containsKey(SSTABLE_COMPRESSION) && !hasLoggedSsTableCompressionWarning) {
hasLoggedSsTableCompressionWarning = true;
logger.warn("The {} option has been deprecated. You should use {} instead", SSTABLE_COMPRESSION, CLASS);
}
return options.remove(SSTABLE_COMPRESSION);
}
use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.
the class AlterKeyspaceStatement method validateTransientReplication.
private void validateTransientReplication(AbstractReplicationStrategy oldStrategy, AbstractReplicationStrategy newStrategy) {
// that a good default is to not allow unsafe changes
if (allow_unsafe_transient_changes)
return;
ReplicationFactor oldRF = oldStrategy.getReplicationFactor();
ReplicationFactor newRF = newStrategy.getReplicationFactor();
int oldTrans = oldRF.transientReplicas();
int oldFull = oldRF.fullReplicas;
int newTrans = newRF.transientReplicas();
int newFull = newRF.fullReplicas;
if (newTrans > 0) {
if (DatabaseDescriptor.getNumTokens() > 1)
throw new ConfigurationException(String.format("Transient replication is not supported with vnodes yet"));
Keyspace ks = Keyspace.open(keyspaceName);
for (ColumnFamilyStore cfs : ks.getColumnFamilyStores()) {
if (cfs.viewManager.hasViews()) {
throw new ConfigurationException("Cannot use transient replication on keyspaces using materialized views");
}
if (cfs.indexManager.hasIndexes()) {
throw new ConfigurationException("Cannot use transient replication on keyspaces using secondary indexes");
}
}
}
// to read from a transient replica as if it were a full replica.
if (oldFull > newFull && oldTrans > 0)
throw new ConfigurationException("Can't add full replicas if there are any transient replicas. You must first remove all transient replicas, then change the # of full replicas, then add back the transient replicas");
// Don't increase transient replication factor by more than one at a time if changing number of replicas
// Just like with changing full replicas it's not safe to do this as you could read from too many replicas
// that don't have the necessary data. W/O transient replication this alteration was allowed and it's not clear
// if it should be.
// This is structured so you can convert as many full replicas to transient replicas as you want.
boolean numReplicasChanged = oldTrans + oldFull != newTrans + newFull;
if (numReplicasChanged && (newTrans > oldTrans && newTrans != oldTrans + 1))
throw new ConfigurationException("Can only safely increase number of transients one at a time with incremental repair run in between each time");
}
use of org.apache.cassandra.exceptions.ConfigurationException in project titan by thinkaurelius.
the class CassandraEmbeddedStoreManager method ensureKeyspaceExists.
private void ensureKeyspaceExists(String keyspaceName) throws StorageException {
if (null != Schema.instance.getTableInstance(keyspaceName))
return;
// Keyspace not found; create it
String strategyName = "org.apache.cassandra.locator.SimpleStrategy";
Map<String, String> options = new HashMap<String, String>() {
{
put("replication_factor", String.valueOf(replicationFactor));
}
};
KSMetaData ksm;
try {
ksm = KSMetaData.newKeyspace(keyspaceName, strategyName, options, true);
} catch (ConfigurationException e) {
throw new PermanentStorageException("Failed to instantiate keyspace metadata for " + keyspaceName, e);
}
try {
MigrationManager.announceNewKeyspace(ksm);
log.debug("Created keyspace {}", keyspaceName);
} catch (ConfigurationException e) {
throw new PermanentStorageException("Failed to create keyspace " + keyspaceName, e);
}
}
Aggregations