You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bs...@apache.org on 2018/01/16 19:08:29 UTC
[geode] branch develop updated: GEODE-4280 add the ability to close
a Driver and to see if the driver is usable
This is an automated email from the ASF dual-hosted git repository.
bschuchardt pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new d0f5068 GEODE-4280 add the ability to close a Driver and to see if the driver is usable
d0f5068 is described below
commit d0f50681a91303e66802ec4301dcfcb198db90cc
Author: Bruce Schuchardt <bs...@pivotal.io>
AuthorDate: Thu Jan 11 16:28:51 2018 -0800
GEODE-4280 add the ability to close a Driver and to see if the driver is usable
Added close() and isConnected() methods and unit tests
This closes #1274
---
.../org/apache/geode/experimental/driver/Driver.java | 10 ++++++++++
.../apache/geode/experimental/driver/ProtobufDriver.java | 14 ++++++++++++++
.../geode/experimental/driver/DriverConnectionTest.java | 16 +++++++++++++---
3 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/Driver.java b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/Driver.java
index f3a3e62..5ad7c94 100644
--- a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/Driver.java
+++ b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/Driver.java
@@ -47,4 +47,14 @@ public interface Driver {
* @return the region object
*/
<K, V> Region<K, V> getRegion(String regionName);
+
+ /**
+ * Close this Driver, rendering it useless
+ */
+ void close();
+
+ /**
+ * Is this driver connected?
+ */
+ boolean isConnected();
}
diff --git a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufDriver.java b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufDriver.java
index 92080bd..57fa2a5 100644
--- a/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufDriver.java
+++ b/geode-experimental-driver/src/main/java/org/apache/geode/experimental/driver/ProtobufDriver.java
@@ -99,6 +99,20 @@ public class ProtobufDriver implements Driver {
return new ProtobufRegion(regionName, socket);
}
+ @Override
+ public void close() {
+ try {
+ this.socket.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+
+ @Override
+ public boolean isConnected() {
+ return !this.socket.isClosed();
+ }
+
/**
* Queries locators for a Geode server that has Protobuf enabled.
*
diff --git a/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/DriverConnectionTest.java b/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/DriverConnectionTest.java
index b12c5c7..f28a9c5 100644
--- a/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/DriverConnectionTest.java
+++ b/geode-experimental-driver/src/test/java/org/apache/geode/experimental/driver/DriverConnectionTest.java
@@ -56,7 +56,7 @@ public class DriverConnectionTest {
private int locatorPort;
@Before
- public void createServerAndDriver() throws Exception {
+ public void createServer() throws Exception {
System.setProperty("geode.feature-protobuf-protocol", "true");
// Create a cache
@@ -77,8 +77,6 @@ public class DriverConnectionTest {
cache.close();
}
-
-
@Test
public void driverFailsToConnectWhenThereAreNoServers() throws Exception {
try {
@@ -96,6 +94,18 @@ public class DriverConnectionTest {
server.setPort(0);
server.start();
driver = new DriverFactory().addLocator("localhost", locatorPort).create();
+ assertTrue(driver.isConnected());
+ }
+
+ @Test
+ public void driverReportsItIsDisconnected() throws Exception {
+ CacheServer server = cache.addCacheServer();
+ server.setPort(0);
+ server.start();
+ driver = new DriverFactory().addLocator("localhost", locatorPort).create();
+ driver.close();
+ assertFalse(driver.isConnected());
}
+
}
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].