@Test public void testActivateWithoutAllTablesCausesIllegalStateException() { mySession.execute(String.format("DROP TABLE %s.%s", myKeyspaceName, TABLE_LOCK)); assertThatExceptionOfType(IllegalStateException.class) .isThrownBy(() -> new CASLockFactory.Builder() .withNativeConnectionProvider(getNativeConnectionProvider()) .withHostStates(hostStates) .withStatementDecorator(s -> s) .withKeyspaceName(myKeyspaceName) .build()); mySession.execute(String.format("CREATE TABLE IF NOT EXISTS %s.%s (resource text, node uuid, metadata map<text,text>, PRIMARY KEY(resource)) WITH default_time_to_live = 600 AND gc_grace_seconds = 0", myKeyspaceName, TABLE_LOCK)); }
private ResultSet execute(String dataCenter, Statement statement) { Statement executeStatement; if (dataCenter != null) { executeStatement = new DataCenterAwareStatement(statement, dataCenter); } else { executeStatement = statement; } return mySession.execute(myStatementDecorator.apply(executeStatement)); }
CASLockFactory implements LockFactory, Closeable { private ResultSet execute(String dataCenter, Statement statement) { Statement executeStatement; if (dataCenter != null) { executeStatement = new DataCenterAwareStatement(statement, dataCenter); } else { executeStatement = statement; } return mySession.execute(myStatementDecorator.apply(executeStatement)); } }
CASLockFactory implements LockFactory, Closeable { private ResultSet execute(String dataCenter, Statement statement) { Statement executeStatement; if (dataCenter != null) { executeStatement = new DataCenterAwareStatement(statement, dataCenter); } else { executeStatement = statement; } return mySession.execute(myStatementDecorator.apply(executeStatement)); } private  CASLockFactory(Builder builder); }
CASLockFactory implements LockFactory, Closeable { private ResultSet execute(String dataCenter, Statement statement) { Statement executeStatement; if (dataCenter != null) { executeStatement = new DataCenterAwareStatement(statement, dataCenter); } else { executeStatement = statement; } return mySession.execute(myStatementDecorator.apply(executeStatement)); } private  CASLockFactory(Builder builder); @Override DistributedLock tryLock(String dataCenter, String resource, int priority, Map<String, String> metadata); @Override Map<String, String> getLockMetadata(String dataCenter, String resource); @Override boolean sufficientNodesForLocking(String dataCenter, String resource); @Override Optional<LockException> getCachedFailure(String dataCenter, String resource); @Override void close(); static Builder builder(); }
CASLockFactory implements LockFactory, Closeable { private ResultSet execute(String dataCenter, Statement statement) { Statement executeStatement; if (dataCenter != null) { executeStatement = new DataCenterAwareStatement(statement, dataCenter); } else { executeStatement = statement; } return mySession.execute(myStatementDecorator.apply(executeStatement)); } private  CASLockFactory(Builder builder); @Override DistributedLock tryLock(String dataCenter, String resource, int priority, Map<String, String> metadata); @Override Map<String, String> getLockMetadata(String dataCenter, String resource); @Override boolean sufficientNodesForLocking(String dataCenter, String resource); @Override Optional<LockException> getCachedFailure(String dataCenter, String resource); @Override void close(); static Builder builder();  }