Skip to content
Open
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 @@ -41,15 +41,15 @@
*/
public class TestHDDSLayoutVersionManager {

private static final String[] UPGRADE_ACTIONS_TEST_PACKAGES = new String[] {
"org.apache.hadoop.hdds.upgrade.test"};
private static final String UPGRADE_ACTIONS_TEST_PACKAGE =
"org.apache.hadoop.hdds.upgrade.test";

@Test
public void testUpgradeActionsRegistered() throws Exception {

HDDSLayoutVersionManager lvm =
new HDDSLayoutVersionManager(maxLayoutVersion());
lvm.registerUpgradeActions(UPGRADE_ACTIONS_TEST_PACKAGES);
lvm.registerUpgradeActions(UPGRADE_ACTIONS_TEST_PACKAGE);

//Cluster is finalized, hence should not register.
Optional<HDDSUpgradeAction> action = INITIAL_VERSION.scmAction();
Expand All @@ -62,7 +62,7 @@ public void testUpgradeActionsRegistered() throws Exception {
when(lvm.getMetadataLayoutVersion()).thenReturn(-1);

doCallRealMethod().when(lvm).registerUpgradeActions(any());
lvm.registerUpgradeActions(UPGRADE_ACTIONS_TEST_PACKAGES);
lvm.registerUpgradeActions(UPGRADE_ACTIONS_TEST_PACKAGE);

action = INITIAL_VERSION.scmAction();
assertTrue(action.isPresent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public static SCMNodeDetails getHASCMNodeDetails(OzoneConfiguration conf,
return builder.build();
}

private static void throwConfException(String message, String... arguments)
private static void throwConfException(String message, Object... arguments)
throws IllegalArgumentException {
String exceptionMsg = String.format(message, arguments);
LOG.error(exceptionMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private String generateReport(
.append(" - move delta: source volume space to be reclaimed after move completion;" +
" this value is reflected only when diskBalancer is running else it is 0.%n");

return String.format(formatBuilder.toString(), contentList.toArray(new String[0]));
return String.format(formatBuilder.toString(), contentList.toArray(new Object[0]));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private String generateStatus(
" by default, CLOSED and QUASI_CLOSED are allowed.");

return String.format(formatBuilder.toString(),
contentList.toArray(new String[0]));
contentList.toArray(new Object[0]));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ protected URI createUploadRedirectionURL(UriInfo uriInfo,
uploadOperation)
.queryParam(DataParam.NAME, Boolean.TRUE)
.replaceQueryParam(NoRedirectParam.NAME, (Object[]) null);
return uriBuilder.build(null);
return uriBuilder.build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public static OMNodeDetails getHAOMNodeDetails(OzoneConfiguration conf,
.build();
}

private static void throwConfException(String message, String... arguments)
private static void throwConfException(String message, Object... arguments)
throws IllegalArgumentException {
String exceptionMsg = String.format(message, arguments);
LOG.error(exceptionMsg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void testGetClientAddress() {
String expectedClientAddressInCaseOfGrpcCall = "172.45.23.4";
Context.Key<String> clientIpAddressKey = mock(Context.Key.class);
when(clientIpAddressKey.get())
.thenReturn(expectedClientAddressInCaseOfGrpcCall, null);
.thenReturn(expectedClientAddressInCaseOfGrpcCall, null, null);

grpcRequestContextStaticMock.when(() -> Context.key("CLIENT_IP_ADDRESS"))
.thenReturn(clientIpAddressKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.ozone.recon.schema;

import static java.util.Collections.unmodifiableList;
import static java.util.stream.Collectors.toList;
import static org.apache.ozone.recon.schema.SqlDbUtils.TABLE_EXISTS_CHECK;
import static org.jooq.impl.DSL.field;
import static org.jooq.impl.DSL.name;
Expand All @@ -25,6 +27,8 @@
import com.google.inject.Singleton;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import javax.sql.DataSource;
import org.jooq.DSLContext;
import org.jooq.impl.DSL;
Expand Down Expand Up @@ -78,7 +82,7 @@ private void createUnhealthyContainersTable() {
.primaryKey(CONTAINER_ID, CONTAINER_STATE))
.constraint(DSL.constraint(UNHEALTHY_CONTAINERS_TABLE_NAME + "ck1")
.check(field(name(CONTAINER_STATE))
.in(UnHealthyContainerStates.values())))
.in(UnHealthyContainerStates.NAMES)))
.execute();
// Composite index (container_state, container_id) serves two query patterns:
//
Expand Down Expand Up @@ -121,6 +125,10 @@ public enum UnHealthyContainerStates {
MIS_REPLICATED,
ALL_REPLICAS_BAD,
NEGATIVE_SIZE, // Added new state to track containers with negative sizes
REPLICA_MISMATCH
REPLICA_MISMATCH;

public static final List<String> NAMES = unmodifiableList(Arrays.stream(values())
.map(Enum::toString)
.collect(toList()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.common.annotations.VisibleForTesting;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import javax.sql.DataSource;
import org.apache.ozone.recon.schema.ContainerSchemaDefinition;
import org.jooq.DSLContext;
Expand Down Expand Up @@ -75,19 +74,14 @@ private void dropConstraint() {
* Adds the updated constraint directly within this class.
*/
private void addUpdatedConstraint() {
String[] enumStates = Arrays
.stream(ContainerSchemaDefinition.UnHealthyContainerStates.values())
.map(Enum::name)
.toArray(String[]::new);

dslContext.alterTable(ContainerSchemaDefinition.UNHEALTHY_CONTAINERS_TABLE_NAME)
.add(DSL.constraint(ContainerSchemaDefinition.UNHEALTHY_CONTAINERS_TABLE_NAME + "ck1")
.check(field(name("container_state"))
.in(enumStates)))
.in(ContainerSchemaDefinition.UnHealthyContainerStates.NAMES)))
.execute();

LOG.info("Added the updated constraint to the UNHEALTHY_CONTAINERS table for enum state values: {}",
Arrays.toString(enumStates));
ContainerSchemaDefinition.UnHealthyContainerStates.NAMES);
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Arrays;
import javax.sql.DataSource;
import org.apache.ozone.recon.schema.ContainerSchemaDefinition;
import org.jooq.DSLContext;
Expand Down Expand Up @@ -73,18 +72,13 @@ private void dropConstraint() {
* Adds the updated constraint directly within this class.
*/
private void addUpdatedConstraint() {
String[] enumStates = Arrays
.stream(ContainerSchemaDefinition.UnHealthyContainerStates.values())
.map(Enum::name)
.toArray(String[]::new);

dslContext.alterTable(ContainerSchemaDefinition.UNHEALTHY_CONTAINERS_TABLE_NAME)
.add(DSL.constraint(ContainerSchemaDefinition.UNHEALTHY_CONTAINERS_TABLE_NAME + "ck1")
.check(field(name("container_state"))
.in(enumStates)))
.in(ContainerSchemaDefinition.UnHealthyContainerStates.NAMES)))
.execute();

LOG.info("Added the updated constraint to the UNHEALTHY_CONTAINERS table for enum state values: {}",
Arrays.toString(enumStates));
ContainerSchemaDefinition.UnHealthyContainerStates.NAMES);
}
}