Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

Use worker cleanup task instead of direct jedis cleanup #89

Merged
merged 14 commits into from
Jun 26, 2019

Conversation

rajatparida86
Copy link
Contributor

Relates to #87

@rajatparida86 rajatparida86 changed the title Use worker task instead of jedis cleanup Use worker cleanup task instead of direct jedis cleanup Jan 7, 2019
public byte[] writeCleanUp(Set<String> removedIds){
CeleryBody body = new CeleryBody();

body.task= "cleanup";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that we don't have a linter for java projects yet, but what do you think if we'll try to follow some basic formatting rules, common for most languages? Like spaces before and after = and + for example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

@@ -24,6 +25,9 @@
@Component
public class EntityRepository extends CachedRepository<String, EntityAdapterRegistry, Entity> {

@Autowired
Scheduler scheduler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice is to use constructor injection over field or setter injection (e.g. https://www.vojtechruzicka.com/field-dependency-injection-considered-harmful/)

@rajatparida86
Copy link
Contributor Author

@alexkorotkikh could you review please?

@codecov
Copy link

codecov bot commented Jan 8, 2019

Codecov Report

Merging #89 into master will increase coverage by 0.67%.
The diff coverage is 50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #89      +/-   ##
============================================
+ Coverage     19.95%   20.63%   +0.67%     
- Complexity      152      159       +7     
============================================
  Files            92       94       +2     
  Lines          2290     2331      +41     
  Branches        232      234       +2     
============================================
+ Hits            457      481      +24     
- Misses         1795     1812      +17     
  Partials         38       38
Impacted Files Coverage Δ Complexity Δ
...alando/zmon/scheduler/ng/DataCenterSubscriber.java 0% <0%> (ø) 0 <0> (ø) ⬇️
.../zmon/scheduler/ng/cleanup/BatchEntityCleanup.java 0% <0%> (ø) 0 <0> (?)
...mon/scheduler/ng/cleanup/EntityChangedCleaner.java 65.62% <0%> (-2.12%) 3 <0> (ø)
...zmon/scheduler/ng/cleanup/SingleEntityCleanup.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...ler/ng/config/BatchEntityCleanupConfiguration.java 0% <0%> (ø) 0 <0> (?)
.../java/de/zalando/zmon/scheduler/ng/CeleryBody.java 66.66% <100%> (+2.38%) 1 <0> (ø) ⬇️
...zalando/zmon/scheduler/ng/scheduler/Scheduler.java 48.62% <100%> (+1.45%) 12 <1> (+1) ⬆️
...e/zalando/zmon/scheduler/ng/CommandSerializer.java 54.87% <78.94%> (+7.73%) 4 <2> (+1) ⬆️
...o/zmon/scheduler/ng/entities/EntityRepository.java 60.83% <83.33%> (+1.18%) 26 <0> (+3) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d41f40...5802283. Read the comment docs.

Copy link
Contributor

@alexkorotkikh alexkorotkikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

vetinari added a commit to zalando-zmon/zmon-worker that referenced this pull request Jan 9, 2019
@@ -65,6 +65,10 @@
public int priority = 1;
public String team;
}

public static class EntityCleanUpArg{
Copy link
Contributor

@alexkorotkikh alexkorotkikh Jan 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EntityCleanUpArg<space>{

@@ -24,21 +21,43 @@ public CommandSerializer(TaskSerializerType type, Tracer tracer) {
}

public String expiresTime(long interval) {
Date exp = new Date(System.currentTimeMillis()+(interval * 1000L));
Date exp = new Date(System.currentTimeMillis() + (interval * 1000L));
Copy link
Contributor

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 as long. E.g. if interval == Long.MAX_VALUE, what do you expect interval * 1000 to be equal to? I'd change interval to int and maybe rename it some way to clarify it's in seconds...

Copy link
Contributor Author

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

Copy link
Contributor

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.

public void notifyEntityRemove(EntityRepository repo, Entity e) {
}

public BatchEntityCleanup(Scheduler scheduler) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constructor usually goes before methods in class declaration

@@ -27,6 +30,9 @@
*/
public class SingleEntityCleanup implements EntityChangeListener{
Copy link
Contributor

@alexkorotkikh alexkorotkikh Jan 9, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EntityChangeListener<space>{

@@ -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) {}
Copy link
Contributor

Choose a reason for hiding this comment

The 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 SingleEntityCleanup. Did you think about introducing new Listener interface? Like BatchEntityChangeListener

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,7 +1,10 @@
package de.zalando.zmon.scheduler.ng.entities;

import com.codahale.metrics.MetricRegistry;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these imports added?

Copy link
Contributor

@alexkorotkikh alexkorotkikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

verify(listener).notifyEntityChange(eq(repository), eq(host1), eq(host1_changed));
}

@Test
public void TestNotifyGlobalScheduler() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not typical in java for method names to start from capital case

mohabusama pushed a commit to zalando-zmon/zmon-worker that referenced this pull request Apr 5, 2019
* cleanup entities task

see also zalando-zmon/zmon-scheduler#89

* finish span...

* fix span?

* fix span?

* log_kv requires dict
@rajatparida86
Copy link
Contributor Author

👍

@mohabusama
Copy link
Contributor

👍

@rajatparida86 rajatparida86 merged commit e056554 into master Jun 26, 2019
@pitr pitr deleted the entity_cleanup branch June 27, 2019 14:40
@vetinari vetinari restored the entity_cleanup branch July 3, 2019 11:03
@pitr pitr deleted the entity_cleanup branch October 1, 2019 12:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants