Skip to content

Commit cc4d580

Browse files
committed
feat:add pika_migrate_unstable
1 parent abfaa02 commit cc4d580

420 files changed

Lines changed: 130008 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tools/include/acl.h

Lines changed: 435 additions & 0 deletions
Large diffs are not rendered by default.

tools/include/build_version.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved.
2+
// This source code is licensed under the BSD-style license found in the
3+
// LICENSE file in the root directory of this source tree. An additional grant
4+
// of patent rights can be found in the PATENTS file in the same directory.
5+
6+
#ifndef INCLUDE_BUILD_VERSION_H_
7+
#define INCLUDE_BUILD_VERSION_H_
8+
9+
// this variable tells us about the git revision
10+
extern const char* pika_build_git_sha;
11+
12+
// Date on which the code was compiled:
13+
extern const char* pika_build_compile_date;
14+
15+
#endif // INCLUDE_BUILD_VERSION_H_

tools/include/migrator_thread.h

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#ifndef MIGRATOR_THREAD_H_
2+
#define MIGRATOR_THREAD_H_
3+
4+
#include <iostream>
5+
#include <mutex>
6+
7+
#include "storage/storage.h"
8+
#include "net/include/redis_cli.h"
9+
10+
#include "include/redis_sender.h"
11+
12+
class MigratorThread : public net::Thread {
13+
public:
14+
MigratorThread(std::shared_ptr<storage::Storage> storage_, std::vector<std::shared_ptr<RedisSender>> *senders, int type, int thread_num) :
15+
storage_(storage_),
16+
should_exit_(false),
17+
senders_(senders),
18+
type_(type),
19+
thread_num_(thread_num),
20+
thread_index_(0),
21+
num_(0) {
22+
}
23+
24+
virtual ~ MigratorThread();
25+
26+
int64_t num() {
27+
std::lock_guard<std::mutex> l(num_mutex_);
28+
return num_;
29+
}
30+
31+
void Stop() {
32+
should_exit_ = true;
33+
}
34+
35+
private:
36+
void PlusNum() {
37+
std::lock_guard<std::mutex> l(num_mutex_);
38+
++num_;
39+
}
40+
41+
void DispatchKey(const std::string &command, const std::string& key = "");
42+
43+
void MigrateDB();
44+
void MigrateStringsDB();
45+
void MigrateListsDB();
46+
void MigrateHashesDB();
47+
void MigrateSetsDB();
48+
void MigrateZsetsDB();
49+
void MigrateStreamsDB();
50+
51+
virtual void *ThreadMain();
52+
53+
private:
54+
std::shared_ptr<storage::Storage> storage_;
55+
bool should_exit_;
56+
57+
std::vector<std::shared_ptr<RedisSender>> *senders_;
58+
int type_;
59+
int thread_num_;
60+
int thread_index_;
61+
62+
int64_t num_;
63+
std::mutex num_mutex_;
64+
};
65+
66+
#endif

tools/include/pika_acl.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) 2015-present, Qihoo, Inc. All rights reserved.
2+
// This source code is licensed under the BSD-style license found in the
3+
// LICENSE file in the root directory of this source tree. An additional grant
4+
// of patent rights can be found in the PATENTS file in the same directory.
5+
6+
// pika ACL command
7+
#ifndef PIKA_ACL_CMD_H
8+
#define PIKA_ACL_CMD_H
9+
10+
#include "include/pika_command.h"
11+
#include "include/pika_server.h"
12+
13+
extern PikaServer* g_pika_server;
14+
15+
class PikaAclCmd : public Cmd {
16+
public:
17+
PikaAclCmd(const std::string& name, int arity, uint32_t flag)
18+
: Cmd(name, arity, flag, static_cast<uint32_t>(AclCategory::ADMIN)) {
19+
subCmdName_ = {"cat", "deluser", "dryrun", "genpass", "getuser", "list", "load",
20+
"log", "save", "setuser", "users", "whoami", "help"};
21+
}
22+
void Do() override;
23+
void Split(const HintKeys& hint_keys) override{};
24+
void Merge() override{};
25+
Cmd* Clone() override { return new PikaAclCmd(*this); }
26+
27+
private:
28+
void DoInitial() override;
29+
void Clear() override {}
30+
31+
void Cat();
32+
void DelUser();
33+
void DryRun();
34+
void GenPass();
35+
void GetUser();
36+
void List();
37+
void Load();
38+
void Log();
39+
void Save();
40+
void SetUser();
41+
void Users();
42+
void WhoAmI();
43+
void Help();
44+
45+
std::string subCmd_;
46+
};
47+
48+
#endif // PIKA_ACL_CMD_H

0 commit comments

Comments
 (0)