Search in sources :

Example 1 with ClusterNotFoundException

use of com.hortonworks.streamline.streams.cluster.exception.ClusterNotFoundException in project streamline by hortonworks.

the class AbstractBundleHintProvider method provide.

@Override
public Map<Long, BundleHintsResponse> provide(Namespace namespace, SecurityContext securityContext, Subject subject) {
    Map<Long, BundleHintsResponse> hintMap = new HashMap<>();
    Collection<NamespaceServiceClusterMap> serviceMappings = environmentService.listServiceClusterMapping(namespace.getId(), getServiceName());
    for (NamespaceServiceClusterMap mapping : serviceMappings) {
        Long clusterId = mapping.getClusterId();
        Cluster cluster = environmentService.getCluster(clusterId);
        if (cluster == null) {
            throw new RuntimeException(new ClusterNotFoundException(clusterId));
        }
        BundleHintsResponse response = new BundleHintsResponse(cluster, getHintsOnCluster(cluster, securityContext, subject));
        hintMap.put(clusterId, response);
    }
    return hintMap;
}
Also used : ClusterNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ClusterNotFoundException) HashMap(java.util.HashMap) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)

Example 2 with ClusterNotFoundException

use of com.hortonworks.streamline.streams.cluster.exception.ClusterNotFoundException in project streamline by hortonworks.

the class AbstractSecureBundleHintProvider method provide.

@Override
public Map<Long, BundleHintsResponse> provide(Namespace namespace, SecurityContext securityContext, Subject subject) {
    Map<Long, BundleHintsResponse> hintMap = new HashMap<>();
    Collection<NamespaceServiceClusterMap> serviceMappings = environmentService.listServiceClusterMapping(namespace.getId(), getServiceName());
    for (NamespaceServiceClusterMap mapping : serviceMappings) {
        Long clusterId = mapping.getClusterId();
        Cluster cluster = environmentService.getCluster(clusterId);
        if (cluster == null) {
            throw new RuntimeException(new ClusterNotFoundException(clusterId));
        }
        BundleHintsResponse response = new SecureBundleHintsResponse(cluster, getSecurity(cluster, securityContext, subject), getHintsOnCluster(cluster, securityContext, subject));
        hintMap.put(clusterId, response);
    }
    return hintMap;
}
Also used : ClusterNotFoundException(com.hortonworks.streamline.streams.cluster.exception.ClusterNotFoundException) HashMap(java.util.HashMap) Cluster(com.hortonworks.streamline.streams.cluster.catalog.Cluster) NamespaceServiceClusterMap(com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)

Aggregations

Cluster (com.hortonworks.streamline.streams.cluster.catalog.Cluster)2 NamespaceServiceClusterMap (com.hortonworks.streamline.streams.cluster.catalog.NamespaceServiceClusterMap)2 ClusterNotFoundException (com.hortonworks.streamline.streams.cluster.exception.ClusterNotFoundException)2 HashMap (java.util.HashMap)2