Skip to content
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 @@ -433,7 +433,7 @@ public final class ScmConfigKeys {
// SCM Ratis Leader Election configurations
public static final String
OZONE_SCM_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY =
"ozone.scm.leader.election.minimum.timeout.duration";
"ozone.scm.ratis.leader.election.minimum.timeout.duration";
public static final TimeDuration
OZONE_SCM_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_DEFAULT =
TimeDuration.valueOf(1, TimeUnit.SECONDS);
Expand Down
4 changes: 2 additions & 2 deletions hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@
<name>ozone.scm.ratis.server.request.timeout</name>
<value>3s</value>
<tag>OZONE, SCM, HA, RATIS</tag>
<description>The timeout duration for SCM's ratis server request .</description>
<description>The timeout duration for SCM's ratis server request.</description>
</property>

<property>
Expand All @@ -2054,7 +2054,7 @@
</property>

<property>
<name>ozone.scm.leader.election.minimum.timeout.duration</name>
<name>ozone.scm.ratis.leader.election.minimum.timeout.duration</name>
<value>1s</value>
<tag>OZONE, SCM, HA, RATIS</tag>
<description>The minimum timeout duration for SCM ratis leader election.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,10 @@
*/
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;

/**
* If type == SIZE the unit should be defined with this attribute.
*/
StorageUnit sizeUnit() default StorageUnit.BYTES;

ConfigTag[] tags();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ public enum ConfigTag {
STANDALONE,
S3GATEWAY,
DATANODE,
RECON
RECON,
HA
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public static <T> void injectConfigurationToObject(ConfigurationSource from,
forcedFieldSet(field, configuration,
from.getTimeDuration(key, "0s", configAnnotation.timeUnit()));
break;
case SIZE:
forcedFieldSet(field, configuration,
from.getStorageSize(key, "0B", configAnnotation.sizeUnit()));
break;
default:
throw new ConfigurationException(
"Unsupported ConfigType " + type + " on " + fieldLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public final class StorageContainerManager extends ServiceRuntimeInfoImpl
*
* @param conf configuration
*/
public StorageContainerManager(OzoneConfiguration conf)
private StorageContainerManager(OzoneConfiguration conf)
throws IOException, AuthenticationException {
// default empty configurator means default managers will be used.
this(conf, new SCMConfigurator());
Expand All @@ -236,7 +236,7 @@ public StorageContainerManager(OzoneConfiguration conf)
* @param conf - Configuration
* @param configurator - configurator
*/
public StorageContainerManager(OzoneConfiguration conf,
private StorageContainerManager(OzoneConfiguration conf,
SCMConfigurator configurator)
throws IOException, AuthenticationException {
super(HddsVersionInfo.HDDS_VERSION_INFO);
Expand Down Expand Up @@ -269,14 +269,9 @@ public StorageContainerManager(OzoneConfiguration conf,
loginAsSCMUser(conf);
}

if (SCMHAUtils.isSCMHAEnabled(conf)) {
this.scmRatisSnapshotInfo = new SCMRatisSnapshotInfo(
scmStorageConfig.getCurrentDir());
this.scmRatisSnapshotDir = SCMHAUtils.createSCMRatisDir(conf);
initializeRatisServer();
} else {
scmRatisServer = null;
}
this.scmRatisSnapshotInfo = new SCMRatisSnapshotInfo(
scmStorageConfig.getCurrentDir());
this.scmRatisSnapshotDir = SCMHAUtils.createSCMRatisDir(conf);

// Creates the SCM DBs or opens them if it exists.
// A valid pointer to the store is required by all the other services below.
Expand Down Expand Up @@ -387,6 +382,38 @@ public StorageContainerManager(OzoneConfiguration conf,
registerMetricsSource(this);
}

/**
* Create an SCM instance based on the supplied configuration.
*
* @param conf HDDS configuration
* @param configurator SCM configurator
* @return SCM instance
* @throws IOException, AuthenticationException
*/
public static StorageContainerManager createSCM(
OzoneConfiguration conf, SCMConfigurator configurator)
throws IOException, AuthenticationException {
StorageContainerManager scm = new StorageContainerManager(
conf, configurator);
if (SCMHAUtils.isSCMHAEnabled(conf) && scm.getScmRatisServer() == null) {
SCMRatisServer scmRatisServer = initializeRatisServer(conf, scm);
scm.setScmRatisServer(scmRatisServer);
}
return scm;
}

/**
* Create an SCM instance based on the supplied configuration.
*
* @param conf HDDS configuration
* @return SCM instance
* @throws IOException, AuthenticationException
*/
public static StorageContainerManager createSCM(OzoneConfiguration conf)
throws IOException, AuthenticationException {
return createSCM(conf, new SCMConfigurator());
}

/**
* This function initializes the following managers. If the configurator
* specifies a value, we will use it, else we will use the default value.
Expand Down Expand Up @@ -633,18 +660,6 @@ public static RPC.Server startRpcServer(
return rpcServer;
}

/**
* Create an SCM instance based on the supplied configuration.
*
* @param conf HDDS configuration
* @return SCM instance
* @throws IOException, AuthenticationException
*/
public static StorageContainerManager createSCM(OzoneConfiguration conf)
throws IOException, AuthenticationException {
return new StorageContainerManager(conf);
}

/**
* Routine to set up the Version info for StorageContainerManager.
*
Expand Down Expand Up @@ -1137,25 +1152,31 @@ public NetworkTopology getClusterMap() {
return this.clusterMap;
}

private void initializeRatisServer() throws IOException {
if (scmRatisServer == null) {
SCMNodeDetails scmNodeDetails = SCMNodeDetails
.initStandAlone(configuration);
//TODO enable Ratis ring
scmRatisServer = SCMRatisServer.newSCMRatisServer(configuration, this,
scmNodeDetails, Collections.EMPTY_LIST);
if (scmRatisServer != null) {
LOG.info("SCM Ratis server initialized at port {}",
scmRatisServer.getServerPort());
}
}
private static SCMRatisServer initializeRatisServer(
OzoneConfiguration conf, StorageContainerManager scm) throws IOException {
SCMNodeDetails scmNodeDetails = SCMNodeDetails
.initStandAlone(conf);
//TODO enable Ratis group
SCMRatisServer scmRatisServer = SCMRatisServer.newSCMRatisServer(
conf.getObject(SCMRatisServer.SCMRatisServerConfiguration.class),
scm, scmNodeDetails, Collections.EMPTY_LIST,
SCMRatisServer.getSCMRatisDirectory(conf));
if (scmRatisServer != null) {
LOG.info("SCM Ratis server initialized at port {}",
scmRatisServer.getServerPort());
} // TODO error handling for scmRatisServer creation failure
return scmRatisServer;
}

@VisibleForTesting
public SCMRatisServer getScmRatisServer() {
return scmRatisServer;
}

public void setScmRatisServer(SCMRatisServer scmRatisServer) {
this.scmRatisServer = scmRatisServer;
}

@VisibleForTesting
public SCMRatisSnapshotInfo getSnapshotInfo() {
return scmRatisSnapshotInfo;
Expand Down
Loading