Runs {@link TcasesCommand Tcases} with the specified options.
547488
public void execute() throws BuildException
    {
    try
      {
      log( "Generating test cases for inputDef=" + options_.getInputDef());

      File logFile = getLogFile();
      if( logFile != null)
        {
        System.setProperty( "tcases.log.file", logFile.getAbsolutePath());
        log( "For details, see " + logFile.getAbsolutePath());
        }

      TcasesCommand.run( options_);
      }
    catch( Exception e)
      {
      throw new BuildException( e, getLocation());
      }
    }
918276
private void runCustomPasses(CustomPassExecutionTime executionTime) {
    if (options.customPasses != null) {
      Tracer t = newTracer("runCustomPasses");
      try {
        for (CompilerPass p : options.customPasses.get(executionTime)) {
          process(p);
        }
      } finally {
        stopTracer(t, "runCustomPasses");
      }
    }
  }
301446
public void run() throws IOException, ClassNotFoundException, Util.Exit {
        int i = 0;
        if (outFile != null) {
            /* Everything goes to one big file... */
            ByteArrayOutputStream bout = new ByteArrayOutputStream(8192);
            writeFileTop(bout); /* only once */

            for (TypeElement t: classes) {
                write(bout, t);
            }

            writeIfChanged(bout.toByteArray(), outFile);
        } else {
            /* Each class goes to its own file... */
            for (TypeElement t: classes) {
                ByteArrayOutputStream bout = new ByteArrayOutputStream(8192);
                writeFileTop(bout);
                write(bout, t);
                writeIfChanged(bout.toByteArray(), getFileObject(t.getQualifiedName()));
            }
        }
    }
1024151
public void process(CAS tcas) {

		String text = tcas.getDocumentText();
		Document document = new DocumentImpl(text);

		cogroo.analyze(document);

		for (Sentence sentence : document.getSentences()) {

			// create sentence annotations
			AnnotationFS sentenceAnn = tcas.createAnnotation(mSentenceType,
					sentence.getStart(), sentence.getEnd());
			tcas.getIndexRepository().addFS(sentenceAnn);

			int sentenceOffset = sentence.getStart();

			AnnotationFS[] tokenAnnotationArr = new AnnotationFS[sentence
					.getTokens().size()];
			int i = 0;
			for (Token token : sentence.getTokens()) {
				// create token annotations
				tokenAnnotationArr[i] = tcas.createAnnotation(mTokenType,
						sentenceOffset + token.getStart(), sentenceOffset
								+ token.getEnd());

				// add POSTag annotations
				tokenAnnotationArr[i].setStringValue(this.mPosFeature,
						token.getPOSTag());

				// add lexeme annotations
				tokenAnnotationArr[i].setStringValue(this.mLexemeFeature,
						token.getLexeme());

				// add lemma annotations
				StringArrayFS lemmas = tcas.createStringArrayFS(token
						.getLemmas().length);
				lemmas.copyFromArray(token.getLemmas(), 0, 0,
						token.getLemmas().length);
				tokenAnnotationArr[i].setFeatureValue(this.mLemmaFeature,
						lemmas);

				tokenAnnotationArr[i].setStringValue(this.mFeaturesFeature,
						token.getFeatures());

				tcas.getIndexRepository().addFS(tokenAnnotationArr[i]);
				i++;
			}

			// chunks
			for (Chunk chunk : sentence.getChunks()) {

				int start = sentence.getTokens().get(chunk.getStart())
						.getStart()
						+ sentenceOffset;
				int end = sentence.getTokens().get(chunk.getEnd() - 1).getEnd()
						+ sentenceOffset;

				AnnotationFS chunkAnn = tcas.createAnnotation(mChunkType,
						start, end);

				chunkAnn.setStringValue(mChunkFeature, chunk.getTag());

				if(chunk.getHeadIndex() >= 0) {
					chunkAnn.setFeatureValue(mChunkHead,
							tokenAnnotationArr[chunk.getHeadIndex()]);
				}

				tcas.getIndexRepository().addFS(chunkAnn);
			}

			// syntactic chunk
			for (SyntacticChunk sc : sentence.getSyntacticChunks()) {
				int start = sentence.getTokens().get(sc.getStart()).getStart()
						+ sentenceOffset;
				int end = sentence.getTokens().get(sc.getEnd() - 1).getEnd()
						+ sentenceOffset;

				AnnotationFS syntChunkAnn = tcas.createAnnotation(
						mSyntacticChunkType, start, end);

				syntChunkAnn.setStringValue(mSyntacticChunkFeature, sc.getTag());

				tcas.getIndexRepository().addFS(syntChunkAnn);
			}
		}
	}
