Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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