Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/QueueTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 802 - (show annotations) (download) (as text)
Sat Oct 15 15:08:50 2011 UTC (12 years, 5 months ago) by okuyamaoo
File MIME type: text/x-java
File size: 3059 byte(s)
20111015-5
1 import java.util.*;
2 import java.io.*;
3 import java.net.*;
4
5 import okuyama.imdst.util.*;
6 import okuyama.imdst.client.OkuyamaQueueClient ;
7 import okuyama.base.lang.BatchException;
8
9 public class QueueTest {
10
11 public static void main(String[] args) {
12 try {
13 String methodType = args[0];
14 String masterNodeInfos = args[1];
15
16 OkuyamaQueueClient queueClient = new OkuyamaQueueClient();
17 queueClient.setConnectionInfos(masterNodeInfos.split(","));
18 queueClient.autoConnect();
19
20 if (methodType.equals("create")) {
21
22 if(queueClient.createQueueSpace(args[2])) {
23 System.out.println("Create Queue Success QueueName=[" + args[2] + "]");
24 } else {
25 System.out.println("Create Queue Error QueueName=[" + args[2] + "]");
26 }
27 } else if (methodType.equals("put")) {
28
29 if(queueClient.put(args[2], args[3])) {
30 System.out.println("Put Queue Success QueueName=[" + args[2] + "] Data=[" + args[3] + "]");
31 } else {
32 System.out.println("Put Queue Error QueueName=[" + args[2] + "] Data=[" + args[3] + "]");
33 }
34 } else if (methodType.equals("putmany")) {
35
36 for (int idx = 0; idx < Integer.parseInt(args[4]); idx++) {
37 if(queueClient.put(args[2], args[3] + "_" + idx)) {
38 if ((idx % 1000) == 0) System.out.println("Put Queue Count=[" + idx + "]");
39 } else {
40 System.out.println("Put Queue Error QueueName=[" + args[2] + "] Data=[" + args[3] + "_" + idx + "]");
41 }
42 }
43 } else if (methodType.equals("take")) {
44
45 String data = null;
46 data = queueClient.take(args[2], 10000);
47 if(data != null) {
48 System.out.println("Take Queue Success QueueName=[" + args[2] + "] Data=[" + data + "]");
49 } else {
50 System.out.println("Take Queue Error QueueName=[" + args[2] + "] Data=[" + data + "]");
51 }
52 } else if (methodType.equals("takemany")) {
53
54 String data = null;
55 while (true) {
56
57 data = queueClient.take(args[2], 10000);
58 if(data != null) {
59 System.out.println("Take Queue Success QueueName=[" + args[2] + "] Data=[" + data + "]");
60 } else {
61 break;
62 }
63 }
64 } else if (methodType.equals("remove")) {
65
66 if(queueClient.removeQueueSpace(args[2])) {
67 System.out.println("Remove Queue Success QueueName=[" + args[2] + "]");
68 } else {
69 System.out.println("Remove Queue Error QueueName=[" + args[2] + "]");
70 }
71 }
72
73 } catch (Exception e) {
74 e.printStackTrace();
75 }
76 }
77 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26