use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.
the class TypeDBServer method main.
public static void main(String[] args) {
try {
printASCIILogo();
CoreConfigParser configParser = new CoreConfigParser();
ArgsParser<ServerSubcommand> argsParser = new ArgsParser<ServerSubcommand>().subcommand(new ServerSubcommandParser.Server(configParser)).subcommand(new ServerSubcommandParser.Import()).subcommand(new ServerSubcommandParser.Export());
Optional<ServerSubcommand> subcmd = argsParser.parse(args);
if (subcmd.isEmpty()) {
LOG.error(UNRECOGNISED_CLI_COMMAND.message(String.join(" ", args)));
LOG.error(argsParser.usage());
System.exit(1);
} else {
if (subcmd.get().isServer()) {
ServerSubcommand.Server subcmdServer = subcmd.get().asServer();
if (subcmdServer.isHelp())
System.out.println(argsParser.help());
else if (subcmdServer.isVersion())
System.out.println("Version: " + Version.VERSION);
else
runServer(subcmdServer);
} else if (subcmd.get().isImport()) {
importData(subcmd.get().asImport());
} else if (subcmd.get().isExport()) {
exportData(subcmd.get().asExport());
} else
throw TypeDBException.of(ILLEGAL_STATE);
}
} catch (Exception e) {
if (e instanceof TypeDBException) {
LOG.error(e.getMessage());
} else {
LOG.error(e.getMessage(), e);
LOG.error(EXITED_WITH_ERROR.message());
}
System.exit(1);
}
System.exit(0);
}
use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.
the class CoreConfigTest method overrides_list_can_be_yaml_or_repeated.
@Test
public void overrides_list_can_be_yaml_or_repeated() {
CoreConfig config = CoreConfigFactory.config(set(new Option("log.logger.typedb.output", "[file]")), new CoreConfigParser());
assertEquals(set("file"), set(config.log().logger().filteredLoggers().get("typedb").outputs()));
CoreConfig configWithRepeatedArgs = CoreConfigFactory.config(set(new Option("log.logger.typedb.output", "file"), new Option("log.logger.typedb.output", "stdout")), new CoreConfigParser());
assertEquals(set("stdout", "file"), set(configWithRepeatedArgs.log().logger().filteredLoggers().get("typedb").outputs()));
}
use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.
the class CoreConfigTest method config_invalid_path_throws.
@Test
public void config_invalid_path_throws() {
Path configMissing = Util.getTypedbDir().resolve("server/test/missing.yml");
try {
CoreConfigFactory.config(configMissing, new HashSet<>(), new CoreConfigParser());
fail();
} catch (TypeDBException e) {
assert e.code().isPresent();
assertEquals(CONFIG_FILE_NOT_FOUND.code(), e.code().get());
}
}
use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.
the class CoreConfigTest method config_file_missing_data_throws.
@Test
public void config_file_missing_data_throws() {
Path configMissingLog = Util.getTypedbDir().resolve("server/test/config/config-missing-data.yml");
try {
CoreConfigFactory.config(configMissingLog, new HashSet<>(), new CoreConfigParser());
fail();
} catch (TypeDBException e) {
assert e.code().isPresent();
assertEquals(MISSING_CONFIG_OPTION.code(), e.code().get());
assertEquals(MISSING_CONFIG_OPTION.message("storage.data"), e.getMessage());
}
}
use of com.vaticle.typedb.core.server.parameters.CoreConfigParser in project grakn by graknlabs.
the class CoreConfigTest method config_file_invalid_output_reference_throws.
@Test
public void config_file_invalid_output_reference_throws() {
Path configInvalidOutput = Util.getTypedbDir().resolve("server/test/config/config-invalid-logger-output.yml");
try {
CoreConfigFactory.config(configInvalidOutput, new HashSet<>(), new CoreConfigParser());
fail();
} catch (TypeDBException e) {
assert e.code().isPresent();
assertEquals(CONFIG_OUTPUT_UNRECOGNISED.code(), e.code().get());
}
}
Aggregations