Skip to content

Commit 986ef4f

Browse files
committed
Bug 37213021 - [37193693->25.03] Unable to redefine cache mapping using cache config override
(auto-submit 112138 after successfully running remote remote.full) Job ID: job.9.20241024202123.32649 [git-p4: depot-paths = "//dev/coherence-ce/main/": change = 112144]
1 parent 4215819 commit 986ef4f

File tree

4 files changed

+87
-10
lines changed

4 files changed

+87
-10
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2022, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
package com.tangosol.coherence.config.xml.processor;
88

@@ -11,6 +11,7 @@
1111
import java.util.ArrayList;
1212
import java.util.List;
1313

14+
import com.oracle.coherence.common.base.Logger;
1415
import com.tangosol.config.xml.OverrideProcessor;
1516
import com.tangosol.run.xml.XmlElement;
1617
import com.tangosol.run.xml.XmlHelper;
@@ -116,10 +117,13 @@ private void processSchemeMappings(XmlElement xmlBase,
116117
if (sCacheNameOverride.equals(sCacheNameBase))
117118
{
118119
XmlHelper.overrideElement(xmlElementBase, xmlElementOverride);
119-
}
120-
else if (!listElements.contains(xmlElementOverride))
121-
{
122-
listElements.add(xmlElementOverride);
120+
121+
if (listElements.contains(xmlElementOverride))
122+
{
123+
listElements.remove(xmlElementOverride);
124+
}
125+
126+
break;
123127
}
124128
else if (sSchemeName.equals(sOverrideSchemeName))
125129
{

prj/test/functional/cache/pom.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@
5151
<artifactId>coherence</artifactId>
5252
<version>${project.version}</version>
5353
</dependency>
54-
54+
<dependency>
55+
<groupId>${coherence.group.id}</groupId>
56+
<artifactId>coherence-concurrent</artifactId>
57+
<version>${project.version}</version>
58+
</dependency>
5559
<dependency>
5660
<groupId>com.github.ben-manes.caffeine</groupId>
5761
<artifactId>caffeine</artifactId>

prj/test/functional/cache/src/main/java/override/CacheConfigOverrideTests.java

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
66
*/
77
package override;
88

9-
import com.oracle.coherence.testing.AbstractFunctionalTest;
9+
import com.oracle.coherence.concurrent.Queues;
1010

11+
import com.oracle.coherence.testing.AbstractFunctionalTest;
12+
import com.oracle.bedrock.runtime.coherence.options.LocalHost;
13+
import com.oracle.bedrock.runtime.coherence.options.WellKnownAddress;
14+
import com.oracle.bedrock.runtime.java.options.IPv4Preferred;
1115
import com.oracle.bedrock.testsupport.deferred.Eventually;
1216

1317
import com.tangosol.net.CacheFactory;
1418
import com.tangosol.net.CacheService;
1519
import com.tangosol.net.Cluster;
20+
import com.tangosol.net.Coherence;
1621
import com.tangosol.net.CoherenceSession;
1722
import com.tangosol.net.ConfigurableCacheFactory;
1823
import com.tangosol.net.ExtensibleConfigurableCacheFactory;
24+
import com.tangosol.net.NamedBlockingQueue;
1925
import com.tangosol.net.NamedCache;
26+
import com.tangosol.net.QueueService;
2027
import com.tangosol.net.RequestPolicyException;
2128

2229
import com.tangosol.net.events.EventInterceptor;
@@ -67,6 +74,8 @@ public CacheConfigOverrideTests()
6774
public static void _startup()
6875
{
6976
// this test requires local storage to be enabled
77+
System.setProperty(WellKnownAddress.PROPERTY, LocalHost.loopback().getAddress());
78+
System.setProperty(IPv4Preferred.JAVA_NET_PREFER_IPV4_STACK, "true");
7079
System.setProperty("coherence.distributed.localstorage", "true");
7180
}
7281

@@ -162,7 +171,7 @@ public void testCacheConfigOverrideSingleScheme()
162171
// Check for correct QuorumStatus for service "$SYS:MyCacheService2" with write
163172
objectName = "Coherence:type=Service,name=\"$SYS:MyCacheService2\",*";
164173
mbeanObj = serverJMX.queryMBeans(new ObjectName(objectName), null);
165-
assertTrue(mbeanObj.size() == 1);
174+
assertEquals(mbeanObj.size(), 1);
166175

167176
serviceON = new ObjectName(mbeanObj.iterator().next().getObjectName().toString());
168177
quorumStatus = (String) serverJMX.getAttribute(serviceON, "QuorumStatus");
@@ -583,6 +592,40 @@ public void testCacheConfigWithExistingTopicsMappingAndOverride()
583592
}
584593
}
585594

595+
@Test
596+
public void testConcurrentOverride()
597+
throws Exception
598+
{
599+
System.setProperty("coherence.concurrent.cacheconfig.override", "override/test-override.xml");
600+
601+
try (Coherence coherence = Coherence.clusterMember().start().join())
602+
{
603+
try (NamedBlockingQueue<Integer> q = Queues.pagedQueue("elastic-numbers"))
604+
{
605+
QueueService qs = q.getService();
606+
assertEquals("$SYS:OverrideQueue", qs.getInfo().getServiceName());
607+
assertEquals("DistributedCache", qs.getInfo().getServiceType());
608+
609+
for (int i = 0; i < 10; i++)
610+
{
611+
q.add(i);
612+
}
613+
614+
Integer e = q.poll();
615+
while (e != null)
616+
{
617+
Thread.sleep(1000L);
618+
System.out.println(e);
619+
e = q.poll();
620+
}
621+
}
622+
}
623+
finally
624+
{
625+
System.clearProperty("coherence.concurrent.cacheconfig.override");
626+
}
627+
}
628+
586629
// ----- constants and data members -------------------------------------
587630

588631
/**
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
Copyright (c) 2000, 2024, 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+
<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
10+
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">
11+
12+
<caching-scheme-mapping>
13+
<cache-mapping>
14+
<cache-name>PagedQueue$*</cache-name>
15+
<scheme-name>my-paged-queues</scheme-name>
16+
</cache-mapping>
17+
</caching-scheme-mapping>
18+
19+
<caching-schemes>
20+
<distributed-scheme>
21+
<scheme-name>my-paged-queues</scheme-name>
22+
<service-name>OverrideQueue</service-name>
23+
<autostart>true</autostart>
24+
</distributed-scheme>
25+
</caching-schemes>
26+
</cache-config>

0 commit comments

Comments
 (0)