-
Notifications
You must be signed in to change notification settings - Fork 324
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
Add OL facet tables #2152
Add OL facet tables #2152
Changes from all commits
c3f9566
8a7b246
1bee933
046510e
1ea7c0b
2e9ea61
ffff23c
a52e9a1
2c017a5
1ba2603
879da87
e48849a
66eda9e
22141f4
ec66136
6f02f60
f6039c6
5b565d7
34d9a5a
fc1754b
ad0fa19
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
import marquez.api.filter.JobRedirectFilter; | ||
import marquez.cli.MetadataCommand; | ||
import marquez.cli.SeedCommand; | ||
import marquez.cli.V55MigrationCommand; | ||
import marquez.common.Utils; | ||
import marquez.db.DbMigration; | ||
import marquez.logging.LoggingMdcFilter; | ||
|
@@ -149,6 +150,12 @@ public void registerResources( | |
} | ||
} | ||
|
||
@Override | ||
protected void addDefaultCommands(Bootstrap<MarquezConfig> bootstrap) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To avoid overriding @Override
public void initialize(@NonNull Bootstrap<MarquezConfig> bootstrap) {
bootstrap.addCommand(new V55MigrationCommand());
// continue initialization ...
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing commands are kind of no-arg commands. Migration commands needs to be able to access database connection. That's why I included it here so that it can get |
||
bootstrap.addCommand(new V55MigrationCommand(this)); | ||
super.addDefaultCommands(bootstrap); | ||
} | ||
|
||
private MarquezContext buildMarquezContext( | ||
MarquezConfig config, Environment env, ManagedDataSource source) { | ||
final JdbiFactory factory = new JdbiFactory(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright 2018-2022 contributors to the Marquez project | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package marquez.cli; | ||
|
||
import io.dropwizard.Application; | ||
import io.dropwizard.cli.EnvironmentCommand; | ||
import io.dropwizard.db.DataSourceFactory; | ||
import io.dropwizard.db.ManagedDataSource; | ||
import io.dropwizard.jdbi3.JdbiFactory; | ||
import io.dropwizard.setup.Environment; | ||
import javax.sql.DataSource; | ||
import lombok.extern.slf4j.Slf4j; | ||
import marquez.db.migrations.V55_5__BackfillFacets; | ||
import net.sourceforge.argparse4j.inf.Namespace; | ||
import net.sourceforge.argparse4j.inf.Subparser; | ||
import org.jdbi.v3.core.Jdbi; | ||
import org.jdbi.v3.jackson2.Jackson2Plugin; | ||
import org.jdbi.v3.postgres.PostgresPlugin; | ||
import org.jdbi.v3.sqlobject.SqlObjectPlugin; | ||
|
||
/** | ||
* A command to manually run V55 database migration. This migration requires a heavy DB operation | ||
* which can be done asynchronously (with limited API downtime) due to separate migration command. | ||
* | ||
* <p>Please refer to @link marquez/db/migration/V55__readme.md for more details. | ||
*/ | ||
@Slf4j | ||
public class V55MigrationCommand<MarquezConfig> extends EnvironmentCommand<marquez.MarquezConfig> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is |
||
|
||
private static final String COMMAND_NAME = "v55_migrate"; | ||
private static final String COMMAND_DESCRIPTION = | ||
""" | ||
A command to manually run V55 database migration. | ||
Please refer to https://github.com/MarquezProject/marquez/blob/main/api/src/main/resources/marquez/db/migration/V55__readme.md for more details. | ||
"""; | ||
|
||
/** | ||
* Creates a new environment command. | ||
* | ||
* @param application the application providing this command | ||
*/ | ||
public V55MigrationCommand(Application<marquez.MarquezConfig> application) { | ||
super(application, COMMAND_NAME, COMMAND_DESCRIPTION); | ||
} | ||
|
||
@Override | ||
public void configure(Subparser subparser) { | ||
subparser | ||
.addArgument("--chunkSize") | ||
.dest("chunkSize") | ||
.type(Integer.class) | ||
.required(false) | ||
.setDefault(V55_5__BackfillFacets.DEFAULT_CHUNK_SIZE) | ||
.help("amount of lineage_events rows processed in a single SQL query and transaction."); | ||
addFileArgument(subparser); | ||
} | ||
|
||
@Override | ||
protected void run( | ||
Environment environment, Namespace namespace, marquez.MarquezConfig configuration) | ||
throws Exception { | ||
log.info("Running v55 migration command"); | ||
|
||
final DataSourceFactory sourceFactory = configuration.getDataSourceFactory(); | ||
final DataSource source = sourceFactory.build(environment.metrics(), "MarquezApp-source"); | ||
|
||
final JdbiFactory factory = new JdbiFactory(); | ||
final Jdbi jdbi = | ||
factory | ||
.build( | ||
environment, | ||
configuration.getDataSourceFactory(), | ||
(ManagedDataSource) source, | ||
"postgresql-command") | ||
.installPlugin(new SqlObjectPlugin()) | ||
.installPlugin(new PostgresPlugin()) | ||
.installPlugin(new Jackson2Plugin()); | ||
|
||
V55_5__BackfillFacets migration = new V55_5__BackfillFacets(); | ||
migration.setTriggeredByCommand(true); | ||
migration.setJdbi(jdbi); | ||
migration.setChunkSize(namespace.getInt("chunkSize")); | ||
migration.migrate(null); | ||
|
||
log.info("Migration finished successfully"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: I would reword as follows:
Note: We highly encourage users to review our migration plan.