Search in sources :

Example 1 with ConcurrencyType

use of com.linkedin.kafka.cruisecontrol.executor.ConcurrencyType in project cruise-control by linkedin.

the class ParameterUtils method concurrencyTypes.

private static Set<ConcurrencyType> concurrencyTypes(HttpServletRequest request, boolean isEnable) throws UnsupportedEncodingException {
    Set<String> concurrencyForStringSet = parseParamToStringSet(request, isEnable ? ENABLE_CONCURRENCY_ADJUSTER_FOR_PARAM : DISABLE_CONCURRENCY_ADJUSTER_FOR_PARAM);
    Set<ConcurrencyType> concurrencyTypes = new HashSet<>();
    try {
        for (String concurrencyForString : concurrencyForStringSet) {
            concurrencyTypes.add(ConcurrencyType.valueOf(concurrencyForString.toUpperCase()));
        }
    } catch (IllegalArgumentException iae) {
        throw new UserRequestException(String.format("Unsupported concurrency types in %s. Supported: %s", concurrencyForStringSet, ConcurrencyType.cachedValues()));
    }
    return Collections.unmodifiableSet(concurrencyTypes);
}
Also used : ConcurrencyType(com.linkedin.kafka.cruisecontrol.executor.ConcurrencyType) UserRequestException(com.linkedin.kafka.cruisecontrol.servlet.UserRequestException) HashSet(java.util.HashSet)

Example 2 with ConcurrencyType

use of com.linkedin.kafka.cruisecontrol.executor.ConcurrencyType in project cruise-control by linkedin.

the class AdminRequest method processUpdateConcurrencyAdjusterRequest.

protected void processUpdateConcurrencyAdjusterRequest(Map<ConcurrencyType, Boolean> concurrencyAdjusterBefore, Map<ConcurrencyType, Boolean> concurrencyAdjusterAfter, StringBuilder minIsrBasedConcurrencyAdjustmentRequest) {
    UpdateConcurrencyAdjusterParameters updateConcurrencyAdjusterParameters = _parameters.updateConcurrencyAdjusterParameters();
    if (updateConcurrencyAdjusterParameters != null) {
        Set<ConcurrencyType> disableConcurrencyAdjusterFor = updateConcurrencyAdjusterParameters.disableConcurrencyAdjusterFor();
        Set<ConcurrencyType> enableConcurrencyAdjusterFor = updateConcurrencyAdjusterParameters.enableConcurrencyAdjusterFor();
        Boolean minIsrBasedConcurrencyAdjustment = updateConcurrencyAdjusterParameters.minIsrBasedConcurrencyAdjustment();
        if (minIsrBasedConcurrencyAdjustment != null) {
            boolean oldValue = _kafkaCruiseControl.setConcurrencyAdjusterMinIsrCheck(minIsrBasedConcurrencyAdjustment);
            minIsrBasedConcurrencyAdjustmentRequest.append(String.format("MinISR-based concurrency adjustment is modified (before: %s after: %s).", oldValue, minIsrBasedConcurrencyAdjustment));
            LOG.info("MinISR-based concurrency adjustment is modified by user (before: {} after: {}).", oldValue, minIsrBasedConcurrencyAdjustment);
        }
        for (ConcurrencyType type : disableConcurrencyAdjusterFor) {
            concurrencyAdjusterBefore.put(type, _kafkaCruiseControl.setConcurrencyAdjusterFor(type, false));
            concurrencyAdjusterAfter.put(type, false);
        }
        for (ConcurrencyType adjusterType : enableConcurrencyAdjusterFor) {
            concurrencyAdjusterBefore.put(adjusterType, _kafkaCruiseControl.setConcurrencyAdjusterFor(adjusterType, true));
            concurrencyAdjusterAfter.put(adjusterType, true);
        }
        if (!disableConcurrencyAdjusterFor.isEmpty() || !enableConcurrencyAdjusterFor.isEmpty()) {
            LOG.info("Concurrency adjuster state is modified by user (before: {} after: {}).", concurrencyAdjusterBefore, concurrencyAdjusterAfter);
        }
    }
}
Also used : UpdateConcurrencyAdjusterParameters(com.linkedin.kafka.cruisecontrol.servlet.parameters.UpdateConcurrencyAdjusterParameters) ConcurrencyType(com.linkedin.kafka.cruisecontrol.executor.ConcurrencyType)

Aggregations

ConcurrencyType (com.linkedin.kafka.cruisecontrol.executor.ConcurrencyType)2 UserRequestException (com.linkedin.kafka.cruisecontrol.servlet.UserRequestException)1 UpdateConcurrencyAdjusterParameters (com.linkedin.kafka.cruisecontrol.servlet.parameters.UpdateConcurrencyAdjusterParameters)1 HashSet (java.util.HashSet)1