Package org.apache.slider.providers.agent.application.metadata

Examples of org.apache.slider.providers.agent.application.metadata.Service


          for (String key : status.getConfigs().keySet()) {
            Map<String, String> configs = status.getConfigs().get(key);
            publishComponentConfiguration(key, key, configs.entrySet());
          }

          Service service = getMetainfo().getServices().get(0);
          List<ExportGroup> exportGroups = service.getExportGroups();
          if (exportGroups != null && !exportGroups.isEmpty()) {

            String configKeyFormat = "${site.%s.%s}";
            String hostKeyFormat = "${%s_HOST}";
View Full Code Here


    String scriptPath = null;
    List<Service> services = getMetainfo().getServices();
    if (services.size() != 1) {
      log.error("Malformed app definition: Expect only one service in the metainfo.xml");
    }
    Service service = services.get(0);
    for (Component component : service.getComponents()) {
      if (component.getName().equals(roleName)) {
        scriptPath = component.getCommandScript().getScript();
        break;
      }
    }
View Full Code Here

  protected boolean isMaster(String roleName) {
    List<Service> services = getMetainfo().getServices();
    if (services.size() != 1) {
      log.error("Malformed app definition: Expect only one service in the metainfo.xml");
    } else {
      Service service = services.get(0);
      for (Component component : service.getComponents()) {
        if (component.getName().equals(roleName)) {
          if (component.getCategory().equals("MASTER")) {
            return true;
          } else {
            return false;
View Full Code Here

  protected boolean canPublishConfig(String roleName) {
    List<Service> services = getMetainfo().getServices();
    if (services.size() != 1) {
      log.error("Malformed app definition: Expect only one service in the metainfo.xml");
    } else {
      Service service = services.get(0);
      for (Component component : service.getComponents()) {
        if (component.getName().equals(roleName)) {
          return Boolean.TRUE.toString().equals(component.getPublishConfig());
        }
      }
    }
View Full Code Here

    if (canAnyMasterPublish == null) {
      List<Service> services = getMetainfo().getServices();
      if (services.size() != 1) {
        log.error("Malformed app definition: Expect only one service in the metainfo.xml");
      } else {
        Service service = services.get(0);
        for (Component component : service.getComponents()) {
          if (Boolean.TRUE.toString().equals(component.getPublishConfig()) &&
              component.getCategory().equals("MASTER")) {
            canAnyMasterPublish = true;
          }
        }
View Full Code Here

    AgentProviderService mockAps = Mockito.spy(aps);
    doReturn(access).when(mockAps).getAmState();
    doReturn("scripts/hbase_master.py").when(mockAps).getScriptPathFromMetainfo(anyString());
    Metainfo metainfo = new Metainfo();
    metainfo.addService(new Service());
    doReturn(metainfo).when(mockAps).getApplicationMetainfo(any(SliderFileSystem.class), anyString());

    try {
      doReturn(true).when(mockAps).isMaster(anyString());
      doNothing().when(mockAps).addInstallCommand(
View Full Code Here

  @Test
  public void testMetainfoParsing() throws Exception {
    InputStream metainfo_1 = new ByteArrayInputStream(metainfo_1_str.getBytes());
    Metainfo metainfo = new MetainfoParser().parse(metainfo_1);
    Assert.assertEquals(metainfo.getServices().size(), 1);
    Service service = metainfo.getServices().get(0);
    log.info("Service: " + service.toString());
    Assert.assertEquals(service.getName(), "HBASE");
    Assert.assertEquals(service.getComponents().size(), 2);
    List<Component> components = service.getComponents();
    int found = 0;
    for (Component component : components) {
      if (component.getName().equals("HBASE_MASTER")) {
        Assert.assertEquals(component.getMinInstanceCount(), "1");
        Assert.assertEquals(component.getMaxInstanceCount(), "2");
        Assert.assertEquals(component.getCommandScript().getScript(), "scripts/hbase_master.py");
        Assert.assertEquals(component.getCategory(), "MASTER");
        found++;
      }
      if (component.getName().equals("HBASE_REGIONSERVER")) {
        Assert.assertEquals(component.getMinInstanceCount(), "1");
        Assert.assertNull(component.getMaxInstanceCount());
        Assert.assertEquals(component.getCommandScript().getScript(), "scripts/hbase_regionserver.py");
        Assert.assertEquals(component.getCategory(), "SLAVE");
        found++;
      }
    }
    Assert.assertEquals(found, 2);

    assert service.getExportGroups().size() == 1;
    List<ExportGroup> egs = service.getExportGroups();
    ExportGroup eg = egs.get(0);
    assert eg.getName().equals("QuickLinks");
    assert eg.getExports().size() == 2;

    found = 0;
    for (Export export : eg.getExports()) {
      if (export.getName().equals("JMX_Endpoint")) {
        found++;
        Assert.assertEquals(export.getValue(),
            "http://${HBASE_MASTER_HOST}:${site.hbase-site.hbase.master.info.port}/jmx");
      }
      if (export.getName().equals("Master_Status")) {
        found++;
        Assert.assertEquals(export.getValue(),
            "http://${HBASE_MASTER_HOST}:${site.hbase-site.hbase.master.info.port}/master-status");
      }
    }
    Assert.assertEquals(found, 2);

    List<CommandOrder> cmdOrders = service.getCommandOrder();
    Assert.assertEquals(cmdOrders.size(), 2);
    found = 0;
    for (CommandOrder co : service.getCommandOrder()) {
      if (co.getCommand().equals("HBASE_REGIONSERVER-START")) {
        Assert.assertTrue(co.getRequires().equals("HBASE_MASTER-STARTED"));
        found++;
      }
      if (co.getCommand().equals("A-START")) {
View Full Code Here

  public Set<String> getApplicationTags(SliderFileSystem fileSystem,
                                        String appDef) throws SliderException {
    Set<String> tags;
    try {
      Metainfo metainfo = AgentUtils.getApplicationMetainfo(fileSystem, appDef);
      Service service = metainfo.getServices().get(0);
      tags = new HashSet<>();
      tags.add("Name: " + service.getName());
      tags.add("Version: " + service.getVersion());
      tags.add("Description: " + SliderUtils.truncate(service.getComment(), 80));
    } catch (IOException e) {
      log.error("error retrieving metainfo from {}", appDef, e);
      throw new SliderException("error retrieving metainfo", e);
    }
View Full Code Here

            Metainfo metainfo = new MetainfoParser().parse(zipFile
                                                               .getInputStream(zipFile.getEntry("metainfo.xml")));
            // Create app type object
            if (metainfo.getServices() != null
                && metainfo.getServices().size() > 0) {
              Service service = metainfo.getServices().get(0);
              String appConfigJsonString = IOUtils.toString(
                  zipFile.getInputStream(zipFile.getEntry("appConfig.json")),
                  "UTF-8");
              String resourcesJsonString = IOUtils.toString(
                  zipFile.getInputStream(zipFile.getEntry("resources.json")),
                  "UTF-8");
              JsonElement appConfigJson = new JsonParser()
                  .parse(appConfigJsonString);
              JsonElement resourcesJson = new JsonParser()
                  .parse(resourcesJsonString);
              SliderAppType appType = new SliderAppType();
              appType.setId(service.getName());
              appType.setTypeName(service.getName());
              appType.setTypeDescription(service.getComment());
              appType.setTypeVersion(service.getVersion());
              appType.setTypePackageFileName(appZip.getName());
              // Configs
              Map<String, String> configsMap = new HashMap<String, String>();
              JsonObject appTypeGlobalJson = appConfigJson.getAsJsonObject()
                  .get("global").getAsJsonObject();
              for (Entry<String, JsonElement> e : appTypeGlobalJson.entrySet()) {
                configsMap.put(e.getKey(), e.getValue().getAsString());
              }
              appType.setTypeConfigs(configsMap);
              // Components
              ArrayList<SliderAppTypeComponent> appTypeComponentList = new ArrayList<SliderAppTypeComponent>();
              for (Component component : service.getComponents()) {
                if ("CLIENT".equals(component.getCategory())) {
                  continue;
                }
                SliderAppTypeComponent appTypeComponent = new SliderAppTypeComponent();
                appTypeComponent.setDisplayName(component.getName());
View Full Code Here

TOP

Related Classes of org.apache.slider.providers.agent.application.metadata.Service

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.