1267828
private void processOptions(OptionSet options) {
    Pseudorandom.get().setSeed(options.valueOf(randomSeed));

    if (opts.contains(CommonOptions.MAP_REDUCE)) {
      MapReduceConfiguration.setMapReduceExecutor(new LocalMapReduceExecutor(
          options.valueOf(mrMaxThreads), options.valueOf(mrMaxBatchesPerThread)));
    }

    if (opts.contains(CommonOptions.STOCHASTIC_GRADIENT) || opts.contains(CommonOptions.LBFGS)) {
      LogFunction log = null;
      if (parsedOptions.has(logBrief)) {
        log = new NullLogFunction();
      } else {
         log = new DefaultLogFunction(parsedOptions.valueOf(logInterval), false,
             options.valueOf(logParametersInterval), options.valueOf(logParametersDir));
      }
      LogFunctions.setLogFunction(log);
    }
  }
895399
public void run(T configuration, Environment environment) throws Exception {
        for (ConfiguredBundle<? super T> bundle : configuredBundles) {
            bundle.run(configuration, environment);
        }
    }
1270730
@Override
  public void run() {
    List<CompactionVerifier> verifiers = this.suite.getMapReduceVerifiers();
    for (CompactionVerifier verifier : verifiers) {
      if (!verifier.verify(dataset).isSuccessful()) {
        log.error("Verification {} for {} is not passed.", verifier.getName(), dataset.datasetURN());
        this.onMRTaskComplete (false, new IOException("Compaction verification for MR is failed"));
        return;
      }
    }

    super.run();
  }
365656
public void run() {
        ConnectionFactory connectionFactory = Optional.ofNullable(endpointConfiguration.getConnectionFactory())
                                                      .orElse(endpointConfiguration.getJmsTemplate().getConnectionFactory());

        TopicConnection connection = null;
        try {
            if (connectionFactory == null || !(connectionFactory instanceof TopicConnectionFactory)) {
                throw new CitrusRuntimeException("Failed to create JMS topic subscriber for unsupported connection factory type: " + Optional.ofNullable(connectionFactory)
                        .map(Object::getClass)
                        .map(Class::getName)
                        .orElse("connection factory not set"));
            }

            connection = ((TopicConnectionFactory)connectionFactory).createTopicConnection();

            TopicSession session = connection.createTopicSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
            Topic topic;
            if (endpointConfiguration.getDestination() != null && endpointConfiguration.getDestination() instanceof Topic) {
                topic = (Topic) endpointConfiguration.getDestination();
            } else if (StringUtils.hasText(endpointConfiguration.getDestinationName())) {
                topic = session.createTopic(endpointConfiguration.getDestinationName());
            } else if (endpointConfiguration.getJmsTemplate().getDefaultDestination() != null && endpointConfiguration.getJmsTemplate().getDefaultDestination() instanceof Topic) {
                topic = (Topic) endpointConfiguration.getJmsTemplate().getDefaultDestination();
            } else if (StringUtils.hasText(endpointConfiguration.getJmsTemplate().getDefaultDestinationName())) {
                topic = session.createTopic(endpointConfiguration.getJmsTemplate().getDefaultDestinationName());
            } else {
                throw new CitrusRuntimeException("Unable to receive message - JMS destination not set");
            }

            TopicSubscriber subscriber;
            if (endpointConfiguration.isDurableSubscription()) {
                log.debug(String.format("Create JMS topic durable subscription '%s'", Optional.ofNullable(endpointConfiguration.getDurableSubscriberName()).orElse(getName())));
                subscriber = session.createDurableSubscriber(topic, Optional.ofNullable(endpointConfiguration.getDurableSubscriberName()).orElse(getName()));
            } else {
                log.debug("Create JMS topic subscription");
                subscriber = session.createSubscriber(topic);
            }

            connection.start();

            started.complete(true);

            while (running) {
                javax.jms.Message event = subscriber.receive();

                if (event != null) {
                    TestContext context = testContextFactory.getObject();
                    Message message = endpointConfiguration.getMessageConverter().convertInbound(event, endpointConfiguration, context);

                    if (log.isDebugEnabled()) {
                        log.debug(String.format("Received topic event '%s'", message.getId()));
                    }
                    messageChannel.createProducer().send(message, context);
                } else {
                    log.warn("Topic subscriber received null message - continue after " + endpointConfiguration.getPollingInterval() + " milliseconds");

                    try {
                        Thread.sleep(endpointConfiguration.getPollingInterval());
                    } catch (InterruptedException e) {
                        log.warn("Interrupted while waiting after null message", e);
                    }
                }
            }
        } catch (RuntimeException e) {
            started.completeExceptionally(e);
            throw e;
        } catch (JMSException e) {
            started.completeExceptionally(e);
        } finally {
            if (connection != null) {
                try {
                    connection.close();
                } catch (JMSException e) {
                    log.warn("Failed to close JMS topic connection", e);
                }
            }

            stopped.complete(true);
        }
    }
