RE: Adding new fields without server restart

2018-02-14 Thread Tim Newman
Hi Val,

Thanks for the response.

We will destroy the cache this time around. We will look to upgrade our 
environments to 2.3 (currently on 2.1) so we can dynamically update the cache 
configuration next time.

Thanks again!

-Original Message-
From: vkulichenko [mailto:valentin.kuliche...@gmail.com] 
Sent: Monday, February 12, 2018 03:33 PM
To: user@ignite.apache.org
Subject: Re: Adding new fields without server restart

Hi Tim,

Cache configuration is defines when it's started. So @QuerySqlField annotation 
on the new field does not have affect unless you restart the cluster or at 
least destroy the cache and create with the new configuration.
Field are added on object level transparently, but to modify the SQL schema in 
runtime you need to use ALTER TABLE and CREATE INDEX:
https://apacheignite-sql.readme.io/docs/ddl

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Re: Adding new fields without server restart

2018-02-12 Thread vkulichenko
Hi Tim,

Cache configuration is defines when it's started. So @QuerySqlField
annotation on the new field does not have affect unless you restart the
cluster or at least destroy the cache and create with the new configuration.
Field are added on object level transparently, but to modify the SQL schema
in runtime you need to use ALTER TABLE and CREATE INDEX:
https://apacheignite-sql.readme.io/docs/ddl

-Val



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/


Adding new fields without server restart

2018-02-12 Thread Tim Newman
Hi,

I have a POJO that I am caching written like:
public class Person implements Serializable {
private static final long serialVersionUID = 1537032807962869676L;

@QuerySqlField(index = true)
private final Long personId;

@QuerySqlField
private final String firstName;

...
}

This is working well and good, but now I want to add a new field: "homeState":
public class Person implements Serializable {
private static final long serialVersionUID = 1537032807962869676L;

@QuerySqlField(index = true)
private final Long personId;

@QuerySqlField
private final String firstName;

@QuerySqlField(index = true)
private final String homeState;

...
}

If I update the entries in the cache to have the new "homeState" value and then 
dump out the contents of the cache, the data is as I would expect. However, 
when I try to run a query against the new column (for example: "DELETE FROM 
person WHERE homeState = 'CA'") I get the error:
org.h2.jdbc.JdbcSQLException: Column "HOMESTATE" not found; SQL statement: 
DELETE FROM person WHERE homeState = ? [42122-195]

My CacheConfiguration used to get the cache:
CacheConfiguration cfg = new CacheConfiguration<>();
cfg.setName("person");
cfg.setIndexedTypes(Long.class, Person.class);

If I print out the QueryEntity objects, it looks like everything is good:
[QueryEntity [keyType=java.lang.Long, valType=com.calabrio.igtest.Person, 
keyFieldName=null, valueFieldName=null, fields={personId=java.lang.Long, 
firstName=java.lang.String, homeState=java.lang.String}, keyFields=[], 
aliases={firstName=firstName, personId=personId, homeState=homeState}, 
idxs=[QueryIndex [name=Person_personId_idx, fields={personId=true}, 
type=SORTED, inlineSize=-1], QueryIndex [name=Person_homeState_idx, 
fields={homeState=true}, type=SORTED, inlineSize=-1]], tableName=null]]

When I call the metadata REST API, the new field is not listed in the "fields" 
section for my cache object.

I've tried this on v2.1 and v2.3. Am I missing something, or is this simply not 
possible without including the relevant ALTER TABLE ... statement too? The goal 
is to not need to restart the Ignite server cluster.

Thanks
-Tim