Package org.apache.ambari.server.controller.spi

Examples of org.apache.ambari.server.controller.spi.Resource


    });

    Set<Resource> resources = new HashSet<Resource>();

    for (StackServiceResponse response : responses) {
      Resource resource = new ResourceImpl(Resource.Type.StackService);

      setResourceProperty(resource, STACK_NAME_PROPERTY_ID,
          stackServiceRequest.getStackName(), requestedIds);

      setResourceProperty(resource, STACK_VERSION_PROPERTY_ID,
View Full Code Here


      }
    });

    Set<Resource> resources = new HashSet<Resource>();
    for (ConfigurationResponse response : responses) {
      Resource resource = new ResourceImpl(Resource.Type.Configuration);
      resource.setProperty(CONFIGURATION_CLUSTER_NAME_PROPERTY_ID, response.getClusterName());
      resource.setProperty(CONFIGURATION_CONFIG_TYPE_PROPERTY_ID, response.getType());
      resource.setProperty(CONFIGURATION_CONFIG_TAG_PROPERTY_ID, response.getVersionTag());

      if (null != response.getConfigs() && response.getConfigs().size() > 0) {
        Map<String, String> configs = response.getConfigs();

        for (Entry<String, String> entry : configs.entrySet()) {
          String id = PropertyHelper.getPropertyId("properties", entry.getKey());
          resource.setProperty(id, entry.getValue());
        }
      }
      resources.add(resource);
    }
    return resources;
View Full Code Here

    Set<String>   requestedIds = getRequestPropertyIds(request, predicate);
    Set<Resource> resources    = new HashSet<Resource>();

    for (HostResponse response : responses) {
      Resource resource = new ResourceImpl(Resource.Type.Host);

      // TODO : properly handle more than one cluster
      if (response.getClusterName() != null
          && !response.getClusterName().isEmpty()) {
        setResourceProperty(resource, HOST_CLUSTER_NAME_PROPERTY_ID,
View Full Code Here

  private static final String PROPERTY_ID_NAGIOS_ALERTS = PropertyHelper.getPropertyId("HostRoles", "nagios_alerts");

  @Test
  public void testReadNagiosServer() throws Exception {

    Resource resource = doPopulate("NAGIOS_SERVER", Collections.<String>emptySet());
   
    Assert.assertNotNull("Expected non-null for 'nagios_alerts'",
      resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS));
  }
View Full Code Here

  
   Set<String> propertyIds = new HashSet<String>();
   propertyIds.add(PropertyHelper.getPropertyId("HostRoles", "state"));
   propertyIds.add(PROPERTY_ID_COMPONENT_NAME);
  
   Resource resource = doPopulate("NAGIOS_SERVER", propertyIds);
  
   Assert.assertNull("Expected null for 'nagios_alerts'",
     resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS));   
  }
View Full Code Here

   
   Set<String> propertyIds = new HashSet<String>();
   propertyIds.add(PropertyHelper.getPropertyId("HostRoles", "nagios_alerts"));
   propertyIds.add(PROPERTY_ID_COMPONENT_NAME);
  
   Resource resource = doPopulate("NAGIOS_SERVER", propertyIds);
  
   Assert.assertNotNull("Expected non-null for 'nagios_alerts'",
     resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS));       
  }
View Full Code Here

   
   Set<String> propertyIds = new HashSet<String>();
   propertyIds.add(PropertyHelper.getPropertyId("HostRoles", "nagios_alerts"));
   propertyIds.add(PROPERTY_ID_COMPONENT_NAME);
  
   Resource resource = doPopulate("NAGIOS_SERVER", propertyIds, true);

   Assert.assertNull("Expected null for 'nagios_alerts'",
       resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS));       
  }
View Full Code Here

  public void testReadWithRequestedJson() throws Exception {

    Set<String> propertyIds = new HashSet<String>();
    propertyIds.add(PropertyHelper.getPropertyId("HostRoles", "nagios_alerts"));
    propertyIds.add(PROPERTY_ID_COMPONENT_NAME);
    Resource resource = doPopulate("NAGIOS_SERVER", propertyIds);
    Object propertyValue = resource.getPropertyValue(PROPERTY_ID_NAGIOS_ALERTS);

    Assert.assertNotNull("Expected non-null for 'nagios_alerts'", propertyValue);
    Assert.assertTrue("Expected Map for parsed JSON", propertyValue instanceof Map);
   
    Object alertsEntry = ((Map) propertyValue).get("alerts");
View Full Code Here

      }
    }

    Set<Resource> resources = new HashSet<Resource>();
    for (TaskStatusResponse response : responses) {
      Resource resource = new ResourceImpl(Resource.Type.Task);

      setResourceProperty(resource, TASK_CLUSTER_NAME_PROPERTY_ID, clusterName, requestedIds);
      setResourceProperty(resource, TASK_REQUEST_ID_PROPERTY_ID, request_id, requestedIds);
      setResourceProperty(resource, TASK_ID_PROPERTY_ID, response.getTaskId(), requestedIds);
      setResourceProperty(resource, TASK_STAGE_ID_PROPERTY_ID, response.getStageId(), requestedIds);
View Full Code Here

    propertyIds.add("cat2/baz");
    propertyIds.add("cat3/sub1/bam");
    propertyIds.add("cat4/sub2/sub3/bat");
    propertyIds.add("cat5/sub5");

    Resource resource = new ResourceImpl(Resource.Type.Service);

    Assert.assertNull(resource.getPropertyValue("foo"));

    BaseProvider.setResourceProperty(resource, "foo", "value1", propertyIds);
    Assert.assertEquals("value1", resource.getPropertyValue("foo"));

    BaseProvider.setResourceProperty(resource, "cat2/bar", "value2", propertyIds);
    Assert.assertEquals("value2", resource.getPropertyValue("cat2/bar"));

    Assert.assertNull(resource.getPropertyValue("unsupported"));
    BaseProvider.setResourceProperty(resource, "unsupported", "valueX", propertyIds);
    Assert.assertNull(resource.getPropertyValue("unsupported"));

    // we should allow anything under the category cat5/sub5
    BaseProvider.setResourceProperty(resource, "cat5/sub5/prop5", "value5", propertyIds);
    Assert.assertEquals("value5", resource.getPropertyValue("cat5/sub5/prop5"));
    BaseProvider.setResourceProperty(resource, "cat5/sub5/sub5a/prop5a", "value5", propertyIds);
    Assert.assertEquals("value5", resource.getPropertyValue("cat5/sub5/sub5a/prop5a"));
    // we shouldn't allow anything under the category cat5/sub7
    BaseProvider.setResourceProperty(resource, "cat5/sub7/unsupported", "valueX", propertyIds);
    Assert.assertNull(resource.getPropertyValue("cat5/sub7/unsupported"));
  }
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.controller.spi.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.