Bug is created already
https://issues.jboss.org/browse/ISPN-3405
----- Original Message -----
From: "Galder Zamarreño" <galder(a)redhat.com>
To: "infinispan -Dev List" <infinispan-dev(a)lists.jboss.org>
Sent: Tuesday, August 13, 2013 8:33:28 AM
Subject: Re: [infinispan-dev] How to get key ID passivated into DB
On Aug 9, 2013, at 4:58 PM, Mircea Markus <mmarkus(a)redhat.com> wrote:
+1, I think this is a bug. the active Equivalence implementation
should be used there.
Can you please create a JIRA for this?
And assign it to me, thanks! :)
On 9 Aug 2013, at 14:57, Vitalii Chepeliuk <vchepeli(a)redhat.com> wrote:
> Hi all! I have a question about entry passivation into DB, concretly this class
LockSupportCacheStore and method store
> @Override
> public final void store(InternalCacheEntry ed) throws CacheLoaderException {
> if (trace) {
> log.tracef("store(%s)", ed);
> }
> if (ed == null) {
> return;
> }
> if (ed.canExpire() && ed.isExpired(timeService.wallClockTime())) {
> if (containsKey(ed.getKey())) {
> if (trace) {
> log.tracef("Entry %s is expired! Removing!", ed);
> }
> remove(ed.getKey());
> } else {
> if (trace) {
> log.tracef("Entry %s is expired! Not doing anything.", ed);
> }
> }
> return;
> }
>
> L keyHashCode = getLockFromKey(ed.getKey()); <<< here key is generated
like ed.getKey().hashCode() & 0xfffffc00;
> lockForWriting(keyHashCode);
> try {
> storeLockSafe(ed, keyHashCode); <<< here it should be stored into
Bucket and then stored in DB
> } finally {
> unlock(keyHashCode);
> }
> if (trace) {
> log.tracef("exit store(%s)", ed);
> }
> }
> When I use RemoteCacheManager and RemoteCache I am putting entries into cache
> cache.put("key1", "v1");
> cache.put("key2", "v2");
> cache.put("key3", "v3");
> Then 2 entries are passivated and stored in DB
> ID DATA VERSION
>
183713792 0301fe032a01034c422b21033e286d7942657374506572736f6e616c4b657957686963684861734e657665724265656e426574746572420521033e02763203620003630000000000000002 -1
>
23486464 0301fe032a01034c420721033e046b657931420521033e02763103620003630000000000000001
-1
> IDs are generated from method above and
> byte[] keyBytes = marshaller.objectToByteBuffer(key, 64); <<< data are
marshalled
> long keyID = ByteArrayEquivalence.INSTANCE.hashCode(keyBytes) & 0xfffffc00
//computation taken from BucketBasedCacheStore << this does not work for me
> And next step I'd like to retrieve data from DB
> SELECT ID, DATA FROM JDBC_BINARY_DEFAULT WHERE ID=keyID
> But in method
> @Override
> public Integer getLockFromKey(Object key) {
> return key.hashCode() & 0xfffffc00; <<< here should be used
Arrays.hashCode((byte[])key) & 0xfffffc00), if key is represented as byte array, or
Used ByteArrayEquivalence instead of simple byte array(byte[]) as argument
Cheers,
--
Mircea Markus
Infinispan lead (
www.infinispan.org)
_______________________________________________
infinispan-dev mailing list
infinispan-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev
--
Galder Zamarreño
galder(a)redhat.com
twitter.com/galderz
Project Lead, Escalante
http://escalante.io
Engineer, Infinispan
http://infinispan.org
_______________________________________________
infinispan-dev mailing list
infinispan-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev