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;
}
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));
}
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;
}
}
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));
}
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);
}
Aggregations