1 |
42a6220b
|
Katja Luther
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*
|
6 |
|
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7 |
|
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8 |
|
|
*/
|
9 |
|
|
|
10 |
|
|
package eu.etaxonomy.cdm.io.common;
|
11 |
|
|
|
12 |
|
|
import org.apache.log4j.Logger;
|
13 |
|
|
import org.joda.time.DateTime;
|
14 |
|
|
import org.joda.time.Duration;
|
15 |
|
|
import org.joda.time.ReadableDuration;
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
/**
|
19 |
|
|
* @author a.mueller
|
20 |
|
|
* @created 21.02.2010
|
21 |
|
|
* @version 1.0
|
22 |
|
|
*/
|
23 |
|
|
public class PartitionerProfiler {
|
24 |
|
|
private static final Logger logger = Logger.getLogger(PartitionerProfiler.class);
|
25 |
|
|
|
26 |
|
|
ResultSetPartitioner partitioner;
|
27 |
|
|
|
28 |
|
|
DateTime startTx = new DateTime();
|
29 |
|
|
DateTime startRs = new DateTime();
|
30 |
|
|
DateTime startRelObjects = new DateTime();
|
31 |
|
|
DateTime startRS2 = new DateTime();
|
32 |
|
|
DateTime startDoPartition = new DateTime();
|
33 |
|
|
DateTime startDoSave = new DateTime();
|
34 |
|
|
DateTime startDoCommit = new DateTime();
|
35 |
|
|
DateTime end = new DateTime();
|
36 |
|
|
|
37 |
|
|
private Duration durTxStartAll = new Duration(0, 0);
|
38 |
|
|
private Duration durPartitionRs1All= new Duration(0, 0);
|
39 |
|
|
private Duration durRelObjectsAll = new Duration(0, 0);
|
40 |
|
|
private Duration durPartitionRs2All =new Duration(0, 0);
|
41 |
|
|
private Duration durPartitionAll = new Duration(0, 0);
|
42 |
|
|
private Duration durTxCommitAll = new Duration(0, 0);
|
43 |
|
|
private Duration durSaveAll = new Duration(0, 0);
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
private ReadableDuration durTxStartSingle;
|
47 |
|
|
private ReadableDuration durPartitionRs1Single;
|
48 |
|
|
private ReadableDuration durRelObjectsSingle;
|
49 |
|
|
private ReadableDuration durPartitionRs2Single;
|
50 |
|
|
private ReadableDuration durPartitionSingle;
|
51 |
|
|
private ReadableDuration durSaveSingle;
|
52 |
|
|
private ReadableDuration durTxCommitSingle;
|
53 |
|
|
|
54 |
|
|
public void startTx(){
|
55 |
|
|
startTx = new DateTime();
|
56 |
|
|
|
57 |
|
|
}
|
58 |
|
|
|
59 |
|
|
public void startRs(){
|
60 |
|
|
startRs = new DateTime();
|
61 |
|
|
durTxStartSingle = new Duration(startTx, startRs);
|
62 |
|
|
durTxStartAll = durTxStartAll.withDurationAdded(durTxStartSingle, 1);
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
public void startRelObjects(){
|
66 |
|
|
startRelObjects = new DateTime();
|
67 |
|
|
durPartitionRs1Single = new Duration(startRs, startRelObjects);
|
68 |
|
|
durPartitionRs1All= durPartitionRs1All.withDurationAdded(durPartitionRs1Single, 1);
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
public void startRs2(){
|
72 |
|
|
startRS2 = new DateTime();
|
73 |
|
|
durRelObjectsSingle = new Duration(startRelObjects, startRS2);
|
74 |
|
|
durRelObjectsAll = durRelObjectsAll.withDurationAdded(durRelObjectsSingle, 1);
|
75 |
|
|
}
|
76 |
|
|
|
77 |
|
|
public void startDoPartition(){
|
78 |
|
|
startDoPartition = new DateTime();
|
79 |
|
|
startDoSave = new DateTime();
|
80 |
|
|
durPartitionRs2Single = new Duration(startRS2, startDoPartition);
|
81 |
|
|
durPartitionRs2All = durPartitionRs2All.withDurationAdded(durPartitionRs2Single, 1);
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
public void startDoSave(){
|
85 |
|
|
startDoSave = new DateTime();
|
86 |
|
|
//durSaveSingle = new Duration(startRS2, startSave);
|
87 |
|
|
//durPartitionRs2All = durPartitionRs2All.withDurationAdded(durPartitionRs2Single, 1);
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
public void startDoCommit(){
|
91 |
|
|
startDoCommit = new DateTime();
|
92 |
|
|
durPartitionSingle = new Duration(startDoPartition, startDoCommit);
|
93 |
|
|
durPartitionAll = durPartitionAll.withDurationAdded(durPartitionSingle, 1);
|
94 |
|
|
durSaveSingle = new Duration(startDoSave, startDoCommit);
|
95 |
|
|
durSaveAll = durSaveAll.withDurationAdded(durSaveSingle, 1);
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
public void end(){
|
99 |
|
|
end = new DateTime();
|
100 |
|
|
durTxCommitSingle = new Duration(startDoCommit, end);
|
101 |
|
|
durTxCommitAll = durTxCommitAll.withDurationAdded(durTxCommitSingle, 1);
|
102 |
|
|
}
|
103 |
|
|
|
104 |
|
|
public void print(){
|
105 |
f07264f3
|
Katja Luther
|
if (logger.isDebugEnabled()){
|
106 |
892efc69
|
Andreas Kohlbecker
|
System.out.println("Durations: " +
|
107 |
|
|
"Start Transaction: " + durTxStartSingle.getMillis() + "/" + durTxStartAll.getMillis() +
|
108 |
|
|
"; partitionRS1: " + durPartitionRs1Single.getMillis() + "/" + durPartitionRs1All.getMillis() +
|
109 |
|
|
"; getRelatedObjects: " + durRelObjectsSingle.getMillis() + "/" + durRelObjectsAll.getMillis() +
|
110 |
|
|
"; partitionRS2 " + durPartitionRs2Single.getMillis() + "/" + durPartitionRs2All.getMillis() +
|
111 |
|
|
"; doPartition " + durPartitionSingle.getMillis() + "/" + durPartitionAll.getMillis() +
|
112 |
|
|
"; doSave " + durSaveSingle.getMillis() + "/" + durSaveAll.getMillis() +
|
113 |
|
|
"; commit " + durTxCommitSingle.getMillis() + "/" + durTxCommitAll.getMillis()
|
114 |
|
|
);
|
115 |
|
|
}
|
116 |
f07264f3
|
Katja Luther
|
}
|
117 |
42a6220b
|
Katja Luther
|
|
118 |
|
|
}
|