From 155e6205083493851894623b855cd0ec99bbe7c2 Mon Sep 17 00:00:00 2001 From: "Magnusen, Drew (dm741q)" Date: Wed, 4 Apr 2018 11:52:26 -0500 Subject: Small modification to resolve junit failures Added protected method to Heartbeat class that allowed for the passing of a CountDown latch. This will resolve the timing-related junit failures in Jenkins environment. Issue-ID: POLICY-729 Change-Id: I3d2d8bddfb6d9f82be54a2f13bdcd7e1fc65a286 Signed-off-by: Magnusen, Drew (dm741q) --- .../locking/DistributedLockingFeature.java | 11 +- .../onap/policy/distributed/locking/Heartbeat.java | 28 ++- .../DistributedLockingFeatureExceptionTest.java | 36 +++ .../policy/distributed/locking/TargetLockTest.java | 251 +++++++++++++++++++++ .../DistributedLockingFeatureExceptionTest.java | 36 --- .../distributed/locking/test/TargetLockTest.java | 220 ------------------ 6 files changed, 322 insertions(+), 260 deletions(-) create mode 100644 feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java create mode 100644 feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java delete mode 100644 feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/test/DistributedLockingFeatureExceptionTest.java delete mode 100644 feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/test/TargetLockTest.java (limited to 'feature-distributed-locking/src') diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java index cc7a7a12..3d19c873 100644 --- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java +++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/DistributedLockingFeature.java @@ -65,9 +65,12 @@ public class DistributedLockingFeature implements PolicyEngineFeatureAPI, Policy */ private static final UUID uuid = UUID.randomUUID(); + /** - * Config directory + * Reference to Heartbeat */ + private static Heartbeat heartbeat = null; + @Override public int getSequenceNumber() { return 1000; @@ -116,7 +119,7 @@ public class DistributedLockingFeature implements PolicyEngineFeatureAPI, Policy long heartbeatInterval = this.lockProps.getHeartBeatIntervalProperty(); cleanLockTable(); - Heartbeat heartbeat = new Heartbeat(this.uuid, lockProps); + heartbeat = new Heartbeat(this.uuid, lockProps); this.scheduledExecutorService = Executors.newScheduledThreadPool(1); this.scheduledExecutorService.scheduleAtFixedRate(heartbeat, heartbeatInterval, heartbeatInterval, TimeUnit.MILLISECONDS); @@ -154,5 +157,9 @@ public class DistributedLockingFeature implements PolicyEngineFeatureAPI, Policy } } + + public static Heartbeat getHeartbeat() { + return heartbeat; + } } diff --git a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/Heartbeat.java b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/Heartbeat.java index c753dba9..edd0782e 100644 --- a/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/Heartbeat.java +++ b/feature-distributed-locking/src/main/java/org/onap/policy/distributed/locking/Heartbeat.java @@ -24,10 +24,9 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; -import java.util.Properties; import java.util.UUID; +import java.util.concurrent.CountDownLatch; -import org.onap.policy.drools.utils.NetworkUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,14 +51,34 @@ public class Heartbeat implements Runnable{ */ private UUID uuid; + /** + * Countdown latch for testing + */ + private volatile CountDownLatch latch; + + /** + * + * @param uuid + * @param lockProps + */ public Heartbeat(UUID uuid, DistributedLockingProperties lockProps) { this.lockProps = lockProps; this.uuid = uuid; + this.latch = new CountDownLatch(1); + } + /** + * + * @param latch + * Used for testing purposes + */ + protected void giveLatch(CountDownLatch latch) { + this.latch = latch; } @Override public void run() { + long expirationAge = lockProps.getAgingProperty(); try (Connection conn = DriverManager.getConnection(lockProps.getDbUrl(), lockProps.getDbUser(), @@ -70,9 +89,14 @@ public class Heartbeat implements Runnable{ statement.setLong(1, System.currentTimeMillis() + expirationAge); statement.setString(2, this.uuid.toString()); statement.executeUpdate(); + + latch.countDown(); + } catch (SQLException e) { logger.error("error in Heartbeat.run()", e); } } + + } diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java new file mode 100644 index 00000000..5bc3ae5e --- /dev/null +++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/DistributedLockingFeatureExceptionTest.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= + * feature-distributed-locking + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distributed.locking; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.policy.common.utils.test.ExceptionsTester; +import org.onap.policy.distributed.locking.DistributedLockingFeatureException; + +public class DistributedLockingFeatureExceptionTest extends ExceptionsTester{ + + @Test + public void test() { + assertEquals(1, test(DistributedLockingFeatureException.class)); + } + +} diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java new file mode 100644 index 00000000..2dc2ceb8 --- /dev/null +++ b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/TargetLockTest.java @@ -0,0 +1,251 @@ +/* + * ============LICENSE_START======================================================= + * feature-distributed-locking + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.distributed.locking; + +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.distributed.locking.DistributedLockingFeature; +import org.onap.policy.drools.persistence.SystemPersistence; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +public class TargetLockTest { + private static final Logger logger = LoggerFactory.getLogger(TargetLockTest.class); + private static final String DB_CONNECTION = "jdbc:h2:mem:pooling;INIT=CREATE SCHEMA IF NOT EXISTS pooling\\;SET SCHEMA pooling"; + private static final String DB_USER = "user"; + private static final String DB_PASSWORD = "password"; + private static Connection conn = null; + private static DistributedLockingFeature distLockFeat; + + @BeforeClass + public static void setup() { + getDBConnection(); + createTable(); + SystemPersistence.manager.setConfigurationDir("src/test/resources"); + distLockFeat = new DistributedLockingFeature(); + distLockFeat.afterStart(null); + + } + + @AfterClass + public static void cleanUp() { + distLockFeat.beforeShutdown(null); + try { + conn.close(); + } catch (SQLException e) { + logger.error("Error in TargetLockTest.cleanUp()", e); + } + } + + @Before + public void wipeDb() { + try (PreparedStatement lockDelete = conn.prepareStatement("DELETE FROM pooling.locks");){ + lockDelete.executeUpdate(); + } catch (SQLException e) { + logger.error("Error in TargetLockTest.wipeDb()", e); + throw new RuntimeException(e); + } + + } + + @Test + public void testGrabLockSuccess() throws InterruptedException, ExecutionException { + assertTrue(distLockFeat.beforeLock("resource1", "owner1", null).get()); + + //attempt to grab expiredLock + try (PreparedStatement updateStatement = conn.prepareStatement("UPDATE pooling.locks SET expirationTime = ? WHERE resourceId = ?");) + { + updateStatement.setLong(1, System.currentTimeMillis() - 1000); + updateStatement.setString(2, "resource1"); + updateStatement.executeUpdate(); + + } catch (SQLException e) { + logger.error("Error in TargetLockTest.testGrabLockSuccess()", e); + throw new RuntimeException(e); + } + + assertTrue(distLockFeat.beforeLock("resource1", "owner1", null).get()); + } + + @Test + public void testExpiredLocks() throws InterruptedException, ExecutionException { + + CountDownLatch rowExpireLatch = new CountDownLatch(1); + CountDownLatch heartbeatLatch = new CountDownLatch(1); + + //grab lock + distLockFeat.beforeLock("resource1", "owner1", null); + + //Wait for lock to expire + try { + rowExpireLatch.await(150, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + logger.error("Error in testExpiredLocks", e); + } + + // Grab reference to heartbeat object + Heartbeat heartbeat = distLockFeat.getHeartbeat(); + + // Pass heartbeat object countdown latch + try { + heartbeat.giveLatch(heartbeatLatch); + heartbeatLatch.await(5, TimeUnit.SECONDS); + } catch (InterruptedException e) { + logger.error("Error in testExpiredLocks", e); + } + + //Heartbeat should keep it active + assertFalse(distLockFeat.beforeLock("resource1", "owner1", null).get()); + } + + @Test + public void testGrabLockFail() throws InterruptedException, ExecutionException { + CountDownLatch latch = new CountDownLatch(1); + + distLockFeat.beforeLock("resource1", "owner1", null); + + try { + latch.await(10, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + logger.error("Error in testExpiredLocks", e); + } + assertFalse(distLockFeat.beforeLock("resource1", "owner1", null).get()); + + } + + + @Test + public void testUnlock() throws InterruptedException, ExecutionException { + distLockFeat.beforeLock("resource1", "owner1", null); + + assertTrue(distLockFeat.beforeUnlock("resource1", "owner1")); + assertTrue(distLockFeat.beforeLock("resource1", "owner1", null).get()); + } + + @Test + public void testIsActive() { + assertFalse(distLockFeat.beforeIsLockedBy("resource1", "owner1")); + distLockFeat.beforeLock("resource1", "owner1", null); + assertTrue(distLockFeat.beforeIsLockedBy("resource1", "owner1")); + assertFalse(distLockFeat.beforeIsLockedBy("resource1", "owner2")); + + // isActive on expiredLock + try (PreparedStatement updateStatement = conn + .prepareStatement("UPDATE pooling.locks SET expirationTime = ? WHERE resourceId = ?");) { + updateStatement.setLong(1, System.currentTimeMillis() - 5000); + updateStatement.setString(2, "resource1"); + updateStatement.executeUpdate(); + + } catch (SQLException e) { + logger.error("Error in TargetLockTest.testIsActive()", e); + throw new RuntimeException(e); + } + + assertFalse(distLockFeat.beforeIsLockedBy("resource1", "owner1")); + + distLockFeat.beforeLock("resource1", "owner1", null); + //Unlock record, next isActive attempt should fail + distLockFeat.beforeUnlock("resource1", "owner1"); + assertFalse(distLockFeat.beforeIsLockedBy("resource1", "owner1")); + + } + + @Test + public void testHeartbeat() { + + CountDownLatch rowExpireLatch = new CountDownLatch(1); + CountDownLatch heartbeatLatch = new CountDownLatch(1); + + //grab lock + distLockFeat.beforeLock("resource1", "owner1", null); + + //Wait for lock to expire + try { + rowExpireLatch.await(150, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + logger.error("Error in testExpiredLocks", e); + } + + //Grab reference to heartbeat object + Heartbeat heartbeat = distLockFeat.getHeartbeat(); + + //Pass heartbeat object countdown latch + try { + heartbeat.giveLatch(heartbeatLatch); + heartbeatLatch.await(5, TimeUnit.SECONDS); + } catch (InterruptedException e) { + logger.error("Error in testExpiredLocks", e); + } + //At this point the heartbeat object should hve + //refreshed the lock. assert that resource1 is + //locked + assertTrue(distLockFeat.beforeIsLocked("resource1")); + } + + @Test + public void unlockBeforeLock() { + assertFalse(distLockFeat.beforeUnlock("resource1", "owner1")); + distLockFeat.beforeLock("resource1", "owner1", null); + assertTrue(distLockFeat.beforeUnlock("resource1", "owner1")); + assertFalse(distLockFeat.beforeUnlock("resource1", "owner1")); + } + + @Test + public void testIsLocked() { + assertFalse(distLockFeat.beforeIsLocked("resource1")); + distLockFeat.beforeLock("resource1", "owner1", null); + assertTrue(distLockFeat.beforeIsLocked("resource1")); + + } + + private static void getDBConnection() { + try { + conn = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD); + } catch (SQLException e) { + logger.error("Error in TargetLockTest.getDBConnection()", e); + } + } + + private static void createTable() { + String createString = "create table if not exists pooling.locks (resourceId VARCHAR(128), host VARCHAR(128), owner VARCHAR(128), expirationTime BIGINT, PRIMARY KEY (resourceId))"; + try (PreparedStatement createStmt = conn.prepareStatement(createString);) { + createStmt.executeUpdate(); + + } catch (SQLException e) { + logger.error("Error in TargetLockTest.createTable()", e); + } + } + + +} diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/test/DistributedLockingFeatureExceptionTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/test/DistributedLockingFeatureExceptionTest.java deleted file mode 100644 index ea53e522..00000000 --- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/test/DistributedLockingFeatureExceptionTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * feature-distributed-locking - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distributed.locking.test; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.common.utils.test.ExceptionsTester; -import org.onap.policy.distributed.locking.DistributedLockingFeatureException; - -public class DistributedLockingFeatureExceptionTest extends ExceptionsTester{ - - @Test - public void test() { - assertEquals(1, test(DistributedLockingFeatureException.class)); - } - -} diff --git a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/test/TargetLockTest.java b/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/test/TargetLockTest.java deleted file mode 100644 index e624afb9..00000000 --- a/feature-distributed-locking/src/test/java/org/onap/policy/distributed/locking/test/TargetLockTest.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * feature-distributed-locking - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.distributed.locking.test; - -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.distributed.locking.DistributedLockingFeature; -import org.onap.policy.drools.persistence.SystemPersistence; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; - -public class TargetLockTest { - private static final Logger logger = LoggerFactory.getLogger(TargetLockTest.class); - private static final String DB_CONNECTION = "jdbc:h2:mem:pooling;INIT=CREATE SCHEMA IF NOT EXISTS pooling\\;SET SCHEMA pooling"; - private static final String DB_USER = "user"; - private static final String DB_PASSWORD = "password"; - private static Connection conn = null; - private static DistributedLockingFeature distLockFeat; - - @BeforeClass - public static void setup() { - getDBConnection(); - createTable(); - SystemPersistence.manager.setConfigurationDir("src/test/resources"); - distLockFeat = new DistributedLockingFeature(); - distLockFeat.afterStart(null); - - } - - @AfterClass - public static void cleanUp() { - distLockFeat.beforeShutdown(null); - try { - conn.close(); - } catch (SQLException e) { - logger.error("Error in TargetLockTest.cleanUp()", e); - } - } - - @Before - public void wipeDb() { - - try (PreparedStatement lockDelete = conn.prepareStatement("DELETE FROM pooling.locks");){ - lockDelete.executeUpdate(); - } catch (SQLException e) { - logger.error("Error in TargetLockTest.wipeDb()", e); - throw new RuntimeException(e); - } - - } - - @Test - public void testGrabLockSuccess() throws InterruptedException, ExecutionException { - assertTrue(distLockFeat.beforeLock("resource1", "owner1", null).get()); - - //attempt to grab expiredLock - try (PreparedStatement updateStatement = conn.prepareStatement("UPDATE pooling.locks SET expirationTime = ? WHERE resourceId = ?");) - { - updateStatement.setLong(1, System.currentTimeMillis() - 1000); - updateStatement.setString(2, "resource1"); - updateStatement.executeUpdate(); - - } catch (SQLException e) { - logger.error("Error in TargetLockTest.testGrabLockSuccess()", e); - throw new RuntimeException(e); - } - - assertTrue(distLockFeat.beforeLock("resource1", "owner1", null).get()); - } - - @Test - public void testExpiredLocks() throws InterruptedException, ExecutionException { - CountDownLatch latch = new CountDownLatch(1); - - distLockFeat.beforeLock("resource1", "owner1", null); - - try { - latch.await(1000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.error("Error in testExpiredLocks", e); - } - - //Heartbeat should keep it active - assertFalse(distLockFeat.beforeLock("resource1", "owner1", null).get()); - } - - @Test - public void testGrabLockFail() throws InterruptedException, ExecutionException { - CountDownLatch latch = new CountDownLatch(1); - - distLockFeat.beforeLock("resource1", "owner1", null); - - try { - latch.await(10, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.error("Error in testExpiredLocks", e); - } - assertFalse(distLockFeat.beforeLock("resource1", "owner1", null).get()); - - } - - - @Test - public void testUnlock() throws InterruptedException, ExecutionException { - distLockFeat.beforeLock("resource1", "owner1", null); - - assertTrue(distLockFeat.beforeUnlock("resource1", "owner1")); - assertTrue(distLockFeat.beforeLock("resource1", "owner1", null).get()); - } - - @Test - public void testIsActive() { - assertFalse(distLockFeat.beforeIsLockedBy("resource1", "owner1")); - distLockFeat.beforeLock("resource1", "owner1", null); - assertTrue(distLockFeat.beforeIsLockedBy("resource1", "owner1")); - assertFalse(distLockFeat.beforeIsLockedBy("resource1", "owner2")); - - // isActive on expiredLock - try (PreparedStatement updateStatement = conn - .prepareStatement("UPDATE pooling.locks SET expirationTime = ? WHERE resourceId = ?");) { - updateStatement.setLong(1, System.currentTimeMillis() - 5000); - updateStatement.setString(2, "resource1"); - updateStatement.executeUpdate(); - - } catch (SQLException e) { - logger.error("Error in TargetLockTest.testIsActive()", e); - throw new RuntimeException(e); - } - - assertFalse(distLockFeat.beforeIsLockedBy("resource1", "owner1")); - - distLockFeat.beforeLock("resource1", "owner1", null); - //Unlock record, next isActive attempt should fail - distLockFeat.beforeUnlock("resource1", "owner1"); - assertFalse(distLockFeat.beforeIsLockedBy("resource1", "owner1")); - - } - - @Test - public void testHeartbeat() { - CountDownLatch latch = new CountDownLatch(1); - - distLockFeat.beforeLock("resource1", "owner1", null); - try { - latch.await(1000, TimeUnit.MILLISECONDS); - } catch (InterruptedException e) { - logger.error("Error in testExpiredLocks", e); - } - - // This test always returns true. - assertTrue(distLockFeat.beforeIsLocked("resource1")); - } - - @Test - public void unlockBeforeLock() { - assertFalse(distLockFeat.beforeUnlock("resource1", "owner1")); - distLockFeat.beforeLock("resource1", "owner1", null); - assertTrue(distLockFeat.beforeUnlock("resource1", "owner1")); - assertFalse(distLockFeat.beforeUnlock("resource1", "owner1")); - } - - @Test - public void testIsLocked() { - assertFalse(distLockFeat.beforeIsLocked("resource1")); - distLockFeat.beforeLock("resource1", "owner1", null); - assertTrue(distLockFeat.beforeIsLocked("resource1")); - - } - - private static void getDBConnection() { - try { - conn = DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD); - } catch (SQLException e) { - logger.error("Error in TargetLockTest.getDBConnection()", e); - } - } - - private static void createTable() { - String createString = "create table if not exists pooling.locks (resourceId VARCHAR(128), host VARCHAR(128), owner VARCHAR(128), expirationTime BIGINT, PRIMARY KEY (resourceId))"; - try (PreparedStatement createStmt = conn.prepareStatement(createString);) { - createStmt.executeUpdate(); - - } catch (SQLException e) { - logger.error("Error in TargetLockTest.createTable()", e); - } - } - - -} -- cgit 1.2.3-korg