This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 293
ARUHA-2328: added tmp script for removing locks of deleted subscriptions; #1057
Open
v-stepanov
wants to merge
4
commits into
master
Choose a base branch
from
ARUHA-2328
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
36 changes: 36 additions & 0 deletions
36
src/test/java/org/zalando/nakadi/domain/SubscriptionLocksCleaner.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,36 @@ | ||
package org.zalando.nakadi.domain; | ||
|
||
import org.apache.zookeeper.ZKUtil; | ||
import org.apache.zookeeper.ZooKeeper; | ||
|
||
import java.util.List; | ||
|
||
public class SubscriptionLocksCleaner { | ||
|
||
public static void main(String args[]) throws Exception { | ||
ZooKeeper zk = new ZooKeeper("localhost:2181", 30000, event -> { | ||
}); | ||
|
||
final String contextPath = "/staging"; | ||
|
||
final List<String> locks = zk.getChildren(contextPath + "/nakadi/locks", false); | ||
final List<String> subscriptions = zk.getChildren(contextPath + "/nakadi/subscriptions", false); | ||
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. 10000 subscriptions, 100000 locks. It makes sense to use HashSet for subscriptions |
||
System.out.println(locks.size() + " locks, " + subscriptions.size() + " subscriptions"); | ||
|
||
int notExists = 0; | ||
for (int i = 0; i < locks.size(); i++) { | ||
System.out.println((i * 100 / (locks.size() - 1)) + "%"); | ||
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. Division by zero 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. And it reports 100 before executing action |
||
|
||
String lockName = locks.get(i); | ||
final String subscriptionId = lockName.substring(13); | ||
|
||
if (!subscriptions.contains(subscriptionId)) { | ||
ZKUtil.deleteRecursive(zk, contextPath + "/nakadi/locks/" + lockName); | ||
System.out.println("Removed lock for " + subscriptionId + " as it doesn't exist"); | ||
notExists++; | ||
} | ||
} | ||
System.out.println("Exist: " + (locks.size() - notExists) + ", Removed: " + notExists); | ||
} | ||
|
||
} |
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.
Please document additional VM arguments that should be used to run this thing.
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.
Done.
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.
e082c89