package org.onap.policy.controlloop.actorserviceprovider.impl;
import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
-import org.onap.policy.common.parameters.BeanValidationResult;
import org.onap.policy.controlloop.actorserviceprovider.Operator;
import org.onap.policy.controlloop.actorserviceprovider.Util;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ActorParams;
import org.onap.policy.controlloop.actorserviceprovider.parameters.ParameterValidationRuntimeException;
import org.onap.policy.controlloop.actorserviceprovider.spi.Actor;
import org.slf4j.Logger;
super(name);
}
+ /**
+ * This method simply returns {@code 0}.
+ */
+ @Override
+ public int getSequenceNumber() {
+ return 0;
+ }
+
/**
* Adds an operator supported by this actor.
*
final String actorName = getName();
logger.info("configuring operations for actor {}", actorName);
- BeanValidationResult valres = new BeanValidationResult(actorName, parameters);
-
// function that creates operator-specific parameters, given the operation name
Function<String, Map<String, Object>> opParamsMaker = makeOperatorParameters(parameters);
operator.configure(subparams);
} catch (ParameterValidationRuntimeException e) {
- logger.warn("failed to configure operation {}.{}", actorName, operName, e);
- valres.addResult(e.getResult());
+ logger.warn("failed to configure operation {}.{} because:\n{}", actorName, operName,
+ e.getResult().getResult(), e);
} catch (RuntimeException e) {
logger.warn("failed to configure operation {}.{}", actorName, operName, e);
/**
* Extracts the operator parameters from the actor parameters, for a given operator.
- * This method assumes each operation has its own set of parameters.
+ * This method translates the parameters to an {@link ActorParams} and then creates a function
+ * that will extract operator-specific parameters.
*
* @param actorParameters actor parameters
* @return a function to extract the operator parameters from the actor parameters.
* the given operation name
*/
protected Function<String, Map<String, Object>> makeOperatorParameters(Map<String, Object> actorParameters) {
+ String actorName = getName();
- return operName -> Util.translateToMap(getName() + "." + operName, actorParameters.get(operName));
+ // @formatter:off
+ return Util.translate(actorName, actorParameters, ActorParams.class)
+ .doValidation(actorName)
+ .makeOperationParameters(actorName);
+ // @formatter:on
}
/**
"failed to shutdown operation {}.{}", actorName, oper.getName()));
// @formatter:on
}
-
- // TODO old code: remove lines down to **HERE**
-
- @Override
- public String actor() {
- return null;
- }
-
- @Override
- public List<String> recipes() {
- return Collections.emptyList();
- }
-
- @Override
- public List<String> recipeTargets(String recipe) {
- return Collections.emptyList();
- }
-
- @Override
- public List<String> recipePayloads(String recipe) {
- return Collections.emptyList();
- }
-
- // **HERE**
}