Search in sources :

Example 1 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project titan by thinkaurelius.

the class CassandraEmbeddedStoreManager method ensureColumnFamilyExists.

private void ensureColumnFamilyExists(String keyspaceName, String columnfamilyName, AbstractType<?> comparator) throws BackendException {
    if (null != Schema.instance.getCFMetaData(keyspaceName, columnfamilyName))
        return;
    // Column Family not found; create it
    CFMetaData cfm = new CFMetaData(keyspaceName, columnfamilyName, ColumnFamilyType.Standard, CellNames.fromAbstractType(comparator, true));
    // Hard-coded caching settings
    if (columnfamilyName.startsWith(Backend.EDGESTORE_NAME)) {
        cfm.caching(CachingOptions.KEYS_ONLY);
    } else if (columnfamilyName.startsWith(Backend.INDEXSTORE_NAME)) {
        cfm.caching(CachingOptions.ROWS_ONLY);
    }
    // Configure sstable compression
    final CompressionParameters cp;
    if (compressionEnabled) {
        try {
            cp = new CompressionParameters(compressionClass, compressionChunkSizeKB * 1024, Collections.<String, String>emptyMap());
            // CompressionParameters doesn't override toString(), so be explicit
            log.debug("Creating CF {}: setting {}={} and {}={} on {}", new Object[] { columnfamilyName, CompressionParameters.SSTABLE_COMPRESSION, compressionClass, CompressionParameters.CHUNK_LENGTH_KB, compressionChunkSizeKB, cp });
        } catch (ConfigurationException ce) {
            throw new PermanentBackendException(ce);
        }
    } else {
        cp = new CompressionParameters(null);
        log.debug("Creating CF {}: setting {} to null to disable compression", columnfamilyName, CompressionParameters.SSTABLE_COMPRESSION);
    }
    cfm.compressionParameters(cp);
    try {
        cfm.addDefaultIndexNames();
    } catch (ConfigurationException e) {
        throw new PermanentBackendException("Failed to create column family metadata for " + keyspaceName + ":" + columnfamilyName, e);
    }
    try {
        MigrationManager.announceNewColumnFamily(cfm);
        log.info("Created CF {} in KS {}", columnfamilyName, keyspaceName);
    } catch (ConfigurationException e) {
        throw new PermanentBackendException("Failed to create column family " + keyspaceName + ":" + columnfamilyName, e);
    }
    /*
         * I'm chasing a nondetermistic exception that appears only rarely on my
         * machine when executing the embedded cassandra tests. If these dummy
         * reads ever actually fail and dump a log message, it could help debug
         * the root cause.
         *
         *   java.lang.RuntimeException: java.lang.IllegalArgumentException: Unknown table/cf pair (InternalCassandraEmbeddedKeyColumnValueTest.testStore1)
         *          at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:1582)
         *           at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
         *           at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
         *           at java.lang.Thread.run(Thread.java:744)
         *   Caused by: java.lang.IllegalArgumentException: Unknown table/cf pair (InternalCassandraEmbeddedKeyColumnValueTest.testStore1)
         *           at org.apache.cassandra.db.Table.getColumnFamilyStore(Table.java:166)
         *           at org.apache.cassandra.db.Table.getRow(Table.java:354)
         *           at org.apache.cassandra.db.SliceFromReadCommand.getRow(SliceFromReadCommand.java:70)
         *           at org.apache.cassandra.service.StorageProxy$LocalReadRunnable.runMayThrow(StorageProxy.java:1052)
         *           at org.apache.cassandra.service.StorageProxy$DroppableRunnable.run(StorageProxy.java:1578)
         *           ... 3 more
         */
    retryDummyRead(keyspaceName, columnfamilyName);
}
Also used : ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException) CompressionParameters(org.apache.cassandra.io.compress.CompressionParameters) CFMetaData(org.apache.cassandra.config.CFMetaData)

Example 2 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class MigrationManager method announceKeyspaceUpdate.

