@Override
public Set<Resource> getResources(Request request, Predicate predicate)
throws SystemException, UnsupportedPropertyException,
NoSuchResourceException, NoSuchParentResourceException {
final RootServiceHostComponentRequest rootServiceComponentRequest = getRequest(PredicateHelper.getProperties(predicate));
Set<String> requestedIds = getRequestPropertyIds(request, predicate);
Set<RootServiceHostComponentResponse> responses = getResources(new Command<Set<RootServiceHostComponentResponse>>() {
@Override
public Set<RootServiceHostComponentResponse> invoke() throws AmbariException {
return getManagementController().getRootServiceHostComponents(
Collections.singleton(rootServiceComponentRequest));
}
});
Set<Resource> resources = new HashSet<Resource>();
for (RootServiceHostComponentResponse response : responses) {
Resource resource = new ResourceImpl(Resource.Type.RootServiceHostComponent);
setResourceProperty(resource, SERVICE_NAME_PROPERTY_ID,
rootServiceComponentRequest.getServiceName(), requestedIds);
setResourceProperty(resource, HOST_NAME_PROPERTY_ID,
response.getHostName(), requestedIds);
setResourceProperty(resource, COMPONENT_NAME_PROPERTY_ID,