Skip to content
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

Bmoric/extract logs api #18621

Merged
merged 50 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4ebf4ec
Tmp
benmoriceau Oct 21, 2022
6d8e907
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Oct 24, 2022
d930c98
Extract the Attempt API from the V1 API
benmoriceau Oct 24, 2022
2dba567
Add comments
benmoriceau Oct 24, 2022
7c36975
Move Connection API out of configuration API
benmoriceau Oct 24, 2022
0d87509
format
benmoriceau Oct 24, 2022
cf61847
Merge branch 'bmoric/convert-server-to-micronaut' of github.com:airby…
benmoriceau Oct 24, 2022
04e9bb2
format
benmoriceau Oct 24, 2022
c74db48
Rename to Controller
benmoriceau Oct 25, 2022
433dfe5
Merge branch 'bmoric/convert-server-to-micronaut' of github.com:airby…
benmoriceau Oct 25, 2022
415e0c7
Rename to Controller
benmoriceau Oct 25, 2022
7211da6
Add values to the factory
benmoriceau Oct 25, 2022
f503b4c
Change the constructor to use hadler instead of objects needed by the…
benmoriceau Oct 25, 2022
70ce157
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Oct 25, 2022
688f812
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Oct 25, 2022
2103e7d
Update with new tags.
benmoriceau Oct 25, 2022
a5c8522
tmp
benmoriceau Oct 25, 2022
c5aee8f
Fix PMD errors
benmoriceau Oct 25, 2022
50fc3ae
Extract DB migrator
benmoriceau Oct 25, 2022
6b11154
Merge branch 'bmoric/extract-connection-api' of github.com:airbytehq/…
benmoriceau Oct 25, 2022
4e8051e
Add something that I forgot
benmoriceau Oct 26, 2022
99d9d4b
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Oct 26, 2022
aca18c9
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Oct 26, 2022
7254ebb
extract destination definition api
benmoriceau Oct 26, 2022
4d748af
restore destination factory initialization
benmoriceau Oct 26, 2022
e6a56a2
extract destination definition specification api
benmoriceau Oct 26, 2022
709cdc4
format
benmoriceau Oct 26, 2022
aa06c20
Merge branch 'bmoric/extract-db-migration-api' of github.com:airbyteh…
benmoriceau Oct 26, 2022
82360dc
format
benmoriceau Oct 26, 2022
82ccd82
Merge branch 'bmoric/extract-destination-definition-api' of github.co…
benmoriceau Oct 26, 2022
6ecdb17
format
benmoriceau Oct 26, 2022
187c9ea
extract health check api
benmoriceau Oct 26, 2022
f6a5e9b
extract jobs api
benmoriceau Oct 26, 2022
8023bc9
fix test
benmoriceau Oct 27, 2022
bd206a9
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Oct 27, 2022
293c187
format
benmoriceau Oct 27, 2022
89308f5
Merge branch 'master' into bmoric/extract-healt-api
benmoriceau Oct 28, 2022
60fa570
Merge branch 'bmoric/extract-healt-api' of github.com:airbytehq/airby…
benmoriceau Oct 28, 2022
7accc25
Extract logs api
benmoriceau Oct 28, 2022
5151909
Add missing declaration
benmoriceau Oct 28, 2022
0eb77e1
Merge branch 'bmoric/extract-jobs-api' of github.com:airbytehq/airbyt…
benmoriceau Oct 28, 2022
ffb770b
Fix build
benmoriceau Oct 28, 2022
c3cd08e
Merge branch 'master' into bmoric/extract-healt-api
benmoriceau Oct 28, 2022
c65a79b
Merge branch 'bmoric/extract-healt-api' into bmoric/extract-jobs-api
benmoriceau Oct 28, 2022
3ed2fee
format and PR comments
benmoriceau Oct 28, 2022
cef5c58
Merge branch 'bmoric/extract-jobs-api' of github.com:airbytehq/airbyt…
benmoriceau Oct 28, 2022
bfaf6b5
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Nov 1, 2022
8d07282
Merge branch 'bmoric/extract-jobs-api' of github.com:airbytehq/airbyt…
benmoriceau Nov 1, 2022
fa4761d
Fix PMD
benmoriceau Nov 2, 2022
7e32024
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/ext…
benmoriceau Nov 2, 2022
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 @@ -36,7 +36,6 @@ public class ConfigurationApiFactory implements Factory<ConfigurationApi> {
private static TrackingClient trackingClient;
private static WorkerEnvironment workerEnvironment;
private static LogConfigs logConfigs;
private static Path workspaceRoot;
private static AirbyteVersion airbyteVersion;
private static HttpClient httpClient;
private static EventRunner eventRunner;
Expand Down Expand Up @@ -69,7 +68,6 @@ public static void setValues(
ConfigurationApiFactory.trackingClient = trackingClient;
ConfigurationApiFactory.workerEnvironment = workerEnvironment;
ConfigurationApiFactory.logConfigs = logConfigs;
ConfigurationApiFactory.workspaceRoot = workspaceRoot;
ConfigurationApiFactory.airbyteVersion = airbyteVersion;
ConfigurationApiFactory.httpClient = httpClient;
ConfigurationApiFactory.eventRunner = eventRunner;
Expand All @@ -91,7 +89,6 @@ public ConfigurationApi provide() {
ConfigurationApiFactory.workerEnvironment,
ConfigurationApiFactory.logConfigs,
ConfigurationApiFactory.airbyteVersion,
ConfigurationApiFactory.workspaceRoot,
ConfigurationApiFactory.httpClient,
ConfigurationApiFactory.eventRunner);
}
Expand Down
28 changes: 28 additions & 0 deletions airbyte-server/src/main/java/io/airbyte/server/ServerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,12 @@
import io.airbyte.server.handlers.DestinationDefinitionsHandler;
import io.airbyte.server.handlers.DestinationHandler;
import io.airbyte.server.handlers.HealthCheckHandler;
import io.airbyte.server.handlers.JobHistoryHandler;
import io.airbyte.server.handlers.LogsHandler;
import io.airbyte.server.handlers.OperationsHandler;
import io.airbyte.server.handlers.SchedulerHandler;
import io.airbyte.server.handlers.SourceDefinitionsHandler;
import io.airbyte.server.handlers.SourceHandler;
import io.airbyte.server.scheduler.DefaultSynchronousSchedulerClient;
import io.airbyte.server.scheduler.EventRunner;
import io.airbyte.server.scheduler.TemporalEventRunner;
Expand Down Expand Up @@ -302,6 +306,28 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,

final HealthCheckHandler healthCheckHandler = new HealthCheckHandler(configRepository);

final SourceHandler sourceHandler = new SourceHandler(
configRepository,
secretsRepositoryReader,
secretsRepositoryWriter,
schemaValidator,
connectionsHandler);

final SourceDefinitionsHandler sourceDefinitionsHandler = new SourceDefinitionsHandler(configRepository, syncSchedulerClient, sourceHandler);

final JobHistoryHandler jobHistoryHandler = new JobHistoryHandler(
jobPersistence,
configs.getWorkerEnvironment(),
configs.getLogConfigs(),
connectionsHandler,
sourceHandler,
sourceDefinitionsHandler,
destinationHandler,
destinationDefinitionsHandler,
configs.getAirbyteVersion());

final LogsHandler logsHandler = new LogsHandler(configs);

LOGGER.info("Starting server...");

return apiFactory.create(
Expand All @@ -327,6 +353,8 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,
destinationDefinitionsHandler,
destinationHandler,
healthCheckHandler,
jobHistoryHandler,
logsHandler,
operationsHandler,
schedulerHandler);
}
Expand Down
24 changes: 22 additions & 2 deletions airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,34 @@
import io.airbyte.server.apis.DestinationDefinitionApiController;
import io.airbyte.server.apis.DestinationDefinitionSpecificationApiController;
import io.airbyte.server.apis.HealthApiController;
import io.airbyte.server.apis.JobsApiController;
import io.airbyte.server.apis.LogsApiController;
import io.airbyte.server.apis.binders.AttemptApiBinder;
import io.airbyte.server.apis.binders.ConnectionApiBinder;
import io.airbyte.server.apis.binders.DbMigrationBinder;
import io.airbyte.server.apis.binders.DestinationApiBinder;
import io.airbyte.server.apis.binders.DestinationDefinitionApiBinder;
import io.airbyte.server.apis.binders.DestinationDefinitionSpecificationApiBinder;
import io.airbyte.server.apis.binders.HealthApiBinder;
import io.airbyte.server.apis.binders.JobsApiBinder;
import io.airbyte.server.apis.binders.LogsApiBinder;
import io.airbyte.server.apis.factories.AttemptApiFactory;
import io.airbyte.server.apis.factories.ConnectionApiFactory;
import io.airbyte.server.apis.factories.DbMigrationApiFactory;
import io.airbyte.server.apis.factories.DestinationApiFactory;
import io.airbyte.server.apis.factories.DestinationDefinitionApiFactory;
import io.airbyte.server.apis.factories.DestinationDefinitionSpecificationApiFactory;
import io.airbyte.server.apis.factories.HealthApiFactory;
import io.airbyte.server.apis.factories.JobsApiFactory;
import io.airbyte.server.apis.factories.LogsApiFactory;
import io.airbyte.server.handlers.AttemptHandler;
import io.airbyte.server.handlers.ConnectionsHandler;
import io.airbyte.server.handlers.DbMigrationHandler;
import io.airbyte.server.handlers.DestinationDefinitionsHandler;
import io.airbyte.server.handlers.DestinationHandler;
import io.airbyte.server.handlers.HealthCheckHandler;
import io.airbyte.server.handlers.JobHistoryHandler;
import io.airbyte.server.handlers.LogsHandler;
import io.airbyte.server.handlers.OperationsHandler;
import io.airbyte.server.handlers.SchedulerHandler;
import io.airbyte.server.scheduler.EventRunner;
Expand Down Expand Up @@ -77,6 +85,8 @@ ServerRunnable create(final SynchronousSchedulerClient synchronousSchedulerClien
final DestinationDefinitionsHandler destinationDefinitionsHandler,
final DestinationHandler destinationApiHandler,
final HealthCheckHandler healthCheckHandler,
final JobHistoryHandler jobHistoryHandler,
final LogsHandler logsHandler,
final OperationsHandler operationsHandler,
final SchedulerHandler schedulerHandler);

