ConnectionMigrationOptions.Builder

public static class ConnectionMigrationOptions.Builder extends Object

Public Method Summary

ConnectionMigrationOptions.Builder
allowNonDefaultNetworkUsage(boolean enable)
Sets whether connections can be migrated to an alternate network when Cronet detects a degradation of the path currently in use.
ConnectionMigrationOptions.Builder
allowServerMigration(boolean allowServerMigration)
Enables the possibility of migrating connections to an alternate server address at the server's request.
ConnectionMigrationOptions
build()
Creates and returns the final ConnectionMigrationOptions instance, based on the values in this builder.
ConnectionMigrationOptions.Builder
enableDefaultNetworkMigration(boolean enableDefaultNetworkConnectionMigration)
Enables the possibility of migrating connections on default network change.
ConnectionMigrationOptions.Builder
enablePathDegradationMigration(boolean enable)
Enables the possibility of migrating connections if the current path is performing poorly.
ConnectionMigrationOptions.Builder
migrateIdleConnections(boolean migrateIdleConnections)
Configures whether migration of idle connections should be enabled or not.
ConnectionMigrationOptions.Builder
retryPreHandshakeErrorsOnNonDefaultNetwork(boolean retryPreHandshakeErrorsOnAlternateNetwork)
Sets whether connections with pre-handshake errors should be retried on an alternative network.
ConnectionMigrationOptions.Builder
setIdleConnectionMigrationPeriodSeconds(long idleConnectionMigrationPeriodSeconds)
Sets the maximum idle period for which connections will still be migrated, in seconds.
ConnectionMigrationOptions.Builder
setMaxPathDegradingNonDefaultNetworkMigrationsCount(int maxPathDegradingEagerMigrationsCount)
Sets the maximum number of migrations to the non-default network upon encountering path degradation for the existing connection.
ConnectionMigrationOptions.Builder
setMaxTimeOnNonDefaultNetworkSeconds(long maxTimeOnNonDefaultNetworkSeconds)
Sets the maximum period for which eagerly migrated connections should remain on the non-default network before they're migrated back.
ConnectionMigrationOptions.Builder
setMaxWriteErrorNonDefaultNetworkMigrationsCount(int maxWriteErrorEagerMigrationsCount)
Sets the maximum number of migrations to the non-default network upon encountering write errors.

Inherited Method Summary

Public Methods

public ConnectionMigrationOptions.Builder allowNonDefaultNetworkUsage (boolean enable)

Sets whether connections can be migrated to an alternate network when Cronet detects a degradation of the path currently in use.

Note: This setting can result in requests being sent on non-default metered networks. Make sure you're using metered networks sparingly, and fine tune parameters like setMaxPathDegradingNonDefaultNetworkMigrationsCount(int) and setMaxTimeOnNonDefaultNetworkSeconds(long) to limit the time on non-default networks.

Parameters
enable
Returns
  • this builder for chaining

public ConnectionMigrationOptions.Builder allowServerMigration (boolean allowServerMigration)

Enables the possibility of migrating connections to an alternate server address at the server's request.

Parameters
allowServerMigration
Returns
  • this builder for chaining

public ConnectionMigrationOptions build ()

Creates and returns the final ConnectionMigrationOptions instance, based on the values in this builder.

public ConnectionMigrationOptions.Builder enableDefaultNetworkMigration (boolean enableDefaultNetworkConnectionMigration)

Enables the possibility of migrating connections on default network change. If enabled, active QUIC connections will be migrated onto the new network when the platform indicates that the default network is changing.

Parameters
enableDefaultNetworkConnectionMigration
Returns
  • this builder for chaining

public ConnectionMigrationOptions.Builder enablePathDegradationMigration (boolean enable)

Enables the possibility of migrating connections if the current path is performing poorly.

Depending on other configuration, this can result to migrating the connections within the same default network, or to a non-default network.

Parameters
enable
Returns
  • this builder for chaining

public ConnectionMigrationOptions.Builder migrateIdleConnections (boolean migrateIdleConnections)

Configures whether migration of idle connections should be enabled or not.

If set to true, idle connections will be migrated too, as long as they haven't been idle for too long. The setting is shared for all connection migration types. The maximum idle period for which connections will still be migrated can be customized using setIdleConnectionMigrationPeriodSeconds(long).

Parameters
migrateIdleConnections
Returns
  • this builder for chaining

public ConnectionMigrationOptions.Builder retryPreHandshakeErrorsOnNonDefaultNetwork (boolean retryPreHandshakeErrorsOnAlternateNetwork)

Sets whether connections with pre-handshake errors should be retried on an alternative network.

If true, a new connection may be established an alternate network if it fails on the default network before handshake is confirmed.

Note: similarly to allowNonDefaultNetworkUsage(boolean) this setting can result in requests being sent on non-default metered networks. Use with caution!

Parameters
retryPreHandshakeErrorsOnAlternateNetwork
Returns
  • this builder for chaining

public ConnectionMigrationOptions.Builder setIdleConnectionMigrationPeriodSeconds (long idleConnectionMigrationPeriodSeconds)

Sets the maximum idle period for which connections will still be migrated, in seconds. The setting is shared for all connection migration types.

Only relevant if migrateIdleConnections(boolean) is enabled.

Parameters
idleConnectionMigrationPeriodSeconds
Returns
  • this builder for chaining

public ConnectionMigrationOptions.Builder setMaxPathDegradingNonDefaultNetworkMigrationsCount (int maxPathDegradingEagerMigrationsCount)

Sets the maximum number of migrations to the non-default network upon encountering path degradation for the existing connection. Counted cumulatively per network per connection.

Only relevant if allowNonDefaultNetworkUsage(boolean) is enabled.

Parameters
maxPathDegradingEagerMigrationsCount
Returns
  • this builder for chaining

public ConnectionMigrationOptions.Builder setMaxTimeOnNonDefaultNetworkSeconds (long maxTimeOnNonDefaultNetworkSeconds)

Sets the maximum period for which eagerly migrated connections should remain on the non-default network before they're migrated back. This time is not cumulative - each migration off the default network for each connection measures and compares to this value separately.

Only relevant if allowNonDefaultNetworkUsage(boolean) is enabled.

Parameters
maxTimeOnNonDefaultNetworkSeconds
Returns
  • this builder for chaining

public ConnectionMigrationOptions.Builder setMaxWriteErrorNonDefaultNetworkMigrationsCount (int maxWriteErrorEagerMigrationsCount)

Sets the maximum number of migrations to the non-default network upon encountering write errors. Counted cumulatively per network per connection.

Only relevant if allowNonDefaultNetworkUsage(boolean) is enabled.

Parameters
maxWriteErrorEagerMigrationsCount
Returns
  • this builder for chaining