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

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


  }

  @Test
  public void testFinalizeProperties__collection_properties() {
    SchemaFactory schemaFactory = createNiceMock(SchemaFactory.class);
    Schema schema = createNiceMock(Schema.class);

    // schema expectations
    expect(schemaFactory.getSchema(Resource.Type.Service)).andReturn(schema).anyTimes();
    expect(schema.getKeyPropertyId(Resource.Type.Service)).andReturn("ServiceInfo/service_name").anyTimes();

    replay(schemaFactory, schema);

    HashSet<String> serviceProperties = new HashSet<String>();
    serviceProperties.add("foo/bar");
View Full Code Here


  }

  @Test
  public void testFinalizeProperties__instance_subResource_noProperties() {
    SchemaFactory schemaFactory = createNiceMock(SchemaFactory.class);
    Schema serviceSchema = createNiceMock(Schema.class);
    Schema componentSchema = createNiceMock(Schema.class);

    // schema expectations
    expect(schemaFactory.getSchema(Resource.Type.Service)).andReturn(serviceSchema).anyTimes();
    expect(serviceSchema.getKeyPropertyId(Resource.Type.Service)).andReturn("ServiceInfo/service_name").anyTimes();
    expect(schemaFactory.getSchema(Resource.Type.Component)).andReturn(componentSchema).anyTimes();
    expect(componentSchema.getKeyPropertyId(Resource.Type.Component)).andReturn("ServiceComponentInfo/component_name").anyTimes();

    replay(schemaFactory, serviceSchema, componentSchema);

    HashSet<String> serviceProperties = new HashSet<String>();
    QueryInfo rootQuery = new QueryInfo(new ServiceResourceDefinition(), serviceProperties);
View Full Code Here

  }

  @Test
  public void testFinalizeProperties__instance_subResource_properties() {
    SchemaFactory schemaFactory = createNiceMock(SchemaFactory.class);
    Schema serviceSchema = createNiceMock(Schema.class);
    Schema componentSchema = createNiceMock(Schema.class);

    // schema expectations
    expect(schemaFactory.getSchema(Resource.Type.Service)).andReturn(serviceSchema).anyTimes();
    expect(serviceSchema.getKeyPropertyId(Resource.Type.Service)).andReturn("ServiceInfo/service_name").anyTimes();
    expect(schemaFactory.getSchema(Resource.Type.Component)).andReturn(componentSchema).anyTimes();
    expect(componentSchema.getKeyPropertyId(Resource.Type.Component)).andReturn("ServiceComponentInfo/component_name").anyTimes();

    replay(schemaFactory, serviceSchema, componentSchema);

    HashSet<String> serviceProperties = new HashSet<String>();
    serviceProperties.add("foo/bar");
View Full Code Here

  }

  @Test
  public void testFinalizeProperties__collection_subResource_noProperties() {
    SchemaFactory schemaFactory = createNiceMock(SchemaFactory.class);
    Schema serviceSchema = createNiceMock(Schema.class);
    Schema componentSchema = createNiceMock(Schema.class);

    // schema expectations
    expect(schemaFactory.getSchema(Resource.Type.Service)).andReturn(serviceSchema).anyTimes();
    expect(serviceSchema.getKeyPropertyId(Resource.Type.Service)).andReturn("ServiceInfo/service_name").anyTimes();
    expect(schemaFactory.getSchema(Resource.Type.Component)).andReturn(componentSchema).anyTimes();
    expect(componentSchema.getKeyPropertyId(Resource.Type.Component)).andReturn("ServiceComponentInfo/component_name").anyTimes();

    replay(schemaFactory, serviceSchema, componentSchema);

    HashSet<String> serviceProperties = new HashSet<String>();
    QueryInfo rootQuery = new QueryInfo(new ServiceResourceDefinition(), serviceProperties);
View Full Code Here

  }

  @Test
  public void testFinalizeProperties__collection_subResource_propertiesTopLevelOnly() {
    SchemaFactory schemaFactory = createNiceMock(SchemaFactory.class);
    Schema serviceSchema = createNiceMock(Schema.class);
    Schema componentSchema = createNiceMock(Schema.class);

    // schema expectations
    expect(schemaFactory.getSchema(Resource.Type.Service)).andReturn(serviceSchema).anyTimes();
    expect(serviceSchema.getKeyPropertyId(Resource.Type.Service)).andReturn("ServiceInfo/service_name").anyTimes();
    expect(schemaFactory.getSchema(Resource.Type.Component)).andReturn(componentSchema).anyTimes();
    expect(componentSchema.getKeyPropertyId(Resource.Type.Component)).andReturn("ServiceComponentInfo/component_name").anyTimes();

    replay(schemaFactory, serviceSchema, componentSchema);

    HashSet<String> serviceProperties = new HashSet<String>();
    serviceProperties.add("foo/bar");
View Full Code Here

        if (!href.endsWith("/")) {
          href = href + '/';
        }

        Schema schema = getClusterController().getSchema(r.getType());
        Object id     = r.getPropertyValue(schema.getKeyPropertyId(r.getType()));

        href = parent.getProperty("isCollection").equals("true") ?
            href + id : href + parent.getName() + '/' + id;
      }
      resultNode.setProperty("href", href);
