~yolanda.robla/ubuntu/trusty/memcached/add_distribution

« back to all changes in this revision

Viewing changes to scripts/memcached-tool

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2009-08-01 23:26:45 UTC
  • mto: (3.3.1 squeeze) (1.4.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20090801232645-g57xdaf3zal53qcl
Tags: upstream-1.4.0
Import upstream version 1.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
       memcached-tool 10.0.0.5:11211 display    # shows slabs
42
42
       memcached-tool 10.0.0.5:11211            # same.  (default is display)
43
43
       memcached-tool 10.0.0.5:11211 stats      # shows general stats
 
44
       memcached-tool 10.0.0.5:11211 dump       # dumps keys and values
44
45
       memcached-tool 10.0.0.5:11211 move 7 9   # takes 1MB slab from class #7
45
46
                                                # to class #9.
46
47
 
47
 
You can only move slabs around once memory is totally allocated, and only
 
48
You can only move slabs around on a server that supports 'slabs reassign'
 
49
messages and only once slab memory is totally allocated, and only
48
50
once the target class is full.  (So you can't move from #6 to #9 and #7
49
51
to #9 at the same itme, since you'd have to wait for #9 to fill from
50
52
the first reassigned page)
77
79
 
78
80
            print "Page busy, retrying...\n";
79
81
            sleep 1;
 
82
        } elsif ($res =~ "CLIENT_ERROR") {
 
83
            print "Error: CLIENT_ERROR; perhaps slab reassignment is not enabled.\n";
 
84
        exit;
80
85
        }
81
86
    }
82
87
 
102
107
 
103
108
    foreach my $bucket (sort(keys(%items))) {
104
109
        print STDERR "Dumping bucket $bucket - " . $items{$bucket} . " total items\n";
105
 
        print $sock "stats cachedump $bucket $items{$bucket} 1\r\n";
 
110
        print $sock "stats cachedump $bucket $items{$bucket}\r\n";
106
111
        my %keyexp;
107
112
        while (<$sock>) {
108
113
            last if /^END/;
114
119
        }
115
120
 
116
121
        foreach my $k (keys(%keyexp)) {
117
 
            my $val;
118
122
            print $sock "get $k\r\n";
119
123
            my $response = <$sock>;
120
 
            $response =~ /VALUE (\S+) (\d+) (\d+)/;
121
 
            my $flags = $2;
122
 
            my $len = $3;
123
 
            read $sock, $val , $len;
124
 
            # get the END
125
 
            $_ = <$sock>;
126
 
            $_ = <$sock>;
127
 
            print "add $k $flags $keyexp{$k} $len\r\n$val\r\n";
 
124
            if ($response =~ /VALUE (\S+) (\d+) (\d+)/) {
 
125
                my $flags = $2;
 
126
                my $len = $3;
 
127
                my $val;
 
128
                read $sock, $val, $len;
 
129
                print "add $k $flags $keyexp{$k} $len\r\n$val\r\n";
 
130
                # get the END
 
131
                $_ = <$sock>;
 
132
                $_ = <$sock>;
 
133
            }
128
134
        }
129
135
    }
130
136
    exit;