Skip to content

Commit 118d82d

Browse files
committed
Bug 38456354 - [37388347->14.1.2.0.5] Default configuration is not applied to ViewScheme
(merge 14.1.2-0 -> ce/14.1.2-0 118625) [git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v14.1.2.0/": change = 118626]
1 parent a89094e commit 118d82d

File tree

4 files changed

+208
-3
lines changed

4 files changed

+208
-3
lines changed

prj/coherence-core/src/main/java/com/tangosol/coherence/config/scheme/ViewScheme.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package com.tangosol.coherence.config.scheme;
88

9+
import com.tangosol.config.annotation.Injectable;
910
import com.tangosol.config.expression.ParameterResolver;
1011

1112
import com.tangosol.internal.net.service.DefaultViewDependencies;
@@ -22,6 +23,7 @@
2223
import com.tangosol.net.internal.ScopedServiceReferenceStore;
2324
import com.tangosol.net.internal.ViewCacheService;
2425

26+
import com.tangosol.run.xml.XmlElement;
2527
import com.tangosol.util.Base;
2628

2729
import java.lang.reflect.Method;
@@ -87,9 +89,9 @@ public ViewScheme()
8789

8890
setFrontScheme(NO_SCHEME);
8991

90-
DistributedScheme schemeBack = new DistributedScheme();
91-
schemeBack.setServiceName(getServiceType());
92-
setBackScheme(schemeBack);
92+
f_defaultBackScheme = new DistributedScheme();
93+
f_defaultBackScheme.setServiceName(getServiceType());
94+
setBackScheme(f_defaultBackScheme);
9395
}
9496

9597
// ----- AbstractServiceScheme methods ----------------------------------
@@ -100,6 +102,12 @@ public String getScopedServiceName()
100102
return ViewCacheService.KEY_CLUSTER_REGISTRY + '-' + super.getScopedServiceName();
101103
}
102104

105+
@Injectable(".")
106+
public DistributedScheme getDefaultBackScheme()
107+
{
108+
return f_defaultBackScheme;
109+
}
110+
103111
// ----- ServiceBuilder interface ---------------------------------------
104112

105113
@Override
@@ -191,4 +199,11 @@ protected ScopedServiceReferenceStore getServiceStore(Cluster cluster)
191199
* @since 12.2.1.4.19
192200
*/
193201
private static final Method SAFE_CLUSTER_GET_SCOPED_SERVICE_STORE;
202+
203+
// ----- data members ---------------------------------------------------
204+
205+
/**
206+
* The default back scheme, if one is not configured.
207+
*/
208+
private final DistributedScheme f_defaultBackScheme;
194209
}

prj/coherence-core/src/main/java/com/tangosol/coherence/config/xml/CacheConfigNamespaceHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ public CacheConfigNamespaceHandler()
200200
CacheFactory.getServiceConfig(InvocationService.TYPE_REMOTE));
201201

202202
odp.addDefaultsDefinition("paged-topic-scheme", CacheFactory.getServiceConfig(CacheService.TYPE_DISTRIBUTED));
203+
odp.addDefaultsDefinition("view-scheme", CacheFactory.getServiceConfig(CacheService.TYPE_DISTRIBUTED));
203204