Expand Down Expand Up @@ -105,6 +115,8 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
final DestinationDefinitionsHandler destinationDefinitionsHandler,
final DestinationHandler destinationApiHandler,
final HealthCheckHandler healthCheckHandler,
final JobHistoryHandler jobHistoryHandler,
final LogsHandler logsHandler,
final OperationsHandler operationsHandler,
final SchedulerHandler schedulerHandler) {
final Map<String, String> mdc = MDC.getCopyOfContextMap();
Expand Down Expand Up @@ -148,6 +160,10 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

HealthApiFactory.setValues(healthCheckHandler);

JobsApiFactory.setValues(jobHistoryHandler, schedulerHandler);

LogsApiFactory.setValues(logsHandler);

// server configurations
final Set<Class<?>> componentClasses = Set.of(
ConfigurationApi.class,
Expand All @@ -157,7 +173,9 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
DestinationApiController.class,
DestinationDefinitionApiController.class,
DestinationDefinitionSpecificationApiController.class,
HealthApiController.class);
HealthApiController.class,
JobsApiController.class,
LogsApiController.class);

final Set<Object> components = Set.of(
new CorsFilter(),
Expand All @@ -168,7 +186,9 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
new DestinationApiBinder(),
new DestinationDefinitionApiBinder(),
new DestinationDefinitionSpecificationApiBinder(),
new HealthApiBinder());
new HealthApiBinder(),
new JobsApiBinder(),
new LogsApiBinder());

