About cache backups's question

classic Classic list List threaded Threaded
4 messages Options
上帝已死 上帝已死
Reply | Threaded
Open this post in threaded view
|

About cache backups's question

I wrote a test case. The following is my code and configuration. I found the default configuration may have some problem. I didn't set the backups, but output is (backups=2147483647)
CacheConfiguration [name=myCache, storeConcurrentLoadAllThreshold=5, rebalancePoolSize=2, rebalanceTimeout=10000, evictPlc=null, evictSync=false, evictKeyBufSize=1024, evictSyncConcurrencyLvl=4, evictSyncTimeout=10000, evictFilter=null, evictMaxOverflowRatio=10.0, eagerTtl=true, dfltLockTimeout=0, startSize=1500000, nearCfg=null, writeSync=PRIMARY_SYNC, storeFactory=null, storeKeepBinary=false, loadPrevVal=false, aff=org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction@5bdc4f7c, cacheMode=REPLICATED, atomicityMode=ATOMIC, atomicWriteOrderMode=PRIMARY, backups=2147483647, invalidate=false, tmLookupClsName=null, rebalanceMode=ASYNC, rebalanceOrder=0, rebalanceBatchSize=524288, rebalanceBatchesPrefetchCount=2, offHeapMaxMem=-1, swapEnabled=false, maxConcurrentAsyncOps=500, writeBehindEnabled=false, writeBehindFlushSize=10240, writeBehindFlushFreq=5000, writeBehindFlushThreadCnt=1, writeBehindBatchSize=512, memMode=ONHEAP_TIERED, affMapper=org.apache.ignite.internal.processors.cache.CacheDefaultBinaryAffinityKeyMapper@2226344d, rebalanceDelay=0, rebalanceThrottle=0, interceptor=null, longQryWarnTimeout=3000, readFromBackup=true, nodeFilter=org.apache.ignite.configuration.CacheConfiguration$IgniteAllNodesPredicate@1b35db6f, sqlSchema=null, sqlEscapeAll=false, sqlOnheapRowCacheSize=10240, snapshotableIdx=false, cpOnRead=true, topValidator=null]

My Configuration (spring/applicationContext-ignite.xml) :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="
		http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">

	<bean id="igniteConfiguration" class="org.apache.ignite.configuration.IgniteConfiguration">
		<property name="gridName" value="myGrid" />
		<property name="peerClassLoadingEnabled" value="false" />
		<property name="cacheConfiguration">
            <list>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                		<property name="name" value="myCache"/>
                    <!-- <property name="backups" value="1"/> -->
                    <property name="cacheMode" value="REPLICATED" />
                    <property name="statisticsEnabled" value="true" />
                </bean>
            </list>
        </property>
		<property name="discoverySpi">
			<bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
				<property name="ipFinder">
					<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
						<property name="addresses">
							<list>
								<value>192.168.4.249</value>
								<value>192.168.2.232</value>
								<value>192.168.1.199</value>
							</list>
						</property>
					</bean>
				</property>
			</bean>
		</property>
	</bean>

</beans>

My Code
@Component("igniteInstance")
public class IgniteInstance {
	
	private Ignite INSTANCE = null;
	
	private IgniteCache<String, Object> myCache = null;

	public IgniteInstance() {
		INSTANCE = Ignition.start("spring/applicationContext-ignite.xml");
	}
	
	public Ignite getInstance() {
		return INSTANCE;
	}
	
	public IgniteCache<String, Object> getMyCache() {
		myCache = INSTANCE.getOrCreateCache("myCache");
		return myCache;
	}
}



@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring/*.xml" })
public class JustATestClass {
	
	@Resource(name = "igniteInstance")
	private IgniteInstance igniteInstance;
	
	@Test
	public void getData() {
		
		try {
			ExpiryPolicy expiryPolicy = new CreatedExpiryPolicy(new Duration(TimeUnit.SECONDS, 10));
			IgniteCache<String, Object> cache = igniteInstance.getMyCache().withExpiryPolicy(expiryPolicy);
			System.out.println(igniteInstance.getMyCache().getConfiguration(CacheConfiguration.class));
			cache.put("aaa", 123);
			System.out.println("aaa = " + cache.get("aaa"));
			Thread.sleep(11 * 1000);
			System.out.println("aaa = " + cache.get("aaa"));
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
	
}
上帝已死 上帝已死
Reply | Threaded
Open this post in threaded view
|

Re: About cache backups's question

When I set backups = 1, the output still is backups=2147483647
Vladimir Ozerov Vladimir Ozerov
Reply | Threaded
Open this post in threaded view
|

Re: About cache backups's question

You have replicated cache, and backup setting doesn't have sense in this mode because data will be replicated to all nodes in topology.

On Wed, Mar 2, 2016 at 9:03 AM, 上帝已死 <[hidden email]> wrote:
When I set backups = 1, the output still is backups=2147483647



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/About-cache-backups-s-question-tp3331p3332.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Romain Gilles-2 Romain Gilles-2
Reply | Threaded
Open this post in threaded view
|

Re: About cache backups's question

When you set up a replicated cache the ignite automatically set the number of backup to Integer.MAX_VALUE without looking at the provided value in your configuration. That's why you see this value. It's a kind of hard coded value but it doesn't matter in case of replicated cache.

Best regards,

Romain


Le mer. 2 mars 2016 11:24, Vladimir Ozerov <[hidden email]> a écrit :
You have replicated cache, and backup setting doesn't have sense in this mode because data will be replicated to all nodes in topology.

On Wed, Mar 2, 2016 at 9:03 AM, 上帝已死 <[hidden email]> wrote:
When I set backups = 1, the output still is backups=2147483647



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/About-cache-backups-s-question-tp3331p3332.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.