当前位置: 首页>>代码示例>>Java>>正文


Java CommandOutcome.failed方法代码示例

本文整理汇总了Java中io.bootique.command.CommandOutcome.failed方法的典型用法代码示例。如果您正苦于以下问题:Java CommandOutcome.failed方法的具体用法?Java CommandOutcome.failed怎么用?Java CommandOutcome.failed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.bootique.command.CommandOutcome的用法示例。


在下文中一共展示了CommandOutcome.failed方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {

    String topic = cli.optionString(TOPIC_OPT);
    if (topic == null) {
        return CommandOutcome.failed(-1, "No --topic specified");
    }

    ProducerConfig<byte[], String> config = ProducerConfig
            .charValueConfig()
            .bootstrapServers(cli.optionStrings(BOOTSTRAP_SERVER_OPT))
            .build();

    Producer<byte[], String> producer = kafkaProvider.get().createProducer(DEFAULT_CLUSTER_NAME, config);

    shutdownManager.addShutdownHook(() -> {
        producer.close();
        // give a bit of time to stop..
        Thread.sleep(200);
    });

    return runConsole(topic, producer);
}
 
开发者ID:bootique-examples,项目名称:bootique-kafka-producer,代码行数:24,代码来源:KafkaProducerCommand.java

示例2: run

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
public CommandOutcome run(Consumer<BQRuntime> beforeShutdownCallback, String... args) {

        BootLogger logger = createBootLogger();
        Bootique bootique = Bootique.app(args).bootLogger(logger);
        configure(bootique);

        BQRuntime runtime = bootique.createRuntime();
        try {
            return runtime.getInstance(Runner.class).run();
        } catch (Exception e) {
            logger.stderr("Error", e);
            return CommandOutcome.failed(1, getStderr());
        } finally {

            try {
                beforeShutdownCallback.accept(runtime);
            }
            finally {
                runtime.shutdown();
            }
        }
    }
 
开发者ID:bootique,项目名称:bootique-bom,代码行数:23,代码来源:BomTestApp.java

