Added support for gateway conflict resolver and function service
This commit is contained in:
@@ -33,6 +33,11 @@ import org.springframework.data.gemfire.TestUtils;
|
||||
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.Cache;
|
||||
import com.gemstone.gemfire.cache.util.GatewayConflictHelper;
|
||||
import com.gemstone.gemfire.cache.util.GatewayConflictResolver;
|
||||
import com.gemstone.gemfire.cache.util.TimestampedEntryEvent;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@@ -48,9 +53,8 @@ public class CacheNamespaceTest extends RecreatingContextTest {
|
||||
testBasicCache();
|
||||
testNamedCache();
|
||||
testCacheWithXml();
|
||||
// testBasicClientCache();
|
||||
// testBasicClientCacheWithXml();
|
||||
testHeapTunedCache();
|
||||
testCacheWithGatewayConflictResolver();
|
||||
}
|
||||
|
||||
private void testBasicCache() throws Exception {
|
||||
@@ -79,6 +83,12 @@ public class CacheNamespaceTest extends RecreatingContextTest {
|
||||
|
||||
}
|
||||
|
||||
private void testCacheWithGatewayConflictResolver() {
|
||||
Cache cache = ctx.getBean("cache-with-conflict-resolver", Cache.class);
|
||||
assertNotNull(cache.getGatewayConflictResolver());
|
||||
assertTrue(cache.getGatewayConflictResolver() instanceof TestConflictResolver);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testNoBeanFactory() throws Exception {
|
||||
assertTrue(ctx.containsBean("no-bl"));
|
||||
@@ -121,4 +131,12 @@ public class CacheNamespaceTest extends RecreatingContextTest {
|
||||
assertEquals(70, chp, 0.0001);
|
||||
assertEquals(60, ehp, 0.0001);
|
||||
}
|
||||
|
||||
public static class TestConflictResolver implements GatewayConflictResolver {
|
||||
@Override
|
||||
public void onEvent(TimestampedEntryEvent arg0, GatewayConflictHelper arg1) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.gemfire.RecreatingContextTest;
|
||||
|
||||
import com.gemstone.gemfire.cache.execute.FunctionAdapter;
|
||||
import com.gemstone.gemfire.cache.execute.FunctionContext;
|
||||
import com.gemstone.gemfire.cache.execute.FunctionService;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
*/
|
||||
public class FunctionServiceNamespaceTest extends RecreatingContextTest {
|
||||
|
||||
@Override
|
||||
protected String location() {
|
||||
return "org/springframework/data/gemfire/config/function-service-ns.xml";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFunctionsRegistered() throws Exception {
|
||||
assertEquals(2, FunctionService.getRegisteredFunctions().size());
|
||||
assertNotNull(FunctionService.getFunction("function1"));
|
||||
assertNotNull(FunctionService.getFunction("function2"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class Function1 extends FunctionAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(FunctionContext arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "function1";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class Function2 extends FunctionAdapter {
|
||||
|
||||
@Override
|
||||
public void execute(FunctionContext arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "function2";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
<!-- all beans are lazy to allow the same config to be used between multiple tests -->
|
||||
<!-- as there can be only one cache per VM -->
|
||||
|
||||
<gfe:cache />
|
||||
<gfe:cache/>
|
||||
|
||||
<gfe:cache id="cache-with-name"/>
|
||||
|
||||
@@ -29,4 +29,11 @@
|
||||
<gfe:client-cache id="client-cache-with-xml" cache-xml-location="classpath:gemfire-client-cache.xml"/>
|
||||
|
||||
<gfe:cache id="heap-tuned-cache" critical-heap-percentage="70.0" eviction-heap-percentage="60.0"/>
|
||||
</beans>
|
||||
|
||||
<gfe:cache id="cache-with-conflict-resolver">
|
||||
<gfe:gateway-conflict-resolver>
|
||||
<bean class="org.springframework.data.gemfire.config.CacheNamespaceTest.TestConflictResolver"/>
|
||||
</gfe:gateway-conflict-resolver>
|
||||
</gfe:cache>
|
||||
</beans>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
default-lazy-init="true"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
||||
|
||||
<gfe:function-service>
|
||||
<gfe:function>
|
||||
<bean class="org.springframework.data.gemfire.config.FunctionServiceNamespaceTest.Function1"/>
|
||||
<ref bean="function2"/>
|
||||
</gfe:function>
|
||||
</gfe:function-service>
|
||||
|
||||
<bean id="function2" class="org.springframework.data.gemfire.config.FunctionServiceNamespaceTest.Function2"/>
|
||||
</beans>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<gfe:cache />
|
||||
|
||||
<!-- need manual-start=true for the unit test because GF will throw an exception if no locators are configured -->
|
||||
<gfe:local-region id="region-inner-gateway-sender" >
|
||||
<gfe:partitioned-region id="region-inner-gateway-sender" >
|
||||
<gfe:gateway-sender
|
||||
remote-distributed-system-id="1"
|
||||
manual-start="true"
|
||||
@@ -35,7 +35,7 @@
|
||||
</gfe:transport-filter>
|
||||
</gfe:gateway-sender>
|
||||
<gfe:gateway-sender-ref bean="gateway-sender"/>
|
||||
</gfe:local-region>
|
||||
</gfe:partitioned-region>
|
||||
|
||||
<gfe:async-event-queue id="async-event-queue" batch-size="10" persistent="true" disk-store-ref="diskstore"
|
||||
maximum-queue-memory="50">
|
||||
|
||||
Reference in New Issue
Block a user