-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-11465. Introducing Schema Versioning for Recon to Handle Fresh Installs and Upgrades. #7213
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
2573e03
HDDS-11465. Introducing Schema Versioning for Recon Derby table to Ha…
ArafatKhan2198 3e64282
Covered a few edge cases of upgrades and fresh install
ArafatKhan2198 a4895e0
Made changes for latest discussion
ArafatKhan2198 3128cd9
Removed the old changes
ArafatKhan2198 a57f922
New things
ArafatKhan2198 b80f014
New changes
ArafatKhan2198 ea5946d
Fixed a bug
ArafatKhan2198 27f1538
Finalised the new approach
ArafatKhan2198 e4b4b27
Added log comments for testing
ArafatKhan2198 262a93d
Added an initial version to Feature enum
ArafatKhan2198 929d453
Added tests for ReconLayoutVersionManager
ArafatKhan2198 bf68424
Added more tests for Table definition
ArafatKhan2198 855ad92
Added missing licence certs
ArafatKhan2198 6ea93a9
TestCase updation
ArafatKhan2198 d95a1a7
Replaced the occurance of Schema Layout Version to Software Layout Ve…
ArafatKhan2198 29fe85b
Refactored Recon layout feature upgrade framework to support annotati…
ArafatKhan2198 287cafa
Added a new test case
ArafatKhan2198 81e62f0
Made final changes
ArafatKhan2198 0afebff
Final changes for review
ArafatKhan2198 c538a78
Removed the occurance of AUTO_FINALIZE in comments and made changes t…
ArafatKhan2198 4127ab5
Updated recon context for failed upgrades and made other review changes
ArafatKhan2198 3609b74
Fixed the error handling review comments
ArafatKhan2198 defd313
Fixed a failing uT
ArafatKhan2198 f75c952
Fixed stack strace problem
ArafatKhan2198 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
There are no files selected for viewing
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
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
53 changes: 53 additions & 0 deletions
53
...con-codegen/src/main/java/org/hadoop/ozone/recon/schema/SchemaVersionTableDefinition.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,53 @@ | ||
| package org.hadoop.ozone.recon.schema; | ||
|
|
||
| import com.google.inject.Inject; | ||
| import com.google.inject.Singleton; | ||
| import org.jooq.DSLContext; | ||
| import org.jooq.impl.DSL; | ||
| import org.jooq.impl.SQLDataType; | ||
| import static org.hadoop.ozone.recon.codegen.SqlDbUtils.TABLE_EXISTS_CHECK; | ||
|
|
||
| import javax.sql.DataSource; | ||
| import java.sql.Connection; | ||
| import java.sql.SQLException; | ||
|
|
||
| /** | ||
| * Class for managing the schema of the SchemaVersion table. | ||
| */ | ||
| @Singleton | ||
| public class SchemaVersionTableDefinition implements ReconSchemaDefinition { | ||
|
|
||
| public static final String SCHEMA_VERSION_TABLE_NAME = "RECON_SCHEMA_VERSION"; | ||
ArafatKhan2198 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private final DataSource dataSource; | ||
| private DSLContext dslContext; | ||
|
|
||
| @Inject | ||
| public SchemaVersionTableDefinition(DataSource dataSource) { | ||
| this.dataSource = dataSource; | ||
| } | ||
|
|
||
| @Override | ||
| public void initializeSchema() throws SQLException { | ||
| Connection conn = dataSource.getConnection(); | ||
| dslContext = DSL.using(conn); | ||
|
|
||
| if (!TABLE_EXISTS_CHECK.test(conn, SCHEMA_VERSION_TABLE_NAME)) { | ||
| createSchemaVersionTable(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void upgradeSchema(String fromVersion, String toVersion) throws SQLException { | ||
| // No schema upgrades needed for the Schema Version table. | ||
| } | ||
|
|
||
| /** | ||
| * Create the Schema Version table. | ||
| */ | ||
| private void createSchemaVersionTable() throws SQLException { | ||
| dslContext.createTableIfNotExists(SCHEMA_VERSION_TABLE_NAME) | ||
| .column("version_number", SQLDataType.VARCHAR(10).nullable(false)) | ||
| .column("applied_on", SQLDataType.TIMESTAMP.defaultValue(DSL.currentTimestamp())) | ||
| .execute(); | ||
| } | ||
| } | ||
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
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
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.