AvailableSpaceBlockPlacementPolicy extends
    BlockPlacementPolicyDefault { @Override protected DatanodeDescriptor chooseDataNode(final String scope, final Collection<Node> excludedNode, StorageType type) { Preconditions.checkArgument(clusterMap instanceof DFSNetworkTopology); DFSNetworkTopology dfsClusterMap = (DFSNetworkTopology)clusterMap; DatanodeDescriptor a = (DatanodeDescriptor) dfsClusterMap .chooseRandomWithStorageTypeTwoTrial(scope, excludedNode, type); DatanodeDescriptor b = (DatanodeDescriptor) dfsClusterMap .chooseRandomWithStorageTypeTwoTrial(scope, excludedNode, type); return select(a, b, false); }  @Override void initialize(Configuration conf, FSClusterStats stats,
      NetworkTopology clusterMap, Host2NodesMap host2datanodeMap);  }
@Test public void testChooseDataNode() { Collection<Node> allNodes = new ArrayList<>(dataNodes.length); Collections.addAll(allNodes, dataNodes); if (placementPolicy instanceof AvailableSpaceBlockPlacementPolicy) { ((AvailableSpaceBlockPlacementPolicy) placementPolicy) .chooseDataNode("~", allNodes); } }