Skip to content

Commit

Permalink
Add more logging for composite effectors
Browse files Browse the repository at this point in the history
  • Loading branch information
grkvlt committed Mar 27, 2017
1 parent e09d0a6 commit b60b332
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ protected String getInputParameter(Object effectorDetails) {
}

protected Object invokeEffectorNamed(Entity target, String effectorName, ConfigBag params) {
LOG.info("{} invoking effector on {}, effector={}, parameters={}",
new Object[]{this, target, effectorName, params});
LOG.info("{} invoking {} with params {}", new Object[] { this, effectorName, params });
Maybe<Effector<?>> effector = target.getEntityType().getEffectorByName(effectorName);
if (effector.isAbsent()) {
throw new IllegalStateException("Cannot find effector " + effectorName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public Body(Effector<?> eff, ConfigBag config) {

@Override
public Object call(final ConfigBag params) {
LOG.info("{} called with config {}", new Object[] { this, config });
List<Object> effectors = EntityInitializers.resolve(config, COMPOSE);

Object result = null;
Expand All @@ -82,6 +83,7 @@ public Object call(final ConfigBag params) {
String inputArgument = getInputArgument(effectorDetails);
String inputParameter = getInputParameter(effectorDetails);
Entity targetEntity = getTargetEntity(effectorDetails);
LOG.info("{} executing {}({}:{}) on {}", new Object[] { this, effectorName, inputArgument, inputParameter, targetEntity });

if (inputArgument == null) {
throw new IllegalArgumentException("Input is not set for this effector: " + effectorDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public Body(Effector<?> eff, ConfigBag config) {

@Override
public List call(final ConfigBag params) {
LOG.info("{} called with config {}", new Object[] { this, config });
Object effectorDetails = EntityInitializers.resolve(config, LOOP);
String input = config.get(INPUT);
Object inputObject = config.getStringKey(input);
Expand All @@ -89,6 +90,7 @@ public List call(final ConfigBag params) {
String effectorName = getEffectorName(effectorDetails);
String inputArgument = getInputArgument(effectorDetails);
Entity targetEntity = getTargetEntity(effectorDetails);
LOG.info("{} executing {}({}) on {}", new Object[] { this, effectorName, inputArgument, targetEntity });

if (inputArgument == null) {
throw new IllegalArgumentException("Input is not set for this effector: " + effectorDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ public Body(Effector<?> eff, ConfigBag config) {

@Override
public Object call(final ConfigBag params) {
LOG.info("{} called with config {}", new Object[] { this, config });
ReplaceAction action = config.get(ACTION);
Object effectorDetails = EntityInitializers.resolve(config, REPLACE);

String effectorName = getEffectorName(effectorDetails);
String inputArgument = getInputArgument(effectorDetails);
Entity targetEntity = getTargetEntity(effectorDetails);
LOG.info("{} executing {}({}) on {}", new Object[] { this, effectorName, inputArgument, targetEntity });

if (inputArgument != null) {
Object input = config.getStringKey(inputArgument);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public Body(Effector<?> eff, ConfigBag config) {

@Override
public Object call(final ConfigBag params) {
LOG.info("{} called with config {}", new Object[] { this, config });
List<Object> effectors = EntityInitializers.resolve(config, SEQUENCE);

Object result = null;
Expand All @@ -82,6 +83,7 @@ public Object call(final ConfigBag params) {
String effectorName = getEffectorName(effectorDetails);
String inputArgument = getInputArgument(effectorDetails);
Entity targetEntity = getTargetEntity(effectorDetails);
LOG.info("{} executing {}({}) on {}", new Object[] { this, effectorName, inputArgument, targetEntity });

if (inputArgument == null) {
throw new IllegalArgumentException("Input is not set for this effector: " + effectorDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public Body(Effector<?> eff, ConfigBag config) {

@Override
public Object call(final ConfigBag params) {
LOG.info("{} called with config {}", new Object[] { this, config });
Function<Object,Object> function = EntityInitializers.resolve(config, FUNCTION);

String input = config.get(INPUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.api.client.repackaged.com.google.common.base.Preconditions;
import com.google.common.annotations.Beta;
import com.google.common.base.Predicates;

Expand Down Expand Up @@ -75,7 +76,7 @@ public PeriodicEffectorPolicy() {

public PeriodicEffectorPolicy(Map<String,?> props) {
super(props);
Duration period = config().get(PERIOD);
Duration period = Preconditions.checkNotNull(config().get(PERIOD), "The period must be copnfigured for this policy");
delay = period.toMilliseconds();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.api.client.repackaged.com.google.common.base.Preconditions;
import com.google.common.annotations.Beta;
import com.google.common.base.Predicates;

Expand Down Expand Up @@ -70,7 +71,7 @@ public ScheduledEffectorPolicy() {

public ScheduledEffectorPolicy(Map<String,?> props) {
super(props);
String time = config().get(TIME);
String time = Preconditions.checkNotNull(config().get(TIME), "The time must be configured for this policy");
DateFormat format = DateFormat.getDateTimeInstance();
try {
when = format.parse(time);
Expand Down

0 comments on commit b60b332

Please sign in to comment.