Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*-
   * See the file LICENSE for redistribution information.
   *
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
   *
   */
  
  package com.sleepycat.je.rep;
  
 
Specifies the attributes that may be changed after a ReplicatedEnvironment has been created. ReplicationMutableConfig is a parameter to com.sleepycat.je.Environment.setMutableConfig(com.sleepycat.je.EnvironmentMutableConfig) and is returned by com.sleepycat.je.Environment.getMutableConfig().
 
 public class ReplicationMutableConfig implements CloneableSerializable {
     private static final long serialVersionUID = 1L;
 
     /*
      * Note: all replicated parameters should start with
      * EnvironmentParams.REP_PARAMS_PREFIX, which is "je.rep.",
      * see SR [#19080].
      */

    
Identifies the Primary node in a two node group. See the discussion of issues when href= "{@docRoot/../ReplicationGuide/lifecycle.html#twonode"> configuring two node groups}

NameTypeMutableDefault
BooleanYesFalse
 
     public static final String DESIGNATED_PRIMARY =
         . + "designatedPrimary";

    
An escape mechanism to modify the way in which the number of electable nodes, and consequently the quorum requirements for elections and commit acknowledgments, is calculated. The override is accomplished by specifying the quorum size via this mutable configuration parameter.

When this parameter is set to a non-zero value at a member node, the member will use this value as the electable group size, instead of using the metadata stored in the RepGroup database for its quorum calculations. This parameter's value should be set to the number of nodes known to be available. The default value is zero, which indicates normal operation with the electable group size being calculated from the metadata.

Please keep in mind that this is an escape mechanism, only for use in exceptional circumstances, to be used with care. Since JE HA is no longer maintaining quorum requirements automatically, there is the possibility that the simple majority of unavailable nodes could elect their own Master, which would result in a diverging set of changes to the same environment being made by multiple Masters. It is essential to ensure that the problematic nodes are in fact down before making this temporary configuration change. See the discussion in href= "{@docRoot/../ReplicationGuide/election-override.html">Appendix: Managing a Failure of the Majority}.

NameTypeMutableDefault
IntegerYes0

    public static final String ELECTABLE_GROUP_SIZE_OVERRIDE =
        . + "electableGroupSizeOverride";

    
The election priority associated with this node. The election algorithm for choosing a new master will pick the participating node that has the most current set of log files. When there is a tie, the election priority is used as a tie-breaker to select amongst these nodes.

A priority of zero is used to ensure that this node is never elected master, even if it has the most up to date log files. Note that the node still votes for a Master and participates in quorum requirements. Please use this option with care, since it means that some node with less current log files could be elected master. As a result, this node would be forced to rollback committed data and must be prepared to handle any RollbackException exceptions that might be thrown.

NameTypeMutableDefaultMinimumMaximum
IntegerYes10Integer.MAX_VALUE

    public static final String NODE_PRIORITY =
        . + "node.priority";

    
If true, JE HA (replication) will flush all committed transactions to disk at the specified time interval. This is of interest because the default durability for replicated transactions of com.sleepycat.je.Durability.COMMIT_NO_SYNC. The default for this behavior is true.

When using com.sleepycat.je.Durability.COMMIT_NO_SYNC, continued activity will naturally cause the steady flush of committed transactions, but a pause in activity may cause the latest commits to stay in memory. In such a case, it is unlikely but possible that all members of the replication group have these last transactions in memory and that no members have persisted them to disk. A catastrophic failure of all nodes in the replication group would cause a loss of these transactions, in this unlikely scenario. This background flush task will reduce such a possibility.

Note that enabling this feature when using com.sleepycat.je.Durability.COMMIT_NO_SYNC, does not constitute a guarantee that updates made by a transaction are persisted. For an explicit guarantee, transactions should use com.sleepycat.je.Durability.COMMIT_SYNC or com.sleepycat.je.Durability.COMMIT_WRITE_NO_SYNC. These more stringent, persistent Durability options can be set at the environment or per-transaction scope. Using one of these Durability settings for a given transaction will also flush all commits that occurred earlier in time.

NameTypeMutableDefault
BooleanNotrue
    public static final String RUN_LOG_FLUSH_TASK =
        . + "runLogFlushTask";

    
The interval that JE HA will do a log buffer flush.

NameTypeMutableDefaultMinimumMaximum
href="../EnvironmentConfig.html.timeDuration">Duration Yes5 min1 s-none-

