├── .circleci └── config.yml ├── .gitignore ├── ignite-rest-service ├── .gitignore ├── pom.xml └── src │ ├── main │ ├── java │ │ └── pl │ │ │ └── piomin │ │ │ └── services │ │ │ └── ignite │ │ │ ├── IgniteRestApplication.java │ │ │ ├── controller │ │ │ ├── ContactController.java │ │ │ └── PersonController.java │ │ │ ├── model │ │ │ ├── Contact.java │ │ │ ├── ContactType.java │ │ │ ├── Gender.java │ │ │ └── Person.java │ │ │ └── repository │ │ │ ├── ContactRepository.java │ │ │ └── PersonRepository.java │ └── resources │ │ └── application.yml │ └── test │ ├── java │ └── pl │ │ └── piomin │ │ └── services │ │ └── ignite │ │ └── controller │ │ └── IgniteRestControllerTest.java │ └── resources │ └── logback-test.xml ├── pom.xml ├── readme.md └── renovate.json /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | jobs: 4 | build: 5 | docker: 6 | - image: 'cimg/openjdk:21.0.6' 7 | steps: 8 | - checkout 9 | - run: 10 | name: Analyze on SonarCloud 11 | command: mvn verify sonar:sonar 12 | 13 | executors: 14 | jdk: 15 | docker: 16 | - image: 'cimg/openjdk:21.0.6' 17 | 18 | orbs: 19 | maven: circleci/maven@2.0.0 20 | 21 | workflows: 22 | maven_test: 23 | jobs: 24 | - maven/test: 25 | executor: jdk 26 | - build: 27 | context: SonarCloud -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.settings/ 2 | /.project 3 | -------------------------------------------------------------------------------- /ignite-rest-service/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.settings/ 3 | /.classpath 4 | /.project 5 | -------------------------------------------------------------------------------- /ignite-rest-service/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | ignite-rest-service 6 | 1.0-SNAPSHOT 7 | 8 | 9 | ${project.artifactId} 10 | 11 | 12 | 13 | pl.piomin.services 14 | sample-ignite-jpa 15 | 1.0-SNAPSHOT 16 | 17 | 18 | 19 | 20 | org.springframework.boot 21 | spring-boot-starter-web 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-jdbc 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-actuator 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | com.mysql 38 | mysql-connector-j 39 | runtime 40 | 41 | 42 | org.apache.ignite 43 | ignite-spring-data-ext 44 | 3.1.0 45 | 46 | 47 | org.apache.ignite 48 | ignite-indexing 49 | ${ignite.version} 50 | 51 | 52 | 53 | org.apache.ignite 54 | ignite-spring 55 | ${ignite.version} 56 | 57 | 58 | org.springframework.data 59 | spring-data-commons 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/IgniteRestApplication.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite; 2 | 3 | import org.apache.ignite.Ignite; 4 | import org.apache.ignite.Ignition; 5 | import org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStoreFactory; 6 | import org.apache.ignite.cache.store.jdbc.JdbcType; 7 | import org.apache.ignite.cache.store.jdbc.JdbcTypeField; 8 | import org.apache.ignite.cache.store.jdbc.dialect.MySQLDialect; 9 | import org.apache.ignite.configuration.CacheConfiguration; 10 | import org.apache.ignite.configuration.IgniteConfiguration; 11 | import org.apache.ignite.springdata.repository.config.EnableIgniteRepositories; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.boot.SpringApplication; 14 | import org.springframework.boot.autoconfigure.SpringBootApplication; 15 | import org.springframework.context.annotation.Bean; 16 | import pl.piomin.services.ignite.model.Contact; 17 | import pl.piomin.services.ignite.model.ContactType; 18 | import pl.piomin.services.ignite.model.Gender; 19 | import pl.piomin.services.ignite.model.Person; 20 | 21 | import javax.sql.DataSource; 22 | import java.sql.Types; 23 | import java.util.Date; 24 | 25 | @SpringBootApplication 26 | @EnableIgniteRepositories 27 | public class IgniteRestApplication { 28 | 29 | @Autowired 30 | DataSource datasource; 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(IgniteRestApplication.class, args); 34 | } 35 | 36 | @Bean 37 | public Ignite igniteInstance() { 38 | IgniteConfiguration cfg = new IgniteConfiguration(); 39 | cfg.setIgniteInstanceName("ignite-1"); 40 | cfg.setPeerClassLoadingEnabled(true); 41 | 42 | CacheConfiguration ccfg2 = new CacheConfiguration<>("ContactCache"); 43 | ccfg2.setIndexedTypes(Long.class, Contact.class); 44 | ccfg2.setWriteBehindEnabled(true); 45 | ccfg2.setReadThrough(true); 46 | ccfg2.setWriteThrough(true); 47 | CacheJdbcPojoStoreFactory f2 = new CacheJdbcPojoStoreFactory<>(); 48 | f2.setDataSource(datasource); 49 | f2.setDialect(new MySQLDialect()); 50 | JdbcType jdbcContactType = new JdbcType(); 51 | jdbcContactType.setCacheName("ContactCache"); 52 | jdbcContactType.setKeyType(Long.class); 53 | jdbcContactType.setValueType(Contact.class); 54 | jdbcContactType.setDatabaseTable("contact"); 55 | jdbcContactType.setDatabaseSchema("ignite"); 56 | jdbcContactType.setKeyFields(new JdbcTypeField(Types.INTEGER, "id", Long.class, "id")); 57 | jdbcContactType.setValueFields(new JdbcTypeField(Types.VARCHAR, "contact_type", ContactType.class, "type"), 58 | new JdbcTypeField(Types.VARCHAR, "location", String.class, "location"), 59 | new JdbcTypeField(Types.INTEGER, "person_id", Long.class, "personId")); 60 | f2.setTypes(jdbcContactType); 61 | ccfg2.setCacheStoreFactory(f2); 62 | 63 | CacheConfiguration ccfg = new CacheConfiguration<>("PersonCache"); 64 | ccfg.setIndexedTypes(Long.class, Person.class); 65 | ccfg.setWriteBehindEnabled(true); 66 | ccfg.setReadThrough(true); 67 | ccfg.setWriteThrough(true); 68 | CacheJdbcPojoStoreFactory f = new CacheJdbcPojoStoreFactory<>(); 69 | f.setDataSource(datasource); 70 | f.setDialect(new MySQLDialect()); 71 | JdbcType jdbcType = new JdbcType(); 72 | jdbcType.setCacheName("PersonCache"); 73 | jdbcType.setKeyType(Long.class); 74 | jdbcType.setValueType(Person.class); 75 | jdbcType.setDatabaseTable("person"); 76 | jdbcType.setDatabaseSchema("ignite"); 77 | jdbcType.setKeyFields(new JdbcTypeField(Types.INTEGER, "id", Long.class, "id")); 78 | jdbcType.setValueFields(new JdbcTypeField(Types.VARCHAR, "first_name", String.class, "firstName"), 79 | new JdbcTypeField(Types.VARCHAR, "last_name", String.class, "lastName"), 80 | new JdbcTypeField(Types.VARCHAR, "gender", Gender.class, "gender"), 81 | new JdbcTypeField(Types.VARCHAR, "country", String.class, "country"), 82 | new JdbcTypeField(Types.VARCHAR, "city", String.class, "city"), 83 | new JdbcTypeField(Types.VARCHAR, "address", String.class, "address"), 84 | new JdbcTypeField(Types.DATE, "birth_date", Date.class, "birthDate")); 85 | f.setTypes(jdbcType); 86 | ccfg.setCacheStoreFactory(f); 87 | 88 | cfg.setCacheConfiguration(ccfg, ccfg2); 89 | return Ignition.start(cfg); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/controller/ContactController.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.controller; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import pl.piomin.services.ignite.model.Contact; 14 | import pl.piomin.services.ignite.repository.ContactRepository; 15 | 16 | @RestController 17 | @RequestMapping("/contact") 18 | public class ContactController { 19 | 20 | @Autowired 21 | ContactRepository repository; 22 | 23 | @PostMapping 24 | public Contact add(@RequestBody Contact contact) { 25 | contact.init(); 26 | return repository.save(contact.getId(), contact); 27 | } 28 | 29 | @GetMapping("/{id}") 30 | public Contact findById(@PathVariable("id") Long id) { 31 | return repository.findById(id).orElse(null); 32 | } 33 | 34 | @GetMapping("/location/{location}") 35 | public List findById(@PathVariable("location") String location) { 36 | return repository.findByLocation(location); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/controller/PersonController.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.controller; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.Collectors; 6 | 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.DeleteMapping; 11 | import org.springframework.web.bind.annotation.GetMapping; 12 | import org.springframework.web.bind.annotation.PathVariable; 13 | import org.springframework.web.bind.annotation.PostMapping; 14 | import org.springframework.web.bind.annotation.PutMapping; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | import org.springframework.web.bind.annotation.RequestMapping; 17 | import org.springframework.web.bind.annotation.RestController; 18 | 19 | import pl.piomin.services.ignite.model.Contact; 20 | import pl.piomin.services.ignite.model.ContactType; 21 | import pl.piomin.services.ignite.model.Person; 22 | import pl.piomin.services.ignite.repository.PersonRepository; 23 | 24 | @RestController 25 | @RequestMapping("/person") 26 | public class PersonController { 27 | 28 | private static final Logger LOGGER = LoggerFactory.getLogger(PersonController.class); 29 | 30 | @Autowired 31 | PersonRepository repository; 32 | 33 | @PostMapping 34 | public Person add(@RequestBody Person person) { 35 | person.init(); 36 | return repository.save(person.getId(), person); 37 | } 38 | 39 | @PutMapping 40 | public Person update(@RequestBody Person person) { 41 | return repository.save(person.getId(), person); 42 | } 43 | 44 | @DeleteMapping("/{id}") 45 | public void delete(Long id) { 46 | repository.deleteById(id); 47 | } 48 | 49 | @GetMapping("/{id}") 50 | public Person findById(@PathVariable("id") Long id) { 51 | return repository.findById(id).orElse(null); 52 | } 53 | 54 | @GetMapping("/{firstName}/{lastName}") 55 | public List findByName(@PathVariable("firstName") String firstName, @PathVariable("lastName") String lastName) { 56 | return repository.findByFirstNameAndLastName(firstName, lastName); 57 | } 58 | 59 | @GetMapping("/contacts/{firstName}/{lastName}") 60 | public List findByNameWithContacts(@PathVariable("firstName") String firstName, @PathVariable("lastName") String lastName) { 61 | List persons = repository.findByFirstNameAndLastName(firstName, lastName); 62 | List contacts = repository.selectContacts(firstName, lastName); 63 | persons.stream().forEach(it -> it.setContacts(contacts.stream().filter(c -> c.getPersonId().equals(it.getId())).collect(Collectors.toList()))); 64 | LOGGER.info("PersonController.findByIdWithContacts: {}", contacts); 65 | return persons; 66 | } 67 | 68 | @GetMapping("/contacts2/{firstName}/{lastName}") 69 | public List findByNameWithContacts2(@PathVariable("firstName") String firstName, @PathVariable("lastName") String lastName) { 70 | List> result = repository.selectContacts2(firstName, lastName); 71 | List persons = new ArrayList<>(); 72 | for (List l : result) { 73 | persons.add(mapPerson(l)); 74 | } 75 | LOGGER.info("PersonController.findByIdWithContacts: {}", result); 76 | return persons; 77 | } 78 | 79 | private Person mapPerson(List l) { 80 | Person p = new Person(); 81 | Contact c = new Contact(); 82 | p.setId((Long) l.get(0)); 83 | p.setFirstName((String) l.get(1)); 84 | p.setLastName((String) l.get(2)); 85 | c.setId((Long) l.get(3)); 86 | c.setType((ContactType) l.get(4)); 87 | c.setLocation((String) l.get(4)); 88 | p.addContact(c); 89 | return p; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/model/Contact.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.model; 2 | 3 | import org.apache.ignite.cache.query.annotations.QuerySqlField; 4 | 5 | import java.io.Serializable; 6 | import java.util.concurrent.atomic.AtomicLong; 7 | 8 | public class Contact implements Serializable { 9 | 10 | private static final long serialVersionUID = -5350789537473512833L; 11 | private static final AtomicLong ID_GEN = new AtomicLong(); 12 | 13 | @QuerySqlField(index = true) 14 | private Long id; 15 | @QuerySqlField 16 | private ContactType type; 17 | @QuerySqlField(index = true) 18 | private String location; 19 | @QuerySqlField(index = true) 20 | private Long personId; 21 | 22 | public void init() { 23 | this.id = ID_GEN.incrementAndGet(); 24 | } 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | public ContactType getType() { 35 | return type; 36 | } 37 | 38 | public void setType(ContactType type) { 39 | this.type = type; 40 | } 41 | 42 | public String getLocation() { 43 | return location; 44 | } 45 | 46 | public void setLocation(String location) { 47 | this.location = location; 48 | } 49 | 50 | public Long getPersonId() { 51 | return personId; 52 | } 53 | 54 | public void setPersonId(Long personId) { 55 | this.personId = personId; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/model/ContactType.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.model; 2 | 3 | public enum ContactType { 4 | 5 | EMAIL, MOBILE, PHONE, SKYPE; 6 | } 7 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/model/Gender.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.model; 2 | 3 | public enum Gender { 4 | 5 | MALE, FEMALE; 6 | 7 | } 8 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/model/Person.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.model; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.Date; 6 | import java.util.List; 7 | import java.util.concurrent.atomic.AtomicLong; 8 | 9 | import org.apache.ignite.cache.query.annotations.QueryGroupIndex; 10 | import org.apache.ignite.cache.query.annotations.QuerySqlField; 11 | import org.springframework.data.annotation.Transient; 12 | 13 | @QueryGroupIndex.List( 14 | @QueryGroupIndex(name = "idx1") 15 | ) 16 | public class Person implements Serializable { 17 | 18 | private static final long serialVersionUID = -1271194616130404625L; 19 | private static final AtomicLong ID_GEN = new AtomicLong(); 20 | 21 | @QuerySqlField(index = true) 22 | private Long id; 23 | @QuerySqlField(index = true) 24 | @QuerySqlField.Group(name = "idx1", order = 0) 25 | private String firstName; 26 | @QuerySqlField(index = true) 27 | @QuerySqlField.Group(name = "idx1", order = 1) 28 | private String lastName; 29 | private Gender gender; 30 | private Date birthDate; 31 | private String country; 32 | private String city; 33 | private String address; 34 | @Transient 35 | private List contacts = new ArrayList<>(); 36 | 37 | public void init() { 38 | this.id = ID_GEN.incrementAndGet(); 39 | } 40 | 41 | public Long getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Long id) { 46 | this.id = id; 47 | } 48 | 49 | public String getFirstName() { 50 | return firstName; 51 | } 52 | 53 | public void setFirstName(String firstName) { 54 | this.firstName = firstName; 55 | } 56 | 57 | public String getLastName() { 58 | return lastName; 59 | } 60 | 61 | public void setLastName(String lastName) { 62 | this.lastName = lastName; 63 | } 64 | 65 | public Gender getGender() { 66 | return gender; 67 | } 68 | 69 | public void setGender(Gender gender) { 70 | this.gender = gender; 71 | } 72 | 73 | public Date getBirthDate() { 74 | return birthDate; 75 | } 76 | 77 | public void setBirthDate(Date birthDate) { 78 | this.birthDate = birthDate; 79 | } 80 | 81 | public String getCountry() { 82 | return country; 83 | } 84 | 85 | public void setCountry(String country) { 86 | this.country = country; 87 | } 88 | 89 | public String getCity() { 90 | return city; 91 | } 92 | 93 | public void setCity(String city) { 94 | this.city = city; 95 | } 96 | 97 | public String getAddress() { 98 | return address; 99 | } 100 | 101 | public void setAddress(String address) { 102 | this.address = address; 103 | } 104 | 105 | public List getContacts() { 106 | return contacts; 107 | } 108 | 109 | public void setContacts(List contacts) { 110 | this.contacts = contacts; 111 | } 112 | 113 | public void addContact(Contact contact) { 114 | this.contacts.add(contact); 115 | } 116 | 117 | @Override 118 | public int hashCode() { 119 | final int prime = 31; 120 | int result = 1; 121 | result = prime * result + ((id == null) ? 0 : id.hashCode()); 122 | return result; 123 | } 124 | 125 | @Override 126 | public boolean equals(Object obj) { 127 | if (this == obj) 128 | return true; 129 | if (obj == null) 130 | return false; 131 | if (getClass() != obj.getClass()) 132 | return false; 133 | Person other = (Person) obj; 134 | if (id == null) { 135 | if (other.id != null) 136 | return false; 137 | } else if (!id.equals(other.id)) 138 | return false; 139 | return true; 140 | } 141 | 142 | } 143 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/repository/ContactRepository.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.repository; 2 | 3 | import java.util.List; 4 | 5 | import org.apache.ignite.springdata.repository.IgniteRepository; 6 | import org.apache.ignite.springdata.repository.config.RepositoryConfig; 7 | 8 | //import org.apache.ignite.springdata22.repository.IgniteRepository; 9 | //import org.apache.ignite.springdata22.repository.config.RepositoryConfig; 10 | import pl.piomin.services.ignite.model.Contact; 11 | 12 | @RepositoryConfig(cacheName = "ContactCache") 13 | public interface ContactRepository extends IgniteRepository { 14 | 15 | List findByLocation(String location); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/java/pl/piomin/services/ignite/repository/PersonRepository.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.repository; 2 | 3 | import java.util.List; 4 | 5 | 6 | import org.apache.ignite.springdata.repository.IgniteRepository; 7 | import org.apache.ignite.springdata.repository.config.Query; 8 | import org.apache.ignite.springdata.repository.config.RepositoryConfig; 9 | import pl.piomin.services.ignite.model.Contact; 10 | import pl.piomin.services.ignite.model.Person; 11 | 12 | @RepositoryConfig(cacheName = "PersonCache") 13 | public interface PersonRepository extends IgniteRepository { 14 | 15 | List findByFirstNameAndLastName(String firstName, String lastName); 16 | 17 | @Query("SELECT c.* FROM Person p JOIN \"ContactCache\".Contact c ON p.id=c.personId WHERE p.firstName=? and p.lastName=?") 18 | List selectContacts(String firstName, String lastName); 19 | 20 | @Query("SELECT p.id, p.firstName, p.lastName, c.id, c.type, c.location FROM Person p JOIN \"ContactCache\".Contact c ON p.id=c.personId WHERE p.firstName=? and p.lastName=?") 21 | List> selectContacts2(String firstName, String lastName); 22 | } 23 | -------------------------------------------------------------------------------- /ignite-rest-service/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | application: 3 | name: ignite-rest-service 4 | datasource: 5 | name: mysqlds 6 | url: jdbc:mysql://localhost:3306/ignite?useSSL=false 7 | username: ignite 8 | password: ignite123 9 | 10 | server: 11 | port: ${PORT:8090} 12 | 13 | management: 14 | security: 15 | enabled: false -------------------------------------------------------------------------------- /ignite-rest-service/src/test/java/pl/piomin/services/ignite/controller/IgniteRestControllerTest.java: -------------------------------------------------------------------------------- 1 | package pl.piomin.services.ignite.controller; 2 | 3 | import org.springframework.boot.test.web.client.TestRestTemplate; 4 | import pl.piomin.services.ignite.model.Contact; 5 | import pl.piomin.services.ignite.model.ContactType; 6 | import pl.piomin.services.ignite.model.Gender; 7 | import pl.piomin.services.ignite.model.Person; 8 | 9 | import java.text.DecimalFormat; 10 | import java.util.Date; 11 | import java.util.Random; 12 | import java.util.concurrent.ExecutorService; 13 | import java.util.concurrent.Executors; 14 | import java.util.concurrent.TimeUnit; 15 | 16 | //@FixMethodOrder(MethodSorters.NAME_ASCENDING) 17 | public class IgniteRestControllerTest { 18 | 19 | // private static long index = 0; 20 | 21 | DecimalFormat f = new DecimalFormat("000000000"); 22 | 23 | // @Test 24 | public void testAddPerson() throws InterruptedException { 25 | ExecutorService es = Executors.newCachedThreadPool(); 26 | for (int j = 0; j < 10; j++) { 27 | es.execute(() -> { 28 | TestRestTemplate restTemplateLocal = new TestRestTemplate(); 29 | Random r = new Random(); 30 | for (int i = 0; i < 10000; i++) { 31 | Person p = restTemplateLocal.postForObject("http://localhost:8090/person", createTestPerson(), Person.class); 32 | int x = r.nextInt(6); 33 | for (int k = 0; k < x; k++) { 34 | restTemplateLocal.postForObject("http://localhost:8090/contact", createTestContact(p.getId()), Contact.class); 35 | } 36 | } 37 | }); 38 | } 39 | es.shutdown(); 40 | es.awaitTermination(10, TimeUnit.MINUTES); 41 | } 42 | 43 | // @Test 44 | public void testFindById() { 45 | TestRestTemplate restTemplate = new TestRestTemplate(); 46 | for (int i = 0; i < 1000; i++) { 47 | restTemplate.getForObject("http://localhost:8090/person/{id}", Person.class, i+1); 48 | } 49 | } 50 | 51 | // @Test 52 | public void testFindContactByLocation() { 53 | TestRestTemplate restTemplate = new TestRestTemplate(); 54 | Random r = new Random(); 55 | for (int i = 0; i < 1000; i++) { 56 | int n = r.nextInt(100000); 57 | restTemplate.getForObject("http://localhost:8090/contact/location/{location}", Contact[].class, "location-" + n); 58 | } 59 | } 60 | 61 | // @Test 62 | public void testFindByName() { 63 | TestRestTemplate restTemplate = new TestRestTemplate(); 64 | Random r = new Random(); 65 | for (int i = 0; i < 1000; i++) { 66 | int n = r.nextInt(100000); 67 | restTemplate.getForObject("http://localhost:8090/person/{firstName}/{lastName}", Person[].class, "Test" + n, "Test" + n); 68 | } 69 | } 70 | 71 | // @Test 72 | public void testFindByNameWithContacts() { 73 | TestRestTemplate restTemplate = new TestRestTemplate(); 74 | Random r = new Random(); 75 | for (int i = 0; i < 1000; i++) { 76 | int n = r.nextInt(100000); 77 | restTemplate.getForObject("http://localhost:8090/person/contacts/{firstName}/{lastName}", Person[].class, "Test" + n, "Test" + n); 78 | } 79 | } 80 | 81 | private Person createTestPerson() { 82 | Random r = new Random(); 83 | Person p = new Person(); 84 | int n = r.nextInt(100000); 85 | p.setFirstName("Test" + n); 86 | p.setLastName("Test" + n); 87 | p.setGender(Gender.values()[r.nextInt(2)]); 88 | p.setCountry("PL"); 89 | p.setCity("Test" + n); 90 | p.setBirthDate(new Date()); 91 | p.setAddress("Address " + n); 92 | return p; 93 | } 94 | 95 | private Contact createTestContact(Long personId) { 96 | Random r = new Random(); 97 | Contact c = new Contact(); 98 | c.setPersonId(personId); 99 | c.setType(ContactType.values()[r.nextInt(4)]); 100 | c.setLocation("location-" + f.format(r.nextInt())); 101 | return c; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /ignite-rest-service/src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | 5 | org.springframework.boot 6 | spring-boot-starter-parent 7 | 3.5.0 8 | 9 | 10 | pl.piomin.services 11 | sample-ignite-jpa 12 | 1.0-SNAPSHOT 13 | pom 14 | 15 | 16 | piomin_sample-ignite-jpa 17 | piomin 18 | https://sonarcloud.io 19 | 2.17.0 20 | 21 21 | 22 | 23 | 24 | ignite-rest-service 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## In-memory data grid with Apache Ignite [![Twitter](https://img.shields.io/twitter/follow/piotr_minkowski.svg?style=social&logo=twitter&label=Follow%20Me)](https://twitter.com/piotr_minkowski) 2 | 3 | [![CircleCI](https://circleci.com/gh/piomin/sample-ignite-jpa.svg?style=svg)](https://circleci.com/gh/piomin/sample-ignite-jpa) 4 | 5 | [![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-black.svg)](https://sonarcloud.io/dashboard?id=piomin_sample-ignite-jpa) 6 | [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=piomin_sample-ignite-jpa&metric=bugs)](https://sonarcloud.io/dashboard?id=piomin_sample-ignite-jpa) 7 | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=piomin_sample-ignite-jpa&metric=coverage)](https://sonarcloud.io/dashboard?id=piomin_sample-ignite-jpa) 8 | [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=piomin_sample-ignite-jpa&metric=ncloc)](https://sonarcloud.io/dashboard?id=piomin_sample-ignite-jpa) 9 | 10 | Detailed description can be found here: [In-memory data grid with Apache Ignite](https://piotrminkowski.com/2017/11/13/in-memory-data-grid-with-apache-ignite/) 11 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base",":dependencyDashboard" 5 | ], 6 | "packageRules": [ 7 | { 8 | "matchUpdateTypes": ["minor", "patch", "pin", "digest"], 9 | "automerge": true 10 | } 11 | ] 12 | } --------------------------------------------------------------------------------