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

HDDS-10422. Fix some warnings about exposing internal representation in hdds-common #6351

Merged
merged 16 commits into from
May 22, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
fix compile errors in FakeClusterTopology
adoroszlai committed May 22, 2024
commit b9ed7e87a9586791a3ddbb2cbb010afedecdd3e6
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
package org.apache.hadoop.hdds.freon;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.UUID;
@@ -41,19 +42,20 @@ public final class FakeClusterTopology {
private static final Logger LOGGER =
LoggerFactory.getLogger(FakeClusterTopology.class);

public static final FakeClusterTopology INSTANCE = new FakeClusterTopology();
public static final FakeClusterTopology INSTANCE = newFakeClusterTopology();

private final List<DatanodeDetailsProto> datanodes;

private final List<Pipeline> pipelines = new ArrayList<>();
private final List<Pipeline> pipelines;

private final Random random = new Random();

private FakeClusterTopology newFakeClusterTopology() {
final List<DatanodeDetailsProto> datanodes = new ArrayList<>();
final List<Pipeline> pipelines = new ArrayList<>();
private static FakeClusterTopology newFakeClusterTopology() {
final int nodeCount = 9;
final List<DatanodeDetailsProto> datanodes = new ArrayList<>(nodeCount);
final List<Pipeline> pipelines = new ArrayList<>(nodeCount / 3);
try {
for (int i = 0; i < 9; i++) {
for (int i = 0; i < nodeCount; i++) {
datanodes.add(createDatanode());
if ((i + 1) % 3 == 0) {
pipelines.add(Pipeline.newBuilder()
@@ -69,10 +71,15 @@ private FakeClusterTopology newFakeClusterTopology() {
} catch (Exception ex) {
LOGGER.error("Can't initialize FakeClusterTopology", ex);
}
return new FakeClusterTopology(datanodes, pipelines);
}

private FakeClusterTopology(List<DatanodeDetailsProto> datanodes, List<Pipeline> pipelines) {
this.datanodes = Collections.unmodifiableList(datanodes);
this.pipelines = Collections.unmodifiableList(pipelines);
}

private DatanodeDetailsProto createDatanode() {
private static DatanodeDetailsProto createDatanode() {
return DatanodeDetailsProto.newBuilder()
.setUuid(UUID.randomUUID().toString())
.setHostName("localhost")