204205
dep.addElementPreprocessor(odp);
205206

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Universal Permissive License v 1.0 as shown at
5+
* https://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
package cache;
9+
10+
import com.tangosol.io.pof.ConfigurablePofContext;
11+
import com.tangosol.net.CacheService;
12+
import com.tangosol.net.Coherence;
13+
import com.tangosol.net.DistributedCacheService;
14+
import com.tangosol.net.NamedCache;
15+
import com.tangosol.net.Session;
16+
import org.junit.AfterClass;
17+
import org.junit.BeforeClass;
18+
import org.junit.Test;
19+
20+
import static org.hamcrest.CoreMatchers.instanceOf;
21+
import static org.hamcrest.CoreMatchers.is;
22+
import static org.hamcrest.MatcherAssert.assertThat;
23+
24+
public class ViewSchemeDefaultsTests
25+
{
26+
@BeforeClass
27+
public static void setup() throws Exception
28+
{
29+
System.setProperty("coherence.cacheconfig", "view-cache-config.xml");
30+
System.setProperty("coherence.distributed.partitioncount", "13");
31+
System.setProperty("coherence.distributed.backupcount", "2");
32+
33+
Coherence coherence = Coherence.clusterMember().startAndWait();
34+
session = coherence.getSession();
35+
}
36+
37+
@AfterClass
38+
public static void cleanup()
39+
{
40+
Coherence.closeAll();
41+
}
42+
43+
@Test
44+
public void shouldHaveCorrectSerializerWithBackSchemeRef() throws Exception
45+
{
46+
NamedCache<?, ?> cache = session.getCache("view-with-ref");
47+
CacheService service = cache.getCacheService();
48+
assertThat(service.getSerializer(), is(instanceOf(ConfigurablePofContext.class)));
49+
}
50+
51+
@Test
52+
public void shouldHaveCorrectSerializerWithBackScheme() throws Exception
53+
{
54+
NamedCache<?, ?> cache = session.getCache("view-with-back");
55+
CacheService service = cache.getCacheService();
56+
assertThat(service.getSerializer(), is(instanceOf(ConfigurablePofContext.class)));
57+
}
58+
59+
@Test
60+
public void shouldHaveCorrectSerializerWithNoBackScheme() throws Exception
61+
{
62+
NamedCache<?, ?> cache = session.getCache("view-with-no-back");
63+
CacheService service = cache.getCacheService();
64+
assertThat(service.getSerializer(), is(instanceOf(ConfigurablePofContext.class)));
65+
}
66+
67+
@Test
68+
public void shouldHaveCorrectPartitionCountWithBackSchemeRef() throws Exception
69+
{
70+
NamedCache<?, ?> cache = session.getCache("view-with-ref");
71+
DistributedCacheService service = (DistributedCacheService) cache.getCacheService();
72+
assertThat(service.getPartitionCount(), is(13));
73+
}
74+
75+
@Test
76+
public void shouldHaveCorrectPartitionCountWithBackScheme() throws Exception
77+
{
78+
NamedCache<?, ?> cache = session.getCache("view-with-back");
79+
DistributedCacheService service = (DistributedCacheService) cache.getCacheService();
80+
assertThat(service.getPartitionCount(), is(13));
81+
}
82+
83+
@Test
84+
public void shouldHaveCorrectPartitionCountWithNoBackScheme() throws Exception
85+
{
86+
NamedCache<?, ?> cache = session.getCache("view-with-no-back");
87+
DistributedCacheService service = (DistributedCacheService) cache.getCacheService();
88+
assertThat(service.getPartitionCount(), is(13));
89+
}
90+
91+
@Test
92+
public void shouldHaveCorrectBackupCountWithBackSchemeRef() throws Exception
93+
{
94+
NamedCache<?, ?> cache = session.getCache("view-with-ref");
95+
DistributedCacheService service = (DistributedCacheService) cache.getCacheService();
96+
assertThat(service.getBackupCount(), is(2));
97+
}
98+
99+
@Test
100+
public void shouldHaveCorrectBackupCountWithBackScheme() throws Exception
101+
{
102+
NamedCache<?, ?> cache = session.getCache("view-with-back");
103+
DistributedCacheService service = (DistributedCacheService) cache.getCacheService();
104+
assertThat(service.getBackupCount(), is(2));
105+
}
106+
107+
@Test
108+
public void shouldHaveCorrectBackupCountWithNoBackScheme() throws Exception
109+
{
110+
NamedCache<?, ?> cache = session.getCache("view-with-no-back");
111+
DistributedCacheService service = (DistributedCacheService) cache.getCacheService();
112+
assertThat(service.getBackupCount(), is(2));
113+
}
114+
115+
// ----- data members ---------------------------------------------------
116+
117+
private static Session session;
118+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (c) 2000, 2025, Oracle and/or its affiliates.
4+
5+
Licensed under the Universal Permissive License v 1.0 as shown at
6+
https://oss.oracle.com/licenses/upl.
7+
-->
8+
9+
<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
11+
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
12+
13+
<defaults>
14+
<serializer>pof</serializer>
15+
</defaults>
16+
17+
<caching-scheme-mapping>
18+
<cache-mapping>
19+
<cache-name>view-with-ref</cache-name>
20+
<scheme-name>view-with-ref-scheme</scheme-name>
21+
</cache-mapping>
22+
<cache-mapping>
23+
<cache-name>view-with-back</cache-name>
24+
<scheme-name>view-with-back-scheme</scheme-name>
25+
</cache-mapping>
26+
<cache-mapping>
27+
<cache-name>view-with-no-back</cache-name>
28+
<scheme-name>view-with-no-back-scheme</scheme-name>
29+
</cache-mapping>
30+
</caching-scheme-mapping>
31+
32+
<caching-schemes>
33+
<view-scheme>
34+
<scheme-name>view-with-ref-scheme</scheme-name>
35+
<back-scheme>
36+
<distributed-scheme>
37+
<scheme-ref>dist-default</scheme-ref>
38+
</distributed-scheme>
39+
</back-scheme>
40+
<autostart>true</autostart>
41+
</view-scheme>
42+
43+
<view-scheme>
44+
<scheme-name>view-with-back-scheme</scheme-name>
45+
<back-scheme>
46+
<distributed-scheme>
47+
<service-name>DistributedViewCache</service-name>
48+
<backing-map-scheme>
49+
<local-scheme/>
50+
</backing-map-scheme>
51+
</distributed-scheme>
52+
</back-scheme>
53+
<autostart>true</autostart>
54+
</view-scheme>
55+
56+
<view-scheme>
57+
<scheme-name>view-with-no-back-scheme</scheme-name>
58+
<autostart>true</autostart>
59+
</view-scheme>
60+
61+
<distributed-scheme>
62+
<scheme-name>dist-default</scheme-name>
63+
<service-name>DistributedCache</service-name>
64+
<backing-map-scheme>
65+
<local-scheme/>
66+
</backing-map-scheme>
67+
<autostart>true</autostart>
68+
</distributed-scheme>
69+
</caching-schemes>
70+
71+
</cache-config>

0 commit comments

Comments
 (0)