public static void announceKeyspaceUpdate(KeyspaceMetadata ksm, boolean announceLocally) throws ConfigurationException {
    ksm.validate();
    KeyspaceMetadata oldKsm = Schema.instance.getKeyspaceMetadata(ksm.name);
    if (oldKsm == null)
        throw new ConfigurationException(String.format("Cannot update non existing keyspace '%s'.", ksm.name));
    logger.info("Update Keyspace '{}' From {} To {}", ksm.name, oldKsm, ksm);
    announce(SchemaKeyspace.makeCreateKeyspaceMutation(ksm.name, ksm.params, FBUtilities.timestampMicros()), announceLocally);
}
Also used : ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException)

Example 3 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class MigrationManager method announceViewUpdate.

public static void announceViewUpdate(ViewMetadata view, boolean announceLocally) throws ConfigurationException {
    view.metadata.validate();
    ViewMetadata oldView = Schema.instance.getView(view.keyspace, view.name);
    if (oldView == null)
        throw new ConfigurationException(String.format("Cannot update non existing materialized view '%s' in keyspace '%s'.", view.name, view.keyspace));
    KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(view.keyspace);
    oldView.metadata.validateCompatibility(view.metadata);
    logger.info("Update view '{}/{}' From {} To {}", view.keyspace, view.name, oldView, view);
    announce(SchemaKeyspace.makeUpdateViewMutation(ksm, oldView, view, FBUtilities.timestampMicros()), announceLocally);
}
Also used : ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException)

Example 4 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class MigrationManager method announceKeyspaceDrop.

public static void announceKeyspaceDrop(String ksName, boolean announceLocally) throws ConfigurationException {
    KeyspaceMetadata oldKsm = Schema.instance.getKeyspaceMetadata(ksName);
    if (oldKsm == null)
        throw new ConfigurationException(String.format("Cannot drop non existing keyspace '%s'.", ksName));
    logger.info("Drop Keyspace '{}'", oldKsm.name);
    announce(SchemaKeyspace.makeDropKeyspaceMutation(oldKsm, FBUtilities.timestampMicros()), announceLocally);
}
Also used : ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException)

Example 5 with ConfigurationException

use of org.apache.cassandra.exceptions.ConfigurationException in project cassandra by apache.

the class MigrationManager method announceNewView.

public static void announceNewView(ViewMetadata view, boolean announceLocally) throws ConfigurationException {
    view.metadata.validate();
    KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(view.keyspace);
    if (ksm == null)
        throw new ConfigurationException(String.format("Cannot add table '%s' to non existing keyspace '%s'.", view.name, view.keyspace));
    else if (ksm.getTableOrViewNullable(view.name) != null)
        throw new AlreadyExistsException(view.keyspace, view.name);
    logger.info("Create new view: {}", view);
    announce(SchemaKeyspace.makeCreateViewMutation(ksm, view, FBUtilities.timestampMicros()), announceLocally);
}
Also used : AlreadyExistsException(org.apache.cassandra.exceptions.AlreadyExistsException) ConfigurationException(org.apache.cassandra.exceptions.ConfigurationException)

Aggregations

ConfigurationException (org.apache.cassandra.exceptions.ConfigurationException)84 IOException (java.io.IOException)12 URL (java.net.URL)6 HashMap (java.util.HashMap)6 Keyspace (org.apache.cassandra.db.Keyspace)5 DataInputStream (java.io.DataInputStream)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 HttpURLConnection (java.net.HttpURLConnection)4 Map (java.util.Map)4 Matcher (java.util.regex.Matcher)4 File (org.apache.cassandra.io.util.File)4 FilterInputStream (java.io.FilterInputStream)3 UnknownHostException (java.net.UnknownHostException)3 CFMetaData (org.apache.cassandra.config.CFMetaData)3 IPartitioner (org.apache.cassandra.dht.IPartitioner)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 PermanentStorageException (com.thinkaurelius.titan.diskstorage.PermanentStorageException)2 InputStream (java.io.InputStream)2 InetAddress (java.net.InetAddress)2 HashSet (java.util.HashSet)2