Hi,

Can you please properly subscribe to the mailing list so that the community
receives email notifications? Here is the instruction:
http://apache-ignite-users.70518.x6.nabble.com/mailing_list/MailingListOptions.jtp?forum=1


nikhilknk wrote
> I started 3 nodes of ignite cluster and tried to keep all items of some
> type to same node . but it is not working .
> 
> I used the below ToleranceCacheKey  as the key . 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;
>     }

By default Scala doesn't apply annotation attached to constructor parameters
to auto-generated fields. Ot force it to do this, define the affinity key
parameter like this (note @field suffix):

@(AffinityKeyMapped @field) val marketSectorId:Int = 0

After this the collocation should work.

-Val



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

Reply via email to