You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by vkulichenko <va...@gmail.com> on 2016/09/23 22:32:01 UTC

Re: Ignite zeppelin jdbc connection

Hi,

Please properly subscribe to the mailing list so that the community can
receive email notifications for your messages. To subscribe, send empty
email to user-subscribe@ignite.apache.org and follow simple instructions in
the reply.


junyoung.kang wrote
> I have two question.
> 
> First, This is my zeppelin ignite interpreter configuration.
> 
> name           	value
> ignite.addresses	x.x.x.x:47500..47509,x.x.x.x:47500..47509
> ignite.clientMode	true
> ignite.config.url	
> ignite.jdbc.url
> jdbc:ignite:cfg://cache=testCache@file:///default-config.xml
> ignite.peerClassLoadingEnabled	true
> zeppelin.interpreter.localRepo	/apps/zeppelin/local-repo/2BW6BG9YY
> 
> my remote ignite server have two caches (testCache, testCache2) 
> 
> I want to connect both testCache and testCache2. 
> 
> how to setting config??
> 
> Second,
> 
> one cache is one database table?
> 
> in other words , 
> 
> table == cache?
> 
> either
> 
> database == cache??
> 
> I understand table == cache... (because indexType is java pojo) 

Each cache is a database schema. The cache you're connected to is your
default schema, so you can query from others providing schema name before
table name. For example, if you connect to testCache, you can query from
testCache2 like this:

select * from "testCache2".table_name

You can join these two tables with each other as well.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-zeppelin-jdbc-connection-tp7898p7927.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite zeppelin jdbc connection

Posted by Sergej Sidorov <se...@gmail.com>.
Hi!

It looks like in thread [1].
Server and client spring contexts should have dataSource configuration.
Let me now if the solution from the tread won't help.

[1]
http://apache-ignite-users.70518.x6.nabble.com/Data-grid-client-errors-out-when-datasource-not-defined-tp7820p7854.html

-Sergej



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-zeppelin-jdbc-connection-tp7898p8150.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite zeppelin jdbc connection

Posted by vdpyatkov <vl...@gmail.com>.
Hi,

This can be if you change data from database (for example using SQL update)
after loading to Ignite cache.
Ignite does not load data if they had loaded already (idetificatin by key).

If you use setReadThrough and setWriteThrough, you need to modify data
through cache only.


