ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject [02/51] [partial] AMBARI-7621. Import initial contribution for Ambari support on Windows to branch-windows-dev. (Jayush Luniya and Florian Barca via yusaku)
Date Tue, 07 Oct 2014 22:52:30 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
index 1442a0c..9cef695 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/StackVersionResourceProvider.java
@@ -58,9 +58,6 @@ public class StackVersionResourceProvider extends ReadOnlyResourceProvider {
 
   private static final String STACK_ACTIVE_PROPERTY_ID = PropertyHelper
       .getPropertyId("Versions", "active");
-  
-  private static final String STACK_CONFIG_TYPES = PropertyHelper
-      .getPropertyId("Versions", "config_types");
 
   private static Set<String> pkPropertyIds = new HashSet<String>(
       Arrays.asList(new String[] { STACK_NAME_PROPERTY_ID,
@@ -112,9 +109,6 @@ public class StackVersionResourceProvider extends ReadOnlyResourceProvider {
 
       setResourceProperty(resource, STACK_PARENT_PROPERTY_ID,
         response.getParentVersion(), requestedIds);
-      
-      setResourceProperty(resource, STACK_CONFIG_TYPES,
-          response.getConfigTypes(), requestedIds);
 
       resources.add(resource);
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java
index 1806b78..79a4f05 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/TaskResourceProvider.java
@@ -57,8 +57,6 @@ class TaskResourceProvider extends AbstractControllerResourceProvider {
   protected static final String TASK_EXIT_CODE_PROPERTY_ID    = PropertyHelper.getPropertyId("Tasks", "exit_code");
   protected static final String TASK_STDERR_PROPERTY_ID       = PropertyHelper.getPropertyId("Tasks", "stderr");
   protected static final String TASK_STOUT_PROPERTY_ID        = PropertyHelper.getPropertyId("Tasks", "stdout");
-  protected static final String TASK_OUTPUTLOG_PROPERTY_ID    = PropertyHelper.getPropertyId("Tasks", "output_log");
-  protected static final String TASK_ERRORLOG_PROPERTY_ID     = PropertyHelper.getPropertyId("Tasks", "error_log");
   protected static final String TASK_STRUCT_OUT_PROPERTY_ID   = PropertyHelper.getPropertyId("Tasks", "structured_out");
   protected static final String TASK_START_TIME_PROPERTY_ID   = PropertyHelper.getPropertyId("Tasks", "start_time");
   protected static final String TASK_END_TIME_PROPERTY_ID     = PropertyHelper.getPropertyId("Tasks", "end_time");
@@ -155,8 +153,6 @@ class TaskResourceProvider extends AbstractControllerResourceProvider {
         setResourceProperty(resource, TASK_EXIT_CODE_PROPERTY_ID, response.getExitCode(), requestedIds);
         setResourceProperty(resource, TASK_STDERR_PROPERTY_ID, response.getStderr(), requestedIds);
         setResourceProperty(resource, TASK_STOUT_PROPERTY_ID, response.getStdout(), requestedIds);
-        setResourceProperty(resource, TASK_OUTPUTLOG_PROPERTY_ID, response.getOutputLog(), requestedIds);
-        setResourceProperty(resource, TASK_ERRORLOG_PROPERTY_ID, response.getErrorLog(), requestedIds);
         setResourceProperty(resource, TASK_STRUCT_OUT_PROPERTY_ID, parseStructuredOutput(response.getStructuredOut()), requestedIds);
         setResourceProperty(resource, TASK_START_TIME_PROPERTY_ID, response.getStartTime(), requestedIds);
         setResourceProperty(resource, TASK_END_TIME_PROPERTY_ID, response.getEndTime(), requestedIds);

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
index 1b57c84..2b32d11 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLStreamProvider.java
@@ -218,8 +218,4 @@ public class URLStreamProvider implements StreamProvider {
  
     return connection;
   }
-
-  public AppCookieManager getAppCookieManager() {
-    return appCookieManager;
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
index 35f9db5..3c0a7cc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/UserResourceProvider.java
@@ -25,6 +25,7 @@ import org.apache.ambari.server.controller.spi.*;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -38,12 +39,11 @@ class UserResourceProvider extends AbstractControllerResourceProvider {
 
   // Users
   protected static final String USER_USERNAME_PROPERTY_ID     = PropertyHelper.getPropertyId("Users", "user_name");
+  protected static final String USER_ROLES_PROPERTY_ID        = PropertyHelper.getPropertyId("Users", "roles");
   protected static final String USER_PASSWORD_PROPERTY_ID     = PropertyHelper.getPropertyId("Users", "password");
   protected static final String USER_OLD_PASSWORD_PROPERTY_ID = PropertyHelper.getPropertyId("Users", "old_password");
   protected static final String USER_LDAP_USER_PROPERTY_ID    = PropertyHelper.getPropertyId("Users", "ldap_user");
   protected static final String USER_ACTIVE_PROPERTY_ID       = PropertyHelper.getPropertyId("Users", "active");
-  protected static final String USER_GROUPS_PROPERTY_ID       = PropertyHelper.getPropertyId("Users", "groups");
-  protected static final String USER_ADMIN_PROPERTY_ID        = PropertyHelper.getPropertyId("Users", "admin");
 
   private static Set<String> pkPropertyIds =
       new HashSet<String>(Arrays.asList(new String[]{
@@ -116,18 +116,15 @@ class UserResourceProvider extends AbstractControllerResourceProvider {
       setResourceProperty(resource, USER_USERNAME_PROPERTY_ID,
           userResponse.getUsername(), requestedIds);
 
+      setResourceProperty(resource, USER_ROLES_PROPERTY_ID,
+          userResponse.getRoles(), requestedIds);
+
       setResourceProperty(resource, USER_LDAP_USER_PROPERTY_ID,
           userResponse.isLdapUser(), requestedIds);
 
       setResourceProperty(resource, USER_ACTIVE_PROPERTY_ID,
           userResponse.isActive(), requestedIds);
 
-      setResourceProperty(resource, USER_GROUPS_PROPERTY_ID,
-          userResponse.getGroups(), requestedIds);
-
-      setResourceProperty(resource, USER_ADMIN_PROPERTY_ID,
-          userResponse.isAdmin(), requestedIds);
-
       resources.add(resource);
     }
 
@@ -193,12 +190,17 @@ class UserResourceProvider extends AbstractControllerResourceProvider {
     request.setPassword((String) properties.get(USER_PASSWORD_PROPERTY_ID));
     request.setOldPassword((String) properties.get(USER_OLD_PASSWORD_PROPERTY_ID));
 
-    if (null != properties.get(USER_ACTIVE_PROPERTY_ID)) {
-      request.setActive(Boolean.valueOf(properties.get(USER_ACTIVE_PROPERTY_ID).toString()));
+    // TODO - support array/sets directly out of the request
+    if (null != properties.get(USER_ROLES_PROPERTY_ID)) {
+      HashSet<String> roles = new HashSet<String>();
+
+      Collections.addAll(roles, ((String) properties.get(USER_ROLES_PROPERTY_ID)).split(","));
+
+      request.setRoles(roles);
     }
 
-    if (null != properties.get(USER_ADMIN_PROPERTY_ID)) {
-      request.setAdmin(Boolean.valueOf(properties.get(USER_ADMIN_PROPERTY_ID).toString()));
+    if (null != properties.get(USER_ACTIVE_PROPERTY_ID)) {
+      request.setActive(Boolean.valueOf(properties.get(USER_ACTIVE_PROPERTY_ID).toString()));
     }
 
     return request;

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java
deleted file mode 100644
index d77cf7d..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ValidationResourceProvider.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- * 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.ambari.server.controller.internal;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorException;
-import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequest;
-import org.apache.ambari.server.api.services.stackadvisor.StackAdvisorRequestException;
-import org.apache.ambari.server.api.services.stackadvisor.validations.ValidationResponse;
-import org.apache.ambari.server.api.services.stackadvisor.validations.ValidationResponse.ValidationItem;
-import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.RequestStatus;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.Resource.Type;
-import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
-
-public class ValidationResourceProvider extends StackAdvisorResourceProvider {
-
-  protected static final String VALIDATION_ID_PROPERTY_ID = PropertyHelper.getPropertyId(
-      "Validation", "id");
-  protected static final String VALIDATE_PROPERTY_ID = "validate";
-
-  protected static final String ITEMS_PROPERTY_ID = "items";
-  protected static final String ITEMS_TYPE_PROPERTY_ID = "type";
-  protected static final String ITEMS_LEVE_PROPERTY_ID = "level";
-  protected static final String ITEMS_MESSAGE_PROPERTY_ID = "message";
-  protected static final String ITEMS_COMPONENT_NAME_PROPERTY_ID = "component-name";
-  protected static final String ITEMS_HOST_PROPERTY_ID = "host";
-  protected static final String ITEMS_CONFIG_TYPE_PROPERTY_ID = "config-type";
-  protected static final String ITEMS_CONFIG_NAME_PROPERTY_ID = "config-name";
-
-  private static Set<String> pkPropertyIds = new HashSet<String>(
-      Arrays.asList(new String[] { VALIDATION_ID_PROPERTY_ID }));
-
-  protected ValidationResourceProvider(Set<String> propertyIds, Map<Type, String> keyPropertyIds,
-      AmbariManagementController managementController) {
-    super(propertyIds, keyPropertyIds, managementController);
-  }
-
-  @Override
-  protected String getRequestTypePropertyId() {
-    return VALIDATE_PROPERTY_ID;
-  }
-
-  @Override
-  public RequestStatus createResources(final Request request) throws SystemException,
-      UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException {
-    StackAdvisorRequest validationRequest = prepareStackAdvisorRequest(request);
-
-    final ValidationResponse response;
-    try {
-      response = saHelper.validate(validationRequest);
-    } catch (StackAdvisorRequestException e) {
-      LOG.warn("Error occurred during validation", e);
-      throw new IllegalArgumentException(e.getMessage(), e);
-    } catch (StackAdvisorException e) {
-      LOG.warn("Error occurred during validation", e);
-      throw new SystemException(e.getMessage(), e);
-    }
-
-    Resource validation = createResources(new Command<Resource>() {
-      @Override
-      public Resource invoke() throws AmbariException {
-
-        Resource resource = new ResourceImpl(Resource.Type.Validation);
-        setResourceProperty(resource, VALIDATION_ID_PROPERTY_ID, response.getId(), getPropertyIds());
-        setResourceProperty(resource, STACK_NAME_PROPERTY_ID, response.getVersion().getStackName(), getPropertyIds());
-        setResourceProperty(resource, STACK_VERSION_PROPERTY_ID, response.getVersion().getStackVersion(), getPropertyIds());
-
-        List<Map<String, Object>> listItemProps = new ArrayList<Map<String, Object>>();
-
-        Set<ValidationItem> items = response.getItems();
-        for (ValidationItem item : items) {
-          Map<String, Object> mapItemProps = new HashMap<String, Object>();
-          mapItemProps.put(ITEMS_TYPE_PROPERTY_ID, item.getType());
-          mapItemProps.put(ITEMS_LEVE_PROPERTY_ID, item.getLevel());
-          mapItemProps.put(ITEMS_MESSAGE_PROPERTY_ID, item.getMessage());
-
-          if (item.getComponentName() != null) {
-            mapItemProps.put(ITEMS_COMPONENT_NAME_PROPERTY_ID, item.getComponentName());
-          }
-          if (item.getHost() != null) {
-            mapItemProps.put(ITEMS_HOST_PROPERTY_ID, item.getHost());
-          }
-          if (item.getConfigType() != null) {
-            mapItemProps.put(ITEMS_CONFIG_TYPE_PROPERTY_ID, item.getConfigType());
-            mapItemProps.put(ITEMS_CONFIG_NAME_PROPERTY_ID, item.getConfigName());
-          }
-          listItemProps.add(mapItemProps);
-        }
-        setResourceProperty(resource, ITEMS_PROPERTY_ID, listItemProps, getPropertyIds());
-
-        return resource;
-      }
-    });
-    notifyCreate(Resource.Type.Validation, request);
-
-    Set<Resource> resources = new HashSet<Resource>(Arrays.asList(validation));
-    return new RequestStatusImpl(null, resources);
-  }
-
-  @Override
-  protected Set<String> getPKPropertyIds() {
-    return pkPropertyIds;
-  }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
index 9a48b41..5b48679 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewInstanceResourceProvider.java
@@ -19,7 +19,6 @@
 package org.apache.ambari.server.controller.internal;
 
 import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.DuplicateResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.NoSuchResourceException;
 import org.apache.ambari.server.controller.spi.Predicate;
@@ -34,7 +33,6 @@ import org.apache.ambari.server.orm.entities.ViewEntity;
 import org.apache.ambari.server.orm.entities.ViewInstanceDataEntity;
 import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
 import org.apache.ambari.server.orm.entities.ViewInstancePropertyEntity;
-import org.apache.ambari.server.orm.entities.ViewParameterEntity;
 import org.apache.ambari.server.view.ViewRegistry;
 
 import java.util.Collection;
@@ -64,7 +62,6 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
   public static final String PROPERTIES_PROPERTY_ID    = "ViewInstanceInfo/properties";
   public static final String DATA_PROPERTY_ID          = "ViewInstanceInfo/instance_data";
   public static final String CONTEXT_PATH_PROPERTY_ID  = "ViewInstanceInfo/context_path";
-  public static final String STATIC_PROPERTY_ID        = "ViewInstanceInfo/static";
 
   /**
    * Property prefix values.
@@ -98,7 +95,6 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
     propertyIds.add(PROPERTIES_PROPERTY_ID);
     propertyIds.add(DATA_PROPERTY_ID);
     propertyIds.add(CONTEXT_PATH_PROPERTY_ID);
-    propertyIds.add(STATIC_PROPERTY_ID);
   }
 
   // ----- Constructors ------------------------------------------------------
@@ -145,17 +141,12 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
       String instanceName = (String) propertyMap.get(INSTANCE_NAME_PROPERTY_ID);
 
       for (ViewEntity viewDefinition : viewRegistry.getDefinitions()){
-        // do not report instances for views that are not loaded.
-        if (viewDefinition.isDeployed()){
-          if (viewName == null || viewName.equals(viewDefinition.getCommonName())) {
-            for (ViewInstanceEntity viewInstanceDefinition : viewRegistry.getInstanceDefinitions(viewDefinition)) {
-              if (instanceName == null || instanceName.equals(viewInstanceDefinition.getName())) {
-                if (viewVersion == null || viewVersion.equals(viewDefinition.getVersion())) {
-                  if (includeInstance(viewInstanceDefinition, true)) {
-                    Resource resource = toResource(viewInstanceDefinition, requestedIds);
-                    resources.add(resource);
-                  }
-                }
+        if (viewName == null || viewName.equals(viewDefinition.getCommonName())) {
+          for (ViewInstanceEntity viewInstanceDefinition : viewRegistry.getInstanceDefinitions(viewDefinition)) {
+            if (instanceName == null || instanceName.equals(viewInstanceDefinition.getName())) {
+              if (viewVersion == null || viewVersion.equals(viewDefinition.getVersion())) {
+                Resource resource = toResource(viewInstanceDefinition, requestedIds);
+                resources.add(resource);
               }
             }
           }
@@ -206,7 +197,7 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
   // ----- helper methods ----------------------------------------------------
 
   // Convert an instance entity to a resource
-  protected Resource toResource(ViewInstanceEntity viewInstanceEntity, Set<String> requestedIds) {
+  private Resource toResource(ViewInstanceEntity viewInstanceEntity, Set<String> requestedIds) {
     Resource   resource   = new ResourceImpl(Resource.Type.ViewInstance);
     ViewEntity viewEntity = viewInstanceEntity.getViewEntity();
 
@@ -220,26 +211,17 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
     setResourceProperty(resource, LABEL_PROPERTY_ID, viewInstanceEntity.getLabel(), requestedIds);
     setResourceProperty(resource, DESCRIPTION_PROPERTY_ID, viewInstanceEntity.getDescription(), requestedIds);
     setResourceProperty(resource, VISIBLE_PROPERTY_ID, viewInstanceEntity.isVisible(), requestedIds);
-    setResourceProperty(resource, STATIC_PROPERTY_ID, viewInstanceEntity.isXmlDriven(), requestedIds);
     Map<String, String> properties = new HashMap<String, String>();
 
     for (ViewInstancePropertyEntity viewInstancePropertyEntity : viewInstanceEntity.getProperties()) {
       properties.put(viewInstancePropertyEntity.getName(), viewInstancePropertyEntity.getValue());
     }
-    for (ViewParameterEntity viewParameterEntity : viewEntity.getParameters()) {
-      if (!properties.containsKey(viewParameterEntity.getName())) {
-        properties.put(viewParameterEntity.getName(), null);
-      }
-    }
     setResourceProperty(resource, PROPERTIES_PROPERTY_ID,
         properties, requestedIds);
     Map<String, String> applicationData = new HashMap<String, String>();
 
-    String currentUserName = viewInstanceEntity.getCurrentUserName();
     for (ViewInstanceDataEntity viewInstanceDataEntity : viewInstanceEntity.getData()) {
-      if (currentUserName.equals(viewInstanceDataEntity.getUser())) {
-        applicationData.put(viewInstanceDataEntity.getName(), viewInstanceDataEntity.getValue());
-      }
+      applicationData.put(viewInstanceDataEntity.getName(), viewInstanceDataEntity.getValue());
     }
     setResourceProperty(resource, DATA_PROPERTY_ID,
         applicationData, requestedIds);
@@ -304,6 +286,7 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
     }
 
     Collection<ViewInstancePropertyEntity> instanceProperties = new HashSet<ViewInstancePropertyEntity>();
+    Collection<ViewInstanceDataEntity>     instanceData       = new HashSet<ViewInstanceDataEntity>();
 
     for (Map.Entry<String, Object> entry : properties.entrySet()) {
 
@@ -320,12 +303,23 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
 
         instanceProperties.add(viewInstancePropertyEntity);
       } else if (propertyName.startsWith(DATA_PREFIX)) {
-        viewInstanceEntity.putInstanceData(entry.getKey().substring(DATA_PREFIX.length()), (String) entry.getValue());
+        ViewInstanceDataEntity viewInstanceDataEntity = new ViewInstanceDataEntity();
+
+        viewInstanceDataEntity.setViewName(viewName);
+        viewInstanceDataEntity.setViewInstanceName(name);
+        viewInstanceDataEntity.setName(entry.getKey().substring(DATA_PREFIX.length()));
+        viewInstanceDataEntity.setValue((String) entry.getValue());
+        viewInstanceDataEntity.setViewInstanceEntity(viewInstanceEntity);
+
+        instanceData.add(viewInstanceDataEntity);
       }
     }
     if (!instanceProperties.isEmpty()) {
       viewInstanceEntity.setProperties(instanceProperties);
     }
+    if (!instanceData.isEmpty()) {
+      viewInstanceEntity.setData(instanceData);
+    }
 
     return viewInstanceEntity;
   }
@@ -335,31 +329,7 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
     return new Command<Void>() {
       @Override
       public Void invoke() throws AmbariException {
-        try {
-          ViewRegistry       viewRegistry   = ViewRegistry.getInstance();
-          ViewInstanceEntity instanceEntity = toEntity(properties);
-
-          ViewEntity viewEntity = instanceEntity.getViewEntity();
-          String     viewName   = viewEntity.getCommonName();
-          String     version    = viewEntity.getVersion();
-          ViewEntity view       = viewRegistry.getDefinition(viewName, version);
-
-          if ( view == null ) {
-            throw new IllegalStateException("The view " + viewName + " is not registered.");
-          }
-
-          // the view must be in the DEPLOYED state to create an instance
-          if (!view.isDeployed()) {
-            throw new IllegalStateException("The view " + viewName + " is not loaded.");
-          }
-
-          if (viewRegistry.instanceExists(instanceEntity)) {
-            throw new DuplicateResourceException("The instance " + instanceEntity.getName() + " already exists.");
-          }
-          viewRegistry.installViewInstance(instanceEntity);
-        } catch (org.apache.ambari.view.SystemException e) {
-          throw new AmbariException("Caught exception trying to create view instance.", e);
-        }
+        ViewRegistry.getInstance().installViewInstance(toEntity(properties));
         return null;
       }
     };
@@ -370,13 +340,7 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
     return new Command<Void>() {
       @Override
       public Void invoke() throws AmbariException {
-
-        ViewInstanceEntity instance = toEntity(properties);
-        ViewEntity         view     = instance.getViewEntity();
-
-        if (includeInstance(view.getCommonName(), view.getVersion(), instance.getInstanceName(), false)) {
-          ViewRegistry.getInstance().updateViewInstance(instance);
-        }
+        ViewRegistry.getInstance().updateViewInstance(toEntity(properties));
         return null;
       }
     };
@@ -393,15 +357,10 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
         Set<ViewInstanceEntity> viewInstanceEntities = new HashSet<ViewInstanceEntity>();
 
         for (ViewEntity viewEntity : viewRegistry.getDefinitions()){
-          // the view must be in the DEPLOYED state to delete an instance
-          if (viewEntity.isDeployed()) {
-            for (ViewInstanceEntity viewInstanceEntity : viewRegistry.getInstanceDefinitions(viewEntity)){
-              Resource resource = toResource(viewInstanceEntity, requestedIds);
-              if (predicate == null || predicate.evaluate(resource)) {
-                if (includeInstance(viewInstanceEntity, false)) {
-                  viewInstanceEntities.add(viewInstanceEntity);
-                }
-              }
+          for (ViewInstanceEntity viewInstanceEntity : viewRegistry.getInstanceDefinitions(viewEntity)){
+            Resource resource = toResource(viewInstanceEntity, requestedIds);
+            if (predicate == null || predicate.evaluate(resource)) {
+              viewInstanceEntities.add(viewInstanceEntity);
             }
           }
         }
@@ -418,39 +377,4 @@ public class ViewInstanceResourceProvider extends AbstractResourceProvider {
     return iconPath == null || iconPath.length() == 0 ? null :
         contextPath + (iconPath.startsWith("/") ? "" : "/") + iconPath;
   }
-
-  /**
-   * Determine whether or not the view instance resource identified
-   * by the given instance name should be included based on the permissions
-   * granted to the current user.
-   *
-   * @param viewName      the view name
-   * @param version       the view version
-   * @param instanceName  the name of the view instance resource
-   * @param readOnly      indicate whether or not this is for a read only operation
-   *
-   * @return true if the view instance should be included based on the permissions of the current user
-   */
-  private boolean includeInstance(String viewName, String version, String instanceName, boolean readOnly) {
-
-    ViewRegistry viewRegistry = ViewRegistry.getInstance();
-
-    return viewRegistry.checkPermission(viewName, version, instanceName, readOnly);
-  }
-
-  /**
-   * Determine whether or not the given view instance resource should be included
-   * based on the permissions granted to the current user.
-   *
-   * @param instanceEntity  the view instance entity
-   * @param readOnly        indicate whether or not this is for a read only operation
-   *
-   * @return true if the view instance should be included based on the permissions of the current user
-   */
-  private boolean includeInstance(ViewInstanceEntity instanceEntity, boolean readOnly) {
-
-    ViewRegistry viewRegistry = ViewRegistry.getInstance();
-
-    return viewRegistry.checkPermission(instanceEntity, readOnly);
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPermissionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPermissionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPermissionResourceProvider.java
deleted file mode 100644
index 979e214..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPermissionResourceProvider.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/**
- * 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.ambari.server.controller.internal;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
-import org.apache.ambari.server.controller.spi.NoSuchResourceException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.RequestStatus;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
-import org.apache.ambari.server.controller.spi.SystemException;
-import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
-import org.apache.ambari.server.orm.dao.PermissionDAO;
-import org.apache.ambari.server.orm.entities.PermissionEntity;
-import org.apache.ambari.server.orm.entities.ResourceTypeEntity;
-import org.apache.ambari.server.orm.entities.ViewEntity;
-import org.apache.ambari.server.view.ViewRegistry;
-
-/**
- * Resource provider for custom view permissions.
- */
-public class ViewPermissionResourceProvider extends AbstractResourceProvider {
-
-  /**
-   * Data access object used to obtain permission entities.
-   */
-  protected static PermissionDAO permissionDAO;
-
-  /**
-   * Permission property id constants.
-   */
-  public static final String VIEW_NAME_PROPERTY_ID       = "PermissionInfo/view_name";
-  public static final String VIEW_VERSION_PROPERTY_ID    = "PermissionInfo/version";
-  public static final String PERMISSION_ID_PROPERTY_ID   = "PermissionInfo/permission_id";
-  public static final String PERMISSION_NAME_PROPERTY_ID = "PermissionInfo/permission_name";
-  public static final String RESOURCE_NAME_PROPERTY_ID   = "PermissionInfo/resource_name";
-
-
-  /**
-   * The key property ids for a permission resource.
-   */
-  private static Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
-  static {
-    keyPropertyIds.put(Resource.Type.View, VIEW_NAME_PROPERTY_ID);
-    keyPropertyIds.put(Resource.Type.ViewVersion, VIEW_VERSION_PROPERTY_ID);
-    keyPropertyIds.put(Resource.Type.ViewPermission, PERMISSION_ID_PROPERTY_ID);
-  }
-
-  /**
-   * The property ids for a permission resource.
-   */
-  private static Set<String> propertyIds = new HashSet<String>();
-  static {
-    propertyIds.add(VIEW_NAME_PROPERTY_ID);
-    propertyIds.add(VIEW_VERSION_PROPERTY_ID);
-    propertyIds.add(PERMISSION_ID_PROPERTY_ID);
-    propertyIds.add(PERMISSION_NAME_PROPERTY_ID);
-    propertyIds.add(RESOURCE_NAME_PROPERTY_ID);
-  }
-
-
-  // ----- Constructors ------------------------------------------------------
-
-  /**
-   * Construct a permission resource provider.
-   */
-  public ViewPermissionResourceProvider() {
-    super(propertyIds, keyPropertyIds);
-  }
-
-
-  // ----- PermissionResourceProvider ----------------------------------------
-
-  /**
-   * Static initialization.
-   *
-   * @param dao  permission data access object
-   */
-  public static void init(PermissionDAO dao) {
-    permissionDAO = dao;
-  }
-
-
-  // ----- ResourceProvider --------------------------------------------------
-
-  @Override
-  public RequestStatus createResources(Request request)
-      throws SystemException, UnsupportedPropertyException,
-      ResourceAlreadyExistsException, NoSuchParentResourceException {
-    throw new UnsupportedOperationException("Not supported.");
-  }
-
-  @Override
-  public Set<Resource> getResources(Request request, Predicate predicate)
-      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
-    ViewRegistry  viewRegistry = ViewRegistry.getInstance();
-    Set<Resource> resources    = new HashSet<Resource>();
-    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
-
-    PermissionEntity viewUsePermission = permissionDAO.findViewUsePermission();
-    for (Map<String, Object> propertyMap: getPropertyMaps(predicate)) {
-      Object viewName = propertyMap.get(VIEW_NAME_PROPERTY_ID);
-      Object viewVersion = propertyMap.get(VIEW_VERSION_PROPERTY_ID);
-      if (viewName != null && viewVersion != null) {
-        ViewEntity viewEntity = viewRegistry.getDefinition(viewName.toString(), viewVersion.toString());
-
-        // do not report permissions for views that are not loaded.
-        if (viewEntity.isDeployed()) {
-          resources.add(toResource(viewUsePermission, viewEntity.getResourceType(), viewEntity, requestedIds));
-        }
-      }
-    }
-
-    for(PermissionEntity permissionEntity : permissionDAO.findAll()){
-      ResourceTypeEntity resourceType = permissionEntity.getResourceType();
-
-      ViewEntity viewEntity = viewRegistry.getDefinition(resourceType);
-
-      if (viewEntity != null && viewEntity.isDeployed()) {
-        resources.add(toResource(permissionEntity, resourceType, viewEntity, requestedIds));
-      }
-    }
-
-    return resources;
-  }
-
-  @Override
-  public RequestStatus updateResources(Request request, Predicate predicate)
-      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
-    throw new UnsupportedOperationException("Not supported.");
-  }
-
-  @Override
-  public RequestStatus deleteResources(Predicate predicate)
-      throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
-    throw new UnsupportedOperationException("Not supported.");
-  }
-
-  @Override
-  public Map<Resource.Type, String> getKeyPropertyIds() {
-    return keyPropertyIds;
-  }
-
-
-  // ----- AbstractResourceProvider ------------------------------------------
-
-  @Override
-  protected Set<String> getPKPropertyIds() {
-    return new HashSet<String>(keyPropertyIds.values());
-  }
-
-
-  // ----- helper methods ----------------------------------------------------
-
-  // convert the given permission entity to a resource
-  private Resource toResource(PermissionEntity entity, ResourceTypeEntity resourceType,
-                              ViewEntity viewEntity, Set<String> requestedIds) {
-
-    Resource resource = new ResourceImpl(Resource.Type.ViewPermission);
-
-    setResourceProperty(resource, VIEW_NAME_PROPERTY_ID, viewEntity.getCommonName(), requestedIds);
-    setResourceProperty(resource, VIEW_VERSION_PROPERTY_ID, viewEntity.getVersion(), requestedIds);
-
-    setResourceProperty(resource, PERMISSION_ID_PROPERTY_ID, entity.getId(), requestedIds);
-    setResourceProperty(resource, PERMISSION_NAME_PROPERTY_ID, entity.getPermissionName(), requestedIds);
-    setResourceProperty(resource, RESOURCE_NAME_PROPERTY_ID, resourceType.getName(), requestedIds);
-
-    return resource;
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java
deleted file mode 100644
index 2c016e4..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewPrivilegeResourceProvider.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/**
- * 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 privileges and
- * limitations under the License.
- */
-package org.apache.ambari.server.controller.internal;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.orm.entities.GroupEntity;
-import org.apache.ambari.server.orm.entities.PermissionEntity;
-import org.apache.ambari.server.orm.entities.PrivilegeEntity;
-import org.apache.ambari.server.orm.entities.ResourceEntity;
-import org.apache.ambari.server.orm.entities.ResourceTypeEntity;
-import org.apache.ambari.server.orm.entities.UserEntity;
-import org.apache.ambari.server.orm.entities.ViewEntity;
-import org.apache.ambari.server.orm.entities.ViewInstanceEntity;
-import org.apache.ambari.server.view.ViewRegistry;
-
-/**
- * Resource provider for view privilege resources.
- */
-public class ViewPrivilegeResourceProvider extends PrivilegeResourceProvider<ViewInstanceEntity> {
-
-  /**
-   * View privilege property id constants.
-   */
-  public static final String PRIVILEGE_VIEW_NAME_PROPERTY_ID     = "PrivilegeInfo/view_name";
-  public static final String PRIVILEGE_VIEW_VERSION_PROPERTY_ID  = "PrivilegeInfo/version";
-  public static final String PRIVILEGE_INSTANCE_NAME_PROPERTY_ID = "PrivilegeInfo/instance_name";
-
-  /**
-   * The property ids for a privilege resource.
-   */
-  private static Set<String> propertyIds = new HashSet<String>();
-  static {
-    propertyIds.add(PRIVILEGE_VIEW_NAME_PROPERTY_ID);
-    propertyIds.add(PRIVILEGE_VIEW_VERSION_PROPERTY_ID);
-    propertyIds.add(PRIVILEGE_INSTANCE_NAME_PROPERTY_ID);
-    propertyIds.add(PRIVILEGE_ID_PROPERTY_ID);
-    propertyIds.add(PERMISSION_NAME_PROPERTY_ID);
-    propertyIds.add(PRINCIPAL_NAME_PROPERTY_ID);
-    propertyIds.add(PRINCIPAL_TYPE_PROPERTY_ID);
-  }
-
-  /**
-   * The key property ids for a privilege resource.
-   */
-  private static Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
-  static {
-    keyPropertyIds.put(Resource.Type.View, PRIVILEGE_VIEW_NAME_PROPERTY_ID);
-    keyPropertyIds.put(Resource.Type.ViewVersion, PRIVILEGE_VIEW_VERSION_PROPERTY_ID);
-    keyPropertyIds.put(Resource.Type.ViewInstance, PRIVILEGE_INSTANCE_NAME_PROPERTY_ID);
-    keyPropertyIds.put(Resource.Type.ViewPrivilege, PRIVILEGE_ID_PROPERTY_ID);
-  }
-
-  /**
-   * The built-in VIEW.USE permission.
-   */
-  private final PermissionEntity viewUsePermission;
-
-
-  // ----- Constructors ------------------------------------------------------
-
-  /**
-   * Construct an ViewPrivilegeResourceProvider.
-   */
-  public ViewPrivilegeResourceProvider() {
-    super(propertyIds, keyPropertyIds, Resource.Type.ViewPrivilege);
-    viewUsePermission = permissionDAO.findById(PermissionEntity.VIEW_USE_PERMISSION);
-  }
-
-
-  // ----- AbstractResourceProvider ------------------------------------------
-
-  @Override
-  public Map<Resource.Type, String> getKeyPropertyIds() {
-    return keyPropertyIds;
-  }
-
-
-  // ----- PrivilegeResourceProvider -----------------------------------------
-
-  @Override
-  public Map<Long, ViewInstanceEntity> getResourceEntities(Map<String, Object> properties) throws AmbariException {
-    ViewRegistry viewRegistry = ViewRegistry.getInstance();
-
-    String viewName     = (String) properties.get(PRIVILEGE_VIEW_NAME_PROPERTY_ID);
-    String viewVersion  = (String) properties.get(PRIVILEGE_VIEW_VERSION_PROPERTY_ID);
-    String instanceName = (String) properties.get(PRIVILEGE_INSTANCE_NAME_PROPERTY_ID);
-
-    if (viewName != null && viewVersion != null && instanceName != null) {
-      ViewInstanceEntity viewInstanceEntity =
-          viewRegistry.getInstanceDefinition(viewName, viewVersion, instanceName);
-
-      if (viewInstanceEntity == null) {
-        throw new AmbariException("View instance " + instanceName + " of " + viewName + viewVersion + " was not found");
-      }
-
-      ViewEntity view = viewInstanceEntity.getViewEntity();
-
-      return view.isDeployed() ?
-          Collections.singletonMap(viewInstanceEntity.getResource().getId(), viewInstanceEntity) :
-          Collections.<Long, ViewInstanceEntity>emptyMap();
-    }
-
-    Set<ViewEntity> viewEntities = new HashSet<ViewEntity>();
-
-    if (viewVersion != null) {
-      ViewEntity viewEntity = viewRegistry.getDefinition(viewName, viewVersion);
-      if (viewEntity != null) {
-        viewEntities.add(viewEntity);
-      }
-    } else {
-      for (ViewEntity viewEntity : viewRegistry.getDefinitions()) {
-        if (viewName == null || viewEntity.getCommonName().equals(viewName)) {
-          viewEntities.add(viewEntity);
-        }
-      }
-    }
-
-    Map<Long, ViewInstanceEntity> resourceEntities = new HashMap<Long, ViewInstanceEntity>();
-
-    for (ViewEntity viewEntity : viewEntities) {
-      if (viewEntity.isDeployed()) {
-        for (ViewInstanceEntity viewInstanceEntity : viewEntity.getInstances()) {
-          resourceEntities.put(viewInstanceEntity.getResource().getId(), viewInstanceEntity);
-        }
-      }
-    }
-    return resourceEntities;
-  }
-
-  @Override
-  public Long getResourceEntityId(Predicate predicate) {
-    final ViewRegistry viewRegistry = ViewRegistry.getInstance();
-
-    final String viewName     = getQueryParameterValue(PRIVILEGE_VIEW_NAME_PROPERTY_ID, predicate).toString();
-    final String viewVersion  = getQueryParameterValue(PRIVILEGE_VIEW_VERSION_PROPERTY_ID, predicate).toString();
-    final String instanceName = getQueryParameterValue(PRIVILEGE_INSTANCE_NAME_PROPERTY_ID, predicate).toString();
-
-    final ViewInstanceEntity viewInstanceEntity = viewRegistry.getInstanceDefinition(viewName, viewVersion, instanceName);
-
-    if (viewInstanceEntity != null) {
-
-      ViewEntity view = viewInstanceEntity.getViewEntity();
-
-      return view.isDeployed() ? viewInstanceEntity.getResource().getId() : null;
-    }
-    return null;
-  }
-
-
-  // ----- helper methods ----------------------------------------------------
-
-  @Override
-  protected boolean checkResourceTypes(PrivilegeEntity entity) throws AmbariException {
-    return super.checkResourceTypes(entity) ||
-        entity.getPermission().getResourceType().getId().equals(ResourceTypeEntity.VIEW_RESOURCE_TYPE);
-  }
-
-  @Override
-  protected Resource toResource(PrivilegeEntity privilegeEntity,
-                                Map<Long, UserEntity> userEntities,
-                                Map<Long, GroupEntity> groupEntities,
-                                Map<Long, ViewInstanceEntity> resourceEntities, Set<String> requestedIds) {
-    Resource resource = super.toResource(privilegeEntity, userEntities, groupEntities, resourceEntities, requestedIds);
-    if (resource != null) {
-
-      ViewInstanceEntity viewInstanceEntity = resourceEntities.get(privilegeEntity.getResource().getId());
-      ViewEntity         viewEntity         = viewInstanceEntity.getViewEntity();
-
-      if (!viewEntity.isDeployed()) {
-        return null;
-      }
-
-      setResourceProperty(resource, PRIVILEGE_VIEW_NAME_PROPERTY_ID, viewEntity.getCommonName(), requestedIds);
-      setResourceProperty(resource, PRIVILEGE_VIEW_VERSION_PROPERTY_ID, viewEntity.getVersion(), requestedIds);
-      setResourceProperty(resource, PRIVILEGE_INSTANCE_NAME_PROPERTY_ID, viewInstanceEntity.getName(), requestedIds);
-    }
-    return resource;
-  }
-
-  @Override
-  protected PermissionEntity getPermission(String permissionName, ResourceEntity resourceEntity) throws AmbariException {
-    return (permissionName.equals(PermissionEntity.VIEW_USE_PERMISSION_NAME)) ?
-        viewUsePermission : super.getPermission(permissionName, resourceEntity);
-  }
-}
-

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java
index bc92a91..b76c8e0 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewResourceProvider.java
@@ -63,7 +63,7 @@ public class ViewResourceProvider extends AbstractResourceProvider {
     propertyIds.add(VIEW_NAME_PROPERTY_ID);
   }
 
-
+  
   // ----- Constructors ------------------------------------------------------
 
   /**
@@ -73,12 +73,12 @@ public class ViewResourceProvider extends AbstractResourceProvider {
     super(propertyIds, keyPropertyIds);
   }
 
-
+  
   // ----- ResourceProvider --------------------------------------------------
 
   @Override
-  public RequestStatus createResources(Request request)
-      throws SystemException, UnsupportedPropertyException,
+  public RequestStatus createResources(Request request) 
+      throws SystemException, UnsupportedPropertyException, 
              ResourceAlreadyExistsException, NoSuchParentResourceException {
     throw new UnsupportedOperationException("Not yet supported.");
   }
@@ -102,13 +102,11 @@ public class ViewResourceProvider extends AbstractResourceProvider {
 
       for (ViewEntity viewDefinition : viewRegistry.getDefinitions()){
         if (viewName == null || viewName.equals(viewDefinition.getCommonName())) {
-          if (viewRegistry.includeDefinition(viewDefinition)) {
-            Resource resource = new ResourceImpl(Resource.Type.View);
+          Resource resource = new ResourceImpl(Resource.Type.View);
 
-            setResourceProperty(resource, VIEW_NAME_PROPERTY_ID, viewDefinition.getCommonName(), requestedIds);
+          setResourceProperty(resource, VIEW_NAME_PROPERTY_ID, viewDefinition.getCommonName(), requestedIds);
 
-            resources.add(resource);
-          }
+          resources.add(resource);
         }
       }
     }
@@ -132,7 +130,7 @@ public class ViewResourceProvider extends AbstractResourceProvider {
     return keyPropertyIds;
   }
 
-
+  
   // ----- AbstractResourceProvider ------------------------------------------
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java
index 58cf774..5793a1b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ViewVersionResourceProvider.java
@@ -44,17 +44,13 @@ public class ViewVersionResourceProvider extends AbstractResourceProvider {
   /**
    * View property id constants.
    */
-  public static final String VIEW_NAME_PROPERTY_ID          = "ViewVersionInfo/view_name";
-  public static final String VIEW_VERSION_PROPERTY_ID       = "ViewVersionInfo/version";
-  public static final String LABEL_PROPERTY_ID              = "ViewVersionInfo/label";
-  public static final String DESCRIPTION_PROPERTY_ID        = "ViewVersionInfo/description";
-  public static final String VERSION_PROPERTY_ID            = "ViewVersionInfo/version";
-  public static final String PARAMETERS_PROPERTY_ID         = "ViewVersionInfo/parameters";
-  public static final String ARCHIVE_PROPERTY_ID            = "ViewVersionInfo/archive";
-  public static final String MASKER_CLASS_PROPERTY_ID       = "ViewVersionInfo/masker_class";
-  public static final String VIEW_STATUS_PROPERTY_ID        = "ViewVersionInfo/status";
-  public static final String VIEW_STATUS_DETAIL_PROPERTY_ID = "ViewVersionInfo/status_detail";
-  public static final String SYSTEM_PROPERTY_ID             = "ViewVersionInfo/system";
+  public static final String VIEW_NAME_PROPERTY_ID      = "ViewVersionInfo/view_name";
+  public static final String VIEW_VERSION_PROPERTY_ID   = "ViewVersionInfo/version";
+  public static final String LABEL_PROPERTY_ID          = "ViewVersionInfo/label";
+  public static final String VERSION_PROPERTY_ID        = "ViewVersionInfo/version";
+  public static final String PARAMETERS_PROPERTY_ID     = "ViewVersionInfo/parameters";
+  public static final String ARCHIVE_PROPERTY_ID        = "ViewVersionInfo/archive";
+  public static final String MASKER_CLASS_PROPERTY_ID   = "ViewVersionInfo/masker_class";
 
   /**
    * The key property ids for a view resource.
@@ -73,14 +69,10 @@ public class ViewVersionResourceProvider extends AbstractResourceProvider {
     propertyIds.add(VIEW_NAME_PROPERTY_ID);
     propertyIds.add(VIEW_VERSION_PROPERTY_ID);
     propertyIds.add(LABEL_PROPERTY_ID);
-    propertyIds.add(DESCRIPTION_PROPERTY_ID);
     propertyIds.add(VERSION_PROPERTY_ID);
     propertyIds.add(PARAMETERS_PROPERTY_ID);
     propertyIds.add(ARCHIVE_PROPERTY_ID);
     propertyIds.add(MASKER_CLASS_PROPERTY_ID);
-    propertyIds.add(VIEW_STATUS_PROPERTY_ID);
-    propertyIds.add(VIEW_STATUS_DETAIL_PROPERTY_ID);
-    propertyIds.add(SYSTEM_PROPERTY_ID);
   }
 
 
@@ -100,7 +92,7 @@ public class ViewVersionResourceProvider extends AbstractResourceProvider {
   public RequestStatus createResources(Request request)
       throws SystemException, UnsupportedPropertyException,
       ResourceAlreadyExistsException, NoSuchParentResourceException {
-    throw new UnsupportedOperationException("Not supported.");
+    throw new UnsupportedOperationException("Not yet supported.");
   }
 
   @Override
@@ -129,15 +121,11 @@ public class ViewVersionResourceProvider extends AbstractResourceProvider {
             setResourceProperty(resource, VIEW_NAME_PROPERTY_ID, viewDefinition.getCommonName(), requestedIds);
             setResourceProperty(resource, VIEW_VERSION_PROPERTY_ID, viewDefinition.getVersion(), requestedIds);
             setResourceProperty(resource, LABEL_PROPERTY_ID, viewDefinition.getLabel(), requestedIds);
-            setResourceProperty(resource, DESCRIPTION_PROPERTY_ID, viewDefinition.getDescription(), requestedIds);
             setResourceProperty(resource, VERSION_PROPERTY_ID, viewDefinition.getVersion(), requestedIds);
             setResourceProperty(resource, PARAMETERS_PROPERTY_ID,
                 viewDefinition.getConfiguration().getParameters(), requestedIds);
             setResourceProperty(resource, ARCHIVE_PROPERTY_ID, viewDefinition.getArchive(), requestedIds);
             setResourceProperty(resource, MASKER_CLASS_PROPERTY_ID, viewDefinition.getMask(), requestedIds);
-            setResourceProperty(resource, VIEW_STATUS_PROPERTY_ID, viewDefinition.getStatus().toString(), requestedIds);
-            setResourceProperty(resource, VIEW_STATUS_DETAIL_PROPERTY_ID, viewDefinition.getStatusDetail(), requestedIds);
-            setResourceProperty(resource, SYSTEM_PROPERTY_ID, viewDefinition.isSystem(), requestedIds);
 
             resources.add(resource);
           }
@@ -150,13 +138,13 @@ public class ViewVersionResourceProvider extends AbstractResourceProvider {
   @Override
   public RequestStatus updateResources(Request request, Predicate predicate)
       throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
-    throw new UnsupportedOperationException("Not supported.");
+    throw new UnsupportedOperationException("Not yet supported.");
   }
 
   @Override
   public RequestStatus deleteResources(Predicate predicate)
       throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
-    throw new UnsupportedOperationException("Not supported.");
+    throw new UnsupportedOperationException("Not yet supported.");
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
index 65f7be7..142740c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXHostProvider.java
@@ -17,9 +17,9 @@
  */
 package org.apache.ambari.server.controller.jmx;
 
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
 import org.apache.ambari.server.controller.spi.SystemException;
-
-import java.util.Set;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 
 /**
  * Provider of JMX host information.
@@ -27,15 +27,17 @@ import java.util.Set;
 public interface JMXHostProvider {
 
   /**
-   * Get the JMX host names for the given cluster name and component name.
+   * Get the JMX host name for the given cluster name and component name.
    *
    * @param clusterName    the cluster name
    * @param componentName  the component name
    *
-   * @return set of JMX host names
+   * @return the JMX host name
    *
+   * @throws SystemException if unable to get the JMX host name
    */
-  public Set<String> getHostNames(String clusterName, String componentName);
+  public String getHostName(String clusterName, String componentName)
+      throws SystemException;
 
   /**
    * Get the port for the specified cluster name and component.

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
index 975a479..734da90 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/jmx/JMXPropertyProvider.java
@@ -20,19 +20,26 @@ package org.apache.ambari.server.controller.jmx;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionService;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorCompletionService;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
-import org.apache.ambari.server.controller.metrics.MetricsHostProvider;
-import org.apache.ambari.server.controller.metrics.MetricsProvider;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Request;
 import org.apache.ambari.server.controller.spi.Resource;
@@ -49,11 +56,39 @@ import org.slf4j.LoggerFactory;
 /**
  * Property provider implementation for JMX sources.
  */
-public class JMXPropertyProvider extends MetricsProvider {
+public class JMXPropertyProvider extends AbstractPropertyProvider {
 
   private static final String NAME_KEY = "name";
   private static final String PORT_KEY = "tag.port";
   private static final String DOT_REPLACEMENT_CHAR = "#";
+  private static final long DEFAULT_POPULATE_TIMEOUT_MILLIS = 10000L;
+
+  public static final String TIMED_OUT_MSG = "Timed out waiting for JMX metrics.";
+  public static final String STORM_REST_API = "STORM_REST_API";
+
+  /**
+   * Thread pool
+   */
+  private static final ExecutorService EXECUTOR_SERVICE;
+  private static final int THREAD_POOL_CORE_SIZE = 20;
+  private static final int THREAD_POOL_MAX_SIZE = 100;
+  private static final long THREAD_POOL_TIMEOUT_MILLIS = 30000L;
+
+  static {
+    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(); // unlimited Queue
+
+    ThreadPoolExecutor threadPoolExecutor =
+        new ThreadPoolExecutor(
+            THREAD_POOL_CORE_SIZE,
+            THREAD_POOL_MAX_SIZE,
+            THREAD_POOL_TIMEOUT_MILLIS,
+            TimeUnit.MILLISECONDS,
+            queue);
+
+    threadPoolExecutor.allowCoreThreadTimeOut(true);
+
+    EXECUTOR_SERVICE = threadPoolExecutor;
+  }
 
   private final static ObjectReader jmxObjectReader;
   private final static ObjectReader stormObjectReader;
@@ -102,6 +137,16 @@ public class JMXPropertyProvider extends MetricsProvider {
 
   private final String statePropertyId;
 
+  private final Set<String> healthyStates;
+
+  /**
+   * The amount of time that this provider will wait for JMX metric values to be
+   * returned from the JMX sources.  If no results are returned for this amount of
+   * time then the request to populate the resources will fail.
+   */
+  protected long populateTimeout = DEFAULT_POPULATE_TIMEOUT_MILLIS;
+
+
   // ----- Constructors ------------------------------------------------------
 
   /**
@@ -109,23 +154,23 @@ public class JMXPropertyProvider extends MetricsProvider {
    *
    * @param componentMetrics         the map of supported metrics
    * @param streamProvider           the stream provider
-   * @param jmxHostProvider          the JMX host mapping
-   * @param metricsHostProvider      the host mapping
+   * @param jmxHostProvider          the host mapping
    * @param clusterNamePropertyId    the cluster name property id
    * @param hostNamePropertyId       the host name property id
    * @param componentNamePropertyId  the component name property id
    * @param statePropertyId          the state property id
+   * @param healthyStates            the set of healthy state values
    */
   public JMXPropertyProvider(Map<String, Map<String, PropertyInfo>> componentMetrics,
                              StreamProvider streamProvider,
                              JMXHostProvider jmxHostProvider,
-                             MetricsHostProvider metricsHostProvider,
                              String clusterNamePropertyId,
                              String hostNamePropertyId,
                              String componentNamePropertyId,
-                             String statePropertyId) {
+                             String statePropertyId,
+                             Set<String> healthyStates) {
 
-    super(componentMetrics, hostNamePropertyId, metricsHostProvider);
+    super(componentMetrics);
 
     this.streamProvider           = streamProvider;
     this.jmxHostProvider          = jmxHostProvider;
@@ -133,22 +178,120 @@ public class JMXPropertyProvider extends MetricsProvider {
     this.hostNamePropertyId       = hostNamePropertyId;
     this.componentNamePropertyId  = componentNamePropertyId;
     this.statePropertyId          = statePropertyId;
+    this.healthyStates            = healthyStates;
   }
+  
+  // ----- PropertyProvider --------------------------------------------------
+
+  @Override
+  public Set<Resource> populateResources(Set<Resource> resources, Request request, Predicate predicate)
+      throws SystemException {
+
+    CompletionService<Resource> completionService =
+        new ExecutorCompletionService<Resource>(EXECUTOR_SERVICE);
+
+    // In a large cluster we could have thousands of resources to populate here.
+    // Distribute the work across multiple threads.
+    for (Resource resource : resources) {
+      completionService.submit(getPopulateResourceCallable(resource, request, predicate));
+    }
+
+    Set<Resource> keepers = new HashSet<Resource>();
+    try {
+      for (int i = 0; i < resources.size(); ++ i) {
+        Future<Resource> resourceFuture =
+            completionService.poll(populateTimeout, TimeUnit.MILLISECONDS);
+
+        if (resourceFuture == null) {
+          // its been more than the populateTimeout since the last callable completed ...
+          // don't wait any longer
+          LOG.error(TIMED_OUT_MSG);
+          break;
+        } else {
+          // future should already be completed... no need to wait on get
+          Resource resource = resourceFuture.get();
+          if (resource != null) {
+            keepers.add(resource);
+          }
+        }
+      }
+    } catch (InterruptedException e) {
+      logException(e);
+    } catch (ExecutionException e) {
+      rethrowSystemException(e.getCause());
+    }
+    return keepers;
+  }
+
 
   // ----- helper methods ----------------------------------------------------
 
   /**
+   * Set the populate timeout value for this provider.
+   *
+   * @param populateTimeout  the populate timeout value
+   */
+  protected void setPopulateTimeout(long populateTimeout) {
+    this.populateTimeout = populateTimeout;
+  }
+
+  /**
+   * Get the spec to locate the JMX stream from the given host and port
+   *
+   ** @param protocol  the protocol, one of http or https
+   * @param hostName  the host name
+   * @param port      the port
+   *
+   * @return the spec
+   */
+  protected String getSpec(String protocol, String hostName,
+                           String port, String componentName) {
+      if (null == componentName || !componentName.equals(STORM_REST_API))
+        return protocol + "://" + hostName + ":" + port + "/jmx";
+      else
+        return protocol + "://" + hostName + ":" + port + "/api/cluster/summary";
+  }
+
+  /**
+   * Get the spec to locate the JMX stream from the given host and port
+   *
+   * @param hostName  the host name
+   * @param port      the port
+   *
+   * @return the spec
+   */
+  protected String getSpec(String hostName, String port) {
+      return getSpec("http", hostName, port, null);
+  }
+  
+  /**
+   * Get a callable that can be used to populate the given resource.
+   *
+   * @param resource  the resource to be populated
+   * @param request   the request
+   * @param predicate the predicate
+   *
+   * @return a callable that can be used to populate the given resource
+   */
+  private Callable<Resource> getPopulateResourceCallable(
+      final Resource resource, final Request request, final Predicate predicate) {
+    return new Callable<Resource>() {
+      public Resource call() throws SystemException {
+        return populateResource(resource, request, predicate);
+      }
+    };
+  }
+
+  /**
    * Populate a resource by obtaining the requested JMX properties.
    *
    * @param resource  the resource to be populated
    * @param request   the request
    * @param predicate the predicate
-   * @param ticket    a valid ticket
    *
    * @return the populated resource; null if the resource should NOT be part of the result set for the given predicate
    */
-  @Override
-  protected Resource populateResource(Resource resource, Request request, Predicate predicate, MetricsProvider.Ticket ticket)
+  private Resource populateResource(Resource resource, Request request, Predicate predicate)
       throws SystemException {
 
     Set<String> ids = getRequestPropertyIds(request, predicate);
@@ -191,35 +334,26 @@ public class JMXPropertyProvider extends MetricsProvider {
       return resource;
     }
 
-    Set<String> hostNames = getHosts(resource, clusterName, componentName);
-    if (hostNames == null || hostNames.isEmpty()) {
+    String hostName = getHost(resource, clusterName, componentName);
+    if (hostName == null) {
       LOG.warn("Unable to get JMX metrics.  No host name for " + componentName);
       return resource;
     }
     
     String protocol = getJMXProtocol(clusterName, componentName);
-    InputStream in = null;
-
     try {
-      try {
-        for (String hostName : hostNames) {
-          try {
-            in = streamProvider.readFrom(getSpec(protocol, hostName, port, "/jmx"));
-            // if the ticket becomes invalid (timeout) then bail out
-            if (!ticket.isValid()) {
-              return resource;
-            }
+      InputStream in = streamProvider.readFrom(getSpec(protocol, hostName, port, componentName));
 
-            getHadoopMetricValue(in, ids, resource, request, ticket);
+      try {
 
-          } catch (IOException e) {
-            logException(e);
-          }
+        if (null == componentName || !componentName.equals(STORM_REST_API)) {
+          getHadoopMetricValue(in, ids, resource, request);
+        } else {
+          getStormMetricValue(in, ids, resource);
         }
+
       } finally {
-        if (in != null) {
-          in.close();
-        }
+        in.close();
       }
     } catch (IOException e) {
       logException(e);
@@ -231,7 +365,7 @@ public class JMXPropertyProvider extends MetricsProvider {
    * Hadoop-specific metrics fetching
    */
   private void getHadoopMetricValue(InputStream in, Set<String> ids,
-                       Resource resource, Request request, Ticket ticket) throws IOException {
+                       Resource resource, Request request) throws IOException {
     JMXMetricHolder metricHolder = jmxObjectReader.readValue(in);
 
     Map<String, Map<String, Object>> categories = new HashMap<String, Map<String, Object>>();
@@ -300,17 +434,11 @@ public class JMXPropertyProvider extends MetricsProvider {
                 }
                 // We need to do the final filtering here, after the argument substitution
                 if (isRequestedPropertyId(newPropertyId, requestedPropertyId, request)) {
-                  if (!ticket.isValid()) {
-                    return;
-                  }
                   setResourceValue(resource, categories, newPropertyId, jmxCat, property, keyList);
                 }
               }
             }
           } else {
-            if (!ticket.isValid()) {
-              return;
-            }
             setResourceValue(resource, categories, propertyId, category, property, keyList);
           }
         }
@@ -318,6 +446,28 @@ public class JMXPropertyProvider extends MetricsProvider {
     }
   }
 
+  /**
+   * TODO: Refactor
+   * Storm-specific metrics fetching
+   */
+  private void getStormMetricValue(InputStream in, Set<String> ids,
+                                   Resource resource) throws IOException {
+    HashMap<String, Object> metricHolder = stormObjectReader.readValue(in);
+    for (String category : ids) {
+      Map<String, PropertyInfo> defProps = getComponentMetrics().get(STORM_REST_API);
+      for (Map.Entry<String, PropertyInfo> depEntry : defProps.entrySet()) {
+        if (depEntry.getKey().startsWith(category)) {
+          PropertyInfo propInfo = depEntry.getValue();
+          String propName = propInfo.getPropertyId();
+          Object propertyValue = metricHolder.get(propName);
+          String absId = PropertyHelper.getPropertyId(category, propName);
+          // TODO: Maybe cast to int
+          resource.setProperty(absId, propertyValue);
+        }
+      }
+    }
+  }
+
   private void setResourceValue(Resource resource, Map<String, Map<String, Object>> categories, String propertyId,
                                 String category, String property, List<String> keyList) {
     Map<String, Object> properties = categories.get(category);
@@ -351,10 +501,10 @@ public class JMXPropertyProvider extends MetricsProvider {
     return jmxHostProvider.getJMXProtocol(clusterName, componentName);
   }
   
-  private Set<String> getHosts(Resource resource, String clusterName, String componentName) {
+  private String getHost(Resource resource, String clusterName, String componentName) throws SystemException {
     return hostNamePropertyId == null ?
-            jmxHostProvider.getHostNames(clusterName, componentName) :
-            Collections.singleton((String) resource.getPropertyValue(hostNamePropertyId));
+        jmxHostProvider.getHostName(clusterName, componentName) :
+        (String) resource.getPropertyValue(hostNamePropertyId);
   }
 
   private String getCategory(Map<String, Object> bean) {
@@ -369,4 +519,44 @@ public class JMXPropertyProvider extends MetricsProvider {
     }
     return null;
   }
+
+  /**
+   * Determine whether or not the given property id was requested.
+   */
+  private static boolean isRequestedPropertyId(String propertyId, String requestedPropertyId, Request request) {
+    return request.getPropertyIds().isEmpty() || propertyId.startsWith(requestedPropertyId);
+  }
+
+  /**
+   * Log an error for the given exception.
+   *
+   * @param throwable  the caught exception
+   *
+   * @return the error message that was logged
+   */
+  private static String logException(Throwable throwable) {
+    String msg = "Caught exception getting JMX metrics : " + throwable.getLocalizedMessage();
+
+    LOG.error(msg);
+    LOG.debug(msg, throwable);
+
+    return msg;
+  }
+
+  /**
+   * Rethrow the given exception as a System exception and log the message.
+   *
+   * @param throwable  the caught exception
+   *
+   * @throws org.apache.ambari.server.controller.spi.SystemException always around the given exception
+   */
+  private static void rethrowSystemException(Throwable throwable) throws SystemException {
+    String msg = logException(throwable);
+
+    if (throwable instanceof SystemException) {
+      throw (SystemException) throwable;
+    }
+    throw new SystemException (msg, throwable);
+  }  
+  
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsHostProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsHostProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsHostProvider.java
deleted file mode 100644
index 1a96829..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsHostProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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.ambari.server.controller.metrics;
-
-
-import org.apache.ambari.server.controller.spi.SystemException;
-
-public interface MetricsHostProvider {
-
-  /**
-   * Get the host name for the given cluster name and component name.
-   *
-   * @param clusterName   the cluster name
-   * @param componentName the component name
-   * @return the host name
-   * @throws org.apache.ambari.server.controller.spi.SystemException
-   *          if unable to get the JMX host name
-   */
-  public String getHostName(String clusterName, String componentName)
-      throws SystemException;
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e28d1e3/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsProvider.java
deleted file mode 100644
index 27c55f4..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/metrics/MetricsProvider.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/**
- * 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.ambari.server.controller.metrics;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorCompletionService;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-
-import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
-import org.apache.ambari.server.controller.internal.PropertyInfo;
-import org.apache.ambari.server.controller.spi.Predicate;
-import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Resource;
-import org.apache.ambari.server.controller.spi.SystemException;
-
-/**
- * Unites common functionality for multithreaded metrics providers
- * (JMX and REST as of now). Shares the same pool of executor threads.
- */
-public abstract class MetricsProvider extends AbstractPropertyProvider {
-
-  /**
-   * Host states that make available metrics collection
-   */
-  public static final Set<String> healthyStates = Collections.singleton("STARTED");
-  protected final String hostNamePropertyId;
-  private final MetricsHostProvider metricsHostProvider;
-
-  /**
-   * Executor service is shared between all childs of current class
-   */
-  private static final ExecutorService EXECUTOR_SERVICE = initExecutorService();
-  private static final int THREAD_POOL_CORE_SIZE = 20;
-  private static final int THREAD_POOL_MAX_SIZE = 100;
-  private static final long THREAD_POOL_TIMEOUT_MILLIS = 30000L;
-
-  private static final long DEFAULT_POPULATE_TIMEOUT_MILLIS = 10000L;
-  /**
-   * The amount of time that this provider will wait for JMX metric values to be
-   * returned from the JMX sources.  If no results are returned for this amount of
-   * time then the request to populate the resources will fail.
-   */
-  protected long populateTimeout = DEFAULT_POPULATE_TIMEOUT_MILLIS;
-  public static final String TIMED_OUT_MSG = "Timed out waiting for metrics.";
-
-  // ----- Constructors ------------------------------------------------------
-
-  /**
-   * Construct a provider.
-   *
-   * @param componentMetrics map of metrics for this provider
-   */
-  public MetricsProvider(Map<String, Map<String, PropertyInfo>> componentMetrics,
-                         String hostNamePropertyId,
-                         MetricsHostProvider metricsHostProvider) {
-    super(componentMetrics);
-    this.hostNamePropertyId = hostNamePropertyId;
-    this.metricsHostProvider = metricsHostProvider;
-  }
-
-  // ----- Thread pool -------------------------------------------------------
-
-  /**
-   * Generates thread pool with default parameters
-   */
-
-
-  private static ExecutorService initExecutorService() {
-    LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(); // unlimited Queue
-
-    ThreadPoolExecutor threadPoolExecutor =
-        new ThreadPoolExecutor(
-            THREAD_POOL_CORE_SIZE,
-            THREAD_POOL_MAX_SIZE,
-            THREAD_POOL_TIMEOUT_MILLIS,
-            TimeUnit.MILLISECONDS,
-            queue);
-
-    threadPoolExecutor.allowCoreThreadTimeOut(true);
-
-    return threadPoolExecutor;
-  }
-
-  public static ExecutorService getExecutorService() {
-    return EXECUTOR_SERVICE;
-  }
-
-  // ----- Common PropertyProvider implementation details --------------------
-
-  @Override
-  public Set<Resource> populateResources(Set<Resource> resources, Request request, Predicate predicate)
-      throws SystemException {
-
-    // Get a valid ticket for the request.
-    Ticket ticket = new Ticket();
-
-    CompletionService<Resource> completionService =
-        new ExecutorCompletionService<Resource>(EXECUTOR_SERVICE);
-
-    // In a large cluster we could have thousands of resources to populate here.
-    // Distribute the work across multiple threads.
-    for (Resource resource : resources) {
-      completionService.submit(getPopulateResourceCallable(resource, request, predicate, ticket));
-    }
-
-    Set<Resource> keepers = new HashSet<Resource>();
-    try {
-      for (int i = 0; i < resources.size(); ++ i) {
-        Future<Resource> resourceFuture =
-            completionService.poll(populateTimeout, TimeUnit.MILLISECONDS);
-
-        if (resourceFuture == null) {
-          // its been more than the populateTimeout since the last callable completed ...
-          // invalidate the ticket to abort the threads and don't wait any longer
-          ticket.invalidate();
-          LOG.error(TIMED_OUT_MSG);
-          break;
-        } else {
-          // future should already be completed... no need to wait on get
-          Resource resource = resourceFuture.get();
-          if (resource != null) {
-            keepers.add(resource);
-          }
-        }
-      }
-    } catch (InterruptedException e) {
-      logException(e);
-    } catch (ExecutionException e) {
-      rethrowSystemException(e.getCause());
-    }
-    return keepers;
-  }
-
-  /**
-   * Get a callable that can be used to populate the given resource.
-   *
-   * @param resource  the resource to be populated
-   * @param request   the request
-   * @param predicate the predicate
-   * @param ticket    a valid ticket
-   *
-   * @return a callable that can be used to populate the given resource
-   */
-  private Callable<Resource> getPopulateResourceCallable(
-      final Resource resource, final Request request, final Predicate predicate, final Ticket ticket) {
-    return new Callable<Resource>() {
-      public Resource call() throws SystemException {
-        return populateResource(resource, request, predicate, ticket);
-      }
-    };
-  }
-
-
-  /**
-   * Populate a resource by obtaining the requested JMX properties.
-   *
-   * @param resource  the resource to be populated
-   * @param request   the request
-   * @param predicate the predicate
-   * @return the populated resource; null if the resource should NOT be part of the result set for the given predicate
-   */
-
-
-  protected abstract Resource populateResource(Resource resource,
-                                               Request request, Predicate predicate, Ticket ticket)
-
-      throws SystemException;
-
-  /**
-   * Set the populate timeout value for this provider.
-   *
-   * @param populateTimeout the populate timeout value
-   */
-
-
-  protected void setPopulateTimeout(long populateTimeout) {
-    this.populateTimeout = populateTimeout;
-
-  }
-
-
-  // ----- helper methods ----------------------------------------------------
-
-  /**
-   * Determine whether or not the given property id was requested.
-   */
-  protected static boolean isRequestedPropertyId(String propertyId, String requestedPropertyId, Request request) {
-    return request.getPropertyIds().isEmpty() || propertyId.startsWith(requestedPropertyId);
-  }
-
-  /**
-   * Log an error for the given exception.
-   *
-   * @param throwable  the caught exception
-   *
-   * @return the error message that was logged
-   */
-  protected static String logException(Throwable throwable) {
-    String msg = "Caught exception getting JMX metrics : " + throwable.getLocalizedMessage();
-
-    LOG.debug(msg, throwable);
-
-    return msg;
-  }
-
-  /**
-   * Rethrow the given exception as a System exception and log the message.
-   *
-   * @param throwable  the caught exception
-   *
-   * @throws org.apache.ambari.server.controller.spi.SystemException always around the given exception
-   */
-  protected static void rethrowSystemException(Throwable throwable) throws SystemException {
-    String msg = logException(throwable);
-
-    if (throwable instanceof SystemException) {
-      throw (SystemException) throwable;
-    }
-    throw new SystemException (msg, throwable);
-  }
-
-  /**
-   * Returns a hostname for component
-   */
-
-
-  public String getHost(Resource resource, String clusterName, String componentName) throws SystemException {
-    return hostNamePropertyId == null ?
-        metricsHostProvider.getHostName(clusterName, componentName) :
-        (String) resource.getPropertyValue(hostNamePropertyId);
-
-  }
-
-
-  /**
-   * Get complete URL from parts
-   */
-
-  protected String getSpec(String protocol, String hostName,
-                           String port, String url) {
-    return protocol + "://" + hostName + ":" + port + url;
-
-  }
-
-  // ----- inner class : Ticket ----------------------------------------------
-
-  /**
-   * Ticket used to cancel provider threads.  The provider threads should
-   * monitor the validity of the passed in ticket and bail out if it becomes
-   * invalid (as in a timeout).
-   */
-  protected static class Ticket {
-    /**
-     * Indicate whether or not the ticket is valid.
-     */
-    private volatile boolean valid = true;
-
-    /**
-     * Invalidate the ticket.
-     */
-    public void invalidate() {
-      valid = false;
-    }
-
-    /**
-     * Determine whether or not this ticket is valid.
-     *
-     * @return true if the ticket is valid
-     */
-    public boolean isValid() {
-      return valid;
-    }
-  }
-
-}


Mime
View raw message