public void onRestart(InetAddress endpoint, EndpointState epState) { convict(endpoint, Double.MAX_VALUE); }
public void onFailure(Throwable t) { logger.error(String.format("[repair #%s] Session completed with the following error", getId()), t); Tracing.traceRepair("Session completed with the following error: {}", t); forceShutdown(t); } });
public void handleMessage(InetAddress endpoint, RepairMessage message) { RepairJobDesc desc = message.desc; RepairSession session = sessions.get(desc.sessionId); if (session == null) return; switch (message.messageType) { case VALIDATION_COMPLETE: ValidationComplete validation = (ValidationComplete) message; session.validationComplete(desc, endpoint, validation.trees); break; case SYNC_COMPLETE: // one of replica is synced. SyncComplete sync = (SyncComplete) message; session.syncComplete(desc, sync.nodes, sync.success); break; default: break; } }
/** * clear all RepairJobs and terminate this session. * * @param reason Cause of error for shutdown */ public void forceShutdown(Throwable reason) { setException(reason); taskExecutor.shutdownNow(); terminate(); }
/** * Create repair job to run on specific columnfamily * * @param session RepairSession that this RepairJob belongs * @param columnFamily name of the ColumnFamily to repair */ public RepairJob(RepairSession session, String columnFamily) { this.session = session; this.desc = new RepairJobDesc(session.parentRepairSession, session.getId(), session.keyspace, columnFamily, session.getRanges()); this.repairedAt = session.repairedAt; this.taskExecutor = session.taskExecutor; this.parallelismDegree = session.parallelismDegree; }
return null; final RepairSession session = new RepairSession(parentRepairSession, UUIDGen.getTimeUUID(), range, keyspace, parallelismDegree, endpoints, repairedAt, pullRepair, cfnames); sessions.put(session.getId(), session); session.addListener(new Runnable() session.start(executor); return session;
return; logger.info("[repair #{}] new session: will sync {} on range {} for {}.{}", getId(), repairedNodes(), ranges, keyspace, Arrays.toString(cfnames)); Tracing.traceRepair("Syncing range {}", ranges); SystemDistributedKeyspace.startRepairs(getId(), parentRepairSession, keyspace, cfnames, ranges, endpoints); logger.info("[repair #{}] {}", getId(), message = String.format("No neighbors to repair with on range %s: session completed", ranges)); Tracing.traceRepair(message); set(new RepairSessionResult(id, keyspace, ranges, Lists.<RepairResult>newArrayList())); SystemDistributedKeyspace.failRepairs(getId(), keyspace, cfnames, new RuntimeException(message)); return; logger.error("[repair #{}] {}", getId(), message); Exception e = new IOException(message); setException(e); SystemDistributedKeyspace.failRepairs(getId(), keyspace, cfnames, e); return;
/** * When repair finished, do clean up */ public void run() { sessions.remove(session.getId()); } }, MoreExecutors.directExecutor());
public void runMayThrow() throws Exception logger.info(String.format("[repair #%s] new session: will sync %s on range %s for %s.%s", getId(), repairedNodes(), range, keyspace, Arrays.toString(cfnames))); logger.info(String.format("[repair #%s] No neighbors to repair with on range %s: session completed", getId(), range)); return; logger.error("[repair #{}] {}", getId(), message); throw new IOException(message); logger.info(String.format("[repair #%s] session completed successfully", getId())); logger.error(String.format("[repair #%s] session completed with the following error", getId()), exception); throw exception; terminate();
public void onSuccess(List<RepairResult> results) { // this repair session is completed logger.info("[repair #{}] {}", getId(), "Session completed successfully"); Tracing.traceRepair("Completed sync of range {}", ranges); set(new RepairSessionResult(id, keyspace, ranges, results)); taskExecutor.shutdown(); // mark this session as terminated terminate(); }
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 void failedSnapshot() { exception = new IOException("Failed during snapshot creation."); forceShutdown(); }
message = String.format("Repair session %s for range %s finished", future.session.getId(), future.session.getRange().toString()); logger.info(message); sendNotification("repair", message, new int[]{cmd, ActiveRepairService.Status.SESSION_SUCCESS.ordinal()}); message = String.format("Repair session %s for range %s failed with error %s", future.session.getId(), future.session.getRange().toString(), e.getCause().getMessage()); logger.error(message, e); sendNotification("repair", message, new int[]{cmd, ActiveRepairService.Status.SESSION_FAILED.ordinal()}); message = String.format("Repair session %s for range %s failed with error %s", future.session.getId(), future.session.getRange().toString(), e.getMessage()); logger.error(message, e); sendNotification("repair", message, new int[]{cmd, ActiveRepairService.Status.SESSION_FAILED.ordinal()});
/** * Requests repairs for the given keyspace and column families. * * @return Future for asynchronous call or null if there is no need to repair */ public RepairFuture submitRepairSession(UUID parentRepairSession, Range<Token> range, String keyspace, RepairParallelism parallelismDegree, Set<InetAddress> endpoints, String... cfnames) { if (cfnames.length == 0) return null; RepairSession session = new RepairSession(parentRepairSession, range, keyspace, parallelismDegree, endpoints, cfnames); if (session.endpoints.isEmpty()) return null; RepairFuture futureTask = new RepairFuture(session); executor.execute(futureTask); return futureTask; }
return null; final RepairSession session = new RepairSession(parentRepairSession, UUIDGen.getTimeUUID(), range, keyspace, parallelismDegree, endpoints, repairedAt, pullRepair, cfnames); sessions.put(session.getId(), session); session.addListener(new Runnable() session.start(executor); return session;
return; logger.info("[repair #{}] new session: will sync {} on range {} for {}.{}", getId(), repairedNodes(), ranges, keyspace, Arrays.toString(cfnames)); Tracing.traceRepair("Syncing range {}", ranges); SystemDistributedKeyspace.startRepairs(getId(), parentRepairSession, keyspace, cfnames, ranges, endpoints); logger.info("[repair #{}] {}", getId(), message = String.format("No neighbors to repair with on range %s: session completed", ranges)); Tracing.traceRepair(message); set(new RepairSessionResult(id, keyspace, ranges, Lists.<RepairResult>newArrayList())); SystemDistributedKeyspace.failRepairs(getId(), keyspace, cfnames, new RuntimeException(message)); return; logger.error("[repair #{}] {}", getId(), message); Exception e = new IOException(message); setException(e); SystemDistributedKeyspace.failRepairs(getId(), keyspace, cfnames, e); return;
/** * Create repair job to run on specific columnfamily * * @param session RepairSession that this RepairJob belongs * @param columnFamily name of the ColumnFamily to repair */ public RepairJob(RepairSession session, String columnFamily) { this.session = session; this.desc = new RepairJobDesc(session.parentRepairSession, session.getId(), session.keyspace, columnFamily, session.getRanges()); this.repairedAt = session.repairedAt; this.taskExecutor = session.taskExecutor; this.parallelismDegree = session.parallelismDegree; }
/** * When repair finished, do clean up */ public void run() { sessions.remove(session.getId()); } }, MoreExecutors.directExecutor());
public void onSuccess(List<RepairResult> results) { // this repair session is completed logger.info("[repair #{}] {}", getId(), "Session completed successfully"); Tracing.traceRepair("Completed sync of range {}", ranges); set(new RepairSessionResult(id, keyspace, ranges, results)); taskExecutor.shutdown(); // mark this session as terminated terminate(); }
/** * clear all RepairJobs and terminate this session. * * @param reason Cause of error for shutdown */ public void forceShutdown(Throwable reason) { setException(reason); taskExecutor.shutdownNow(); terminate(); }