Assembles the configuration for an Evaluator.

@param resourceLaunchEvent
@return
@throws IOException
513085
private Configuration makeEvaluatorConfiguration(final ResourceLaunchEvent resourceLaunchEvent)
      throws IOException {
    return Tang.Factory.getTang()
        .newConfigurationBuilder(resourceLaunchEvent.getEvaluatorConf())
        .build();
  }
175268
public static void main(final String[] args) throws Exception {
    LOG.log(Level.INFO, "Entering EvaluatorShimLauncher.main().");

    final Injector injector = Tang.Factory.getTang().newInjector(parseCommandLine(args));
    final EvaluatorShimLauncher launcher = injector.getInstance(EvaluatorShimLauncher.class);
    launcher.launch();
  }
699789
public void submitTask(final String evaluatorConfiguration, final String taskConfiguration) {
    final Configuration contextConfiguration = ContextConfiguration.CONF
        .set(ContextConfiguration.IDENTIFIER, "RootContext_" + this.getId())
        .build();
    final String contextConfigurationString = this.configurationSerializer.toString(contextConfiguration);
    this.launchWithConfigurationString(
        evaluatorConfiguration, contextConfigurationString,  Optional.<String>empty(), Optional.of(taskConfiguration));
  }
1241767
public static void assertLauncherGood(File launcher) throws IOException {
    if (!launcher.exists()) {
      throw new IOException("Unknown file: " + launcher.getPath());
    }

    if (!launcher.isFile()) {
      throw new IOException("Not a real file: " + launcher.getPath());
    }

    if (!FileHandler.canExecute(launcher)) {
      throw new IOException("Not executable: " + launcher.getPath());
    }
  }
1350163
public int launch(final String configurationHdfsPath, final String jobHdfsPath) throws Exception {
        // create hadoop configuration directory
        final File hadoopConfDir = createTemporaryHadoopConfDir();

        final SparkLauncher sparkLauncher =
                createSparkLauncher(hadoopConfDir, configurationHdfsPath, jobHdfsPath, null);

        return launch(sparkLauncher);
    }
264289
private void initializeAppLauncherAndServices() throws Exception {
    // Done to preserve backwards compatibility with the previously hard-coded timeout of 5 minutes
    Properties properties = ConfigUtils.configToProperties(this.config);
    if (!properties.contains(ServiceBasedAppLauncher.APP_STOP_TIME_SECONDS)) {
      properties.setProperty(ServiceBasedAppLauncher.APP_STOP_TIME_SECONDS, Long.toString(300));
    }
    this.applicationLauncher = new ServiceBasedAppLauncher(properties, this.clusterName);

    // create a job catalog for keeping track of received jobs if a job config path is specified
    if (this.config.hasPath(GobblinClusterConfigurationKeys.GOBBLIN_CLUSTER_PREFIX
        + ConfigurationKeys.JOB_CONFIG_FILE_GENERAL_PATH_KEY)) {
      String jobCatalogClassName = ConfigUtils.getString(config, GobblinClusterConfigurationKeys.JOB_CATALOG_KEY,
          GobblinClusterConfigurationKeys.DEFAULT_JOB_CATALOG);

      this.jobCatalog =
          (MutableJobCatalog) GobblinConstructorUtils.invokeFirstConstructor(Class.forName(jobCatalogClassName),
          ImmutableList.of(config
              .getConfig(StringUtils.removeEnd(GobblinClusterConfigurationKeys.GOBBLIN_CLUSTER_PREFIX, "."))
              .withFallback(this.config)));
    } else {
      this.jobCatalog = null;
    }

    SchedulerService schedulerService = new SchedulerService(properties);
    this.applicationLauncher.addService(schedulerService);
    this.jobScheduler = buildGobblinHelixJobScheduler(config, this.appWorkDir, getMetadataTags(clusterName, applicationId),
        schedulerService);
    this.applicationLauncher.addService(this.jobScheduler);
    this.jobConfigurationManager = buildJobConfigurationManager(config);
    this.applicationLauncher.addService(this.jobConfigurationManager);
  }
