org.apache.cassandra.exceptions.ConfigurationException Java Examples
The following examples show how to use
org.apache.cassandra.exceptions.ConfigurationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MigrationManager.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * actively announce a new version to active hosts via rpc * @param schema The schema mutation to be applied */ private static void announce(Mutation schema, boolean announceLocally) { if (announceLocally) { try { DefsTables.mergeSchemaInternal(Collections.singletonList(schema), false); } catch (ConfigurationException | IOException e) { throw new RuntimeException(e); } } else { FBUtilities.waitOnFuture(announce(Collections.singletonList(schema))); } }
Example #2
Source File: CassSSTableReducer.java From aegisthus with Apache License 2.0 | 6 votes |
@Override protected void setup( Context context) throws IOException, InterruptedException { super.setup(context); maxRowSize = context.getConfiguration().getLong(Aegisthus.Feature.CONF_MAXCOLSIZE, Long.MAX_VALUE); String columnType = context.getConfiguration().get(Aegisthus.Feature.CONF_COLUMNTYPE, "BytesType"); String rowKeyType = context.getConfiguration().get(Aegisthus.Feature.CONF_KEYTYPE, "BytesType"); try { columnComparator = TypeParser.parse(columnType); rowKeyComparator = TypeParser.parse(rowKeyType); } catch (SyntaxException | ConfigurationException e) { throw new RuntimeException(e); } }
Example #3
Source File: TriggerExecutorTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void sameKeySameCfPartialRowMutations() throws ConfigurationException, InvalidRequestException { CFMetaData metadata = makeCfMetaData("ks1", "cf1", TriggerDefinition.create("test", SameKeySameCfPartialTrigger.class.getName())); ColumnFamily cf1 = makeCf(metadata, "k1v1", null); ColumnFamily cf2 = makeCf(metadata, "k2v1", null); Mutation rm1 = new Mutation(bytes("k1"), cf1); Mutation rm2 = new Mutation(bytes("k2"), cf2); List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm1, rm2))); assertEquals(2, tmutations.size()); Collections.sort(tmutations, new RmComparator()); List<ColumnFamily> mutatedCFs = new ArrayList<>(tmutations.get(0).getColumnFamilies()); assertEquals(1, mutatedCFs.size()); assertEquals(bytes("k1v1"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c1")).value()); assertNull(mutatedCFs.get(0).getColumn(getColumnName(metadata, "c2"))); mutatedCFs = new ArrayList<>(tmutations.get(1).getColumnFamilies()); assertEquals(1, mutatedCFs.size()); assertEquals(bytes("k2v1"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c1")).value()); assertEquals(bytes("trigger"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c2")).value()); }
Example #4
Source File: MigrationManager.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private static Future<?> announce(final Collection<Mutation> schema) { Future<?> f = StageManager.getStage(Stage.MIGRATION).submit(new WrappedRunnable() { protected void runMayThrow() throws IOException, ConfigurationException { DefsTables.mergeSchema(schema); } }); for (InetAddress endpoint : Gossiper.instance.getLiveMembers()) { // only push schema to nodes with known and equal versions if (!endpoint.equals(FBUtilities.getBroadcastAddress()) && MessagingService.instance().knowsVersion(endpoint) && MessagingService.instance().getRawVersion(endpoint) == MessagingService.current_version) pushSchemaMutation(endpoint, schema); } return f; }
Example #5
Source File: MultiCloudSnitch.java From brooklyn-library with Apache License 2.0 | 6 votes |
public MultiCloudSnitch() throws ConfigurationException { reloadConfiguration(); logger.info("CustomSnitch using datacenter: " + datacenter + ", rack: " + rack + ", publicip: " + public_ip + ", privateip: " + private_ip); try { FBUtilities.resourceToFile(SNITCH_PROPERTIES_FILENAME); Runnable runnable = new WrappedRunnable() { protected void runMayThrow() throws ConfigurationException { reloadConfiguration(); } }; ResourceWatcher.watch(SNITCH_PROPERTIES_FILENAME, runnable, 60 * 1000); } catch (ConfigurationException ex) { logger.debug(SNITCH_PROPERTIES_FILENAME + " found, but does not look like a plain file. Will not watch it for changes"); } }
Example #6
Source File: CachingOptions.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private static void validateCacheConfig(Map<String, String> cacheConfig) throws ConfigurationException { for (Map.Entry<String, String> entry : cacheConfig.entrySet()) { String value = entry.getValue().toUpperCase(); if (entry.getKey().equals("keys")) { if (!(value.equals("ALL") || value.equals("NONE"))) { throw new ConfigurationException("'keys' can only have values 'ALL' or 'NONE'"); } } else if (entry.getKey().equals("rows_per_partition")) { if (!(value.equals("ALL") || value.equals("NONE") || StringUtils.isNumeric(value))) { throw new ConfigurationException("'rows_per_partition' can only have values 'ALL', 'NONE' or be numeric."); } } else throw new ConfigurationException("Only supported CachingOptions parameters are 'keys' and 'rows_per_partition'"); } }
Example #7
Source File: CachingOptions.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public static CachingOptions fromThrift(String caching, String cellsPerRow) throws ConfigurationException { RowCache rc = new RowCache(RowCache.Type.NONE); KeyCache kc = new KeyCache(KeyCache.Type.ALL); // if we get a caching string from thrift it is legacy, "ALL", "KEYS_ONLY" etc, fromString handles those if (caching != null) { CachingOptions givenOptions = CachingOptions.fromString(caching); rc = givenOptions.rowCache; kc = givenOptions.keyCache; } // if we get cells_per_row from thrift, it is either "ALL" or "<number of cells to cache>". if (cellsPerRow != null && rc.isEnabled()) rc = RowCache.fromString(cellsPerRow); return new CachingOptions(kc, rc); }
Example #8
Source File: GoogleCloudSnitchTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void testRac() throws IOException, ConfigurationException { az = "us-central1-a"; GoogleCloudSnitch snitch = new TestGoogleCloudSnitch(); InetAddress local = InetAddress.getByName("127.0.0.1"); InetAddress nonlocal = InetAddress.getByName("127.0.0.7"); Gossiper.instance.addSavedEndpoint(nonlocal); Map<ApplicationState,VersionedValue> stateMap = Gossiper.instance.getEndpointStateForEndpoint(nonlocal).getApplicationStateMap(); stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("europe-west1")); stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.datacenter("a")); assertEquals("europe-west1", snitch.getDatacenter(nonlocal)); assertEquals("a", snitch.getRack(nonlocal)); assertEquals("us-central1", snitch.getDatacenter(local)); assertEquals("a", snitch.getRack(local)); }
Example #9
Source File: EC2SnitchTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void testRac() throws IOException, ConfigurationException { az = "us-east-1d"; Ec2Snitch snitch = new TestEC2Snitch(); InetAddress local = InetAddress.getByName("127.0.0.1"); InetAddress nonlocal = InetAddress.getByName("127.0.0.7"); Gossiper.instance.addSavedEndpoint(nonlocal); Map<ApplicationState,VersionedValue> stateMap = Gossiper.instance.getEndpointStateForEndpoint(nonlocal).getApplicationStateMap(); stateMap.put(ApplicationState.DC, StorageService.instance.valueFactory.datacenter("us-west")); stateMap.put(ApplicationState.RACK, StorageService.instance.valueFactory.datacenter("1a")); assertEquals("us-west", snitch.getDatacenter(nonlocal)); assertEquals("1a", snitch.getRack(nonlocal)); assertEquals("us-east", snitch.getDatacenter(local)); assertEquals("1d", snitch.getRack(local)); }
Example #10
Source File: Ec2Snitch.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public Ec2Snitch() throws IOException, ConfigurationException { String az = awsApiCall(ZONE_NAME_QUERY_URL); // Split "us-east-1a" or "asia-1a" into "us-east"/"1a" and "asia"/"1a". String[] splits = az.split("-"); ec2zone = splits[splits.length - 1]; // hack for CASSANDRA-4026 ec2region = az.substring(0, az.length() - 1); if (ec2region.endsWith("1")) ec2region = az.substring(0, az.length() - 3); String datacenterSuffix = (new SnitchProperties()).get("dc_suffix", ""); ec2region = ec2region.concat(datacenterSuffix); logger.info("EC2Snitch using region: {}, zone: {}.", ec2region, ec2zone); }
Example #11
Source File: NetworkTopologyStrategyTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void testPropertiesWithEmptyDC() throws IOException, ConfigurationException { IEndpointSnitch snitch = new PropertyFileSnitch(); DatabaseDescriptor.setEndpointSnitch(snitch); TokenMetadata metadata = new TokenMetadata(); createDummyTokens(metadata, false); Map<String, String> configOptions = new HashMap<String, String>(); configOptions.put("DC1", "3"); configOptions.put("DC2", "3"); configOptions.put("DC3", "0"); // Set the localhost to the tokenmetadata. Embedded cassandra way? NetworkTopologyStrategy strategy = new NetworkTopologyStrategy(keyspaceName, metadata, snitch, configOptions); assert strategy.getReplicationFactor("DC1") == 3; assert strategy.getReplicationFactor("DC2") == 3; assert strategy.getReplicationFactor("DC3") == 0; // Query for the natural hosts ArrayList<InetAddress> endpoints = strategy.getNaturalEndpoints(new StringToken("123")); assert 6 == endpoints.size(); assert 6 == new HashSet<InetAddress>(endpoints).size(); // ensure uniqueness }
Example #12
Source File: CloudstackSnitch.java From stratio-cassandra with Apache License 2.0 | 6 votes |
String csMetadataEndpoint() throws ConfigurationException { for (String lease_uri: LEASE_FILES) { try { File lease_file = new File(new URI(lease_uri)); if (lease_file.exists()) { return csEndpointFromLease(lease_file); } } catch (Exception e) { JVMStabilityInspector.inspectThrowable(e); continue; } } throw new ConfigurationException("No valid DHCP lease file could be found."); }
Example #13
Source File: TriggerExecutorTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void sameKeySameCfRowMutations() throws ConfigurationException, InvalidRequestException { CFMetaData metadata = makeCfMetaData("ks1", "cf1", TriggerDefinition.create("test", SameKeySameCfTrigger.class.getName())); ColumnFamily cf1 = makeCf(metadata, "k1v1", null); ColumnFamily cf2 = makeCf(metadata, "k2v1", null); Mutation rm1 = new Mutation(bytes("k1"), cf1); Mutation rm2 = new Mutation(bytes("k2"), cf2); List<? extends IMutation> tmutations = new ArrayList<>(TriggerExecutor.instance.execute(Arrays.asList(rm1, rm2))); assertEquals(2, tmutations.size()); Collections.sort(tmutations, new RmComparator()); List<ColumnFamily> mutatedCFs = new ArrayList<>(tmutations.get(0).getColumnFamilies()); assertEquals(1, mutatedCFs.size()); assertEquals(bytes("k1v1"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c1")).value()); assertEquals(bytes("trigger"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c2")).value()); mutatedCFs = new ArrayList<>(tmutations.get(1).getColumnFamilies()); assertEquals(1, mutatedCFs.size()); assertEquals(bytes("k2v1"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c1")).value()); assertEquals(bytes("trigger"), mutatedCFs.get(0).getColumn(getColumnName(metadata, "c2")).value()); }
Example #14
Source File: RemoveTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Before public void setup() throws IOException, ConfigurationException { tmd.clearUnsafe(); // create a ring of 5 nodes Util.createInitialRing(ss, partitioner, endpointTokens, keyTokens, hosts, hostIds, 6); MessagingService.instance().listen(FBUtilities.getBroadcastAddress()); Gossiper.instance.start(1); removalhost = hosts.get(5); hosts.remove(removalhost); removalId = hostIds.get(5); hostIds.remove(removalId); }
Example #15
Source File: CompressionParameters.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void setCrcCheckChance(double crcCheckChance) throws ConfigurationException { validateCrcCheckChance(crcCheckChance); this.crcCheckChance = crcCheckChance; if (liveMetadata != null) liveMetadata.compressionParameters.setCrcCheckChance(crcCheckChance); }
Example #16
Source File: CqlQueriesIntegrationTest.java From tutorials with MIT License | 5 votes |
@BeforeClass public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException { EmbeddedCassandraServerHelper.startEmbeddedCassandra(25000); final Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build(); LOGGER.info("Server Started at 127.0.0.1:9142... "); final Session session = cluster.connect(); session.execute(KEYSPACE_CREATION_QUERY); session.execute(KEYSPACE_ACTIVATE_QUERY); LOGGER.info("KeySpace created and activated."); Thread.sleep(5000); }
Example #17
Source File: MigrationManager.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static void announceColumnFamilyUpdate(CFMetaData cfm, boolean fromThrift, boolean announceLocally) throws ConfigurationException { cfm.validate(); CFMetaData oldCfm = Schema.instance.getCFMetaData(cfm.ksName, cfm.cfName); if (oldCfm == null) throw new ConfigurationException(String.format("Cannot update non existing column family '%s' in keyspace '%s'.", cfm.cfName, cfm.ksName)); oldCfm.validateCompatility(cfm); logger.info(String.format("Update ColumnFamily '%s/%s' From %s To %s", cfm.ksName, cfm.cfName, oldCfm, cfm)); announce(addSerializedKeyspace(oldCfm.toSchemaUpdate(cfm, FBUtilities.timestampMicros(), fromThrift), cfm.ksName), announceLocally); }
Example #18
Source File: RandomPartitioner.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void validate(String token) throws ConfigurationException { try { BigInteger i = new BigInteger(token); if (i.compareTo(ZERO) < 0) throw new ConfigurationException("Token must be >= 0"); if (i.compareTo(MAXIMUM) > 0) throw new ConfigurationException("Token must be <= 2**127"); } catch (NumberFormatException e) { throw new ConfigurationException(e.getMessage()); } }
Example #19
Source File: SetType.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static SetType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException { List<AbstractType<?>> l = parser.getTypeParameters(); if (l.size() != 1) throw new ConfigurationException("SetType takes exactly 1 type parameter"); return getInstance(l.get(0), true); }
Example #20
Source File: MigrationManager.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static void announceNewKeyspace(KSMetaData ksm, long timestamp, boolean announceLocally) throws ConfigurationException { ksm.validate(); if (Schema.instance.getKSMetaData(ksm.name) != null) throw new AlreadyExistsException(ksm.name); logger.info(String.format("Create new Keyspace: %s", ksm)); announce(ksm.toSchema(timestamp), announceLocally); }
Example #21
Source File: Ec2MultiRegionSnitch.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public Ec2MultiRegionSnitch() throws IOException, ConfigurationException { super(); localPublicAddress = InetAddress.getByName(awsApiCall(PUBLIC_IP_QUERY_URL)); logger.info("EC2Snitch using publicIP as identifier: {}", localPublicAddress); localPrivateAddress = awsApiCall(PRIVATE_IP_QUERY_URL); // use the Public IP to broadcast Address to other nodes. DatabaseDescriptor.setBroadcastAddress(localPublicAddress); DatabaseDescriptor.setBroadcastRpcAddress(localPublicAddress); }
Example #22
Source File: MigrationManager.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static void announceColumnFamilyDrop(String ksName, String cfName, boolean announceLocally) throws ConfigurationException { CFMetaData oldCfm = Schema.instance.getCFMetaData(ksName, cfName); if (oldCfm == null) throw new ConfigurationException(String.format("Cannot drop non existing column family '%s' in keyspace '%s'.", cfName, ksName)); logger.info(String.format("Drop ColumnFamily '%s/%s'", oldCfm.ksName, oldCfm.cfName)); announce(addSerializedKeyspace(oldCfm.dropFromSchema(FBUtilities.timestampMicros()), ksName), announceLocally); }
Example #23
Source File: YamlFileNetworkTopologySnitch.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** * Constructor. * * @param topologyConfigFilename * name of the topology configuration file * @throws ConfigurationException * on failure */ YamlFileNetworkTopologySnitch(final String topologyConfigFilename) throws ConfigurationException { logger.warn("YamlFileNetworkTopologySnitch is deprecated; switch to GossipingPropertyFileSnitch instead"); this.topologyConfigFilename = topologyConfigFilename; loadTopologyConfiguration(); try { /* * Check if the topology configuration file is a plain file. */ FBUtilities.resourceToFile(topologyConfigFilename); final Runnable runnable = new WrappedRunnable() { /** * Loads the topology. */ protected void runMayThrow() throws ConfigurationException { loadTopologyConfiguration(); } }; ResourceWatcher.watch(topologyConfigFilename, runnable, CHECK_PERIOD_IN_MS); } catch (final ConfigurationException e) { logger.debug( "{} found, but does not look like a plain file. Will not watch it for changes", topologyConfigFilename); } }
Example #24
Source File: TupleType.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static TupleType getInstance(TypeParser parser) throws ConfigurationException, SyntaxException { List<AbstractType<?>> types = parser.getTypeParameters(); for (int i = 0; i < types.size(); i++) types.set(i, types.get(i).freeze()); return new TupleType(types); }
Example #25
Source File: AbstractReplicationStrategy.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public static void validateReplicationStrategy(String keyspaceName, Class<? extends AbstractReplicationStrategy> strategyClass, TokenMetadata tokenMetadata, IEndpointSnitch snitch, Map<String, String> strategyOptions) throws ConfigurationException { AbstractReplicationStrategy strategy = createInternal(keyspaceName, strategyClass, tokenMetadata, snitch, strategyOptions); strategy.validateExpectedOptions(); strategy.validateOptions(); }
Example #26
Source File: GossipingPropertyFileSnitch.java From stratio-cassandra with Apache License 2.0 | 5 votes |
private void reloadConfiguration() throws ConfigurationException { final SnitchProperties properties = new SnitchProperties(); String newDc = properties.get("dc", null); String newRack = properties.get("rack", null); if (newDc == null || newRack == null) throw new ConfigurationException("DC or rack not found in snitch properties, check your configuration in: " + SnitchProperties.RACKDC_PROPERTY_FILENAME); newDc = newDc.trim(); newRack = newRack.trim(); final boolean newPreferLocal = Boolean.parseBoolean(properties.get("prefer_local", "false")); if (!newDc.equals(myDC) || !newRack.equals(myRack) || (preferLocal != newPreferLocal)) { myDC = newDc; myRack = newRack; preferLocal = newPreferLocal; reloadGossiperState(); if (StorageService.instance != null) StorageService.instance.getTokenMetadata().invalidateCachedRings(); if (gossipStarted) StorageService.instance.gossipSnitchInfo(); } }
Example #27
Source File: AbstractCassandraTest.java From gpmr with Apache License 2.0 | 5 votes |
@BeforeClass public static void startServer() throws InterruptedException, TTransportException, ConfigurationException, IOException, URISyntaxException { EmbeddedCassandraServerHelper.startEmbeddedCassandra(); Cluster cluster = new Cluster.Builder().addContactPoints("127.0.0.1").withPort(9142).build(); Session session = cluster.connect(); CQLDataLoader dataLoader = new CQLDataLoader(session); dataLoader.load(new ClassPathCQLDataSet("config/cql/create-tables.cql", true, CASSANDRA_UNIT_KEYSPACE)); applyScripts(dataLoader, "config/cql/changelog/", "*.cql"); }
Example #28
Source File: GossipingPropertyFileSnitch.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public GossipingPropertyFileSnitch(int refreshPeriodInSeconds) throws ConfigurationException { snitchHelperReference = new AtomicReference<ReconnectableSnitchHelper>(); reloadConfiguration(); try { psnitch = new PropertyFileSnitch(); logger.info("Loaded {} for compatibility", PropertyFileSnitch.SNITCH_PROPERTIES_FILENAME); } catch (ConfigurationException e) { logger.info("Unable to load {}; compatibility mode disabled", PropertyFileSnitch.SNITCH_PROPERTIES_FILENAME); } try { FBUtilities.resourceToFile(SnitchProperties.RACKDC_PROPERTY_FILENAME); Runnable runnable = new WrappedRunnable() { protected void runMayThrow() throws ConfigurationException { reloadConfiguration(); } }; ResourceWatcher.watch(SnitchProperties.RACKDC_PROPERTY_FILENAME, runnable, refreshPeriodInSeconds * 1000); } catch (ConfigurationException ex) { logger.error("{} found, but does not look like a plain file. Will not watch it for changes", SnitchProperties.RACKDC_PROPERTY_FILENAME); } }
Example #29
Source File: LongFlushMemtableTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Test public void testFlushMemtables() throws IOException, ConfigurationException { Keyspace keyspace = Keyspace.open("Keyspace1"); for (int i = 0; i < 100; i++) { CFMetaData metadata = CFMetaData.denseCFMetaData(keyspace.getName(), "_CF" + i, UTF8Type.instance); MigrationManager.announceNewColumnFamily(metadata); } for (int j = 0; j < 200; j++) { for (int i = 0; i < 100; i++) { Mutation rm = new Mutation("Keyspace1", ByteBufferUtil.bytes("key" + j)); ColumnFamily cf = ArrayBackedSortedColumns.factory.create("Keyspace1", "_CF" + i); // don't cheat by allocating this outside of the loop; that defeats the purpose of deliberately using lots of memory ByteBuffer value = ByteBuffer.allocate(100000); cf.addColumn(new BufferCell(Util.cellname("c"), value)); rm.add(cf); rm.applyUnsafe(); } } int flushes = 0; for (ColumnFamilyStore cfs : ColumnFamilyStore.all()) { if (cfs.name.startsWith("_CF")) flushes += cfs.getMemtableSwitchCount(); } assert flushes > 0; }
Example #30
Source File: SimpleStrategy.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void validateOptions() throws ConfigurationException { String rf = configOptions.get("replication_factor"); if (rf == null) throw new ConfigurationException("SimpleStrategy requires a replication_factor strategy option."); validateReplicationFactor(rf); }