-
Notifications
You must be signed in to change notification settings - Fork 469
Introduce DataSourceResolver for multi-datasource support in JDBC per… #3960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Subham-KRLX
wants to merge
17
commits into
apache:main
from
Subham-KRLX:feat/multi-datasource-support
+1,284
−108
Closed
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
136e381
Introduce DataSourceResolver for multi-datasource support in JDBC per…
Subham-KRLX 207aa4c
Address review comments on DataSourceResolver PR
Subham-KRLX e024bea
Final review nits on DataSourceResolver PR
Subham-KRLX 96e7ff0
Address final nit: use import for RealmContext
Subham-KRLX 9a07e6e
Final formatting and naming consistency cleanup
Subham-KRLX 75e4096
Fix InactiveBeanException in non-JDBC profiles via lazy DataSource re…
Subham-KRLX fccb254
Address review comments: tighten scope, use plain injection and @Defa…
Subham-KRLX 9c22635
Address review comments: tighten scope, use @Identifier and producer …
Subham-KRLX 1e00328
Address final nits: Rename identifier to default and move config to J…
Subham-KRLX 493c386
Refine DataSourceResolver configuration wiring per review
Subham-KRLX 6311fbe
Address final CDI producer wiring nits
Subham-KRLX a36e745
Reinstate StoreType, update config docs, and finalize CDI wiring
Subham-KRLX 118e046
Address review feedback: Resolve separate DataSources for METASTORE, …
Subham-KRLX dc8ffda
Address further review feedback: Revert unrelated changes, move CDI p…
Subham-KRLX 7eb2304
Finalize PR #3960: split v4 DDL, fix license headers, and move CDI pr…
Subham-KRLX 7ceaa69
Introduce DataSourceResolver for multi-datasource support in JDBC per…
Subham-KRLX 9df42be
Refine Multi-DataSource support: selective bootstrap, independent ver…
Subham-KRLX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/DataSourceResolver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * 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.persistence.relational.jdbc; | ||
|
|
||
| import javax.sql.DataSource; | ||
| import org.apache.polaris.core.context.RealmContext; | ||
|
|
||
| /** | ||
| * Service to resolve the correct {@link DataSource} for a given realm and store type. This enables | ||
| * isolating different workloads (e.g., entity metadata vs metrics vs events) into different | ||
| * physical databases or connection pools. | ||
| */ | ||
| public interface DataSourceResolver { | ||
|
|
||
|
Subham-KRLX marked this conversation as resolved.
|
||
| /** The type of store representing the workload pattern. */ | ||
| enum StoreType { | ||
| METASTORE, | ||
| METRICS, | ||
| EVENTS | ||
| } | ||
|
|
||
| /** | ||
| * Resolves the DataSource for a given realm and store type. | ||
| * | ||
| * @param realmContext the realm context | ||
| * @param storeType the type of store (e.g., main, metrics, events) | ||
| * @return the resolved DataSource | ||
| */ | ||
| DataSource resolve(RealmContext realmContext, StoreType storeType); | ||
|
Subham-KRLX marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...rc/main/java/org/apache/polaris/quarkus/common/config/jdbc/DefaultDataSourceResolver.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * 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.quarkus.common.config.jdbc; | ||
|
|
||
| import jakarta.enterprise.context.ApplicationScoped; | ||
| import jakarta.enterprise.inject.Instance; | ||
| import jakarta.inject.Inject; | ||
| import javax.sql.DataSource; | ||
| import org.apache.polaris.core.context.RealmContext; | ||
| import org.apache.polaris.persistence.relational.jdbc.DataSourceResolver; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| /** | ||
| * Default implementation of {@link DataSourceResolver} that routes all realms and store types to a | ||
| * single default {@link DataSource}. This serves as both the production default and the base for | ||
| * multi-datasource extensions. | ||
| */ | ||
| @ApplicationScoped | ||
| public class DefaultDataSourceResolver implements DataSourceResolver { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(DefaultDataSourceResolver.class); | ||
|
|
||
| private final Instance<DataSource> defaultDataSource; | ||
|
|
||
| @Inject | ||
| public DefaultDataSourceResolver(Instance<DataSource> defaultDataSource) { | ||
| this.defaultDataSource = defaultDataSource; | ||
| } | ||
|
|
||
| @Override | ||
| public DataSource resolve(RealmContext realmContext, StoreType storeType) { | ||
| LOGGER.debug( | ||
| "Using default DataSource for realm '{}' and store '{}'", | ||
| realmContext.getRealmIdentifier(), | ||
| storeType); | ||
| return defaultDataSource.get(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.