Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<organization>
Expand Down Expand Up @@ -102,7 +103,8 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
101 changes: 76 additions & 25 deletions src/main/java/org/woehlke/twitterwall/ScheduledTasks.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,88 @@
@Component
public class ScheduledTasks {

@Scheduled(initialDelay= TEN_SECONDS, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS)
@Scheduled(initialDelay= TEN_SECONDS, fixedRate = ONE_DAY)
public void createImprintUserAsync(){
String msg = "create Imprint User (Async) ";
if(!schedulerProperties.getSkipFortesting()) {
Task task = asyncStartTask.createImprintUserAsync();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS * 2, fixedRate = FIVE_MINUTES)
public void fetchTweetsFromTwitterSearch() {
String msg = "fetch Tweets From TwitterSearch ";
if((schedulerProperties.getAllowUpdateTweets()) && (!schedulerProperties.getSkipFortesting())) {
if((schedulerProperties.getAllowFetchTweetsFromTwitterSearch()) && (!schedulerProperties.getSkipFortesting())) {
Task task = asyncStartTask.fetchTweetsFromSearch();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS *2, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_USER_LIST)
@Scheduled(initialDelay= TEN_SECONDS * 3, fixedRate = TWELVE_HOURS)
public void fetchUsersFromDefinedUserList(){
String msg = "fetch Users from Defined User List ";
if((schedulerProperties.getFetchUserListAllow()) && (!schedulerProperties.getSkipFortesting())) {
if((schedulerProperties.getFetchUsersFromDefinedUserListAllow()) && (!schedulerProperties.getSkipFortesting())) {
Task task = asyncStartTask.fetchUsersFromList();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS *3, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_FOLLOWER)
@Scheduled(initialDelay= TEN_SECONDS * 4, fixedRate = TWELVE_HOURS)
public void getHomeTimeline() {
String msg = "get Home Timeline Tweets ";
if((schedulerProperties.getAllowGetHomeTimeline()) && (!schedulerProperties.getSkipFortesting())) {
Task task = asyncStartTask.getHomeTimeline();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS * 5, fixedRate = TWELVE_HOURS)
public void getUserTimeline() {
String msg = " get User Timeline Tweets ";
if((schedulerProperties.getAllowGetUserTimeline()) && (!schedulerProperties.getSkipFortesting())) {
Task task = asyncStartTask.getUserTimeline();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS * 6, fixedRate = TWELVE_HOURS)
public void getMentions() {
String msg = " get Mentions ";
if((schedulerProperties.getAllowGetMentions()) && (!schedulerProperties.getSkipFortesting())) {
Task task = asyncStartTask.getMentions();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS * 7, fixedRate = TWELVE_HOURS)
public void getFavorites() {
String msg = " get Favorites ";
if((schedulerProperties.getAllowGetFavorites()) && (!schedulerProperties.getSkipFortesting())) {
Task task = asyncStartTask.getFavorites();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS * 8, fixedRate = TWELVE_HOURS)
public void getRetweetsOfMe() {
String msg = " get Retweets Of Me ";
if((schedulerProperties.getAllowGetRetweetsOfMe()) && (!schedulerProperties.getSkipFortesting())) {
Task task = asyncStartTask.getRetweetsOfMe();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS * 9, fixedRate = TWELVE_HOURS)
public void getLists() {
String msg = " get Lists ";
if((schedulerProperties.getAllowGetLists()) && (!schedulerProperties.getSkipFortesting())) {
Task task = asyncStartTask.getLists();
log.info(msg+ "SCHEDULED: task "+task.getUniqueId());
}
}

@Scheduled(initialDelay= TEN_SECONDS * 10, fixedRate = ONE_DAY)
public void fetchFollower(){
String msg = "fetch Follower ";
if((schedulerProperties.getFetchFollowerAllow()) && (!schedulerProperties.getSkipFortesting())) {
Expand All @@ -42,7 +105,7 @@ public void fetchFollower(){
}
}

@Scheduled(initialDelay= TEN_SECONDS *4, fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_FRIENDS)
@Scheduled(initialDelay= TEN_SECONDS * 11, fixedRate = ONE_DAY)
public void fetchFriends(){
String msg = "fetch Friends ";
if((schedulerProperties.getFetchFriendsAllow()) && (!schedulerProperties.getSkipFortesting())) {
Expand All @@ -51,7 +114,7 @@ public void fetchFriends(){
}
}

@Scheduled(initialDelay= TEN_SECONDS *5, fixedRate = FIXED_RATE_FOR_SCHEDULAR_REMOVE_OLD_DATA_FROM_STORAGE)
@Scheduled(initialDelay= TEN_SECONDS * 12, fixedRate = ONE_HOUR)
public void removeOldDataFromStorage(){
String msg = "remove Old Data From Storage: ";
if((schedulerProperties.getRemoveOldDataFromStorageAllow()) && (!schedulerProperties.getSkipFortesting())) {
Expand All @@ -60,7 +123,7 @@ public void removeOldDataFromStorage(){
}
}

@Scheduled(initialDelay= TEN_SECONDS *6, fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER_BY_MENTION)
@Scheduled(initialDelay= TEN_SECONDS * 13, fixedRate = ONE_HOUR)
public void updateUserProfilesFromMentions(){
String msg = "update User Profiles From Mentions";
if((schedulerProperties.getAllowUpdateUserProfilesFromMention()) && (!schedulerProperties.getSkipFortesting())) {
Expand All @@ -69,7 +132,7 @@ public void updateUserProfilesFromMentions(){
}
}

@Scheduled(initialDelay= TEN_SECONDS *7, fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_TWEETS)
@Scheduled(initialDelay= TEN_SECONDS * 14, fixedRate = ONE_DAY)
public void updateTweets() {
String msg = "update Tweets ";
if((schedulerProperties.getAllowUpdateTweets()) && (!schedulerProperties.getSkipFortesting())){
Expand All @@ -78,7 +141,7 @@ public void updateTweets() {
}
}

@Scheduled(initialDelay= TEN_SECONDS *8, fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER)
@Scheduled(initialDelay= TEN_SECONDS * 15, fixedRate = ONE_DAY)
public void updateUserProfiles() {
String msg = "update User Profiles ";
if((schedulerProperties.getAllowUpdateUserProfiles()) && (!schedulerProperties.getSkipFortesting())) {
Expand All @@ -97,25 +160,13 @@ public ScheduledTasks(SchedulerProperties schedulerProperties, AsyncStartTask mq

public final static long ONE_MINUTE = 60 * 1000;

public final static long FIVE_MINUTES = 5 * ONE_MINUTE;

public final static long ONE_HOUR = 60 * ONE_MINUTE;

public final static long TWELVE_HOURS = 12 * ONE_HOUR;

private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS = ONE_HOUR;

private final static long FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER = TWELVE_HOURS;

private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_FOLLOWER = TWELVE_HOURS;

private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_FRIENDS = TWELVE_HOURS;

private final static long FIXED_RATE_FOR_SCHEDULAR_UPDATE_TWEETS = TWELVE_HOURS;

private final static long FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER_BY_MENTION = ONE_HOUR;

private final static long FIXED_RATE_FOR_SCHEDULAR_FETCH_USER_LIST = TWELVE_HOURS;

private final static long FIXED_RATE_FOR_SCHEDULAR_REMOVE_OLD_DATA_FROM_STORAGE = ONE_HOUR;
public final static long ONE_DAY = 24 * ONE_HOUR;

private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ public class SchedulerProperties {
private Boolean skipFortesting;

@NotNull
private Boolean fetchUserListAllow;
private Boolean fetchUsersFromDefinedUserListAllow;

@NotNull
private String fetchUserListName;
private String fetchUsersFromDefinedUserListName;

@NotNull
private Boolean removeOldDataFromStorageAllow;
Expand All @@ -45,6 +45,24 @@ public class SchedulerProperties {
@NotNull
private Boolean fetchFriendsAllow;

@NotNull
private Boolean allowGetHomeTimeline;

@NotNull
private Boolean allowGetUserTimeline;

@NotNull
private Boolean allowGetMentions;

@NotNull
private Boolean allowGetFavorites;

@NotNull
private Boolean allowGetRetweetsOfMe;

@NotNull
private Boolean allowGetLists;

public Boolean getAllowFetchTweetsFromTwitterSearch() {
return allowFetchTweetsFromTwitterSearch;
}
Expand Down Expand Up @@ -93,20 +111,20 @@ public void setSkipFortesting(Boolean skipFortesting) {
this.skipFortesting = skipFortesting;
}

public Boolean getFetchUserListAllow() {
return fetchUserListAllow;
public Boolean getFetchUsersFromDefinedUserListAllow() {
return fetchUsersFromDefinedUserListAllow;
}

public void setFetchUserListAllow(Boolean fetchUserListAllow) {
this.fetchUserListAllow = fetchUserListAllow;
public void setFetchUsersFromDefinedUserListAllow(Boolean fetchUsersFromDefinedUserListAllow) {
this.fetchUsersFromDefinedUserListAllow = fetchUsersFromDefinedUserListAllow;
}

public String getFetchUserListName() {
return fetchUserListName;
public String getFetchUsersFromDefinedUserListName() {
return fetchUsersFromDefinedUserListName;
}

public void setFetchUserListName(String fetchUserListName) {
this.fetchUserListName = fetchUserListName;
public void setFetchUsersFromDefinedUserListName(String fetchUsersFromDefinedUserListName) {
this.fetchUsersFromDefinedUserListName = fetchUsersFromDefinedUserListName;
}

public Boolean getRemoveOldDataFromStorageAllow() {
Expand All @@ -132,4 +150,52 @@ public void setFetchFriendsAllow(Boolean fetchFriendsAllow) {
public Boolean getFetchFriendsAllow() {
return fetchFriendsAllow;
}

public Boolean getAllowGetHomeTimeline() {
return allowGetHomeTimeline;
}

public void setAllowGetHomeTimeline(Boolean allowGetHomeTimeline) {
this.allowGetHomeTimeline = allowGetHomeTimeline;
}

public Boolean getAllowGetUserTimeline() {
return allowGetUserTimeline;
}

public void setAllowGetUserTimeline(Boolean allowGetUserTimeline) {
this.allowGetUserTimeline = allowGetUserTimeline;
}

public Boolean getAllowGetMentions() {
return allowGetMentions;
}

public void setAllowGetMentions(Boolean allowGetMentions) {
this.allowGetMentions = allowGetMentions;
}

public Boolean getAllowGetFavorites() {
return allowGetFavorites;
}

public void setAllowGetFavorites(Boolean allowGetFavorites) {
this.allowGetFavorites = allowGetFavorites;
}

public Boolean getAllowGetRetweetsOfMe() {
return allowGetRetweetsOfMe;
}

public void setAllowGetRetweetsOfMe(Boolean allowGetRetweetsOfMe) {
this.allowGetRetweetsOfMe = allowGetRetweetsOfMe;
}

public Boolean getAllowGetLists() {
return allowGetLists;
}

public void setAllowGetLists(Boolean allowGetLists) {
this.allowGetLists = allowGetLists;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
import org.woehlke.twitterwall.frontend.controller.common.Symbols;
import org.woehlke.twitterwall.frontend.controller.common.ControllerHelper;
import org.woehlke.twitterwall.oodm.entities.parts.CountedEntities;
import org.woehlke.twitterwall.oodm.service.CountedEntitiesService;

/**
* Created by tw on 03.07.17.
Expand All @@ -17,18 +15,6 @@
@RequestMapping(path="/application")
public class ApplicationController {

@RequestMapping(path="/domain/count")
public String domainCount(Model model) {
String msg = "/application/domain/count: ";
String title = "Counted Entities";
String subtitle = twitterProperties.getSearchQuery();
String symbol = Symbols.DATABASE.toString();
model = controllerHelper.setupPage(model,title,subtitle,symbol);
CountedEntities countedEntities =this.countedEntitiesService.countAll();
model.addAttribute("countedEntities", countedEntities);
return "application/domain/count";
}

@RequestMapping(path="/management")
public String managementPage(Model model) {
String msg = "/application/domain/count: ";
Expand All @@ -39,30 +25,14 @@ public String managementPage(Model model) {
return "application/management";
}

@RequestMapping(path="/domain/delete/all")
public String domainDeleteAll(Model model) {
String msg = "/application/domain/delete/all: ";
String title = "Counted Entities";
String subtitle = twitterProperties.getSearchQuery();
String symbol = Symbols.DATABASE.toString();
model = controllerHelper.setupPage(model,title,subtitle,symbol);
CountedEntities countedEntities =this.countedEntitiesService.deleteAll();
model.addAttribute("countedEntities", countedEntities);
return "application/domain/count";
}

private final CountedEntitiesService countedEntitiesService;

private final ControllerHelper controllerHelper;

private final TwitterProperties twitterProperties;

@Autowired
public ApplicationController(
CountedEntitiesService countedEntitiesService,
ControllerHelper controllerHelper,
TwitterProperties twitterProperties) {
this.countedEntitiesService = countedEntitiesService;
this.controllerHelper = controllerHelper;
this.twitterProperties = twitterProperties;
}
Expand Down
Loading