Enum VersionType

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<VersionType>, java.lang.constant.Constable, Writeable

    public enum VersionType
    extends java.lang.Enum<VersionType>
    implements Writeable
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Enum

        java.lang.Enum.EnumDesc<E extends java.lang.Enum<E>>
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      EXTERNAL  
      EXTERNAL_GTE  
      FORCE
      Deprecated.
      this will be removed in 7.0 and should not be used! It is *ONLY* for backward compatibility with 5.0 indices
      INTERNAL  
    • Method Summary

      Modifier and Type Method Description
      abstract java.lang.String explainConflictForReads​(long currentVersion, long expectedVersion)
      Returns a human readable explanation for a version conflict on read.
      abstract java.lang.String explainConflictForWrites​(long currentVersion, long expectedVersion, boolean deleted)
      Returns a human readable explanation for a version conflict on write.
      static VersionType fromString​(java.lang.String versionType)  
      static VersionType fromString​(java.lang.String versionType, VersionType defaultVersionType)  
      static VersionType fromValue​(byte value)  
      byte getValue()  
      abstract boolean isVersionConflictForReads​(long currentVersion, long expectedVersion)
      Checks whether the current version conflicts with the expected version, based on the current version type.
      abstract boolean isVersionConflictForWrites​(long currentVersion, long expectedVersion, boolean deleted)
      Checks whether the current version conflicts with the expected version, based on the current version type.
      static VersionType readFromStream​(StreamInput in)  
      static java.lang.String toString​(VersionType versionType)  
      abstract long updateVersion​(long currentVersion, long expectedVersion)
      Returns the new version for a document, based on its current one and the specified in the request
      abstract boolean validateVersionForReads​(long version)
      validate the version is a valid value for this type when reading.
      abstract boolean validateVersionForWrites​(long version)
      validate the version is a valid value for this type when writing.
      static VersionType valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static VersionType[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      VersionType versionTypeForReplicationAndRecovery()
      Some version types require different semantics for primary and replicas.
      void writeTo​(StreamOutput out)
      Write this into the StreamOutput.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, describeConstable, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • EXTERNAL_GTE

        public static final VersionType EXTERNAL_GTE
      • FORCE

        @Deprecated
        public static final VersionType FORCE
        Deprecated.
        this will be removed in 7.0 and should not be used! It is *ONLY* for backward compatibility with 5.0 indices
        Warning: this version type should be used with care. Concurrent indexing may result in loss of data on replicas
    • Method Detail

      • values

        public static VersionType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared.
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static VersionType valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • getValue

        public byte getValue()
      • isVersionConflictForWrites

        public abstract boolean isVersionConflictForWrites​(long currentVersion,
                                                           long expectedVersion,
                                                           boolean deleted)
        Checks whether the current version conflicts with the expected version, based on the current version type.
        Parameters:
        currentVersion - the current version for the document
        expectedVersion - the version specified for the write operation
        deleted - true if the document is currently deleted (note that #currentVersion will typically be Versions.NOT_FOUND, but may be something else if the document was recently deleted
        Returns:
        true if versions conflict false o.w.
      • explainConflictForWrites

        public abstract java.lang.String explainConflictForWrites​(long currentVersion,
                                                                  long expectedVersion,
                                                                  boolean deleted)
        Returns a human readable explanation for a version conflict on write. Note that this method is only called if isVersionConflictForWrites(long, long, boolean) returns true;
        Parameters:
        currentVersion - the current version for the document
        expectedVersion - the version specified for the write operation
        deleted - true if the document is currently deleted (note that #currentVersion will typically be Versions.NOT_FOUND, but may be something else if the document was recently deleted
      • isVersionConflictForReads

        public abstract boolean isVersionConflictForReads​(long currentVersion,
                                                          long expectedVersion)
        Checks whether the current version conflicts with the expected version, based on the current version type.
        Parameters:
        currentVersion - the current version for the document
        expectedVersion - the version specified for the read operation
        Returns:
        true if versions conflict false o.w.
      • explainConflictForReads

        public abstract java.lang.String explainConflictForReads​(long currentVersion,
                                                                 long expectedVersion)
        Returns a human readable explanation for a version conflict on read. Note that this method is only called if isVersionConflictForReads(long, long) returns true;
        Parameters:
        currentVersion - the current version for the document
        expectedVersion - the version specified for the read operation
      • updateVersion

        public abstract long updateVersion​(long currentVersion,
                                           long expectedVersion)
        Returns the new version for a document, based on its current one and the specified in the request
        Returns:
        new version
      • validateVersionForWrites

        public abstract boolean validateVersionForWrites​(long version)
        validate the version is a valid value for this type when writing.
        Returns:
        true if valid, false o.w
      • validateVersionForReads

        public abstract boolean validateVersionForReads​(long version)
        validate the version is a valid value for this type when reading.
        Returns:
        true if valid, false o.w
      • versionTypeForReplicationAndRecovery

        public VersionType versionTypeForReplicationAndRecovery()
        Some version types require different semantics for primary and replicas. This version allows the type to override the default behavior.
      • fromString

        public static VersionType fromString​(java.lang.String versionType)
      • fromString

        public static VersionType fromString​(java.lang.String versionType,
                                             VersionType defaultVersionType)
      • toString

        public static java.lang.String toString​(VersionType versionType)
      • fromValue

        public static VersionType fromValue​(byte value)
      • readFromStream

        public static VersionType readFromStream​(StreamInput in)
                                          throws java.io.IOException
        Throws:
        java.io.IOException