org.apache.cassandra.config.Schema Java Examples
The following examples show how to use
org.apache.cassandra.config.Schema.
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: Mutation.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public String toString(boolean shallow) { StringBuilder buff = new StringBuilder("Mutation("); buff.append("keyspace='").append(keyspaceName).append('\''); buff.append(", key='").append(ByteBufferUtil.bytesToHex(key)).append('\''); buff.append(", modifications=["); if (shallow) { List<String> cfnames = new ArrayList<String>(modifications.size()); for (UUID cfid : modifications.keySet()) { CFMetaData cfm = Schema.instance.getCFMetaData(cfid); cfnames.add(cfm == null ? "-dropped-" : cfm.cfName); } buff.append(StringUtils.join(cfnames, ", ")); } else buff.append(StringUtils.join(modifications.values(), ", ")); return buff.append("])").toString(); }
Example #2
Source File: SSTableReader.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public static SSTableReader open(Descriptor descriptor) throws IOException { CFMetaData metadata; if (descriptor.cfname.contains(SECONDARY_INDEX_NAME_SEPARATOR)) { int i = descriptor.cfname.indexOf(SECONDARY_INDEX_NAME_SEPARATOR); String parentName = descriptor.cfname.substring(0, i); CFMetaData parent = Schema.instance.getCFMetaData(descriptor.ksname, parentName); ColumnDefinition def = parent.getColumnDefinitionForIndex(descriptor.cfname.substring(i + 1)); metadata = CFMetaData.newIndexMetadata(parent, def, SecondaryIndex.getIndexComparator(parent, def)); } else { metadata = Schema.instance.getCFMetaData(descriptor.ksname, descriptor.cfname); } return open(descriptor, metadata); }
Example #3
Source File: CassandraEmbeddedStoreManager.java From titan1withtp3.1 with Apache License 2.0 | 6 votes |
@Override public void clearStorage() throws BackendException { openStores.clear(); try { KSMetaData ksMetaData = Schema.instance.getKSMetaData(keySpaceName); // Not a big deal if Keyspace doesn't not exist (dropped manually by user or tests). // This is called on per test setup basis to make sure that previous test cleaned // everything up, so first invocation would always fail as Keyspace doesn't yet exist. if (ksMetaData == null) return; for (String cfName : ksMetaData.cfMetaData().keySet()) StorageService.instance.truncate(keySpaceName, cfName); } catch (Exception e) { throw new PermanentBackendException(e); } }
Example #4
Source File: SliceByNamesReadCommand.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public long serializedSize(ReadCommand cmd, int version) { TypeSizes sizes = TypeSizes.NATIVE; SliceByNamesReadCommand command = (SliceByNamesReadCommand) cmd; int size = sizes.sizeof(command.isDigestQuery()); int keySize = command.key.remaining(); CFMetaData metadata = Schema.instance.getCFMetaData(cmd.ksName, cmd.cfName); size += sizes.sizeof(command.ksName); size += sizes.sizeof((short)keySize) + keySize; size += sizes.sizeof(command.cfName); size += sizes.sizeof(cmd.timestamp); size += metadata.comparator.namesQueryFilterSerializer().serializedSize(command.filter, version); return size; }
Example #5
Source File: TriggersSchemaTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void removeTriggerFromCf() throws Exception { TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass); CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName); cfm1.addTriggerDefinition(td); KSMetaData ksm = KSMetaData.newKeyspace(ksName, SimpleStrategy.class, Collections.singletonMap("replication_factor", "1"), true, Collections.singletonList(cfm1)); MigrationManager.announceNewKeyspace(ksm); CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy(); cfm2.removeTrigger(triggerName); MigrationManager.announceColumnFamilyUpdate(cfm2, false); CFMetaData cfm3 = Schema.instance.getCFMetaData(ksName, cfName).copy(); assertTrue(cfm3.getTriggers().isEmpty()); }
Example #6
Source File: TriggersSchemaTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void addTriggerToCf() throws Exception { CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName); KSMetaData ksm = KSMetaData.newKeyspace(ksName, SimpleStrategy.class, Collections.singletonMap("replication_factor", "1"), true, Collections.singletonList(cfm1)); MigrationManager.announceNewKeyspace(ksm); CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName).copy(); TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass); cfm2.addTriggerDefinition(td); MigrationManager.announceColumnFamilyUpdate(cfm2, false); CFMetaData cfm3 = Schema.instance.getCFMetaData(ksName, cfName); assertFalse(cfm3.getTriggers().isEmpty()); assertEquals(1, cfm3.getTriggers().size()); assertEquals(td, cfm3.getTriggers().get(triggerName)); }
Example #7
Source File: RangeSliceCommand.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public RangeSliceCommand deserialize(DataInput in, int version) throws IOException { String keyspace = in.readUTF(); String columnFamily = in.readUTF(); long timestamp = in.readLong(); CFMetaData metadata = Schema.instance.getCFMetaData(keyspace, columnFamily); IDiskAtomFilter predicate = metadata.comparator.diskAtomFilterSerializer().deserialize(in, version); List<IndexExpression> rowFilter; int filterCount = in.readInt(); rowFilter = new ArrayList<>(filterCount); for (int i = 0; i < filterCount; i++) { rowFilter.add(IndexExpression.readFrom(in)); } AbstractBounds<RowPosition> range = AbstractBounds.serializer.deserialize(in, version).toRowBounds(); int maxResults = in.readInt(); boolean countCQL3Rows = in.readBoolean(); boolean isPaging = in.readBoolean(); return new RangeSliceCommand(keyspace, columnFamily, timestamp, predicate, range, rowFilter, maxResults, countCQL3Rows, isPaging); }
Example #8
Source File: CommitLogReplayer.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public static ReplayFilter create() { // If no replaylist is supplied an empty array of strings is used to replay everything. if (System.getProperty("cassandra.replayList") == null) return new AlwaysReplayFilter(); Multimap<String, String> toReplay = HashMultimap.create(); for (String rawPair : System.getProperty("cassandra.replayList").split(",")) { String[] pair = rawPair.trim().split("\\."); if (pair.length != 2) throw new IllegalArgumentException("Each table to be replayed must be fully qualified with keyspace name, e.g., 'system.peers'"); Keyspace ks = Schema.instance.getKeyspaceInstance(pair[0]); if (ks == null) throw new IllegalArgumentException("Unknown keyspace " + pair[0]); if (ks.getColumnFamilyStore(pair[1]) == null) throw new IllegalArgumentException(String.format("Unknown table %s.%s", pair[0], pair[1])); toReplay.put(pair[0], pair[1]); } return new CustomReplayFilter(toReplay); }
Example #9
Source File: AlterKeyspaceStatement.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public void validate(ClientState state) throws RequestValidationException { KSMetaData ksm = Schema.instance.getKSMetaData(name); if (ksm == null) throw new InvalidRequestException("Unknown keyspace " + name); if (ksm.name.equalsIgnoreCase(Keyspace.SYSTEM_KS)) throw new InvalidRequestException("Cannot alter system keyspace"); attrs.validate(); if (attrs.getReplicationStrategyClass() == null && !attrs.getReplicationOptions().isEmpty()) { throw new ConfigurationException("Missing replication strategy class"); } else if (attrs.getReplicationStrategyClass() != null) { // The strategy is validated through KSMetaData.validate() in announceKeyspaceUpdate below. // However, for backward compatibility with thrift, this doesn't validate unexpected options yet, // so doing proper validation here. AbstractReplicationStrategy.validateReplicationStrategy(name, AbstractReplicationStrategy.getClass(attrs.getReplicationStrategyClass()), StorageService.instance.getTokenMetadata(), DatabaseDescriptor.getEndpointSnitch(), attrs.getReplicationOptions()); } }
Example #10
Source File: DefsTables.java From stratio-cassandra with Apache License 2.0 | 6 votes |
/** * Load keyspace definitions for the system keyspace (system.SCHEMA_KEYSPACES_CF) * * @return Collection of found keyspace definitions */ public static Collection<KSMetaData> loadFromKeyspace() { List<Row> serializedSchema = SystemKeyspace.serializedSchema(SystemKeyspace.SCHEMA_KEYSPACES_CF); List<KSMetaData> keyspaces = new ArrayList<>(serializedSchema.size()); for (Row row : serializedSchema) { if (Schema.invalidSchemaRow(row) || Schema.ignoredSchemaRow(row)) continue; keyspaces.add(KSMetaData.fromSchema(row, serializedColumnFamilies(row.key), serializedUserTypes(row.key))); } return keyspaces; }
Example #11
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public String system_drop_column_family(String column_family) throws InvalidRequestException, SchemaDisagreementException, TException { logger.debug("drop_column_family"); ThriftClientState cState = state(); try { String keyspace = cState.getKeyspace(); cState.hasColumnFamilyAccess(keyspace, column_family, Permission.DROP); MigrationManager.announceColumnFamilyDrop(keyspace, column_family); return Schema.instance.getVersion().toString(); } catch (RequestValidationException e) { throw ThriftConversion.toThrift(e); } }
Example #12
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public String system_add_column_family(CfDef cf_def) throws InvalidRequestException, SchemaDisagreementException, TException { logger.debug("add_column_family"); try { ClientState cState = state(); String keyspace = cState.getKeyspace(); cState.hasKeyspaceAccess(keyspace, Permission.CREATE); cf_def.unsetId(); // explicitly ignore any id set by client (Hector likes to set zero) CFMetaData cfm = CFMetaData.fromThrift(cf_def); CFMetaData.validateCompactionOptions(cfm.compactionStrategyClass, cfm.compactionStrategyOptions); cfm.addDefaultIndexNames(); if (!cfm.getTriggers().isEmpty()) state().ensureIsSuper("Only superusers are allowed to add triggers."); MigrationManager.announceNewColumnFamily(cfm); return Schema.instance.getVersion().toString(); } catch (RequestValidationException e) { throw ThriftConversion.toThrift(e); } }
Example #13
Source File: TriggersSchemaTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@Test public void addNewCfWithTriggerToKs() throws Exception { KSMetaData ksm = KSMetaData.newKeyspace(ksName, SimpleStrategy.class, Collections.singletonMap("replication_factor", "1"), true, Collections.EMPTY_LIST); MigrationManager.announceNewKeyspace(ksm); CFMetaData cfm1 = CFMetaData.compile(String.format("CREATE TABLE %s (k int PRIMARY KEY, v int)", cfName), ksName); TriggerDefinition td = TriggerDefinition.create(triggerName, triggerClass); cfm1.addTriggerDefinition(td); MigrationManager.announceNewColumnFamily(cfm1); CFMetaData cfm2 = Schema.instance.getCFMetaData(ksName, cfName); assertFalse(cfm2.getTriggers().isEmpty()); assertEquals(1, cfm2.getTriggers().size()); assertEquals(td, cfm2.getTriggers().get(triggerName)); }
Example #14
Source File: SliceFromReadCommand.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public long serializedSize(ReadCommand cmd, int version) { TypeSizes sizes = TypeSizes.NATIVE; SliceFromReadCommand command = (SliceFromReadCommand) cmd; int keySize = command.key.remaining(); CFMetaData metadata = Schema.instance.getCFMetaData(cmd.ksName, cmd.cfName); int size = sizes.sizeof(cmd.isDigestQuery()); // boolean size += sizes.sizeof(command.ksName); size += sizes.sizeof((short) keySize) + keySize; size += sizes.sizeof(command.cfName); size += sizes.sizeof(cmd.timestamp); size += metadata.comparator.sliceQueryFilterSerializer().serializedSize(command.filter, version); return size; }
Example #15
Source File: SystemKeyspace.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public static void finishStartup() { setupVersion(); migrateIndexInterval(); migrateCachingOption(); // add entries to system schema columnfamilies for the hardcoded system definitions KSMetaData ksmd = Schema.instance.getKSMetaData(Keyspace.SYSTEM_KS); // delete old, possibly obsolete entries in schema columnfamilies for (String cfname : Arrays.asList(SystemKeyspace.SCHEMA_KEYSPACES_CF, SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF, SystemKeyspace.SCHEMA_COLUMNS_CF, SystemKeyspace.SCHEMA_TRIGGERS_CF, SystemKeyspace.SCHEMA_USER_TYPES_CF)) executeOnceInternal(String.format("DELETE FROM system.%s WHERE keyspace_name = ?", cfname), ksmd.name); // (+1 to timestamp to make sure we don't get shadowed by the tombstones we just added) ksmd.toSchema(FBUtilities.timestampMicros() + 1).apply(); }
Example #16
Source File: SystemKeyspace.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private static void serializeSchema(Map<DecoratedKey, Mutation> mutationMap, String schemaCfName) { for (Row schemaRow : serializedSchema(schemaCfName)) { if (Schema.ignoredSchemaRow(schemaRow)) continue; Mutation mutation = mutationMap.get(schemaRow.key); if (mutation == null) { mutation = new Mutation(Keyspace.SYSTEM_KS, schemaRow.key.getKey()); mutationMap.put(schemaRow.key, mutation); } mutation.add(schemaRow.cf); } }
Example #17
Source File: CassandraServer.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public List<KsDef> describe_keyspaces() throws TException, InvalidRequestException { validateLogin(); Set<String> keyspaces = Schema.instance.getKeyspaces(); List<KsDef> ksset = new ArrayList<KsDef>(keyspaces.size()); for (String ks : keyspaces) { try { ksset.add(describe_keyspace(ks)); } catch (NotFoundException nfe) { logger.info("Failed to find metadata for keyspace '{}'. Continuing... ", ks); } } return ksset; }
Example #18
Source File: PreparedStatementsTest.java From stratio-cassandra with Apache License 2.0 | 6 votes |
@BeforeClass public static void setup() throws Exception { Schema.instance.clear(); EmbeddedCassandraService cassandra = new EmbeddedCassandraService(); cassandra.start(); // Currently the native server start method return before the server is fully binded to the socket, so we need // to wait slightly before trying to connect to it. We should fix this but in the meantime using a sleep. Thread.sleep(500); cluster = Cluster.builder().addContactPoint("127.0.0.1") .withPort(DatabaseDescriptor.getNativeTransportPort()) .build(); session = cluster.connect(); session.execute(dropKsStatement); session.execute(createKsStatement); }
Example #19
Source File: StorageService.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void updateSnitch(String epSnitchClassName, Boolean dynamic, Integer dynamicUpdateInterval, Integer dynamicResetInterval, Double dynamicBadnessThreshold) throws ClassNotFoundException { IEndpointSnitch oldSnitch = DatabaseDescriptor.getEndpointSnitch(); // new snitch registers mbean during construction IEndpointSnitch newSnitch; try { newSnitch = FBUtilities.construct(epSnitchClassName, "snitch"); } catch (ConfigurationException e) { throw new ClassNotFoundException(e.getMessage()); } if (dynamic) { DatabaseDescriptor.setDynamicUpdateInterval(dynamicUpdateInterval); DatabaseDescriptor.setDynamicResetInterval(dynamicResetInterval); DatabaseDescriptor.setDynamicBadnessThreshold(dynamicBadnessThreshold); newSnitch = new DynamicEndpointSnitch(newSnitch); } // point snitch references to the new instance DatabaseDescriptor.setEndpointSnitch(newSnitch); for (String ks : Schema.instance.getKeyspaces()) { Keyspace.open(ks).getReplicationStrategy().snitch = newSnitch; } if (oldSnitch instanceof DynamicEndpointSnitch) ((DynamicEndpointSnitch)oldSnitch).unregisterMBean(); }
Example #20
Source File: CompactionManager.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void disableAutoCompaction() { for (String ksname : Schema.instance.getNonSystemKeyspaces()) { for (ColumnFamilyStore cfs : Keyspace.open(ksname).getColumnFamilyStores()) cfs.disableAutoCompaction(); } }
Example #21
Source File: ClientState.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void setKeyspace(String ks) throws InvalidRequestException { // Skip keyspace validation for non-authenticated users. Apparently, some client libraries // call set_keyspace() before calling login(), and we have to handle that. if (user != null && Schema.instance.getKSMetaData(ks) == null) throw new InvalidRequestException("Keyspace '" + ks + "' does not exist"); keyspace = ks; }
Example #22
Source File: PagedRangeCommand.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public PagedRangeCommand deserialize(DataInput in, int version) throws IOException { String keyspace = in.readUTF(); String columnFamily = in.readUTF(); long timestamp = in.readLong(); AbstractBounds<RowPosition> keyRange = AbstractBounds.serializer.deserialize(in, version).toRowBounds(); CFMetaData metadata = Schema.instance.getCFMetaData(keyspace, columnFamily); SliceQueryFilter predicate = metadata.comparator.sliceQueryFilterSerializer().deserialize(in, version); Composite start = metadata.comparator.serializer().deserialize(in); Composite stop = metadata.comparator.serializer().deserialize(in); int filterCount = in.readInt(); List<IndexExpression> rowFilter = new ArrayList<IndexExpression>(filterCount); for (int i = 0; i < filterCount; i++) { rowFilter.add(IndexExpression.readFrom(in)); } int limit = in.readInt(); boolean countCQL3Rows = version >= MessagingService.VERSION_21 ? in.readBoolean() : predicate.compositesToGroup >= 0 || predicate.count != 1; // See #6857 return new PagedRangeCommand(keyspace, columnFamily, timestamp, keyRange, predicate, start, stop, rowFilter, limit, countCQL3Rows); }
Example #23
Source File: PagedRangeCommand.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public long serializedSize(PagedRangeCommand cmd, int version) { long size = 0; size += TypeSizes.NATIVE.sizeof(cmd.keyspace); size += TypeSizes.NATIVE.sizeof(cmd.columnFamily); size += TypeSizes.NATIVE.sizeof(cmd.timestamp); size += AbstractBounds.serializer.serializedSize(cmd.keyRange, version); CFMetaData metadata = Schema.instance.getCFMetaData(cmd.keyspace, cmd.columnFamily); size += metadata.comparator.sliceQueryFilterSerializer().serializedSize((SliceQueryFilter)cmd.predicate, version); size += metadata.comparator.serializer().serializedSize(cmd.start, TypeSizes.NATIVE); size += metadata.comparator.serializer().serializedSize(cmd.stop, TypeSizes.NATIVE); size += TypeSizes.NATIVE.sizeof(cmd.rowFilter.size()); for (IndexExpression expr : cmd.rowFilter) { size += TypeSizes.NATIVE.sizeofWithShortLength(expr.column); size += TypeSizes.NATIVE.sizeof(expr.operator.ordinal()); size += TypeSizes.NATIVE.sizeofWithShortLength(expr.value); } size += TypeSizes.NATIVE.sizeof(cmd.limit); if (version >= MessagingService.VERSION_21) size += TypeSizes.NATIVE.sizeof(cmd.countCQL3Rows); return size; }
Example #24
Source File: StreamReader.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** * @param channel where this reads data from * @return SSTable transferred * @throws IOException if reading the remote sstable fails. Will throw an RTE if local write fails. */ public SSTableWriter read(ReadableByteChannel channel) throws IOException { logger.debug("reading file from {}, repairedAt = {}", session.peer, repairedAt); long totalSize = totalSize(); Pair<String, String> kscf = Schema.instance.getCF(cfId); if (kscf == null) { // schema was dropped during streaming throw new IOException("CF " + cfId + " was dropped during streaming"); } ColumnFamilyStore cfs = Keyspace.open(kscf.left).getColumnFamilyStore(kscf.right); SSTableWriter writer = createWriter(cfs, totalSize, repairedAt); DataInputStream dis = new DataInputStream(new LZFInputStream(Channels.newInputStream(channel))); BytesReadTracker in = new BytesReadTracker(dis); try { while (in.getBytesRead() < totalSize) { writeRow(writer, in, cfs); // TODO move this to BytesReadTracker session.progress(desc, ProgressInfo.Direction.IN, in.getBytesRead(), totalSize); } return writer; } catch (Throwable e) { writer.abort(); drain(dis, in.getBytesRead()); if (e instanceof IOException) throw (IOException) e; else throw Throwables.propagate(e); } }
Example #25
Source File: CommitLogSegmentManager.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** * Force a flush on all CFs that are still dirty in @param segments. * * @return a Future that will finish when all the flushes are complete. */ private Future<?> flushDataFrom(List<CommitLogSegment> segments, boolean force) { if (segments.isEmpty()) return Futures.immediateFuture(null); final ReplayPosition maxReplayPosition = segments.get(segments.size() - 1).getContext(); // a map of CfId -> forceFlush() to ensure we only queue one flush per cf final Map<UUID, ListenableFuture<?>> flushes = new LinkedHashMap<>(); for (CommitLogSegment segment : segments) { for (UUID dirtyCFId : segment.getDirtyCFIDs()) { Pair<String,String> pair = Schema.instance.getCF(dirtyCFId); if (pair == null) { // even though we remove the schema entry before a final flush when dropping a CF, // it's still possible for a writer to race and finish his append after the flush. logger.debug("Marking clean CF {} that doesn't exist anymore", dirtyCFId); segment.markClean(dirtyCFId, segment.getContext()); } else if (!flushes.containsKey(dirtyCFId)) { String keyspace = pair.left; final ColumnFamilyStore cfs = Keyspace.open(keyspace).getColumnFamilyStore(dirtyCFId); // can safely call forceFlush here as we will only ever block (briefly) for other attempts to flush, // no deadlock possibility since switchLock removal flushes.put(dirtyCFId, force ? cfs.forceFlush() : cfs.forceFlush(maxReplayPosition)); } } } return Futures.allAsList(flushes.values()); }
Example #26
Source File: CommitLogSegment.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public String dirtyString() { StringBuilder sb = new StringBuilder(); for (UUID cfId : getDirtyCFIDs()) { CFMetaData m = Schema.instance.getCFMetaData(cfId); sb.append(m == null ? "<deleted>" : m.cfName).append(" (").append(cfId).append("), "); } return sb.toString(); }
Example #27
Source File: StorageService.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** raw load value */ public double getLoad() { double bytes = 0; for (String keyspaceName : Schema.instance.getKeyspaces()) { Keyspace keyspace = Schema.instance.getKeyspaceInstance(keyspaceName); if (keyspace == null) continue; for (ColumnFamilyStore cfs : keyspace.getColumnFamilyStores()) bytes += cfs.getLiveDiskSpaceUsed(); } return bytes; }
Example #28
Source File: StorageService.java From stratio-cassandra with Apache License 2.0 | 5 votes |
private Map<Range<Token>, List<InetAddress>> getRangeToAddressMap(String keyspace, List<Token> sortedTokens) { // some people just want to get a visual representation of things. Allow null and set it to the first // non-system keyspace. if (keyspace == null) keyspace = Schema.instance.getNonSystemKeyspaces().get(0); List<Range<Token>> ranges = getAllRanges(sortedTokens); return constructRangeToEndpointMap(keyspace, ranges); }
Example #29
Source File: RangeSliceCommand.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void serialize(RangeSliceCommand sliceCommand, DataOutputPlus out, int version) throws IOException { out.writeUTF(sliceCommand.keyspace); out.writeUTF(sliceCommand.columnFamily); out.writeLong(sliceCommand.timestamp); CFMetaData metadata = Schema.instance.getCFMetaData(sliceCommand.keyspace, sliceCommand.columnFamily); metadata.comparator.diskAtomFilterSerializer().serialize(sliceCommand.predicate, out, version); if (sliceCommand.rowFilter == null) { out.writeInt(0); } else { out.writeInt(sliceCommand.rowFilter.size()); for (IndexExpression expr : sliceCommand.rowFilter) { expr.writeTo(out); } } AbstractBounds.serializer.serialize(sliceCommand.keyRange, out, version); out.writeInt(sliceCommand.maxResults); out.writeBoolean(sliceCommand.countCQL3Rows); out.writeBoolean(sliceCommand.isPaging); }
Example #30
Source File: SSTableReader.java From stratio-cassandra with Apache License 2.0 | 5 votes |
public void tidy() { // don't try to cleanup if the sstablereader was never fully constructed if (!setup) return; final ColumnFamilyStore cfs = Schema.instance.getColumnFamilyStoreInstance(metadata.cfId); final OpOrder.Barrier barrier; if (cfs != null) { barrier = cfs.readOrdering.newBarrier(); barrier.issue(); } else barrier = null; ScheduledExecutors.nonPeriodicTasks.execute(new Runnable() { public void run() { if (barrier != null) barrier.await(); bf.close(); if (summary != null) summary.close(); if (runOnClose != null) runOnClose.run(); dfile.close(); ifile.close(); typeRef.release(); } }); }