forked from memcached/mc-crusher
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathslab-tosser
More file actions
executable file
·41 lines (31 loc) · 912 Bytes
/
slab-tosser
File metadata and controls
executable file
·41 lines (31 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/perl
use warnings;
use strict;
use IO::Socket::INET;
use FindBin;
@ARGV == 2
or die "Usage: $FindBin::Script slabmin slabmax\n";
my $addr = "127.0.0.1:11211";
my $slabmin = $ARGV[0];
my $slabmax = $ARGV[1];
my $sock = IO::Socket::INET->new(PeerAddr => $addr,
Timeout => 3);
die "$!\n" unless $sock;
$|++;
while (1) {
my @slabs = (0, 0);
for (0 .. 1) {
while ($slabs[$_] == 0) {
my $rand = int(rand($slabmax))+1;
next if $rand < $slabmin;
next if $rand == $slabs[0];
$slabs[$_] = $rand;
}
}
print $sock "slabs reassign $slabs[0] $slabs[1]\r\n";
# print "slabs reassign $slabs[0] $slabs[1]\r\n";
my $res = scalar <$sock>;
# print "slabs reassign $slabs[0] $slabs[1]: $res" if $res !~ m/^OK/;
print "slabs reassign $slabs[0] $slabs[1]: $res";
sleep 1;
}