1062953
private EvaluatorManager getNewEvaluatorManagerInstance(final String id, final EvaluatorDescriptor desc) {
    LOG.log(Level.FINEST, "Creating Evaluator Manager for Evaluator ID {0}", id);
    final Injector child = this.injector.forkInjector();

    try {
      child.bindVolatileParameter(EvaluatorManager.EvaluatorIdentifier.class, id);
      child.bindVolatileParameter(EvaluatorManager.EvaluatorDescriptorName.class, desc);
    } catch (final BindException e) {
      throw new RuntimeException("Unable to bind evaluator identifier and name.", e);
    }

    final EvaluatorManager result;
    try {
      result = child.getInstance(EvaluatorManager.class);
    } catch (final InjectionException e) {
      throw new RuntimeException("Unable to instantiate a new EvaluatorManager for Evaluator ID: " + id, e);
    }
    return result;
  }
1128575
@SuppressWarnings("unchecked")
    @Override
    public synchronized <T> Evaluator<T> createEvaluator(String source, ClassType projection, String[] names,
            Type[] types, Class<?>[] classes, Map<String, Object> constants) {
        try {
            final String id = toId(source, projection.getJavaClass(), types, constants.values());
            Method method = cache.get(id);
                        
            if (method == null) {
                Class<?> clazz;
                try {
                    clazz = loader.loadClass(id);
                } catch (ClassNotFoundException e) {
                    compile(source, projection, names, types, id, constants);
                    // reload
                    clazz = loader.loadClass(id);
                }
                method = findEvalMethod(clazz);
                cache.put(id, method);
            }
            
            return new MethodEvaluator<T>(method, constants, (Class) projection.getJavaClass());
        } catch (ClassNotFoundException e) {
            throw new CodegenException(e);
        } catch (SecurityException e) {
            throw new CodegenException(e);
        } catch (IOException e) {
            throw new CodegenException(e);
        }
    }
114966
public Reader create(Reader input, String configuration, String defaultConfiguration) throws IOException {
    if(defaultConfiguration==null) {
      defaultConfiguration = defaultArgument;
    }
    if (configs != null && configs.size() > 0) {
      if (configuration == null && defaultConfiguration == null) {
        throw new IOException("no (default)configuration");
      } else if (configuration == null) {
        if (configs.get(defaultConfiguration) != null) {
          return create(input, configs.get(defaultConfiguration));
        } else {
          throw new IOException(
              "default configuration " + defaultConfiguration + " not available");
        }
      } else {
        MtasConfiguration config = configs.get(configuration);
        if (config == null) {
          if (defaultConfiguration != null) {
            if (configs.get(defaultConfiguration) != null) {
              return create(input, configs.get(defaultConfiguration));
            } else {
              throw new IOException("configuration " + configuration
                  + " not found and default configuration " + defaultConfiguration
                  + " not available");
            }
          } else {
            throw new IOException("configuration " + configuration
                + " not available and no default configuration");
          }
        } else {
          return create(input, config);
        }
      }
    } else if (config != null) {
      return create(input, config);
    } else {
      throw new IOException("no configuration");
    }

  }
418390
void onResourceLaunchRequest(
      final ResourceLaunchEvent launchRequest) {

    synchronized (this.theContainers) {

      final Container c = this.theContainers.get(launchRequest.getIdentifier());

      try (final LoggingScope lb = this.loggingScopeFactory
          .getNewLoggingScope("ResourceManager.onResourceLaunchRequest:evaluatorConfigurationFile")) {
        // Add the global files and libraries.
        c.addGlobalFiles(this.fileNames.getGlobalFolder());
        c.addLocalFiles(getLocalFiles(launchRequest));

        // Make the configuration file of the evaluator.
        final File evaluatorConfigurationFile = new File(c.getFolder(), fileNames.getEvaluatorConfigurationPath());

        try {
          this.configurationSerializer.toFile(launchRequest.getEvaluatorConf(), evaluatorConfigurationFile);
        } catch (final IOException | BindException e) {
          throw new RuntimeException("Unable to write configuration.", e);
        }
      }

      try (final LoggingScope lc = this.loggingScopeFactory
          .getNewLoggingScope("ResourceManager.onResourceLaunchRequest:runCommand")) {

        final List<String> command = getLaunchCommand(launchRequest, c.getMemory());
        LOG.log(Level.FINEST, "Launching container: {0}", c);
        c.run(command);
      }
    }
  }
