├── Makefile ├── README ├── client ├── c │ ├── Makefile │ ├── client.c │ └── httpsqs_client.c ├── httpsqs4j │ ├── .classpath │ ├── .project │ ├── .settings │ │ └── org.eclipse.jdt.core.prefs │ ├── bin │ │ └── com │ │ │ └── daguu │ │ │ └── lib │ │ │ └── httpsqs4j │ │ │ ├── Httpsqs4j.class │ │ │ ├── HttpsqsClient.class │ │ │ ├── HttpsqsException.class │ │ │ ├── HttpsqsStatus.class │ │ │ └── Test.class │ ├── doc │ │ ├── allclasses-frame.html │ │ ├── allclasses-noframe.html │ │ ├── com │ │ │ └── daguu │ │ │ │ └── lib │ │ │ │ └── httpsqs4j │ │ │ │ ├── Httpsqs4j.html │ │ │ │ ├── HttpsqsClient.html │ │ │ │ ├── HttpsqsException.html │ │ │ │ ├── HttpsqsStatus.html │ │ │ │ ├── Test.html │ │ │ │ ├── class-use │ │ │ │ ├── Httpsqs4j.html │ │ │ │ ├── HttpsqsClient.html │ │ │ │ ├── HttpsqsException.html │ │ │ │ ├── HttpsqsStatus.html │ │ │ │ └── Test.html │ │ │ │ ├── package-frame.html │ │ │ │ ├── package-summary.html │ │ │ │ ├── package-tree.html │ │ │ │ └── package-use.html │ │ ├── constant-values.html │ │ ├── deprecated-list.html │ │ ├── help-doc.html │ │ ├── index-files │ │ │ ├── index-1.html │ │ │ ├── index-10.html │ │ │ ├── index-11.html │ │ │ ├── index-2.html │ │ │ ├── index-3.html │ │ │ ├── index-4.html │ │ │ ├── index-5.html │ │ │ ├── index-6.html │ │ │ ├── index-7.html │ │ │ ├── index-8.html │ │ │ └── index-9.html │ │ ├── index.html │ │ ├── overview-tree.html │ │ ├── package-list │ │ ├── resources │ │ │ └── inherit.gif │ │ ├── serialized-form.html │ │ └── stylesheet.css │ ├── output │ │ └── httpsqs4j.jar │ └── src │ │ └── com │ │ └── daguu │ │ └── lib │ │ └── httpsqs4j │ │ ├── Httpsqs4j.java │ │ ├── HttpsqsClient.java │ │ ├── HttpsqsException.java │ │ ├── HttpsqsStatus.java │ │ └── Test.java ├── java │ ├── Httpsqs_client.java │ └── Test.java ├── perl │ ├── HttpSQS.pm │ ├── License │ ├── README │ ├── Version │ ├── httpsqs_cmdline_loop_test.pl │ └── httpsqs_cmdline_test.pl └── php │ ├── httpsqs_client.php │ ├── test_commandline.php │ └── test_example.php ├── db_tcdb.c ├── db_ydb.c ├── httpsqs.c ├── httpsqs.h ├── properties.c ├── properties.h ├── rbtree.c └── rbtree.h /Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS=-Wall -I../ydb/root -ggdb -O0 2 | LDFLAGS=-L../ydb/root -lydb -levent 3 | 4 | all: httpsqs 5 | 6 | httpsqs: db_ydb.o httpsqs.o rbtree.o 7 | $(CXX) -o httpsqs $+ $(LDFLAGS) 8 | 9 | clean: 10 | rm -f httpsqs *.o 11 | 12 | install: httpsqs 13 | install $(INSTALL_FLAGS) -m 4755 -o root httpsqs $(DESTDIR)/usr/bin 14 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | HTTPSQS is a Simple Queue Service based on HTTP GET/POST protocol. 2 | This is free software, and you are welcome to modify and redistribute it under the New BSD License. 3 | 4 | This is a fork of Zhang Yan's original HTTPSQS project with an aim to clean up and modularize 5 | code so new backend storage types can be experimented with. 6 | 7 | The current revision users YDB instead of Tokyo Cabinet. 8 | 9 | Changes in this fork: 10 | --------------------- 11 | * All informational responses are in JSON 12 | * UIDs are 64bit integers, rather than the original cyclic IDs 13 | * Queue information is stored in-memory and not persisted 14 | 15 | Features which will be implemented: 16 | ----------------------------------- 17 | * Pluggable storage backends allowing for YDB, TokyoCabinet, filesystem etc. 18 | * Queue information will be persisted, allowing for restarts & crashes 19 | 20 | 21 | References: 22 | ----------- 23 | YDB - http://code.google.com/p/ydb/ 24 | Tokyo Cabinet - http://www.1978th.net/tokyocabinet/ 25 | Original HTTPSQS - http://code.google.com/p/httpsqs/ 26 | -------------------------------------------------------------------------------- /client/c/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for httpsqs_client 2 | CC=gcc 3 | 4 | httpsqs_client: httpsqs_client.c 5 | $(CC) httpsqs_client.c -o httpsqs_client 6 | 7 | clean: httpsqs_client 8 | rm -f httpsqs_client 9 | 10 | install: httpsqs_client 11 | install -m 4755 -o root httpsqs_client $(DESTDIR)/usr/bin 12 | -------------------------------------------------------------------------------- /client/c/client.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/c/client.c -------------------------------------------------------------------------------- /client/c/httpsqs_client.c: -------------------------------------------------------------------------------- 1 | /* 2 | *本程序用C语言作为Linux守护进程 3 | *实现每秒读取队列内容平且POST发送给处理端(例如PHP程序) 4 | *可以修改处理队列数据部分的代码实现其他的数据处理 5 | *本程序只是一个最初级的作品,本人的C语言水平也很低(在写这个程序前还不会C语言的socket发送HTTP请求) 6 | *希望张宴大哥给予指正与修改,体现我们开源的优势~哈哈 7 | * 8 | *使用方法: 9 | *make 10 | *make install 11 | *httpsqs_client -q your_queue_name -t 20(每秒获取队列的次数) 12 | * 13 | *作者:李博 lb13810398408@gmail.com 14 | */ 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #define HttpsqsIp "192.168.1.102" 30 | #define HttpsqsPort 1218 31 | 32 | #define RemoteIp "xxx.xxx.xxx.xxx"//本程序获取队列后的处理是将数据POST给PHP程序 用户可以自行修改那一部分 33 | #define RemotePort 80 34 | 35 | void init_daemon(void); 36 | 37 | 38 | void init_daemon(void) 39 | { 40 | int pid; 41 | int i; 42 | if(pid = fork()) 43 | exit(0); 44 | else if(pid < 0) 45 | exit(1); 46 | setsid(); 47 | 48 | if(pid = fork()) 49 | exit(0); 50 | else if(pid < 0) 51 | exit(1); 52 | 53 | for(i = 0; i < NOFILE; ++i) 54 | close(i); 55 | chdir("/var"); 56 | umask(0); 57 | return; 58 | } 59 | 60 | int htconnect(char *domain,int port) 61 | { 62 | int white_sock; 63 | struct hostent * site; 64 | struct sockaddr_in me; 65 | site = gethostbyname(domain); 66 | if(site == NULL) return -2; 67 | white_sock = socket(AF_INET,SOCK_STREAM, 0); 68 | if(white_sock < 0) return -1; 69 | memset(&me, 0, sizeof(struct sockaddr_in)); 70 | memcpy(&me.sin_addr, site->h_addr_list[0], site->h_length); 71 | me.sin_family = AF_INET; 72 | me.sin_port = htons(port); 73 | return (connect(white_sock, (struct sockaddr *)&me, sizeof(struct sockaddr)) < 0) ? -1 : white_sock; 74 | } 75 | 76 | int htsend(int sock,char *fmt,...) 77 | { 78 | char BUF[1024]; 79 | va_list argptr; 80 | va_start(argptr, fmt); 81 | vsprintf(BUF,fmt, argptr); 82 | va_end(argptr); 83 | return send(sock, BUF, strlen(BUF), 0); 84 | } 85 | 86 | int httpsqs_get(char *queuename) 87 | { 88 | int black_sock; 89 | 90 | black_sock = htconnect(HttpsqsIp, HttpsqsPort); 91 | if (black_sock < 0) return; 92 | 93 | htsend(black_sock, "GET /?charset=utf-8&name=%s&opt=get HTTP/1.1\r\n", queuename, 10); 94 | htsend(black_sock, "Host: %s\r\n", HttpsqsIp, 10); 95 | htsend(black_sock, "Connection: close\r\n", 10); 96 | htsend(black_sock, "\r\n", 10); 97 | 98 | return black_sock; 99 | } 100 | 101 | int http_post(char *datastr) 102 | { 103 | int black_sock; 104 | int len = 0; 105 | 106 | black_sock = htconnect(RemoteIp, RemotePort); 107 | if (black_sock < 0) return; 108 | len = strlen(datastr) + 5; 109 | htsend(black_sock, "POST /index.php?m=feed&a=feed_add HTTP/1.1\r\n", 10); 110 | htsend(black_sock, "Content-type: application/x-www-form-urlencoded\r\n", 10); 111 | htsend(black_sock, "Host: www.oooffice.com\r\n", 10); 112 | htsend(black_sock, "Content-Length: %d\r\n", len, 10); 113 | htsend(black_sock, "Connection: close\r\n", 10); 114 | htsend(black_sock, "\r\n", 10); 115 | htsend(black_sock, "data=%s", datastr, 10); 116 | 117 | return black_sock; 118 | } 119 | 120 | void process(char *queuename, int loop) 121 | { 122 | FILE * fp; 123 | int black_sock; 124 | char data[3]; 125 | char posstr[15]; 126 | char datastr[2000]; 127 | char post[5000]; 128 | int i = 0; 129 | int j = 0; 130 | int len = 0; 131 | int flag = 0; 132 | 133 | char pos[10]; 134 | int p = 0; 135 | 136 | loop --; 137 | while(loop) 138 | { 139 | memset(data, 0, strlen(data)); 140 | memset(datastr, 0, strlen(datastr)); 141 | memset(pos, 0, strlen(pos)); 142 | 143 | black_sock = httpsqs_get(queuename); 144 | 145 | i = 0; 146 | j = 0; 147 | 148 | while (read(black_sock, data, 1) > 0) 149 | { 150 | if(j == 3) 151 | { 152 | if(data[0] == 'P') 153 | flag = 1; 154 | if(flag == 1) 155 | { 156 | i++; 157 | if(i >= 6) 158 | posstr[i-6] = data[0]; 159 | } 160 | } 161 | if(j == 4 && strlen(posstr) > 2) 162 | { 163 | for(i = 0; i < strlen(posstr)-2; i++) 164 | pos[i] = posstr[i]; 165 | pos[strlen(pos)] = '\0'; 166 | i = 0; 167 | if(strlen(pos) > 0) 168 | flag = 2; 169 | } 170 | if(flag == 2 && strlen(pos) > 0) 171 | { 172 | if(j == 8) 173 | { 174 | datastr[i] = data[0]; 175 | i++; 176 | } 177 | } 178 | if(data[0] == '\n') 179 | j ++; 180 | } 181 | if(strlen(datastr) > 0) 182 | datastr[strlen(datastr)] = '\0'; 183 | 184 | if(strlen(datastr) > 0 && strlen(pos) > 0) 185 | printf("POS:%s\nDATA:%s\n", pos, datastr); 186 | 187 | close(black_sock); 188 | memset(data, 0, strlen(data)); 189 | 190 | if(strlen(datastr) > 0 && strlen(pos) > 0) 191 | { 192 | p = atoi(pos); 193 | 194 | if((fp = fopen("httpsqs_feed.log", "a")) >= 0) 195 | fprintf(fp, "GET FROM HTTPSQS:\r\nPOS:%d\nDATA:%s\r\n", p, datastr); 196 | 197 | //这部分是获取队列内容后的操作部分,queuedata为队列内容,p为队列的Pos 198 | black_sock = http_post(datastr); 199 | 200 | i = 0; 201 | while (read(black_sock, data, 1)>0) 202 | { 203 | if(data[0] == '|') 204 | { 205 | if(post[i-1] == 'D' && post[i-2] == 'N' && post[i-3] == 'E') 206 | { 207 | post[i-3] = '\0'; 208 | break; 209 | } 210 | } 211 | post[i] = data[0]; 212 | i++; 213 | } 214 | memset(data, 0, strlen(data)); 215 | close(black_sock); 216 | if(strlen(post)) 217 | { 218 | if(fp >=0) 219 | { 220 | strcpy(post, strstr(post, "Array")); 221 | fprintf(fp, "POST TO REMOTE\r\n%s\r\n", post); 222 | fclose(fp); 223 | } 224 | } 225 | } 226 | 227 | memset(post, 0, strlen(post)); 228 | loop --; 229 | } 230 | return; 231 | } 232 | 233 | int main(int argc,char **argv) 234 | { 235 | char queuename[20]; 236 | int loop; 237 | 238 | if(argc <= 4 || strcmp(argv[1], "-q") != 0 || strcmp(argv[3], "-t") != 0) 239 | { 240 | printf("You should run program like:\n"); 241 | printf("%s -q queuename -t timespersec\n", argv[0]); 242 | return; 243 | } 244 | 245 | strcpy(queuename, argv[2]); 246 | loop = atoi(argv[4]); 247 | 248 | if(loop < 1) 249 | { 250 | printf("The -t(times per second) must be an int number & > 0\n"); 251 | return; 252 | } 253 | 254 | init_daemon(); 255 | 256 | while(1) 257 | { 258 | sleep(1); 259 | process(queuename, loop); 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /client/httpsqs4j/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /client/httpsqs4j/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Httpsqs4j 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /client/httpsqs4j/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | #Thu Apr 29 11:07:00 CST 2010 2 | eclipse.preferences.version=1 3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.6 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.6 13 | -------------------------------------------------------------------------------- /client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/Httpsqs4j.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/Httpsqs4j.class -------------------------------------------------------------------------------- /client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/HttpsqsClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/HttpsqsClient.class -------------------------------------------------------------------------------- /client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/HttpsqsException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/HttpsqsException.class -------------------------------------------------------------------------------- /client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/HttpsqsStatus.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/HttpsqsStatus.class -------------------------------------------------------------------------------- /client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/httpsqs4j/bin/com/daguu/lib/httpsqs4j/Test.class -------------------------------------------------------------------------------- /client/httpsqs4j/doc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | All Classes 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | All Classes 21 |
22 | 23 | 24 | 25 | 36 | 37 |
Httpsqs4j 26 |
27 | HttpsqsClient 28 |
29 | HttpsqsException 30 |
31 | HttpsqsStatus 32 |
33 | Test 34 |
35 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | All Classes 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | All Classes 21 |
22 | 23 | 24 | 25 | 36 | 37 |
Httpsqs4j 26 |
27 | HttpsqsClient 28 |
29 | HttpsqsException 30 |
31 | HttpsqsStatus 32 |
33 | Test 34 |
35 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/com/daguu/lib/httpsqs4j/class-use/Httpsqs4j.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Uses of Class com.daguu.lib.httpsqs4j.Httpsqs4j 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Class
com.daguu.lib.httpsqs4j.Httpsqs4j