370760
@Override
    public void run() {
        try {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                Tr.debug(tc, "Run WriteListenerRunnable start , current thread -->" + Thread.currentThread().getName());
            }
            // clean up everything on this thread
            WebContainerRequestState reqState = WebContainerRequestState.getInstance(false);
            if (reqState != null) {
                reqState.init();
            }
            // Push the original thread's context onto the current thread, also
            // save off the current thread's context
            _tcm.pushContextData();

            // call onWritePossible
            synchronized (this._out) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                    Tr.debug(tc, "Invoking the onWritePossible first time");
                }
                WebContainerRequestState.getInstance(true).setAttribute("com.ibm.ws.webcontainer.upgrade.WriteAllowedonThisThread", true);
                this._listener.onWritePossible();

            }
        } catch (Exception e) {
            // If any other exception is thrown then call error which will set
            // exception from error which will allow application to write error
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                Tr.debug(tc, "An exception occurred during the onWritePossible : " + e);
            }
            _cb.error(_out.getBufferHelper().get_vc(), e);

        } finally {
            // Revert back to the thread's current context
            _tcm.popContextData();
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()){  
                Tr.debug(tc, "Run WriteListenerRunnable done");
            }
        }
    }
426800
@Override
    public final void run() {
        try {
            registry_.updateCollection();

            final long t0 = System.nanoTime();

            processors_.forEach(p -> {
                try {
                    run_implementation_(p);
                } catch (Exception ex) {
                    logger.log(Level.SEVERE, p.getClass().getName() + " failed to run properly, some or all metrics may be missed this cycle", ex);
                }
            });

            final long t_processor = System.nanoTime();
            registry_.updateProcessorDuration(Duration.millis(TimeUnit.NANOSECONDS.toMillis(t_processor - t0)));
        } catch (Throwable t) {
            /*
             * We catch any and all throwables.
             * If we don't and let an exception or error escape,
             * the scheduled executor service will _silently_ drop our task.
             */
            logger.log(Level.SEVERE, "failed to perform collection", t);
        }
    }
1227607
public void executeMethods(final List<Method> methods) throws Exception {

        for (final Method method : methods) {

            // TODO - curious about the findSuitableInstancesOf ? won't
            // method.getDeclaringClass be ok??

            for (final Object object : findSuitableInstancesOf(method.getDeclaringClass())) {

                method.invoke(object);

            }
        }
    }
744749
public void run(String[] args) {
        String context = args.length > 0 ? args[0] : "";
        String action = args.length > 1 ? args[1] : "";
        String option = args.length > 2 ? args[2] : "";

        switch (context) {
            case "server":
                server(action, option);
                break;
            case "version":
                version();
                break;
            default:
                help();
        }
    }
943550
public B options(ClientOptionValue<?>... options) {
        requireNonNull(options, "options");
        for (ClientOptionValue<?> o : options) {
            option(o);
        }
        return self();
    }
373113
protected void run(String[] args) throws Exception {
		LOG.info("Running 'run' command.");

		final Options commandOptions = CliFrontendParser.getRunCommandOptions();

		final Options commandLineOptions = CliFrontendParser.mergeOptions(commandOptions, customCommandLineOptions);

		final CommandLine commandLine = CliFrontendParser.parse(commandLineOptions, args, true);

		final RunOptions runOptions = new RunOptions(commandLine);

		// evaluate help flag
		if (runOptions.isPrintHelp()) {
			CliFrontendParser.printHelpForRun(customCommandLines);
			return;
		}

		if (runOptions.getJarFilePath() == null) {
			throw new CliArgsException("The program JAR file was not specified.");
		}

		final PackagedProgram program;
		try {
			LOG.info("Building program from JAR file");
			program = buildProgram(runOptions);
		}
		catch (FileNotFoundException e) {
			throw new CliArgsException("Could not build the program from JAR file.", e);
		}

		final CustomCommandLine<?> customCommandLine = getActiveCustomCommandLine(commandLine);

		try {
			runProgram(customCommandLine, commandLine, runOptions, program);
		} finally {
			program.deleteExtractedLibraries();
		}
	}