328108
public FutureAPIResponse createEventAsFuture(Event event) throws IOException {
    RequestBuilder builder = new RequestBuilder("POST");
    builder.setUrl(apiUrl + "/events.json?accessKey=" + accessKey);
    String requestJsonString = event.toJsonString();
    builder.setBody(requestJsonString);
    builder.setHeader("Content-Type", "application/json");
    builder.setHeader("Content-Length", "" + requestJsonString.length());
    return new FutureAPIResponse(client.executeRequest(builder.build(), getHandler()));
  }
1356883
JobSubmissionEventImpl.Builder getJobSubmissionBuilder(final Configuration driverConfiguration)
      throws InjectionException, IOException {
    final Injector injector = Tang.Factory.getTang().newInjector(driverConfiguration);

    final boolean preserveEvaluators = injector.getNamedInstance(ResourceManagerPreserveEvaluators.class);
    final int maxAppSubmissions = injector.getNamedInstance(MaxApplicationSubmissions.class);

    final JobSubmissionEventImpl.Builder jbuilder = JobSubmissionEventImpl.newBuilder()
        .setIdentifier(returnOrGenerateDriverId(injector.getNamedInstance(DriverIdentifier.class)))
        .setDriverMemory(injector.getNamedInstance(DriverMemory.class))
        .setDriverCpuCores(injector.getNamedInstance(DriverCPUCores.class))
        .setUserName(System.getProperty("user.name"))
        .setPreserveEvaluators(preserveEvaluators)
        .setMaxApplicationSubmissions(maxAppSubmissions)
        .setConfiguration(driverConfiguration);

    for (final String globalFileName : injector.getNamedInstance(JobGlobalFiles.class)) {
      LOG.log(Level.FINEST, "Adding global file: {0}", globalFileName);
      jbuilder.addGlobalFile(getFileResourceProto(globalFileName, FileType.PLAIN));
    }

    for (final String globalLibraryName : injector.getNamedInstance(JobGlobalLibraries.class)) {
      LOG.log(Level.FINEST, "Adding global library: {0}", globalLibraryName);
      jbuilder.addGlobalFile(getFileResourceProto(globalLibraryName, FileType.LIB));
    }

    for (final String localFileName : injector.getNamedInstance(DriverLocalFiles.class)) {
      LOG.log(Level.FINEST, "Adding local file: {0}", localFileName);
      jbuilder.addLocalFile(getFileResourceProto(localFileName, FileType.PLAIN));
    }

    for (final String localLibraryName : injector.getNamedInstance(DriverLocalLibraries.class)) {
      LOG.log(Level.FINEST, "Adding local library: {0}", localLibraryName);
      jbuilder.addLocalFile(getFileResourceProto(localLibraryName, FileType.LIB));
    }

    return jbuilder;
  }
101986
@Override
    public void initialize(URL location, ResourceBundle resources) {

        DelegatingOutputStreamAppender.setStaticOutputStream(new TextAreaOutputStream(console));

        FxUtils.bindVisible(projectGroup, projectState.isLocking().not());
        FxUtils.bindVisible(genScriptGroup, projectState.isLoaded());
        FxUtils.bindVisible(browsingGroup, projectState.isBrowsing());

        // FxUtils.bindVisible(maximizeButton, windowMaximized.not());
        // FxUtils.bindVisible(minimizeButton, windowMaximized);

        messageView.setTextArea(console);
        StdoutListenerContainer.getInstance().getStdoutListeners()
                .add(new TextAreaStdoutListener(console));
        StdoutListenerContainer.getInstance().getStderrListeners()
                .add(new TextAreaStdoutListener(console));

        testToolbarController.initialize(messageView, fileTreeController, projectState,
                editorTabController, editorTabController, editorTabController);
        testToolbarController.testService = testService;
        sampleToolbarController.initialize(messageView, testToolbarController, projectState);
        diffEvidenceToolbarController.initialize(messageView, fileTreeController, projectState);

        fileTreeController.setTestRunnable(testToolbarController);
        fileTreeController.fileOpenable = editorTabController;
        fileTreeController.scriptService = scriptService;

        editorTabController.setTabs(editorTab);
        editorTabController.setScriptService(scriptService);
        editorTabController.initialize();
        FxUtils.bindDisable(saveButton, editorTabController.getEmpty());
        FxUtils.bindDisable(saveAsButton, editorTabController.getEmpty());

        menuBarController.setProjectState(projectState);
        menuBarController.setAppController(this);
        menuBarController.setEditorTabController(editorTabController);
        menuBarController.setTestToolbarController(testToolbarController);
        menuBarController.setDiffEvidenceToolbarController(diffEvidenceToolbarController);
        menuBarController.setSampleToolbarController(sampleToolbarController);
        menuBarController.initialize();
    }
545258
public FutureAPIResponse createEventsAsFuture(List<Event> events) throws IOException {
    RequestBuilder builder = new RequestBuilder("POST");
    builder.setUrl(apiUrl + "/batch/events.json?accessKey=" + accessKey);

    GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(DateTime.class, new DateTimeAdapter());
    Gson gson = gsonBuilder.create();
    String requestJsonString = gson.toJson(events);

    builder.setBody(requestJsonString);
    builder.setHeader("Content-Type", "application/json");
    builder.setHeader("Content-Length", "" + requestJsonString.length());
    return new FutureAPIResponse(client.executeRequest(builder.build(), getHandler()));
  }
563819
static void init() {// NOPMD

		determineIfNTEventLogIsSupported();

		URL resource = null;

		final String configurationOptionStr = OptionConverter.getSystemProperty(DEFAULT_CONFIGURATION_KEY, null);

		if (configurationOptionStr != null) {
			try {
				resource = new URL(configurationOptionStr);
			} catch (MalformedURLException ex) {
				// so, resource is not a URL:
				// attempt to get the resource from the class path
				resource = Loader.getResource(configurationOptionStr);
			}
		}
		if (resource == null) {
			resource = Loader.getResource(DEFAULT_CONFIGURATION_FILE); // NOPMD
		}

		if (resource == null) {
			System.err.println("[FoundationLogger] Can not find resource: " + DEFAULT_CONFIGURATION_FILE); // NOPMD
			throw new FoundationIOException("Can not find resource: " + DEFAULT_CONFIGURATION_FILE); // NOPMD
		}

		// update the log manager to use the Foundation repository.
		final RepositorySelector foundationRepositorySelector = new FoundationRepositorySelector(FoundationLogFactory.foundationLogHierarchy);
		LogManager.setRepositorySelector(foundationRepositorySelector, null);

		// set logger to info so we always want to see these logs even if root
		// is set to ERROR.
		final Logger logger = getLogger(FoundationLogger.class);

		final String logPropFile = resource.getPath();
		log4jConfigProps = getLogProperties(resource);
		
		// select and configure again so the loggers are created with the right
		// level after the repository selector was updated.
		OptionConverter.selectAndConfigure(resource, null, FoundationLogFactory.foundationLogHierarchy);

		// start watching for property changes
		setUpPropFileReloading(logger, logPropFile, log4jConfigProps);

		// add syslog appender or windows event viewer appender
//		setupOSSystemLog(logger, log4jConfigProps);

		// parseMarkerPatterns(log4jConfigProps);
		// parseMarkerPurePattern(log4jConfigProps);
//		udpateMarkerStructuredLogOverrideMap(logger);

        AbstractFoundationLoggingMarker.init();

		updateSniffingLoggersLevel(logger);

        setupJULSupport(resource);

    }
43114
public Configuration createFromResource(String resourceName) {
        Exceptions.nullArgument("resourceName", resourceName);

        Configuration configuration;
        try {
            InputStream stream = null;
            try {
                stream = Utils.openResourceStream(resourceName);

                if (stream != null) {
                    configuration = create(stream);
                } else {
                    throw new TextProcessorFactoryException("Can't find or open resource \"" + resourceName + "\".");
                }
            } finally {
                if (stream != null) {
                    stream.close();
                }
            }
        } catch (IOException e) {
            throw new TextProcessorFactoryException(e);
        }

        return configuration;
    }
46885
private void init() throws IOException {
    WR = new Path(conf.get("fs.snapshot.waitingroom", "/.WR"));
    WR = WR.makeQualified(dfs);
  }