com.datatorrent.stram.client.StramAppLauncher Java Examples

The following examples show how to use com.datatorrent.stram.client.StramAppLauncher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApexDoTask.java    From incubator-samoa with Apache License 2.0 6 votes vote down vote up
public static void launch(StreamingApplication app, String name, String libjars) throws Exception {
    Configuration conf = new Configuration(true);
//    conf.set("dt.loggers.level", "org.apache.*:DEBUG, com.datatorrent.*:DEBUG");
    conf.set("dt.dfsRootDirectory", System.getProperty("dt.dfsRootDirectory"));
    conf.set("fs.defaultFS", System.getProperty("fs.defaultFS"));
    conf.set("yarn.resourcemanager.address", System.getProperty("yarn.resourcemanager.address"));
    conf.addResource(new File(System.getProperty("dt.site.path")).toURI().toURL());

    if (libjars != null) {
      conf.set(StramAppLauncher.LIBJARS_CONF_KEY_NAME, libjars);
    }
    StramAppLauncher appLauncher = new StramAppLauncher(name, conf);
    appLauncher.loadDependencies();
    StreamingAppFactory appFactory = new StreamingAppFactory(app, name);
    appLauncher.launchApp(appFactory);
  }
 
Example #2
Source File: YarnAppLauncherImpl.java    From Bats with Apache License 2.0 5 votes vote down vote up
@Override
public YarnAppHandleImpl launchApp(final StreamingApplication app, Configuration conf, Attribute.AttributeMap launchParameters) throws LauncherException
{
  if (launchParameters != null) {
    for (Map.Entry<Attribute<?>, Object> entry : launchParameters.entrySet()) {
      String property = propMapping.get(entry.getKey());
      if (property != null) {
        setConfiguration(conf, property, entry.getValue());
      }
    }
  }
  try {
    String name = app.getClass().getName();
    StramAppLauncher appLauncher = new StramAppLauncher(name, conf);
    appLauncher.loadDependencies();
    StreamingAppFactory appFactory = new StreamingAppFactory(name, app.getClass())
    {
      @Override
      public LogicalPlan createApp(LogicalPlanConfiguration planConfig)
      {
        return super.createApp(app, planConfig);
      }
    };
    ApplicationId appId = appLauncher.launchApp(appFactory);
    appLauncher.resetContextClassLoader();
    return new YarnAppHandleImpl(appId, conf);
  } catch (Exception ex) {
    throw new LauncherException(ex);
  }
}
 
Example #3
Source File: ApexCli.java    From Bats with Apache License 2.0 5 votes vote down vote up
private List<AppFactory> getMatchingAppFactories(StramAppLauncher submitApp, String matchString, boolean exactMatch)
{
  try {
    List<AppFactory> cfgList = submitApp.getBundledTopologies();

    if (cfgList.isEmpty()) {
      return null;
    } else if (matchString == null) {
      return cfgList;
    } else {
      List<AppFactory> result = new ArrayList<>();
      if (!exactMatch) {
        matchString = matchString.toLowerCase();
      }
      for (AppFactory ac : cfgList) {
        String appName = ac.getName();
        String appAlias = submitApp.getLogicalPlanConfiguration().getAppAlias(appName);
        if (exactMatch) {
          if (matchString.equals(appName) || matchString.equals(appAlias)) {
            result.add(ac);
          }
        } else if (appName.toLowerCase().contains(matchString) || (appAlias != null && appAlias.toLowerCase()
            .contains(matchString))) {
          result.add(ac);
        }
      }
      return result;
    }
  } catch (Exception ex) {
    LOG.warn("Caught Exception: ", ex);
    return null;
  }
}
 
Example #4
Source File: YarnAppLauncherImpl.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
@Override
public YarnAppHandleImpl launchApp(final StreamingApplication app, Configuration conf, Attribute.AttributeMap launchParameters) throws LauncherException
{
  if (launchParameters != null) {
    for (Map.Entry<Attribute<?>, Object> entry : launchParameters.entrySet()) {
      String property = propMapping.get(entry.getKey());
      if (property != null) {
        setConfiguration(conf, property, entry.getValue());
      }
    }
  }
  try {
    String name = app.getClass().getName();
    StramAppLauncher appLauncher = new StramAppLauncher(name, conf);
    appLauncher.loadDependencies();
    StreamingAppFactory appFactory = new StreamingAppFactory(name, app.getClass())
    {
      @Override
      public LogicalPlan createApp(LogicalPlanConfiguration planConfig)
      {
        return super.createApp(app, planConfig);
      }
    };
    ApplicationId appId = appLauncher.launchApp(appFactory);
    appLauncher.resetContextClassLoader();
    return new YarnAppHandleImpl(appId, conf);
  } catch (Exception ex) {
    throw new LauncherException(ex);
  }
}
 
Example #5
Source File: ApexCli.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
private List<AppFactory> getMatchingAppFactories(StramAppLauncher submitApp, String matchString, boolean exactMatch)
{
  try {
    List<AppFactory> cfgList = submitApp.getBundledTopologies();

    if (cfgList.isEmpty()) {
      return null;
    } else if (matchString == null) {
      return cfgList;
    } else {
      List<AppFactory> result = new ArrayList<>();
      if (!exactMatch) {
        matchString = matchString.toLowerCase();
      }
      for (AppFactory ac : cfgList) {
        String appName = ac.getName();
        String appAlias = submitApp.getLogicalPlanConfiguration().getAppAlias(appName);
        if (exactMatch) {
          if (matchString.equals(appName) || matchString.equals(appAlias)) {
            result.add(ac);
          }
        } else if (appName.toLowerCase().contains(matchString) || (appAlias != null && appAlias.toLowerCase()
            .contains(matchString))) {
          result.add(ac);
        }
      }
      return result;
    }
  } catch (Exception ex) {
    LOG.warn("Caught Exception: ", ex);
    return null;
  }
}
 
Example #6
Source File: DAGSetupPluginTests.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
@Test
public void testPropertyFileApp() throws IOException
{
  File tempFile = File.createTempFile("testTopology", "properties");
  org.apache.commons.io.IOUtils.copy(getClass().getResourceAsStream("/testTopology.properties"), new FileOutputStream(tempFile));
  StramAppLauncher.PropertyFileAppFactory factory = new StramAppLauncher.PropertyFileAppFactory(tempFile);
  Configuration conf = getConfiguration();
  LogicalPlan dag = factory.createApp(new LogicalPlanConfiguration(conf));
  validateProperties(dag);
  tempFile.delete();
}
 
Example #7
Source File: DAGSetupPluginTests.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
@Test
public void testJsonFileApp() throws IOException
{
  File tempFile = File.createTempFile("testTopology", "json");
  org.apache.commons.io.IOUtils.copy(getClass().getResourceAsStream("/testTopology.json"), new FileOutputStream(tempFile));
  StramAppLauncher.JsonFileAppFactory factory = new StramAppLauncher.JsonFileAppFactory(tempFile);
  Configuration conf = getConfiguration();
  LogicalPlan dag = factory.createApp(new LogicalPlanConfiguration(conf));
  validateProperties(dag);
  tempFile.delete();
}