Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f079c38
Done DTO classes
palonekdaniel Aug 18, 2016
0ac299e
Done mappers and repo
palonekdaniel Aug 19, 2016
92ef1fc
Skeleton of services
palonekdaniel Aug 19, 2016
3cb5f56
Basic main page
palonekdaniel Sep 3, 2016
75c77f1
Added registration, login, logout, working communication between fron…
palonekdaniel Sep 13, 2016
7acae8c
Added website panel, distributed cache, plenty of improvements
palonekdaniel Oct 6, 2016
7905623
Subpage bookmark started, improvenents
palonekdaniel Oct 10, 2016
7fa6b06
Missing files
palonekdaniel Oct 11, 2016
7ccd3de
Subpage bookmark almost done, upload and getting images,improves in c…
palonekdaniel Oct 21, 2016
c8a8ff3
Make grayscale subpage image
palonekdaniel Oct 23, 2016
1067c7c
Prepared cache operation for activity, made method for handling activ…
palonekdaniel Oct 28, 2016
04c1152
Done logging activity, show click map on subpage image, basic stats
palonekdaniel Nov 7, 2016
8a94a72
Added improvements in real-time showing click map na subpage
palonekdaniel Nov 15, 2016
c832c18
Almost done selecting date range of click map
palonekdaniel Nov 21, 2016
a796d38
Select date range is now done
palonekdaniel Nov 21, 2016
290336f
Statistic chart prepared, remained only provide data
palonekdaniel Dec 11, 2016
2cbc937
Done hourly and daily statistic chart
palonekdaniel Dec 13, 2016
89c0550
Preparing subpage capture with external API
palonekdaniel Dec 19, 2016
05d1012
Preparing multipart get request from back end
palonekdaniel Dec 20, 2016
8393305
Done adding subpage by external API
palonekdaniel Dec 21, 2016
6d106e4
Update build scripts
palonekdaniel Jan 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
C:\Users\DankessS\workspace\ClickMapActivity\.idea
\ClickMapActivity\.idea
/.idea/
\ClickMapActivity-web\src\main\resources\js\bower_components
18 changes: 18 additions & 0 deletions ClickMapActivity-cache/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
group 'com.academy.engineer'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'spring-boot'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}

