Class SchemaUtils


  • public class SchemaUtils
    extends Object
    Utility class which contains Schema related operations.
    • Method Detail

      • toZNRecord

        public static org.apache.helix.zookeeper.datamodel.ZNRecord toZNRecord​(@Nonnull
                                                                               Schema schema)
        Wrap Schema into a ZNRecord.
      • getSchema

        @Nullable
        public static Schema getSchema​(@Nonnull
                                       String host,
                                       int port,
                                       @Nonnull
                                       String schemaName)
        Given host, port and schema name, send a http GET request to download the Schema.
        Returns:
        schema on success.

        null on failure.

      • postSchema

        public static boolean postSchema​(@Nonnull
                                         String host,
                                         int port,
                                         @Nonnull
                                         Schema schema)
        Given host, port and schema, send a http POST request to upload the Schema.
        Returns:
        true on success.

        false on failure.

      • deleteSchema

        public static boolean deleteSchema​(@Nonnull
                                           String host,
                                           int port,
                                           @Nonnull
                                           String schemaName)
        Given host, port and schema name, send a http DELETE request to delete the Schema.
        Returns:
        true on success.

        false on failure.

      • equalsIgnoreVersion

        public static boolean equalsIgnoreVersion​(@Nonnull
                                                  Schema schema1,
                                                  @Nonnull
                                                  Schema schema2)
        Compare two schemas ignoring their version number.
        Returns:
        true if two schemas equal to each other.

        falseif two schemas do not equal to each other.

      • main

        public static void main​(String[] args)
        An example on how to use this utility class.