Partager via


ConsistencyPolicy Class

  • java.lang.Object
    • com.azure.resourcemanager.cosmos.models.ConsistencyPolicy

Implements

public final class ConsistencyPolicy
implements JsonSerializable<ConsistencyPolicy>

The consistency policy for the Cosmos DB database account.

Constructor Summary

Constructor Description
ConsistencyPolicy()

Creates an instance of ConsistencyPolicy class.

Method Summary

Modifier and Type Method and Description
DefaultConsistencyLevel defaultConsistencyLevel()

Get the defaultConsistencyLevel property: The default consistency level and configuration settings of the Cosmos DB account.

static ConsistencyPolicy fromJson(JsonReader jsonReader)

Reads an instance of ConsistencyPolicy from the JsonReader.

Integer maxIntervalInSeconds()

Get the maxIntervalInSeconds property: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated.

Long maxStalenessPrefix()

Get the maxStalenessPrefix property: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated.

JsonWriter toJson(JsonWriter jsonWriter)
void validate()

Validates the instance.

ConsistencyPolicy withDefaultConsistencyLevel(DefaultConsistencyLevel defaultConsistencyLevel)

Set the defaultConsistencyLevel property: The default consistency level and configuration settings of the Cosmos DB account.

ConsistencyPolicy withMaxIntervalInSeconds(Integer maxIntervalInSeconds)

Set the maxIntervalInSeconds property: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated.

ConsistencyPolicy withMaxStalenessPrefix(Long maxStalenessPrefix)

Set the maxStalenessPrefix property: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated.

Methods inherited from java.lang.Object

Constructor Details

ConsistencyPolicy

public ConsistencyPolicy()

Creates an instance of ConsistencyPolicy class.

Method Details

defaultConsistencyLevel

public DefaultConsistencyLevel defaultConsistencyLevel()

Get the defaultConsistencyLevel property: The default consistency level and configuration settings of the Cosmos DB account.

Returns:

the defaultConsistencyLevel value.

fromJson

public static ConsistencyPolicy fromJson(JsonReader jsonReader)

Reads an instance of ConsistencyPolicy from the JsonReader.

Parameters:

jsonReader - The JsonReader being read.

Returns:

An instance of ConsistencyPolicy if the JsonReader was pointing to an instance of it, or null if it was pointing to JSON null.

Throws:

IOException

- If the deserialized JSON object was missing any required properties.

maxIntervalInSeconds

public Integer maxIntervalInSeconds()

Get the maxIntervalInSeconds property: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'.

Returns:

the maxIntervalInSeconds value.

maxStalenessPrefix

public Long maxStalenessPrefix()

Get the maxStalenessPrefix property: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 \u2013 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'.

Returns:

the maxStalenessPrefix value.

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

validate

public void validate()

Validates the instance.

withDefaultConsistencyLevel

public ConsistencyPolicy withDefaultConsistencyLevel(DefaultConsistencyLevel defaultConsistencyLevel)

Set the defaultConsistencyLevel property: The default consistency level and configuration settings of the Cosmos DB account.

Parameters:

defaultConsistencyLevel - the defaultConsistencyLevel value to set.

Returns:

the ConsistencyPolicy object itself.

withMaxIntervalInSeconds

public ConsistencyPolicy withMaxIntervalInSeconds(Integer maxIntervalInSeconds)

Set the maxIntervalInSeconds property: When used with the Bounded Staleness consistency level, this value represents the time amount of staleness (in seconds) tolerated. Accepted range for this value is 5 - 86400. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'.

Parameters:

maxIntervalInSeconds - the maxIntervalInSeconds value to set.

Returns:

the ConsistencyPolicy object itself.

withMaxStalenessPrefix

public ConsistencyPolicy withMaxStalenessPrefix(Long maxStalenessPrefix)

Set the maxStalenessPrefix property: When used with the Bounded Staleness consistency level, this value represents the number of stale requests tolerated. Accepted range for this value is 1 \u2013 2,147,483,647. Required when defaultConsistencyPolicy is set to 'BoundedStaleness'.

Parameters:

maxStalenessPrefix - the maxStalenessPrefix value to set.

Returns:

the ConsistencyPolicy object itself.

Applies to