See also:
Time Duration Properties
    public static final String LOG_FLUSH_TASK_INTERVAL =
        . + "logFlushTaskInterval";

    
The maximum number of most recently used database handles that are kept open during the replay of the replication stream.

NameTypeMutableDefaultMinimumMaximum
IntYes101-none-

Since:
5.0.38
    public static final String REPLAY_MAX_OPEN_DB_HANDLES =
        . + "replayMaxOpenDbHandles";

    
The maximum amount of time that an inactive database handle is kept open during a replay of the replication stream. Handles that are inactive for more than this time period are automatically closed. Note that this does not impact any handles that may have been opened by the application.

NameTypeMutableDefaultMinimumMaximum
href=".timeDuration">DurationNo30 sec1 sec-none-

Since:
5.0.38
See also:
Time Duration Properties
    public static final String REPLAY_DB_HANDLE_TIMEOUT =
        . + "replayOpenHandleTimeout";

    

See also:
Time Duration Properties
Hidden:
For internal use only. The timeout specifies the amount of time that the ReplicationGroupAdmin.transferMastership command can use to have the specified replica catch up with the original master.

If the replica has not successfully caught up with the original master, the call to com.sleepycat.je.rep.util.ReplicationGroupAdmin will throw an exception.

NameTypeMutableDefaultMinimumMaximum
href="../EnvironmentConfig.html.timeDuration">Duration Yes100 s1 s-none-
    public static final String CATCHUP_MASTER_TIMEOUT =
        . + "catchupMasterTimeout";
    static {
        /*
         * Force loading when a ReplicationConfig is used with strings and
         * an environment has not been created.
         */
        @SuppressWarnings("unused")
        ConfigParam forceLoad = .;
    }

    

Hidden:
Storage for replication related properties.
    protected Properties props;
    /* For unit testing only: only ever set false when testing. */
    transient boolean validateParams = true;

    
Create a ReplicationMutableConfig initialized with the system default settings. Parameter defaults are documented with the string constants in this class.
    public ReplicationMutableConfig() {
         = new Properties();
    }

    
Used by ReplicationConfig to support construction from a property file.

Parameters:
properties Hold replication related properties
    ReplicationMutableConfig(Properties propertiesboolean validateParams)
        throws IllegalArgumentException {
        this. = validateParams;
        validateProperties(properties);
        /* For safety, copy the passed in properties. */
         = new Properties();
        .putAll(properties);
    }

    
Fills in the properties calculated by the environment to the given config object.
    void fillInEnvironmentGeneratedProps(RepImpl repImpl) {
                  Boolean.toString(repImpl.isDesignatedPrimary()));
                  Integer.toString(getNodePriority()));
    }

    

Hidden:
For internal use only
    public void copyMutablePropsTo(ReplicationMutableConfig toConfig) {
        Properties toProps = toConfig.props;
        Enumeration<?> propNames = .propertyNames();
        while (propNames.hasMoreElements()) {
            String paramName = (StringpropNames.nextElement();
            ConfigParam param =
                ..get(paramName);
            assert param != null;
            if (param.isForReplication() &&
                param.isMutable()) {
                String newVal = .getProperty(paramName);
                toProps.setProperty(paramNamenewVal);
            }
        }
    }

    
If isPrimary is true, designate this node as a Primary. The application must ensure that exactly one node is designated to be a Primary at any given time. Primary node configuration is only a concern when the group has two nodes, and there cannot be a simple majority. See the overview on href= "{@docRoot/../ReplicationGuide/lifecycle.html#twonode"> configuring two node groups}

Parameters:
isPrimary true if this node is to be made the Primary.
Returns:
this;
    public ReplicationMutableConfig setDesignatedPrimary(boolean isPrimary) {
        setDesignatedPrimaryVoid(isPrimary);
        return this;
    }

    

Hidden:
The void return setter for use by Bean editors.
    public void setDesignatedPrimaryVoid(boolean isPrimary) {
        DbConfigManager.setBooleanVal(.,
                                      isPrimary);
    }

    
Determines whether this node is the currently designated Primary. See the overview on href= "{@docRoot/../ReplicationGuide/lifecycle.html#twonode"> issues around two node groups}

Returns:
true if this node is a Primary, false otherwise.
    public boolean getDesignatedPrimary() {
        return DbConfigManager.getBooleanVal(,
                                             .);
    }

    
