Git Product home page Git Product logo

Comments (2)

spring-projects-issues avatar spring-projects-issues commented on April 28, 2024

John Blum commented

Note, 1 possible workaround to this Apache Geode induced problem is to "conditionally" define the Index on the PR in each peer member node. This can be easily accomplished using Spring's bean definition profiles.

This works quite nicely especially when several Geode Servers in a cluster are all configured with the same Spring (Data Geode) configuration meta-data.

Essentially, the "Index bean definition" can be wrapped in a Spring Profile. For example...

XML

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:gfe="http://www.springframework.org/schema/gemfire" 
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
">

    <!-- other bean definitions here -->

    <beans profile="EnableIndex">
        <gfe:index name="SharePartitionRegionIndex" expression=".." from="/SomePartitionRegion" .../>
    </beans>

</beans>

JAVA

@Configuration
class GeodeConfiguration {

  // other @Bean definitions defining Geode objects here...

   @Bean("SharedPartitionRegionIndex")
   @Profile("EnableIndex")
   public IndexFactoryBean sharedPrIndex(GemFireCache gemfireCache) {

      IndexFactoryBean indexFactory = new IndexFactoryBean();

      indexFactory.setCache(gemfireCache);
      indexFactory.setExpression("...");
      indexFactory.setFrom("/SomePartitionRegion");
      ...

      return indexFactory;
  }
}

Then all you need do is launch the Spring (Data Geode) configured, Geode peer cache application with the JVM System Property...

-Dspring.profiles.active=EnableIndex.

This Spring Profile (i.e. "EnableIndex) should only be enabled on 1 of the peer member nodes hosting the same PR, defining the same Index. If it is defined on more that 1 peer member node having the same PR and Index definition, then there will be a possibility of a IndexNameConflictException.

from spring-data-geode.

spring-projects-issues avatar spring-projects-issues commented on April 28, 2024

John Blum commented

Final changes resolving this ticket include:

  1. override now defaults to false.

This is a significant behavioral change to SDG so please adjust accordingly. It is atypical for the Spring Data team to introduce a behavioral change of this magnitude in any Service Release. However, this decision was not made lightly and is directly due to the race condition / bug in Apache Geode. In order for SDG to do the right thing and function correctly, the override default had to change to false.

  1. Introduced a new property/attribute, ignoreIfExists on the o.s.d.g.IndexFactoryBean or...
<gfe:index id="myIndex"  expression=".." from=".." ignore-if-exists="true"/>

This option effectively "ignores" the Index that would have been created by the Index bean definition / declaration in Spring config (specified with the <gfe:index/> element using the SDG XML namespace or the IndexFactoryBean when using Spring Java config).

  1. Both ignoreIfExists and override are applicable to either the IndexExistsException or the IndexNameConflictException. Each option performs a slightly different action depending on the Exception. You should make sure you understand each option relative to the type of Index Exception thrown by Geode before using the option.

Both options may be used but ignoreIfExists takes precedence over override.

Read the updated, attached documentation from the Spring Data Geode Reference Guide on Configuring an Index for more details

from spring-data-geode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.