Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.ignite

File IgniteConfigurationSource.java

 

Coverage histogram

../../../img/srcFileCovDistChart7.png
25% of files have more coverage

Code metrics

6
19
9
3
74
56
14
0.74
2.11
3
1.56

Classes

Class Line # Actions
IgniteConfigurationSource 8 18 13
0.7575%
IgniteConfigurationSource.IgniteMemorySettings 61 0 0
-1.0 -
IgniteConfigurationSource.IgniteDiscoverySettings 68 1 1
0.00%
 

Contributing tests

This file is covered by 4 tests. .

Source view

1    package io.sunshower.ignite;
2   
3    import org.apache.ignite.configuration.CacheConfiguration;
4    import org.apache.ignite.configuration.IgniteConfiguration;
5    import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
6    import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
7   
 
8    public class IgniteConfigurationSource {
9   
10    private final String fabricName;
11   
12    private final IgniteMemorySettings memory;
13   
14    private final IgniteDiscoverySettings discovery;
15   
 
16  1 toggle public IgniteConfigurationSource(
17    String name, IgniteMemorySettings memory, IgniteDiscoverySettings discovery) {
18  1 this.memory = memory;
19  1 this.fabricName = name;
20  1 this.discovery = discovery;
21    }
22   
 
23  3 toggle public String getFabricName() {
24  3 return fabricName;
25    }
26   
 
27  0 toggle public IgniteMemorySettings getMemory() {
28  0 return memory;
29    }
30   
 
31  1 toggle public IgniteConfiguration toNative() {
32  1 final IgniteConfiguration cfg = new IgniteConfiguration();
33  1 cfg.setIgniteInstanceName(this.fabricName);
34  1 cfg.setCacheConfiguration(cacheConfiguration());
35  1 configureDiscovery(cfg);
36  1 return cfg;
37    }
38   
 
39  1 toggle private void configureDiscovery(IgniteConfiguration cfg) {
40  1 if (!(discovery == null || discovery.mode() == null)
41    && discovery.mode().trim().equals("vm-local")) {
42  1 TcpDiscoverySpi disco = new TcpDiscoverySpi().setIpFinder(new TcpDiscoveryVmIpFinder(true));
43  1 cfg.setDiscoverySpi(disco);
44    }
45    }
46   
 
47  1 toggle public IgniteDiscoverySettings getDiscovery() {
48  1 return discovery;
49    }
50   
 
51  1 toggle protected CacheConfiguration<?, ?> cacheConfiguration() {
52  1 final CacheConfiguration<?, ?> cfg = new CacheConfiguration<>();
53  1 cfg.setName(this.fabricName == null ? "default-ignite-instance" : this.fabricName);
54  1 return cfg;
55    }
56   
 
57  0 toggle protected long externalMax() {
58  0 return memory != null ? memory.max() : 0;
59    }
60   
 
61    public interface IgniteMemorySettings {
62   
63    long max();
64   
65    String mode();
66    }
67   
 
68    public interface IgniteDiscoverySettings {
69   
 
70  0 toggle default String mode() {
71  0 return "vm-local";
72    }
73    }
74    }