Search in sources :

Example 16 with ConfigurationException

use of org.apache.cassandra.config.ConfigurationException in project eiger by wlloyd.

the class CompositeType method getInstance.

public static synchronized CompositeType getInstance(List<AbstractType> types) throws ConfigurationException {
    if (types == null || types.isEmpty())
        throw new ConfigurationException("Nonsensical empty parameter list for CompositeType");
    CompositeType ct = instances.get(types);
    if (ct == null) {
        ct = new CompositeType(types);
        instances.put(types, ct);
    }
    return ct;
}
Also used : ConfigurationException(org.apache.cassandra.config.ConfigurationException)

Example 17 with ConfigurationException

use of org.apache.cassandra.config.ConfigurationException in project eiger by wlloyd.

the class TypeParser method getAliasParameters.

public Map<Byte, AbstractType> getAliasParameters() throws ConfigurationException {
    Map<Byte, AbstractType> map = new HashMap<Byte, AbstractType>();
    if (isEOS())
        return map;
    if (str.charAt(idx) != '(')
        throw new IllegalStateException();
    // skipping '('
    ++idx;
    while (skipBlankAndComma()) {
        if (str.charAt(idx) == ')') {
            ++idx;
            return map;
        }
        String alias = readNextIdentifier();
        if (alias.length() != 1)
            throwSyntaxError("An alias should be a single character");
        char aliasChar = alias.charAt(0);
        if (aliasChar < 33 || aliasChar > 127)
            throwSyntaxError("An alias should be a single character in [0..9a..bA..B-+._&]");
        skipBlank();
        if (!(str.charAt(idx) == '=' && str.charAt(idx + 1) == '>'))
            throwSyntaxError("expecting '=>' token");
        idx += 2;
        skipBlank();
        try {
            map.put((byte) aliasChar, parse());
        } catch (ConfigurationException e) {
            ConfigurationException ex = new ConfigurationException(String.format("Exception while parsing '%s' around char %d", str, idx));
            ex.initCause(e);
            throw ex;
        }
    }
    throw new ConfigurationException(String.format("Syntax error parsing '%s' at char %d: unexpected end of string", str, idx));
}
Also used : HashMap(java.util.HashMap) ConfigurationException(org.apache.cassandra.config.ConfigurationException)

Example 18 with ConfigurationException

use of org.apache.cassandra.config.ConfigurationException in project eiger by wlloyd.

the class TypeParser method getAbstractType.

private static AbstractType getAbstractType(String compareWith, TypeParser parser) throws ConfigurationException {
    String className = compareWith.contains(".") ? compareWith : "org.apache.cassandra.db.marshal." + compareWith;
    Class<? extends AbstractType> typeClass = FBUtilities.<AbstractType>classForName(className, "abstract-type");
    try {
        Method method = typeClass.getDeclaredMethod("getInstance", TypeParser.class);
        return (AbstractType) method.invoke(null, parser);
    } catch (NoSuchMethodException e) {
        // Trying to see if we have an instance field and apply the default parameter to it
        AbstractType type = getRawAbstractType(typeClass);
        return AbstractType.parseDefaultParameters(type, parser);
    } catch (IllegalAccessException e) {
        // Trying to see if we have an instance field and apply the default parameter to it
        AbstractType type = getRawAbstractType(typeClass);
        return AbstractType.parseDefaultParameters(type, parser);
    } catch (InvocationTargetException e) {
        ConfigurationException ex = new ConfigurationException("Invalid definition for comparator " + typeClass.getName() + ".");
        ex.initCause(e.getTargetException());
        throw ex;
    }
}
Also used : ConfigurationException(org.apache.cassandra.config.ConfigurationException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 19 with ConfigurationException

use of org.apache.cassandra.config.ConfigurationException in project eiger by wlloyd.

the class TypeParser method getTypeParameters.

public List<AbstractType> getTypeParameters() throws ConfigurationException {
    List<AbstractType> list = new ArrayList<AbstractType>();
    if (isEOS())
        return list;
    if (str.charAt(idx) != '(')
        throw new IllegalStateException();
    // skipping '('
    ++idx;
    while (skipBlankAndComma()) {
        if (str.charAt(idx) == ')') {
            ++idx;
            return list;
        }
        try {
            list.add(parse());
        } catch (ConfigurationException e) {
            ConfigurationException ex = new ConfigurationException(String.format("Exception while parsing '%s' around char %d", str, idx));
            ex.initCause(e);
            throw ex;
        }
    }
    throw new ConfigurationException(String.format("Syntax error parsing '%s' at char %d: unexpected end of string", str, idx));
}
Also used : ConfigurationException(org.apache.cassandra.config.ConfigurationException) ArrayList(java.util.ArrayList)

Example 20 with ConfigurationException

use of org.apache.cassandra.config.ConfigurationException in project eiger by wlloyd.

the class MigrationManager method applyMigrations.

/**
 * gets called during startup if we notice a mismatch between the current migration version and the one saved. This
 * can only happen as a result of the commit log recovering schema updates, which overwrites lastVersionId.
 *
 * This method silently eats IOExceptions thrown by Migration.apply() as a result of applying a migration out of
 * order.
 */
public static void applyMigrations(final UUID from, final UUID to) throws IOException {
    List<Future<?>> updates = new ArrayList<Future<?>>();
    Collection<IColumn> migrations = Migration.getLocalMigrations(from, to);
    for (IColumn col : migrations) {
        // assuming MessagingService.version_ is a bit of a risk, but you're playing with fire if you purposefully
        // take down a node to upgrade it during the middle of a schema update.
        final Migration migration = Migration.deserialize(col.value(), MessagingService.version_);
        Future<?> update = StageManager.getStage(Stage.MIGRATION).submit(new Runnable() {

            public void run() {
                try {
                    migration.apply();
                } catch (ConfigurationException ex) {
                    // this happens if we try to apply something that's already been applied. ignore and proceed.
                    logger.debug("Migration not applied " + ex.getMessage());
                } catch (IOException ex) {
                    throw new RuntimeException(ex);
                }
            }
        });
        updates.add(update);
    }
    // wait on all the updates before proceeding.
    for (Future<?> f : updates) {
        try {
            f.get();
        } catch (InterruptedException e) {
            throw new IOException(e);
        } catch (ExecutionException e) {
            throw new IOException(e);
        }
    }
    // we don't need to send rpcs, but we need to update gossip
    passiveAnnounce(to);
}
Also used : Migration(org.apache.cassandra.db.migration.Migration) IColumn(org.apache.cassandra.db.IColumn) ConfigurationException(org.apache.cassandra.config.ConfigurationException) Future(java.util.concurrent.Future) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ConfigurationException (org.apache.cassandra.config.ConfigurationException)26 IOException (java.io.IOException)10 ByteBuffer (java.nio.ByteBuffer)6 HashMap (java.util.HashMap)4 InvalidRequestException (org.apache.cassandra.thrift.InvalidRequestException)4 Map (java.util.Map)3 CFMetaData (org.apache.cassandra.config.CFMetaData)3 AbstractType (org.apache.cassandra.db.marshal.AbstractType)3 File (java.io.File)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 ExecutionException (java.util.concurrent.ExecutionException)2 Future (java.util.concurrent.Future)2 QueryPath (org.apache.cassandra.db.filter.QueryPath)2 Migration (org.apache.cassandra.db.migration.Migration)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataInputStream (java.io.DataInputStream)1 IOError (java.io.IOError)1 InputStream (java.io.InputStream)1