Skip to content

Commit 13ea059

Browse files
committed
Fix tests
1 parent 77db403 commit 13ea059

File tree

12 files changed

+36
-162
lines changed

12 files changed

+36
-162
lines changed

geode-core/src/main/java/org/apache/geode/cache/wan/GatewaySender.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ public interface GatewaySender {
153153
int CONNECTION_RETRY_INTERVAL = Integer
154154
.getInteger(GeodeGlossary.GEMFIRE_PREFIX + "gateway-connection-retry-interval", 1000);
155155

156-
String DEFAULT_TYPE = "SerialGatewaySender";
157-
158156
/**
159157
* The order policy. This enum is applicable only when concurrency-level is > 1.
160158
*

geode-core/src/main/java/org/apache/geode/internal/cache/wan/GatewaySenderAttributesImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class GatewaySenderAttributesImpl implements MutableGatewaySenderAttribut
8181

8282
private boolean groupTransactionEvents = GatewaySender.DEFAULT_MUST_GROUP_TRANSACTION_EVENTS;
8383

84-
private String type = GatewaySender.DEFAULT_TYPE;
84+
private String type;
8585

8686
private boolean isForInternalUse = GatewaySender.DEFAULT_IS_FOR_INTERNAL_USE;
8787

@@ -179,7 +179,7 @@ public void setGroupTransactionEvents(boolean groupTransEvents) {
179179

180180
public void setType(String type) {
181181
this.type = type;
182-
isParallel = type.equals("Parallel") ? true : false;
182+
isParallel = type.contains("Parallel") ? true : false;
183183
}
184184

185185
public void setForInternalUse(boolean forInternalUse) {

geode-core/src/main/java/org/apache/geode/internal/lang/SystemPropertyHelper.java

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
package org.apache.geode.internal.lang;
1616

17-
import java.util.Optional;
17+
import static org.apache.geode.internal.lang.SystemProperty.getProductBooleanProperty;
1818

1919
import org.apache.geode.internal.cache.eviction.LRUListWithAsyncSorting;
2020

@@ -26,9 +26,6 @@
2626
*/
2727
public class SystemPropertyHelper {
2828

29-
public static final String GEODE_PREFIX = "geode.";
30-
public static final String GEMFIRE_PREFIX = "gemfire.";
31-
3229
/**
3330
* When set to "true" enables asynchronous eviction algorithm (defaults to true). For more details
3431
* see {@link LRUListWithAsyncSorting}.
@@ -109,98 +106,6 @@ public class SystemPropertyHelper {
109106
*/
110107
public static final String RE_AUTHENTICATE_WAIT_TIME = "reauthenticate.wait.time";
111108

112-
/**
113-
* This method will try to look up "geode." and "gemfire." versions of the system property. It
114-
* will check and prefer "geode." setting first, then try to check "gemfire." setting.
115-
*
116-
* @param name system property name set in Geode
117-
* @return an Optional containing the Boolean value of the system property
118-
*/
119-
public static Optional<Boolean> getProductBooleanProperty(String name) {
120-
String property = getProperty(name);
121-
return property != null ? Optional.of(Boolean.parseBoolean(property)) : Optional.empty();
122-
}
123-
124-
/**
125-
* This method will try to look up "geode." and "gemfire." versions of the system property. It
126-
* will check and prefer "geode." setting first, then try to check "gemfire." setting.
127-
*
128-
* @param name system property name set in Geode
129-
* @return an Optional containing the Integer value of the system property
130-
*/
131-
public static Optional<Integer> getProductIntegerProperty(String name) {
132-
Integer propertyValue = Integer.getInteger(GEODE_PREFIX + name);
133-
if (propertyValue == null) {
134-
propertyValue = Integer.getInteger(GEMFIRE_PREFIX + name);
135-
}
136-
137-
if (propertyValue != null) {
138-
return Optional.of(propertyValue);
139-
} else {
140-
return Optional.empty();
141-
}
142-
}
143-
144-
/**
145-
* This method will try to look up "geode." and "gemfire." versions of the system property. It
146-
* will check and prefer "geode." setting first, then try to check "gemfire." setting.
147-
*
148-
* @param name system property name set in Geode
149-
* @return an Optional containing the Long value of the system property
150-
*/
151-
public static Optional<Long> getProductLongProperty(String name) {
152-
Long propertyValue = Long.getLong(GEODE_PREFIX + name);
153-
if (propertyValue == null) {
154-
propertyValue = Long.getLong(GEMFIRE_PREFIX + name);
155-
}
156-
157-
if (propertyValue != null) {
158-
return Optional.of(propertyValue);
159-
} else {
160-
return Optional.empty();
161-
}
162-
}
163-
164-
/**
165-
* This method will try to look up "geode." and "gemfire." versions of the system property. It
166-
* will check and prefer "geode." setting first, then try to check "gemfire." setting.
167-
*
168-
* @param name system property name set in Geode
169-
* @return the integer value of the system property if exits or the default value
170-
*/
171-
public static Integer getProductIntegerProperty(String name, int defaultValue) {
172-
return getProductIntegerProperty(name).orElse(defaultValue);
173-
}
174-
175-
public static Long getProductLongProperty(String name, long defaultValue) {
176-
return getProductLongProperty(name).orElse(defaultValue);
177-
}
178-
179-
/**
180-
* This method will try to look up "geode." and "gemfire." versions of the system property. It
181-
* will check and prefer "geode." setting first, then try to check "gemfire." setting.
182-
*
183-
* @param name system property name set in Geode
184-
* @return an Optional containing the String value of the system property
185-
*/
186-
public static Optional<String> getProductStringProperty(String name) {
187-
String property = getProperty(name);
188-
return property != null ? Optional.of(property) : Optional.empty();
189-
}
190-
191-
public static String getProperty(String name) {
192-
String property = getGeodeProperty(name);
193-
return property != null ? property : getGemfireProperty(name);
194-
}
195-
196-
private static String getGeodeProperty(String name) {
197-
return System.getProperty(GEODE_PREFIX + name);
198-
}
199-
200-
private static String getGemfireProperty(String name) {
201-
return System.getProperty(GEMFIRE_PREFIX + name);
202-
}
203-
204109
/**
205110
* As of Geode 1.4.0, a region set operation will be in a transaction even if it is the first
206111
* operation in the transaction.

geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/functions/GatewaySenderCreateFunction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ private GatewaySender createGatewaySender(Cache cache,
8484

8585
String type = gatewaySenderCreateArgs.getType();
8686
if (type != null) {
87-
gateway.setType(gatewaySenderCreateArgs.getType());
88-
gateway.setParallel(gatewaySenderCreateArgs.getType().contains("Parallel"));
87+
gateway.setType(type);
88+
gateway.setParallel(type.contains("Parallel"));
8989
} else {
9090
Boolean isParallel = gatewaySenderCreateArgs.isParallel();
9191
if (isParallel != null) {

geode-wan-txgrouping/src/distributedTest/java/org/apache/geode/internal/cache/wan/txgrouping/TxGroupingPartitionedRegionDUnitTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
@RunWith(GeodeParamsRunner.class)
4141
public class TxGroupingPartitionedRegionDUnitTest extends TxGroupingBaseDUnitTest {
4242
@Test
43-
@Parameters({"TxGroupParallelGatewaySender", "TxGroupSerialGatewaySender"})
43+
@Parameters({"TxGroupingParallelGatewaySender", "TxGroupingSerialGatewaySender"})
4444
public void testPartitionedRegionPropagationWithGroupTransactionEventsAndMixOfEventsInAndNotInTransactions(
4545
String type)
4646
throws Exception {

geode-wan-txgrouping/src/distributedTest/java/org/apache/geode/internal/cache/wan/txgrouping/parallel/TxGroupingParallelDUnitTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,15 @@ public void testParallelPropagationHAWithGroupTransactionEvents() throws Excepti
361361
assertThat(londonServerStats.get(0)).isEqualTo(0);
362362

363363
// eventsReceived
364-
// We may see two retried events (as transactions are made of 2 events) on all members due to
364+
// We may see 4 retried events (as transactions are made of 4 events) on all members due to
365365
// the kill
366-
assertThat(londonServerStats.get(1)).isLessThanOrEqualTo((entries + 2) * redundantCopies);
366+
assertThat(londonServerStats.get(1))
367+
.isLessThanOrEqualTo((entries + putsPerTransaction) * redundantCopies);
367368
assertThat(londonServerStats.get(1)).isGreaterThanOrEqualTo(entries * redundantCopies);
368369

369370
// queuedEvents
370-
assertThat(londonServerStats.get(2)).isLessThanOrEqualTo((entries + 2) * redundantCopies);
371+
assertThat(londonServerStats.get(2))
372+
.isLessThanOrEqualTo((entries + putsPerTransaction) * redundantCopies);
371373
assertThat(londonServerStats.get(2)).isGreaterThanOrEqualTo(entries * redundantCopies);
372374

373375
// batches redistributed

geode-wan-txgrouping/src/integrationTest/java/org/apache/geode/internal/cache/wan/txgrouping/WanTxGroupingConfigurationJUnitTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.apache.geode.cache.RegionShortcut;
3131
import org.apache.geode.cache.wan.GatewaySender;
3232
import org.apache.geode.cache.wan.GatewaySenderFactory;
33+
import org.apache.geode.cache.wan.internal.txgrouping.serial.TxGroupingSerialGatewaySenderImpl;
3334
import org.apache.geode.internal.cache.wan.GatewaySenderException;
3435

3536
public class WanTxGroupingConfigurationJUnitTest {
@@ -63,9 +64,8 @@ public void test_ValidateSerialGatewaySenderGroupTransactionEventsAttributeSetTo
6364
public void test_create_SerialGatewaySender_ThrowsException_when_GroupTransactionEvents_isTrue_and_DispatcherThreads_is_greaterThanOne() {
6465
cache = new CacheFactory().set(MCAST_PORT, "0").create();
6566
GatewaySenderFactory fact = cache.createGatewaySenderFactory();
66-
fact.setParallel(false);
6767
fact.setDispatcherThreads(2);
68-
fact.setGroupTransactionEvents(true);
68+
fact.setType(TxGroupingSerialGatewaySenderImpl.TYPE);
6969
assertThatThrownBy(() -> fact.create("NYSender", 2))
7070
.isInstanceOf(GatewaySenderException.class)
7171
.hasMessageContaining(
@@ -77,7 +77,7 @@ public void test_create_GatewaySender_ThrowsException_when_GroupTransactionEvent
7777
cache = new CacheFactory().set(MCAST_PORT, "0").create();
7878
GatewaySenderFactory fact = cache.createGatewaySenderFactory();
7979
fact.setBatchConflationEnabled(true);
80-
fact.setGroupTransactionEvents(true);
80+
fact.setType(TxGroupingSerialGatewaySenderImpl.TYPE);
8181
assertThatThrownBy(() -> fact.create("NYSender", 2))
8282
.isInstanceOf(GatewaySenderException.class)
8383
.hasMessageContaining(

geode-wan-txgrouping/src/main/java/org/apache/geode/cache/wan/internal/txgrouping/TxGroupingGatewaySenderProperties.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import java.util.concurrent.atomic.AtomicInteger;
1919

20-
import org.apache.geode.internal.lang.SystemPropertyHelper;
20+
import org.apache.geode.internal.lang.SystemProperty;
2121
import org.apache.geode.util.internal.GeodeGlossary;
2222

2323
public class TxGroupingGatewaySenderProperties implements TxGroupingGatewaySender {
@@ -52,7 +52,7 @@ public class TxGroupingGatewaySenderProperties implements TxGroupingGatewaySende
5252
* gateway sender queue when group-transaction-events is true.
5353
*/
5454
public static final int GET_TRANSACTION_EVENTS_FROM_QUEUE_WAIT_TIME_MS =
55-
SystemPropertyHelper.getProductIntegerProperty(
55+
SystemProperty.getProductIntegerProperty(
5656
GET_TRANSACTION_EVENTS_FROM_QUEUE_WAIT_TIME_MS_PROPERTY).orElse(1);
5757

5858
private AtomicInteger retriesToGetTransactionEventsFromQueue =

geode-wan-txgrouping/src/main/java/org/apache/geode/cache/wan/internal/txgrouping/serial/TxGroupingRemoteSerialGatewaySenderEventProcessor.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
import org.jetbrains.annotations.NotNull;
1919
import org.jetbrains.annotations.Nullable;
2020

21+
import org.apache.geode.cache.CacheListener;
22+
import org.apache.geode.cache.asyncqueue.AsyncEvent;
2123
import org.apache.geode.cache.wan.internal.serial.RemoteSerialGatewaySenderEventProcessor;
24+
import org.apache.geode.internal.cache.RegionQueue;
2225
import org.apache.geode.internal.cache.wan.AbstractGatewaySender;
2326
import org.apache.geode.internal.monitoring.ThreadsMonitoring;
2427

@@ -31,11 +34,10 @@ public TxGroupingRemoteSerialGatewaySenderEventProcessor(
3134
super(sender, id, threadsMonitoring, cleanQueues);
3235
}
3336

34-
// @Override
35-
// protected @NotNull RegionQueue createRegionQueue(
36-
// final @NotNull AbstractGatewaySender sender, final @NotNull String regionName,
37-
// final @NotNull CacheListener<?, ?> listener, final boolean cleanQueues) {
38-
// return new TxGroupingSerialGatewaySenderQueue((TxGroupingSerialGatewaySenderImpl) sender,
39-
// regionName, listener, cleanQueues);
40-
// }
37+
@Override
38+
protected @NotNull RegionQueue createRegionQueue(
39+
final @NotNull AbstractGatewaySender sender, final @NotNull String regionName,
40+
final @NotNull CacheListener<Long, AsyncEvent<?, ?>> listener, final boolean cleanQueues) {
41+
return new TxGroupingSerialGatewaySenderQueue(sender, regionName, listener, cleanQueues);
42+
}
4143
}

geode-wan/src/distributedTest/java/org/apache/geode/internal/cache/wan/WANTestBase.java

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
import org.apache.geode.cache.RegionFactory;
104104
import org.apache.geode.cache.RegionShortcut;
105105
import org.apache.geode.cache.Scope;
106-
import org.apache.geode.cache.TransactionException;
107106
import org.apache.geode.cache.asyncqueue.AsyncEventListener;
108107
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
109108
import org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory;
@@ -2609,48 +2608,6 @@ public static void doTxPuts(String regionName) {
26092608
mgr.commit();
26102609
}
26112610

2612-
public static void doTxPutsWithRetryIfError(String regionName, final long putsPerTransaction,
2613-
final long transactions, long offset) {
2614-
Region<Object, Object> r = cache.getRegion(Region.SEPARATOR + regionName);
2615-
2616-
long keyOffset = offset * ((putsPerTransaction + (10 * transactions)) * 100);
2617-
long j = 0;
2618-
CacheTransactionManager mgr = cache.getCacheTransactionManager();
2619-
for (int i = 0; i < transactions; i++) {
2620-
boolean done = false;
2621-
do {
2622-
try {
2623-
mgr.begin();
2624-
for (j = 0; j < putsPerTransaction; j++) {
2625-
long key = keyOffset + ((j + (10 * i)) * 100);
2626-
String value = "Value_" + key;
2627-
r.put(key, value);
2628-
}
2629-
mgr.commit();
2630-
done = true;
2631-
} catch (TransactionException e) {
2632-
logger.info("Something went wrong with transaction [{},{}]. Retrying. Error: {}", i, j,
2633-
e.getMessage());
2634-
e.printStackTrace();
2635-
} catch (IllegalStateException e1) {
2636-
logger.info("Something went wrong with transaction [{},{}]. Retrying. Error: {}", i, j,
2637-
e1.getMessage());
2638-
e1.printStackTrace();
2639-
try {
2640-
mgr.rollback();
2641-
logger.info("Rolled back transaction [{},{}]. Retrying. Error: {}", i, j,
2642-
e1.getMessage());
2643-
} catch (Exception e2) {
2644-
logger.info(
2645-
"Something went wrong when rolling back transaction [{},{}]. Retrying transaction. Error: {}",
2646-
i, j, e2.getMessage());
2647-
e2.printStackTrace();
2648-
}
2649-
}
2650-
} while (!done);
2651-
}
2652-
}
2653-
26542611
public static void doNextPuts(String regionName, int start, int numPuts) {
26552612
IgnoredException exp =
26562613
addIgnoredException(CacheClosedException.class.getName());

0 commit comments

Comments
 (0)