bharatviswa504 commented on a change in pull request #511: HDDS-1148. After
allocating container, we are not adding to container DB.
URL: https://github.com/apache/hadoop/pull/511#discussion_r259132320
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/SCMContainerManager.java
##########
@@ -360,16 +355,108 @@ public ContainerInfo getMatchingContainer(final long
sizeRequired,
String owner, Pipeline pipeline) {
try {
//TODO: #CLUTIL See if lock is required here
- return containerStateManager
- .getMatchingContainer(sizeRequired, owner, pipelineManager,
- pipeline);
+ NavigableSet<ContainerID> containerIDs =
+ pipelineManager.getContainersInPipeline(pipeline.getId());
+ if (containerIDs == null) {
+ LOG.error("Container list is null for pipeline=", pipeline.getId());
+ return null;
+ }
+
+ containerIDs = getContainersForOwner(containerIDs, owner);
+ if (containerIDs.size() < numContainerPerOwnerInPipeline) {
+ synchronized (pipeline) {
+ // TODO: #CLUTIL Maybe we can add selection logic inside synchronized
+ // as well
+ containerIDs = getContainersForOwner(
+ pipelineManager.getContainersInPipeline(pipeline.getId()),
owner);
+ if (containerIDs.size() < numContainerPerOwnerInPipeline) {
+ ContainerInfo containerInfo =
+ containerStateManager.allocateContainer(pipelineManager, owner,
+ pipeline);
+ // Add to DB
+ addContainerToDB(containerInfo);
+ containerStateManager.updateLastUsedMap(pipeline.getId(),
+ containerInfo.containerID(), owner);
+ return containerInfo;
+ }
+ }
+ }
+
+ ContainerInfo containerInfo =
+ containerStateManager.getMatchingContainer(sizeRequired, owner,
+ pipeline.getId(), containerIDs);
+ if (containerInfo == null) {
+ synchronized (pipeline) {
+ containerInfo =
+ containerStateManager.allocateContainer(pipelineManager, owner,
+ pipeline);
+ // Add to DB
+ addContainerToDB(containerInfo);
+ containerStateManager.updateLastUsedMap(pipeline.getId(),
+ containerInfo.containerID(), owner);
+ }
+ } else {
+ containerStateManager.updateLastUsedMap(pipeline.getId(),
+ containerInfo.containerID(), owner);
+ }
+ // TODO: #CLUTIL cleanup entries in lastUsedMap
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]