INT-3846: SimpleMessageStore Improvements
JIRAs: https://jira.spring.io/browse/INT-3830 https://jira.spring.io/browse/INT-3523 https://jira.spring.io/browse/INT-3846 * Fix the OOM condition, when we `release()` `UpperBound` independently of the previous `remove` result (https://jira.spring.io/browse/INT-3846) * Fix "confuse" around `groupCapacity`, when we really didn't care about individual groups (https://jira.spring.io/browse/INT-3523) * Add `upperBoundTimeout` to have a hook to wait some time for the empty slot in the store (https://jira.spring.io/browse/INT-3830) * Fix some JavaDocs warnings * Fix some typos * Fix inconsistency in the `DelayHandler` around `removeMessageFromGroup` when `MS` is `SimpleMessageStore` * Remove `UpperBound.release()` operation from `SimpleMessageStore.removeGroup()`. The waiting process should worry about the new `UpperBound` instance. Some other polishing `tryAcquire` outside of the `lock` Move `tryAcquire` within the `addMessageToGroup` outside of `lock`. But do that only for groups which already exist. For the new groups we have a fresh `UpperBound`, so no need to worry about dead lock and we can obtain a permit immediately. SimpleMessageGroup: BlockingQueue -> LinkedHashSet `SimpleMessageStore`: use "unsynchonized" `SimpleMessageGroup` Make some synchronization fixes according to the migration to the `LinkedHashSet` Avoid extra `Collection` `ResequencingMessageHandler`: compare `size()` of collections instead of `containsAll()` Fix `ConcurrentModificationException` in the `AbstractKeyValueMessageStore` Add `SimpleMessageStore.clearMessageGroup()` Accept polishing and fix `RedisChannelMessageStoreTests` `@Deprecated` `MessageGroupStore.removeMessageFromGroup()` Fix some typos Introduce `SimpleMessageGroupFactory` Extract `MessageGroupFactory` and address PR comments Polishing after rebase JavaDocs and Reference Manual Fix JavaDocs
This commit is contained in:
committed by
Gary Russell
parent
5d5fa86e6e
commit
201f0fc2b1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2007-2015 the original author or authors
|
||||
* Copyright 2007-2016 the original author or authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.gemfire.store;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -32,7 +33,6 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
@@ -52,13 +52,13 @@ import org.springframework.util.Assert;
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.Scope;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author David Turanski
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
*/
|
||||
public class GemfireGroupStoreTests {
|
||||
@@ -67,7 +67,7 @@ public class GemfireGroupStoreTests {
|
||||
|
||||
private Region<Object, Object> region;
|
||||
|
||||
@Rule
|
||||
// @Rule
|
||||
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
|
||||
|
||||
@Test
|
||||
@@ -119,7 +119,7 @@ public class GemfireGroupStoreTests {
|
||||
messageGroup = store.getMessageGroup(1);
|
||||
assertEquals(3, messageGroup.size());
|
||||
|
||||
messageGroup = store.removeMessageFromGroup(messageGroup.getGroupId(), message);
|
||||
store.removeMessagesFromGroup(messageGroup.getGroupId(), message);
|
||||
messageGroup = store.getMessageGroup(1);
|
||||
assertEquals(2, messageGroup.size());
|
||||
|
||||
@@ -163,14 +163,14 @@ public class GemfireGroupStoreTests {
|
||||
store.afterPropertiesSet();
|
||||
MessageGroup messageGroup = store.getMessageGroup(1);
|
||||
store.addMessageToGroup(messageGroup.getGroupId(), new GenericMessage<String>("1"));
|
||||
store.removeMessageFromGroup(1, new GenericMessage<String>("2"));
|
||||
store.removeMessagesFromGroup(1, new GenericMessage<String>("2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveNonExistingMessageFromNonExistingTheGroup() throws Exception {
|
||||
GemfireMessageStore store = new GemfireMessageStore(this.region);
|
||||
store.afterPropertiesSet();
|
||||
store.removeMessageFromGroup(1, new GenericMessage<String>("2"));
|
||||
store.removeMessagesFromGroup(1, new GenericMessage<String>("2"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -214,7 +214,8 @@ public class GemfireGroupStoreTests {
|
||||
GemfireMessageStore store3 = new GemfireMessageStore(this.region);
|
||||
store3.afterPropertiesSet();
|
||||
|
||||
messageGroup = store3.removeMessageFromGroup(1, message);
|
||||
store3.removeMessagesFromGroup(1, message);
|
||||
messageGroup = store3.getMessageGroup(1);
|
||||
|
||||
assertEquals(1, messageGroup.getMessages().size());
|
||||
}
|
||||
@@ -308,7 +309,8 @@ public class GemfireGroupStoreTests {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MessageGroup group = store2.removeMessageFromGroup(1, message);
|
||||
store2.removeMessagesFromGroup(1, message);
|
||||
MessageGroup group = store2.getMessageGroup(1);
|
||||
if (group.getMessages().size() != 0) {
|
||||
failures.add("REMOVE");
|
||||
throw new AssertionFailedError("Failed on Remove");
|
||||
@@ -318,7 +320,7 @@ public class GemfireGroupStoreTests {
|
||||
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(10, TimeUnit.SECONDS);
|
||||
store2.removeMessageFromGroup(1, message); // ensures that if ADD thread executed after REMOVE, the store is empty for the next cycle
|
||||
store2.removeMessagesFromGroup(1, message); // ensures that if ADD thread executed after REMOVE, the store is empty for the next cycle
|
||||
}
|
||||
assertTrue(failures.size() == 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user