KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > test > server > appserver > load > DataKeeperRequest


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.test.server.appserver.load;
5
6 import org.apache.commons.httpclient.HttpClient;
7
8 import com.tc.util.Assert;
9
10 import java.net.URL JavaDoc;
11
12 public class DataKeeperRequest implements Request {
13
14   private static final int UNDEFINED = -1;
15   private long enterQueueTime;
16   private long exitQueueTime;
17   private long processCompletionTime;
18   private final HttpClient client;
19   private final int appserverID;
20   private final URL JavaDoc url;
21
22   public DataKeeperRequest(HttpClient client, int appserverID, URL JavaDoc url) {
23     this.client = client;
24     this.appserverID = appserverID;
25     this.url = url;
26     this.enterQueueTime = UNDEFINED;
27     this.exitQueueTime = UNDEFINED;
28     this.processCompletionTime = UNDEFINED;
29   }
30
31   public void setEnterQueueTime() {
32     Assert.assertEquals(UNDEFINED, this.enterQueueTime);
33     // this.enterQueueTime = System.nanoTime();
34
this.enterQueueTime = System.currentTimeMillis();
35   }
36
37   public void setExitQueueTime() {
38     Assert.assertEquals(UNDEFINED, this.exitQueueTime);
39     // this.exitQueueTime = System.nanoTime();
40
this.exitQueueTime = System.currentTimeMillis();
41   }
42
43   public void setProcessCompletionTime() {
44     Assert.assertEquals(UNDEFINED, this.processCompletionTime);
45     // this.processCompletionTime = System.nanoTime();
46
this.processCompletionTime = System.currentTimeMillis();
47   }
48
49   public URL JavaDoc getUrl() {
50     return this.url;
51   }
52
53   public long getEnterQueueTime() {
54     return this.enterQueueTime;
55   }
56
57   public long getExitQueueTime() {
58     return this.exitQueueTime;
59   }
60
61   public long getProcessCompletionTime() {
62     return this.processCompletionTime;
63   }
64
65   public HttpClient getClient() {
66     return this.client;
67   }
68
69   public int getAppserverID() {
70     return this.appserverID;
71   }
72
73   public String JavaDoc toString() {
74     return "client=" + this.client + " AppserverID=" + this.appserverID;
75   }
76
77   public String JavaDoc printData() {
78
79     return this.enterQueueTime + "," + this.exitQueueTime + "," + this.processCompletionTime + this.appserverID + ","
80            + this.client + "," + this.client.getState().getCookies()[0].toString();
81   }
82 }
83
Popular Tags