Skip to content

Commit

Permalink
Always invoke on passive then track result
Browse files Browse the repository at this point in the history
  • Loading branch information
myronkscott committed Sep 13, 2021
1 parent a280de9 commit a0c65c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public int getConcurrencyKey() {
}
};
}
messageHandler.invoke(realContext, message, this::invokePassiveInternal);
EhcacheEntityResponse resp = invokePassiveInternal(realContext, message);
messageHandler.invoke(realContext, message, (c, m) -> resp);
}

@SuppressWarnings("try")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,36 +142,6 @@ public void testInvalidMessageThrowsError() throws Exception {
}
}

@Test
public void testPassiveTracksMessageDuplication() throws Exception {
ClusterTierPassiveEntity passiveEntity = new ClusterTierPassiveEntity(defaultRegistry, defaultConfiguration, DEFAULT_MAPPER);
passiveEntity.createNew();

Chain chain = sequencedChainOf(createPayload(1L));
TestClientDescriptor client = TestClientDescriptor.newClient();

long clientId = 3;

PassiveReplicationMessage message1 = new PassiveReplicationMessage.ChainReplicationMessage(2, chain, 2L, 1L, clientId);
passiveEntity.invokePassive(client.invokeContext(), message1);

// Should be added
assertThat(passiveEntity.getStateService().getStore(passiveEntity.getStoreIdentifier()).get(2).isEmpty(), is(false));

Chain emptyChain = sequencedChainOf();
PassiveReplicationMessage message2 = new PassiveReplicationMessage.ChainReplicationMessage(2, emptyChain, 2L, 1L, clientId);
passiveEntity.invokePassive(client.invokeContext(), message2);

// Should not be cleared, message is a duplicate
assertThat(passiveEntity.getStateService().getStore(passiveEntity.getStoreIdentifier()).get(2).isEmpty(), is(false));

PassiveReplicationMessage message3 = new PassiveReplicationMessage.ChainReplicationMessage(2, chain, 3L, 1L, clientId);
passiveEntity.invokePassive(client.invokeContext(), message3);

// Should be added as well, different message id
assertThat(passiveEntity.getStateService().getStore(passiveEntity.getStoreIdentifier()).get(2).isEmpty(), is(false));
}

@Test
public void testOversizeReplaceAtHeadMessage() throws Exception {
ClusterTierPassiveEntity passiveEntity = new ClusterTierPassiveEntity(defaultRegistry, defaultConfiguration, DEFAULT_MAPPER);
Expand Down

0 comments on commit a0c65c8

Please sign in to comment.