RepairFuture submitArtificialRepairSession(RepairJobDesc desc) { Set<InetAddress> neighbours = new HashSet<>(); Collection<Range<Token>> keyspaceLocalRanges = StorageService.instance.getLocalRanges(desc.keyspace); neighbours.addAll(ActiveRepairService.getNeighbors(desc.keyspace, keyspaceLocalRanges, desc.range, null, null)); RepairSession session = new RepairSession(desc.parentSessionId, desc.sessionId, desc.range, desc.keyspace, RepairParallelism.PARALLEL, neighbours, new String[]{desc.columnFamily}); sessions.put(session.getId(), session); RepairFuture futureTask = new RepairFuture(session); executor.execute(futureTask); return futureTask; }
public int forceRepairAsync(String keyspace, boolean isSequential, boolean isLocal, boolean primaryRange, boolean fullRepair, String... columnFamilies) { Collection<Range<Token>> ranges; if (primaryRange) { ranges = isLocal ? getPrimaryRangesWithinDC(keyspace) : getPrimaryRanges(keyspace); } else { ranges = getLocalRanges(keyspace); } return forceRepairAsync(keyspace, isSequential, isLocal, ranges, fullRepair, columnFamilies); }
public CompactionInfo getCompactionInfo() { long rangesLeft = 0, rangesTotal = 0; Token lastToken = prevToken; // This approximation is not very accurate, but since we do not have a method which allows us to calculate the // percentage of a range covered by a second range, this is the best approximation that we can calculate. // Instead, we just count the total number of ranges that haven't been seen by the node (we use the order of // the tokens to determine whether they have been seen yet or not), and the total number of ranges that a node // has. for (Range<Token> range : StorageService.instance.getLocalRanges(baseCfs.keyspace.getName())) { rangesLeft++; rangesTotal++; // This will reset rangesLeft, so that the number of ranges left will be less than the total ranges at the // end of the method. if (lastToken == null || range.contains(lastToken)) rangesLeft = 0; } return new CompactionInfo(baseCfs.metadata, OperationType.VIEW_BUILD, rangesLeft, rangesTotal, "ranges", compactionId); }
public CompactionInfo getCompactionInfo() { long rangesCompleted = 0, rangesTotal = 0; Token lastToken = prevToken; // This approximation is not very accurate, but since we do not have a method which allows us to calculate the // percentage of a range covered by a second range, this is the best approximation that we can calculate. // Instead, we just count the total number of ranges that haven't been seen by the node (we use the order of // the tokens to determine whether they have been seen yet or not), and the total number of ranges that a node // has. for (Range<Token> range : StorageService.instance.getLocalRanges(baseCfs.keyspace.getName())) { rangesTotal++; if ((lastToken != null) && lastToken.compareTo(range.right) > 0) rangesCompleted++; } return new CompactionInfo(baseCfs.metadata, OperationType.VIEW_BUILD, rangesCompleted, rangesTotal, Unit.RANGES, compactionId); }
public AllSSTableOpStatus performCleanup(final ColumnFamilyStore cfStore, int jobs) throws InterruptedException, ExecutionException { assert !cfStore.isIndex(); Keyspace keyspace = cfStore.keyspace; final Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); if (ranges.isEmpty()) { logger.info("Cleanup cannot run before a node has joined the ring"); return AllSSTableOpStatus.ABORTED; } final boolean hasIndexes = cfStore.indexManager.hasIndexes(); return parallelAllSSTableOperation(cfStore, new OneSSTableOperation() { @Override public Iterable<SSTableReader> filterSSTables(Iterable<SSTableReader> input) { List<SSTableReader> sortedSSTables = Lists.newArrayList(input); Collections.sort(sortedSSTables, new SSTableReader.SizeComparator()); return sortedSSTables; } @Override public void execute(SSTableReader input) throws IOException { CleanupStrategy cleanupStrategy = CleanupStrategy.get(cfStore, ranges); doCleanupOne(cfStore, input, cleanupStrategy, ranges, hasIndexes); } }, jobs); }
@SuppressWarnings("resource") public CleaningTimeWindowCompactionWriter(ColumnFamilyStore cfs, Directories directories, LifecycleTransaction txn, Set<SSTableReader> nonExpiredSSTables, int nowInSec, boolean offline, boolean keepOriginals) { super(cfs, directories, txn, nonExpiredSSTables, offline, keepOriginals); this.allSSTables = txn.originals(); this.txn = txn; this.sstableWriter = SSTableRewriter.constructKeepingOriginals(txn, keepOriginals, maxAge, offline); this.sortedRanges = Range.normalize(StorageService.instance.getLocalRanges(cfs.keyspace.getName())); this.nowInSec = nowInSec; }
public CompactionInfo getCompactionInfo() { long rangesCompleted = 0, rangesTotal = 0; Token lastToken = prevToken; // This approximation is not very accurate, but since we do not have a method which allows us to calculate the // percentage of a range covered by a second range, this is the best approximation that we can calculate. // Instead, we just count the total number of ranges that haven't been seen by the node (we use the order of // the tokens to determine whether they have been seen yet or not), and the total number of ranges that a node // has. for (Range<Token> range : StorageService.instance.getLocalRanges(baseCfs.keyspace.getName())) { rangesTotal++; if ((lastToken != null) && lastToken.compareTo(range.right) > 0) rangesCompleted++; } return new CompactionInfo(baseCfs.metadata, OperationType.VIEW_BUILD, rangesCompleted, rangesTotal, Unit.RANGES, compactionId); }
public int forceRepairAsync(String keyspace, int parallelismDegree, Collection<String> dataCenters, Collection<String> hosts, boolean primaryRange, boolean fullRepair, String... columnFamilies) { if (parallelismDegree < 0 || parallelismDegree > RepairParallelism.values().length - 1) { throw new IllegalArgumentException("Invalid parallelism degree specified: " + parallelismDegree); } Collection<Range<Token>> ranges; if (primaryRange) { // when repairing only primary range, neither dataCenters nor hosts can be set if (dataCenters == null && hosts == null) ranges = getPrimaryRanges(keyspace); // except dataCenters only contain local DC (i.e. -local) else if (dataCenters != null && dataCenters.size() == 1 && dataCenters.contains(DatabaseDescriptor.getLocalDataCenter())) ranges = getPrimaryRangesWithinDC(keyspace); else throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster."); } else { ranges = getLocalRanges(keyspace); } return forceRepairAsync(keyspace, RepairParallelism.values()[parallelismDegree], dataCenters, hosts, ranges, fullRepair, columnFamilies); }
streamer.addRanges(keyspaceName, getLocalRanges(keyspaceName));
Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (SSTableReader sstable : sstables)
public int repairAsync(String keyspace, Map<String, String> repairSpec) { RepairOption option = RepairOption.parse(repairSpec, tokenMetadata.partitioner); // if ranges are not specified if (option.getRanges().isEmpty()) { if (option.isPrimaryRange()) { // when repairing only primary range, neither dataCenters nor hosts can be set if (option.getDataCenters().isEmpty() && option.getHosts().isEmpty()) option.getRanges().addAll(getPrimaryRanges(keyspace)); // except dataCenters only contain local DC (i.e. -local) else if (option.isInLocalDCOnly()) option.getRanges().addAll(getPrimaryRangesWithinDC(keyspace)); else throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster."); } else { option.getRanges().addAll(getLocalRanges(keyspace)); } } return forceRepairAsync(keyspace, option, false); }
public int repairAsync(String keyspace, Map<String, String> repairSpec) { RepairOption option = RepairOption.parse(repairSpec, tokenMetadata.partitioner); // if ranges are not specified if (option.getRanges().isEmpty()) { if (option.isPrimaryRange()) { // when repairing only primary range, neither dataCenters nor hosts can be set if (option.getDataCenters().isEmpty() && option.getHosts().isEmpty()) option.getRanges().addAll(getPrimaryRanges(keyspace)); // except dataCenters only contain local DC (i.e. -local) else if (option.isInLocalDCOnly()) option.getRanges().addAll(getPrimaryRangesWithinDC(keyspace)); else throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster."); } else { option.getRanges().addAll(getLocalRanges(keyspace)); } } return forceRepairAsync(keyspace, option, false); }
public int repairAsync(String keyspace, Map<String, String> repairSpec) { RepairOption option = RepairOption.parse(repairSpec, tokenMetadata.partitioner); // if ranges are not specified if (option.getRanges().isEmpty()) { if (option.isPrimaryRange()) { // when repairing only primary range, neither dataCenters nor hosts can be set if (option.getDataCenters().isEmpty() && option.getHosts().isEmpty()) option.getRanges().addAll(getPrimaryRanges(keyspace)); // except dataCenters only contain local DC (i.e. -local) else if (option.isInLocalDCOnly()) option.getRanges().addAll(getPrimaryRangesWithinDC(keyspace)); else throw new IllegalArgumentException("You need to run primary range repair on all nodes in the cluster."); } else { option.getRanges().addAll(getLocalRanges(keyspace)); } } return forceRepairAsync(keyspace, option, false); }
public void cleanupCache() { Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (Iterator<RowCacheKey> keyIter = CacheService.instance.rowCache.keyIterator(); keyIter.hasNext(); ) { RowCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.key)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) invalidateCachedPartition(dk); } if (metadata.isCounter()) { for (Iterator<CounterCacheKey> keyIter = CacheService.instance.counterCache.keyIterator(); keyIter.hasNext(); ) { CounterCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.partitionKey)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) CacheService.instance.counterCache.remove(key); } } }
public void cleanupCache() { Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (Iterator<RowCacheKey> keyIter = CacheService.instance.rowCache.keyIterator(); keyIter.hasNext(); ) { RowCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.key)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) invalidateCachedPartition(dk); } if (metadata.isCounter()) { for (Iterator<CounterCacheKey> keyIter = CacheService.instance.counterCache.keyIterator(); keyIter.hasNext(); ) { CounterCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.partitionKey)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) CacheService.instance.counterCache.remove(key); } } }
public AllSSTableOpStatus performCleanup(final ColumnFamilyStore cfStore, int jobs) throws InterruptedException, ExecutionException { assert !cfStore.isIndex(); Keyspace keyspace = cfStore.keyspace; if (!StorageService.instance.isJoined()) { logger.info("Cleanup cannot run before a node has joined the ring"); return AllSSTableOpStatus.ABORTED; } // if local ranges is empty, it means no data should remain final Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); final boolean hasIndexes = cfStore.indexManager.hasIndexes(); return parallelAllSSTableOperation(cfStore, new OneSSTableOperation() { @Override public Iterable<SSTableReader> filterSSTables(LifecycleTransaction transaction) { List<SSTableReader> sortedSSTables = Lists.newArrayList(transaction.originals()); Collections.sort(sortedSSTables, SSTableReader.sizeComparator); return sortedSSTables; } @Override public void execute(LifecycleTransaction txn) throws IOException { CleanupStrategy cleanupStrategy = CleanupStrategy.get(cfStore, ranges, FBUtilities.nowInSeconds()); doCleanupOne(cfStore, txn, cleanupStrategy, ranges, hasIndexes); } }, jobs, OperationType.CLEANUP); }
public AllSSTableOpStatus performCleanup(final ColumnFamilyStore cfStore, int jobs) throws InterruptedException, ExecutionException { assert !cfStore.isIndex(); Keyspace keyspace = cfStore.keyspace; if (!StorageService.instance.isJoined()) { logger.info("Cleanup cannot run before a node has joined the ring"); return AllSSTableOpStatus.ABORTED; } // if local ranges is empty, it means no data should remain final Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); final boolean hasIndexes = cfStore.indexManager.hasIndexes(); return parallelAllSSTableOperation(cfStore, new OneSSTableOperation() { @Override public Iterable<SSTableReader> filterSSTables(LifecycleTransaction transaction) { List<SSTableReader> sortedSSTables = Lists.newArrayList(transaction.originals()); Collections.sort(sortedSSTables, SSTableReader.sizeComparator); return sortedSSTables; } @Override public void execute(LifecycleTransaction txn) throws IOException { CleanupStrategy cleanupStrategy = CleanupStrategy.get(cfStore, ranges, FBUtilities.nowInSeconds()); doCleanupOne(cfStore, txn, cleanupStrategy, ranges, hasIndexes); } }, jobs, OperationType.CLEANUP); }
public void cleanupCache() { Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (Iterator<RowCacheKey> keyIter = CacheService.instance.rowCache.keyIterator(); keyIter.hasNext(); ) { RowCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.key)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) invalidateCachedPartition(dk); } if (metadata.isCounter()) { for (Iterator<CounterCacheKey> keyIter = CacheService.instance.counterCache.keyIterator(); keyIter.hasNext(); ) { CounterCacheKey key = keyIter.next(); DecoratedKey dk = decorateKey(ByteBuffer.wrap(key.partitionKey)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) CacheService.instance.counterCache.remove(key); } } }
Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (SSTableReader sstable : sstables)
public void cleanupCache() { Collection<Range<Token>> ranges = StorageService.instance.getLocalRanges(keyspace.getName()); for (RowCacheKey key : CacheService.instance.rowCache.getKeySet()) { DecoratedKey dk = partitioner.decorateKey(ByteBuffer.wrap(key.key)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) invalidateCachedRow(dk); } if (metadata.isCounter()) { for (CounterCacheKey key : CacheService.instance.counterCache.getKeySet()) { DecoratedKey dk = partitioner.decorateKey(ByteBuffer.wrap(key.partitionKey)); if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges)) CacheService.instance.counterCache.remove(key); } } }