-
Notifications
You must be signed in to change notification settings - Fork 625
HDDS-7083. Spread container-copy directories #3648
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 6 commits
db0cf77
ea07251
e5c0a34
75e9f8d
1cc345d
14d3e00
615070d
417fd4b
1ef25a4
4bfa4df
f590482
8cb4030
dfd161d
e551a67
205d6a3
fc6bee4
cc5dcdf
4ecff14
2207a50
a5c34fe
299d0f6
c62d37f
e8f036e
5806f6c
0f1780d
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 |
|---|---|---|
|
|
@@ -28,16 +28,24 @@ | |
| import java.util.concurrent.ExecutionException; | ||
|
|
||
| import org.apache.hadoop.hdds.conf.ConfigurationSource; | ||
| import org.apache.hadoop.hdds.conf.StorageUnit; | ||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
| import org.apache.hadoop.hdds.protocol.DatanodeDetails.Port.Name; | ||
| import org.apache.hadoop.hdds.scm.ScmConfigKeys; | ||
| import org.apache.hadoop.hdds.security.x509.SecurityConfig; | ||
| import org.apache.hadoop.hdds.security.x509.certificate.client.CertificateClient; | ||
| import org.apache.hadoop.ozone.OzoneConfigKeys; | ||
|
|
||
| import com.google.common.annotations.VisibleForTesting; | ||
| import org.apache.hadoop.ozone.container.common.interfaces.VolumeChoosingPolicy; | ||
| import org.apache.hadoop.ozone.container.common.utils.StorageVolumeUtil; | ||
| import org.apache.hadoop.ozone.container.common.volume.HddsVolume; | ||
| import org.apache.hadoop.ozone.container.common.volume.RoundRobinVolumeChoosingPolicy; | ||
| import org.apache.hadoop.ozone.container.common.volume.VolumeSet; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import static org.apache.hadoop.hdds.HddsConfigKeys.HDDS_DATANODE_VOLUME_CHOOSING_POLICY; | ||
|
|
||
| /** | ||
| * Simple ContainerDownloaderImplementation to download the missing container | ||
| * from the first available datanode. | ||
|
|
@@ -50,24 +58,33 @@ public class SimpleContainerDownloader implements ContainerDownloader { | |
| private static final Logger LOG = | ||
| LoggerFactory.getLogger(SimpleContainerDownloader.class); | ||
|
|
||
| private final Path workingDirectory; | ||
| public static final String CONTAINER_COPY_DIR = "container-copy"; | ||
|
Contributor
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. These two fields are not used anymore. |
||
|
|
||
| private ConfigurationSource conf; | ||
|
Contributor
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. Looks like this conf is not used anymore after initialized. |
||
| private final SecurityConfig securityConfig; | ||
| private final CertificateClient certClient; | ||
| private final VolumeSet volumeSet; | ||
| private VolumeChoosingPolicy volumeChoosingPolicy = null; | ||
| private long containerSize; | ||
|
|
||
| public SimpleContainerDownloader( | ||
| ConfigurationSource conf, CertificateClient certClient) { | ||
| ConfigurationSource conf, CertificateClient certClient, | ||
| VolumeSet volumeSet) { | ||
|
|
||
| String workDirString = | ||
| conf.get(OzoneConfigKeys.OZONE_CONTAINER_COPY_WORKDIR); | ||
|
|
||
| if (workDirString == null) { | ||
| workingDirectory = Paths.get(System.getProperty("java.io.tmpdir")) | ||
| .resolve("container-copy"); | ||
| } else { | ||
| workingDirectory = Paths.get(workDirString); | ||
| } | ||
| this.conf = conf; | ||
| securityConfig = new SecurityConfig(conf); | ||
| this.certClient = certClient; | ||
| this.volumeSet = volumeSet; | ||
|
Contributor
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. @symious , the new proposed flow should be,
So not only SimpleContainerDownloader, but also the container import flow should be updated.
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. I see, should we apply the new proposal in a new ticket or the current one?
Contributor
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. We can implement the proposal in more than one tickets. If so, please change the JIRA to a feature JIRA and create sub JIRAs for different tasks.
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. Noted with thanks. |
||
| try { | ||
| this.volumeChoosingPolicy = conf.getClass( | ||
| HDDS_DATANODE_VOLUME_CHOOSING_POLICY, RoundRobinVolumeChoosingPolicy | ||
| .class, VolumeChoosingPolicy.class).newInstance(); | ||
| } catch (Exception e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| this.containerSize = (long) conf.getStorageSize( | ||
| ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE, | ||
| ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_DEFAULT, StorageUnit.BYTES); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -118,7 +135,7 @@ protected CompletableFuture<Path> downloadContainer( | |
| GrpcReplicationClient grpcReplicationClient = | ||
| new GrpcReplicationClient(datanode.getIpAddress(), | ||
| datanode.getPort(Name.REPLICATION).getValue(), | ||
| workingDirectory, securityConfig, certClient); | ||
| getWorkingDirectory(), securityConfig, certClient); | ||
| result = grpcReplicationClient.download(containerId) | ||
| .whenComplete((r, ex) -> { | ||
| try { | ||
|
|
@@ -135,4 +152,21 @@ protected CompletableFuture<Path> downloadContainer( | |
| public void close() { | ||
| // noop | ||
| } | ||
|
|
||
| public Path getWorkingDirectory() { | ||
| Path defaultWorkingDirectory = | ||
| Paths.get(System.getProperty("java.io.tmpdir")); | ||
|
Contributor
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.
|
||
| try { | ||
| // Use containerSize * 2 to store source and dest file | ||
| HddsVolume volume = volumeChoosingPolicy.chooseVolume( | ||
| StorageVolumeUtil.getHddsVolumesList(volumeSet.getVolumesList()), | ||
| containerSize * 2); | ||
| return Paths.get(volume.getStorageDir().getParent()).resolve("tmp") | ||
| .resolve(CONTAINER_COPY_DIR); | ||
| } catch (IOException e) { | ||
| LOG.error("Exception when spreading copy directory, using default " + | ||
| "working directory {}", defaultWorkingDirectory.toAbsolutePath(), e); | ||
| } | ||
| return defaultWorkingDirectory; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This configuration is deprecated. Temporary sub directory under each hdds.datanode.dir will be used during the container replication between datanodes to save the downloaded container(in compressed format).