@aloxc
2017-12-05T06:37:18.000000Z
字数 24097
阅读 501
ignite
如题,使用官方的示例代码来测试ignite的时候,如果不配置部署模式deploymentMode,也就是默认的配置SHARED,测试该类,一切正常,当调整为PRIVATE的时候(服务器端的配置同步调整为PRIVATE),如下
<property name="deploymentMode" value="PRIVATE"/>
第二天补充下
部署模式测试了一下几种都会发生这个异常
- PRIVATE
- ISOLATED
而SHARED和CONTINUOUS没问题,难道是bug还是?
这时候执行该类,会发生异常,异常堆栈如下:
Exception in thread "main" javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException: Query execution failed: GridCacheQueryBean [qry=GridCacheQueryAdapter [type=SCAN, clsName=null, clause=null, filter=com.github.aloxc.ignite.datagrid.CacheQueryExample$1@10c8f62, part=null, incMeta=false, metrics=GridCacheQueryMetricsAdapter [minTime=0, maxTime=0, sumTime=0, avgTime=0.0, execs=0, completed=0, fails=0], pageSize=1024, timeout=0, keepAll=true, incBackups=false, dedup=false, prj=null, keepBinary=true, subjId=9d99e4dc-7040-4670-a190-4bdb10f92dcf, taskHash=0], rdc=null, trans=null]
at org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1502)
at org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter.next(GridCacheQueryFutureAdapter.java:176)
at org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$5.onHasNext(GridCacheDistributedQueryManager.java:634)
at org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
at org.apache.ignite.internal.processors.cache.IgniteCacheProxy$2$1.onHasNext(IgniteCacheProxy.java:501)
at org.apache.ignite.internal.util.GridCloseableIteratorAdapter.hasNextX(GridCloseableIteratorAdapter.java:53)
at org.apache.ignite.internal.util.lang.GridIteratorAdapter.hasNext(GridIteratorAdapter.java:45)
at org.apache.ignite.internal.processors.cache.QueryCursorImpl.getAll(QueryCursorImpl.java:73)
at com.github.aloxc.ignite.datagrid.CacheQueryExample.scanQueryx(CacheQueryExample.java:177)
at com.github.aloxc.ignite.datagrid.CacheQueryExample.main(CacheQueryExample.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: class org.apache.ignite.IgniteCheckedException: Query execution failed: GridCacheQueryBean [qry=GridCacheQueryAdapter [type=SCAN, clsName=null, clause=null, filter=com.github.aloxc.ignite.datagrid.CacheQueryExample$1@10c8f62, part=null, incMeta=false, metrics=GridCacheQueryMetricsAdapter [minTime=0, maxTime=0, sumTime=0, avgTime=0.0, execs=0, completed=0, fails=0], pageSize=1024, timeout=0, keepAll=true, incBackups=false, dedup=false, prj=null, keepBinary=true, subjId=9d99e4dc-7040-4670-a190-4bdb10f92dcf, taskHash=0], rdc=null, trans=null]
at org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter.checkError(GridCacheQueryFutureAdapter.java:262)
at org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter.internalIterator(GridCacheQueryFutureAdapter.java:320)
at org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter.next(GridCacheQueryFutureAdapter.java:166)
... 13 more
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to execute query on node [query=GridCacheQueryBean [qry=GridCacheQueryAdapter [type=SCAN, clsName=null, clause=null, filter=com.github.aloxc.ignite.datagrid.CacheQueryExample$1@10c8f62, part=null, incMeta=false, metrics=GridCacheQueryMetricsAdapter [minTime=0, maxTime=0, sumTime=0, avgTime=0.0, execs=0, completed=0, fails=0], pageSize=1024, timeout=0, keepAll=true, incBackups=false, dedup=false, prj=null, keepBinary=true, subjId=9d99e4dc-7040-4670-a190-4bdb10f92dcf, taskHash=0], rdc=null, trans=null], nodeId=a71b03a7-311c-41d6-9b9d-e381adfca013]
at org.apache.ignite.internal.processors.cache.query.GridCacheQueryFutureAdapter.onPage(GridCacheQueryFutureAdapter.java:385)
at org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager.processQueryResponse(GridCacheDistributedQueryManager.java:398)
at org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager.access$000(GridCacheDistributedQueryManager.java:63)
at org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$1.apply(GridCacheDistributedQueryManager.java:93)
at org.apache.ignite.internal.processors.cache.query.GridCacheDistributedQueryManager$1.apply(GridCacheDistributedQueryManager.java:91)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.processMessage(GridCacheIoManager.java:748)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:353)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$400(GridCacheIoManager.java:88)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager$OrderedMessageListener.onMessage(GridCacheIoManager.java:1262)
at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1238)
at org.apache.ignite.internal.managers.communication.GridIoManager.access$1600(GridIoManager.java:106)
at org.apache.ignite.internal.managers.communication.GridIoManager$GridCommunicationMessageSet.unwind(GridIoManager.java:2488)
at org.apache.ignite.internal.managers.communication.GridIoManager.unwindMessageSet(GridIoManager.java:1198)
at org.apache.ignite.internal.managers.communication.GridIoManager.access$1900(GridIoManager.java:106)
at org.apache.ignite.internal.managers.communication.GridIoManager$6.run(GridIoManager.java:1167)
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.IgniteCheckedException: com.github.aloxc.ignite.datagrid.CacheQueryExample$1
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.unmarshall(GridCacheIoManager.java:1221)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.onMessage0(GridCacheIoManager.java:348)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.handleMessage(GridCacheIoManager.java:277)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.access$000(GridCacheIoManager.java:88)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager$1.onMessage(GridCacheIoManager.java:231)
at org.apache.ignite.internal.managers.communication.GridIoManager.invokeListener(GridIoManager.java:1238)
at org.apache.ignite.internal.managers.communication.GridIoManager.processRegularMessage0(GridIoManager.java:866)
at org.apache.ignite.internal.managers.communication.GridIoManager.access$1700(GridIoManager.java:106)
at org.apache.ignite.internal.managers.communication.GridIoManager$5.run(GridIoManager.java:829)
... 3 more
Caused by: class org.apache.ignite.binary.BinaryInvalidTypeException: com.github.aloxc.ignite.datagrid.CacheQueryExample$1
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:671)
at org.apache.ignite.internal.binary.BinaryContext.descriptorForTypeId(BinaryContext.java:668)
at org.apache.ignite.internal.binary.BinaryReaderExImpl.deserialize(BinaryReaderExImpl.java:1474)
at org.apache.ignite.internal.binary.GridBinaryMarshaller.deserialize(GridBinaryMarshaller.java:298)
at org.apache.ignite.internal.binary.BinaryMarshaller.unmarshal(BinaryMarshaller.java:109)
at org.apache.ignite.internal.processors.cache.query.GridCacheQueryRequest.finishUnmarshal(GridCacheQueryRequest.java:322)
at org.apache.ignite.internal.processors.cache.GridCacheIoManager.unmarshall(GridCacheIoManager.java:1215)
... 11 more
Caused by: java.lang.ClassNotFoundException: com.github.aloxc.ignite.datagrid.CacheQueryExample$1
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)
... 17 more
我们把java代码中的方法scanQuery()中的代码注释掉以后又没问题了,这是为嘛?有谁知道
注意看异常堆栈信息提示
Caused by: java.lang.ClassNotFoundException: com.github.aloxc.ignite.datagrid.CacheQueryExample$1,这个提示就是找不到CacheQueryExample,这是本类啊;照说找不到的话我把scanQuery()方法中的代码注释掉后再运行也应该找不到啊
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.github.aloxc.ignite.datagrid;
import com.github.aloxc.ignite.Config;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.binary.BinaryObject;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.affinity.AffinityKey;
import org.apache.ignite.cache.query.*;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.examples.ExampleNodeStartup;
import org.apache.ignite.examples.model.Organization;
import org.apache.ignite.examples.model.Person;
import org.apache.ignite.lang.IgniteBiPredicate;
import javax.cache.Cache;
import java.util.List;
/**
* Cache queries example. This example demonstrates SQL, TEXT, and FULL SCAN
* queries over cache.
* <p>
* Example also demonstrates usage of fields queries that return only required
* fields instead of whole key-value pairs. When fields queries are distributed
* across several nodes, they may not work as expected. Keep in mind following
* limitations (not applied if data is queried from one node only):
* <ul>
* <li>
* Non-distributed joins will work correctly only if joined objects are stored in
* collocated mode. Refer to {@link AffinityKey} javadoc for more details.
* <p>
* To use distributed joins it is necessary to set query 'distributedJoin' flag using
* {@link SqlFieldsQuery#setDistributedJoins(boolean)} or {@link SqlQuery#setDistributedJoins(boolean)}.
* </li>
* <li>
* Note that if you created query on to replicated cache, all data will
* be queried only on one node, not depending on what caches participate in
* the query (some data from partitioned cache can be lost). And visa versa,
* if you created it on partitioned cache, data from replicated caches
* will be duplicated.
* </li>
* </ul>
* <p>
* Remote nodes should be started using {@link ExampleNodeStartup} which will
* start node with {@code examples/config/example-ignite.xml} configuration.
*/
public class CacheQueryExample {
/** Organizations cache name. */
private static final String ORG_CACHE = CacheQueryExample.class.getSimpleName() + "Organizations";
/** Persons collocated with Organizations cache name. */
private static final String COLLOCATED_PERSON_CACHE = CacheQueryExample.class.getSimpleName() + "CollocatedPersons";
/** Persons cache name. */
private static final String PERSON_CACHE = CacheQueryExample.class.getSimpleName() + "Persons";
/**
* Executes example.
*
* @param args Command line arguments, none required.
* @throws Exception If example execution failed.
*/
public static void main(String[] args) throws Exception {
try (Ignite ignite = Ignition.start(Config.DEFAULT_CONFIG_PATH)) {
System.out.println();
System.out.println(">>> Cache query example started.");
CacheConfiguration<Long, Organization> orgCacheCfg = new CacheConfiguration<>(ORG_CACHE);
orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
CacheConfiguration<AffinityKey<Long>, Person> colPersonCacheCfg = new CacheConfiguration<>(COLLOCATED_PERSON_CACHE);
colPersonCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
colPersonCacheCfg.setIndexedTypes(AffinityKey.class, Person.class);
CacheConfiguration<AffinityKey<Long>, Person> personCacheCfg = new CacheConfiguration<>(PERSON_CACHE);
personCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
personCacheCfg.setIndexedTypes(Long.class, Person.class);
// Auto-close cache at the end of the example.
try (
IgniteCache<Long, Organization> orgCache = ignite.getOrCreateCache(orgCacheCfg);
IgniteCache<AffinityKey<Long>, Person> colPersonCache = ignite.getOrCreateCache(colPersonCacheCfg);
IgniteCache<AffinityKey<Long>, Person> personCache = ignite.getOrCreateCache(personCacheCfg)
) {
// Populate cache.
initialize();
// Example for SCAN-based query based on a predicate.
scanQuery();
// Example for SQL-based querying employees based on salary ranges.
sqlQuery();
// Example for SQL-based querying employees for a given organization (includes SQL join for collocated objects).
sqlQueryWithJoin();
// Example for SQL-based querying employees for a given organization (includes distributed SQL join).
sqlQueryWithDistributedJoin();
// Example for TEXT-based querying for a given string in peoples resumes.
textQuery();
// Example for SQL-based querying to calculate average salary among all employees within a company.
sqlQueryWithAggregation();
// Example for SQL-based fields queries that return only required
// fields instead of whole key-value pairs.
sqlFieldsQuery();
// Example for SQL-based fields queries that uses joins.
sqlFieldsQueryWithJoin();
}
finally {
// Distributed cache could be removed from cluster only by #destroyCache() call.
ignite.destroyCache(COLLOCATED_PERSON_CACHE);
ignite.destroyCache(PERSON_CACHE);
ignite.destroyCache(ORG_CACHE);
}
print("Cache query example finished.");
}
}
private static void scanQuery() {
IgniteCache<BinaryObject, BinaryObject> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE).withKeepBinary();
ScanQuery<BinaryObject, BinaryObject> scan = new ScanQuery<>(
new IgniteBiPredicate<BinaryObject, BinaryObject>() {
@Override public boolean apply(BinaryObject key, BinaryObject person) {
return person.<Double>field("salary") <= 1000;
}
}
);
// Execute queries for salary ranges.
print("People with salaries between 0 and 1000 (queried with SCAN query)[withKeepBinary]: ", cache.query(scan).getAll());
}
/**
* Example for SQL queries based on salary ranges.
*/
private static void sqlQuery() {
IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
// SQL clause which selects salaries based on range.
String sql = "salary > ? and salary <= ?";
// Execute queries for salary ranges.
print("People with salaries between 0 and 1000 (queried with SQL query): ",
cache.query(new SqlQuery<AffinityKey<Long>, Person>(Person.class, sql).
setArgs(0, 1000)).getAll());
print("People with salaries between 1000 and 2000 (queried with SQL query): ",
cache.query(new SqlQuery<AffinityKey<Long>, Person>(Person.class, sql).
setArgs(1000, 2000)).getAll());
}
/**
* Example for SQL queries based on all employees working for a specific organization.
*/
private static void sqlQueryWithJoin() {
IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE);
// SQL clause query which joins on 2 types to select people for a specific organization.
String joinSql =
"from Person, \"" + ORG_CACHE + "\".Organization as org " +
"where Person.orgId = org.id " +
"and lower(org.name) = lower(?)";
// Execute queries for find employees for different organizations.
print("Following people are 'ApacheIgnite' employees: ",
cache.query(new SqlQuery<AffinityKey<Long>, Person>(Person.class, joinSql).
setArgs("ApacheIgnite")).getAll());
print("Following people are 'Other' employees: ",
cache.query(new SqlQuery<AffinityKey<Long>, Person>(Person.class, joinSql).
setArgs("Other")).getAll());
}
/**
* Example for SQL queries based on all employees working for a specific organization (query uses distributed join).
*/
private static void sqlQueryWithDistributedJoin() {
IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
// SQL clause query which joins on 2 types to select people for a specific organization.
String joinSql =
"from Person, \"" + ORG_CACHE + "\".Organization as org " +
"where Person.orgId = org.id " +
"and lower(org.name) = lower(?)";
SqlQuery qry = new SqlQuery<AffinityKey<Long>, Person>(Person.class, joinSql).
setArgs("ApacheIgnite");
// Enable distributed joins for query.
qry.setDistributedJoins(true);
// Execute queries for find employees for different organizations.
print("Following people are 'ApacheIgnite' employees (distributed join): ", cache.query(qry).getAll());
qry.setArgs("Other");
print("Following people are 'Other' employees (distributed join): ", cache.query(qry).getAll());
}
/**
* Example for TEXT queries using LUCENE-based indexing of people's resumes.
*/
private static void textQuery() {
IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
// Query for all people with "Master Degree" in their resumes.
QueryCursor<Cache.Entry<AffinityKey<Long>, Person>> masters =
cache.query(new TextQuery<AffinityKey<Long>, Person>(Person.class, "Master"));
// Query for all people with "Bachelor Degree" in their resumes.
QueryCursor<Cache.Entry<AffinityKey<Long>, Person>> bachelors =
cache.query(new TextQuery<AffinityKey<Long>, Person>(Person.class, "Bachelor"));
print("Following people have 'Master Degree' in their resumes: ", masters.getAll());
print("Following people have 'Bachelor Degree' in their resumes: ", bachelors.getAll());
}
/**
* Example for SQL queries to calculate average salary for a specific organization.
*/
private static void sqlQueryWithAggregation() {
IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE);
// Calculate average of salary of all persons in ApacheIgnite.
// Note that we also join on Organization cache as well.
String sql =
"select avg(salary) " +
"from Person, \"" + ORG_CACHE + "\".Organization as org " +
"where Person.orgId = org.id " +
"and lower(org.name) = lower(?)";
QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(sql).setArgs("ApacheIgnite"));
// Calculate average salary for a specific organization.
print("Average salary for 'ApacheIgnite' employees: ", cursor.getAll());
}
/**
* Example for SQL-based fields queries that return only required
* fields instead of whole key-value pairs.
*/
private static void sqlFieldsQuery() {
IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(PERSON_CACHE);
// Execute query to get names of all employees.
QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(
"select concat(firstName, ' ', lastName) from Person"));
// In this particular case each row will have one element with full name of an employees.
List<List<?>> res = cursor.getAll();
// Print names.
print("Names of all employees:", res);
}
/**
* Example for SQL-based fields queries that return only required
* fields instead of whole key-value pairs.
*/
private static void sqlFieldsQueryWithJoin() {
IgniteCache<AffinityKey<Long>, Person> cache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE);
// Execute query to get names of all employees.
String sql =
"select concat(firstName, ' ', lastName), org.name " +
"from Person, \"" + ORG_CACHE + "\".Organization as org " +
"where Person.orgId = org.id";
QueryCursor<List<?>> cursor = cache.query(new SqlFieldsQuery(sql));
// In this particular case each row will have one element with full name of an employees.
List<List<?>> res = cursor.getAll();
// Print persons' names and organizations' names.
print("Names of all employees and organizations they belong to: ", res);
}
/**
* Populate cache with test data.
*/
private static void initialize() {
IgniteCache<Long, Organization> orgCache = Ignition.ignite().cache(ORG_CACHE);
// Clear cache before running the example.
orgCache.clear();
// Organizations.
Organization org1 = new Organization("ApacheIgnite");
Organization org2 = new Organization("Other");
orgCache.put(org1.id(), org1);
orgCache.put(org2.id(), org2);
IgniteCache<AffinityKey<Long>, Person> colPersonCache = Ignition.ignite().cache(COLLOCATED_PERSON_CACHE);
IgniteCache<Long, Person> personCache = Ignition.ignite().cache(PERSON_CACHE);
// Clear caches before running the example.
colPersonCache.clear();
personCache.clear();
// People.
Person p1 = new Person(org1, "John", "Doe", 2000, "John Doe has Master Degree.");
Person p2 = new Person(org1, "Jane", "Doe", 800, "Jane Doe has Bachelor Degree.");
Person p3 = new Person(org2, "John", "Smith", 900, "John Smith has Bachelor Degree.");
Person p4 = new Person(org2, "Jane", "Smith", 2000, "Jane Smith has Master Degree.");
// Note that in this example we use custom affinity key for Person objects
// to ensure that all persons are collocated with their organizations.
colPersonCache.put(p1.key(), p1);
colPersonCache.put(p2.key(), p2);
colPersonCache.put(p3.key(), p3);
colPersonCache.put(p4.key(), p4);
// These Person objects are not collocated with their organizations.
personCache.put(p1.id, p1);
personCache.put(p2.id, p2);
personCache.put(p3.id, p3);
personCache.put(p4.id, p4);
}
/**
* Prints message and query results.
*
* @param msg Message to print before all objects are printed.
* @param col Query results.
*/
private static void print(String msg, Iterable<?> col) {
print(msg);
print(col);
}
/**
* Prints message.
*
* @param msg Message to print before all objects are printed.
*/
private static void print(String msg) {
System.out.println();
System.out.println(">>> " + msg);
}
/**
* Prints query results.
*
* @param col Query results.
*/
private static void print(Iterable<?> col) {
for (Object next : col)
System.out.println(">>> " + next);
}
}
2016-12-07补充下:今天为技术分享会做准备的时候,对一些参数进行测试,其中就有调整过部署模式,调整为PRIVATE,当时是测试分布式计算,计算字符串中所有单词的长度。当部署模式是SHARED的时候没问题,更改为PRIVATE的时候日志中有一行提示,
Deployment mode for cache is not CONTINUOUS or SHARED (it is recommended that you change deployment mode and restart): PRIVATE
意思是对于缓存来说,部署模式仅仅支持CONTINUOUS和SHARED.我当时的配置文件中的确有缓存相关的配置,虽然我测试中没有使用缓存,它还是依然给我提示了。如下为配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:component-scan base-package="com.github.aloxc.ignite.datagrid.store"/>
<!-- Datasource for sample in-memory H2 database. -->
<bean id="h2-example-db" class="org.h2.jdbcx.JdbcDataSource">
<property name="URL" value="jdbc:h2:tcp://localhost/mem:ExampleDb" />
<property name="user" value="sa" />
</bean>
<bean class="org.springframework.jdbc.datasource.DriverManagerDataSource" id="tybbs_user_datasource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://192.168.20.185:3306/user"></property>
<property name="username" value="testtyDB"></property>
<property name="password" value="wfjmL2vF"></property>
</bean>
<bean id="cacheOnlyStoreFactoryExampleUsingMysql" class="com.github.aloxc.ignite.datagrid.store.CacheOnlyStoreFactoryExampleUsingMysql">
<property name="dataSource" ref="tybbs_user_datasource"></property>
</bean>
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="peerClassLoadingEnabled" value="true"/>
<property name="clientMode" value="false"/>
<property name="deploymentMode" value="PRIVATE"/>
<property name="marshaller">
<bean class="org.apache.ignite.internal.binary.BinaryMarshaller"/>
</property>
<property name="cacheConfiguration" >
<list>
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="cacheMode" value="PARTITIONED"/>
<property name="writeThrough" value="true"/>
<property name="readThrough" value="true" />
<property name="name" value="cacheOnlyUsingMysql"/>
<property name="backups" value="1"/>
<property name="writeBehindEnabled" value="true" />
<property name="writeBehindFlushSize" value="3" />
<property name="writeBehindFlushFrequency" value="0" />
<property name="writeBehindBatchSize" value="10" />
<property name="cacheStoreFactory">
<bean class="javax.cache.configuration.FactoryBuilder.SingletonFactory">
<constructor-arg ref="cacheOnlyStoreFactoryExampleUsingMysql" />
</bean>
</property>
<property name="queryEntities">
<util:list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="keyType" value="java.lang.Long"/>
<property name="valueType" value="com.github.aloxc.ignite.model.Person"/>
<property name="fields">
<map>
<entry key="id" value="java.lang.Long"/>
<entry key="first_name" value="java.lang.String"/>
<entry key="last_name" value="java.lang.String"/>
</map>
</property>
<property name="indexes">
<list>
<bean class="org.apache.ignite.cache.QueryIndex">
<constructor-arg name="field" value="id" />
</bean>
<bean class="org.apache.ignite.cache.QueryIndex">
<constructor-arg name="field" value="first_name" />
</bean>
</list>
</property>
</bean>
</util:list>
</property>
</bean>
</list>
</property>
</bean>
</beans>
作者[@aloxc]