mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-20 23:18:01 +00:00
Co-authored-by: Akash-Jain <Akash.J@deuexsolutions.com>
This commit is contained in:
parent
aec9ba2ddb
commit
cf3d4314dd
@ -94,6 +94,14 @@
|
|||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-multipart</artifactId>
|
<artifactId>jersey-media-multipart</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.maksymdolgykh.dropwizard</groupId>
|
||||||
|
<artifactId>dropwizard-micrometer-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.maksymdolgykh.dropwizard</groupId>
|
||||||
|
<artifactId>dropwizard-micrometer-jdbi</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-lang</groupId>
|
<groupId>commons-lang</groupId>
|
||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang</artifactId>
|
||||||
|
@ -29,10 +29,16 @@ import io.dropwizard.setup.Bootstrap;
|
|||||||
import io.dropwizard.setup.Environment;
|
import io.dropwizard.setup.Environment;
|
||||||
import io.federecio.dropwizard.swagger.SwaggerBundle;
|
import io.federecio.dropwizard.swagger.SwaggerBundle;
|
||||||
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
|
import io.federecio.dropwizard.swagger.SwaggerBundleConfiguration;
|
||||||
|
import io.github.maksymdolgykh.dropwizard.micrometer.MicrometerBundle;
|
||||||
|
import io.github.maksymdolgykh.dropwizard.micrometer.MicrometerHttpFilter;
|
||||||
|
import io.github.maksymdolgykh.dropwizard.micrometer.MicrometerJdbiTimingCollector;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.EnumSet;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import javax.servlet.DispatcherType;
|
||||||
|
import javax.servlet.FilterRegistration;
|
||||||
import javax.ws.rs.container.ContainerRequestFilter;
|
import javax.ws.rs.container.ContainerRequestFilter;
|
||||||
import javax.ws.rs.container.ContainerResponseFilter;
|
import javax.ws.rs.container.ContainerResponseFilter;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
@ -79,6 +85,7 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
|||||||
throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException,
|
throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException,
|
||||||
InvocationTargetException, IOException {
|
InvocationTargetException, IOException {
|
||||||
final Jdbi jdbi = new JdbiFactory().build(environment, catalogConfig.getDataSourceFactory(), "database");
|
final Jdbi jdbi = new JdbiFactory().build(environment, catalogConfig.getDataSourceFactory(), "database");
|
||||||
|
jdbi.setTimingCollector(new MicrometerJdbiTimingCollector());
|
||||||
|
|
||||||
SqlLogger sqlLogger =
|
SqlLogger sqlLogger =
|
||||||
new SqlLogger() {
|
new SqlLogger() {
|
||||||
@ -125,7 +132,7 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
|||||||
environment.jersey().register(new JsonProcessingExceptionMapper(true));
|
environment.jersey().register(new JsonProcessingExceptionMapper(true));
|
||||||
environment.jersey().register(new EarlyEofExceptionMapper());
|
environment.jersey().register(new EarlyEofExceptionMapper());
|
||||||
environment.jersey().register(JsonMappingExceptionMapper.class);
|
environment.jersey().register(JsonMappingExceptionMapper.class);
|
||||||
environment.healthChecks().register("UserDatabaseCheck", new CatalogHealthCheck(jdbi));
|
environment.healthChecks().register("OpenMetadataServerHealthCheck", new OpenMetadataServerHealthCheck());
|
||||||
registerResources(catalogConfig, environment, jdbi);
|
registerResources(catalogConfig, environment, jdbi);
|
||||||
RoleEvaluator.getInstance().load();
|
RoleEvaluator.getInstance().load();
|
||||||
PolicyEvaluator.getInstance().load();
|
PolicyEvaluator.getInstance().load();
|
||||||
@ -137,9 +144,13 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
|||||||
EventPubSub.start();
|
EventPubSub.start();
|
||||||
// Register Event publishers
|
// Register Event publishers
|
||||||
registerEventPublisher(catalogConfig);
|
registerEventPublisher(catalogConfig);
|
||||||
|
|
||||||
// start authorizer after event publishers
|
// start authorizer after event publishers
|
||||||
// authorizer creates admin/bot users, ES publisher should start before to index users created by authorizer
|
// authorizer creates admin/bot users, ES publisher should start before to index users created by authorizer
|
||||||
authorizer.init(catalogConfig.getAuthorizerConfiguration(), jdbi);
|
authorizer.init(catalogConfig.getAuthorizerConfiguration(), jdbi);
|
||||||
|
FilterRegistration.Dynamic micrometerFilter =
|
||||||
|
environment.servlets().addFilter("MicrometerHttpFilter", new MicrometerHttpFilter());
|
||||||
|
micrometerFilter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@ -163,6 +174,7 @@ public class CatalogApplication extends Application<CatalogApplicationConfig> {
|
|||||||
return configuration.getHealthConfiguration();
|
return configuration.getHealthConfiguration();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
bootstrap.addBundle(new MicrometerBundle());
|
||||||
super.initialize(bootstrap);
|
super.initialize(bootstrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021 Collate
|
||||||
|
* Licensed 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.openmetadata.catalog;
|
||||||
|
|
||||||
|
import com.codahale.metrics.health.HealthCheck;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
public class OpenMetadataServerHealthCheck extends HealthCheck {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Result check() throws Exception {
|
||||||
|
return Result.healthy();
|
||||||
|
}
|
||||||
|
}
|
@ -114,9 +114,8 @@ migrationConfiguration:
|
|||||||
health:
|
health:
|
||||||
delayedShutdownHandlerEnabled: true
|
delayedShutdownHandlerEnabled: true
|
||||||
shutdownWaitPeriod: 5s
|
shutdownWaitPeriod: 5s
|
||||||
healthCheckUrlPaths: ["/api/v1/health-check"]
|
|
||||||
healthChecks:
|
healthChecks:
|
||||||
- name: UserDatabaseCheck
|
- name: OpenMetadataServerHealthCheck
|
||||||
critical: true
|
critical: true
|
||||||
|
|
||||||
# Authorizer Configuration
|
# Authorizer Configuration
|
||||||
|
@ -221,9 +221,8 @@ fernetConfiguration:
|
|||||||
health:
|
health:
|
||||||
delayedShutdownHandlerEnabled: true
|
delayedShutdownHandlerEnabled: true
|
||||||
shutdownWaitPeriod: 1s
|
shutdownWaitPeriod: 1s
|
||||||
healthCheckUrlPaths: ["/api/v1/health-check"]
|
|
||||||
healthChecks:
|
healthChecks:
|
||||||
- name: UserDatabaseCheck
|
- name: OpenMetadataServerHealthCheck
|
||||||
critical: true
|
critical: true
|
||||||
schedule:
|
schedule:
|
||||||
checkInterval: 2500ms
|
checkInterval: 2500ms
|
||||||
|
@ -98,11 +98,13 @@ services:
|
|||||||
OM_AUTH_AIRFLOW_CUSTOM_OIDC_TOKEN_ENDPOINT_URL: ${OM_AUTH_AIRFLOW_CUSTOM_OIDC_TOKEN_ENDPOINT_URL:-""}
|
OM_AUTH_AIRFLOW_CUSTOM_OIDC_TOKEN_ENDPOINT_URL: ${OM_AUTH_AIRFLOW_CUSTOM_OIDC_TOKEN_ENDPOINT_URL:-""}
|
||||||
expose:
|
expose:
|
||||||
- 8585
|
- 8585
|
||||||
|
- 8586
|
||||||
- 9200
|
- 9200
|
||||||
- 9300
|
- 9300
|
||||||
- 3306
|
- 3306
|
||||||
ports:
|
ports:
|
||||||
- 8585:8585
|
- 8585:8585
|
||||||
|
- 8586:8586
|
||||||
depends_on:
|
depends_on:
|
||||||
- elasticsearch
|
- elasticsearch
|
||||||
- mysql
|
- mysql
|
||||||
|
@ -87,11 +87,13 @@ services:
|
|||||||
OM_AUTH_AIRFLOW_CUSTOM_OIDC_TOKEN_ENDPOINT_URL: ${OM_AUTH_AIRFLOW_CUSTOM_OIDC_TOKEN_ENDPOINT_URL:-""}
|
OM_AUTH_AIRFLOW_CUSTOM_OIDC_TOKEN_ENDPOINT_URL: ${OM_AUTH_AIRFLOW_CUSTOM_OIDC_TOKEN_ENDPOINT_URL:-""}
|
||||||
expose:
|
expose:
|
||||||
- 8585
|
- 8585
|
||||||
|
- 8586
|
||||||
- 9200
|
- 9200
|
||||||
- 9300
|
- 9300
|
||||||
- 3306
|
- 3306
|
||||||
ports:
|
ports:
|
||||||
- 8585:8585
|
- 8585:8585
|
||||||
|
- 8586:8586
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
- mysql
|
||||||
networks:
|
networks:
|
||||||
|
@ -649,9 +649,10 @@ class OpenMetadata(
|
|||||||
|
|
||||||
def health_check(self) -> bool:
|
def health_check(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Run endpoint health-check. Return `true` if OK
|
Run version api call. Return `true` if response is not None
|
||||||
"""
|
"""
|
||||||
return self.client.get("/health-check")["status"] == "healthy"
|
raw_version = self.client.get("/version")["version"]
|
||||||
|
return raw_version is not None
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
|
@ -154,7 +154,7 @@ def test_read_tables(hive_service):
|
|||||||
|
|
||||||
|
|
||||||
def test_check_table():
|
def test_check_table():
|
||||||
is_responsive("http://localhost:8585/api/v1/health-check")
|
is_responsive("http://localhost:8586/healthcheck")
|
||||||
metadata_config = MetadataServerConfig.parse_obj(
|
metadata_config = MetadataServerConfig.parse_obj(
|
||||||
{"api_endpoint": "http://localhost:8585/api", "auth_provider_type": "no-auth"}
|
{"api_endpoint": "http://localhost:8585/api", "auth_provider_type": "no-auth"}
|
||||||
)
|
)
|
||||||
|
@ -162,7 +162,7 @@ def test_read_tables(trino_service):
|
|||||||
|
|
||||||
|
|
||||||
def test_check_table():
|
def test_check_table():
|
||||||
is_responsive("http://localhost:8585/api/v1/health-check")
|
is_responsive("http://localhost:8586/healthcheck")
|
||||||
metadata_config = MetadataServerConfig.parse_obj(
|
metadata_config = MetadataServerConfig.parse_obj(
|
||||||
{"api_endpoint": "http://localhost:8585/api", "auth_provider_type": "no-auth"}
|
{"api_endpoint": "http://localhost:8585/api", "auth_provider_type": "no-auth"}
|
||||||
)
|
)
|
||||||
|
11
pom.xml
11
pom.xml
@ -95,6 +95,7 @@
|
|||||||
<sonar.skip>false</sonar.skip>
|
<sonar.skip>false</sonar.skip>
|
||||||
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
|
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
|
||||||
<testng.version>7.6.0</testng.version>
|
<testng.version>7.6.0</testng.version>
|
||||||
|
<dropwizard-micrometer.version>2.0.5</dropwizard-micrometer.version>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -318,6 +319,16 @@
|
|||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
<version>${spring.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.maksymdolgykh.dropwizard</groupId>
|
||||||
|
<artifactId>dropwizard-micrometer-core</artifactId>
|
||||||
|
<version>${dropwizard-micrometer.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.maksymdolgykh.dropwizard</groupId>
|
||||||
|
<artifactId>dropwizard-micrometer-jdbi</artifactId>
|
||||||
|
<version>${dropwizard-micrometer.version}</version>
|
||||||
|
</dependency>
|
||||||
<!-- API, java.xml.bind module -->
|
<!-- API, java.xml.bind module -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>jakarta.xml.bind</groupId>
|
<groupId>jakarta.xml.bind</groupId>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user