class InventoryUtil {

	public static Map<String,List<Cluster>> fetchEMRInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){

		Map<String,List<Cluster>> clusterList = new LinkedHashMap<>();
		String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"EMR\" , \"region\":\"" ;
		for(Region region : RegionUtils.getRegions()){
			try{
				if(!skipRegions.contains(region.getName())){
					AmazonElasticMapReduce emrClient = AmazonElasticMapReduceClientBuilder.standard().
					 	withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
					List<ClusterSummary> clusters = new ArrayList<>();
					String marker = null;
					ListClustersResult clusterResult ;
					do{
						clusterResult = emrClient.listClusters(new ListClustersRequest().withMarker(marker));
						clusters.addAll(clusterResult.getClusters());
						marker = clusterResult.getMarker();
					}while(marker!=null);

					List<Cluster> clustersList = new ArrayList<>();
					clusters.forEach(cluster ->
						{
							DescribeClusterResult descClstrRslt = emrClient.describeCluster(new DescribeClusterRequest().withClusterId(cluster.getId()));
							clustersList.add(descClstrRslt.getCluster());
						});

					if( !clustersList.isEmpty() ){
						log.debug(InventoryConstants.ACCOUNT + accountId +" Type : EMR "+region.getName() + " >> "+clustersList.size());
						clusterList.put(accountId+delimiter+accountName+delimiter+region.getName(),clustersList);
					}
				}
			}catch(Exception e){
				if(region.isServiceSupported(AmazonElasticMapReduce.ENDPOINT_PREFIX)){
					log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}");
					ErrorManageUtil.uploadError(accountId,region.getName(),"emr",e.getMessage());
				}
			}
		}
		return clusterList;
	}

	private  InventoryUtil();

}