/** * called when the repair session is done - either failed or anticompaction has completed * * clears out any snapshots created by this repair * * @param parentSessionId * @return */ public synchronized ParentRepairSession removeParentRepairSession(UUID parentSessionId) { String snapshotName = parentSessionId.toString(); for (ColumnFamilyStore cfs : getParentRepairSession(parentSessionId).columnFamilyStores.values()) { if (cfs.snapshotExists(snapshotName)) cfs.clearSnapshot(snapshotName); } return parentRepairSessions.remove(parentSessionId); }
/** * called when the repair session is done - either failed or anticompaction has completed * * clears out any snapshots created by this repair * * @param parentSessionId * @return */ public synchronized ParentRepairSession removeParentRepairSession(UUID parentSessionId) { String snapshotName = parentSessionId.toString(); for (ColumnFamilyStore cfs : getParentRepairSession(parentSessionId).columnFamilyStores.values()) { if (cfs.snapshotExists(snapshotName)) cfs.clearSnapshot(snapshotName); } return parentRepairSessions.remove(parentSessionId); }
/** * called when the repair session is done - either failed or anticompaction has completed * * clears out any snapshots created by this repair * * @param parentSessionId * @return */ public synchronized ParentRepairSession removeParentRepairSession(UUID parentSessionId) { String snapshotName = parentSessionId.toString(); for (ColumnFamilyStore cfs : getParentRepairSession(parentSessionId).columnFamilyStores.values()) { if (cfs.snapshotExists(snapshotName)) cfs.clearSnapshot(snapshotName); } return parentRepairSessions.remove(parentSessionId); }
private void initiateStreaming() { long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE; InetAddress dest = request.dst; InetAddress preferred = SystemKeyspace.getPreferredIP(dest); if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null) repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).repairedAt; logger.info(String.format("[streaming task #%s] Performing streaming repair of %d ranges with %s", desc.sessionId, request.ranges.size(), request.dst)); StreamResultFuture op = new StreamPlan("Repair", repairedAt, 1) .flushBeforeTransfer(true) // request ranges from the remote node .requestRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily) // send ranges to the remote node .transferRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily) .execute(); op.addEventListener(this); }
ParentRepairSession prs = getParentRepairSession(parentRepairSession);
ParentRepairSession prs = getParentRepairSession(parentRepairSession);
/** * Submit anti-compaction jobs to CompactionManager. * When all jobs are done, parent repair session is removed whether those are suceeded or not. * * @param parentRepairSession parent repair session ID * @return Future result of all anti-compaction jobs. */ public ListenableFuture<List<Object>> doAntiCompaction(final UUID parentRepairSession) { assert parentRepairSession != null; ParentRepairSession prs = getParentRepairSession(parentRepairSession); List<ListenableFuture<?>> futures = new ArrayList<>(); for (Map.Entry<UUID, ColumnFamilyStore> columnFamilyStoreEntry : prs.columnFamilyStores.entrySet()) { Refs<SSTableReader> sstables = prs.getActiveRepairedSSTableRefsForAntiCompaction(columnFamilyStoreEntry.getKey()); ColumnFamilyStore cfs = columnFamilyStoreEntry.getValue(); futures.add(CompactionManager.instance.submitAntiCompaction(cfs, prs.ranges, sstables, prs.repairedAt)); } ListenableFuture<List<Object>> allAntiCompactionResults = Futures.successfulAsList(futures); allAntiCompactionResults.addListener(new Runnable() { @Override public void run() { removeParentRepairSession(parentRepairSession); } }, MoreExecutors.sameThreadExecutor()); return allAntiCompactionResults; }
ParentRepairSession prs = getParentRepairSession(parentRepairSession);
public void run() { InetAddress dest = request.dst; InetAddress preferred = SystemKeyspace.getPreferredIP(dest); logger.info("[streaming task #{}] Performing streaming repair of {} ranges with {}", desc.sessionId, request.ranges.size(), request.dst); boolean isIncremental = false; if (desc.parentSessionId != null) { ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); isIncremental = prs.isIncremental; } new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false).listeners(this) .flushBeforeTransfer(true) // request ranges from the remote node .requestRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily) // send ranges to the remote node .transferRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily) .execute(); }
public void run() { InetAddress dest = request.dst; InetAddress preferred = SystemKeyspace.getPreferredIP(dest); logger.info("[streaming task #{}] Performing streaming repair of {} ranges with {}", desc.sessionId, request.ranges.size(), request.dst); boolean isIncremental = false; if (desc.parentSessionId != null) { ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); isIncremental = prs.isIncremental; } new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false).listeners(this) .flushBeforeTransfer(true) // request ranges from the remote node .requestRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily) // send ranges to the remote node .transferRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily) .execute(); }
public void run() { InetAddress dest = request.dst; InetAddress preferred = SystemKeyspace.getPreferredIP(dest); logger.info("[streaming task #{}] Performing streaming repair of {} ranges with {}", desc.sessionId, request.ranges.size(), request.dst); boolean isIncremental = false; if (desc.parentSessionId != null) { ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); isIncremental = prs.isIncremental; } new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false).listeners(this) .flushBeforeTransfer(true) // request ranges from the remote node .requestRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily) // send ranges to the remote node .transferRanges(dest, preferred, desc.keyspace, request.ranges, desc.columnFamily) .execute(); }
/** * Starts sending/receiving our list of differences to/from the remote endpoint: creates a callback * that will be called out of band once the streams complete. */ protected void startSync(List<Range<Token>> differences) { InetAddress local = FBUtilities.getBroadcastAddress(); // We can take anyone of the node as source or destination, however if one is localhost, we put at source to avoid a forwarding InetAddress dst = r2.endpoint.equals(local) ? r1.endpoint : r2.endpoint; InetAddress preferred = SystemKeyspace.getPreferredIP(dst); String message = String.format("Performing streaming repair of %d ranges with %s", differences.size(), dst); logger.info("[repair #{}] {}", desc.sessionId, message); boolean isIncremental = false; if (desc.parentSessionId != null) { ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); isIncremental = prs.isIncremental; } Tracing.traceRepair(message); StreamPlan plan = new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false).listeners(this) .flushBeforeTransfer(true) // request ranges from the remote node .requestRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily); if (!pullRepair) { // send ranges to the remote node if we are not performing a pull repair plan.transferRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily); } plan.execute(); }
/** * Starts sending/receiving our list of differences to/from the remote endpoint: creates a callback * that will be called out of band once the streams complete. */ protected void startSync(List<Range<Token>> differences) { InetAddress local = FBUtilities.getBroadcastAddress(); // We can take anyone of the node as source or destination, however if one is localhost, we put at source to avoid a forwarding InetAddress dst = r2.endpoint.equals(local) ? r1.endpoint : r2.endpoint; InetAddress preferred = SystemKeyspace.getPreferredIP(dst); String message = String.format("Performing streaming repair of %d ranges with %s", differences.size(), dst); logger.info("[repair #{}] {}", desc.sessionId, message); boolean isIncremental = false; if (desc.parentSessionId != null) { ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); isIncremental = prs.isIncremental; } Tracing.traceRepair(message); StreamPlan plan = new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false).listeners(this) .flushBeforeTransfer(true) // request ranges from the remote node .requestRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily); if (!pullRepair) { // send ranges to the remote node if we are not performing a pull repair plan.transferRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily); } plan.execute(); }
private synchronized Refs<SSTableReader> getSSTablesToValidate(ColumnFamilyStore cfs, Validator validator) { Refs<SSTableReader> sstables; ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId); if (prs == null) return null; Set<SSTableReader> sstablesToValidate = new HashSet<>(); if (prs.isGlobal) prs.markSSTablesRepairing(cfs.metadata.cfId, validator.desc.parentSessionId); // note that we always grab all existing sstables for this - if we were to just grab the ones that // were marked as repairing, we would miss any ranges that were compacted away and this would cause us to overstream try (ColumnFamilyStore.RefViewFragment sstableCandidates = cfs.selectAndReference(View.select(SSTableSet.CANONICAL, (s) -> !prs.isIncremental || !s.isRepaired()))) { for (SSTableReader sstable : sstableCandidates.sstables) { if (new Bounds<>(sstable.first.getToken(), sstable.last.getToken()).intersects(validator.desc.ranges)) { sstablesToValidate.add(sstable); } } sstables = Refs.tryRef(sstablesToValidate); if (sstables == null) { logger.error("Could not reference sstables"); throw new RuntimeException("Could not reference sstables"); } } return sstables; }
private synchronized Refs<SSTableReader> getSSTablesToValidate(ColumnFamilyStore cfs, Validator validator) { Refs<SSTableReader> sstables; ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId); if (prs == null) return null; Set<SSTableReader> sstablesToValidate = new HashSet<>(); if (prs.isGlobal) prs.markSSTablesRepairing(cfs.metadata.cfId, validator.desc.parentSessionId); // note that we always grab all existing sstables for this - if we were to just grab the ones that // were marked as repairing, we would miss any ranges that were compacted away and this would cause us to overstream try (ColumnFamilyStore.RefViewFragment sstableCandidates = cfs.selectAndReference(View.select(SSTableSet.CANONICAL, (s) -> !prs.isIncremental || !s.isRepaired()))) { for (SSTableReader sstable : sstableCandidates.sstables) { if (new Bounds<>(sstable.first.getToken(), sstable.last.getToken()).intersects(validator.desc.ranges)) { sstablesToValidate.add(sstable); } } sstables = Refs.tryRef(sstablesToValidate); if (sstables == null) { logger.error("Could not reference sstables"); throw new RuntimeException("Could not reference sstables"); } } return sstables; }
/** * Starts sending/receiving our list of differences to/from the remote endpoint: creates a callback * that will be called out of band once the streams complete. */ protected void startSync(List<Range<Token>> differences) { InetAddress local = FBUtilities.getBroadcastAddress(); // We can take anyone of the node as source or destination, however if one is localhost, we put at source to avoid a forwarding InetAddress dst = r2.endpoint.equals(local) ? r1.endpoint : r2.endpoint; InetAddress preferred = SystemKeyspace.getPreferredIP(dst); String message = String.format("Performing streaming repair of %d ranges with %s", differences.size(), dst); logger.info("[repair #{}] {}", desc.sessionId, message); boolean isIncremental = false; if (desc.parentSessionId != null) { ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); isIncremental = prs.isIncremental; } Tracing.traceRepair(message); StreamPlan plan = new StreamPlan("Repair", repairedAt, 1, false, isIncremental, false).listeners(this) .flushBeforeTransfer(true) // request ranges from the remote node .requestRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily); if (!pullRepair) { // send ranges to the remote node if we are not performing a pull repair plan.transferRanges(dst, preferred, desc.keyspace, differences, desc.columnFamily); } plan.execute(); }
private synchronized Refs<SSTableReader> getSSTablesToValidate(ColumnFamilyStore cfs, Validator validator) { Refs<SSTableReader> sstables; ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId); if (prs == null) return null; Set<SSTableReader> sstablesToValidate = new HashSet<>(); if (prs.isGlobal) prs.markSSTablesRepairing(cfs.metadata.cfId, validator.desc.parentSessionId); // note that we always grab all existing sstables for this - if we were to just grab the ones that // were marked as repairing, we would miss any ranges that were compacted away and this would cause us to overstream try (ColumnFamilyStore.RefViewFragment sstableCandidates = cfs.selectAndReference(View.select(SSTableSet.CANONICAL, (s) -> !prs.isIncremental || !s.isRepaired()))) { for (SSTableReader sstable : sstableCandidates.sstables) { if (new Bounds<>(sstable.first.getToken(), sstable.last.getToken()).intersects(validator.desc.ranges)) { sstablesToValidate.add(sstable); } } sstables = Refs.tryRef(sstablesToValidate); if (sstables == null) { logger.error("Could not reference sstables"); throw new RuntimeException("Could not reference sstables"); } } return sstables; }
ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); if (prs.isGlobal) logger.debug("Syncing {}", request); long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE; if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null) repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).getRepairedAt();
ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId); if (prs.isGlobal) logger.debug("Syncing {}", request); long repairedAt = ActiveRepairService.UNREPAIRED_SSTABLE; if (desc.parentSessionId != null && ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId) != null) repairedAt = ActiveRepairService.instance.getParentRepairSession(desc.parentSessionId).getRepairedAt();
if (validator.desc.parentSessionId == null || ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId) == null) sstables = cfs.selectAndReference(ColumnFamilyStore.CANONICAL_SSTABLES).refs; else ActiveRepairService.ParentRepairSession prs = ActiveRepairService.instance.getParentRepairSession(validator.desc.parentSessionId); prs.markSSTablesRepairing(cfs.metadata.cfId, validator.desc.parentSessionId); sstables = cfs.selectAndReference(ColumnFamilyStore.UNREPAIRED_SSTABLES).refs;