Returns the value associated with the override. A value of zero means that the number of electable nodes is determined as usual, that is, from the contents of the group metadata.

Returns:
the number of electable nodes as specified by the override
See also:
ELECTABLE_GROUP_SIZE_OVERRIDE
    public int getElectableGroupSizeOverride() {
        return DbConfigManager.
    }

    
Sets the size used to determine the number of electable nodes.

Parameters:
override the number of electable nodes. A value of zero means that the number of electable nodes is determined as usual, that is, from the contents of the group metadata.
Returns:
this
See also:
ELECTABLE_GROUP_SIZE_OVERRIDE
        setElectableGroupSizeOverride(int override) {
        setElectableGroupSizeOverrideVoid(override);
        return this;
    }

    

Hidden:
The void return setter for use by Bean editors.
    public void setElectableGroupSizeOverrideVoid(int override) {
        DbConfigManager.
            setIntVal(.override,
                      );
    }

    
Returns the election priority associated with the node.

Returns:
the priority for this node
See also:
NODE_PRIORITY
    public int getNodePriority() {
        return DbConfigManager.getIntVal(.);
    }

    
Sets the election priority for the node. The algorithm for choosing a new master will pick the participating node that has the most current set of log files. When there is a tie, the priority is used as a tie-breaker to select amongst these nodes.

A priority of zero is used to ensure that a node is never elected master, even if it has the most current set of files. Please use this option with caution, since it means that a node with less current log files could be elected master potentially forcing this node to rollback data that had been committed.

Parameters:
priority the priority to be associated with the node. It must be zero, or a positive number.
See also:
NODE_PRIORITY
    public ReplicationMutableConfig setNodePriority(int priority) {
        setNodePriorityVoid(priority);;
        return this;
    }

    

Hidden:
The void return setter for use by Bean editors.
    public void setNodePriorityVoid(int priority) {
        DbConfigManager.setIntVal(.priority,
                                  );
    }

    
Set this configuration parameter with this value. Values are validated before setting the parameter.

Parameters:
paramName the configuration parameter name, one of the String constants in this class
value the configuration value.
Returns:
this;
Throws:
java.lang.IllegalArgumentException if the paramName or value is invalid.
                                                   String value)
        throws IllegalArgumentException {
        DbConfigManager.setConfigParam(,
                                       paramName,
                                       value,
                                       true,   /* require mutability. */
                                       ,
                                       true,   /* forReplication */
                                       true);  /* verifyForReplication */
        return this;
    }

    
Return the value for this parameter.

Parameters:
paramName a valid configuration parameter, one of the String constants in this class.
Returns:
the configuration value.
Throws:
java.lang.IllegalArgumentException if the paramName is invalid.
    public String getConfigParam(String paramName)
        throws IllegalArgumentException {
        return DbConfigManager.getConfigParam(paramName);
    }

    
Validate a property bag passed in a construction time.
    void validateProperties(Properties checkProps)
        throws IllegalArgumentException {
        /* Check that the properties have valid names and values */
        Enumeration<?> propNames = checkProps.propertyNames();
        while (propNames.hasMoreElements()) {
            String name = (StringpropNames.nextElement();
            /* Is this a valid property name? */
            ConfigParam param =
                ..get(name);
            if (param == null) {
                throw new IllegalArgumentException
                (name + " is not a valid JE environment configuration");
            }
            /* Is this a valid property value? */
            if () {
                param.validateValue(checkProps.getProperty(name));
            }
        }
    }

    

Hidden:
For internal use only. Access the internal property bag, used during startup.
    public Properties getProps() {
        return ;
    }

    
List the configuration parameters and values that have been set in this configuration object.
    @Override
    public String toString() {
        return .toString();
    }

    
For unit testing only
    void setOverrideValidateParams(boolean validateParams) {
        this. = validateParams;
    }

    

Hidden:
For testing only
    public boolean  getValidateParams() {
        return ;
    }

    

Hidden:
For internal use only. Overrides Object.clone() to clone all properties, used by this class and ReplicationConfig.
    @Override
    protected Object clone()
        throws CloneNotSupportedException {
        ReplicationMutableConfig copy =
            (ReplicationMutableConfigsuper.clone();
        copy.props = (Properties.clone();
        return copy;
    }
New to GrepCode? Check out our FAQ X