Class SchemaExporter

java.lang.Object
com.illumon.iris.db.schema.SchemaExporter

public class SchemaExporter extends Object
Simple class to export schemas from a kv-store to .schema XML files. Each file will be called namespace.tableName.schema.
  • Constructor Details

    • SchemaExporter

      public SchemaExporter(@NotNull com.fishlib.io.logger.Logger log, @Nullable String directory, @Nullable String[] namespacesToExport, boolean overwrite, boolean listSchemas, @NotNull List<NamespaceSet> namespaceSets)
      Constructor for the schema exporter.
      Parameters:
      log - the logger to use for messages
      directory - the directory in which the files will be written (ignored if list is true)
      namespacesToExport - if supplied, the namespaces to process, otherwise all namespaces will be processed
      overwrite - if true, then overwrite existing schema files, otherwise skip writing a schema if the file already exists
      listSchemas - if true, list but don't export the schemas
      namespaceSets - the namespace sets to be processed
  • Method Details

    • export

      public int export(@NotNull SchemaService schemaService) throws IOException
      Export or list the schemas to the XML files. If a file exists and the overwrite option is not specified, that file will be skipped.
      Parameters:
      schemaService - export from this schema service
      Returns:
      the number of schemas found that match the given criteria
      Throws:
      IOException - from the underlying file operations.
    • exportSchemas

      public static void exportSchemas(@NotNull com.fishlib.io.logger.Logger log, @NotNull List<SchemaXml> schemasToExport, @Nullable File directory, boolean overwrite) throws IOException
      Export the schemas to the XML files. If a file exists and the overwrite option is not specified, that file will be skipped.
      Parameters:
      log - the logger
      schemasToExport - the schemas to export
      directory - if null, the files will be written to this directory, otherwise they will be written to stdout
      overwrite - if true, then overwrite existing schema files, otherwise skip
      Throws:
      IOException - if there is an error writing the files
    • getExitCodeFromSchemaCount

      public static int getExitCodeFromSchemaCount(int count)
      A count of 0 for list or export is considered unsuccessful and will return 1
      Parameters:
      count - number of schema
      Returns:
      1 if count is 0, 0 otherwise
    • main

      public static void main(String... commandLineArguments) throws IOException
      Throws:
      IOException