Here are the examples of the java api org.apache.ignite.configuration.IgniteConfiguration taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
61 Examples
19
Source : SpringAppConfig.java
with GNU General Public License v3.0
from srecon
with GNU General Public License v3.0
from srecon
@Bean
public Ignite igniteInstance() {
IgniteConfiguration cfg = new IgniteConfiguration();
// Setting some custom name for the node.
cfg.setIgniteInstanceName("springDataNode");
// Enabling peer-clreplaced loading feature.
cfg.setPeerClreplacedLoadingEnabled(true);
// Defining and creating a new cache to be used by Ignite Spring Data
// repository.
CacheConfiguration ccfgDog = new CacheConfiguration("DogCache");
CacheConfiguration ccfgBreed = new CacheConfiguration("BreedCache");
// Setting SQL schema for the cache.
ccfgBreed.setIndexedTypes(Long.clreplaced, Breed.clreplaced);
ccfgDog.setIndexedTypes(Long.clreplaced, Dog.clreplaced);
cfg.setCacheConfiguration(new CacheConfiguration[] { ccfgDog, ccfgBreed });
return Ignition.start(cfg);
}
19
Source : IgniteCfg.java
with MIT License
from ltlayx
with MIT License
from ltlayx
/**
* 初始化ignite节点信息
* @return Ignite
*/
@Bean
public Ignite igniteInstance() {
// 配置一个节点的Configuration
IgniteConfiguration cfg = new IgniteConfiguration();
// 设置该节点名称
cfg.setIgniteInstanceName("springDataNode");
// 启用Peer类加载器
cfg.setPeerClreplacedLoadingEnabled(true);
// 创建一个Cache的配置,名称为PersonCache
CacheConfiguration ccfg = new CacheConfiguration("PersonCache");
// 设置这个Cache的键值对模型
ccfg.setIndexedTypes(Long.clreplaced, Person.clreplaced);
// 把这个Cache放入springDataNode这个Node中
cfg.setCacheConfiguration(ccfg);
// 启动这个节点
return Ignition.start(cfg);
}
19
Source : MyTinyGridConfigBuilder.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
@Override
public IgniteConfiguration build() {
IgniteConfiguration config = new IgniteConfiguration();
config.setIgniteInstanceName(GRID_NAME);
return config;
}
19
Source : IgniteCustomThreadPoolExample.java
with MIT License
from gauravrmazra
with MIT License
from gauravrmazra
public static void main(String[] args) {
IgniteConfiguration icfg = defaultIgniteCfg("custom-thread-pool-grid");
icfg.setExecutorConfiguration(new ExecutorConfiguration("myCustomThreadPool").setSize(16));
try (Ignite ignite = Ignition.start(icfg)) {
ignite.compute().run(new OuterTask());
}
}
19
Source : IgniteConfig.java
with Apache License 2.0
from cording
with Apache License 2.0
from cording
/**
* Created by cord on 2018/4/11.
* ignite配置类
*/
@Configuration
public clreplaced IgniteConfig {
private static final Logger log = LogManager.getLogger(IgniteConfig.clreplaced);
@Autowired
private IgniteConfiguration igniteCfg;
@Value("${ignite.isDebug:#{false}}")
private Boolean isDebug;
@Bean
@ConditionalOnMissingBean
public Ignite igniteInit() {
/**
* 配置IGNITE_HOME
*/
// igniteCfg.setIgniteHome("D:\\Test");
/**
* 持久化配置
*/
// DataStorageConfiguration dcfg = igniteCfg.getDataStorageConfiguration();
// dcfg.getDefaultDataRegionConfiguration()
// .setMaxSize(4L * 1024 * 1024 * 1024) //设置默认区域的最大可用内存
// .setPersistenceEnabled(true);//默认区域开启持久化
// /**设置持久化路径*/
// dcfg.setStoragePath();
// dcfg.setWalPath();
// dcfg.setWalArchivePath();
Ignite ignite = Ignition.start(igniteCfg);
log.info("-----------ignite service is started.----------");
return ignite;
}
/**
* 通过代码初始化datasource
*/
// @Bean(name = "igniteDS")
public DataSource dataSource() throws IOException {
PoolConfiguration pc = new PoolProperties();
pc.setDriverClreplacedName("org.apache.ignite.IgniteJdbcThinDriver");
pc.setUrl("jdbc:ignite:thin://127.0.0.1");
pc.setInitialSize(10);
pc.setMinIdle(10);
pc.setMaxActive(100);
pc.setMaxIdle(20);
pc.setRemoveAbandonedTimeout(60);
pc.setRemoveAbandoned(true);
// 检测链接可用性,防止节点重启的情况
pc.setValidationQuery("SELECT 1 FROM dual");
pc.setValidationInterval(3000);
// 获取链接的时候检测链接可用性,并不是每次都检验,取决于validationInterval
pc.setTestOnBorrow(true);
// 建立链接的时候检测链接可用性
pc.setTestOnConnect(true);
DataSource dataSource = new DataSource(pc);
dataSource.setUsername("ignite");
dataSource.setPreplacedword("ignite");
// schema init
Resource[] initSchema = new PathMatchingResourcePatternResolver().getResources("clreplacedpath:db/schema.sql");
// Resource initData = new ClreplacedPathResource("db/data.sql");
DatabasePopulator databasePopulator = new ResourceDatabasePopulator(initSchema);
DatabasePopulatorUtils.execute(databasePopulator, dataSource);
return dataSource;
}
@Bean
public Gson gson() {
return new GsonBuilder().serializeNulls().registerTypeAdapter(Map.clreplaced, new MapDeserializer()).setDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS").create();
}
}
19
Source : NormalController.java
with Apache License 2.0
from cording
with Apache License 2.0
from cording
/**
* Created by cord on 2018/4/11.
* http://localhost:8080/sqlFieldsQuery
* http://localhost:8080/sqlQuery
* http://localhost:8080/getByKey
* http://localhost:8080/ddlstream
*/
@RestController
public clreplaced NormalController {
@Autowired
private Ignite ignite;
@Autowired
private IgniteConfiguration igniteCfg;
private Student student;
@RequestMapping("/getByKey")
@ResponseBody
public String getByKey(HttpServletRequest request, HttpServletResponse response) {
IgniteCache<Long, Student> cache = ignite.cache(CacheKeyConstant.STUDENT);
Student student = cache.get(1L);
System.out.format("The result is %s.\n", student.toString());
return "all executed!";
}
/**
* BinaryObject 流导数
* CREATE TABLE IF NOT EXISTS PUBLIC.TEST (
* STUDID INTEGER,
* grade DOUBLE,
* info varchar,
* PRIMARY KEY (STUDID, grade))
* WITH "template=replicated,atomicity=ATOMIC,cache_name=test,key_type=java.lang.String";
*/
@RequestMapping("/ddlstream")
@ResponseBody
public String ddlByStream(HttpServletRequest request, HttpServletResponse response) {
IgniteCache<Object, BinaryObject> cache = ignite.cache("test").withKeepBinary();
BinaryObject student = cache.get("1");
IgniteDataStreamer<Object, BinaryObject> dataLdr = ignite.dataStreamer("test");
List<QueryEnreplacedy> list = (ArrayList) cache.getConfiguration(CacheConfiguration.clreplaced).getQueryEnreplacedies();
String valueType = list.get(0).findValueType();
BinaryObjectBuilder obj = ignite.binary().builder(valueType);
obj.setField("studid", 22);
obj.setField("grade", 22);
obj.setField("info", "ss");
dataLdr.addData("351", obj.build());
dataLdr.close(false);
return "all executed!";
}
@RequestMapping("/sqlFieldsQuery")
@ResponseBody
public String sqlFieldsQuery(HttpServletRequest request, HttpServletResponse response) {
IgniteCache<Long, Student> cache = ignite.cache(CacheKeyConstant.STUDENT);
SqlFieldsQuery sfq = new SqlFieldsQuery("select name from \"student\".student");
sfq.setReplicatedOnly(true);
// 懒加载,应对海量数据
sfq.setLazy(true);
List<List<?>> res = cache.query(sfq).getAll();
System.out.format("The name is %s.\n", res.get(0).get(0));
return "all executed!";
}
@RequestMapping("/sqlQuery")
@ResponseBody
public String sqlQuery(HttpServletRequest request, HttpServletResponse response) {
IgniteCache<Long, Student> tempCache = ignite.cache(CacheKeyConstant.STUDENT);
/**
* 普通查询
*/
String sql_query = "name = ? and email = ?";
SqlQuery<Long, Student> cSqlQuery = new SqlQuery<>(Student.clreplaced, sql_query);
cSqlQuery.setReplicatedOnly(true).setArgs("student_44", "student_44gmail.com");
List<Cache.Entry<Long, Student>> tempResult = tempCache.query(cSqlQuery).getAll();
if (CollectionUtils.isEmpty(tempResult)) {
return "result is Empty!";
}
Student student = tempResult.stream().map(t -> t.getValue()).findFirst().get();
System.out.format("the beginning of student[student_44] is %s\n", student.getDob());
/**
* 域查询
*/
SqlFieldsQuery sfq = new SqlFieldsQuery("select studId, name, email from student");
// sfq.setLazy(true); //开启懒加载防止结果集过大的情况导致堆溢出
sfq.setReplicatedOnly(true);
FieldsQueryCursor<List<?>> qc = tempCache.query(sfq);
List<List<?>> result = qc.getAll();
// 关闭资源防止内存泄漏
qc.close();
// 将每一行的记录转换为map对象, key为对应的列名,value为对应的值
List<Map<?, ?>> maps = result.stream().map(x -> IntStream.range(0, x.size()).boxed().collect(Collectors.toMap(i -> qc.getFieldName(i), i -> x.get(i)))).collect(Collectors.toList());
/**
* 聚合函数查询
*/
/**
* [count]
*/
String sql_count = "select count(1) from student";
SqlFieldsQuery countQuery = new SqlFieldsQuery(sql_count);
countQuery.setReplicatedOnly(true);
List<List<?>> countList = tempCache.query(countQuery).getAll();
long count = 0;
if (!CollectionUtils.isEmpty(countList)) {
count = (Long) countList.get(0).get(0);
}
System.out.format("count of cache[student] is %s\n", count);
/**
* [sum]
*/
String sql_sum = "select sum(studId) from student";
SqlFieldsQuery sumQuery = new SqlFieldsQuery(sql_sum);
sumQuery.setReplicatedOnly(true);
List<List<?>> sumList = tempCache.query(sumQuery).getAll();
long sum = 0;
if (!CollectionUtils.isEmpty(sumList)) {
sum = (Long) sumList.get(0).get(0);
}
System.out.format("sum of cache[student.id] is %s\n", sum);
return "all executed!";
}
/**
* 获取协调者节点
* http://localhost:8080/coordinator
*/
@GetMapping("/coordinator")
public String getCoordinator() {
TcpDiscoverySpi tds = (TcpDiscoverySpi) igniteCfg.getDiscoverySpi();
UUID uuid = tds.getCoordinator();
ClusterNode node = ignite.cluster().nodes().stream().filter(n -> n.id().equals(uuid)).findFirst().get();
// String ip = node.addresses().stream().filter(a -> !"127.0.0.1".equals(a) && !"0:0:0:0:0:0:0:1".equals(a)).findFirst().get();
return String.format("nodeId [%s], address [%s]", uuid.toString(), node.addresses().toString());
}
/**
* 判断节点是否达到再平衡状态
*/
@GetMapping("/rebalanceFinished")
public boolean isRebalanceFinished() {
AffinityTopologyVersion topVer0 = new AffinityTopologyVersion(0);
return ((IgniteKernal) ignite).context().cache().context().cacheContext(GridCacheUtils.cacheId("student")).topology().rebalanceFinished(topVer0);
}
// @RequestMapping("/sqlQuery")
// public @ResponseBody
// String sqlQuery(HttpServletRequest request, HttpServletResponse response) {
// IgniteCache<Long, Student> cache = ignite.cache(CacheKeyConstant.STUDENT);
//
// /**普通查询*/
// String querySql = "salary = ?";
// SqlQuery<Long, Person> sqlQuery = new SqlQuery<>(Person.clreplaced, querySql);
// sqlQuery.setReplicatedOnly(true).setArgs(2);
//
// List<Cache.Entry<Long, Person>> result = cache.query(sqlQuery).getAll();
//
// if(CollectionUtils.isEmpty(result)){
// return "result is Empty!";
// }
//
// List<Person> ret = result.stream().map(t -> t.getValue()).collect(Collectors.toList());
//
// System.out.println(ret);
//
// return "all executed.";
// }
//
}
19
Source : ComputeTestController.java
with Apache License 2.0
from cording
with Apache License 2.0
from cording
/**
* @author: cord
* @date: 2018/8/22 22:50
* http://localhost:8080/broadcast
* http://localhost:8080/call
* http://localhost:8080/apply
* http://localhost:8080/affinity
* http://localhost:8080/affinity2
* http://localhost:8080/taskMap
* http://localhost:8080/taskSplit
*/
@RestController
public clreplaced ComputeTestController {
@Autowired
private Ignite ignite;
@Autowired
private IgniteConfiguration igniteCfg;
/**
* broadCast测试
*/
@RequestMapping("/broadcast")
String broadcastTest(HttpServletRequest request, HttpServletResponse response) {
// IgniteCompute compute = ignite.compute(ignite.cluster().forRemotes()); //只传播远程节点
IgniteCompute compute = ignite.compute();
compute.broadcast(() -> System.out.println("Hello Node: " + ignite.cluster().localNode().id()));
return "all executed.";
}
/**
* call和run测试
*/
@RequestMapping("/call")
@ResponseBody
public String callTest(HttpServletRequest request, HttpServletResponse response) {
Collection<IgniteCallable<Integer>> calls = new ArrayList<>();
/**
* call
*/
System.out.println("-----------call-----------");
for (String word : "How many characters".split(" ")) {
calls.add(word::length);
// calls.add(() -> word.length());
}
Collection<Integer> res = ignite.compute().call(calls);
int total = res.stream().mapToInt(Integer::intValue).sum();
System.out.println(String.format("the total lengths of all words is [%s].", total));
/**
* run
*/
System.out.println("-----------run-----------");
for (String word : "Print words on different cluster nodes".split(" ")) {
ignite.compute().run(() -> System.out.println(word));
}
/**
* async call
*/
System.out.println("-----------async call-----------");
IgniteCompute asyncCompute = ignite.compute().withAsync();
asyncCompute.call(calls);
asyncCompute.future().listen(fut -> {
Collection<Integer> result = (Collection<Integer>) fut.get();
int t = result.stream().mapToInt(Integer::intValue).sum();
System.out.println("Total number of characters: " + total);
});
/**
* async run
*/
System.out.println("-----------async run-----------");
Collection<ComputeTaskFuture<?>> futs = new ArrayList<>();
asyncCompute = ignite.compute().withAsync();
for (String word : "Print words on different cluster nodes".split(" ")) {
asyncCompute.run(() -> System.out.println(word));
futs.add(asyncCompute.future());
}
futs.stream().forEach(ComputeTaskFuture::get);
return "all executed.";
}
/**
* apply测试
*/
@RequestMapping("/apply")
@ResponseBody
public String applyTest(HttpServletRequest request, HttpServletResponse response) {
/**
* apply
*/
System.out.println("-----------apply-----------");
IgniteCompute compute = ignite.compute();
Collection<Integer> res = compute.apply(String::length, Arrays.asList("How many characters".split(" ")));
int total = res.stream().mapToInt(Integer::intValue).sum();
System.out.println(String.format("the total lengths of all words is [%s].", total));
/**
* async apply
*/
IgniteCompute asyncCompute = ignite.compute().withAsync();
res = asyncCompute.apply(String::length, Arrays.asList("How many characters".split(" ")));
asyncCompute.future().listen(fut -> {
int t = ((Collection<Integer>) fut.get()).stream().mapToInt(Integer::intValue).sum();
System.out.println(String.format("Total number of characters: " + total));
});
return "all executed.";
}
/**
* 并置计算测试
*/
@RequestMapping("/affinity")
@ResponseBody
public String affinityTest(HttpServletRequest request, HttpServletResponse response) {
/**
* affinityRun call
*/
System.out.println("-----------affinityRun call-----------");
IgniteCompute compute = ignite.compute();
// IgniteCompute compute = ignite.compute(ignite.cluster().forRemotes());
for (int key = 0; key < 100; key++) {
// final long k = key;
// 生成随机k值
final long k = IntStream.generate(() -> (int) (System.nanoTime() % 100)).limit(1).findFirst().getAsInt();
compute.affinityRun(CacheKeyConstant.STUDENT, k, () -> {
IgniteCache<Long, BinaryObject> cache = ignite.cache(CacheKeyConstant.STUDENT).withKeepBinary();
BinaryObject obj = cache.get(k);
if (obj != null) {
System.out.println(String.format("Co-located[key= %s, value= %s]", k, obj.<String>field("name")));
}
});
}
IgniteCache<Long, BinaryObject> cache = ignite.cache(CacheKeyConstant.STUDENT).withKeepBinary();
cache.forEach(lo -> compute.affinityRun(CacheKeyConstant.STUDENT, lo.getKey(), () -> {
System.out.println(lo.getValue().<String>field("name"));
}));
return "all executed.";
}
/**
* 分区模式测试并置计算
*/
@RequestMapping("/affinity2")
@ResponseBody
public String affinityTest2(HttpServletRequest request, HttpServletResponse response) {
System.out.println("-----------affinityRun run-----------");
IgniteCompute compute = ignite.compute();
for (int key = 1; key <= 50; key++) {
long k = key;
compute.affinityRun(CacheKeyConstant.STUDENT, k, () -> {
IgniteCache<Long, Student> cache = ignite.cache(CacheKeyConstant.STUDENT);
List<List<?>> res = cache.query(new SqlFieldsQuery("select _VAL,name from \"student\".student")).getAll();
System.out.format("The name is %s.\n", res.get(0).get(0));
});
}
for (int key = 1; key <= 50; key++) {
long k = key;
compute.affinityRun("Test", k, () -> {
IgniteCache<Long, Student> cache = ignite.cache(CacheKeyConstant.STUDENT);
Student stu = cache.get(k);
if (stu != null) {
System.out.println(String.format("Co-located[key= %s, value= %s]", k, stu.getName()));
}
});
}
return "all executed.";
}
/**
* ComputeTaskAdapter
*/
@RequestMapping("/taskMap")
@ResponseBody
public String taskMapTest(HttpServletRequest request, HttpServletResponse response) {
/**
* ComputeTaskMap
*/
int cnt = ignite.compute().execute(MapExampleCharacterCountTask.clreplaced, "Hello Ignite Enable World!");
System.out.println(String.format(">>> Total number of characters in the phrase is %s.", cnt));
return "all executed.";
}
private static clreplaced MapExampleCharacterCountTask extends ComputeTaskAdapter<String, Integer> {
/**
* 节点映射
*/
@Override
public Map<? extends ComputeJob, ClusterNode> map(List<ClusterNode> nodes, String arg) throws IgniteException {
Map<ComputeJob, ClusterNode> map = new HashMap<>();
Iterator<ClusterNode> it = nodes.iterator();
for (final String word : arg.split(" ")) {
// If we used all nodes, restart the iterator.
if (!it.hasNext()) {
it = nodes.iterator();
}
ClusterNode node = it.next();
map.put(new ComputeJobAdapter() {
@Override
public Object execute() throws IgniteException {
System.out.println("-------------------------------------");
System.out.println(String.format(">>> Printing [%s] on this node from ignite job.", word));
return word.length();
}
}, node);
}
return map;
}
/**
* 结果汇总
*/
@Override
public Integer reduce(List<ComputeJobResult> results) throws IgniteException {
int sum = 0;
for (ComputeJobResult res : results) {
sum += res.<Integer>getData();
}
return sum;
}
}
/**
* ComputeTaskSplitAdapter
*/
@RequestMapping("/taskSplit")
@ResponseBody
public String taskSplitTest(HttpServletRequest request, HttpServletResponse response) {
/**
* ComputeTaskSplitAdapter(自动映射)
*/
int result = ignite.compute().execute(SplitExampleDistributedCompute.clreplaced, null);
System.out.println(String.format(">>> result: [%s]", result));
return "all executed.";
}
private static clreplaced SplitExampleDistributedCompute extends ComputeTaskSplitAdapter<String, Integer> {
@Override
protected Collection<? extends ComputeJob> split(int gridSize, String arg) throws IgniteException {
Collection<ComputeJob> jobs = new LinkedList<>();
jobs.add(new ComputeJobAdapter() {
@Override
public Object execute() throws IgniteException {
// IgniteCache<Long, Student> cache = Ignition.ignite().cache(CacheKeyConstant.STUDENT);
IgniteCache<Long, BinaryObject> cache = Ignition.ignite().cache(CacheKeyConstant.STUDENT).withKeepBinary();
/**
* 普通查询
*/
String sql_query = "name = ? and email = ?";
// SqlQuery<Long, Student> cSqlQuery = new SqlQuery<>(Student.clreplaced, sql_query);
SqlQuery<Long, BinaryObject> cSqlQuery = new SqlQuery<>(Student.clreplaced, sql_query);
cSqlQuery.setReplicatedOnly(true).setArgs("student_54", "student_54gmail.com");
// List<Cache.Entry<Long, Student>> result = cache.query(cSqlQuery).getAll();
List<Cache.Entry<Long, BinaryObject>> result = cache.query(cSqlQuery).getAll();
System.out.println("--------------------");
result.stream().map(x -> {
Integer studId = x.getValue().field("studId");
String name = x.getValue().field("name");
return String.format("name=[%s], studId=[%s].", name, studId);
}).forEach(System.out::println);
System.out.println(String.format("the query size is [%s].", result.size()));
return result.size();
}
});
return jobs;
}
@Override
public Integer reduce(List<ComputeJobResult> results) throws IgniteException {
int sum = results.stream().mapToInt(x -> x.<Integer>getData()).sum();
return sum;
}
}
}
19
Source : GridSpringTransactionManagerSelfTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration cache = new CacheConfiguration(DEFAULT_CACHE_NAME);
cache.setName(CACHE_NAME);
cache.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cfg.setCacheConfiguration(cache);
return cfg;
}
19
Source : SpringTransactionManager.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Implementation of Spring transaction abstraction based on Ignite transaction.
* <h1 clreplaced="header">Overview</h1>
* Spring transaction abstraction allows to enable declarative transaction management
* and concentrate on business logic rather than transaction life-cycle.
* For more information, refer to
* <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/transaction.html">
* Spring Transaction Abstraction doreplacedentation</a>.
* <h1 clreplaced="header">How To Enable Transaction support</h1>
* To enable declarative transaction management on Ignite cache in your Spring application,
* you will need to do the following:
* <ul>
* <li>
* Start an Ignite node with proper configuration in embedded mode
* (i.e., in the same JVM where the application is running). It can
* already have predefined caches, but it's not required - caches
* will be created automatically on first access if needed.
* </li>
* <li>
* Configure {@code SpringTransactionManager} as a transaction manager
* in the Spring application context.
* </li>
* </ul>
* {@code SpringTransactionManager} can start a node itself on its startup
* based on provided Ignite configuration. You can provide path to a
* Spring configuration XML file, like below (path can be absolute or
* relative to {@code IGNITE_HOME}):
* <pre name="code" clreplaced="xml">
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:tx="http://www.springframework.org/schema/tx"
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
* <-- Provide configuration file path. -->
* <bean id="transactionManager" clreplaced="org.apache.ignite.transactions.spring.SpringTransactionManager">
* <property name="configurationPath" value="examples/config/spring-transaction.xml"/>
* </bean>
*
* <-- Use annotation-driven transaction configuration. -->
* <tx:annotation-driven/>
* </beans>
* </pre>
* Or you can provide a {@link IgniteConfiguration} bean, like below:
* <pre name="code" clreplaced="xml">
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:tx="http://www.springframework.org/schema/tx"
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
* <-- Provide configuration bean. -->
* <bean id="transactionManager" clreplaced="org.apache.ignite.transactions.spring.SpringTransactionManager">
* <property name="configuration">
* <bean id="gridCfg" clreplaced="org.apache.ignite.configuration.IgniteConfiguration">
* ...
* </bean>
* </property>
* </bean>
*
* <-- Use annotation-driven transaction configuration. -->
* <tx:annotation-driven/>
* </beans>
* </pre>
* Note that providing both configuration path and configuration bean is illegal
* and results in {@link IllegalArgumentException}.
*
* If you already have Ignite node running within your application,
* simply provide correct Ignite instance name, like below (if there is no Grid
* instance with such name, exception will be thrown):
* <pre name="code" clreplaced="xml">
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:tx="http://www.springframework.org/schema/tx"
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
* <-- Provide Ignite instance name. -->
* <bean id="transactionManager" clreplaced="org.apache.ignite.transactions.spring.SpringTransactionManager">
* <property name="igniteInstanceName" value="myGrid"/>
* </bean>
*
* <-- Use annotation-driven transaction configuration. -->
* <tx:annotation-driven/>
* </beans>
* </pre>
* This can be used, for example, when you are running your application
* in a J2EE Web container and use {@ignitelink org.apache.ignite.startup.servlet.ServletContextListenerStartup}
* for node startup.
*
* If neither {@link #setConfigurationPath(String) configurationPath},
* {@link #setConfiguration(IgniteConfiguration) configuration}, nor
* {@link #setIgniteInstanceName(String) igniteInstanceName} are provided, transaction manager
* will try to use default Grid instance (the one with the {@code null}
* name). If it doesn't exist, exception will be thrown.
*
* {@code SpringTransactionManager} can be configured to support Ignite transaction concurrency.
* For this you need to provide {@code SpringTransactionManager} with transactionConcurrency property.
* If this property is not set then default transaction concurrency will be used
* <pre name="code" clreplaced="xml">
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:tx="http://www.springframework.org/schema/tx"
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
* <-- Provide Ignite instance name. -->
* <bean id="transactionManager" clreplaced="org.apache.ignite.transactions.spring.SpringTransactionManager">
* <property name="igniteInstanceName" value="myGrid"/>
* <property name="transactionConcurrency" value="OPTIMISTIC"/>
* </bean>
*
* <-- Use annotation-driven transaction configuration. -->
* <tx:annotation-driven/>
* </beans>
* </pre>
*
* In case you need to support both "OPTIMISTIC" and "PESSIMISTIC" transaction concurrency in you application,
* you need to create two transaction managers with different transaction concurrency
* <pre name="code" clreplaced="xml">
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:tx="http://www.springframework.org/schema/tx"
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
* <bean id="optimisticTransactionManager" clreplaced="org.apache.ignite.transactions.spring.SpringTransactionManager">
* <property name="igniteInstanceName" value="myGrid"/>
* <property name="transactionConcurrency" value="OPTIMISTIC"/>
* </bean>
*
* <bean id="pessimisticTransactionManager" clreplaced="org.apache.ignite.transactions.spring.SpringTransactionManager">
* <property name="igniteInstanceName" value="myGrid"/>
* <property name="transactionConcurrency" value="PESSIMISTIC"/>
* </bean>
*
* <-- Use annotation-driven transaction configuration. -->
* <tx:annotation-driven/>
* </beans>
* </pre>
* Then use them with qualifiers in your application:
* <pre name="code" clreplaced="xml">
* public clreplaced TransactionalService {
* {@literal @}Transactional("optimisticTransactionManager")
* public void doOptimistically() {
* ...
* }
*
* {@literal @}Transactional("pessimisticTransactionManager")
* public void doPessimistically() {
* ...
* }
* }
* </pre>
*/
public clreplaced SpringTransactionManager extends AbstractSpringTransactionManager implements ApplicationContextAware, DisposableBean {
/**
* Grid configuration file path.
*/
private String cfgPath;
/**
* Ignite configuration.
*/
private IgniteConfiguration cfg;
/**
* Ignite instance name.
*/
private String igniteInstanceName;
/**
* Ignite instance.
*/
private Ignite ignite;
/**
* Flag indicating that Ignite instance was not created inside current transaction manager.
*/
private boolean externalIgniteInstance;
/**
* Ignite transactions configuration.
*/
private TransactionConfiguration txCfg;
/**
* Spring context
*/
private ApplicationContext springCtx;
/**
* Gets configuration file path.
*
* @return Grid configuration file path.
*/
public String getConfigurationPath() {
return cfgPath;
}
/**
* Sets configuration file path.
*
* @param cfgPath Grid configuration file path.
*/
public void setConfigurationPath(String cfgPath) {
this.cfgPath = cfgPath;
}
/**
* Gets configuration bean.
*
* @return Grid configuration bean.
*/
public IgniteConfiguration getConfiguration() {
return cfg;
}
/**
* Sets configuration bean.
*
* @param cfg Grid configuration bean.
*/
public void setConfiguration(IgniteConfiguration cfg) {
this.cfg = cfg;
}
/**
* Gets grid name.
*
* @return Grid name.
* @deprecated Use {@link #getIgniteInstanceName()}.
*/
@Deprecated
public String getGridName() {
return getIgniteInstanceName();
}
/**
* Sets grid name.
*
* @param gridName Grid name.
* @deprecated Use {@link #setIgniteInstanceName(String)}.
*/
@Deprecated
public void setGridName(String gridName) {
setIgniteInstanceName(gridName);
}
/**
* Gets Ignite instance name.
*
* @return Ignite instance name.
*/
public String getIgniteInstanceName() {
return igniteInstanceName;
}
/**
* Sets Ignite instance name.
*
* @param igniteInstanceName Ignite instance name.
*/
public void setIgniteInstanceName(String igniteInstanceName) {
this.igniteInstanceName = igniteInstanceName;
}
/**
* {@inheritDoc}
*/
@Override
public void onApplicationEvent(ContextRefreshedEvent evt) {
if (ignite == null) {
if (cfgPath != null && cfg != null) {
throw new IllegalArgumentException("Both 'configurationPath' and 'configuration' are " + "provided. Set only one of these properties if you need to start a Ignite node inside of " + "SpringTransactionManager. If you already have a node running, omit both of them and set" + "'igniteInstanceName' property.");
}
try {
if (cfgPath != null)
ignite = IgniteSpring.start(cfgPath, springCtx);
else if (cfg != null)
ignite = IgniteSpring.start(cfg, springCtx);
else {
ignite = Ignition.ignite(igniteInstanceName);
externalIgniteInstance = true;
}
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
txCfg = ignite.configuration().getTransactionConfiguration();
}
super.onApplicationEvent(evt);
}
/**
* {@inheritDoc}
*/
@Override
public void setApplicationContext(ApplicationContext ctx) throws BeansException {
this.springCtx = ctx;
}
/**
* {@inheritDoc}
*/
@Override
protected TransactionIsolation defaultTransactionIsolation() {
return txCfg.getDefaultTxIsolation();
}
/**
* {@inheritDoc}
*/
@Override
protected long defaultTransactionTimeout() {
return txCfg.getDefaultTxTimeout();
}
/**
* {@inheritDoc}
*/
@Override
protected IgniteLogger log() {
return ignite.log();
}
/**
* {@inheritDoc}
*/
@Override
protected TransactionConcurrency defaultTransactionConcurrency() {
return txCfg.getDefaultTxConcurrency();
}
/**
* {@inheritDoc}
*/
@Override
protected TransactionProxyFactory createTransactionFactory() {
return new IgniteTransactionProxyFactory(ignite.transactions());
}
/**
* {@inheritDoc}
*/
@Override
public void destroy() {
if (!externalIgniteInstance)
ignite.close();
}
}
19
Source : SpringTransactionManager.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Sets configuration bean.
*
* @param cfg Grid configuration bean.
*/
public void setConfiguration(IgniteConfiguration cfg) {
this.cfg = cfg;
}
19
Source : IgniteClientApplicationConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* @return {@link Ignite} node instance.
*/
@Bean
public IgniteEx igniteServerNode() {
IgniteConfiguration cfg = new IgniteConfiguration().setClientConnectorConfiguration(new ClientConnectorConfiguration().setPort(CLI_CONN_PORT)).setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(new TcpDiscoveryVmIpFinder(true))).setCacheConfiguration(new CacheConfiguration<Integer, Person>("PersonCache").setIndexedTypes(Integer.clreplaced, Person.clreplaced));
return (IgniteEx) Ignition.start(cfg);
}
19
Source : ApplicationConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* @return Ignite instance.
*/
@Bean
public Ignite igniteInstance() {
IgniteConfiguration cfg = new IgniteConfiguration().setCacheConfiguration(new CacheConfiguration<Integer, Person>("PersonCache").setIndexedTypes(Integer.clreplaced, Person.clreplaced), new CacheConfiguration<PersonKey, Person>("PersonWithKeyCache")).setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(new TcpDiscoveryVmIpFinder(true)));
return Ignition.start(cfg);
}
19
Source : ApplicationConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Ignite instance bean - no instance name provided on RepositoryConfig
*/
@Bean
public Ignite igniteInstance() {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName(IGNITE_INSTANCE_ONE);
CacheConfiguration ccfg = new CacheConfiguration("PersonCache");
ccfg.setIndexedTypes(Integer.clreplaced, Person.clreplaced);
cfg.setCacheConfiguration(ccfg);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
cfg.setDiscoverySpi(spi);
return Ignition.start(cfg);
}
19
Source : ApplicationConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Ignite instance bean with not default name
*/
@Bean
public Ignite igniteInstanceTWO() {
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName(IGNITE_INSTANCE_TWO);
CacheConfiguration ccfg = new CacheConfiguration("PersonCache");
ccfg.setIndexedTypes(Integer.clreplaced, Person.clreplaced);
cfg.setCacheConfiguration(ccfg);
TcpDiscoverySpi spi = new TcpDiscoverySpi();
spi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
cfg.setDiscoverySpi(spi);
return Ignition.start(cfg);
}
19
Source : IgniteClientSpringCacheManagerTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setCacheConfiguration(new CacheConfiguration<>(CACHE_NAME));
cfg.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true));
return cfg;
}
19
Source : GridSpringCacheManagerSelfTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheConfiguration cache = new CacheConfiguration(DEFAULT_CACHE_NAME);
cache.setName(CACHE_NAME);
cfg.setCacheConfiguration(cache);
return cfg;
}
19
Source : SpringCacheManager.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Implementation of Spring cache abstraction based on Ignite cache.
* <h1 clreplaced="header">Overview</h1>
* Spring cache abstraction allows to enable caching for Java methods
* so that the result of a method execution is stored in some storage. If
* later the same method is called with the same set of parameters,
* the result will be retrieved from that storage instead of actually
* executing the method. For more information, refer to
* <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/cache.html">
* Spring Cache Abstraction doreplacedentation</a>.
* <h1 clreplaced="header">How To Enable Caching</h1>
* To enable caching based on Ignite cache in your Spring application,
* you will need to do the following:
* <ul>
* <li>
* Start an Ignite node with proper configuration in embedded mode
* (i.e., in the same JVM where the application is running). It can
* already have predefined caches, but it's not required - caches
* will be created automatically on first access if needed.
* </li>
* <li>
* Configure {@code SpringCacheManager} as a cache provider
* in the Spring application context.
* </li>
* </ul>
* {@code SpringCacheManager} can start a node itself on its startup
* based on provided Ignite configuration. You can provide path to a
* Spring configuration XML file, like below (path can be absolute or
* relative to {@code IGNITE_HOME}):
* <pre name="code" clreplaced="xml">
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:cache="http://www.springframework.org/schema/cache"
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
* <-- Provide configuration file path. -->
* <bean id="cacheManager" clreplaced="org.apache.ignite.cache.spring.SpringCacheManager">
* <property name="configurationPath" value="examples/config/spring-cache.xml"/>
* </bean>
*
* <-- Use annotation-driven caching configuration. -->
* <cache:annotation-driven/>
* </beans>
* </pre>
* Or you can provide a {@link IgniteConfiguration} bean, like below:
* <pre name="code" clreplaced="xml">
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:cache="http://www.springframework.org/schema/cache"
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
* <-- Provide configuration bean. -->
* <bean id="cacheManager" clreplaced="org.apache.ignite.cache.spring.SpringCacheManager">
* <property name="configuration">
* <bean id="gridCfg" clreplaced="org.apache.ignite.configuration.IgniteConfiguration">
* ...
* </bean>
* </property>
* </bean>
*
* <-- Use annotation-driven caching configuration. -->
* <cache:annotation-driven/>
* </beans>
* </pre>
* Note that providing both configuration path and configuration bean is illegal
* and results in {@link IllegalArgumentException}.
* <p>
* If you already have Ignite node running within your application,
* simply provide correct Ignite instance name, like below (if there is no Grid
* instance with such name, exception will be thrown):
* <pre name="code" clreplaced="xml">
* <beans xmlns="http://www.springframework.org/schema/beans"
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
* xmlns:cache="http://www.springframework.org/schema/cache"
* xsi:schemaLocation="
* http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
* http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
* <-- Provide Ignite instance name. -->
* <bean id="cacheManager" clreplaced="org.apache.ignite.cache.spring.SpringCacheManager">
* <property name="igniteInstanceName" value="myGrid"/>
* </bean>
*
* <-- Use annotation-driven caching configuration. -->
* <cache:annotation-driven/>
* </beans>
* </pre>
* This can be used, for example, when you are running your application
* in a J2EE Web container and use {@ignitelink org.apache.ignite.startup.servlet.ServletContextListenerStartup}
* for node startup.
* <p>
* If neither {@link #setConfigurationPath(String) configurationPath},
* {@link #setConfiguration(IgniteConfiguration) configuration}, nor
* {@link #setIgniteInstanceName(String) igniteInstanceName} are provided, cache manager
* will try to use default Grid instance (the one with the {@code null}
* name). If it doesn't exist, exception will be thrown.
* <h1>Starting Remote Nodes</h1>
* Keep in mind that the node started inside your application is an entry point
* to the whole topology it connects to. You can start as many remote standalone
* nodes as you need using {@code bin/ignite.{sh|bat}} scripts provided in
* Ignite distribution, and all these nodes will participate
* in caching the data.
*/
public clreplaced SpringCacheManager extends AbstractCacheManager implements ApplicationListener<ContextRefreshedEvent>, ApplicationContextAware, DisposableBean {
/**
* Default locks count.
*/
private static final int DEFAULT_LOCKS_COUNT = 512;
/**
* IgniteLock name prefix.
*/
private static final String SPRING_LOCK_NAME_PREFIX = "springSync";
/**
* Grid configuration file path.
*/
private String cfgPath;
/**
* Ignite configuration.
*/
private IgniteConfiguration cfg;
/**
* Ignite instance name.
*/
private String igniteInstanceName;
/**
* Count of IgniteLocks are used for sync get
*/
private int locksCnt = DEFAULT_LOCKS_COUNT;
/**
* Dynamic cache configuration template.
*/
private CacheConfiguration<Object, Object> dynamicCacheCfg;
/**
* Dynamic near cache configuration template.
*/
private NearCacheConfiguration<Object, Object> dynamicNearCacheCfg;
/**
* Ignite instance.
*/
private Ignite ignite;
/**
* Spring context.
*/
private ApplicationContext springCtx;
/**
* Locks for value loading to support sync option.
*/
private ConcurrentHashMap<Integer, IgniteLock> locks = new ConcurrentHashMap<>();
/**
* Flag that indicates whether external Ignite instance is configured.
*/
private boolean externalIgniteInstance;
/**
* {@inheritDoc}
*/
@Override
public void setApplicationContext(ApplicationContext ctx) {
this.springCtx = ctx;
}
/**
* Gets configuration file path.
*
* @return Grid configuration file path.
*/
public String getConfigurationPath() {
return cfgPath;
}
/**
* Sets configuration file path.
*
* @param cfgPath Grid configuration file path.
*/
public void setConfigurationPath(String cfgPath) {
this.cfgPath = cfgPath;
}
/**
* Gets configuration bean.
*
* @return Grid configuration bean.
*/
public IgniteConfiguration getConfiguration() {
return cfg;
}
/**
* Sets configuration bean.
*
* @param cfg Grid configuration bean.
*/
public void setConfiguration(IgniteConfiguration cfg) {
this.cfg = cfg;
}
/**
* Gets grid name.
*
* @return Grid name.
* @deprecated Use {@link #getIgniteInstanceName()}.
*/
@Deprecated
public String getGridName() {
return getIgniteInstanceName();
}
/**
* Sets grid name.
*
* @param gridName Grid name.
* @deprecated Use {@link #setIgniteInstanceName(String)}.
*/
@Deprecated
public void setGridName(String gridName) {
setIgniteInstanceName(gridName);
}
/**
* Gets Ignite instance name.
*
* @return Ignite instance name.
*/
public String getIgniteInstanceName() {
return igniteInstanceName;
}
/**
* Sets Ignite instance name.
*
* @param igniteInstanceName Ignite instance name.
*/
public void setIgniteInstanceName(String igniteInstanceName) {
this.igniteInstanceName = igniteInstanceName;
}
/**
* Gets locks count.
*
* @return locks count.
*/
public int getLocksCount() {
return locksCnt;
}
/**
* @param locksCnt locks count.
*/
public void setLocksCount(int locksCnt) {
this.locksCnt = locksCnt;
}
/**
* Gets dynamic cache configuration template.
*
* @return Dynamic cache configuration template.
*/
public CacheConfiguration<Object, Object> getDynamicCacheConfiguration() {
return dynamicCacheCfg;
}
/**
* Sets dynamic cache configuration template.
*
* @param dynamicCacheCfg Dynamic cache configuration template.
*/
public void setDynamicCacheConfiguration(CacheConfiguration<Object, Object> dynamicCacheCfg) {
this.dynamicCacheCfg = dynamicCacheCfg;
}
/**
* Gets dynamic near cache configuration template.
*
* @return Dynamic near cache configuration template.
*/
public NearCacheConfiguration<Object, Object> getDynamicNearCacheConfiguration() {
return dynamicNearCacheCfg;
}
/**
* Sets dynamic cache configuration template.
*
* @param dynamicNearCacheCfg Dynamic cache configuration template.
*/
public void setDynamicNearCacheConfiguration(NearCacheConfiguration<Object, Object> dynamicNearCacheCfg) {
this.dynamicNearCacheCfg = dynamicNearCacheCfg;
}
/**
* {@inheritDoc}
*/
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (ignite == null) {
if (cfgPath != null && cfg != null) {
throw new IllegalArgumentException("Both 'configurationPath' and 'configuration' are " + "provided. Set only one of these properties if you need to start a Ignite node inside of " + "SpringCacheManager. If you already have a node running, omit both of them and set" + "'igniteInstanceName' property.");
}
try {
if (cfgPath != null) {
ignite = IgniteSpring.start(cfgPath, springCtx);
} else if (cfg != null)
ignite = IgniteSpring.start(cfg, springCtx);
else {
ignite = Ignition.ignite(igniteInstanceName);
externalIgniteInstance = true;
}
} catch (IgniteCheckedException e) {
throw U.convertException(e);
}
}
}
/**
* {@inheritDoc}
*/
@Override
protected SpringCache createCache(String name) {
CacheConfiguration<Object, Object> cacheCfg = dynamicCacheCfg != null ? new CacheConfiguration<>(dynamicCacheCfg) : new CacheConfiguration<>();
NearCacheConfiguration<Object, Object> nearCacheCfg = dynamicNearCacheCfg != null ? new NearCacheConfiguration<>(dynamicNearCacheCfg) : null;
cacheCfg.setName(name);
IgniteCache<Object, Object> cache = nearCacheCfg != null ? ignite.getOrCreateCache(cacheCfg, nearCacheCfg) : ignite.getOrCreateCache(cacheCfg);
return new SpringCache(new IgniteNodeCacheProxy<>(cache), this);
}
/**
* {@inheritDoc}
*/
@Override
protected IgniteLock getSyncLock(String name, Object key) {
int hash = Objects.hash(name, key);
final int idx = hash % getLocksCount();
return locks.computeIfAbsent(idx, i -> ignite.reentrantLock(SPRING_LOCK_NAME_PREFIX + idx, true, false, true));
}
/**
* {@inheritDoc}
*/
@Override
public void destroy() {
if (!externalIgniteInstance)
ignite.close();
}
}
19
Source : IgniteAutoConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Starts an {@link Ignite} node.
*
* @param cfg Configuration.
* @return Ignite instance.
*/
@ConditionalOnBean(IgniteConfiguration.clreplaced)
@Bean
public Ignite ignite(IgniteConfiguration cfg) {
return Ignition.start(cfg);
}
19
Source : IgniteAutoConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Provides an instance of {@link IgniteConfiguration} customized with the {@link IgniteConfigurer}.
*
* @param configurer Configurer.
* @return Ignite configuration.
*/
@ConditionalOnMissingBean
@Bean
@ConfigurationProperties(prefix = IGNITE_PROPS_PREFIX)
public IgniteConfiguration igniteConfiguration(IgniteConfigurer configurer) {
IgniteConfiguration cfg = new IgniteConfiguration();
configurer.accept(cfg);
return cfg;
}
19
Source : IgniteSetComponentConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Interact with Ignite Set data structures.
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.springboot.maven.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.ignite-set")
public clreplaced IgniteSetComponentConfiguration extends ComponentConfigurationPropertiesCommon {
/**
* Whether to enable auto configuration of the ignite-set component. This is
* enabled by default.
*/
private Boolean enabled;
/**
* The resource from where to load the configuration. It can be a: URL,
* String or InputStream type. The option is a java.lang.Object type.
*/
private Object configurationResource;
/**
* To use an existing Ignite instance. The option is a
* org.apache.ignite.Ignite type.
*/
private Ignite ignite;
/**
* Allows the user to set a programmatic ignite configuration. The option is
* a org.apache.ignite.configuration.IgniteConfiguration type.
*/
private IgniteConfiguration igniteConfiguration;
/**
* Whether the producer should be started lazy (on the first message). By
* starting lazy you can use this to allow CamelContext and routes to
* startup in situations where a producer may otherwise fail during starting
* and cause the route to fail being started. By deferring this startup to
* be lazy then the startup failure can be handled during routing messages
* via Camel's routing error handlers. Beware that when the first message is
* processed then creating and starting the producer may take a little time
* and prolong the total processing time of the processing.
*/
private Boolean lazyStartProducer = false;
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in the
* registry to find if there is a single instance of matching type, which
* then gets configured on the component. This can be used for automatic
* configuring JDBC data sources, JMS connection factories, AWS Clients,
* etc.
*/
private Boolean autowiredEnabled = true;
public Object getConfigurationResource() {
return configurationResource;
}
public void setConfigurationResource(Object configurationResource) {
this.configurationResource = configurationResource;
}
public Ignite getIgnite() {
return ignite;
}
public void setIgnite(Ignite ignite) {
this.ignite = ignite;
}
public IgniteConfiguration getIgniteConfiguration() {
return igniteConfiguration;
}
public void setIgniteConfiguration(IgniteConfiguration igniteConfiguration) {
this.igniteConfiguration = igniteConfiguration;
}
public Boolean getLazyStartProducer() {
return lazyStartProducer;
}
public void setLazyStartProducer(Boolean lazyStartProducer) {
this.lazyStartProducer = lazyStartProducer;
}
public Boolean getAutowiredEnabled() {
return autowiredEnabled;
}
public void setAutowiredEnabled(Boolean autowiredEnabled) {
this.autowiredEnabled = autowiredEnabled;
}
}
19
Source : IgniteSetComponentConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public void setIgniteConfiguration(IgniteConfiguration igniteConfiguration) {
this.igniteConfiguration = igniteConfiguration;
}
19
Source : IgniteQueueComponentConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Interact with Ignite Queue data structures.
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.springboot.maven.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.ignite-queue")
public clreplaced IgniteQueueComponentConfiguration extends ComponentConfigurationPropertiesCommon {
/**
* Whether to enable auto configuration of the ignite-queue component. This
* is enabled by default.
*/
private Boolean enabled;
/**
* The resource from where to load the configuration. It can be a: URL,
* String or InputStream type. The option is a java.lang.Object type.
*/
private Object configurationResource;
/**
* To use an existing Ignite instance. The option is a
* org.apache.ignite.Ignite type.
*/
private Ignite ignite;
/**
* Allows the user to set a programmatic ignite configuration. The option is
* a org.apache.ignite.configuration.IgniteConfiguration type.
*/
private IgniteConfiguration igniteConfiguration;
/**
* Whether the producer should be started lazy (on the first message). By
* starting lazy you can use this to allow CamelContext and routes to
* startup in situations where a producer may otherwise fail during starting
* and cause the route to fail being started. By deferring this startup to
* be lazy then the startup failure can be handled during routing messages
* via Camel's routing error handlers. Beware that when the first message is
* processed then creating and starting the producer may take a little time
* and prolong the total processing time of the processing.
*/
private Boolean lazyStartProducer = false;
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in the
* registry to find if there is a single instance of matching type, which
* then gets configured on the component. This can be used for automatic
* configuring JDBC data sources, JMS connection factories, AWS Clients,
* etc.
*/
private Boolean autowiredEnabled = true;
public Object getConfigurationResource() {
return configurationResource;
}
public void setConfigurationResource(Object configurationResource) {
this.configurationResource = configurationResource;
}
public Ignite getIgnite() {
return ignite;
}
public void setIgnite(Ignite ignite) {
this.ignite = ignite;
}
public IgniteConfiguration getIgniteConfiguration() {
return igniteConfiguration;
}
public void setIgniteConfiguration(IgniteConfiguration igniteConfiguration) {
this.igniteConfiguration = igniteConfiguration;
}
public Boolean getLazyStartProducer() {
return lazyStartProducer;
}
public void setLazyStartProducer(Boolean lazyStartProducer) {
this.lazyStartProducer = lazyStartProducer;
}
public Boolean getAutowiredEnabled() {
return autowiredEnabled;
}
public void setAutowiredEnabled(Boolean autowiredEnabled) {
this.autowiredEnabled = autowiredEnabled;
}
}
19
Source : IgniteIdGenComponentConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Interact with Ignite Atomic Sequences and ID Generators .
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.springboot.maven.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.ignite-idgen")
public clreplaced IgniteIdGenComponentConfiguration extends ComponentConfigurationPropertiesCommon {
/**
* Whether to enable auto configuration of the ignite-idgen component. This
* is enabled by default.
*/
private Boolean enabled;
/**
* The resource from where to load the configuration. It can be a: URL,
* String or InputStream type. The option is a java.lang.Object type.
*/
private Object configurationResource;
/**
* To use an existing Ignite instance. The option is a
* org.apache.ignite.Ignite type.
*/
private Ignite ignite;
/**
* Allows the user to set a programmatic ignite configuration. The option is
* a org.apache.ignite.configuration.IgniteConfiguration type.
*/
private IgniteConfiguration igniteConfiguration;
/**
* Whether the producer should be started lazy (on the first message). By
* starting lazy you can use this to allow CamelContext and routes to
* startup in situations where a producer may otherwise fail during starting
* and cause the route to fail being started. By deferring this startup to
* be lazy then the startup failure can be handled during routing messages
* via Camel's routing error handlers. Beware that when the first message is
* processed then creating and starting the producer may take a little time
* and prolong the total processing time of the processing.
*/
private Boolean lazyStartProducer = false;
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in the
* registry to find if there is a single instance of matching type, which
* then gets configured on the component. This can be used for automatic
* configuring JDBC data sources, JMS connection factories, AWS Clients,
* etc.
*/
private Boolean autowiredEnabled = true;
public Object getConfigurationResource() {
return configurationResource;
}
public void setConfigurationResource(Object configurationResource) {
this.configurationResource = configurationResource;
}
public Ignite getIgnite() {
return ignite;
}
public void setIgnite(Ignite ignite) {
this.ignite = ignite;
}
public IgniteConfiguration getIgniteConfiguration() {
return igniteConfiguration;
}
public void setIgniteConfiguration(IgniteConfiguration igniteConfiguration) {
this.igniteConfiguration = igniteConfiguration;
}
public Boolean getLazyStartProducer() {
return lazyStartProducer;
}
public void setLazyStartProducer(Boolean lazyStartProducer) {
this.lazyStartProducer = lazyStartProducer;
}
public Boolean getAutowiredEnabled() {
return autowiredEnabled;
}
public void setAutowiredEnabled(Boolean autowiredEnabled) {
this.autowiredEnabled = autowiredEnabled;
}
}
19
Source : IgniteEventsComponentConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Receive events from an Ignite cluster by creating a local event listener.
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.springboot.maven.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.ignite-events")
public clreplaced IgniteEventsComponentConfiguration extends ComponentConfigurationPropertiesCommon {
/**
* Whether to enable auto configuration of the ignite-events component. This
* is enabled by default.
*/
private Boolean enabled;
/**
* Allows for bridging the consumer to the Camel routing Error Handler,
* which mean any exceptions occurred while the consumer is trying to pickup
* incoming messages, or the likes, will now be processed as a message and
* handled by the routing Error Handler. By default the consumer will use
* the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that
* will be logged at WARN or ERROR level and ignored.
*/
private Boolean bridgeErrorHandler = false;
/**
* The resource from where to load the configuration. It can be a: URL,
* String or InputStream type. The option is a java.lang.Object type.
*/
private Object configurationResource;
/**
* To use an existing Ignite instance. The option is a
* org.apache.ignite.Ignite type.
*/
private Ignite ignite;
/**
* Allows the user to set a programmatic ignite configuration. The option is
* a org.apache.ignite.configuration.IgniteConfiguration type.
*/
private IgniteConfiguration igniteConfiguration;
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in the
* registry to find if there is a single instance of matching type, which
* then gets configured on the component. This can be used for automatic
* configuring JDBC data sources, JMS connection factories, AWS Clients,
* etc.
*/
private Boolean autowiredEnabled = true;
public Boolean getBridgeErrorHandler() {
return bridgeErrorHandler;
}
public void setBridgeErrorHandler(Boolean bridgeErrorHandler) {
this.bridgeErrorHandler = bridgeErrorHandler;
}
public Object getConfigurationResource() {
return configurationResource;
}
public void setConfigurationResource(Object configurationResource) {
this.configurationResource = configurationResource;
}
public Ignite getIgnite() {
return ignite;
}
public void setIgnite(Ignite ignite) {
this.ignite = ignite;
}
public IgniteConfiguration getIgniteConfiguration() {
return igniteConfiguration;
}
public void setIgniteConfiguration(IgniteConfiguration igniteConfiguration) {
this.igniteConfiguration = igniteConfiguration;
}
public Boolean getAutowiredEnabled() {
return autowiredEnabled;
}
public void setAutowiredEnabled(Boolean autowiredEnabled) {
this.autowiredEnabled = autowiredEnabled;
}
}
19
Source : IgniteCacheComponentConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Perform cache operations on an Ignite cache or consume changes from a
* continuous query.
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.springboot.maven.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.ignite-cache")
public clreplaced IgniteCacheComponentConfiguration extends ComponentConfigurationPropertiesCommon {
/**
* Whether to enable auto configuration of the ignite-cache component. This
* is enabled by default.
*/
private Boolean enabled;
/**
* The resource from where to load the configuration. It can be a: URL,
* String or InputStream type. The option is a java.lang.Object type.
*/
private Object configurationResource;
/**
* To use an existing Ignite instance. The option is a
* org.apache.ignite.Ignite type.
*/
private Ignite ignite;
/**
* Allows the user to set a programmatic ignite configuration. The option is
* a org.apache.ignite.configuration.IgniteConfiguration type.
*/
private IgniteConfiguration igniteConfiguration;
/**
* Allows for bridging the consumer to the Camel routing Error Handler,
* which mean any exceptions occurred while the consumer is trying to pickup
* incoming messages, or the likes, will now be processed as a message and
* handled by the routing Error Handler. By default the consumer will use
* the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that
* will be logged at WARN or ERROR level and ignored.
*/
private Boolean bridgeErrorHandler = false;
/**
* Whether the producer should be started lazy (on the first message). By
* starting lazy you can use this to allow CamelContext and routes to
* startup in situations where a producer may otherwise fail during starting
* and cause the route to fail being started. By deferring this startup to
* be lazy then the startup failure can be handled during routing messages
* via Camel's routing error handlers. Beware that when the first message is
* processed then creating and starting the producer may take a little time
* and prolong the total processing time of the processing.
*/
private Boolean lazyStartProducer = false;
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in the
* registry to find if there is a single instance of matching type, which
* then gets configured on the component. This can be used for automatic
* configuring JDBC data sources, JMS connection factories, AWS Clients,
* etc.
*/
private Boolean autowiredEnabled = true;
public Object getConfigurationResource() {
return configurationResource;
}
public void setConfigurationResource(Object configurationResource) {
this.configurationResource = configurationResource;
}
public Ignite getIgnite() {
return ignite;
}
public void setIgnite(Ignite ignite) {
this.ignite = ignite;
}
public IgniteConfiguration getIgniteConfiguration() {
return igniteConfiguration;
}
public void setIgniteConfiguration(IgniteConfiguration igniteConfiguration) {
this.igniteConfiguration = igniteConfiguration;
}
public Boolean getBridgeErrorHandler() {
return bridgeErrorHandler;
}
public void setBridgeErrorHandler(Boolean bridgeErrorHandler) {
this.bridgeErrorHandler = bridgeErrorHandler;
}
public Boolean getLazyStartProducer() {
return lazyStartProducer;
}
public void setLazyStartProducer(Boolean lazyStartProducer) {
this.lazyStartProducer = lazyStartProducer;
}
public Boolean getAutowiredEnabled() {
return autowiredEnabled;
}
public void setAutowiredEnabled(Boolean autowiredEnabled) {
this.autowiredEnabled = autowiredEnabled;
}
}
18
Source : AlertManagerConfiguration.java
with Apache License 2.0
from Romeh
with Apache License 2.0
from Romeh
@Bean(destroyMethod = "close")
Ignite ignite(IgniteConfiguration igniteConfiguration) throws IgniteException {
final Ignite ignite = Ignition.start(igniteConfiguration);
// Activate the cluster. Automatic topology initialization occurs
// only if you manually activate the cluster for the very first time.
ignite.cluster().active(true);
/*// Get all server nodes that are already up and running.
Collection<ClusterNode> nodes = ignite.cluster().forServers().nodes();
// Set the baseline topology that is represented by these nodes.
ignite.cluster().setBaselineTopology(nodes);*/
return ignite;
}
18
Source : ConfigPropertiesTest.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
private IgniteConfiguration createConfig(String gridName) {
IgniteConfiguration result = new IgniteConfiguration();
result.setIgniteInstanceName(gridName);
return result;
}
18
Source : IgniteDatastoreProvider.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
private void injectJtaPlatform(IgniteConfiguration conf) {
if (!(jtaPlatform instanceof NoJtaPlatform) && conf.getTransactionConfiguration().getTxManagerFactory() == null) {
conf.getTransactionConfiguration().setTxManagerFactory(new IgniteTransactionManagerFactory(jtaPlatform));
}
}
18
Source : IgniteDatastoreProvider.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
@Override
public void start() {
try {
// vk: take local node instance
localNode = Thread.currentThread() instanceof IgniteThread;
if (localNode) {
cacheManager = (IgniteEx) Ignition.localIgnite();
gridName = cacheManager.name();
} else {
IgniteConfiguration conf = createIgniteConfiguration(configProvider);
gridName = gridName(configProvider.getInstanceName(), configProvider.getUrl(), conf);
startIgnite(conf);
}
} catch (ServiceException ex) {
throw ex;
} catch (Exception ex) {
throw log.unableToStartDatastoreProvider(ex);
}
}
18
Source : StormIgniteStreamerSelfTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* {@inheritDoc}
*/
@Override
protected void beforeTest() throws Exception {
IgniteConfiguration cfg = loadConfiguration(GRID_CONF_FILE);
cfg.setClientMode(false);
ignite = startGrid("igniteServerNode", cfg);
}
18
Source : IgniteAutoconfigureTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Tests that Ignite node will use configuration provided in {@link BeanFactory}.
*/
@Test
public void testIgniteUseProvidedConfiguration() throws Exception {
IgniteConfiguration cfg = new IgniteConfiguration().setIgniteInstanceName("test-name").setConsistentId("test-id");
contextRunner.withBean(IgniteConfiguration.clreplaced, () -> cfg).run((context) -> {
replacedertThat(context).hreplacedingleBean(IgniteConfiguration.clreplaced);
replacedertThat(context).hreplacedingleBean(Ignite.clreplaced);
IgniteConfiguration cfg0 = context.getBean(IgniteConfiguration.clreplaced);
replacedertEquals("Expecting usage of the configuration from context", cfg.getIgniteInstanceName(), cfg0.getIgniteInstanceName());
replacedertEquals("Expecting usage of the configuration from context", cfg.getConsistentId(), cfg0.getConsistentId());
cfg0 = context.getBean(Ignite.clreplaced).configuration();
replacedertEquals("Expecting usage of the configuration from context", cfg.getIgniteInstanceName(), cfg0.getIgniteInstanceName());
replacedertEquals("Expecting usage of the configuration from context", cfg.getConsistentId(), cfg0.getConsistentId());
});
}
18
Source : IgniteAutoconfigureTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Tests that Spring will use {@link IgniteConfigurer} to customize {@link IgniteConfiguration}.
*/
@Test
public void testIgniteConfigurer() throws Exception {
String instanceName = "configurer-test-name";
String consistentId = "configurer-test-id";
ApplicationContextRunner runner = contextRunner.withBean(IgniteConfigurer.clreplaced, () -> cfg -> {
cfg.setIgniteInstanceName(instanceName).setConsistentId(consistentId);
});
runner.run((context) -> {
replacedertThat(context).hreplacedingleBean(IgniteConfiguration.clreplaced);
replacedertThat(context).hreplacedingleBean(Ignite.clreplaced);
IgniteConfiguration cfg0 = context.getBean(IgniteConfiguration.clreplaced);
replacedertEquals("Expecting usage of the configuration from context", instanceName, cfg0.getIgniteInstanceName());
replacedertEquals("Expecting usage of the configuration from context", consistentId, cfg0.getConsistentId());
cfg0 = context.getBean(Ignite.clreplaced).configuration();
replacedertEquals("Expecting usage of the configuration from context", instanceName, cfg0.getIgniteInstanceName());
replacedertEquals("Expecting usage of the configuration from context", consistentId, cfg0.getConsistentId());
});
}
18
Source : IgniteSourceConnectorTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* {@inheritDoc}
*/
@Override
protected void beforeTestsStarted() throws Exception {
IgniteConfiguration cfg = loadConfiguration("example-ignite.xml");
cfg.setClientMode(false);
grid = startGrid("igniteServerNode", cfg);
}
18
Source : IgniteMessagingComponentConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Send and receive messages from an Ignite topic.
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.springboot.maven.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.ignite-messaging")
public clreplaced IgniteMessagingComponentConfiguration extends ComponentConfigurationPropertiesCommon {
/**
* Whether to enable auto configuration of the ignite-messaging component.
* This is enabled by default.
*/
private Boolean enabled;
/**
* The resource from where to load the configuration. It can be a: URL,
* String or InputStream type. The option is a java.lang.Object type.
*/
private Object configurationResource;
/**
* To use an existing Ignite instance. The option is a
* org.apache.ignite.Ignite type.
*/
private Ignite ignite;
/**
* Allows the user to set a programmatic ignite configuration. The option is
* a org.apache.ignite.configuration.IgniteConfiguration type.
*/
private IgniteConfiguration igniteConfiguration;
/**
* Allows for bridging the consumer to the Camel routing Error Handler,
* which mean any exceptions occurred while the consumer is trying to pickup
* incoming messages, or the likes, will now be processed as a message and
* handled by the routing Error Handler. By default the consumer will use
* the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that
* will be logged at WARN or ERROR level and ignored.
*/
private Boolean bridgeErrorHandler = false;
/**
* Whether the producer should be started lazy (on the first message). By
* starting lazy you can use this to allow CamelContext and routes to
* startup in situations where a producer may otherwise fail during starting
* and cause the route to fail being started. By deferring this startup to
* be lazy then the startup failure can be handled during routing messages
* via Camel's routing error handlers. Beware that when the first message is
* processed then creating and starting the producer may take a little time
* and prolong the total processing time of the processing.
*/
private Boolean lazyStartProducer = false;
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in the
* registry to find if there is a single instance of matching type, which
* then gets configured on the component. This can be used for automatic
* configuring JDBC data sources, JMS connection factories, AWS Clients,
* etc.
*/
private Boolean autowiredEnabled = true;
public Object getConfigurationResource() {
return configurationResource;
}
public void setConfigurationResource(Object configurationResource) {
this.configurationResource = configurationResource;
}
public Ignite getIgnite() {
return ignite;
}
public void setIgnite(Ignite ignite) {
this.ignite = ignite;
}
public IgniteConfiguration getIgniteConfiguration() {
return igniteConfiguration;
}
public void setIgniteConfiguration(IgniteConfiguration igniteConfiguration) {
this.igniteConfiguration = igniteConfiguration;
}
public Boolean getBridgeErrorHandler() {
return bridgeErrorHandler;
}
public void setBridgeErrorHandler(Boolean bridgeErrorHandler) {
this.bridgeErrorHandler = bridgeErrorHandler;
}
public Boolean getLazyStartProducer() {
return lazyStartProducer;
}
public void setLazyStartProducer(Boolean lazyStartProducer) {
this.lazyStartProducer = lazyStartProducer;
}
public Boolean getAutowiredEnabled() {
return autowiredEnabled;
}
public void setAutowiredEnabled(Boolean autowiredEnabled) {
this.autowiredEnabled = autowiredEnabled;
}
}
18
Source : IgniteComputeComponentConfiguration.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Run compute operations on an Ignite cluster.
*
* Generated by camel-package-maven-plugin - do not edit this file!
*/
@Generated("org.apache.camel.springboot.maven.SpringBootAutoConfigurationMojo")
@ConfigurationProperties(prefix = "camel.component.ignite-compute")
public clreplaced IgniteComputeComponentConfiguration extends ComponentConfigurationPropertiesCommon {
/**
* Whether to enable auto configuration of the ignite-compute component.
* This is enabled by default.
*/
private Boolean enabled;
/**
* The resource from where to load the configuration. It can be a: URL,
* String or InputStream type. The option is a java.lang.Object type.
*/
private Object configurationResource;
/**
* To use an existing Ignite instance. The option is a
* org.apache.ignite.Ignite type.
*/
private Ignite ignite;
/**
* Allows the user to set a programmatic ignite configuration. The option is
* a org.apache.ignite.configuration.IgniteConfiguration type.
*/
private IgniteConfiguration igniteConfiguration;
/**
* Whether the producer should be started lazy (on the first message). By
* starting lazy you can use this to allow CamelContext and routes to
* startup in situations where a producer may otherwise fail during starting
* and cause the route to fail being started. By deferring this startup to
* be lazy then the startup failure can be handled during routing messages
* via Camel's routing error handlers. Beware that when the first message is
* processed then creating and starting the producer may take a little time
* and prolong the total processing time of the processing.
*/
private Boolean lazyStartProducer = false;
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in the
* registry to find if there is a single instance of matching type, which
* then gets configured on the component. This can be used for automatic
* configuring JDBC data sources, JMS connection factories, AWS Clients,
* etc.
*/
private Boolean autowiredEnabled = true;
public Object getConfigurationResource() {
return configurationResource;
}
public void setConfigurationResource(Object configurationResource) {
this.configurationResource = configurationResource;
}
public Ignite getIgnite() {
return ignite;
}
public void setIgnite(Ignite ignite) {
this.ignite = ignite;
}
public IgniteConfiguration getIgniteConfiguration() {
return igniteConfiguration;
}
public void setIgniteConfiguration(IgniteConfiguration igniteConfiguration) {
this.igniteConfiguration = igniteConfiguration;
}
public Boolean getLazyStartProducer() {
return lazyStartProducer;
}
public void setLazyStartProducer(Boolean lazyStartProducer) {
this.lazyStartProducer = lazyStartProducer;
}
public Boolean getAutowiredEnabled() {
return autowiredEnabled;
}
public void setAutowiredEnabled(Boolean autowiredEnabled) {
this.autowiredEnabled = autowiredEnabled;
}
}
17
Source : IgniteDatastoreProvider.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
private void startIgnite(IgniteConfiguration conf) {
try {
cacheManager = (IgniteEx) Ignition.ignite(gridName);
} catch (IgniteIllegalStateException iise) {
// not found, then start
conf.setIgniteInstanceName(gridName);
cacheManager = (IgniteEx) Ignition.start(conf);
if (conf.getPersistentStoreConfiguration() != null && !conf.isClientMode()) {
cacheManager.active(true);
}
stopOnExit = true;
}
}
17
Source : IgniteDatastoreProvider.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
private IgniteConfiguration createIgniteConfiguration(IgniteProviderConfiguration configProvider) throws IgniteCheckedException {
IgniteConfiguration conf = null;
if (configProvider.getConfigBuilder() != null) {
conf = configProvider.getConfigBuilder().build();
}
if (conf == null && configProvider.getUrl() != null) {
conf = IgnitionEx.loadConfiguration(configProvider.getUrl()).get1();
}
if (conf == null) {
throw log.configurationNotSet();
}
injectJtaPlatform(conf);
return conf;
}
17
Source : SpringTransactionManagerContextInjectionTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* @throws Exception If failed.
*/
@Test
public void testBeanInjectionUsingConfigPath() throws Exception {
BeanFactory factory = new AnnotationConfigApplicationContext(TestPathConfiguration.clreplaced);
Ignite grid = IgnitionEx.grid("springInjectionTest");
IgniteConfiguration cfg = grid.configuration();
LifecycleBean[] beans = cfg.getLifecycleBeans();
replacedertEquals(2, beans.length);
TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean) beans[0];
TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean) beans[1];
bean1.checkState();
bean2.checkState();
}
17
Source : SpringCacheManagerContextInjectionTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* @throws Exception If failed.
*/
@Test
public void testBeanInjectionUsingConfigPath() throws Exception {
new AnnotationConfigApplicationContext(TestPathConfiguration.clreplaced);
Ignite grid = IgnitionEx.grid("springInjectionTest");
IgniteConfiguration cfg = grid.configuration();
LifecycleBean[] beans = cfg.getLifecycleBeans();
replacedertEquals(2, beans.length);
TestInjectionLifecycleBean bean1 = (TestInjectionLifecycleBean) beans[0];
TestInjectionLifecycleBean bean2 = (TestInjectionLifecycleBean) beans[1];
bean1.checkState();
bean2.checkState();
}
17
Source : IgniteAutoconfigureTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Tests that Spring will use application properties to customize {@link IgniteConfiguration}.
*/
@Test
public void testIgniteUseApplicationProperties() throws Exception {
ApplicationContextRunner runner = contextRunner.withPropertyValues("ignite.igniteInstanceName=from-property-name", "ignite.consistentId=from-property-id");
String instanceName = "from-property-name";
String consistentId = "from-property-id";
runner.run((context) -> {
replacedertThat(context).hreplacedingleBean(IgniteConfiguration.clreplaced);
replacedertThat(context).hreplacedingleBean(Ignite.clreplaced);
IgniteConfiguration cfg0 = context.getBean(IgniteConfiguration.clreplaced);
replacedertEquals("Expecting usage of the configuration from context", instanceName, cfg0.getIgniteInstanceName());
replacedertEquals("Expecting usage of the configuration from context", consistentId, cfg0.getConsistentId());
cfg0 = context.getBean(Ignite.clreplaced).configuration();
replacedertEquals("Expecting usage of the configuration from context", instanceName, cfg0.getIgniteInstanceName());
replacedertEquals("Expecting usage of the configuration from context", consistentId, cfg0.getConsistentId());
});
}
17
Source : IgniteAutoconfigureTest.java
with Apache License 2.0
from apache
with Apache License 2.0
from apache
/**
* Tests that application properties will override {@link IgniteConfiguration} provided by {@link IgniteConfigurer}.
*/
@Test
public void testApplicationPropertiesOverridesConfigurer() throws Exception {
String instanceName = "test-name";
String consistentId = "from-property-id";
ApplicationContextRunner runner = contextRunner.withPropertyValues("ignite.consistentId=from-property-id").withBean(IgniteConfigurer.clreplaced, () -> cfg -> {
cfg.setIgniteInstanceName(instanceName).setConsistentId("test-id");
});
runner.run((context) -> {
replacedertThat(context).hreplacedingleBean(IgniteConfiguration.clreplaced);
replacedertThat(context).hreplacedingleBean(Ignite.clreplaced);
IgniteConfiguration cfg0 = context.getBean(IgniteConfiguration.clreplaced);
replacedertEquals("Expecting usage of the configuration from context", instanceName, cfg0.getIgniteInstanceName());
replacedertEquals("Expecting usage of the configuration from context", consistentId, cfg0.getConsistentId());
cfg0 = context.getBean(Ignite.clreplaced).configuration();
replacedertEquals("Expecting usage of the configuration from context", instanceName, cfg0.getIgniteInstanceName());
replacedertEquals("Expecting usage of the configuration from context", consistentId, cfg0.getConsistentId());
});
}
16
Source : IgniteDatastoreProvider.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
private String gridName(String instanceName, URL ingiteConfigUrl, IgniteConfiguration conf) {
if (isNotEmpty(instanceName)) {
return instanceName;
}
if (isNotEmpty(conf.getIgniteInstanceName())) {
return conf.getIgniteInstanceName();
}
if (ingiteConfigUrl != null) {
String name = ingiteConfigUrl.getPath();
return name.replaceAll("[\\,\\\",:,\\*,\\/,\\\\]", "_");
} else {
return UUID.randomUUID().toString();
}
}
15
Source : IgniteClientTest.java
with MIT License
from aliyun
with MIT License
from aliyun
@BeforeClreplaced
public static void beforeTest() throws IgniteCheckedException {
IgniteConfiguration igcfg = new IgniteConfiguration();
igcfg.setIgniteInstanceName(SERVER_NODE_NAME);
igcfg.setClientMode(false);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
Collection<String> adders = new LinkedHashSet<>();
adders.add(HOST + ":" + PORTS);
((TcpDiscoveryVmIpFinder) ipFinder).setAddresses(adders);
disco.setIpFinder(ipFinder);
igcfg.setDiscoverySpi(disco);
igcfg.setNetworkTimeout(2000);
CacheConfiguration ccfg = new CacheConfiguration().setName(DEFAULT_CACHE_NAME);
igcfg.setCacheConfiguration(ccfg);
Log4J2Logger logger = new Log4J2Logger(IgniteClientTest.clreplaced.getClreplacedLoader().getResource("log4j2.xml"));
igcfg.setGridLogger(logger);
cluster = Ignition.start(igcfg);
cluster.active();
}
14
Source : ConfigPropertiesTest.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
@Test
public void testGridNameOverrideConfigBuilder() {
IgniteConfiguration config = createConfig(CUSTOM_GRID_NAME);
try (Ignite ignite = Ignition.start(config)) {
StandardServiceRegistry registry = registryBuilder().applySetting(IgniteProperties.CONFIGURATION_CLreplaced_NAME, MyTinyGridConfigBuilder.clreplaced.getName()).applySetting(IgniteProperties.IGNITE_INSTANCE_NAME, CUSTOM_GRID_NAME).build();
try (OgmSessionFactory sessionFactory = createFactory(registry)) {
replacedertThat(Ignition.allGrids()).hreplacedize(1);
replacedertThat(Ignition.allGrids().get(0).name()).isEqualTo(CUSTOM_GRID_NAME);
}
}
}
13
Source : IgniteAbstractClient.java
with MIT License
from aliyun
with MIT License
from aliyun
/**
* Initialize any state for this DB. Called once per DB instance; there is one
* DB instance per client thread.
*/
@Override
public void init() throws DBException {
// Keep track of number of calls to init (for later cleanup)
INIT_COUNT.incrementAndGet();
// Synchronized so that we only have a single
// cluster/session instance for all the threads.
synchronized (INIT_COUNT) {
// Check if the cluster has already been initialized
if (cluster != null) {
return;
}
try {
debug = Boolean.parseBoolean(getProperties().getProperty("debug", "false"));
IgniteConfiguration igcfg = new IgniteConfiguration();
igcfg.setIgniteInstanceName(CLIENT_NODE_NAME);
String host = getProperties().getProperty(HOSTS_PROPERTY);
if (host == null) {
throw new DBException(String.format("Required property \"%s\" missing for Ignite Cluster", HOSTS_PROPERTY));
}
String ports = getProperties().getProperty(PORTS_PROPERTY, PORTS_DEFAULTS);
if (ports == null) {
throw new DBException(String.format("Required property \"%s\" missing for Ignite Cluster", PORTS_PROPERTY));
}
System.setProperty("IGNITE_QUIET", "false");
TcpDiscoverySpi disco = new TcpDiscoverySpi();
Collection<String> addrs = new LinkedHashSet<>();
addrs.add(host + ":" + ports);
((TcpDiscoveryVmIpFinder) ipFinder).setAddresses(addrs);
disco.setIpFinder(ipFinder);
igcfg.setDiscoverySpi(disco);
igcfg.setNetworkTimeout(2000);
igcfg.setClientMode(true);
Log4J2Logger logger = new Log4J2Logger(this.getClreplaced().getClreplacedLoader().getResource("log4j2.xml"));
igcfg.setGridLogger(logger);
log.info("Start Ignite client node.");
cluster = Ignition.start(igcfg);
log.info("Activate Ignite cluster.");
cluster.active(true);
cache = cluster.cache(DEFAULT_CACHE_NAME).withKeepBinary();
if (cache == null) {
throw new DBException(new IgniteCheckedException("Failed to find cache " + DEFAULT_CACHE_NAME));
}
} catch (Exception e) {
throw new DBException(e);
}
}
// synchronized
}
13
Source : ApacheIgniteManager.java
with GNU General Public License v3.0
from alain898
with GNU General Public License v3.0
from alain898
private static void init() {
IgniteConfiguration cfg = new IgniteConfiguration();
// configApp discovery port, used to transport meta data
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
discoverySpi.setLocalPort(metaPort);
discoverySpi.setLocalPortRange(0);
TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
ipFinder.setAddresses(parseClusterHosts(cluster, metaPort));
discoverySpi.setIpFinder(ipFinder);
cfg.setDiscoverySpi(discoverySpi);
// configApp communication port, used to transport data
TcpCommunicationSpi commSpi = new TcpCommunicationSpi();
commSpi.setLocalPort(dataPort);
cfg.setCommunicationSpi(commSpi);
// configApp ignite memory
DataStorageConfiguration storageCfg = new DataStorageConfiguration();
storageCfg.getDefaultDataRegionConfiguration().setMaxSize(maxMemoryBytes);
storageCfg.getDefaultDataRegionConfiguration().setPersistenceEnabled(persistenceEnabled);
storageCfg.setStoragePath(workPath);
storageCfg.setWalPath(walPath);
storageCfg.setWalArchivePath(walArchivePath);
cfg.setDataStorageConfiguration(storageCfg);
ignite = Ignition.start(cfg);
ignite.active(true);
}
12
Source : MigniteBootstrap.java
with Apache License 2.0
from XiaoMi
with Apache License 2.0
from XiaoMi
public static void main(String[] args) {
log.info("ignite start");
IgniteConfiguration cfg = new IgniteConfiguration();
// cfg.setClientMode(true);
cfg.setPeerClreplacedLoadingEnabled(true);
TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
Ignite ignite = Ignition.start(cfg);
IgniteCache<String, String> cache = ignite.getOrCreateCache("myCache");
cache.put("name", "zzy");
log.info(">> Created the cache and add the values.");
System.out.println(cache.get("name"));
}
11
Source : HelloIgnite.java
with GNU General Public License v3.0
from srecon
with GNU General Public License v3.0
from srecon
public static void main(String[] args) {
System.out.println("Hello Ignite");
// create a new instance of TCP Discovery SPI
TcpDiscoverySpi spi = new TcpDiscoverySpi();
// create a new instance of tcp discovery multicast ip finder
TcpDiscoveryMulticastIpFinder tcMp = new TcpDiscoveryMulticastIpFinder();
// change your IP address here
tcMp.setAddresses(Arrays.asList("localhost"));
// set the multi cast ip finder for spi
spi.setIpFinder(tcMp);
// create new ignite configuration
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setClientMode(false);
// set the discovery spi to ignite configuration
cfg.setDiscoverySpi(spi);
// Start ignite
Ignite ignite = Ignition.start(cfg);
// get or create cache
IgniteCache<Integer, String> cache = ignite.getOrCreateCache("testCache");
// put some cache elements
for (int i = 1; i <= 100; i++) {
cache.put(i, Integer.toString(i));
}
// get them from the cache and write to the console
for (int i = 1; i <= 100; i++) {
System.out.println("Cache get:" + cache.get(i));
}
ignite.close();
}
11
Source : IgniteTestConfigurationBuilder.java
with GNU Lesser General Public License v2.1
from hibernate
with GNU Lesser General Public License v2.1
from hibernate
private IgniteConfiguration createConfig() {
IgniteConfiguration config = new IgniteConfiguration();
config.setIgniteInstanceName("OgmTestGrid");
config.setClientMode(false);
BinaryConfiguration binaryConfiguration = new BinaryConfiguration();
binaryConfiguration.setNameMapper(new BinaryBasicNameMapper(true));
// it is necessary only for embedded collections (@ElementCollection)
binaryConfiguration.setCompactFooter(false);
config.setBinaryConfiguration(binaryConfiguration);
TransactionConfiguration transactionConfiguration = new TransactionConfiguration();
// I'm going to use PESSIMISTIC here because some people had problem with it and it would be nice if tests
// can highlight the issue. Ideally, we would want to test the different concurrency and isolation level.
transactionConfiguration.setDefaultTxConcurrency(TransactionConcurrency.PESSIMISTIC);
transactionConfiguration.setDefaultTxIsolation(TransactionIsolation.READ_COMMITTED);
config.setTransactionConfiguration(transactionConfiguration);
return config;
}
11
Source : IgniteConfigurationHelper.java
with MIT License
from gauravrmazra
with MIT License
from gauravrmazra
public static IgniteConfiguration defaultIgniteCfg(String igniteInstanceName) {
int cpus = Runtime.getRuntime().availableProcessors();
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setIgniteInstanceName(igniteInstanceName);
cfg.setClientMode(true);
cfg.setPeerClreplacedLoadingEnabled(true);
cfg.setDeploymentMode(DeploymentMode.CONTINUOUS);
cfg.setPeerClreplacedLoadingMissedResourcesCacheSize(200);
cfg.setPublicThreadPoolSize(4 * cpus);
cfg.setSystemThreadPoolSize(2 * cpus);
// log frequency in ms
cfg.setMetricsLogFrequency(30000);
cfg.setGridLogger(igniteLogger());
cfg.setDiscoverySpi(multicastDiscoverySpi());
return cfg;
}
See More Examples