This repository has been archived by the owner on Apr 22, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Use worker cleanup task instead of direct jedis cleanup #89
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
70332de
Use worker task instead of jedis cleanup
rajatparida86 395fd41
Use appropriate UUID, Constructor injection, Formatting
rajatparida86 694d3e1
Separate interface method for batch entity cleanup
rajatparida86 cd656a9
Batch entity cleanup
rajatparida86 3ef0d03
Add timelimit to redis payload
rajatparida86 9341fb7
Only cleanup if there is something to cleanup
rajatparida86 de70fb8
Use TR as the prefix of task ID
rajatparida86 d0fd7e0
Review comments
rajatparida86 4228868
Only execute batch cleanup in remote schedulers
rajatparida86 886ba7b
Log entity counts
rajatparida86 6f5c0a7
Differentiate between Global and Local scheduler
rajatparida86 ea90f38
unit tests for cleanup and global scheduler
rajatparida86 8537001
Fix test method name to camel case
rajatparida86 5802283
Fix camel case for missed method
rajatparida86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/de/zalando/zmon/scheduler/ng/cleanup/BatchEntityCleanup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.zalando.zmon.scheduler.ng.cleanup; | ||
|
||
import de.zalando.zmon.scheduler.ng.entities.Entity; | ||
import de.zalando.zmon.scheduler.ng.entities.EntityChangeListener; | ||
import de.zalando.zmon.scheduler.ng.entities.EntityRepository; | ||
import de.zalando.zmon.scheduler.ng.scheduler.Scheduler; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.Set; | ||
|
||
public class BatchEntityCleanup implements EntityChangeListener { | ||
private Scheduler scheduler; | ||
private final static Logger LOG = LoggerFactory.getLogger(BatchEntityCleanup.class); | ||
|
||
public BatchEntityCleanup(Scheduler scheduler) { | ||
this.scheduler = scheduler; | ||
} | ||
|
||
@Override | ||
public void notifyEntityChange(EntityRepository repo, Entity entityOld, Entity entityNew) { | ||
|
||
} | ||
|
||
@Override | ||
public void notifyEntityRemove(EntityRepository repo, Entity e) { | ||
} | ||
|
||
@Override | ||
public void notifyBatchEntityRemove(EntityRepository repo, Set<String> removedEntities) { | ||
scheduler.scheduleEntityCleanUp(removedEntities); | ||
LOG.info("Batch cleanup scheduled for {} entities", removedEntities.size()); | ||
} | ||
|
||
@Override | ||
public void notifyEntityAdd(EntityRepository repo, Entity e) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,12 @@ | |
|
||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.concurrent.ScheduledThreadPoolExecutor; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.stream.Collectors; | ||
|
||
import de.zalando.zmon.scheduler.ng.scheduler.Scheduler; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
@@ -18,14 +20,18 @@ | |
import de.zalando.zmon.scheduler.ng.entities.Entity; | ||
import de.zalando.zmon.scheduler.ng.entities.EntityChangeListener; | ||
import de.zalando.zmon.scheduler.ng.entities.EntityRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import redis.clients.jedis.Jedis; | ||
import redis.clients.jedis.JedisPool; | ||
import redis.clients.jedis.JedisPoolConfig; | ||
|
||
/** | ||
* Created by jmussler on 30.06.16. | ||
*/ | ||
public class SingleEntityCleanup implements EntityChangeListener{ | ||
public class SingleEntityCleanup implements EntityChangeListener { | ||
|
||
@Autowired | ||
private Scheduler scheduler; | ||
|
||
private final static Logger LOG = LoggerFactory.getLogger(SingleEntityCleanup.class); | ||
|
||
|
@@ -56,6 +62,9 @@ public void notifyEntityRemove(EntityRepository repo, Entity e) { | |
executor.schedule(new EntityCleanupTask(e), 300, TimeUnit.SECONDS); | ||
} | ||
|
||
@Override | ||
public void notifyBatchEntityRemove (EntityRepository repo, Set<String> removedEntities) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, but it sounds semantically incorrect to have batch operation method in a class called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The EntityRepository only allows listeners of type |
||
|
||
@Override | ||
public void notifyEntityAdd(EntityRepository repo, Entity e) { | ||
|
||
|
23 changes: 23 additions & 0 deletions
23
src/main/java/de/zalando/zmon/scheduler/ng/config/BatchEntityCleanupConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package de.zalando.zmon.scheduler.ng.config; | ||
|
||
import de.zalando.zmon.scheduler.ng.cleanup.BatchEntityCleanup; | ||
import de.zalando.zmon.scheduler.ng.entities.EntityRepository; | ||
import de.zalando.zmon.scheduler.ng.scheduler.Scheduler; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
|
||
@Configuration | ||
public class BatchEntityCleanupConfiguration { | ||
private static final Logger LOG = LoggerFactory.getLogger(BatchEntityCleanupConfiguration.class); | ||
|
||
@Bean | ||
BatchEntityCleanup getBatchEntityCleanup(Scheduler scheduler, EntityRepository entityRepository) { | ||
LOG.info("Registering BatchEntityCleanup job"); | ||
BatchEntityCleanup cleanup = new BatchEntityCleanup(scheduler); | ||
entityRepository.registerListener(cleanup); | ||
return cleanup; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's error-prone to have
interval
aslong
. E.g. ifinterval == Long.MAX_VALUE
, what do you expectinterval * 1000
to be equal to? I'd changeinterval
toint
and maybe rename it some way to clarify it's in seconds...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexkorotkikh this piece of code was previously there. Only formatting changes were introduced by me. I understand your point. However, I would solve this in another PR rather than using this PR to solve it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, I was inattentive. Sorry about that.