85 |
86 | No usage of com.daguu.lib.httpsqs4j.Httpsqs4j 87 |

88 |


89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 110 | 113 | 114 | 115 | 116 | 119 | 135 | 136 |
111 | 112 |
137 | 138 | 139 | 140 |
141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/com/daguu/lib/httpsqs4j/class-use/HttpsqsClient.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Uses of Class com.daguu.lib.httpsqs4j.HttpsqsClient 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Class
com.daguu.lib.httpsqs4j.HttpsqsClient

85 |
86 | 87 | 88 | 89 | 91 | 92 |
90 | Uses of HttpsqsClient in com.daguu.lib.httpsqs4j
93 |   94 |

95 | 96 | 97 | 98 | 99 | 100 | 101 | 103 | 107 | 108 |
Methods in com.daguu.lib.httpsqs4j that return HttpsqsClient
102 | static HttpsqsClientHttpsqs4j.createNewClient() 104 | 105 |
106 |           创建新的客户端对象
109 |   110 |

111 |


112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 133 | 136 | 137 | 138 | 139 | 142 | 158 | 159 |
134 | 135 |
160 | 161 | 162 | 163 |
164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/com/daguu/lib/httpsqs4j/class-use/HttpsqsStatus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Uses of Class com.daguu.lib.httpsqs4j.HttpsqsStatus 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Class
com.daguu.lib.httpsqs4j.HttpsqsStatus

85 |
86 | 87 | 88 | 89 | 91 | 92 |
90 | Uses of HttpsqsStatus in com.daguu.lib.httpsqs4j
93 |   94 |

95 | 96 | 97 | 98 | 99 | 100 | 101 | 103 | 107 | 108 |
Methods in com.daguu.lib.httpsqs4j that return HttpsqsStatus
102 |  HttpsqsStatusHttpsqsClient.getStatus(java.lang.String queueName) 104 | 105 |
106 |           获取HttpSQS状态
109 |   110 |

111 |


112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 133 | 136 | 137 | 138 | 139 | 142 | 158 | 159 |
134 | 135 |
160 | 161 | 162 | 163 |
164 | 165 | 166 | 167 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/com/daguu/lib/httpsqs4j/class-use/Test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Uses of Class com.daguu.lib.httpsqs4j.Test 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Class
com.daguu.lib.httpsqs4j.Test

85 |
86 | No usage of com.daguu.lib.httpsqs4j.Test 87 |

88 |


89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 110 | 113 | 114 | 115 | 116 | 119 | 135 | 136 |
111 | 112 |
137 | 138 | 139 | 140 |
141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/com/daguu/lib/httpsqs4j/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | com.daguu.lib.httpsqs4j 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | com.daguu.lib.httpsqs4j 21 | 22 | 23 | 34 | 35 |
24 | Classes  25 | 26 |
27 | Httpsqs4j 28 |
29 | HttpsqsClient 30 |
31 | HttpsqsStatus 32 |
33 | Test
36 | 37 | 38 | 39 | 40 | 45 | 46 |
41 | Exceptions  42 | 43 |
44 | HttpsqsException
47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/com/daguu/lib/httpsqs4j/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | com.daguu.lib.httpsqs4j 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |

83 | Package com.daguu.lib.httpsqs4j 84 |

85 | 86 | 87 | 88 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 |
89 | Class Summary
Httpsqs4jHttpsqs4j基础类,用于设置连接信息及创建客户端对象
HttpsqsClient客户端类,使用Httpsqs4j类的createNewClient()方法创建,创建前请先调用Httpsqs4j的setConnectionInfo设置连接信息
HttpsqsStatus 
Test 
108 |   109 | 110 |

111 | 112 | 113 | 114 | 116 | 117 | 118 | 119 | 120 | 121 |
115 | Exception Summary
HttpsqsException 
122 |   123 | 124 |

125 |

126 |
127 |
128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 149 | 152 | 153 | 154 | 155 | 158 | 174 | 175 |
150 | 151 |
176 | 177 | 178 | 179 |
180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/com/daguu/lib/httpsqs4j/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | com.daguu.lib.httpsqs4j Class Hierarchy 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Hierarchy For Package com.daguu.lib.httpsqs4j 85 |

86 |
87 |

88 | Class Hierarchy 89 |

