Skip to content

Commit

Permalink
Add more logging to help debugging the time spent on goal based opera…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
allenxwang committed Oct 1, 2024
1 parent 85d6ca7 commit 73918f2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,26 @@ public synchronized String toString() {
return sb.toString();
}

/**
* @return the up-to-date total execution time on the progress
*/
public synchronized long getCurrentTotalExecutionTime() {
if (_startTimes.isEmpty()) {
return 0;
} else {
long currentTime = System.currentTimeMillis();
long startTime = _startTimes.get(0);
return currentTime - startTime;
}
}

/**
* @return the name of the operation
*/
public String getOperation() {
return _operation;
}

/**
* @return The map describing the progress of the operation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,9 @@ public synchronized void executeProposals(Collection<ExecutionProposal> proposal
isTriggeredByUserRequest, loadMonitor);
startExecution(loadMonitor, null, removedBrokers, replicationThrottle, isTriggeredByUserRequest);
} catch (Exception e) {
if (e instanceof OngoingExecutionException) {
LOG.info("Broker removal operation with uuid {} aborted due to ongoing execution", uuid);
}
processExecuteProposalsFailure();
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.concurrent.TimeoutException;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.linkedin.kafka.cruisecontrol.KafkaCruiseControlUtils.goalsByPriority;
import static com.linkedin.kafka.cruisecontrol.KafkaCruiseControlUtils.sanityCheckGoals;
Expand All @@ -34,6 +36,7 @@
* An abstract class to extract the common logic of goal based operation runnables.
*/
public abstract class GoalBasedOperationRunnable extends OperationRunnable {
private static final Logger LOG = LoggerFactory.getLogger(GoalBasedOperationRunnable.class);
protected final List<String> _goals;
protected final ModelCompletenessRequirements _modelCompletenessRequirements;
protected final boolean _dryRun;
Expand Down Expand Up @@ -207,6 +210,11 @@ protected abstract OptimizerResult workWithClusterModel()
* Perform the memory clean up after {@link #computeResult()}.
*/
protected void finish() {
if (_operationProgress != null) {
long totalTime = _operationProgress.getCurrentTotalExecutionTime();
LOG.info("Operation {} finished with uuid {}; total time: {}ms; steps: {}",
_operationProgress.getOperation(), _uuid, totalTime, _operationProgress);
}
_operationProgress = null;
_combinedCompletenessRequirements = null;
if (_goalsByPriority != null) {
Expand Down

0 comments on commit 73918f2

Please sign in to comment.