Skip to content

Commit

Permalink
DatabaseChecks class was renamed to DatabaseChecksOnCluster (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfvanek authored Nov 24, 2024
1 parent 9a17beb commit 05840d5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
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

0 comments on commit 05840d5

Please sign in to comment.