90 |
    91 |
  • java.lang.Object
      92 |
    • com.daguu.lib.httpsqs4j.Httpsqs4j
    • com.daguu.lib.httpsqs4j.HttpsqsClient
    • com.daguu.lib.httpsqs4j.HttpsqsStatus
    • com.daguu.lib.httpsqs4j.Test
    • java.lang.Throwable (implements java.io.Serializable) 93 | 97 |
    98 |
99 |
100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 121 | 124 | 125 | 126 | 127 | 130 | 146 | 147 |
122 | 123 |
148 | 149 | 150 | 151 |
152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/com/daguu/lib/httpsqs4j/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Uses of Package com.daguu.lib.httpsqs4j 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Uses of Package
com.daguu.lib.httpsqs4j

85 |
86 | 87 | 88 | 89 | 91 | 92 | 93 | 97 | 98 | 99 | 103 | 104 | 105 | 109 | 110 |
90 | Classes in com.daguu.lib.httpsqs4j used by com.daguu.lib.httpsqs4j
HttpsqsClient 94 | 95 |
96 |           客户端类,使用Httpsqs4j类的createNewClient()方法创建,创建前请先调用Httpsqs4j的setConnectionInfo设置连接信息
HttpsqsException 100 | 101 |
102 |            
HttpsqsStatus 106 | 107 |
108 |            
111 |   112 |

113 |


114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 135 | 138 | 139 | 140 | 141 | 144 | 160 | 161 |
136 | 137 |
162 | 163 | 164 | 165 |
166 | 167 | 168 | 169 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/constant-values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Constant Field Values 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Constant Field Values

85 |
86 |
87 | Contents
    88 |
89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 112 | 115 | 116 | 117 | 118 | 121 | 137 | 138 |
113 | 114 |
139 | 140 | 141 | 142 |
143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Deprecated List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Deprecated API

85 |
86 |
87 | Contents
    88 |
89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 112 | 115 | 116 | 117 | 118 | 121 | 137 | 138 |
113 | 114 |
139 | 140 | 141 | 142 |
143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | C-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | C

84 |
85 |
com.daguu.lib.httpsqs4j - package com.daguu.lib.httpsqs4j
 
createNewClient() - 86 | Static method in class com.daguu.lib.httpsqs4j.Httpsqs4j 87 |
创建新的客户端对象 88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 | C G H M P Q R S T U V
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-10.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | U-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | U

84 |
85 |
unreadNumber - 86 | Variable in class com.daguu.lib.httpsqs4j.HttpsqsStatus 87 |
当前未出队数量 88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 | C G H M P Q R S T U V
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-11.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | V-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | V

84 |
85 |
version - 86 | Variable in class com.daguu.lib.httpsqs4j.HttpsqsStatus 87 |
HttpSQS版本 88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 | C G H M P Q R S T U V
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | G-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | G

84 |
85 |
getLap - 86 | Variable in class com.daguu.lib.httpsqs4j.HttpsqsStatus 87 |
当前出队圈数 88 |
getLastPos() - 89 | Method in class com.daguu.lib.httpsqs4j.HttpsqsClient 90 |
获取最后一次出入队列操作的位置值 91 |
getPosition - 92 | Variable in class com.daguu.lib.httpsqs4j.HttpsqsStatus 93 |
当前出队位置 94 |
getStatus(String) - 95 | Method in class com.daguu.lib.httpsqs4j.HttpsqsClient 96 |
获取HttpSQS状态 97 |
getString(String) - 98 | Method in class com.daguu.lib.httpsqs4j.HttpsqsClient 99 |
将字符串出队列 100 |
getStringAt(String, long) - 101 | Method in class com.daguu.lib.httpsqs4j.HttpsqsClient 102 |
获取某位置的字符串 103 |
104 |
105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 126 | 129 | 130 | 131 | 132 | 135 | 151 | 152 |
127 | 128 |
153 | 154 | 155 | 156 | C G H M P Q R S T U V
157 | 158 | 159 | 160 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | H-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | H

84 |
85 |
Httpsqs4j - Class in com.daguu.lib.httpsqs4j
Httpsqs4j基础类,用于设置连接信息及创建客户端对象
Httpsqs4j() - 86 | Constructor for class com.daguu.lib.httpsqs4j.Httpsqs4j 87 |
  88 |
HttpsqsClient - Class in com.daguu.lib.httpsqs4j
客户端类,使用Httpsqs4j类的createNewClient()方法创建,创建前请先调用Httpsqs4j的setConnectionInfo设置连接信息
HttpsqsException - Exception in com.daguu.lib.httpsqs4j
 
HttpsqsException() - 89 | Constructor for exception com.daguu.lib.httpsqs4j.HttpsqsException 90 |
  91 |
HttpsqsException(String) - 92 | Constructor for exception com.daguu.lib.httpsqs4j.HttpsqsException 93 |
  94 |
HttpsqsException(String, Throwable) - 95 | Constructor for exception com.daguu.lib.httpsqs4j.HttpsqsException 96 |
  97 |
HttpsqsStatus - Class in com.daguu.lib.httpsqs4j
 
HttpsqsStatus() - 98 | Constructor for class com.daguu.lib.httpsqs4j.HttpsqsStatus 99 |
  100 |
101 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 123 | 126 | 127 | 128 | 129 | 132 | 148 | 149 |
124 | 125 |
150 | 151 | 152 | 153 | C G H M P Q R S T U V
154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | M-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | M

84 |
85 |
main(String[]) - 86 | Static method in class com.daguu.lib.httpsqs4j.Test 87 |
  88 |
maxNumber - 89 | Variable in class com.daguu.lib.httpsqs4j.HttpsqsStatus 90 |
队列最大数量 91 |
92 |
93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 114 | 117 | 118 | 119 | 120 | 123 | 139 | 140 |
115 | 116 |
141 | 142 | 143 | 144 | C G H M P Q R S T U V
145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | P-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | P

84 |
85 |
putLap - 86 | Variable in class com.daguu.lib.httpsqs4j.HttpsqsStatus 87 |
当前入队圈数 88 |
putPosition - 89 | Variable in class com.daguu.lib.httpsqs4j.HttpsqsStatus 90 |
当前入队位置 91 |
putString(String, String) - 92 | Method in class com.daguu.lib.httpsqs4j.HttpsqsClient 93 |
将字符串加入队列 94 |
95 |
96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 117 | 120 | 121 | 122 | 123 | 126 | 142 | 143 |
118 | 119 |
144 | 145 | 146 | 147 | C G H M P Q R S T U V
148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-6.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Q-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | Q

84 |
85 |
queueName - 86 | Variable in class com.daguu.lib.httpsqs4j.HttpsqsStatus 87 |
队列名称 88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 | C G H M P Q R S T U V
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | R-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | R

84 |
85 |
reset(String) - 86 | Method in class com.daguu.lib.httpsqs4j.HttpsqsClient 87 |
重置队列 88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 | C G H M P Q R S T U V
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | S-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | S

84 |
85 |
setConnectionInfo(String, int, String) - 86 | Static method in class com.daguu.lib.httpsqs4j.Httpsqs4j 87 |
设置连接信息 88 |
setMaxNumber(String, long) - 89 | Method in class com.daguu.lib.httpsqs4j.HttpsqsClient 90 |
设置最大队列数量 91 |
92 |
93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 114 | 117 | 118 | 119 | 120 | 123 | 139 | 140 |
115 | 116 |
141 | 142 | 143 | 144 | C G H M P Q R S T U V
145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index-files/index-9.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | T-Index 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 | C G H M P Q R S T U V
82 |

83 | T

84 |
85 |
Test - Class in com.daguu.lib.httpsqs4j
 
Test() - 86 | Constructor for class com.daguu.lib.httpsqs4j.Test 87 |
  88 |
89 |
90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 111 | 114 | 115 | 116 | 117 | 120 | 136 | 137 |
112 | 113 |
138 | 139 | 140 | 141 | C G H M P Q R S T U V
142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Generated Documentation (Untitled) 9 | 10 | 21 | 23 | 24 | 25 | 26 | 27 | 28 | <H2> 29 | Frame Alert</H2> 30 | 31 | <P> 32 | This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. 33 | <BR> 34 | Link to<A HREF="com/daguu/lib/httpsqs4j/package-summary.html">Non-frame version.</A> 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/overview-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Class Hierarchy 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Hierarchy For All Packages

85 |
86 |
87 |
Package Hierarchies:
com.daguu.lib.httpsqs4j
88 |
89 |

90 | Class Hierarchy 91 |

92 |
    93 |
  • java.lang.Object
      94 |
    • com.daguu.lib.httpsqs4j.Httpsqs4j
    • com.daguu.lib.httpsqs4j.HttpsqsClient
    • com.daguu.lib.httpsqs4j.HttpsqsStatus
    • com.daguu.lib.httpsqs4j.Test
    • java.lang.Throwable (implements java.io.Serializable) 95 | 99 |
    100 |
101 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 123 | 126 | 127 | 128 | 129 | 132 | 148 | 149 |
124 | 125 |
150 | 151 | 152 | 153 |
154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/package-list: -------------------------------------------------------------------------------- 1 | com.daguu.lib.httpsqs4j 2 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/resources/inherit.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/httpsqs4j/doc/resources/inherit.gif -------------------------------------------------------------------------------- /client/httpsqs4j/doc/serialized-form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Serialized Form 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 25 | 26 | 27 | 28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 51 | 54 | 55 | 56 | 57 | 60 | 76 | 77 |
52 | 53 |
78 | 79 | 80 | 81 |
82 |
83 |

84 | Serialized Form

85 |
86 |
87 | 88 | 89 | 90 | 92 | 93 |
91 | Package com.daguu.lib.httpsqs4j
94 | 95 |

