Package org.apache.ambari.server.view.configuration

Examples of org.apache.ambari.server.view.configuration.ViewConfig


            ClassLoader cl = URLClassLoader.newInstance(new URL[]{fileEntry.toURI().toURL()});

            InputStream    configStream     = cl.getResourceAsStream(VIEW_XML);
            JAXBContext    jaxbContext      = JAXBContext.newInstance(ViewConfig.class);
            Unmarshaller   jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            ViewConfig     viewConfig       = (ViewConfig) jaxbUnmarshaller.unmarshal(configStream);
            ViewEntity viewDefinition       = installView(viewConfig, configuration, cl, fileEntry.getAbsolutePath());

            for (InstanceConfig instanceConfig : viewConfig.getInstances()) {
              ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);

              for (PropertyConfig propertyConfig : instanceConfig.getProperties()) {
                viewInstanceDefinition.putProperty(propertyConfig.getKey(), propertyConfig.getValue());
              }
View Full Code Here


    Assert.assertEquals("1.0.0", viewDefinition.getVersion());
  }

  @Test
  public void testGetConfiguration() throws Exception {
    ViewConfig viewConfig = ViewConfigTest.getConfig();
    ViewEntity viewDefinition = getViewEntity(viewConfig);
    Assert.assertEquals(viewConfig, viewDefinition.getConfiguration());
  }
View Full Code Here

    Assert.assertEquals(viewConfig, viewDefinition.getConfiguration());
  }

  @Test
  public void testGetAmbariProperty() throws Exception {
    ViewConfig viewConfig = ViewConfigTest.getConfig();
    ViewEntity viewDefinition = getViewEntity(viewConfig);
    Assert.assertEquals("v1", viewDefinition.getAmbariProperty("p1"));
    Assert.assertEquals("v2", viewDefinition.getAmbariProperty("p2"));
    Assert.assertEquals("v3", viewDefinition.getAmbariProperty("p3"));
  }
View Full Code Here

    Assert.assertEquals("/a/different/icon.png", viewDefinition.getIcon64());
  }

  @Test
  public void testGetConfiguration() throws Exception {
    ViewConfig viewConfig = ViewConfigTest.getConfig();
    ViewEntity viewDefinition = getViewEntity(viewConfig);
    Assert.assertEquals(viewConfig, viewDefinition.getConfiguration());
  }
View Full Code Here

    Assert.assertEquals(viewConfig, viewDefinition.getConfiguration());
  }

  @Test
  public void testGetAmbariProperty() throws Exception {
    ViewConfig viewConfig = ViewConfigTest.getConfig();
    ViewEntity viewDefinition = getViewEntity(viewConfig);
    Assert.assertEquals("v1", viewDefinition.getAmbariProperty("p1"));
    Assert.assertEquals("v2", viewDefinition.getAmbariProperty("p2"));
    Assert.assertEquals("v3", viewDefinition.getAmbariProperty("p3"));
  }
View Full Code Here

    Properties properties = new Properties();
    properties.put("p1", "v1");

    Configuration ambariConfig = new Configuration(properties);

    ViewConfig config = ViewConfigTest.getConfig(xml_valid_instance);
    ViewEntity viewEntity = ViewRegistryTest.getViewEntity(config, ambariConfig, getClass().getClassLoader(), "");
    ViewInstanceEntity viewInstanceEntity = ViewRegistryTest.getViewInstanceEntity(viewEntity, config.getInstances().get(0));

    viewInstanceEntity.validate(viewEntity);
  }
View Full Code Here

    Properties properties = new Properties();
    properties.put("p1", "v1");

    Configuration ambariConfig = new Configuration(properties);

    ViewConfig config = ViewConfigTest.getConfig(xml_invalid_instance);
    ViewEntity viewEntity = ViewRegistryTest.getViewEntity(config, ambariConfig, getClass().getClassLoader(), "");
    ViewInstanceEntity viewInstanceEntity = ViewRegistryTest.getViewInstanceEntity(viewEntity, config.getInstances().get(0));

    try {
      viewInstanceEntity.validate(viewEntity);
      Assert.fail("Expected an IllegalStateException");
    } catch (IllegalStateException e) {
View Full Code Here

        if (files != null) {
          for (File archiveFile : files) {
            if (!archiveFile.isDirectory()) {
              try {
                ViewConfig viewConfig = helper.getViewConfigFromArchive(archiveFile);

                String viewName    = ViewEntity.getViewName(viewConfig.getName(), viewConfig.getVersion());
                String archivePath = extractedArchivesPath + File.separator + viewName;

                // extract the archive and get the class loader
                ClassLoader cl = extractViewArchive(archiveFile, helper.getFile(archivePath));

                ViewEntity viewDefinition = createViewDefinition(viewConfig, configuration, cl, archivePath);

                Set<ViewInstanceEntity> instanceDefinitions = new HashSet<ViewInstanceEntity>();

                for (InstanceConfig instanceConfig : viewConfig.getInstances()) {
                  try {
                    instanceDefinitions.add(createViewInstanceDefinition(viewDefinition, instanceConfig));
                  } catch (Exception e) {
                    LOG.error("Caught exception adding view instance for view " +
                        viewDefinition.getViewName(), e);
View Full Code Here

  }

  // Set the entities defined in the view persistence element for the given view instance
  private static void setPersistenceEntities(ViewInstanceEntity viewInstanceDefinition) {
    ViewEntity        viewDefinition    = viewInstanceDefinition.getViewEntity();
    ViewConfig        viewConfig        = viewDefinition.getConfiguration();

    Collection<ViewEntityEntity> entities = new HashSet<ViewEntityEntity>();

    if (viewConfig != null) {
      PersistenceConfig persistenceConfig = viewConfig.getPersistence();

      if (persistenceConfig != null) {
        for (EntityConfig entityConfiguration : persistenceConfig.getEntities()) {
          ViewEntityEntity viewEntityEntity = new ViewEntityEntity();
View Full Code Here

    Properties properties = new Properties();
    properties.put("p1", "v1");

    Configuration ambariConfig = new Configuration(properties);

    ViewConfig config = ViewConfigTest.getConfig(xml);
    ViewEntity viewEntity = ViewRegistryTest.getViewEntity(config, ambariConfig, getClass().getClassLoader(), "");
    ViewRegistryTest.getViewInstanceEntity(viewEntity, config.getInstances().get(0));

    Map<Resource.Type, ViewSubResourceDefinition> resourceDefinitions = viewEntity.getResourceDefinitions();

    Assert.assertEquals(1, resourceDefinitions.size());
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.view.configuration.ViewConfig

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.