List of usage examples for org.apache.cassandra.exceptions ConfigurationException ConfigurationException
protected ConfigurationException(ExceptionCode code, String msg)
From source file:brooklyn.entity.nosql.cassandra.customsnitch.MultiCloudSnitch.java
License:Apache License
public void reloadConfiguration() throws ConfigurationException { HashMap<InetAddress, String[]> reloadedMap = new HashMap<InetAddress, String[]>(); String DC_PROPERTY = "dc"; String RACK_PROPERTY = "rack"; String PUBLIC_IP_PROPERTY = "publicip"; String PRIVATE_IP_PROPERTY = "privateip"; Properties properties = new Properties(); InputStream stream = null;/* w w w . j a va2 s .co m*/ try { stream = getClass().getClassLoader().getResourceAsStream(SNITCH_PROPERTIES_FILENAME); properties.load(stream); } catch (Exception e) { throw new ConfigurationException("Unable to read " + SNITCH_PROPERTIES_FILENAME, e); } finally { FileUtils.closeQuietly(stream); } datacenter = properties.getProperty(DC_PROPERTY); rack = properties.getProperty(RACK_PROPERTY); private_ip = checkNotNull(properties.getProperty(PRIVATE_IP_PROPERTY), "%s in %s", PRIVATE_IP_PROPERTY, SNITCH_PROPERTIES_FILENAME); String public_ip_str = checkNotNull(properties.getProperty(PUBLIC_IP_PROPERTY), "%s in %s", PUBLIC_IP_PROPERTY, SNITCH_PROPERTIES_FILENAME); try { public_ip = InetAddress.getByName(public_ip_str); } catch (UnknownHostException e) { throw new ConfigurationException("Unknown host " + public_ip_str, e); } logger.debug("CustomSnitch reloaded, using datacenter: " + datacenter + ", rack: " + rack + ", publicip: " + public_ip + ", privateip: " + private_ip); if (StorageService.instance != null) // null check tolerates circular dependency; see CASSANDRA-4145 StorageService.instance.getTokenMetadata().invalidateCaches(); if (gossipStarted) StorageService.instance.gossipSnitchInfo(); }
From source file:com.jeffjirsa.cassandra.db.compaction.SizeTieredCompactionStrategyOptions.java
License:Apache License
private static double parseDouble(Map<String, String> options, String key, double defaultValue) throws ConfigurationException { String optionValue = options.get(key); try {/*from w w w . ja va 2 s.co m*/ return optionValue == null ? defaultValue : Double.parseDouble(optionValue); } catch (NumberFormatException e) { throw new ConfigurationException(String.format("%s is not a parsable float for %s", optionValue, key), e); } }
From source file:com.protectwise.cassandra.retrospect.deletion.RuleBasedLateTTLConvictor.java
License:Apache License
/** * @param cfs//from ww w .j a v a2s . c om * @param options */ public RuleBasedLateTTLConvictor(ColumnFamilyStore cfs, Map<String, String> options) throws ConfigurationException { super(cfs, options); selectStatement = options.get(RULES_STATEMENT_KEY); if (options.containsKey(DEFAULT_TTL_KEY)) { try { defaultTTL = Long.parseLong(options.get(DEFAULT_TTL_KEY)); } catch (NumberFormatException e) { throw new ConfigurationException( "Invalid value '" + options.get(DEFAULT_TTL_KEY) + "' for " + DEFAULT_TTL_KEY, e); } } else { defaultTTL = null; } List<Rule> rules; try { rules = translateRules(parseRules(selectStatement)); } catch (ConfigurationException e) { // If we haven't fully started up before compaction begins, this error is expected because we can't // necessarily query the rules table. Try to avoid logging errors at startup, however outside of startup // this should be a noisy exception. if (!QueryHelper.hasStartedCQL()) { rules = new ArrayList<>(0); isSpooked = true; logger.info( "Unable to query for deletion rules data, however it looks like this node has not fully joined the ring, so defaulting to a dry run."); } else { throw e; } } this.rules = rules; logger.debug("Got {} rules to consider", rules.size()); }
From source file:com.stratio.cassandra.index.RowIndex.java
License:Apache License
@Override public void validateOptions() throws ConfigurationException { Log.debug("Validating"); try {//from ww w. jav a 2 s . co m ColumnDefinition columnDefinition = columnDefs.iterator().next(); if (baseCfs != null) { new RowIndexConfig(baseCfs.metadata, columnDefinition.getIndexOptions()); Log.debug("Index options are valid"); } else { Log.debug("Validation skipped"); } } catch (Exception e) { String message = "Error while validating index options: " + e.getMessage(); Log.error(e, message); throw new ConfigurationException(message, e); } }
From source file:com.stratio.cassandra.lucene.Index.java
License:Apache License
@Override public void validateOptions() throws ConfigurationException { Log.debug("Validating Lucene index options"); try {/*from ww w .jav a2 s.co m*/ ColumnDefinition columnDefinition = columnDefs.iterator().next(); String ksName = columnDefinition.ksName; String cfName = columnDefinition.cfName; CFMetaData metadata = Schema.instance.getCFMetaData(ksName, cfName); new IndexConfig(metadata, columnDefinition.getIndexOptions()); Log.debug("Lucene index options are valid"); } catch (Exception e) { String message = "Error while validating Lucene index options: " + e.getMessage(); Log.error(e, message); throw new ConfigurationException(message, e); } }
From source file:com.tuplejump.calliope.hadoop.cql3.CqlRecordWriter.java
License:Apache License
private AbstractType<?> parseType(String type) throws ConfigurationException { try {// ww w . j a v a 2 s.co m // always treat counters like longs, specifically CCT.serialize is not what we need if (type != null && type.equals("org.apache.cassandra.db.marshal.CounterColumnType")) return LongType.instance; return TypeParser.parse(type); } catch (SyntaxException e) { throw new ConfigurationException(e.getMessage(), e); } }
From source file:kina.cql.CqlRecordWriter.java
License:Apache License
private AbstractType<?> parseType(String type) throws ConfigurationException { try {//from w w w.j a va 2 s. c o m // always treat counters like longs, specifically CCT.serialize is not what we need if (type != null && "org.apache.cassandra.db.marshal.CounterColumnType".equals(type)) { return LongType.instance; } return TypeParser.parse(type); } catch (SyntaxException e) { throw new ConfigurationException(e.getMessage(), e); } }
From source file:org.elassandra.config.YamlTestConfigurationLoader.java
License:Apache License
@SuppressForbidden(reason = "unchecked") public Config loadConfig(URL url) throws ConfigurationException { try {//from w ww . j av a 2 s. c o m logger.debug("Loading settings from {}", url); byte[] configBytes; try (InputStream is = url.openStream()) { configBytes = ByteStreams.toByteArray(is); } catch (IOException e) { // getStorageConfigURL should have ruled this out throw new AssertionError(e); } org.yaml.snakeyaml.constructor.Constructor constructor = new org.yaml.snakeyaml.constructor.Constructor( Config.class); TypeDescription seedDesc = new TypeDescription(ParameterizedClass.class); seedDesc.putMapPropertyType("parameters", String.class, String.class); constructor.addTypeDescription(seedDesc); MissingPropertiesChecker propertiesChecker = new MissingPropertiesChecker(); constructor.setPropertyUtils(propertiesChecker); Yaml yaml = new Yaml(constructor); Config result = yaml.loadAs(new ByteArrayInputStream(configBytes), Config.class); result.configHintedHandoff(); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-hhmmss", Locale.ROOT); String datadir = System.getProperty("cassandra.storagedir", ".") + File.separator + sdf.format(new Date()) + "_" + new Random().nextInt(); result.commitlog_directory = datadir + File.separator + "commitlog"; result.saved_caches_directory = datadir + File.separator + "saved_caches"; result.data_file_directories = new String[] { datadir + File.separator + "data" }; propertiesChecker.check(); return result; } catch (YAMLException e) { throw new ConfigurationException("Invalid yaml: " + url, e); } }