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 292
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 all commits
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
46 changes: 46 additions & 0 deletions
46
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,46 @@ | ||
package org.zalando.nakadi.domain; | ||
|
||
import org.apache.zookeeper.ZKUtil; | ||
import org.apache.zookeeper.ZooKeeper; | ||
|
||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* If the amount of children in /nakadi/locks is so high that it can't be fetched by zookeeper client - then | ||
* this class should be run with VM parameter -Djute.maxbuffer=BUFFER_SIZE_BYTES where BUFFER_SIZE_BYTES should | ||
* be the value that will fit the list of nodes, for example 41943040 (40 MB) | ||
*/ | ||
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); | ||
|
||
System.out.println(locks.size() + "Waiting 70 seconds before fetching list of subscriptions..."); | ||
Thread.sleep(70000); // we need to wait here to avoid deletion of locks for just started subscriptions | ||
|
||
final Set<String> subscriptions = new HashSet<>(zk.getChildren(contextPath + "/nakadi/subscriptions", false)); | ||
System.out.println(locks.size() + " locks, " + subscriptions.size() + " subscriptions"); | ||
|
||
int notExists = 0; | ||
for (int i = 0; i < locks.size(); i++) { | ||
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(((i + 1) * 100 / locks.size()) + "%"); | ||
} | ||
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