dependencies {
compile 'com.hazelcast:hazelcast:3.7.1'
compile ("org.springframework.boot:spring-boot-starter-data-jpa")
compile ("org.springframework.boot:spring-boot-starter-web")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.academy.cache;

import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.ConcurrentMap;

/**
* Created by Daniel Palonek on 2016-09-17.
*/
public abstract class AbstractCacheSupplier {

@Autowired
private HazelcastInstance hazelcastInstance;

protected ConcurrentMap<String,Object> getUserContext() {
return hazelcastInstance.getUserContext();
}

protected IMap getMap(String mapName) {
return hazelcastInstance.getMap(mapName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.academy.cache;

/**
* Created by Daniel Palonek on 2016-09-05.
*/
public class CacheConstants {

static final String LOGGED_USERNAME = "loggedUsername";
static final String USER_WEBSITES = "userWebsites";
static final String REQUESTED_WEBSITE = "requestedWebsite";
static final String WEBSITE_SUBPAGES = "websiteSubpages";
static final String ACTIVITIES = "activities";
static final String POINTS = "points";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.academy.cache;

import com.hazelcast.config.Config;
import com.hazelcast.config.XmlConfigBuilder;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.FileNotFoundException;

/**
* Created by Daniel Palonek on 2016-09-05.
*/
@Configuration
public class HazelcastConfiguration {
@Bean
public HazelcastInstance config() {
return Hazelcast.newHazelcastInstance();
}
}
107 changes: 107 additions & 0 deletions ClickMapActivity-cache/src/main/java/com/academy/cache/UserCache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package com.academy.cache;

import org.springframework.stereotype.Component;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import static java.util.stream.StreamSupport.stream;

/**
* Created by Daniel Palonek on 2016-09-16.
*/
@Component
public class UserCache extends AbstractCacheSupplier {

public String getLoggedUsername() {
return (String)getUserContext().getOrDefault(CacheConstants.LOGGED_USERNAME,null);
}

public void setLoggedUsername(String username) {
getUserContext().put(CacheConstants.LOGGED_USERNAME,username);
}

public void removeLoggedUsername() {
getUserContext().remove(CacheConstants.LOGGED_USERNAME);
}

public void setUserWebsites(Iterable websites) {
getMap(CacheConstants.USER_WEBSITES).set(getLoggedUsername(),websites);
}

public Iterable getUserWebsites() {
return (Iterable)getMap(CacheConstants.USER_WEBSITES).get(getLoggedUsername());
}

public void removeUserWebsites() {
getMap(CacheConstants.USER_WEBSITES).remove(getLoggedUsername());
}

public void setRequestedWebsite(Object website) {
getUserContext().put(CacheConstants.REQUESTED_WEBSITE,website);
}

public Object getRequestedWebsite() {
return getUserContext().getOrDefault(CacheConstants.REQUESTED_WEBSITE,null);
}

public void setWebsiteSubpages(Long websiteId, Map<Long, Object> subpages) {
getMap(CacheConstants.WEBSITE_SUBPAGES).set(websiteId, subpages);
}

public void updateWebsiteSubpage(Long websiteId, Long subpageId, Object subpage) {
Map<Long, Object> subpages = (Map)getMap(CacheConstants.WEBSITE_SUBPAGES).get(websiteId);
if(subpages == null) {
subpages = new HashMap<>();
}
subpages.put(subpageId, subpage);
getMap(CacheConstants.WEBSITE_SUBPAGES).set(websiteId, subpages);
}

public Iterable getWebsiteSubpages(Long key) {
Map<Long, Object> subpages = (Map)getMap(CacheConstants.WEBSITE_SUBPAGES).get(key);
return subpages.entrySet().stream().map(Map.Entry::getValue).collect(Collectors.toList());
}

public void deleteWebsiteSubpages(Long websiteId) {
getMap(CacheConstants.WEBSITE_SUBPAGES).removeAsync(websiteId);
}

public void setSubpageActivities(Long subpageId, Iterable activities) {
getMap(CacheConstants.ACTIVITIES).set(subpageId,activities);
}

public synchronized void addSubpageActivity(Long subpageId, Object activity) {
Iterable values = (Iterable)getMap(CacheConstants.ACTIVITIES).get(subpageId);
if(values != null) {
List l = (List)StreamSupport.stream(values.spliterator(),false).collect(Collectors.toList());
l.add(activity);
getMap(CacheConstants.ACTIVITIES).set(subpageId, l);
} else {
List c = Arrays.asList(activity);
getMap(CacheConstants.ACTIVITIES).set(subpageId, c);
}
}

public Iterable getSubpageActivities(Long subpageId) {
return (Iterable)getMap(CacheConstants.ACTIVITIES).get(subpageId);
}

public void deleteSubpageActivities(Long subpageId) {
getMap(CacheConstants.ACTIVITIES).removeAsync(subpageId);
}

public void setActivityPoints(Long activityId, Iterable points) {
getMap(CacheConstants.POINTS).set(activityId, points);
}

public Iterable getActivityPoints(Long activityId) {
return (Iterable)getMap(CacheConstants.POINTS).get(activityId);
}

public void deleteActivityPoints(Long activityId) {
getMap(CacheConstants.POINTS).removeAsync(activityId);
}

}
192 changes: 192 additions & 0 deletions ClickMapActivity-cache/src/main/resources/hazelcast.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.7.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>dev</name>
<password>dev-pass</password>
</group>
<management-center enabled="false">http://localhost:8080/mancenter</management-center>
<network>
<port auto-increment="true" port-count="100">5701</port>
<outbound-ports>
<!--
Allowed port range when connecting to other nodes.
0 or * means use system provided port.
-->
<ports>0</ports>
</outbound-ports>
<join>
<multicast enabled="true">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="false">
<interface>127.0.0.1</interface>
<member-list>
<member>127.0.0.1</member>
</member-list>
</tcp-ip>
<aws enabled="false">
<access-key>my-access-key</access-key>
<secret-key>my-secret-key</secret-key>
<!--optional, default is us-east-1 -->
<region>us-west-1</region>
<!--optional, default is ec2.amazonaws.com. If set, region shouldn't be set as it will override this property -->
<host-header>ec2.amazonaws.com</host-header>
<!-- optional, only instances belonging to this group will be discovered, default will try all running instances -->
<security-group-name>hazelcast-sg</security-group-name>
<tag-key>type</tag-key>
<tag-value>hz-nodes</tag-value>
</aws>
<discovery-strategies>
</discovery-strategies>
</join>
<interfaces enabled="false">
<interface>10.10.1.*</interface>
</interfaces>
<ssl enabled="false"/>
<socket-interceptor enabled="false"/>
<symmetric-encryption enabled="false">
<!--
encryption algorithm such as
DES/ECB/PKCS5Padding,
PBEWithMD5AndDES,
AES/CBC/PKCS5Padding,
Blowfish,
DESede
-->
<algorithm>PBEWithMD5AndDES</algorithm>
<!-- salt value to use when generating the secret key -->
<salt>thesalt</salt>
<!-- pass phrase to use when generating the secret key -->
<password>thepass</password>
<!-- iteration count to use when generating the secret key -->
<iteration-count>19</iteration-count>
</symmetric-encryption>
</network>
<partition-group enabled="false"/>
<executor-service name="default">
<pool-size>16</pool-size>
<!--Queue capacity. 0 means Integer.MAX_VALUE.-->
<queue-capacity>0</queue-capacity>
</executor-service>
<queue name="default">
<!--
Maximum size of the queue. When a JVM's local queue size reaches the maximum,
all put/offer operations will get blocked until the queue size
of the JVM goes down below the maximum.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
-->
<max-size>0</max-size>
<!--
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. 0 means no backup.
-->
<backup-count>1</backup-count>

<!--
Number of async backups. 0 means no backup.
-->
<async-backup-count>0</async-backup-count>

<empty-queue-ttl>-1</empty-queue-ttl>
</queue>
<map name="userWebsites">
<in-memory-format>BINARY</in-memory-format>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<time-to-live-seconds>24000</time-to-live-seconds>
<max-idle-seconds>24000</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<max-size policy="PER_NODE">0</max-size>
<merge-policy>com.hazelcast.map.merge.PutIfAbsentMapMergePolicy</merge-policy>
<cache-deserialized-values>INDEX-ONLY</cache-deserialized-values>
</map>
<map name="websiteSubpages">
<in-memory-format>BINARY</in-memory-format>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<time-to-live-seconds>24000</time-to-live-seconds>
<max-idle-seconds>24000</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<max-size policy="PER_NODE">0</max-size>
<merge-policy>com.hazelcast.map.merge.PutIfAbsentMapMergePolicy</merge-policy>
<cache-deserialized-values>INDEX-ONLY</cache-deserialized-values>
</map>
<map name="activities">
<in-memory-format>BINARY</in-memory-format>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<time-to-live-seconds>24000</time-to-live-seconds>
<max-idle-seconds>24000</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<max-size policy="PER_NODE">0</max-size>
<merge-policy>com.hazelcast.map.merge.PutIfAbsentMapMergePolicy</merge-policy>
<cache-deserialized-values>INDEX-ONLY</cache-deserialized-values>
</map>
<map name="points">
<in-memory-format>BINARY</in-memory-format>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<time-to-live-seconds>24000</time-to-live-seconds>
<max-idle-seconds>24000</max-idle-seconds>
<eviction-policy>LRU</eviction-policy>
<max-size policy="PER_NODE">0</max-size>
<merge-policy>com.hazelcast.map.merge.PutIfAbsentMapMergePolicy</merge-policy>
<cache-deserialized-values>INDEX-ONLY</cache-deserialized-values>
</map>

<multimap name="default">
<backup-count>1</backup-count>
<value-collection-type>SET</value-collection-type>
</multimap>

<list name="default">
<backup-count>1</backup-count>
</list>

<set name="default">
<backup-count>1</backup-count>
</set>

<jobtracker name="default">
<max-thread-size>0</max-thread-size>
<!-- Queue size 0 means number of partitions * 2 -->
<queue-size>0</queue-size>
<retry-count>0</retry-count>
<chunk-size>1000</chunk-size>
<communicate-stats>true</communicate-stats>
<topology-changed-strategy>CANCEL_RUNNING_OPERATION</topology-changed-strategy>
</jobtracker>

<semaphore name="default">
<initial-permits>0</initial-permits>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
</semaphore>

<reliable-topic name="default">
<read-batch-size>10</read-batch-size>
<topic-overload-policy>BLOCK</topic-overload-policy>
<statistics-enabled>true</statistics-enabled>
</reliable-topic>

<ringbuffer name="default">
<capacity>10000</capacity>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<time-to-live-seconds>30</time-to-live-seconds>
<in-memory-format>BINARY</in-memory-format>
</ringbuffer>

<serialization>
<portable-version>0</portable-version>
</serialization>

<services enable-defaults="true"/>

<lite-member enabled="false"/>

</hazelcast>
Loading