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

Join Map Lane reporting the same value for both previous and current on didUpdate #66

Open
DobromirM opened this issue Oct 1, 2021 · 1 comment
Labels
C-bug Category: bug

Comments

@DobromirM
Copy link
Member

If a didUpdate callback is added to a JoinMapLane it reports the previous and the current value as the same.

Example:

BasicPlane.java

public class BasicPlane extends AbstractPlane {

  @SwimRoute("/unit/:id")
  AgentRoute<UnitAgent> unitAgentType;

  public static void main(String[] args) {
    final Kernel kernel = ServerLoader.loadServer();
    final ActorSpace space = (ActorSpace) kernel.getSpace("basic");

    kernel.start();
    System.out.println("Running Basic server...");
    kernel.run();

    space.command("/unit/foo", "wakeup", Value.absent());
  }
}

UnitAgent.java

public class UnitAgent extends AbstractAgent {

  @SwimLane("shoppingCart")
  MapLane<String, Integer> shoppingCart = this.<String, Integer>mapLane();

  @SwimLane("addItem")
  CommandLane<String> publish = this.<String>commandLane()
      .onCommand(msg -> {
        final int n = this.shoppingCart.getOrDefault(msg, 0) + 1;
        this.shoppingCart.put(msg, n);
      });

    @SwimLane("join")
    JoinMapLane<String, String, Integer> stateStreetStats = this.<String, String, Integer>joinMapLane().didUpdate((key, newValue, oldValue) -> {
        System.out.println("join map lane: " + key + " count changed to " + newValue + " from " + oldValue);
    });

    @Override
    public void didStart() {
        stateStreetStats.downlink("foo").hostUri("warp://127.0.0.1:9001").nodeUri("/unit/foo").laneUri("shoppingCart").open();
    }

}

Input:

@command(node:"/unit/foo", lane:"addItem")"foo"
@command(node:"/unit/foo", lane:"addItem")"foo"
@command(node:"/unit/foo", lane:"addItem")"foo"

Output:

join map lane: foo count changed to 1 from 1
join map lane: foo count changed to 2 from 2
join map lane: foo count changed to 3 from 3

(The previous value should be one lower than the current)

@DobromirM DobromirM added the C-bug Category: bug label Oct 1, 2021
@DobromirM
Copy link
Member Author

Map lanes and join value lanes are not affected by this.

ajay-gov added a commit that referenced this issue Oct 11, 2021
ajay-gov added a commit that referenced this issue Oct 12, 2021
ajay-gov added a commit that referenced this issue Oct 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

1 participant