-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeedTest.java
More file actions
308 lines (153 loc) · 9.08 KB
/
SpeedTest.java
File metadata and controls
308 lines (153 loc) · 9.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
import java.io.*;
import oracle.stellent.ridc.*;
import oracle.stellent.ridc.model.*;
import oracle.stellent.ridc.protocol.*;
import oracle.stellent.ridc.protocol.intradoc.*;
import oracle.stellent.ridc.common.log.*;
import oracle.stellent.ridc.model.serialize.*;
import oracle.stellent.ridc.protocol.http.*;
import oracle.stellent.ridc.common.http.utils.RIDCHttpConstants.HttpLibrary;
import oracle.stellent.ridc.protocol.http.IdcHttpClientConfig;
import java.util.*;
class RunnableDemo implements Runnable {
private Thread t;
public String threadName;
boolean statucheck=false;
public RIDCUploader RU;
public TransferFile.TransferProgress primaryProgress;
RunnableDemo( String name) {
threadName = name;
RU = new RIDCUploader ();
primaryProgress = RU.priProgress;
statucheck=true;
}
public void run() {
try {
int onlyfiletransfer = 0;
while (true) {
int percent = primaryProgress.getTransferPercentage();
if (percent==100)
{ System.out.print("-->100% \n\n");
System.out.println("time took only for file transfer is "+onlyfiletransfer + " sec" );
System.out.println("Network Speed between client & UCM server is "+RU.sizeinKB/onlyfiletransfer + " KB/sec");
System.out.println("Network Speed between client & UCM server is "+RU.sizeinKB/(1024*onlyfiletransfer) + "MB/sec" );
break;
}
else if (percent==0)
{
System.out.println("Sending File to UCM -----> \n");
onlyfiletransfer = 0;
}
else
{
System.out.print("----->"+percent+"%");
onlyfiletransfer++;
double speedsofar = (RU.sizeinKB * percent)/( onlyfiletransfer * 100);
System.out.print(" speed "+speedsofar+" KB/sec");
double timerequried = RU.sizeinKB/speedsofar;
double eta = timerequried - onlyfiletransfer;
System.out.println(" ETA "+eta + " sec");
}
t.sleep(1000);
}
} catch (InterruptedException e) {
System.out.println("Thread " + threadName + " interrupted.");
}
}
public void start ()
{
System.out.println("Starting " + threadName );
if (t == null)
{
t = new Thread (this, threadName);
t.start ();
if(statucheck )
{
RU.uploaderMethod();
statucheck=false;
}
}
}
}
public class SpeedTest {
public static void main(String args[]) {
RunnableDemo R1 = new RunnableDemo( "Uploadler");
R1.start();
}
}
class RIDCUploader {
File file;
TransferFile TF;
TransferFile.TransferProgress priProgress ;
double sizeinKB;
public RIDCUploader () {
Properties prop = new Properties();
InputStream input = null;
try{
input = new FileInputStream("config.properties");
// load a properties file
prop.load(input);
file = new File ( prop.getProperty("primaryFile") );
TF = new TransferFile (file);
long transferlengrth = TF.getContentLength();
System.out.println("Size of file in bytes " + transferlengrth);
sizeinKB = transferlengrth/1024 ;
System.out.println("Size of file in KB " + sizeinKB);
System.out.println("Size of file in MB " + sizeinKB/(1024));
priProgress = TF.new TransferProgress(transferlengrth);
TF.setTransferListener(priProgress);
} catch (IOException ioe){
ioe.printStackTrace();
}
}
public void uploaderMethod () {
IdcClientManager manager = new IdcClientManager ();
Properties prop = new Properties();
InputStream input = null;
try{
input = new FileInputStream("config.properties");
// load a properties file
prop.load(input);
// Create a new IdcClient Connection using idc protocol (i.e. socket connection to Content Server)
String httpLibrary = "httpurlconnection";
IdcClient idcClient = manager.createClient (prop.getProperty("url"));
IdcClientConfig idcConfig = idcClient.getConfig ();
IdcHttpClientConfig config = (IdcHttpClientConfig)idcConfig;
config.setHttpLibrary(HttpLibrary.valueOf(httpLibrary));
IdcContext userContext = new IdcContext (prop.getProperty("user"),prop.getProperty("password"));
System.out.println("hostname is " + config.getHostName());
System.out.println("Sec is " + config.getSecurityRealm());
config.setSocketTimeout(780000);
System.out.println("Time out value is "+ config.getSocketTimeout());
// Create an HdaBinderSerializer; this is not necessary, but it allows us to serialize the request and response data binders
HdaBinderSerializer serializer = new HdaBinderSerializer ("UTF-8", idcClient.getDataFactory ());
// Create a new binder for submitting a search
DataBinder dataBinder = idcClient.createBinder();
// Databinder for checkin request
dataBinder.putLocal("IdcService", "CHECKIN_UNIVERSAL");
dataBinder.putLocal("dDocType", "Document");
dataBinder.putLocal("dDocAccount", "");
dataBinder.putLocal("dSecurityGroup", "Public");
dataBinder.addFile("primaryFile", TF );
long filesize = file.length();
double filesizeinKB = filesize/(1024);
dataBinder.putLocal("dDocTitle", ("Test RIDC Checkin "+ filesizeinKB));
// Write the data binder for the request to stdout
serializer.serializeBinder (System.out, dataBinder);
// Send the request to Content Server
long currentTimeMillis = System.currentTimeMillis();
ServiceResponse response = idcClient.sendRequest(userContext,dataBinder);
// Get the data binder for the response from Content Server
DataBinder responseData = response.getResponseAsBinder();
System.out.println(" \n ContentID is " + responseData.getLocal("dDocName"));
double timespend = System.currentTimeMillis() - currentTimeMillis;
System.out.println("Time took in UCM server is " + timespend/1000 + " sec");
System.out.println("Processing Capacity of your environment "+ filesizeinKB*1000/timespend + " KB/s");
System.out.println("Processing Capacity of your environment "+ filesizeinKB/timespend + " MB/s");
} catch (IdcClientException ice){
ice.printStackTrace();
} catch (IOException ioe){
ioe.printStackTrace();
}
}
} // end of RIDCUploader class