10.2. Configure Locking (Library Mode)


For Library mode, the locking element and its parameters are set within the optional configuration element on a per cache basis. For example, for the default cache, the configuration element occurs within the default element and for each named cache, it occurs within the namedCache element. The following is an example of this configuration:

Procedure 10.2. Configure Locking (Library Mode)

  1. Set the Concurrency Level

    The concurrencyLevel parameter specifies the concurrency level for the lock container. Set this value according to the number of concurrent threads interacting with the data grid.
    <infinispan>
    	...
    	<default>
    		<locking concurrencyLevel="${VALUE}" />
    
  2. Specify the Cache Isolation Level

    The isolationLevel parameter specifies the cache's isolation level. Valid isolation levels are READ_COMMITTED and REPEATABLE_READ. For details about isolation levels, see Section 12.1, “About Isolation Levels”
    <infinispan>
    	...
    	<default>
    		<locking concurrencyLevel="${VALUE}"
    				isolationLevel="${LEVEL}" />
    
  3. Set the Lock Acquisition Timeout

    The lockAcquisitionTimeout parameter specifies time (in milliseconds) after which a lock acquisition attempt times out.
    <infinispan>
    	...
    	<default>
    		<locking concurrencyLevel="${VALUE}"
    			isolationLevel="${LEVEL}"
    			lockAcquisitionTimeout="${TIME}" />
    
  4. Configure Lock Striping

    The useLockStriping parameter specifies whether a pool of shared locks are maintained for all entries that require locks. If set to FALSE, locks are created for each entry in the cache. For details, see Section 11.1, “About Lock Striping”
    <infinispan>
    	...
    	<default>
    		<locking concurrencyLevel="${VALUE}"
    			isolationLevel="${LEVEL}"
    			lockAcquisitionTimeout="${TIME}"
    			useLockStriping="${TRUE/FALSE}" />
    
    • Set writeSkewCheck Parameter

      The writeSkewCheck parameter is only valid if the isolationLevel is set to REPEATABLE_READ. If this parameter is set to FALSE, a disparity between a working entry and the underlying entry at write time results in the working entry overwriting the underlying entry. If the parameter is set to TRUE, such conflicts (namely write skews) throw an exception.
      <infinispan>
      	...
      	<default>
      		<locking concurrencyLevel="${VALUE}"
      			isolationLevel="${LEVEL}"
      			lockAcquisitionTimeout="${TIME}"
      			useLockStriping="${TRUE/FALSE}"
      			writeSkewCheck="${TRUE/FALSE}" />
      
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.