Java Code Examples for org.apache.cassandra.config.DatabaseDescriptor#setPartitioner()
The following examples show how to use
org.apache.cassandra.config.DatabaseDescriptor#setPartitioner() .
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: StorageService.java From stratio-cassandra with Apache License 2.0 | 5 votes |
IPartitioner setPartitionerUnsafe(IPartitioner newPartitioner) { IPartitioner oldPartitioner = DatabaseDescriptor.getPartitioner(); DatabaseDescriptor.setPartitioner(newPartitioner); valueFactory = new VersionedValue.VersionedValueFactory(getPartitioner()); return oldPartitioner; }
Example 2
Source File: MerkleTreeTest.java From stratio-cassandra with Apache License 2.0 | 5 votes |
@Before public void clear() { TOKEN_SCALE = new BigInteger("8"); partitioner = new RandomPartitioner(); // TODO need to trickle TokenSerializer DatabaseDescriptor.setPartitioner(partitioner); mt = new MerkleTree(partitioner, fullRange(), RECOMMENDED_DEPTH, Integer.MAX_VALUE); }
Example 3
Source File: AbstractSSTableSimpleWriter.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public AbstractSSTableSimpleWriter(File directory, CFMetaData metadata, IPartitioner partitioner) { this.metadata = metadata; this.directory = directory; DatabaseDescriptor.setPartitioner(partitioner); }
Example 4
Source File: SSTableLoader.java From stratio-cassandra with Apache License 2.0 | 4 votes |
protected void setPartitioner(IPartitioner partitioner) { this.partitioner = partitioner; // the following is still necessary since Range/Token reference partitioner through StorageService.getPartitioner DatabaseDescriptor.setPartitioner(partitioner); }
Example 5
Source File: CountTombstones.java From cassandra-opstools with Apache License 2.0 | 4 votes |
/** * Counts the number of tombstones, per row, in a given SSTable * * Assumes RandomPartitioner, standard columns and UTF8 encoded row keys * * Does not require a cassandra.yaml file or system tables. * * @param args command lines arguments * * @throws java.io.IOException on failure to open/read/write files or output streams */ public static void main(String[] args) throws IOException, ParseException { String usage = String.format("Usage: %s [-l] <sstable> [<sstable> ...]%n", CountTombstones.class.getName()); final Options options = new Options(); options.addOption("l", "legend", false, "Include column name explanation"); options.addOption("p", "partitioner", true, "The partitioner used by database"); CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(options, args); if (cmd.getArgs().length < 1) { System.err.println("You must supply at least one sstable"); System.err.println(usage); System.exit(1); } // Fake DatabaseDescriptor settings so we don't have to load cassandra.yaml etc Config.setClientMode(true); String partitionerName = String.format("org.apache.cassandra.dht.%s", cmd.hasOption("p") ? cmd.getOptionValue("p") : "RandomPartitioner"); try { Class<?> clazz = Class.forName(partitionerName); IPartitioner partitioner = (IPartitioner) clazz.newInstance(); DatabaseDescriptor.setPartitioner(partitioner); } catch (Exception e) { throw new RuntimeException("Can't instantiate partitioner " + partitionerName); } PrintStream out = System.out; for (String arg : cmd.getArgs()) { String ssTableFileName = new File(arg).getAbsolutePath(); Descriptor descriptor = Descriptor.fromFilename(ssTableFileName); run(descriptor, cmd, out); } System.exit(0); }