You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by nikhilknk <ni...@gmail.com> on 2016/04/29 10:48:49 UTC
Affinitykey is not working
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.
Re: Affinitykey is not working
Posted by Alexey Goncharuk <al...@gmail.com>.
Yes, as long as cache configurations have matching affinity configuration
and those caches are deployed on the same nodes - the same affinity keys
will go to the same nodes in any cache.
2016-05-02 3:38 GMT-07:00 nikhilknk <ni...@gmail.com>:
> Thanks Alexey . This is working . I have one more question following the
> previous .
>
> I have two cache’s in 3 nodes , which saves same sort of data for different
> dates (one for current day cache and other for previous day cache) .
>
> Will all the records having same market sector id will be saved on same
> node
> for both the caches ??
>
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Affinitykey-is-not-working-tp4685p4727.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>
Re: Affinitykey is not working
Posted by nikhilknk <ni...@gmail.com>.
Thanks Alexey . This is working . I have one more question following the
previous .
I have two cache’s in 3 nodes , which saves same sort of data for different
dates (one for current day cache and other for previous day cache) .
Will all the records having same market sector id will be saved on same node
for both the caches ??
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Affinitykey-is-not-working-tp4685p4727.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Affinitykey is not working
Posted by Alexey Goncharuk <al...@gmail.com>.
Hi,
Scala does not automatically place annotations to generated fields, you
need to use the annotation as follows:
@(AffinityKeyMapped @field) val marketSectorId:Int = 0
Re: Affinitykey is not working
Posted by Vladimir Ozerov <vo...@gridgain.com>.
Hi,
Could you please explain how do you detect a node to which key is mapped?
Do you use Affinity API?
Vladimir.
On Fri, Apr 29, 2016 at 11:48 AM, nikhilknk <ni...@gmail.com> wrote:
> 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.
>