示例3: run

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {

	List<String> jobNames = cli.optionStrings(JOB_OPTION);
	if (jobNames == null || jobNames.isEmpty()) {
		return CommandOutcome.failed(1,
				String.format("No jobs specified. Use '--%s' option to provide job names", JOB_OPTION));
	}

	LOGGER.info("Will run job(s): " + jobNames);

	Scheduler scheduler = schedulerProvider.get();

	CommandOutcome outcome;
	if (cli.hasOption(SERIAL_OPTION)) {
		outcome = runSerial(jobNames, scheduler);
	} else {
		outcome = runParallel(jobNames, scheduler);
	}
	return outcome;
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:22,代码来源:ExecCommand.java

示例4: testStart_StartupFailure

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
@Test
public void testStart_StartupFailure() {

    CommandOutcome failed = CommandOutcome.failed(-1, "Intended failure");

    try {
        testFactory.app("")
                .module(b ->
                        BQCoreModule.extend(b).setDefaultCommand(cli -> failed))
                .startupCheck(r -> false)
                .start();
    } catch (BootiqueException e) {
        assertEquals(-1, e.getOutcome().getExitCode());
        assertEquals("Daemon failed to start: " + failed, e.getOutcome().getMessage());
    }
}
 
开发者ID:bootique,项目名称:bootique,代码行数:17,代码来源:BQDaemonTestFactoryIT.java

示例5: runConsole

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
private CommandOutcome runConsole(String topic, Producer<byte[], String> producer) {

        System.out.println("");
        System.out.println("    Start typing messages below. Type '\\q' to exit.");
        System.out.println("");

        try (BufferedReader stdinReader = new BufferedReader(new InputStreamReader(System.in))) {
            readAndPost(stdinReader, topic, producer);
            return CommandOutcome.succeeded();
        } catch (IOException ex) {
            return CommandOutcome.failed(-1, ex);
        }
    }
 
开发者ID:bootique-examples,项目名称:bootique-kafka-producer,代码行数:14,代码来源:KafkaProducerCommand.java

示例6: run

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {
	ObjectContext context = cayenne.get().newContext();
	PrintWriter writer = new PrintWriter(System.out);
	try (CSVWriter csv = new CSVWriter(writer)) {
		SelectQuery<Concept> query = SelectQuery.query(Concept.class, Concept.RECURSIVE_PARENT_CONCEPTS.dot(Concept.CONCEPT_ID).eq(Category.PHARMACEUTICAL_OR_BIOLOGICAL_PRODUCT.conceptId));
		String[] row = new String[] {"product", "isPrescribable","conceptIdentifier","type", "isSearchable", "prescribeAs" };
		csv.writeNext(row);
		try (ResultBatchIterator<Concept> iterator = query.batchIterator(context, 500)) {
			while (iterator.hasNext()) {
				List<Concept> batch = iterator.next();
				for (Concept c : batch) {
					Dmd.Product.productForConcept(c).ifPresent(p -> {
						row[0] = c.getPreferredDescription().getTerm();
						row[1] = String.valueOf(_productIsPrescribable(c, p));
						row[2] = c.getConceptId().toString();
						row[3] = p.abbreviation();
						row[4] = String.valueOf(_productIsSearchable(c, p));
						row[5] = _prescribingNotes(c,  p);
						csv.writeNext(row);
					});
				}
			}
		}
	} catch (IOException e) {
		e.printStackTrace();
		return CommandOutcome.failed(-1, e);
	}
	return CommandOutcome.succeeded();
}
 
开发者ID:wardle,项目名称:rsterminology,代码行数:31,代码来源:ExportDmdMain.java

示例7: run

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {
    LOGGER.info("Will run Undertow Server...");

    UndertowServer server = serverProvider.get();

    try {
        server.start();
    } catch (Exception e) {
        return CommandOutcome.failed(1, e);
    }

    return CommandOutcome.succeededAndForkedToBackground();
}
 
开发者ID:bootique,项目名称:bootique-undertow,代码行数:15,代码来源:ServerCommand.java

示例8: run

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
@Override
public CommandOutcome run(Cli cli) {

    Server server = serverProvider.get();
    try {
        // this blocks until a successful start or an error, then releases current thread, while Jetty
        // stays running on the background
        server.start();
    } catch (Exception e) {
        return CommandOutcome.failed(1, e);
    }

    return CommandOutcome.succeededAndForkedToBackground();
}
 
开发者ID:bootique,项目名称:bootique-jetty,代码行数:15,代码来源:ServerCommand.java

示例9: runParallel

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
private CommandOutcome runParallel(List<String> jobNames, Scheduler scheduler) {
	List<JobFuture> futures = jobNames.stream().map(scheduler::runOnce).collect(Collectors.toList());
	long failedCount = futures.stream()
			.map(JobFuture::get)
			.peek(this::processResult)
			.filter(result -> !result.isSuccess())
			.count();

	return (failedCount > 0) ? CommandOutcome.failed(1, "Some of the jobs failed") : CommandOutcome.succeeded();
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:11,代码来源:ExecCommand.java

示例10: runSerial

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
private CommandOutcome runSerial(List<String> jobNames, Scheduler scheduler) {
	for (String jobName : jobNames) {
		JobResult result = scheduler.runOnce(jobName).get();
		processResult(result);
		if (!result.isSuccess()) {
			return CommandOutcome.failed(1, "One of the jobs failed");
		}
	}
	return CommandOutcome.succeeded();
}
 
开发者ID:bootique,项目名称:bootique-job,代码行数:11,代码来源:ExecCommand.java

示例11: processExceptions

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
private CommandOutcome processExceptions(Throwable th, Throwable parentTh) {


        if (th instanceof BootiqueException) {
            CommandOutcome originalOutcome = ((BootiqueException) th).getOutcome();

            // BootiqueException should be stripped of the exception cause and reported on a single line
            // TODO: should we still print the stack trace via logger.trace?
            return CommandOutcome.failed(originalOutcome.getExitCode(), originalOutcome.getMessage());
        }

        String thMessage = th != null ? th.getMessage() : null;
        String message = thMessage != null ? "Command exception: '" + thMessage + "'." : "Command exception.";
        return CommandOutcome.failed(1, message, parentTh);
    }
 
开发者ID:bootique,项目名称:bootique,代码行数:16,代码来源:Bootique.java

示例12: run

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
/**
 * @param runtime runtime started by Bootique.
 * @return the outcome of the command execution.
 * @deprecated since 0.23. Previously this method existed to catch and process run exceptions, but it doesn't
 * have wide enough scope for this, so exception processing was moved to {@link #exec()}.
 */
@Deprecated
private CommandOutcome run(BQRuntime runtime) {
    try {
        return runtime.getRunner().run();
    }
    // handle startup Guice exceptions
    catch (ProvisionException e) {

        // TODO: a dependency on JOPT OptionException shouldn't be here
        return (e.getCause() instanceof OptionException) ? CommandOutcome.failed(1, e.getCause().getMessage())
                : CommandOutcome.failed(1, e);
    }
}
 
开发者ID:bootique,项目名称:bootique,代码行数:20,代码来源:Bootique.java

示例13: BootiqueException

import io.bootique.command.CommandOutcome; //导入方法依赖的package包/类
public BootiqueException(int exitCode, String message) {
    this.outcome = CommandOutcome.failed(exitCode, message, this);
}
 
开发者ID:bootique,项目名称:bootique,代码行数:4,代码来源:BootiqueException.java


注:本文中的io.bootique.command.CommandOutcome.failed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。