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 (#2202)

* Add more logging to help debugging the time spent on goal based operation

* Update cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/async/progress/OperationProgress.java

Co-authored-by: Maryan Hratson <[email protected]>

* Update cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/servlet/handler/async/runnable/GoalBasedOperationRunnable.java

Co-authored-by: Maryan Hratson <[email protected]>

* Update cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/servlet/handler/async/runnable/GoalBasedOperationRunnable.java

Co-authored-by: Maryan Hratson <[email protected]>

---------

Co-authored-by: Maryan Hratson <[email protected]>
  • Loading branch information
allenxwang and mhratson authored Oct 2, 2024
1 parent 85d6ca7 commit f925566
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 getCurrentTotalExecutionTimeMs() {
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 totalTimeMs = _operationProgress.getCurrentTotalExecutionTimeMs();
LOG.info("Operation {} finished with uuid {}; total time: {}ms; steps: {}",
_operationProgress.getOperation(), _uuid, totalTimeMs, _operationProgress);
}
_operationProgress = null;
_combinedCompletenessRequirements = null;
if (_goalsByPriority != null) {
Expand Down

0 comments on commit f925566

Please sign in to comment.