Hi folks,
I want to integrated couchbase as persistent store with apache-ignite as per
instructions given in
http://apacheignite.gridgain.org/v1.6/docs/persistent-store. But I'm getting
error while compiling my TestTableStore.java which extends
CacheStoreAdapter<Long, TestTable>.
*Following is the output from compile command:*
src]$ javac -cp
$IGNITE_HOME/libs/ignite-core-1.6.0.jar:$IGNITE_HOME/libs/cache-api-1.0.0.jar:$IGNITE_HOME/libs/ignite-spring:.
TestTableStore.java -Xlint:deprecation
TestTableStore.java:14: error: TestTableStore is not abstract and does not
override abstract method write(Entry<? extends Long,? extends TestTable>) in
CacheWriter
public class TestTableStore extends CacheStoreAdapter<Long, TestTable> {
^
TestTableStore.java:54: error: name clash: write(Entry<Long,TestTable>) in
TestTableStore and write(Entry<? extends K,? extends V>) in CacheWriter have
the same erasure, yet neither overrides the other
@Override public void write(Cache.Entry<Long, TestTable> entry) {
^
where K,V are type-variables:
K extends Object declared in interface CacheWriter
V extends Object declared in interface CacheWriter
TestTableStore.java:54: error: method does not override or implement a
method from a supertype
@Override public void write(Cache.Entry<Long, TestTable> entry) {
^
TestTableStore.java:151: error: name clash: loadAll(Iterable<Long>) in
TestTableStore and loadAll(Iterable<? extends K>) in CacheStoreAdapter have
the same erasure, yet neither overrides the other
@Override public Map<Long, TestTable> loadAll(Iterable<Long> keys) {
^
where K,V are type-variables:
K extends Object declared in class CacheStoreAdapter
V extends Object declared in class CacheStoreAdapter
TestTableStore.java:151: error: method does not override or implement a
method from a supertype
@Override public Map<Long, TestTable> loadAll(Iterable<Long> keys) {
^
TestTableStore.java:176: error: name clash:
writeAll(Collection<Entry<Long,TestTable>>) in TestTableStore and
writeAll(Collection<Entry<? extends K,? extends V>>) in CacheStoreAdapter
have the same erasure, yet neither overrides the other
@Override public void writeAll(Collection<Cache.Entry<Long,
TestTable>> entries) {
^
where K,V are type-variables:
K extends Object declared in class CacheStoreAdapter
V extends Object declared in class CacheStoreAdapter
TestTableStore.java:176: error: method does not override or implement a
method from a supertype
@Override public void writeAll(Collection<Cache.Entry<Long,
TestTable>> entries) {
^
TestTableStore.java:201: error: name clash: deleteAll(Collection<Long>) in
TestTableStore and deleteAll(Collection<?>) in CacheStoreAdapter have the
same erasure, yet neither overrides the other
@Override public void deleteAll(Collection<Long> keys) {
^
TestTableStore.java:201: error: method does not override or implement a
method from a supertype
@Override public void deleteAll(Collection<Long> keys) {
^
9 errors
*Following is the relevant portion of source code:*
src]$ cat TestTableStore.java
import org.apache.ignite.cache.store.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.resources.*;
import java.sql.*;
import java.util.*;
import javax.cache.*;
import javax.cache.integration.*;
public class TestTableStore extends CacheStoreAdapter<Long, TestTable> {
...
// This mehtod is called whenever "put(...)" methods are called on
IgniteCache.
@Override public void write(Cache.Entry<Long, TestTable> entry) {
try (Connection 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.
try (PreparedStatement st = conn.prepareStatement(
"merge into TestTable (id,
firstName, lastName) key (id) VALUES (?, ?, ?)")) {
//st.setLong(1, entry.getKey());
//st.setString(2, val.getFirstName());
//st.setString(3, val.getLastName());
//st.executeUpdate();
}
}
catch (SQLException e) {
throw new CacheWriterException("Failed to write
[key= , val=");
//throw new CacheWriterException("Failed to write
[key=" + key + ", val=" + val + ']', e);
}
}
// This mehtod is called whenever "getAll(...)" methods are called
on IgniteCache.
@Override public Map<Long, TestTable> loadAll(Iterable<Long> keys) {
try (Connection conn = connection()) {
try (PreparedStatement st = conn.prepareStatement(
"select firstName, lastName from TestTable
where id=?")) {
Map<Long, TestTable> loaded = new
HashMap<>();
for (Long key : keys) {
st.setLong(1, key);
try(ResultSet rs =
st.executeQuery()) {
if (rs.next())
loaded.put(key, new
TestTable());
//loaded.put(key,
new TestTable(key, rs.getString(1), rs.getString(2)));
}
}
return loaded;
}
}
catch (SQLException e) {
throw new CacheLoaderException("Failed to loadAll: "
+ keys, e);
}
}
// This mehtod is called whenever "putAll(...)" methods are called
on IgniteCache.
@Override public void writeAll(Collection<Cache.Entry<Long,
TestTable>> entries) {
try (Connection 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.
try (PreparedStatement st = conn.prepareStatement(
"merge into TestTable (id, firstName,
lastName) key (id) VALUES (?, ?, ?)")) {
for (Cache.Entry<Long, TestTable> entry :
entries) {
TestTable val = entry.getValue();
//st.setLong(1, entry.getKey());
//st.setString(2,
val.getFirstName());
//st.setString(3,
val.getLastName());
st.addBatch();
}
st.executeBatch();
}
}
catch (SQLException e) {
throw new CacheWriterException("Failed to writeAll:
" + entries, e);
}
}
// This mehtod is called whenever "removeAll(...)" methods are
called on IgniteCache.
@Override public void deleteAll(Collection<Long> keys) {
try (Connection conn = connection()) {
try (PreparedStatement st =
conn.prepareStatement("delete from TestTable where id=?")) {
for (Long key : keys) {
st.setLong(1, key);
st.addBatch();
}
st.executeBatch();
}
}
catch (SQLException e) {
throw new CacheWriterException("Failed to deleteAll:
" + keys, e);
}
}
}
Please let me know what I'm missing here.
thanks.
--
View this message in context:
http://apache-ignite-users.70518.x6.nabble.com/Couchbase-as-persistent-store-tp7476.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.