-
Notifications
You must be signed in to change notification settings - Fork 594
HDDS-9279. Basic implementation of OM Follower read #9222
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
Changes from all commits
9fe023f
c19f785
d6285cd
26b2ff0
4cdea9f
9846235
ccbcae6
c41c82c
e085288
daa9763
2ac7ae4
e9a84b8
26dc572
4e01828
4cb7dc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hadoop.ozone.freon; | ||
|
|
||
| import com.codahale.metrics.Timer; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.concurrent.Callable; | ||
| import org.apache.hadoop.hdds.cli.HddsVersionProvider; | ||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.ozone.client.OzoneClient; | ||
| import org.kohsuke.MetaInfServices; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import picocli.CommandLine; | ||
| import picocli.CommandLine.Command; | ||
|
|
||
| /** | ||
| * Data generator tool test om performance. | ||
| */ | ||
| @Command(name = "fr", | ||
| aliases = "follower-reader", | ||
| description = "Read the same keySize from multiple threads.", | ||
| versionProvider = HddsVersionProvider.class, | ||
| mixinStandardHelpOptions = true, | ||
| showDefaultValues = true) | ||
| @MetaInfServices(FreonSubcommand.class) | ||
| public class FollowerReader extends BaseFreonGenerator | ||
| implements Callable<Void> { | ||
|
|
||
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(FollowerReader.class); | ||
|
|
||
| @CommandLine.Option(names = {"-v", "--volume"}, | ||
| description = "Name of the bucket which contains the test data. Will be" | ||
| + " created if missing.", | ||
| defaultValue = "vol1") | ||
| private String volumeName; | ||
|
|
||
| @CommandLine.Option(names = {"-b", "--bucket"}, | ||
| description = "Name of the bucket which contains the test data.", | ||
| defaultValue = "bucket1") | ||
| private String bucketName; | ||
|
|
||
| @CommandLine.Option(names = {"-k", "--key"}, | ||
| description = "Name of the key which contains the test data.", | ||
| defaultValue = "key1") | ||
| private String keyName; | ||
|
|
||
| private String omServiceID = null; | ||
|
|
||
| private Timer timer; | ||
|
|
||
| private final List<OzoneClient> rpcClients = new ArrayList<>(); | ||
|
|
||
| @Override | ||
| public Void call() throws Exception { | ||
| init(); | ||
| OzoneConfiguration ozoneConfiguration = createOzoneConfiguration(); | ||
|
|
||
| for (int i = 0; i < getThreadNo(); i++) { | ||
| OzoneClient rpcClient = createOzoneClient(omServiceID, ozoneConfiguration); | ||
| rpcClients.add(rpcClient); | ||
| } | ||
|
|
||
| timer = getMetrics().timer("follower-read"); | ||
|
|
||
| runTests(this::readKeySize); | ||
| return null; | ||
| } | ||
|
|
||
| private void readKeySize(long counter) throws Exception { | ||
| int clientIdx = (int) (counter % rpcClients.size()); | ||
| timer.time(() -> { | ||
| long unused = rpcClients.get(clientIdx).getObjectStore().getVolume(volumeName) | ||
| .getBucket(bucketName).getKey(keyName).getDataSize(); | ||
| return null; | ||
| }); | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,6 +52,27 @@ public class OzoneManagerRatisServerConfig { | |||||||||
| ) | ||||||||||
| private long retryCacheTimeout = Duration.ofSeconds(300).toMillis(); | ||||||||||
|
|
||||||||||
| @Config(key = "read.option", | ||||||||||
| defaultValue = "DEFAULT", | ||||||||||
| type = ConfigType.STRING, | ||||||||||
| tags = {OZONE, OM, RATIS, PERFORMANCE}, | ||||||||||
| description = "Select the Ratis server read option." + | ||||||||||
| " Possible values are: " + | ||||||||||
| " DEFAULT - Directly query statemachine (non-linearizable). " + | ||||||||||
| " Only the leader can serve read requests. " + | ||||||||||
|
Comment on lines
+61
to
+62
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
IIUC, the current DEFAULT is still linearizable. To avoid confusion, let’s rename the modes to something more explicit—for example:
Then we can add our own parsing that maps these OM-level configs to the corresponding Ratis read options, instead of relying directly on RaftServerConfigKeys.Read.option(...).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently this configuration is using directly from Ratis. If changed, OM Ratis Server won't start normally. The thing is the localLease is not a 1:1 mapping, if locallease condition check doesn't fit, it will fallback to ReadIndex which is linearizable. |
||||||||||
| " LINEARIZABLE - Use ReadIndex (see Raft Paper section 6.4) to maintain linearizability. " + | ||||||||||
| " Both the leader and the followers can serve read requests." | ||||||||||
| ) | ||||||||||
| private String readOption; | ||||||||||
|
|
||||||||||
| @Config(key = "read.leader.lease.enabled", | ||||||||||
| defaultValue = "false", | ||||||||||
| type = ConfigType.BOOLEAN, | ||||||||||
| tags = {OZONE, OM, RATIS, PERFORMANCE}, | ||||||||||
| description = "If we enabled the leader lease on Ratis Leader." | ||||||||||
| ) | ||||||||||
| private boolean readLeaderLeaseEnabled; | ||||||||||
|
|
||||||||||
| public long getLogAppenderWaitTimeMin() { | ||||||||||
| return logAppenderWaitTimeMin; | ||||||||||
| } | ||||||||||
|
|
@@ -67,4 +88,20 @@ public long getRetryCacheTimeout() { | |||||||||
| public void setRetryCacheTimeout(Duration duration) { | ||||||||||
| this.retryCacheTimeout = duration.toMillis(); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public String getReadOption() { | ||||||||||
| return readOption; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public void setReadOption(String option) { | ||||||||||
| this.readOption = option; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public boolean isReadLeaderLeaseEnabled() { | ||||||||||
| return readLeaderLeaseEnabled; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public void setReadLeaderLeaseEnabled(boolean readLeaderLeaseEnabled) { | ||||||||||
| this.readLeaderLeaseEnabled = readLeaderLeaseEnabled; | ||||||||||
| } | ||||||||||
| } | ||||||||||
Uh oh!
There was an error while loading. Please reload this page.