1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package openr66.protocol.test;
22
23 import goldengate.common.logging.GgInternalLoggerFactory;
24 import goldengate.common.logging.GgSlf4JLoggerFactory;
25
26 import java.sql.Timestamp;
27 import java.util.concurrent.ExecutorService;
28 import java.util.concurrent.Executors;
29
30 import openr66.client.SubmitTransfer;
31 import openr66.database.DbConstant;
32 import openr66.protocol.utils.R66Future;
33
34 import org.jboss.netty.logging.InternalLoggerFactory;
35
36
37
38
39
40
41
42 public class TestSubmitTransfer extends SubmitTransfer {
43 static int nb = 100;
44
45
46
47
48
49 protected static boolean getSpecialParams(String []args, int rank) {
50 for (int i = rank; i<args.length; i++) {
51 if (args[i].equalsIgnoreCase("-nb")) {
52 i++;
53 nb = Integer.parseInt(args[i]);
54 } else if (args[i].equalsIgnoreCase("-md5")) {
55 } else if (args[i].charAt(0) == '-') {
56 i++;
57 }
58 }
59 return true;
60 }
61
62 public TestSubmitTransfer(R66Future future, String remoteHost,
63 String filename, String rulename, String fileinfo, boolean isMD5, int blocksize,
64 Timestamp starttime) {
65 super(future, remoteHost, filename, rulename, fileinfo, isMD5, blocksize,
66 DbConstant.ILLEGALVALUE, starttime);
67 }
68
69 public static void main(String[] args) {
70 InternalLoggerFactory.setDefaultFactory(new GgSlf4JLoggerFactory(
71 null));
72 if (logger == null) {
73 logger = GgInternalLoggerFactory.getLogger(SubmitTransfer.class);
74 }
75 if (! getParams(args, true)) {
76 logger.error("Wrong initialization");
77 if (DbConstant.admin != null && DbConstant.admin.isConnected) {
78 DbConstant.admin.close();
79 }
80 System.exit(1);
81 }
82 getSpecialParams(args, 1);
83
84 ExecutorService executorService = Executors.newCachedThreadPool();
85 R66Future[] arrayFuture = new R66Future[nb];
86
87 logger.warn("Start Test Submit");
88 for (int i = 0; i < nb; i ++) {
89 arrayFuture[i] = new R66Future(true);
90 Timestamp newstart = ttimestart;
91 if (newstart != null) {
92
93 newstart = new Timestamp(newstart.getTime()+i*10);
94 }
95 TestSubmitTransfer transaction = new TestSubmitTransfer(arrayFuture[i],
96 rhost, localFilename, rule, fileInfo, ismd5, block, newstart);
97
98 transaction.run();
99 }
100 int success = 0;
101 int error = 0;
102 for (int i = 0; i < nb; i ++) {
103 arrayFuture[i].awaitUninterruptibly();
104 if (arrayFuture[i].isSuccess()) {
105 success ++;
106 } else {
107 error ++;
108 }
109 }
110 executorService.shutdown();
111 logger.warn("Prepare transfer Success: " + success + " Error: " + error);
112 }
113
114 }