Skip to content

Commit

Permalink
Renamed RdbUtils; import cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred Baedke committed Jan 13, 2025
1 parent d01833c commit c8d50fa
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import javax.jcr.RepositoryException;

import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.document.RdbUtils;
import org.apache.jackrabbit.oak.plugins.document.RdbConnectionUtils;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentNodeStoreBuilder;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBOptions;
Expand All @@ -35,7 +35,7 @@
*/
public class OakDocumentRDBRepositoryStub extends BaseRepositoryStub {

private static final String jdbcUrl = RdbUtils.mapJdbcURL();
private static final String jdbcUrl = RdbConnectionUtils.mapJdbcURL();

private final Repository repository;

Expand All @@ -57,7 +57,7 @@ public OakDocumentRDBRepositoryStub(Properties settings) throws RepositoryExcept
m = new RDBDocumentNodeStoreBuilder().
memoryCacheSize(64 * 1024 * 1024).
setPersistentCache("target/persistentCache,time").
setRDBConnection(RDBDataSourceFactory.forJdbcUrl(jdbcUrl, RdbUtils.USERNAME, RdbUtils.PASSWD), options).
setRDBConnection(RDBDataSourceFactory.forJdbcUrl(jdbcUrl, RdbConnectionUtils.USERNAME, RdbConnectionUtils.PASSWD), options).
build();
Jcr jcr = new Jcr(m);
preCreateRepository(jcr);
Expand All @@ -76,7 +76,7 @@ public void run() {

public static boolean isAvailable() {
try {
Connection c = DriverManager.getConnection(jdbcUrl, RdbUtils.USERNAME, RdbUtils.PASSWD);
Connection c = DriverManager.getConnection(jdbcUrl, RdbConnectionUtils.USERNAME, RdbConnectionUtils.PASSWD);
c.close();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
package org.apache.jackrabbit.oak.fixture;

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Objects;
Expand All @@ -29,7 +28,7 @@
import javax.sql.DataSource;

import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.document.RdbUtils;
import org.apache.jackrabbit.oak.plugins.document.RdbConnectionUtils;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDocumentNodeStoreBuilder;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBOptions;
Expand All @@ -41,13 +40,13 @@ public class DocumentRdbFixture extends NodeStoreFixture {

private final Map<NodeStore, DataSource> dataSources = new ConcurrentHashMap<NodeStore, DataSource>();

private static final String jdbcUrl = RdbUtils.mapJdbcURL();
private static final String jdbcUrl = RdbConnectionUtils.mapJdbcURL();

@Override
public NodeStore createNodeStore() {
String prefix = "T" + Long.toHexString(System.currentTimeMillis());
RDBOptions options = new RDBOptions().tablePrefix(prefix).dropTablesOnClose(true);
DataSource ds = RDBDataSourceFactory.forJdbcUrl(jdbcUrl, RdbUtils.USERNAME, RdbUtils.PASSWD);
DataSource ds = RDBDataSourceFactory.forJdbcUrl(jdbcUrl, RdbConnectionUtils.USERNAME, RdbConnectionUtils.PASSWD);
//do not reuse the whiteboard
setWhiteboard(new DefaultWhiteboard());
RDBDocumentNodeStoreBuilder builder = new RDBDocumentNodeStoreBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static void checkRDBAvailable() {

@Before
public void setUpConnection() throws Exception {
dataSource = RDBDataSourceFactory.forJdbcUrl(RdbUtils.mapJdbcURL(), USERNAME, PASSWD);
dataSource = RDBDataSourceFactory.forJdbcUrl(RdbConnectionUtils.mapJdbcURL(), USERNAME, PASSWD);
Revision.setClock(getTestClock());
mk = new DocumentMK(newBuilder(dataSource).build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CacheConsistencyRDBTest extends AbstractRDBConnectionTest {
@Before
@Override
public void setUpConnection() throws Exception {
dataSource = RDBDataSourceFactory.forJdbcUrl(RdbUtils.mapJdbcURL(), USERNAME, PASSWD);
dataSource = RDBDataSourceFactory.forJdbcUrl(RdbConnectionUtils.mapJdbcURL(), USERNAME, PASSWD);
DocumentMK.Builder builder = new DocumentMK.Builder().clock(getTestClock()).setAsyncDelay(0);
RDBOptions opt = new RDBOptions().tablePrefix("T" + Long.toHexString(System.currentTimeMillis())).dropTablesOnClose(true);
store = new TestStore(dataSource, builder, opt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@
*/
package org.apache.jackrabbit.oak.plugins.document;

import com.github.dockerjava.api.DockerClient;
import org.apache.jackrabbit.guava.common.base.Strings;
import org.apache.jackrabbit.oak.plugins.document.rdb.RDBDataSourceFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.DockerClientFactory;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.startupcheck.StartupCheckStrategy;
import org.testcontainers.images.RemoteDockerImage;
import org.testcontainers.utility.DockerImageName;

Expand All @@ -38,9 +36,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RdbUtils {
public class RdbConnectionUtils {

private static final Logger LOG = LoggerFactory.getLogger(RdbUtils.class);
private static final Logger LOG = LoggerFactory.getLogger(RdbConnectionUtils.class);

public static final String URL = System.getProperty("rdb.jdbc-url", "jdbc:h2:file:./{fname}oaktest;DB_CLOSE_ON_EXIT=FALSE");
public static final String USERNAME = System.getProperty("rdb.jdbc-user", "sa");
Expand Down Expand Up @@ -76,15 +74,15 @@ public class RdbUtils {
long startTime = Instant.now().toEpochMilli();
rdbContainer.start();
LOG.info("RDB container started in: " + (Instant.now().toEpochMilli() - startTime) + " ms");
String url = RdbUtils.mapJdbcURL();
String url = RdbConnectionUtils.mapJdbcURL();
LOG.info("Mapped JDBC URL is {}.", url);
boolean containerReady = false;
LOG.info("Trying to connect to {}", url);
for (int k = 0; k < 30 && !containerReady; k++) {
Thread.sleep(10000);
Connection connection = null;
try {
DataSource dataSource = RDBDataSourceFactory.forJdbcUrl(url, RdbUtils.USERNAME, RdbUtils.PASSWD);
DataSource dataSource = RDBDataSourceFactory.forJdbcUrl(url, RdbConnectionUtils.USERNAME, RdbConnectionUtils.PASSWD);
connection = dataSource.getConnection();
containerReady = true;
} catch (SQLException expected) {
Expand Down

0 comments on commit c8d50fa

Please sign in to comment.