96 | 97 | 98 | 99 | 101 | 102 |
100 | Class com.daguu.lib.httpsqs4j.HttpsqsException extends java.lang.Exception implements Serializable
103 | 104 |

105 | serialVersionUID: 1L 106 | 107 |

108 | 109 |

110 |


111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 132 | 135 | 136 | 137 | 138 | 141 | 157 | 158 |
133 | 134 |
159 | 160 | 161 | 162 |
163 | 164 | 165 | 166 | -------------------------------------------------------------------------------- /client/httpsqs4j/doc/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* Javadoc style sheet */ 2 | 3 | /* Define colors, fonts and other style attributes here to override the defaults */ 4 | 5 | /* Page background color */ 6 | body { background-color: #FFFFFF; color:#000000 } 7 | 8 | /* Headings */ 9 | h1 { font-size: 145% } 10 | 11 | /* Table colors */ 12 | .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ 13 | .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ 14 | .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ 15 | 16 | /* Font used in left-hand frame lists */ 17 | .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 18 | .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 19 | .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } 20 | 21 | /* Navigation bar fonts and colors */ 22 | .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ 23 | .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ 24 | .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} 25 | .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} 26 | 27 | .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 28 | .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} 29 | 30 | -------------------------------------------------------------------------------- /client/httpsqs4j/output/httpsqs4j.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/httpsqs4j/output/httpsqs4j.jar -------------------------------------------------------------------------------- /client/httpsqs4j/src/com/daguu/lib/httpsqs4j/Httpsqs4j.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @(#)HttpsqsConnectionInfo.java Apr 29, 2010 4 | * 5 | * Copyright 2010 QinYu, Inc. All rights reserved. 6 | * 7 | */ 8 | package com.daguu.lib.httpsqs4j; 9 | 10 | import java.io.IOException; 11 | import java.io.UnsupportedEncodingException; 12 | import java.net.HttpURLConnection; 13 | import java.net.URL; 14 | 15 | /** 16 | * 17 | * Httpsqs4j基础类,用于设置连接信息及创建客户端对象 18 | * 19 | * @author Henry Young 20 | * 21 | */ 22 | public class Httpsqs4j { 23 | 24 | protected static String prefix; 25 | 26 | protected static String charset; 27 | 28 | protected static boolean configured = false; 29 | 30 | /** 31 | * 设置连接信息 32 | * 33 | * @param ip 34 | * @param port 35 | * @param charset 字符集 36 | * @throws HttpsqsException 37 | */ 38 | public static void setConnectionInfo(String ip, int port, String charset) throws HttpsqsException { 39 | try { 40 | "".getBytes(charset); 41 | } catch (UnsupportedEncodingException e) { 42 | throw new HttpsqsException("Unknown charset.", (Throwable) e); 43 | } 44 | URL url; 45 | HttpURLConnection connection = null; 46 | String prefix = "http://" + ip + ":" + port + "/"; 47 | try { 48 | url = new URL(prefix); 49 | connection = (HttpURLConnection) url.openConnection(); 50 | connection.connect(); 51 | } catch (IOException e) { 52 | throw new HttpsqsException(prefix + " cannot located.", (Throwable) e); 53 | } finally { 54 | if (connection != null) { 55 | connection.disconnect(); 56 | } 57 | } 58 | Httpsqs4j.prefix = prefix + "?"; 59 | Httpsqs4j.charset = charset; 60 | Httpsqs4j.configured = true; 61 | } 62 | 63 | /** 64 | * 创建新的客户端对象 65 | * 66 | * @return 67 | */ 68 | public static HttpsqsClient createNewClient() { 69 | return new HttpsqsClient(); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /client/httpsqs4j/src/com/daguu/lib/httpsqs4j/HttpsqsClient.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @(#)HttpsqsClient.java Apr 29, 2010 4 | * 5 | * Copyright 2010 QinYu, Inc. All rights reserved. 6 | * 7 | */ 8 | package com.daguu.lib.httpsqs4j; 9 | 10 | import java.io.BufferedReader; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.io.InputStreamReader; 14 | import java.io.OutputStream; 15 | import java.io.OutputStreamWriter; 16 | import java.net.HttpURLConnection; 17 | import java.net.URL; 18 | import java.util.regex.Matcher; 19 | 20 | /** 21 | * 22 | * 客户端类,使用Httpsqs4j类的createNewClient()方法创建,创建前请先调用Httpsqs4j的setConnectionInfo设置连接信息 23 | * 24 | * @author Henry Young 25 | * 26 | */ 27 | public class HttpsqsClient { 28 | 29 | private long pos; 30 | 31 | protected HttpsqsClient() { 32 | 33 | } 34 | 35 | private String httpPost(String urlStr, String postData) throws HttpsqsException { 36 | return this.getSource(urlStr, postData); 37 | } 38 | 39 | private String httpGet(String urlStr) throws HttpsqsException { 40 | return this.getSource(urlStr, null); 41 | } 42 | 43 | private String getSource(String urlStr, String postData) throws HttpsqsException { 44 | HttpURLConnection connection = null; 45 | InputStream is = null; 46 | InputStreamReader isr = null; 47 | BufferedReader reader = null; 48 | OutputStream os = null; 49 | OutputStreamWriter osw = null; 50 | StringBuffer sb = new StringBuffer(); 51 | try { 52 | URL url = new URL(Httpsqs4j.prefix + urlStr); 53 | connection = (HttpURLConnection) url.openConnection(); 54 | if (postData != null) { 55 | try { 56 | connection.setDoOutput(true); 57 | os = connection.getOutputStream(); 58 | osw = new OutputStreamWriter(os); 59 | osw.write(postData); 60 | osw.flush(); 61 | } catch (IOException e) { 62 | throw new HttpsqsException("Send data error.", (Throwable) e); 63 | } finally { 64 | if (osw != null) { 65 | osw.close(); 66 | } 67 | if (os != null) { 68 | os.close(); 69 | } 70 | } 71 | } 72 | is = connection.getInputStream(); 73 | isr = new InputStreamReader(is, Httpsqs4j.charset); 74 | reader = new BufferedReader(isr); 75 | String line = ""; 76 | while ((line = reader.readLine()) != null) { 77 | sb.append(line).append('\n'); 78 | } 79 | String pos = connection.getHeaderField("Pos"); 80 | if (pos != null) { 81 | this.pos = Long.valueOf(pos); 82 | } 83 | } catch (IOException e) { 84 | throw new HttpsqsException("Cannot connect to server.", (Throwable) e); 85 | } finally { 86 | if (reader != null) { 87 | try { 88 | reader.close(); 89 | } catch (IOException e) { 90 | e.printStackTrace(); 91 | } 92 | } 93 | if (isr != null) { 94 | try { 95 | isr.close(); 96 | } catch (IOException e) { 97 | e.printStackTrace(); 98 | } 99 | } 100 | if (is != null) { 101 | try { 102 | is.close(); 103 | } catch (IOException e) { 104 | e.printStackTrace(); 105 | } 106 | } 107 | if (connection != null) { 108 | connection.disconnect(); 109 | } 110 | } 111 | String sbs = sb.toString(); 112 | if (sbs.contains("HTTPSQS_ERROR")) { 113 | throw new HttpsqsException("Global error."); 114 | } 115 | return sb.toString(); 116 | } 117 | 118 | /** 119 | * 获取最后一次出入队列操作的位置值 120 | * 121 | * @return 122 | */ 123 | public long getLastPos() { 124 | return this.pos; 125 | } 126 | 127 | /** 128 | * 获取HttpSQS状态 129 | * 130 | * @param queueName 队列名称 131 | * @return 132 | * @throws HttpsqsException 133 | */ 134 | public HttpsqsStatus getStatus(String queueName) throws HttpsqsException { 135 | String urlStr = "opt=status&name=" + queueName; 136 | String source = this.httpGet(urlStr); 137 | Matcher matcher = HttpsqsStatus.pattern.matcher(source); 138 | if (matcher.find()) { 139 | HttpsqsStatus status = new HttpsqsStatus(); 140 | status.version = matcher.group(1); 141 | status.queueName = matcher.group(2); 142 | status.maxNumber = Long.parseLong(matcher.group(3)); 143 | status.getLap = Long.parseLong(matcher.group(4)); 144 | status.getPosition = Long.parseLong(matcher.group(5)); 145 | status.putLap = Long.parseLong(matcher.group(6)); 146 | status.putPosition = Long.parseLong(matcher.group(7)); 147 | status.unreadNumber = Long.parseLong(matcher.group(8)); 148 | return status; 149 | } 150 | return null; 151 | } 152 | 153 | /** 154 | * 将字符串加入队列 155 | * 156 | * @param queueName 队列名称 157 | * @param str 字符串 158 | * @throws HttpsqsException 159 | */ 160 | public void putString(String queueName, String str) throws HttpsqsException { 161 | String urlStr = "opt=put&name=" + queueName; 162 | String source = this.httpPost(urlStr, str); 163 | if (source.contains("HTTPSQS_PUT_END")) { 164 | throw new HttpsqsException("Queue [" + queueName + "] fulled."); 165 | } else if (source.contains("HTTPSQS_PUT_ERROR")) { 166 | throw new HttpsqsException("Put data to queue [" + queueName + "] failed."); 167 | } 168 | } 169 | 170 | /** 171 | * 将字符串出队列 172 | * 173 | * @param queueName 队列名称 174 | * @return 175 | * @throws HttpsqsException 176 | */ 177 | public String getString(String queueName) throws HttpsqsException { 178 | String urlStr = "opt=get&charset=" + Httpsqs4j.charset + "&name=" + queueName; 179 | String source = this.httpGet(urlStr); 180 | if (source.contains("HTTPSQS_GET_END")) { 181 | throw new HttpsqsException("There's no data in queue [" + queueName + "]."); 182 | } 183 | return source; 184 | } 185 | 186 | /** 187 | * 获取某位置的字符串 188 | * 189 | * @param queueName 队列名称 190 | * @param pos 位置 191 | * @return 192 | * @throws HttpsqsException 193 | */ 194 | public String getStringAt(String queueName, long pos) throws HttpsqsException { 195 | if (pos < 1 || pos > 1000000000l) { 196 | throw new HttpsqsException("Pos' out of range[1 - 1000000000]."); 197 | } 198 | String urlStr = "opt=view&charset=" + Httpsqs4j.charset + "&name=" + queueName + "&pos=" + pos; 199 | return this.httpGet(urlStr); 200 | } 201 | 202 | /** 203 | * 重置队列 204 | * 205 | * @param queueName 队列名称 206 | * @return 207 | * @throws HttpsqsException 208 | */ 209 | public boolean reset(String queueName) throws HttpsqsException { 210 | String urlStr = "opt=reset&name=" + queueName; 211 | String source = this.httpGet(urlStr); 212 | return source.contains("HTTPSQS_RESET_OK"); 213 | } 214 | 215 | /** 216 | * 设置最大队列数量 217 | * 218 | * @param queueName 队列名称 219 | * @param number 最大数量 220 | * @return 221 | * @throws HttpsqsException 222 | */ 223 | public boolean setMaxNumber(String queueName, long number) throws HttpsqsException { 224 | if (pos < 10 || pos > 1000000000l) { 225 | throw new HttpsqsException("Pos' out of range[10 - 1000000000]."); 226 | } 227 | String urlStr = "opt=maxqueue&name=" + queueName + "&num=" + number; 228 | String source = this.httpGet(urlStr); 229 | return source.contains("HTTPSQS_MAXQUEUE_OK"); 230 | } 231 | 232 | } 233 | -------------------------------------------------------------------------------- /client/httpsqs4j/src/com/daguu/lib/httpsqs4j/HttpsqsException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @(#)HttpsqsException.java Apr 29, 2010 4 | * 5 | * Copyright 2010 QinYu, Inc. All rights reserved. 6 | * 7 | */ 8 | package com.daguu.lib.httpsqs4j; 9 | 10 | /** 11 | * @author Henry Young 12 | * 13 | */ 14 | public class HttpsqsException extends Exception { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | public HttpsqsException() { 19 | super(); 20 | } 21 | 22 | public HttpsqsException(String message) { 23 | super(message); 24 | } 25 | 26 | public HttpsqsException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | // public HttpsqsException 31 | 32 | } 33 | -------------------------------------------------------------------------------- /client/httpsqs4j/src/com/daguu/lib/httpsqs4j/HttpsqsStatus.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @(#)HttpsqsStatus.java Apr 29, 2010 4 | * 5 | * Copyright 2010 QinYu, Inc. All rights reserved. 6 | * 7 | */ 8 | package com.daguu.lib.httpsqs4j; 9 | 10 | import java.util.regex.Pattern; 11 | 12 | /** 13 | * @author Henry Young 14 | * 15 | */ 16 | public class HttpsqsStatus { 17 | 18 | /** 19 | * HttpSQS版本 20 | */ 21 | public String version; 22 | 23 | /** 24 | * 队列名称 25 | */ 26 | public String queueName; 27 | 28 | /** 29 | * 队列最大数量 30 | */ 31 | public long maxNumber; 32 | 33 | /** 34 | * 当前入队位置 35 | */ 36 | public long putPosition; 37 | 38 | /** 39 | * 当前入队圈数 40 | */ 41 | public long putLap; 42 | 43 | /** 44 | * 当前出队位置 45 | */ 46 | public long getPosition; 47 | 48 | /** 49 | * 当前出队圈数 50 | */ 51 | public long getLap; 52 | 53 | /** 54 | * 当前未出队数量 55 | */ 56 | public long unreadNumber; 57 | 58 | protected static Pattern pattern = Pattern.compile("HTTP Simple Queue Service v(.+?)\\s(?:.+?)\\sQueue Name: (.+?)\\sMaximum number of queues: (\\d+)\\sPut position of queue \\((\\d+)st lap\\): (\\d+)\\sGet position of queue \\((\\d+)st lap\\): (\\d+)\\sNumber of unread queue: (\\d+)"); 59 | 60 | } 61 | -------------------------------------------------------------------------------- /client/httpsqs4j/src/com/daguu/lib/httpsqs4j/Test.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @(#)Tester.java Apr 29, 2010 4 | * 5 | * Copyright 2010 QinYu, Inc. All rights reserved. 6 | * 7 | */ 8 | package com.daguu.lib.httpsqs4j; 9 | 10 | /** 11 | * @author Henry Young 12 | * 13 | */ 14 | public class Test { 15 | 16 | public static void main(String[] args) { 17 | try { 18 | Httpsqs4j.setConnectionInfo("192.168.1.201", 1218, "UTF-8"); 19 | HttpsqsClient client = Httpsqs4j.createNewClient(); 20 | HttpsqsStatus status = client.getStatus("asdf"); 21 | System.out.println(status.version); 22 | System.out.println(status.queueName); 23 | System.out.println(status.maxNumber);; 24 | System.out.println(status.getLap);; 25 | System.out.println(status.getPosition); 26 | System.out.println(status.putLap); 27 | System.out.println(status.putPosition); 28 | System.out.println(status.unreadNumber); 29 | client.putString("asdf", "test"); 30 | System.out.println(client.getString("asdf")); 31 | } catch (HttpsqsException e) { 32 | e.printStackTrace(); 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /client/java/Httpsqs_client.java: -------------------------------------------------------------------------------- 1 | /* 2 | * 不包括keep-alive的部分,get方法只能获得数据,无法获得pos 3 | * 作者:李博 lb13810398408@gmail.com 4 | */ 5 | 6 | import java.io.*; 7 | import java.net.*; 8 | 9 | class Httpsqs_client { 10 | private String server, port, charset; 11 | 12 | public Httpsqs_client(String server, String port, String charset) { 13 | this.server = server; 14 | this.port = port; 15 | this.charset = charset; 16 | } 17 | 18 | private String doprocess(String urlstr) { 19 | URL url = null; 20 | try { 21 | url = new URL(urlstr); 22 | } catch (MalformedURLException e) { 23 | return "The httpsqs server must be error"; 24 | } 25 | try { 26 | BufferedReader instream = new BufferedReader(new InputStreamReader(url.openStream())); 27 | String s = null; 28 | StringBuffer result = new StringBuffer(""); 29 | 30 | while((s = instream.readLine()) != null) 31 | { 32 | result.append(s); 33 | } 34 | instream.close(); 35 | return result.toString(); 36 | } catch (IOException e) { 37 | return "Get data error"; 38 | } 39 | } 40 | 41 | public String maxqueue(String queue_name, String num) { 42 | String urlstr = "http://" + this.server + ":" + this.port + "/?name=" + queue_name + "&opt=maxqueue&num=" + num; 43 | String result = null; 44 | 45 | result = this.doprocess(urlstr); 46 | return result; 47 | } 48 | 49 | public String reset(String queue_name) { 50 | String urlstr = "http://" + this.server + ":" + this.port + "/?name=" + queue_name + "&opt=reset"; 51 | String result = null; 52 | 53 | result = this.doprocess(urlstr); 54 | return result; 55 | } 56 | 57 | public String view(String queue_name, String pos) { 58 | String urlstr = "http://" + this.server + ":" + this.port + "/?charset=" + this.charset + "&name=" + queue_name + "&opt=view&pos=" + pos; 59 | String result = null; 60 | 61 | result = this.doprocess(urlstr); 62 | return result; 63 | } 64 | 65 | public String status(String queue_name) { 66 | String urlstr = "http://" + this.server + ":" + this.port + "/?name=" + queue_name + "&opt=status"; 67 | String result = null; 68 | 69 | result = this.doprocess(urlstr); 70 | return result; 71 | } 72 | 73 | public String get(String queue_name) { 74 | String urlstr = "http://" + this.server + ":" + this.port + "/?charset=" + this.charset + "&name=" + queue_name + "&opt=get"; 75 | String result = null; 76 | 77 | result = this.doprocess(urlstr); 78 | return result; 79 | } 80 | 81 | public String put(String queue_name, String data) { 82 | String urlstr = "http://" + this.server + ":" + this.port + "/?name=" + queue_name + "&opt=put"; 83 | URL url = null; 84 | try { 85 | url = new URL(urlstr); 86 | } catch (MalformedURLException e) { 87 | return "The httpsqs server must be error"; 88 | } 89 | 90 | URLConnection conn = null; 91 | 92 | try { 93 | conn = url.openConnection(); 94 | conn.setDoOutput(true); 95 | OutputStreamWriter out = null; 96 | out = new OutputStreamWriter(conn.getOutputStream()); 97 | out.write(data); 98 | out.flush(); 99 | out.close(); 100 | } catch (IOException e) { 101 | return "Put data error"; 102 | } 103 | 104 | BufferedReader reader = null; 105 | 106 | try { 107 | reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); 108 | String line = null; 109 | while ((line = reader.readLine()) != null) { 110 | return line; 111 | } 112 | } catch (IOException e) { 113 | return "Get return data error"; 114 | } 115 | return null; 116 | } 117 | } -------------------------------------------------------------------------------- /client/java/Test.java: -------------------------------------------------------------------------------- 1 | public class Test { 2 | public static void main(String args[]) 3 | { 4 | Httpsqs_client sqs = new Httpsqs_client("192.168.1.102", "1218", "utf-8"); 5 | String result = null; 6 | result = sqs.put("testq", "dsadasd"); 7 | System.out.println(result); 8 | System.out.println("---------------------------"); 9 | result = sqs.status("testq"); 10 | System.out.println(result); 11 | System.out.println("---------------------------"); 12 | result = sqs.get("testq"); 13 | System.out.println(result); 14 | System.out.println("---------------------------"); 15 | result = sqs.reset("testq"); 16 | System.out.println(result); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /client/perl/License: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deniskin82/httpsqs/f1c41a7aeec32f57d85227fd1bbec373f7b08c7c/client/perl/License -------------------------------------------------------------------------------- /client/perl/README: -------------------------------------------------------------------------------- 1 | HttpSQS 模块参数说明 2 | 开发平台:CentOS 5.4 3 | Perl版本:5.8.8 4 | Editor: VIM 5 | ################################################################## 6 | new 方法: 7 | 8 | 参数个数:4个 9 | 10 | 参数说明: 11 | 1.HttpSQS-服务器IP地址。 12 | 2.HttpSQS-工作端口号。 13 | 3.Proto-连接服务器协议类型,TCP 还是UDP. 默认是TCP连接。 14 | 4.Charset-字符集。默认是UTF-8。 15 | ################################################################### 16 | put方法: 17 | 18 | 参数个数:2个 19 | 20 | 传递参数: 21 | 1.队列名 22 | 2.以POST方式提交的字符串 23 | #################################################################### 24 | get方法: 25 | 26 | 参数个数:1个 27 | 28 | 传递参数: 29 | 1.队列名 30 | #################################################################### 31 | status方法: 32 | 33 | 参数个数:1个 34 | 35 | 传递参数: 36 | 1.队列名 37 | ##################################################################### 38 | view方法: 39 | 40 | 参数个数:2个 41 | 42 | 传递参数: 43 | 1.队列名 44 | 2.查看队列的编号 45 | ##################################################################### 46 | reset方法: 47 | 48 | 参数个数:1个 49 | 50 | 传递参数: 51 | 1.队列名 52 | ##################################################################### 53 | maxqueue方法: 54 | 55 | 参数个数:2个 56 | 57 | 传递参数: 58 | 1.队列名 59 | 2.指定的最大队列数 60 | ##################################################################### 61 | pput方法: 62 | 63 | 参数个数:2个 64 | 65 | 传递参数: 66 | 1.队列名 67 | 2.POST方式提交的数据。 68 | ##################################################################### 69 | pget方法: 70 | 71 | 参数个数:1个 72 | 73 | 传递参数: 74 | 1.队列名 75 | ##################################################################### 76 | pstatus方法: 77 | 78 | 参数个数:1个 79 | 80 | 传递参数: 81 | 1.队列名 82 | ##################################################################### 83 | pview方法: 84 | 85 | 参数个数:2个 86 | 87 | 传递参数: 88 | 1.队列名 89 | 2.查看队列的编号。 90 | ##################################################################### 91 | pmaxqueue方法: 92 | 93 | 参数个数:2个 94 | 95 | 传递参数: 96 | 1.队列名 97 | 2.指定队列的最大数。 98 | ##################################################################### 99 | preset方法: 100 | 101 | 参数个数:1个 102 | 103 | 传递参数: 104 | 1.队列名 105 | ##################################################################### 106 | 107 | 使用的例子见: 108 | httpsqs_cmdline_test.pl 109 | httpsqs_cmdline_loop_test.pl 110 | -------------------------------------------------------------------------------- /client/perl/Version: -------------------------------------------------------------------------------- 1 | 0.1.0 2 | -------------------------------------------------------------------------------- /client/perl/httpsqs_cmdline_loop_test.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl -w 2 | 3 | use HttpSQS ; 4 | use Benchmark qw(:all) ; 5 | use v5.8.8 ; 6 | 7 | # clear block buffer 8 | 9 | $| = 1 ; 10 | 11 | my $number = 10 ; 12 | 13 | my $mesg = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' ; 14 | 15 | my $sqs = HttpSQS->new("127.0.0.1","1218",'tcp','utf-8') ; 16 | 17 | # Just testing in my perl source code 18 | my $tm_0 = new Benchmark ; 19 | 20 | for(my $i=1;$i<=$number;$i++) 21 | { 22 | my $str = $i.$mesg ; 23 | my $rtn = $sqs->pput("perl_cmdline_test","$str") ; 24 | print "pput method return value $rtn\n" ; 25 | } 26 | for(my $j=1;$j<=$number;$j++) 27 | { 28 | my $result = $sqs->pget("perl_cmdline_test") ; 29 | print "HttpSQS return result $result\n" ; 30 | } 31 | my $tm_1 = new Benchmark ; 32 | 33 | my $td = timediff($tm_1,$tm_0) ; 34 | 35 | print "The code diff run time:",timestr($td),"\n" ; 36 | -------------------------------------------------------------------------------- /client/perl/httpsqs_cmdline_test.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # This script Just test programe HttpSQS module 4 | # Autho : Tony 5 | # Date : 2010.3.10 6 | # Email : tonny0830@gmail.com 7 | 8 | use strict ; 9 | use HttpSQS ; 10 | use v5.8.8 ; 11 | 12 | $| = 1 ; 13 | 14 | my $sqs = HttpSQS->new("127.0.0.1","1218",'tcp','utf-8') ; 15 | 16 | # Just testing in my perl source code 17 | my $put = $sqs->put("perl_cmdline_test","hello") ; 18 | 19 | print "HttpSQS put return result $put\n" ; 20 | 21 | my $status = $sqs->status("perl_cmdline_test") ; 22 | 23 | print "HttpSQS status return result $status\n" ; 24 | 25 | my $get = $sqs->get("perl_cmdline_test") ; 26 | 27 | print "HttpSQS get return result $get\n" ; 28 | 29 | my $view = $sqs->view("perl_cmdline_test",1) ; 30 | 31 | print "HttpSQS view return result $view\n" ; 32 | 33 | # If reset OK, will return 1, reset fail will return 0 ; 34 | my $reset = $sqs->reset("perl_cmdline_test") ; 35 | 36 | print "HttpSQS reset return result $reset\n" ; 37 | 38 | # If maxqueue set OK, will return 1, If fail will return 0 ; 39 | my $maxqueue = $sqs->maxqueue("perl_cmdline_test",1_0_0_0) ; 40 | 41 | print "HttpSQS maxqueue return result $maxqueue\n" ; 42 | 43 | #$print "HttpSQS urlencode return result $urlencode\n" ; 44 | my $pput = $sqs->pput("p_perl_cmdline_test","abcdefghi") ; 45 | 46 | print "HttpSQS pput return result $pput\n" ; 47 | 48 | # If get Data OK,then will return data,else return 0 ; 49 | my $pget = $sqs->pget("p_perl_cmdline_test") ; 50 | 51 | print "HttpSQS pget return result $pget\n" ; 52 | 53 | my $pstatus = $sqs->pstatus("p_perl_cmdline_test") ; 54 | 55 | print "HttpSQS pstatus return result $pstatus\n" ; 56 | 57 | # If view data OK,then will return data, else return 0 58 | my $pview = $sqs->pview("p_perl_cmdline_test",1) ; 59 | 60 | print "HttpSQS pview return result $pview\n" ; 61 | 62 | # If set pmaxqueue OK, will return 1, fail return 0 63 | my $pmaxqueue = $sqs->pmaxqueue("p_perl_cmdline_test",1_0_0_0) ; 64 | 65 | print "HttpSQS pmaxqueue return result $pmaxqueue\n" ; 66 | 67 | # If reset OK,will return 1, fail will return 0 68 | my $preset = $sqs->preset("p_perl_cmdline_test") ; 69 | 70 | print "HttpSQS preset return result $preset\n" ; 71 | -------------------------------------------------------------------------------- /client/php/test_commandline.php: -------------------------------------------------------------------------------- 1 | pput("127.0.0.1", 1218, "utf-8", "command_line_test", $i.$message); 21 | } 22 | $run_time = microtime(true) - $start_time; 23 | echo "PUT ".$number." messages. Run Time for Queue PUT: $run_time sec, ".$number/$run_time." requests/sec\n"; 24 | ob_flush(); 25 | 26 | /* test queue get */ 27 | echo "Test Queue GET, please waitting ...\n"; 28 | $start_time = microtime(true); 29 | for ($i=1;$i<=$number;$i++){ 30 | $result = $httpsqs->pget("127.0.0.1", 1218, "utf-8", "command_line_test"); 31 | //echo($result."\n"); 32 | } 33 | $run_time = microtime(true) - $start_time; 34 | echo "GET ".$number." messages. Run Time for Queue GET: $run_time sec, ".$number/$run_time." requests/sec\n"; 35 | ?> 36 | -------------------------------------------------------------------------------- /client/php/test_example.php: -------------------------------------------------------------------------------- 1 | put("127.0.0.1", 1218, "utf-8", "your_queue_name1", urlencode("text_message1")); 5 | echo "###1.put result:\r\n"; 6 | var_dump($result); 7 | echo "\r\n\r\n"; 8 | 9 | $result = $httpsqs->get("127.0.0.1", 1218, "utf-8", "your_queue_name1"); 10 | echo "###2.get result:\r\n"; 11 | var_dump($result); 12 | echo "\r\n\r\n"; 13 | 14 | $result = $httpsqs->put("127.0.0.1", 1218, "utf-8", "your_queue_name1", urlencode("text_message2")); 15 | echo "###3.put result:\r\n"; 16 | var_dump($result); 17 | echo "\r\n\r\n"; 18 | 19 | $result = $httpsqs->gets("127.0.0.1", 1218, "utf-8", "your_queue_name1"); 20 | echo "###4.gets result:\r\n"; 21 | var_dump($result); 22 | echo "\r\n\r\n"; 23 | 24 | $result = $httpsqs->pput("127.0.0.1", 1218, "gb2312", "your_queue_name2", urlencode("text_message3")); 25 | echo "###5.pput result:\r\n"; 26 | var_dump($result); 27 | echo "\r\n\r\n"; 28 | 29 | $result = $httpsqs->pget("127.0.0.1", 1218, "gb2312", "your_queue_name2"); 30 | echo "###6.pget result:\r\n"; 31 | var_dump($result); 32 | echo "\r\n\r\n"; 33 | 34 | $result = $httpsqs->status("127.0.0.1", 1218, "utf-8", "your_queue_name1"); 35 | echo "###7.status result:\r\n"; 36 | var_dump($result); 37 | echo "\r\n\r\n"; 38 | 39 | $result = $httpsqs->status_json("127.0.0.1", 1218, "utf-8", "your_queue_name1"); 40 | echo "###8.status_json result:\r\n"; 41 | var_dump($result); 42 | echo "\r\n\r\n"; 43 | 44 | $result = $httpsqs->view("127.0.0.1", 1218, "utf-8", "your_queue_name1", 1); 45 | echo "###9.view result:\r\n"; 46 | var_dump($result); 47 | echo "\r\n\r\n"; 48 | 49 | $result = $httpsqs->reset("127.0.0.1", 1218, "utf-8", "your_queue_name1"); 50 | echo "###10.reset result:\r\n"; 51 | var_dump($result); 52 | echo "\r\n\r\n"; 53 | 54 | $result = $httpsqs->maxqueue("127.0.0.1", 1218, "utf-8", "your_queue_name1", 5000000); 55 | echo "###11.maxqueue result:\r\n"; 56 | var_dump($result); 57 | echo "\r\n\r\n"; 58 | 59 | $result = $httpsqs->synctime("127.0.0.1", 1218, "utf-8", "your_queue_name1", 10); 60 | echo "###12.synctime result:\r\n"; 61 | var_dump($result); 62 | echo "\r\n\r\n"; 63 | ?> 64 | -------------------------------------------------------------------------------- /db_tcdb.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "httpsqs.h" 9 | #include "rbtree.h" 10 | 11 | #include 12 | #include 13 | 14 | static int 15 | dbint_del(struct httpsqs *h, const char *key, size_t key_sz) { 16 | TCHDB *db = httpsqs_get_db_internal(h); 17 | return tchdbout(db, key, key_sz); 18 | } 19 | 20 | static int 21 | dbint_add(struct httpsqs *h, const char *key, size_t key_sz, char *value, size_t value_sz) { 22 | TCHDB *db = httpsqs_get_db_internal(h); 23 | return tchdbput(db, key, key_sz, value, value_sz); 24 | } 25 | 26 | static int 27 | dbint_get(struct httpsqs *h, const char *key, size_t key_sz, char **value, size_t *value_sz) { 28 | TCHDB *db = httpsqs_get_db_internal(h); 29 | ssize_t x; 30 | *value = tchdbget(db, key, key_sz, &x); 31 | if( *value ) *value_sz = x; 32 | return *value != NULL; 33 | } 34 | 35 | static void 36 | dbint_close(struct httpsqs *h) { 37 | TCHDB *db = (TCHDB *)httpsqs_get_db_internal(h); 38 | tchdbclose(db); 39 | } 40 | 41 | static int 42 | dbint_open(struct httpsqs *h) { 43 | const char *data_path = httpsqs_get_option(h, "data_path", NULL); 44 | if( data_path == NULL ) data_path = "./"; 45 | 46 | // Tuning flags 47 | int64_t bnum = httpsqs_get_option_int(h, "tchdb_bnum", 131071); 48 | int8_t apow = httpsqs_get_option_int(h, "tchdb_apow", 4); 49 | int8_t fpow = httpsqs_get_option_int(h, "tchdb_fpow", 10); 50 | uint8_t opts = 0; 51 | if( httpsqs_get_option_int(h, "tchdb_HDBTLARGE", 0) ) opts |= HDBTLARGE; 52 | if( httpsqs_get_option_int(h, "tchdb_HDBTDEFLATE", 0) ) opts |= HDBTDEFLATE; 53 | if( httpsqs_get_option_int(h, "tchdb_HDBTBZIP", 0) ) opts |= HDBTBZIP; 54 | 55 | //Misc flags 56 | int32_t rcnum = httpsqs_get_option_int(h, "tchdb_rcnum", 20); 57 | int64_t xmsiz = httpsqs_get_option_int(h, "tchdb_xmsiz", 67108864); 58 | int32_t dfunit = httpsqs_get_option_int(h, "tchdb_dfunit", 0); 59 | int mode_nolck = httpsqs_get_option_int(h, "tchdb_nolck", 0); 60 | int mode_lcknb = httpsqs_get_option_int(h, "tchdb_lcknb", 0); 61 | 62 | int omode = HDBOWRITER | HDBOCREAT; 63 | if( mode_nolck ) omode |= HDBONOLCK; 64 | if( mode_lcknb ) omode |= HDBOLCKNB; 65 | 66 | assert( data_path != NULL ); 67 | 68 | TCHDB *db = tchdbnew(); 69 | if( ! tchdbtune(db, bnum, apow, fpow, opts) ) return -1; 70 | if( ! tchdbsetcache(db, rcnum) ) return -2; 71 | if( ! tchdbsetxmsiz(db, xmsiz) ) return -3; 72 | if( ! tchdbsetdfunit(db, dfunit) ) return -4; 73 | 74 | if( ! tchdbopen(db, data_path, omode) ) return -6; 75 | 76 | h->db->internal_handle = (void*)db; 77 | return 1; 78 | } 79 | 80 | static void 81 | dbint_sync(struct httpsqs *h) { 82 | TCHDB *db = httpsqs_get_db_internal(h); 83 | tchdbsync(db); 84 | } 85 | 86 | void 87 | db_show_opts(void) { 88 | // " >------------------< X...n" 89 | printf(" tchdb_bnum specifies the number of elements of the bucket array. (default 131071)\n"); 90 | printf(" tchdb_apow size of record alignment by power of 2 (default 4)\n"); 91 | printf(" tchdb_fpow maximum number of elements of the free block pool by power of 2 (default 10, e.g. 2^10)\n"); 92 | printf(" tchdb_HDBTLARGE the size of the database can be larger than 2GB by using 64-bit bucket array\n"); 93 | printf(" tchdb_HDBTDEFLATE each record is compressed with Deflate encoding\n"); 94 | printf(" tchdb_HDBTBZIP each record is compressed with BZIP2 encoding\n"); 95 | printf(" tchdb_rcnum maximum number of records to be cached (default 20)\n"); 96 | printf(" tchdb_xmsiz size of the extra mapped memory. (default 67108864)\n"); 97 | printf(" tchdb_dfunit unit step number of auto defragmentation of a hash database object. (default 0)\n"); 98 | printf(" tchdb_nolck opens the database file without file locking\n"); 99 | printf(" tchdb_lcknb locking is performed without blocking\n"); 100 | } 101 | 102 | struct httpsqs_db * 103 | db_init(struct httpsqs *h) { 104 | struct httpsqs_db *db; 105 | 106 | h->db = (struct httpsqs_db *)malloc(sizeof(struct httpsqs_db)); 107 | assert( h->db != NULL ); 108 | h->db = memset(h->db, 0, sizeof(struct httpsqs_db *)); 109 | db = h->db; 110 | 111 | db->del = dbint_del; 112 | db->add = dbint_add; 113 | db->get = dbint_get; 114 | db->close = dbint_close; 115 | db->open = dbint_open; 116 | db->sync = dbint_sync; 117 | 118 | return db; 119 | } -------------------------------------------------------------------------------- /db_ydb.c: -------------------------------------------------------------------------------- 1 | #define _GNU_SOURCE 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "httpsqs.h" 9 | #include "rbtree.h" 10 | #include "ydb.h" 11 | 12 | static int 13 | dbint_del(struct httpsqs *h, const char *key, size_t key_sz) { 14 | YDB ydb_h = httpsqs_get_db_internal(h); 15 | return ydb_del(ydb_h, (char *)key, key_sz); 16 | } 17 | 18 | static int 19 | dbint_add(struct httpsqs *h, const char *key, size_t key_sz, char *value, size_t value_sz) { 20 | YDB ydb_h = httpsqs_get_db_internal(h); 21 | return ydb_add(ydb_h, (char *)key, key_sz, value, value_sz); 22 | } 23 | 24 | static int 25 | dbint_get(struct httpsqs *h, const char *key, size_t key_sz, char **value, size_t *value_sz) { 26 | YDB ydb_h = httpsqs_get_db_internal(h); 27 | return ydb_geta(ydb_h, (char *)key, key_sz, value, value_sz); 28 | } 29 | 30 | static void 31 | dbint_close(struct httpsqs *h) { 32 | YDB ydb_h = httpsqs_get_db_internal(h); 33 | ydb_close(ydb_h); 34 | } 35 | 36 | static int 37 | dbint_open(struct httpsqs *h) { 38 | const char *data_path = httpsqs_get_option(h, "data_path", NULL); 39 | size_t overcommit = httpsqs_get_option_int(h, "ydb_overcommit", 3); 40 | size_t min_log_size = httpsqs_get_option_int(h, "ydb_min_log_size", 5 * 1024 * 1024); 41 | if( data_path == NULL ) data_path = "./"; 42 | 43 | assert( data_path != NULL ); 44 | assert( min_log_size > 0 ); 45 | assert( overcommit > 0 ); 46 | 47 | h->db->internal_handle = ydb_open((char *)data_path, overcommit, min_log_size, YDB_CREAT); 48 | return h->db->internal_handle != NULL; 49 | } 50 | 51 | static void 52 | dbint_sync(struct httpsqs *h) { 53 | YDB ydb_h = httpsqs_get_db_internal(h); 54 | ydb_sync(ydb_h); 55 | } 56 | 57 | struct httpsqs_db * 58 | db_init(struct httpsqs *h) { 59 | struct httpsqs_db *db; 60 | 61 | h->db = (struct httpsqs_db *)malloc(sizeof(struct httpsqs_db)); 62 | assert( h->db != NULL ); 63 | h->db = memset(h->db, 0, sizeof(struct httpsqs_db *)); 64 | db = h->db; 65 | 66 | db->del = dbint_del; 67 | db->add = dbint_add; 68 | db->get = dbint_get; 69 | db->close = dbint_close; 70 | db->open = dbint_open; 71 | db->sync = dbint_sync; 72 | 73 | return db; 74 | } -------------------------------------------------------------------------------- /httpsqs.h: -------------------------------------------------------------------------------- 1 | #ifndef HTTPSQS_H_ 2 | #define HTTPSQS_H_ 3 | 4 | #define _GNU_SOURCE 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | #include 17 | #include 18 | #include 19 | #include "rbtree.h" 20 | 21 | #define SQS_VERSION "1.3.2.panda" 22 | 23 | //YDB httpsqs_db_tcbdb; 24 | //const char *httpsqs_settings_pidfile; 25 | 26 | struct sqs_queue_status { 27 | char name[11]; 28 | size_t name_sz; 29 | uint64_t tail_id; 30 | uint64_t head_id; 31 | uint32_t maxqueue; 32 | uint32_t count; 33 | uint64_t count_bytes; 34 | 35 | /* Totals for the lifetime of the queue */ 36 | uint64_t total_get; 37 | uint64_t total_put; 38 | uint64_t total_info; 39 | uint64_t total_get_bytes; 40 | uint64_t total_put_bytes; 41 | 42 | /* RB node */ 43 | struct rb_node rbnode; 44 | }; 45 | 46 | struct httpsqs; 47 | 48 | struct httpsqs_db { 49 | void *internal_handle; 50 | int (*del)(struct httpsqs *h, const char *key, size_t key_sz); 51 | int (*add)(struct httpsqs *h, const char *key, size_t key_sz, char *value, size_t value_sz); 52 | int (*get)(struct httpsqs *h, const char *key, size_t key_sz, char **value, size_t *value_sz); 53 | void (*close)(struct httpsqs *h); 54 | int (*open)(struct httpsqs *h); 55 | // Optional methods 56 | void (*sync)(struct httpsqs *h); 57 | // void (*prefetch)(struct httpsqs *h, const char **keys, size_t *key_szs, size_t item_count); 58 | }; 59 | 60 | struct httpsqs { 61 | struct evkeyvalq params; 62 | struct httpsqs_db *db; 63 | struct rb_root queues; 64 | struct evhttp *httpd; 65 | }; 66 | 67 | struct httpsqs_db *httpsqs_get_db(struct httpsqs *h); 68 | void* httpsqs_get_db_internal(struct httpsqs *h); 69 | const char *httpsqs_get_option(struct httpsqs* h, const char *name, const char *default_value); 70 | int httpsqs_get_option_bool(struct httpsqs* h, const char *name, int default_value); 71 | int httpsqs_get_option_int(struct httpsqs *h, const char *name, int default_value); 72 | int httpsqs_set_option(struct httpsqs* h, const char *name, const char *value); 73 | 74 | // Defined in whichever DB handler you're using 75 | struct httpsqs_db *db_init(struct httpsqs *h); 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /properties.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2010 Harry Roberts. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without modification, 6 | are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | * Neither the name of Zend Technologies USA, Inc. nor the names of its 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #include "properties.h" 32 | 33 | #include 34 | #include 35 | 36 | void 37 | properties_parse_line( char *line, struct evkeyvalq *output ) { 38 | char *key, *value, *end; 39 | key = line; 40 | while( isspace(*key) ) key++; 41 | if( *key == ';' ) return; 42 | value = key; 43 | while( isalnum(*value) || *value == '_' ) value++; 44 | while( isspace(*value) ) { *value++ = 0; }; 45 | if( *value != '=' ) return; 46 | *value++ = 0; 47 | while( isspace(*value) ) value++; 48 | end = value + strlen(value) - 1; 49 | while( end > value && isspace(*end) ) end--; 50 | *(end+1) = 0; 51 | 52 | if( strlen(key) && strlen(value) ) { 53 | evhttp_add_header(output, key, value); 54 | } 55 | } 56 | 57 | void 58 | properties_parse_file( FILE *fh, struct evkeyvalq *output ) { 59 | char line[1024]; 60 | assert( output != NULL ); 61 | assert( fh != NULL ); 62 | 63 | while( fgets(line, sizeof(line) / sizeof(char), fh) != NULL ) { 64 | properties_parse_line(line, output); 65 | } 66 | } -------------------------------------------------------------------------------- /properties.h: -------------------------------------------------------------------------------- 1 | #ifndef PROPERTIES_H_ 2 | #define PROPERTIES_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | void properties_parse_line( char *line, struct evkeyvalq *output ); 11 | void properties_parse_file( FILE *fh, struct evkeyvalq *output ); 12 | 13 | #endif 14 | 15 | -------------------------------------------------------------------------------- /rbtree.h: -------------------------------------------------------------------------------- 1 | /* 2 | Red Black Trees 3 | (C) 1999 Andrea Arcangeli 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 2 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | linux/include/linux/rbtree.h 20 | 21 | To use rbtrees you'll have to implement your own insert and search cores. 22 | This will avoid us to use callbacks and to drop drammatically performances. 23 | I know it's not the cleaner way, but in C (not in C++) to get 24 | performances and genericity... 25 | 26 | Some example of insert and search follows here. The search is a plain 27 | normal search over an ordered tree. The insert instead must be implemented 28 | int two steps: as first thing the code must insert the element in 29 | order as a red leaf in the tree, then the support library function 30 | rb_insert_color() must be called. Such function will do the 31 | not trivial work to rebalance the rbtree if necessary. 32 | 33 | ----------------------------------------------------------------------- 34 | static inline struct page * rb_search_page_cache(struct inode * inode, 35 | unsigned long offset) 36 | { 37 | struct rb_node * n = inode->i_rb_page_cache.rb_node; 38 | struct page * page; 39 | 40 | while (n) 41 | { 42 | page = rb_entry(n, struct page, rb_page_cache); 43 | 44 | if (offset < page->offset) 45 | n = n->rb_left; 46 | else if (offset > page->offset) 47 | n = n->rb_right; 48 | else 49 | return page; 50 | } 51 | return NULL; 52 | } 53 | 54 | static inline struct page * __rb_insert_page_cache(struct inode * inode, 55 | unsigned long offset, 56 | struct rb_node * node) 57 | { 58 | struct rb_node ** p = &inode->i_rb_page_cache.rb_node; 59 | struct rb_node * parent = NULL; 60 | struct page * page; 61 | 62 | while (*p) 63 | { 64 | parent = *p; 65 | page = rb_entry(parent, struct page, rb_page_cache); 66 | 67 | if (offset < page->offset) 68 | p = &(*p)->rb_left; 69 | else if (offset > page->offset) 70 | p = &(*p)->rb_right; 71 | else 72 | return page; 73 | } 74 | 75 | rb_link_node(node, parent, p); 76 | 77 | return NULL; 78 | } 79 | 80 | static inline struct page * rb_insert_page_cache(struct inode * inode, 81 | unsigned long offset, 82 | struct rb_node * node) 83 | { 84 | struct page * ret; 85 | if ((ret = __rb_insert_page_cache(inode, offset, node))) 86 | goto out; 87 | rb_insert_color(node, &inode->i_rb_page_cache); 88 | out: 89 | return ret; 90 | } 91 | ----------------------------------------------------------------------- 92 | */ 93 | 94 | #ifndef _LINUX_RBTREE_H 95 | #define _LINUX_RBTREE_H 96 | 97 | /* 98 | #include 99 | #include 100 | */ 101 | 102 | #ifndef PACKED 103 | #define PACKED __attribute__ ((packed)) 104 | #endif 105 | 106 | struct PACKED rb_node 107 | { 108 | struct rb_node *rb_parent; 109 | #define RB_RED 0 110 | #define RB_BLACK 1 111 | struct rb_node *rb_right; 112 | struct rb_node *rb_left; 113 | char rb_color; 114 | }; 115 | 116 | struct rb_root 117 | { 118 | struct rb_node *rb_node; 119 | }; 120 | 121 | // Copy from linux kernel 2.6 source (kernel.h, stddef.h) 122 | #define container_of(ptr, type, member) ({ \ 123 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ 124 | (type *)( (char *)__mptr - offsetof(type,member) );}) 125 | #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) 126 | 127 | 128 | #define RB_ROOT (struct rb_root) { NULL, } 129 | #define rb_entry(ptr, type, member) container_of(ptr, type, member) 130 | 131 | extern void rb_insert_color(struct rb_node *, struct rb_root *); 132 | extern void rb_erase(struct rb_node *, struct rb_root *); 133 | 134 | /* Find logical next and previous nodes in a tree */ 135 | extern struct rb_node *rb_next(struct rb_node *); 136 | extern struct rb_node *rb_prev(struct rb_node *); 137 | extern struct rb_node *rb_first(struct rb_root *); 138 | extern struct rb_node *rb_last(struct rb_root *); 139 | 140 | /* Fast replacement of a single node without remove/rebalance/add/rebalance */ 141 | extern void rb_replace_node(struct rb_node *victim, struct rb_node *rbnew, 142 | struct rb_root *root); 143 | 144 | static inline void rb_link_node(struct rb_node * node, struct rb_node * parent, 145 | struct rb_node ** rb_link) 146 | { 147 | node->rb_parent = parent; 148 | node->rb_color = RB_RED; 149 | node->rb_left = node->rb_right = NULL; 150 | 151 | *rb_link = node; 152 | } 153 | 154 | #endif /* _LINUX_RBTREE_H */ 155 | --------------------------------------------------------------------------------