View Full Code Here

    public void process(Request request, TreeNode<Resource> resultNode, String href) {
      TreeNode<Resource> parent = resultNode.getParent();

      if (parent.getParent() != null && parent.getParent().getObject().getType() == Resource.Type.HostComponent) {
        Resource r = resultNode.getObject();
        Schema schema = ClusterControllerHelper.getClusterController().getSchema(r.getType());
        Object serviceId = r.getPropertyValue(schema.getKeyPropertyId(Resource.Type.Service));
        Object componentId = r.getPropertyValue(schema.getKeyPropertyId(r.getType()));

        href = href.substring(0, href.indexOf("/hosts/") + 1) +
            "services/" + serviceId + "/components/" + componentId;

        resultNode.setProperty("href", href);
View Full Code Here

 
  private class RootServiceHostComponentHrefProcessor extends BaseHrefPostProcessor {
    @Override
    public void process(Request request, TreeNode<Resource> resultNode, String href) {
      Resource r = resultNode.getObject();
      Schema schema = ClusterControllerHelper.getClusterController().getSchema(r.getType());
      Object host = r.getPropertyValue(schema.getKeyPropertyId(Resource.Type.Host));
      Object hostComponent = r.getPropertyValue(schema.getKeyPropertyId(r.getType()));

      int idx = href.indexOf("services/") + "services/".length();
      idx = href.indexOf("/", idx) + 1;

      href = href.substring(0, idx) + "hosts/" + host + "/hostComponents/" + hostComponent;
View Full Code Here

        if (!href.endsWith("/")) {
          href = href + '/';
        }

        Schema schema = getClusterController().getSchema(r.getType());
        Object id     = r.getPropertyValue(schema.getKeyPropertyId(r.getType()));

        href = parent.getProperty("isCollection").equals("true") ?
            href + id : href + parent.getName() + '/' + id;
      }
      resultNode.setProperty("href", href);
View Full Code Here

  private class HostComponentHrefProcessor extends BaseHrefPostProcessor {
    @Override
    public void process(Request request, TreeNode<Resource> resultNode, String href) {
      if (! href.contains("/hosts/")) {
        Resource r = resultNode.getObject();
        Schema schema = ClusterControllerHelper.getClusterController().getSchema(r.getType());
        Object host = r.getPropertyValue(schema.getKeyPropertyId(Resource.Type.Host));
        Object hostComponent = r.getPropertyValue(schema.getKeyPropertyId(r.getType()));

        int idx = href.indexOf("clusters/") + "clusters/".length();
        idx = href.indexOf("/", idx) + 1;

        href = href.substring(0, idx) +
View Full Code Here

TOP

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

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.