junyoung.kang wrote
> I mistake.. Sorry.
> 
> my load() function is
> 
>     @Override
>     public TbCustomer load(Integer customerId) throws CacheLoaderException
> {
> 
>         System.out.println(">>>> load data key =" + customerId);
> 
>         try {
>             Connection connection = dataSource.getConnection();
> 
>             PreparedStatement st = connection.prepareStatement("select *
> from TB_CUSTOMER where CUSTOMER_ID=?");
>             st.setString(1, customerId.toString());
> 
>             ResultSet rs = st.executeQuery();
> 
>             return rs.next() ? new TbCustomer(rs.getInt(1),
> rs.getString("EXTRA_CUSTOMER_NAME"),
>                     rs.getString("MOBILE_PHONE"), rs.getString("EMAIL"),
> Integer.valueOf(rs.getString("DEL_FLAG"))) : null;
> 
>         } catch (SQLException e) {
>             e.printStackTrace();
>             throw new CacheLoaderException("Failed to load customer id ="
> + customerId, e);
>         }
>     }
> 
> 
> I retry to test.. I want to value through database.
> 
> In my case(don't get value in database), I execute sql query on this
> cache.. 
> 
> like this..
> 
>         String query = "select * from TbCustomer where delFlag=?";
>         System.out.println(query);
>         QueryCursor&lt;List&lt;?&gt;> results = customerCache.query(new
> SqlFieldsQuery(query).setArgs(0));
>         Util.print("simple Query : select * from TbCustomer where
> delFlag=0 ", results.getAll());
> 
> In this case, I can't get value in all database.(database query result !=
> above sql result)
> 
> However, when I invoke get() method, I get a value(not existed cache and
> existed database)
> 
> Thank you to reply.





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-zeppelin-jdbc-connection-tp7898p8012.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite zeppelin jdbc connection

Posted by vkulichenko <va...@gmail.com>.
Read-through means that when you do a get() on the cache, it will return the
value from the database if it doesn't exist in cache. But it sounds you're
invoking load() directly on the store. Is this the case? Can you show your
code?

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-zeppelin-jdbc-connection-tp7898p7991.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite zeppelin jdbc connection

Posted by vkulichenko <va...@gmail.com>.
Hi,

What query are you executing? This should happen only if you do 'select *',
because this includes special pre-defined _key and _val fields that
represent whole key and value objects. If you specify the list of fields,
you should not get the exception.

-Val



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-zeppelin-jdbc-connection-tp7898p7980.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite zeppelin jdbc connection

Posted by vdpyatkov <vl...@gmail.com>.
Hi,

As I know you can configure CacheJdbcPojoStore in order to pairs of various
object save to different tables. But in the case types of key must be
different.

All nodes of cluster need to have value classes on classpath or to configure

<bean class="org.apache.ignite.configuration.IgniteConfiguration">
  <property name="peerClassLoadingEnabled" value="true"/>

About loading data from persistent store you can look the article[1]

PS
Do not forget to subscribe on mailing list, as Val said.

[1]: http://apacheignite.gridgain.org/docs/data-loading


junyoung.kang wrote
> Wow Thank you for reply!!! also I subscribe mail. 
> 
> I respect you.
> 
> I have more question.(to much.. sorry)
> 
> First, you say a cache is a database schema. But Ignite cache have one
> table in one cache. This is why I think I push data to cache, "
> cacheConfiguration.setIndexedTypes(Integer.class, testTable.class) " . 
> Integer.class is table PK, testTable is JavaPoJo class(have table fields).
> So I insert another table..., I make more cache. isn't it ok?
> 
> Second, how to setting classpath?.. because "select * from TbCustomer" ->
> occur below error.
> 
> ERROR [2016-09-27 14:46:00,923] ({pool-2-thread-7}
> IgniteSqlInterpreter.java[interpret]:158) - Exception in
> IgniteSqlInterpreter while InterpreterResult interpret:
> java.sql.SQLException: Failed to query Ignite.
>         at
> org.apache.ignite.internal.jdbc2.JdbcStatement.executeQuery(JdbcStatement.java:115)
>         at
> org.apache.zeppelin.ignite.IgniteSqlInterpreter.interpret(IgniteSqlInterpreter.java:132)
>         at
> org.apache.zeppelin.interpreter.LazyOpenInterpreter.interpret(LazyOpenInterpreter.java:94)
>         at
> org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:341)
>         at org.apache.zeppelin.scheduler.Job.run(Job.java:176)
>         at
> org.apache.zeppelin.scheduler.FIFOScheduler$1.run(FIFOScheduler.java:139)
>         at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>         at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
>         at
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>         at java.lang.Thread.run(Thread.java:745)
> Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException:
> com.navercorp.searchad.model.TbCustomer
>         at
> org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:671)
>         at
> org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1474)
>         at
> org.apache.ignite.internal.binary.BinaryObjectImpl.deserializeValue(BinaryObjectImpl.java:585)
>         at
> org.apache.ignite.internal.binary.BinaryObjectImpl.value(BinaryObjectImpl.java:142)
>         at
> org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinary(CacheObjectContext.java:272)
>         at
> org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinariesIfNeeded(CacheObjectContext.java:185)
>         at
> org.apache.ignite.internal.processors.cache.CacheObjectContext.unwrapBinariesIfNeeded(CacheObjectContext.java:169)
>         at
> org.apache.ignite.internal.processors.cache.GridCacheContext.unwrapBinariesIfNeeded(GridCacheContext.java:1741)
>         at
> org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator.next(GridQueryCacheObjectsIterator.java:64)
>         at
> org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator.next(GridQueryCacheObjectsIterator.java:29)
>         at
> org.apache.ignite.internal.jdbc2.JdbcQueryTask.call(JdbcQueryTask.java:177)
>         at
> org.apache.ignite.internal.jdbc2.JdbcStatement.executeQuery(JdbcStatement.java:102)
>         ... 12 more
> Caused by: java.lang.ClassNotFoundException:
> com.navercorp.searchad.model.TbCustomer
>         at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
>         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
>         at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
>         at java.lang.Class.forName0(Native Method)
>         at java.lang.Class.forName(Class.java:348)
>         at
> org.apache.ignite.internal.util.IgniteUtils.forName(IgniteUtils.java:8350)
>         at
> org.apache.ignite.internal.MarshallerContextAdapter.getClass(MarshallerContextAdapter.java:185)
>         at
> org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:662)
>         ... 23 more
> 
> I know class file is in IGNITE_HOME/libs...?? 
> please example in detail.
> 
> 
> Finally, In client mode, how to connect to persistent store??
> I want to read-through, write-through data in persistent store.
> 
> 
> Thank you..
> 
> ps. sorry to many questions ... 
> I look forward to your reply. Thank you~!





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-zeppelin-jdbc-connection-tp7898p7967.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.