Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDDS-1490. Support configurable container placement policy through 'o… (
#903)
- Loading branch information
Showing
24 changed files
with
380 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
...src/main/java/org/apache/hadoop/hdds/scm/container/placement/algorithms/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* 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.hdds.scm.container.placement.algorithms; | ||
/** | ||
Contains container placement policy interface definition. | ||
**/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...pache/hadoop/hdds/scm/container/placement/algorithms/ContainerPlacementPolicyFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* 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.hdds.scm.container.placement.algorithms; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hdds.scm.ScmConfigKeys; | ||
import org.apache.hadoop.hdds.scm.exceptions.SCMException; | ||
import org.apache.hadoop.hdds.scm.net.NetworkTopology; | ||
import org.apache.hadoop.hdds.scm.node.NodeManager; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.lang.reflect.Constructor; | ||
|
||
/** | ||
* A factory to create container placement instance based on configuration | ||
* property ozone.scm.container.placement.classname. | ||
*/ | ||
public final class ContainerPlacementPolicyFactory { | ||
private static final Logger LOG = | ||
LoggerFactory.getLogger(ContainerPlacementPolicyFactory.class); | ||
|
||
private ContainerPlacementPolicyFactory() { | ||
} | ||
|
||
public static ContainerPlacementPolicy getPolicy(Configuration conf, | ||
final NodeManager nodeManager, NetworkTopology clusterMap, | ||
final boolean fallback) throws SCMException{ | ||
final Class<? extends ContainerPlacementPolicy> placementClass = conf | ||
.getClass(ScmConfigKeys.OZONE_SCM_CONTAINER_PLACEMENT_IMPL_KEY, | ||
SCMContainerPlacementRackAware.class, | ||
ContainerPlacementPolicy.class); | ||
Constructor<? extends ContainerPlacementPolicy> constructor; | ||
try { | ||
constructor = placementClass.getDeclaredConstructor(NodeManager.class, | ||
Configuration.class, NetworkTopology.class, boolean.class); | ||
} catch (NoSuchMethodException e) { | ||
String msg = "Failed to find constructor(NodeManager, Configuration, " + | ||
"NetworkTopology, boolean) for class " + | ||
placementClass.getCanonicalName(); | ||
LOG.error(msg); | ||
throw new SCMException(msg, | ||
SCMException.ResultCodes.FAILED_TO_INIT_CONTAINER_PLACEMENT_POLICY); | ||
} | ||
|
||
try { | ||
return constructor.newInstance(nodeManager, conf, clusterMap, fallback); | ||
} catch (Exception e) { | ||
throw new RuntimeException("Failed to instantiate class " + | ||
placementClass.getCanonicalName() + " for " + e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.