improving some disque samples

This commit is contained in:
zsx 2015-05-07 14:51:46 +08:00
parent 0efff4dbe5
commit 3724809b41
10 changed files with 68 additions and 17 deletions

View File

@ -154,7 +154,7 @@ public:
* HTTP
* HttpServletResponse::write(const void*, size_t)
* 使 chunked
* 0
* buf.empty() == true
* @param buf {const string&}
* @return {bool} false
*/

View File

@ -141,16 +141,18 @@ int main(void)
```
### add acl disque to your projects
Before you use the acl disque, you should compile the three base libraries which disque depending on. Enter the lib_acl, lib_protocol, lib_acl_cpp, and build the lib_acl.a, lib_protocol.a and lib_acl_cpp.a.
Before you use the acl disque, you should compile the three base libraries which disque depending on. Enter the ** lib_acl, lib_protocol, lib_acl_cpp,** and build the lib_acl.a, lib_protocol.a and lib_acl_cpp.a.
```compile
$cd lib_acl; make
$cd lib_protocol; make
$cd lib_acl_cpp; make
```
#### On UNIX/LINUX
In your Makefile, you should add below compiling flags:
-DLINUX2 for LINUX, -DFREEBSD for FreeBSD, -DMACOSX for MAXOS, -DSUNOS5 for Solaris X86;
-I path specify the lib_acl.hpp's parent path, for exmaple: -I./lib_acl_cpp/include, in the lib_acl_cpp/include path the acl_cpp path should be included;
At last, link with -L{path_to_acl_cpp} -l_acl_cpp -L{path_to_protocol} -l_protocol -L{path_to_acl) -l_acl
At last, link with ** -L{path_to_acl_cpp} -l_acl_cpp -L{path_to_protocol} -l_protocol -L{path_to_acl) -l_acl **
Of couse you can look at the Makefile.in in lib_acl_cpp\samples and Makfile in lib_acl_cpp\samples\disque\ to find the build conditions.
One Makefile as below:
```Makefile
@ -169,7 +171,7 @@ main.o: main.cpp
gcc $(CFLAGS) main.cpp -o main.o
```
### On WIN32
Open acl_cpp_vc2003.sln/acl_cpp_vc2008.sln/acl_cpp_vc2010.sln/acl_cpp_vc2012.sln, and looat at the disque samples project option setting.
Open acl_cpp_vc2003.sln/acl_cpp_vc2008.sln/acl_cpp_vc2010.sln/acl_cpp_vc2012.sln, and look at at the disque samples project option setting.
## reference
- disque include in acl: [disque include files](../../include/acl_cpp/disque/)

View File

@ -271,6 +271,16 @@ static void usage(const char* procname)
"-C [if need ackjob for getjob]\r\n"
"-a cmd[addjob|getjob|qlen|qpeek|show|ackjob|fastack|enqueue|dequeue|deljob|info|hello]\r\n",
procname);
printf("sample:\r\n"
"%s -s 127.0.0.1:7711 -n 10000 -D 1 -R 2 -r 1 -T 1000 -M 1000000 -a addjob\r\n"
"%s -s 127.0.0.1:7711 -n 10000 -a getjob\r\n"
"%s -s 127.0.0.1:7711 -n 10000 -a getjob -C\r\n"
"%s -s 127.0.0.1:7711 -n 10 -a qlen\r\n"
"%s -s 127.0.0.1:7711 -n 100 -a qpeek\r\n"
"%s -s 127.0.0.1:7711 -n 1 -a info\r\n"
"%s -s 127.0.0.1:7711 -n 1 -a hello\r\n",
procname, procname, procname, procname, procname, procname, procname);
}
int main(int argc, char* argv[])

View File

@ -1,3 +1,3 @@
#!/bin/sh
valgrind --tool=memcheck --leak-check=yes -v ./disque_client -s 127.0.0.1:7711 -a all -n 10
valgrind --tool=memcheck --leak-check=yes -v ./disque_client -s 127.0.0.1:7711 -a addjob -n 10000

View File

@ -196,6 +196,13 @@ static void usage(const char* procname)
"-A [async]\r\n"
"-a cmd[addjob|getjob|qlen|qpeek]\r\n",
procname);
printf("sample:\r\n"
"%s -s \"127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713\" -n 10000 -c 10 -D 1 -R 2 -M 1000000 -A -a addjob\r\n"
"%s -s \"127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713\" -n 10000 -c 10 -a getjob\r\n"
"%s -s \"127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713\" -n 1 -c 10 -a qlen\r\n"
"%s -s \"127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713\" -n 1 -c 10 -a qpeek\r\n",
procname, procname, procname, procname);
}
int main(int argc, char* argv[])

View File

@ -195,7 +195,7 @@ private:
static void usage(const char* procname)
{
printf("usage: %s -h[help]\r\n"
"-s redis_addr[127.0.0.1:6379]\r\n"
"-s redis_addr_list[127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713]\r\n"
"-n count[default: 10]\r\n"
"-C connect_timeout[default: 10]\r\n"
"-I rw_timeout[default: 10]\r\n"
@ -208,6 +208,13 @@ static void usage(const char* procname)
"-A [async]\r\n"
"-a cmd[addjob|getjob|qlen|qpeek]\r\n",
procname);
printf("sample:\r\n"
"%s -s \"127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713\" -n 10000 -c 10 -D 1 -R 2 -M 1000000 -A -a addjob\r\n"
"%s -s \"127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713\" -n 10000 -c 10 -a getjob\r\n"
"%s -s \"127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713\" -n 1 -c 10 -a qlen\r\n"
"%s -s \"127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713\" -n 1 -c 10 -a qpeek\r\n",
procname, procname, procname, procname);
}
int main(int argc, char* argv[])
@ -215,7 +222,7 @@ int main(int argc, char* argv[])
int ch, n = 1, conn_timeout = 10, rw_timeout = 10;
int max_threads = 10;
acl::disque_cond cond;
acl::string addr("127.0.0.1:6379"), cmd;
acl::string addr_list("127.0.0.1:7711, 127.0.0.1:7712, 127.0.0.1:7713"), cmd;
while ((ch = getopt(argc, argv, "hs:n:C:I:c:a:D:R:r:T:M:A")) > 0)
{
@ -225,7 +232,7 @@ int main(int argc, char* argv[])
usage(argv[0]);
return 0;
case 's':
addr = optarg;
addr_list = optarg;
break;
case 'n':
n = atoi(optarg);
@ -267,8 +274,18 @@ int main(int argc, char* argv[])
acl::acl_cpp_init();
if (addr_list.empty())
{
usage(argv[0]);
return 1;
}
acl::disque_client_cluster manager(conn_timeout, rw_timeout);
manager.set(addr.c_str(), max_threads);
const std::vector<acl::string>& tokens = addr_list.split2(";, \t");
std::vector<acl::string>::const_iterator cit;
for (cit = tokens.begin(); cit != tokens.end(); ++cit)
manager.set((*cit).c_str(), max_threads);
std::vector<test_thread*> threads;
for (int i = 0; i < max_threads; i++)

View File

@ -1,3 +1,3 @@
#!/bin/sh
valgrind --tool=memcheck --leak-check=yes -v ./disque_manager -s 127.0.0.1:7711 -a all -n 10 -c 10
valgrind --tool=memcheck --leak-check=yes -v ./disque_manager -s 127.0.0.1:7711 -a addjob -n 10 -c 10

View File

@ -186,13 +186,26 @@ private:
static void usage(const char* procname)
{
printf("usage: %s -h[help]\r\n"
"-s redis_addr[127.0.0.1:6379]\r\n"
"-s redis_addr[127.0.0.1:7711]\r\n"
"-n count[default: 10]\r\n"
"-C connect_timeout[default: 10]\r\n"
"-I rw_timeout[default: 10]\r\n"
"-c max_threads[default: 10]\r\n"
"-D delay\r\n"
"-R replicate\r\n"
"-r retry\r\n"
"-T ttl\r\n"
"-M maxlen\r\n"
"-A [async]\r\n"
"-a cmd[addjob|getjob|qlen|qpeek]\r\n",
procname);
printf("sample:\r\n"
"%s -s 127.0.0.1:7711 -n 10000 -c 10 -D 1 -R 2 -M 1000000 -A -a addjob\r\n"
"%s -s 127.0.0.1:7711 -n 10000 -c 10 -a getjob\r\n"
"%s -s 127.0.0.1:7711 -n 1 -c 10 -a qlen\r\n"
"%s -s 127.0.0.1:7711 -n 1 -c 10 -a qpeek\r\n",
procname, procname, procname, procname);
}
int main(int argc, char* argv[])

View File

@ -1,3 +1,3 @@
#!/bin/sh
valgrind --tool=memcheck --leak-check=yes -v ./disque_pool -s 127.0.0.1:7711 -a all -n 10 -c 10
valgrind --tool=memcheck --leak-check=yes -v ./disque_pool -s 127.0.0.1:7711 -a addjob -n 10 -c 10

View File

@ -8,9 +8,9 @@ The header files of acl redis are in lib_acl_cpp\include\acl_cpp\redis; the sour
Because acl redis lib is a part of lib_acl_cpp lib, and lib_acl_cpp depend lib_acl and lib_protocol, you should compile lib_acl and lib_protocol libs first, and compile lib_acl_cpp lib. After you've compiled lib_acl_cpp lib, the redis lib is also compiled OK.
### compile on UNIX/LINUX
- 1 compile lib_acl.a: Enter into lib_acl path and type make, the lib_acl.a will be compiled
- 2 compile lib_protocol.a: Enter into lib_protocol path and type make, the lib_protocol.a will be compiled
- 3 compile lib_acl_cpp.a: Enter into lib_acl_cpp path and type make, the lib_acl_cpp.a will be compiled
- 1 compile ** lib_acl.a **: Enter into lib_acl path and type make, the lib_acl.a will be compiled
- 2 compile ** lib_protocol.a **: Enter into lib_protocol path and type make, the lib_protocol.a will be compiled
- 3 compile ** lib_acl_cpp.a **: Enter into lib_acl_cpp path and type make, the lib_acl_cpp.a will be compiled
- 4 compile redis samples: Enter into lib_acl_cpp\samples\redis and type make, all the redis samples(including redis_cluster, redis_connection, redis_hash, redis_hyperloglog, redis_key, redis_lib, redis_manager, redis_pool, redis_pubsub, redis_server, redis_set, redis_string, redis_trans, redis_zset, redis_zset_pool, redis_client_cluster) will be compiled.
### compile on WINDOWS
@ -214,10 +214,12 @@ int main(void)
```
### add acl redis to your projects
Before you use the acl redis, you should compile the three base libraries which redis depending on. Enter the lib_acl, lib_protocol, lib_acl_cpp, and build the lib_acl.a, lib_protocol.a and lib_acl_cpp.a.
Before you use the acl redis, you should compile the three base libraries which redis depending on. Enter the lib_acl, lib_protocol, lib_acl_cpp, and build the ** lib_acl.a, lib_protocol.a and lib_acl_cpp.a **.
```compile
$cd lib_acl; make
$cd lib_protocol; make
$cd lib_acl_cpp; make
```
#### On UNIX/LINUX
In your Makefile, you should add below compiling flags:
@ -242,7 +244,7 @@ main.o: main.cpp
gcc $(CFLAGS) main.cpp -o main.o
```
### On WIN32
Open acl_cpp_vc2003.sln/acl_cpp_vc2008.sln/acl_cpp_vc2010.sln/acl_cpp_vc2012.sln, and looat at the redis samples project option setting.
Open acl_cpp_vc2003.sln/acl_cpp_vc2008.sln/acl_cpp_vc2010.sln/acl_cpp_vc2012.sln, and look at at the redis samples project option setting.
## reference
- redis include in acl: [redis include files](../../include/acl_cpp/redis/)