Skip to content

Commit

Permalink
GEODE-7869: Cleanup warnings in geode-redis
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-at-work committed Mar 16, 2020
1 parent 644c52f commit 23701b2
Show file tree
Hide file tree
Showing 23 changed files with 229 additions and 258 deletions.
1 change: 1 addition & 0 deletions geode-redis/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
apply from: "${rootDir}/${scriptDir}/standard-subproject-configuration.gradle"

apply from: "${project.projectDir}/../gradle/publish-java.gradle"
apply from: "${rootDir}/${scriptDir}/warnings.gradle"

dependencies {
compile(platform(project(':boms:geode-all-bom')))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.geode.test.awaitility.GeodeAwaitility;
import org.apache.geode.test.dunit.AsyncInvocation;
import org.apache.geode.test.dunit.IgnoredException;
import org.apache.geode.test.dunit.SerializableCallable;
import org.apache.geode.test.dunit.SerializableRunnable;
import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.ClusterStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
Expand All @@ -45,9 +45,6 @@ public class RedisDistDUnitTest implements Serializable {
private static String LOCALHOST = "localhost";

public static final String TEST_KEY = "key";
private static MemberVM locator;
private static MemberVM server1;
private static MemberVM server2;
private static VM client1;
private static VM client2;

Expand All @@ -57,7 +54,7 @@ public class RedisDistDUnitTest implements Serializable {
private static final int JEDIS_TIMEOUT =
Math.toIntExact(GeodeAwaitility.getTimeout().getValueInMS());

private abstract static class ClientTestBase extends SerializableCallable<Object> {
private abstract static class ClientTestBase extends SerializableRunnable {
int port;

protected ClientTestBase(int port) {
Expand All @@ -71,15 +68,15 @@ public static void setup() {
server1Port = ports[0];
server2Port = ports[1];

locator = cluster.startLocatorVM(0);
MemberVM locator = cluster.startLocatorVM(0);

Properties redisProps = new Properties();
redisProps.setProperty("redis-bind-address", LOCALHOST);
redisProps.setProperty("redis-port", Integer.toString(ports[0]));
server1 = cluster.startServerVM(1, redisProps, locator.getPort());
cluster.startServerVM(1, redisProps, locator.getPort());

redisProps.setProperty("redis-port", Integer.toString(ports[1]));
server2 = cluster.startServerVM(2, redisProps, locator.getPort());
cluster.startServerVM(2, redisProps, locator.getPort());

client1 = cluster.getVM(3);
client2 = cluster.getVM(4);
Expand All @@ -97,7 +94,7 @@ protected ConcListOps(int port) {
}

@Override
public Object call() throws Exception {
public void run() {
Jedis jedis = new Jedis(LOCALHOST, port, JEDIS_TIMEOUT);
Random r = new Random();
for (int i = 0; i < pushes; i++) {
Expand All @@ -107,13 +104,12 @@ public Object call() throws Exception {
jedis.rpush(TEST_KEY, randString());
}
}
return null;
}
};
}

AsyncInvocation i = client1.invokeAsync(new ConcListOps(server1Port));
AsyncInvocation<Void> i = client1.invokeAsync(new ConcListOps(server1Port));
client2.invoke(new ConcListOps(server2Port));
i.get();
i.await();
long expected = 2 * pushes;
long result1 = jedis1.llen(TEST_KEY);
long result2 = jedis2.llen(TEST_KEY);
Expand All @@ -137,7 +133,7 @@ protected ConcCreateDestroy(int port) {
}

@Override
public Object call() throws Exception {
public void run() {
Jedis jedis = new Jedis(LOCALHOST, port, JEDIS_TIMEOUT);
Random r = new Random();
for (int i = 0; i < ops; i++) {
Expand Down Expand Up @@ -168,19 +164,19 @@ public Object call() throws Exception {
}
}
}
return null;
}
}

// Expect to run with no exception
AsyncInvocation i = client1.invokeAsync(new ConcCreateDestroy(server1Port));
AsyncInvocation<Void> i = client1.invokeAsync(new ConcCreateDestroy(server1Port));
client2.invoke(new ConcCreateDestroy(server2Port));
i.get();
i.await();
}

/**
* Just make sure there are no unexpected server crashes
*/
@Test
public void testConcOps() throws Exception {

final int ops = 100;
Expand All @@ -196,7 +192,7 @@ protected ConcOps(int port) {
}

@Override
public Object call() throws Exception {
public void run() {
Jedis jedis = new Jedis(LOCALHOST, port, JEDIS_TIMEOUT);
Random r = new Random();
for (int i = 0; i < ops; i++) {
Expand All @@ -222,14 +218,13 @@ public Object call() throws Exception {
jedis.sunionstore("dst", sKey, "afds");
}
}
return null;
}
}

// Expect to run with no exception
AsyncInvocation i = client1.invokeAsync(new ConcOps(server1Port));
AsyncInvocation<Void> i = client1.invokeAsync(new ConcOps(server1Port));
client2.invoke(new ConcOps(server2Port));
i.getResult();
i.await();
}

private String randString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@ public void setUp() {

@After
public void tearDown() {
if (this.cache != null) {
this.cache.close();
this.cache = null;
if (cache != null) {
cache.close();
cache = null;
}
}

@Test
public void testCachelessStart() throws InterruptedException {
runNServers(numServers);
GemFireCacheImpl.getInstance().close();
getCache().close();
}

@Test
public void testCachefulStart() throws InterruptedException {
CacheFactory cf = new CacheFactory();
cf.set(MCAST_PORT, "0");
cf.set(LOCATORS, "");
this.cache = cf.create();
cache = cf.create();

runNServers(numServers);
}
Expand All @@ -76,14 +76,10 @@ private void runNServers(int n) throws InterruptedException {
final Thread[] threads = new Thread[n];
for (int i = 0; i < n; i++) {
final int j = i;
Runnable r = new Runnable() {

@Override
public void run() {
GeodeRedisServer s = new GeodeRedisServer(ports[j]);
s.start();
s.shutdown();
}
Runnable r = () -> {
GeodeRedisServer s = new GeodeRedisServer(ports[j]);
s.start();
s.shutdown();
};

Thread t = new Thread(r);
Expand All @@ -93,7 +89,12 @@ public void run() {
}
for (Thread t : threads)
t.join();
this.cache = GemFireCacheImpl.getInstance();
assertFalse(this.cache.isClosed());
cache = getCache();
assertFalse(cache.isClosed());
}

@SuppressWarnings("deprecation")
private GemFireCacheImpl getCache() {
return GemFireCacheImpl.getInstance();
}
}
Loading

0 comments on commit 23701b2

Please sign in to comment.