// construct server
return new ServerApp(airbyteVersion, componentClasses, components);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
import io.airbyte.server.handlers.DestinationDefinitionsHandler;
import io.airbyte.server.handlers.DestinationHandler;
import io.airbyte.server.handlers.JobHistoryHandler;
import io.airbyte.server.handlers.LogsHandler;
import io.airbyte.server.handlers.OAuthHandler;
import io.airbyte.server.handlers.OpenApiConfigHandler;
import io.airbyte.server.handlers.OperationsHandler;
Expand All @@ -135,7 +134,6 @@
import java.io.File;
import java.io.IOException;
import java.net.http.HttpClient;
import java.nio.file.Path;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.NotImplementedException;
Expand All @@ -156,12 +154,8 @@ public class ConfigurationApi implements io.airbyte.api.generated.V1Api {
private final JobHistoryHandler jobHistoryHandler;
private final WebBackendConnectionsHandler webBackendConnectionsHandler;
private final WebBackendGeographiesHandler webBackendGeographiesHandler;
private final LogsHandler logsHandler;
private final OpenApiConfigHandler openApiConfigHandler;
private final OAuthHandler oAuthHandler;
private final WorkerEnvironment workerEnvironment;
private final LogConfigs logConfigs;
private final Path workspaceRoot;

public ConfigurationApi(final ConfigRepository configRepository,
final JobPersistence jobPersistence,
Expand All @@ -173,12 +167,8 @@ public ConfigurationApi(final ConfigRepository configRepository,
final WorkerEnvironment workerEnvironment,
final LogConfigs logConfigs,
final AirbyteVersion airbyteVersion,
final Path workspaceRoot,
final HttpClient httpClient,
final EventRunner eventRunner) {
this.workerEnvironment = workerEnvironment;
this.logConfigs = logConfigs;
this.workspaceRoot = workspaceRoot;

final JsonSchemaValidator schemaValidator = new JsonSchemaValidator();

Expand Down Expand Up @@ -235,7 +225,6 @@ public ConfigurationApi(final ConfigRepository configRepository,
eventRunner,
configRepository);
webBackendGeographiesHandler = new WebBackendGeographiesHandler();
logsHandler = new LogsHandler();
openApiConfigHandler = new OpenApiConfigHandler();
}

Expand Down Expand Up @@ -889,41 +878,69 @@ public SourceDiscoverSchemaRead executeSourceDiscoverSchema(final SourceCoreConf
return execute(() -> schedulerHandler.discoverSchemaForSourceFromSourceCreate(sourceCreate));
}

/**
* This implementation has been moved to {@link JobsApiController}. Since the path of
* {@link JobsApiController} is more granular, it will override this implementation
*/
@Override
public JobInfoRead cancelJob(final JobIdRequestBody jobIdRequestBody) {
return execute(() -> schedulerHandler.cancelJob(jobIdRequestBody));
throw new NotImplementedException();
}

// JOB HISTORY

/**
* This implementation has been moved to {@link JobsApiController}. Since the path of
* {@link JobsApiController} is more granular, it will override this implementation
*/
@Override
public JobReadList listJobsFor(final JobListRequestBody jobListRequestBody) {
return execute(() -> jobHistoryHandler.listJobsFor(jobListRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link JobsApiController}. Since the path of
* {@link JobsApiController} is more granular, it will override this implementation
*/
@Override
public JobInfoRead getJobInfo(final JobIdRequestBody jobIdRequestBody) {
return execute(() -> jobHistoryHandler.getJobInfo(jobIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link JobsApiController}. Since the path of
* {@link JobsApiController} is more granular, it will override this implementation
*/
@Override
public JobInfoLightRead getJobInfoLight(final JobIdRequestBody jobIdRequestBody) {
return execute(() -> jobHistoryHandler.getJobInfoLight(jobIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link JobsApiController}. Since the path of
* {@link JobsApiController} is more granular, it will override this implementation
*/
@Override
public JobDebugInfoRead getJobDebugInfo(final JobIdRequestBody jobIdRequestBody) {
return execute(() -> jobHistoryHandler.getJobDebugInfo(jobIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link JobsApiController}. Since the path of
* {@link JobsApiController} is more granular, it will override this implementation
*/
@Override
public AttemptNormalizationStatusReadList getAttemptNormalizationStatusesForJob(final JobIdRequestBody jobIdRequestBody) {
return execute(() -> jobHistoryHandler.getAttemptNormalizationStatuses(jobIdRequestBody));
}

/**
* This implementation has been moved to {@link LogsApiController}. Since the path of
* {@link LogsApiController} is more granular, it will override this implementation
*/
@Override
public File getLogs(final LogsRequestBody logsRequestBody) {
return execute(() -> logsHandler.getLogs(workspaceRoot, workerEnvironment, logConfigs, logsRequestBody));
throw new NotImplementedException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.apis;

import io.airbyte.api.generated.JobsApi;
import io.airbyte.api.model.generated.AttemptNormalizationStatusReadList;
import io.airbyte.api.model.generated.JobDebugInfoRead;
import io.airbyte.api.model.generated.JobIdRequestBody;
import io.airbyte.api.model.generated.JobInfoLightRead;
import io.airbyte.api.model.generated.JobInfoRead;
import io.airbyte.api.model.generated.JobListRequestBody;
import io.airbyte.api.model.generated.JobReadList;
import io.airbyte.server.handlers.JobHistoryHandler;
import io.airbyte.server.handlers.SchedulerHandler;
import javax.ws.rs.Path;
import lombok.AllArgsConstructor;

@Path("/v1/jobs")
@AllArgsConstructor
public class JobsApiController implements JobsApi {

private final JobHistoryHandler jobHistoryHandler;
private final SchedulerHandler schedulerHandler;

@Override
public JobInfoRead cancelJob(final JobIdRequestBody jobIdRequestBody) {
return ConfigurationApi.execute(() -> schedulerHandler.cancelJob(jobIdRequestBody));
}

@Override
public AttemptNormalizationStatusReadList getAttemptNormalizationStatusesForJob(final JobIdRequestBody jobIdRequestBody) {
return ConfigurationApi.execute(() -> jobHistoryHandler.getAttemptNormalizationStatuses(jobIdRequestBody));
}

@Override
public JobDebugInfoRead getJobDebugInfo(final JobIdRequestBody jobIdRequestBody) {
return ConfigurationApi.execute(() -> jobHistoryHandler.getJobDebugInfo(jobIdRequestBody));
}

@Override
public JobInfoRead getJobInfo(final JobIdRequestBody jobIdRequestBody) {
return ConfigurationApi.execute(() -> jobHistoryHandler.getJobInfo(jobIdRequestBody));
}

@Override
public JobInfoLightRead getJobInfoLight(final JobIdRequestBody jobIdRequestBody) {
return ConfigurationApi.execute(() -> jobHistoryHandler.getJobInfoLight(jobIdRequestBody));
}

@Override
public JobReadList listJobsFor(final JobListRequestBody jobListRequestBody) {
return ConfigurationApi.execute(() -> jobHistoryHandler.listJobsFor(jobListRequestBody));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.apis;

import io.airbyte.api.generated.LogsApi;
import io.airbyte.api.model.generated.LogsRequestBody;
import io.airbyte.server.handlers.LogsHandler;
import java.io.File;
import javax.ws.rs.Path;
import lombok.AllArgsConstructor;

@Path("/v1/logs/get")
@AllArgsConstructor
public class LogsApiController implements LogsApi {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this missing a path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no. Adding the path is not needed because it is inherited from the interface but I prefer to add it in order to avoid to have to look at the interface know the path when you are debugging. I have added it now.


private final LogsHandler logsHandler;

@Override
public File getLogs(final LogsRequestBody logsRequestBody) {
return ConfigurationApi.execute(() -> logsHandler.getLogs(logsRequestBody));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.apis.binders;

import io.airbyte.server.apis.JobsApiController;
import io.airbyte.server.apis.factories.JobsApiFactory;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.process.internal.RequestScoped;

public class JobsApiBinder extends AbstractBinder {

@Override
protected void configure() {
bindFactory(JobsApiFactory.class)
.to(JobsApiController.class)
.in(RequestScoped.class);
}

}
Loading