ChenSammi commented on code in PR #3648:
URL: https://github.com/apache/ozone/pull/3648#discussion_r1045964189
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/DownloadAndImportReplicator.java:
##########
@@ -46,36 +60,68 @@ public class DownloadAndImportReplicator implements
ContainerReplicator {
public static final Logger LOG =
LoggerFactory.getLogger(DownloadAndImportReplicator.class);
- private final ContainerSet containerSet;
+ public static final String CONTAINER_COPY_DIR = "container-copy";
+ public static final String CONTAINER_COPY_TMP_DIR = "tmp";
+ private final ConfigurationSource conf;
+ private final ContainerSet containerSet;
private final ContainerController controller;
-
private final ContainerDownloader downloader;
-
private final TarContainerPacker packer;
+ private final MutableVolumeSet volumeSet;
+ private VolumeChoosingPolicy volumeChoosingPolicy;
+ private long containerSize;
+ private Map<HddsVolume, ContainerReader> containerReaderMap;
public DownloadAndImportReplicator(
+ ConfigurationSource conf,
ContainerSet containerSet,
ContainerController controller,
ContainerDownloader downloader,
- TarContainerPacker packer) {
+ TarContainerPacker packer,
+ MutableVolumeSet volumeSet) {
+ this.conf = conf;
this.containerSet = containerSet;
this.controller = controller;
this.downloader = downloader;
this.packer = packer;
+ this.volumeSet = volumeSet;
+ 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);
+
+ this.containerReaderMap = new HashMap<>();
+ for (HddsVolume hddsVolume: getHddsVolumesList()) {
+ containerReaderMap.put(hddsVolume,
+ new ContainerReader(volumeSet, hddsVolume, containerSet, conf,
+ false));
+ }
}
- public void importContainer(long containerID, Path tarFilePath)
- throws IOException {
+ public void importContainer(long containerID, Path tarFilePath,
+ HddsVolume hddsVolume) throws IOException {
+
+ HddsVolume targetVolume = hddsVolume;
+ if (targetVolume == null) {
+ targetVolume = chooseNextVolume();
Review Comment:
Please add a targetVolume not null check here. targetVolume should not be
null in all cases(excluding tests).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]