Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,24 @@
import java.nio.file.Path;
import org.apache.polaris.core.config.ProductionReadinessCheck;
import org.apache.polaris.core.config.ProductionReadinessCheck.Error;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@ApplicationScoped
public class EclipseLinkProductionReadinessChecks {

private static final Logger LOGGER =
LoggerFactory.getLogger(EclipseLinkProductionReadinessChecks.class);

@Produces
public ProductionReadinessCheck checkJdbcUrl(EclipseLinkConfiguration eclipseLinkConfiguration) {
public ProductionReadinessCheck checkEclipseLink(
MetaStoreManagerFactory metaStoreManagerFactory,
EclipseLinkConfiguration eclipseLinkConfiguration) {
// This check should only be applicable when persistence uses EclipseLink.
if (!(metaStoreManagerFactory instanceof EclipseLinkPolarisMetaStoreManagerFactory)) {
return ProductionReadinessCheck.OK;
}

try {
var confFile = eclipseLinkConfiguration.configurationFile().map(Path::toString).orElse(null);
var persistenceUnitName =
Expand Down
1 change: 0 additions & 1 deletion extension/persistence/relational-jdbc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ dependencies {
implementation(libs.smallrye.common.annotation) // @Identifier

testImplementation(libs.mockito.junit.jupiter)

testImplementation(libs.h2)
testImplementation(testFixtures(project(":polaris-core")))
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,19 @@ private void initializeForRealm(
metaStoreManagerMap.put(realmContext.getRealmIdentifier(), metaStoreManager);
}

protected DatabaseType getDatabaseType() throws SQLException {
try (Connection connection = dataSource.get().getConnection()) {
String productName = connection.getMetaData().getDatabaseProductName();
return DatabaseType.fromDisplayName(productName);
}
}

private DatasourceOperations getDatasourceOperations(boolean isBootstrap) {
DatasourceOperations databaseOperations =
new DatasourceOperations(dataSource.get(), relationalJdbcConfiguration);
if (isBootstrap) {
try {
DatabaseType databaseType;
try (Connection connection = dataSource.get().getConnection()) {
String productName = connection.getMetaData().getDatabaseProductName();
databaseType = DatabaseType.fromDisplayName(productName);
}
DatabaseType databaseType = getDatabaseType();
databaseOperations.executeScript(
String.format("%s/schema-v1.sql", databaseType.getDisplayName()));
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/

package org.apache.polaris.extension.persistence.relational.jdbc;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import java.sql.SQLException;
import org.apache.polaris.core.config.ProductionReadinessCheck;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;

@ApplicationScoped
public class RelationalJdbcProductionReadinessChecks {
@Produces
public ProductionReadinessCheck checkRelationalJdbc(
MetaStoreManagerFactory metaStoreManagerFactory) {
// This check should only be applicable when persistence uses RelationalJdbc.
if (!(metaStoreManagerFactory
instanceof JdbcMetaStoreManagerFactory jdbcMetaStoreManagerFactory)) {
return ProductionReadinessCheck.OK;
}

try {
if (jdbcMetaStoreManagerFactory.getDatabaseType().equals(DatabaseType.H2)) {
return ProductionReadinessCheck.of(
ProductionReadinessCheck.Error.of(
"The current persistence (jdbc:h2) is intended for tests only.",
"quarkus.datasource.jdbc.url"));
}
} catch (SQLException e) {
return ProductionReadinessCheck.of(
ProductionReadinessCheck.Error.of(
"Misconfigured JDBC datasource", "quarkus.datasource.jdbc.url"));
}
return ProductionReadinessCheck.OK;
}
}