ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kvipin <vipinkuma...@yahoo.com>
Subject Re: Couchbase as persistent store
Date Fri, 21 Oct 2016 07:39:15 GMT
Igor, thanks a lot for confirming that everything is working fine from
Apache-Ignite side. That helped me focus into my code only, which was really
a problematic piece.

The biggest problem was that I didn't have exception handling in my code
hence I was not getting any clue. Once I added exception handling,
everything was out in open.

First problem was that I had "storeKeepBinary" property enabled through my
configuration file, which was creating problem while typecasting record back
to TestTable object before constructing json document from it. Second
problem was that bytes and timestamp java datatypes couldn't directly be
stored in json object, hence I stored them as string data.

Following is the relevant portion of working code:

...
        // This mehtod is called whenever "putAll(...)" methods are called
on IgniteCache.
        @Override public void writeAll(Collection<Cache.Entry&lt;? extends
Long, ? extends TestTable>> entries) throws CacheWriterException {
                Bucket conn = connection();
                // Syntax of MERGE statement is database specific and should
be adopted for your database.
                // If your database does not support MERGE statement then
use sequentially update, insert statements.
                for (Cache.Entry<? extends Long, ? extends TestTable> entry
: entries) {
                        try {
                                *TestTable val = entry.getValue();* // type
casting error if "storeKeepBinary" property enabled.
                               
conn.insert(JsonDocument.create(entry.getKey().toString(),
JsonObject.create().put("tid", val.getTid()).put("idint",
val.getIdint()).put("idbigint", val.getIdbigint()).put("idchar",
val.getIdchar()).put("idbinary",
*val.getIdbinary()*.toString()).put("idvarbinary",
*val.getIdvarbinary()*.toString()).put("idvarchar",
val.getIdvarchar()).put("idts", val.getIdts().toString()))); // bytes
couldn't be stored in json object. applied toString on them to make it work
                        } catch (Exception e) {
                                System.out.println("There was an error
inserting record: " + e.getMessage());
                        }
                }
        }
...

Now things work fine for me.

Special thanks to Igor and Val for giving your precious time, things
would've been much more difficult without your kind support.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Couchbase-as-persistent-store-tp7476p8396.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Mime
View raw message