861635
public void run(String[] args) {
		System.out.println("SampleStarter.run(String[])");
		System.out.println("- args.length: " + args.length);
		for (String arg : args) System.out.println("  - " + arg);
		System.out.println(this);
	}
710569
private void processGeneralOptions(Configuration conf,
      CommandLine line) {
    if (line.hasOption("fs")) {
      FileSystem.setDefaultUri(conf, line.getOptionValue("fs"));
    }

    if (line.hasOption("jt")) {
      conf.set("mapred.job.tracker", line.getOptionValue("jt"));
    }
    if (line.hasOption("conf")) {
      String[] values = line.getOptionValues("conf");
      for(String value : values) {
        conf.addResource(new Path(value));
      }
    }
    try {
      if (line.hasOption("libjars")) {
        conf.set("tmpjars", 
                 validateFiles(line.getOptionValue("libjars"), conf));
        //setting libjars in client classpath
        URL[] libjars = getLibJars(conf);
        if(libjars!=null && libjars.length>0) {
          conf.setClassLoader(new URLClassLoader(libjars, conf.getClassLoader()));
          Thread.currentThread().setContextClassLoader(
              new URLClassLoader(libjars, 
                  Thread.currentThread().getContextClassLoader()));
        }
      }
      if (line.hasOption("files")) {
        conf.set("tmpfiles", 
                 validateFiles(line.getOptionValue("files"), conf));
      }
      if (line.hasOption("archives")) {
        conf.set("tmparchives", 
                  validateFiles(line.getOptionValue("archives"), conf));
      }
    } catch (IOException ioe) {
      System.err.println(StringUtils.stringifyException(ioe));
    }
    if (line.hasOption('D')) {
      String[] property = line.getOptionValues('D');
      for(String prop : property) {
        String[] keyval = prop.split("=", 2);
        if (keyval.length == 2) {
          conf.set(keyval[0], keyval[1]);
        }
      }
    }
    conf.setBoolean("mapred.used.genericoptionsparser", true);
  }
607723
public static void run( Options options) throws Exception
    {
    if( options.showVersion())
      {
      System.out.println( getVersion());
      return;
      }
    logger_.info( "{}", getVersion());

    // Identify the API spec file
    File apiSpecFile = options.getApiSpec();
    if( apiSpecFile != null && !apiSpecFile.isAbsolute())
      {
      apiSpecFile = new File( options.getWorkingDir(), apiSpecFile.getPath());
      }

    File inputDir =
      apiSpecFile==null
      ? options.getWorkingDir()
      : apiSpecFile.getParentFile();


    // Output file defined?
    File outputDir = options.getOutDir();
    File outputFile = options.getOutFile();
    if( outputFile == null && apiSpecFile != null)
      {
      // No, use default name
      outputFile =
        new File(
          String.format(
            "%s%s-%s-%s.json",
            Optional.ofNullable( apiSpecFile.getParent()).map( p -> p + "/").orElse( ""),
            getBaseName( apiSpecFile.getName()),
            options.isServerTest()? "Requests" : "Responses",
            options.isTests()? "Test" : "Input"));
      }
    if( outputFile != null)
      {
      // Ensure output directory exists.
      if( outputDir == null)
        {
        outputDir =
          outputFile.isAbsolute()
          ? outputFile.getParentFile()
          : inputDir;
        }
      if( !outputDir.exists() && !outputDir.mkdirs())
        {
        throw new RuntimeException( "Can't create output directory=" + outputDir);
        }

      outputFile =
        new File
        ( outputDir,
          outputFile.isAbsolute()? outputFile.getName() : outputFile.getPath());
      }

    OutputStream outputStream = null;
    if( outputFile != null)
      {
      try
        {
        outputStream = new FileOutputStream( outputFile);
        }
      catch( Exception e)
        {
        throw new IllegalArgumentException( "Can't open output file=" + outputFile);
        }
      }
    
    // Generate requested input definition
    logger_.info( "Reading API spec from {}", apiSpecFile==null? "standard input" : apiSpecFile);
    SystemInputDef inputDef =
      options.isServerTest()
      ? TcasesOpenApiIO.getRequestInputModel( apiSpecFile)
      : TcasesOpenApiIO.getResponseInputModel( apiSpecFile);

    // Write requested results
    logger_.info( "Writing results to {}", outputFile==null? "standard output" : outputFile);
    if( options.isTests())
      {
      TcasesOpenApiIO.writeTests( Tcases.getTests( inputDef, null, null), outputStream);
      }
    else
      {
      TcasesOpenApiIO.writeInputModel( inputDef, outputStream);
      }
    }