ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nikhilknk <nikhil...@gmail.com>
Subject Affinitykey is not working
Date Fri, 29 Apr 2016 08:48:49 GMT
I used the below ToleranceCacheKey  as the key . I want to keep all the keys
whose  marketSectorId is same in the same node . So I kept annotation
"@AffinityKeyMapped" for marketSectorId .

I started 3 nodes of ignite cluster but the instruments of same
marketSectorId  are sahred among three nodes .

Is affinity doesnt work in this case . please suggest if i am missing
anything . 

I am using ignite 1.5 and scala 2.10.5 versions . 

/** 
 * 
 */ 
package com.spse.pricing.domain 

import java.util.Date 
import org.apache.ignite.cache.affinity.AffinityKeyMapped 
/** 
 * @author nkakkireni 
 * 
 */ 
case class ToleranceCacheKey ( 

                val instrumentId:String = null, 
                val cycleId:Int = 0, 
                @AffinityKeyMapped val marketSectorId:Int = 0, 
                val runDate :Date = null 
                ) 



my cache configuration 

val toleranceCache = { 
    val temp = ignite match { 
      case Some(s) => { 
        
         val toleranceCache = new
CacheConfiguration[ToleranceCacheKey,ToleranceCacheValue]("toleranceCache"); 
            toleranceCache.setCacheMode(CacheMode.PARTITIONED); 
            toleranceCache.setTypeMetadata(toleranceCacheMetadata()); 
        
        val cache = s.getOrCreateCache(toleranceCache) 
        cache 
      } 
      case _ => logError("Getting toleranceCache cache failed") 
            throw new Throwable("Getting toleranceCache cache failed") 
      
    } 
    temp 
    
  } 
  
    def toleranceCacheMetadata() = { 
        val types = new ArrayList[CacheTypeMetadata](); 
  
        val cacheType = new CacheTypeMetadata(); 
        cacheType.setValueType(classOf[ToleranceCacheValue].getName); 
        
          val qryFlds = cacheType.getQueryFields(); 
        qryFlds.put("tradingGroupId", classOf[Int]); 
  
        val indexedFlds=cacheType.getAscendingFields 
        indexedFlds.put("instrumentId", classOf[String]); 
        indexedFlds.put("cycleId", classOf[Int]); 
        indexedFlds.put("runDate", classOf[Date]); 
        indexedFlds.put("marketSectorId", classOf[Int]); 
  
        types.add(cacheType); 
  
        types; 
    }



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Affinitykey-is-not-working-tp4685.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message