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

DatabaseChecks class was renamed to DatabaseChecksOnCluster #510

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -57,14 +57,14 @@ public abstract class AbstractHealthLogger implements HealthLogger {

private final ConnectionCredentials credentials;
private final HighAvailabilityPgConnectionFactory connectionFactory;
private final Function<HighAvailabilityPgConnection, DatabaseChecks> databaseChecksFactory;
private final AtomicReference<DatabaseChecks> databaseChecksHolder = new AtomicReference<>();
private final Function<HighAvailabilityPgConnection, DatabaseChecksOnCluster> databaseChecksFactory;
private final AtomicReference<DatabaseChecksOnCluster> databaseChecksHolder = new AtomicReference<>();
private final AtomicReference<PgContext> pgContextHolder = new AtomicReference<>();

@SuppressWarnings("WeakerAccess")
protected AbstractHealthLogger(@Nonnull final ConnectionCredentials credentials,
@Nonnull final HighAvailabilityPgConnectionFactory connectionFactory,
@Nonnull final Function<HighAvailabilityPgConnection, DatabaseChecks> databaseChecksFactory) {
@Nonnull final Function<HighAvailabilityPgConnection, DatabaseChecksOnCluster> databaseChecksFactory) {
this.credentials = Objects.requireNonNull(credentials, "credentials cannot be null");
this.connectionFactory = Objects.requireNonNull(connectionFactory, "connectionFactory cannot be null");
this.databaseChecksFactory = Objects.requireNonNull(databaseChecksFactory, "databaseChecksFactory cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@

@SuppressWarnings({"checkstyle:ClassDataAbstractionCoupling", "checkstyle:ClassFanOutComplexity"})
@ThreadSafe
public class DatabaseChecks {
public final class DatabaseChecksOnCluster {

private final ConcurrentMap<Diagnostic, DatabaseCheckOnCluster<? extends DbObject>> checks = new ConcurrentHashMap<>();

public DatabaseChecks(@Nonnull final HighAvailabilityPgConnection haPgConnection) {
public DatabaseChecksOnCluster(@Nonnull final HighAvailabilityPgConnection haPgConnection) {
final Stream<DatabaseCheckOnCluster<? extends DbObject>> allChecks = Stream.of(
new TablesWithBloatCheckOnCluster(haPgConnection),
new TablesWithMissingIndexesCheckOnCluster(haPgConnection),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class KeyValueFileHealthLogger extends AbstractHealthLogger {

public KeyValueFileHealthLogger(@Nonnull final ConnectionCredentials credentials,
@Nonnull final HighAvailabilityPgConnectionFactory connectionFactory,
@Nonnull final Function<HighAvailabilityPgConnection, DatabaseChecks> databaseChecksFactory) {
@Nonnull final Function<HighAvailabilityPgConnection, DatabaseChecksOnCluster> databaseChecksFactory) {
super(credentials, connectionFactory, databaseChecksFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class StandardHealthLogger extends AbstractHealthLogger {

public StandardHealthLogger(@Nonnull final ConnectionCredentials credentials,
@Nonnull final HighAvailabilityPgConnectionFactory connectionFactory,
@Nonnull final Function<HighAvailabilityPgConnection, DatabaseChecks> databaseChecksFactory) {
@Nonnull final Function<HighAvailabilityPgConnection, DatabaseChecksOnCluster> databaseChecksFactory) {
super(credentials, connectionFactory, databaseChecksFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

class DatabaseChecksTest extends DatabaseAwareTestBase {
class DatabaseChecksOnClusterTest extends DatabaseAwareTestBase {

private static final String[] SCHEMAS = {PgContext.DEFAULT_SCHEMA_NAME, "custom"};

private final DatabaseChecks checks = new DatabaseChecks(getHaPgConnection());
private final DatabaseChecksOnCluster checks = new DatabaseChecksOnCluster(getHaPgConnection());

@Test
void shouldThrowExceptionForInvalidType() {
Expand Down Expand Up @@ -62,7 +62,7 @@ void getAllChecksShouldWork() {
@Test
@SuppressForbidden
void shouldThrowExceptionIfCheckNotFound() throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
final DatabaseChecks databaseChecks = new DatabaseChecks(getHaPgConnection());
final DatabaseChecksOnCluster databaseChecks = new DatabaseChecksOnCluster(getHaPgConnection());
final Field field = databaseChecks.getClass().getDeclaredField("checks");
field.setAccessible(true);
final Object fieldValue = field.get(databaseChecks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static void tearDown() {
@Nonnull
@Override
protected HealthLogger getHealthLogger() {
return new KeyValueFileHealthLogger(getConnectionCredentials(), getConnectionFactory(), DatabaseChecks::new);
return new KeyValueFileHealthLogger(getConnectionCredentials(), getConnectionFactory(), DatabaseChecksOnCluster::new);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class StandardHealthLoggerTest extends HealthLoggerTestBase {
@Nonnull
@Override
protected HealthLogger getHealthLogger() {
return new StandardHealthLogger(getConnectionCredentials(), getConnectionFactory(), DatabaseChecks::new);
return new StandardHealthLogger(getConnectionCredentials(), getConnectionFactory(), DatabaseChecksOnCluster::new);
}

@Nonnull
Expand Down