Skip to content

Commit

Permalink
HDDS-10416. Move HA-specific settings to MiniOzoneHAClusterImpl.Build…
Browse files Browse the repository at this point in the history
…er (apache#6275)

(cherry picked from commit f440654)
Change-Id: Ieb1e5e37560459462eafdf8edb27a2a90e559885
  • Loading branch information
adoroszlai authored and jojochuang committed Mar 7, 2024
1 parent 92c3d87 commit 0760aae
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public MiniOzoneChaosCluster build() throws IOException {
DatanodeStoreCache.setMiniClusterMode();

initializeConfiguration();
if (numOfOMs > 1) {
if (numberOfOzoneManagers() > 1) {
initOMRatisConf();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ static void initClass(@TempDir File tempDir) throws Exception {

// Start the cluster
cluster = MiniOzoneCluster.newHABuilder(conf)
.setNumDatanodes(5)
.setOMServiceId(omServiceId)
.setNumOfOzoneManagers(numOfOMs)
.setNumDatanodes(5)
.build();
cluster.waitForClusterToBeReady();
client = OzoneClientFactory.getRpcClient(omServiceId, conf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ public void init() throws Exception {
MiniOzoneCluster.Builder builder = MiniOzoneCluster.newHABuilder(conf)
.setSCMServiceId("TestSecretKeySnapshot")
.setSCMServiceId("SCMServiceId")
.setNumDatanodes(1)
.setNumOfStorageContainerManagers(3)
.setNumOfActiveSCMs(2)
.setNumOfOzoneManagers(1);
.setNumOfOzoneManagers(1)
.setNumDatanodes(1);

cluster = (MiniOzoneHAClusterImpl) builder.build();
cluster.waitForClusterToBeReady();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ private void startCluster(int numSCMs)
OzoneManager.setTestSecureOmFlag(true);
MiniOzoneCluster.Builder builder = MiniOzoneCluster.newHABuilder(conf)
.setSCMServiceId("TestSecretKey")
.setNumDatanodes(3)
.setNumOfStorageContainerManagers(numSCMs)
.setNumOfOzoneManagers(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ public static void initClass() {

MiniOzoneCluster.Builder builder =
new MiniOzoneHAClusterImpl.Builder(conf)
.setNumDatanodes(NUM_DATA_NODES)
.setNumOfStorageContainerManagers(NUM_SCMS)
.setSCMConfigurator(scmConfigurator)
.setNumDatanodes(NUM_DATA_NODES)
.setDatanodeFactory(UniformDatanodesFactory.newBuilder()
.setLayoutVersion(HDDSLayoutFeature.INITIAL_VERSION.layoutVersion())
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public void init(OzoneConfiguration conf,
.setNumOfStorageContainerManagers(NUM_SCMS)
.setNumOfActiveSCMs(NUM_SCMS - numInactiveSCMs)
.setSCMServiceId("scmservice")
.setSCMConfigurator(configurator)
.setNumOfOzoneManagers(1)
.setSCMConfigurator(configurator)
.setNumDatanodes(NUM_DATANODES)
.setDatanodeFactory(UniformDatanodesFactory.newBuilder()
.setLayoutVersion(HDDSLayoutFeature.INITIAL_VERSION.layoutVersion())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ static void setUp() throws IOException, InterruptedException,
TimeoutException {
OzoneConfiguration conf = new OzoneConfiguration();
conf.set(OZONE_METADATA_STORE_ROCKSDB_STATISTICS, "ALL");
String omServiceId = "omServiceId1";
cluster = MiniOzoneCluster.newBuilder(conf)
.setOMServiceId(omServiceId)
.setNumOfOzoneManagers(1)
.build();
cluster.waitForClusterToBeReady();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static Builder newBuilder(OzoneConfiguration conf) {
*
* @return MiniOzoneCluster builder
*/
static Builder newHABuilder(OzoneConfiguration conf) {
static MiniOzoneHAClusterImpl.Builder newHABuilder(OzoneConfiguration conf) {
return new MiniOzoneHAClusterImpl.Builder(conf);
}

Expand Down Expand Up @@ -272,13 +272,6 @@ abstract class Builder {
protected String path;

protected String clusterId;
protected String omServiceId;
protected int numOfOMs;
protected int numOfActiveOMs = ACTIVE_OMS_NOT_SET;

protected String scmServiceId;
protected int numOfSCMs;
protected int numOfActiveSCMs = ACTIVE_SCMS_NOT_SET;
protected SCMConfigurator scmConfigurator;

protected String scmId = UUID.randomUUID().toString();
Expand Down Expand Up @@ -392,41 +385,11 @@ public Builder setDatanodeFactory(DatanodeFactory factory) {
return this;
}

public Builder setNumOfOzoneManagers(int numOMs) {
this.numOfOMs = numOMs;
return this;
}

public Builder setNumOfActiveOMs(int numActiveOMs) {
this.numOfActiveOMs = numActiveOMs;
return this;
}

public Builder setOMServiceId(String serviceId) {
this.omServiceId = serviceId;
return this;
}

public Builder includeRecon(boolean include) {
this.includeRecon = include;
return this;
}

public Builder setNumOfStorageContainerManagers(int numSCMs) {
this.numOfSCMs = numSCMs;
return this;
}

public Builder setNumOfActiveSCMs(int numActiveSCMs) {
this.numOfActiveSCMs = numActiveSCMs;
return this;
}

public Builder setSCMServiceId(String serviceId) {
this.scmServiceId = serviceId;
return this;
}

/**
* Constructs and returns MiniOzoneCluster.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ public static class Builder extends MiniOzoneClusterImpl.Builder {
private final List<StorageContainerManager> activeSCMs = new ArrayList<>();
private final List<StorageContainerManager> inactiveSCMs = new ArrayList<>();

private String omServiceId;
private int numOfOMs;
private int numOfActiveOMs = ACTIVE_OMS_NOT_SET;

private String scmServiceId;
private int numOfSCMs;
private int numOfActiveSCMs = ACTIVE_SCMS_NOT_SET;

/**
* Creates a new Builder.
*
Expand All @@ -353,6 +361,36 @@ public Builder(OzoneConfiguration conf) {
super(conf);
}

public Builder setNumOfOzoneManagers(int numOMs) {
this.numOfOMs = numOMs;
return this;
}

public Builder setNumOfActiveOMs(int numActiveOMs) {
this.numOfActiveOMs = numActiveOMs;
return this;
}

public Builder setOMServiceId(String serviceId) {
this.omServiceId = serviceId;
return this;
}

public Builder setNumOfStorageContainerManagers(int numSCMs) {
this.numOfSCMs = numSCMs;
return this;
}

public Builder setNumOfActiveSCMs(int numActiveSCMs) {
this.numOfActiveSCMs = numActiveSCMs;
return this;
}

public Builder setSCMServiceId(String serviceId) {
this.scmServiceId = serviceId;
return this;
}

@Override
public MiniOzoneCluster build() throws IOException {
if (numOfActiveOMs > numOfOMs) {
Expand Down Expand Up @@ -402,6 +440,10 @@ public MiniOzoneCluster build() throws IOException {
return cluster;
}

protected int numberOfOzoneManagers() {
return numOfOMs;
}

protected void initOMRatisConf() {
conf.setBoolean(OMConfigKeys.OZONE_OM_RATIS_ENABLE_KEY, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ private static void startCluster()
OzoneManager.setTestSecureOmFlag(true);
MiniOzoneCluster.Builder builder = MiniOzoneCluster.newHABuilder(conf)
.setSCMServiceId("TestSecretKey")
.setNumDatanodes(3)
.setNumOfStorageContainerManagers(3)
.setNumOfOzoneManagers(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ private static void startCluster()
MiniOzoneCluster.Builder builder = MiniOzoneCluster.newHABuilder(conf)
.setSCMServiceId(scmServiceId)
.setOMServiceId(omServiceId)
.setNumDatanodes(3)
.setNumOfStorageContainerManagers(3)
.setNumOfOzoneManagers(3);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ private static void startCluster()
MiniOzoneCluster.Builder builder = MiniOzoneCluster.newHABuilder(conf)
.setSCMServiceId(scmServiceId)
.setOMServiceId(omServiceId)
.setNumDatanodes(3)
.setNumOfStorageContainerManagers(3)
.setNumOfOzoneManagers(3);
cluster = (MiniOzoneHAClusterImpl) builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ private void init() throws Exception {
conf.setInt(OZONE_OM_INIT_DEFAULT_LAYOUT_VERSION, OMLayoutFeature.BUCKET_LAYOUT_SUPPORT.layoutVersion());

cluster = MiniOzoneCluster.newBuilder(conf)
.setNumOfOzoneManagers(3)
.build();

cluster.waitForClusterToBeReady();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public void setup() throws Exception {

cluster = (MiniOzoneHAClusterImpl) MiniOzoneCluster.newHABuilder(conf)
.setOMServiceId(OM_SERVICE_ID)
.setNumDatanodes(1)
.setNumOfOzoneManagers(3)
.setNumDatanodes(1)
.includeRecon(true)
.build();
cluster.waitForClusterToBeReady();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,14 @@
public class TestOzoneContainerUpgradeShell {
private static final Logger LOG =
LoggerFactory.getLogger(TestOzoneContainerUpgradeShell.class);
private static String omServiceId;
private static MiniOzoneCluster cluster = null;
private static OzoneClient client;
private static OzoneConfiguration conf = null;
private static final String VOLUME_NAME = UUID.randomUUID().toString();
private static final String BUCKET_NAME = UUID.randomUUID().toString();

protected static void startCluster() throws Exception {
// Init HA cluster
omServiceId = "om-service-test-upgrade-container1";
final int numDNs = 3;
cluster = MiniOzoneCluster.newBuilder(conf)
.setOMServiceId(omServiceId)
.setNumDatanodes(numDNs)
.build();
cluster.waitForClusterToBeReady();
client = cluster.newClient();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ protected static void startCluster() throws Exception {
omServiceId = "om-service-test1";
final int numDNs = 3;
cluster = MiniOzoneCluster.newBuilder(conf)
.setOMServiceId(omServiceId)
.setNumDatanodes(numDNs)
.build();
cluster.waitForClusterToBeReady();
Expand Down

0 comments on commit 0760aae

Please sign in to comment.