1
|
/**
|
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 java.time.Duration;
|
13
|
import java.time.ZonedDateTime;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
|
17
|
|
18
|
|
19
|
/**
|
20
|
* @author a.mueller
|
21
|
* @created 21.02.2010
|
22
|
* @version 1.0
|
23
|
*/
|
24
|
public class PartitionerProfiler {
|
25
|
private static final Logger logger = Logger.getLogger(PartitionerProfiler.class);
|
26
|
|
27
|
ResultSetPartitioner partitioner;
|
28
|
|
29
|
ZonedDateTime startTx = ZonedDateTime.now();
|
30
|
ZonedDateTime startRs = ZonedDateTime.now();
|
31
|
ZonedDateTime startRelObjects = ZonedDateTime.now();
|
32
|
ZonedDateTime startRS2 = ZonedDateTime.now();
|
33
|
ZonedDateTime startDoPartition = ZonedDateTime.now();
|
34
|
ZonedDateTime startDoSave = ZonedDateTime.now();
|
35
|
ZonedDateTime startDoCommit = ZonedDateTime.now();
|
36
|
ZonedDateTime end = ZonedDateTime.now();
|
37
|
|
38
|
private Duration durTxStartAll =Duration.ofMinutes(0);
|
39
|
private Duration durPartitionRs1All= Duration.ofMinutes(0);
|
40
|
private Duration durRelObjectsAll = Duration.ofMinutes(0);
|
41
|
private Duration durPartitionRs2All =Duration.ofMinutes(0);
|
42
|
private Duration durPartitionAll = Duration.ofMinutes(0);
|
43
|
private Duration durTxCommitAll = Duration.ofMinutes(0);
|
44
|
private Duration durSaveAll = Duration.ofMinutes(0);
|
45
|
|
46
|
|
47
|
private Duration durTxStartSingle;
|
48
|
private Duration durPartitionRs1Single;
|
49
|
private Duration durRelObjectsSingle;
|
50
|
private Duration durPartitionRs2Single;
|
51
|
private Duration durPartitionSingle;
|
52
|
private Duration durSaveSingle;
|
53
|
private Duration durTxCommitSingle;
|
54
|
|
55
|
public void startTx(){
|
56
|
startTx = ZonedDateTime.now();
|
57
|
|
58
|
}
|
59
|
|
60
|
public void startRs(){
|
61
|
startRs = ZonedDateTime.now();
|
62
|
|
63
|
durTxStartSingle = Duration.between(startTx, startRs);
|
64
|
durTxStartAll = durTxStartAll.plus(durTxStartSingle);
|
65
|
}
|
66
|
|
67
|
public void startRelObjects(){
|
68
|
startRelObjects =ZonedDateTime.now();
|
69
|
durPartitionRs1Single = Duration.between(startRs, startRelObjects);
|
70
|
durPartitionRs1All= durPartitionRs1All.plus(durPartitionRs1Single);
|
71
|
}
|
72
|
|
73
|
public void startRs2(){
|
74
|
startRS2 = ZonedDateTime.now();
|
75
|
durRelObjectsSingle = Duration.between(startRelObjects, startRS2);
|
76
|
durRelObjectsAll = durRelObjectsAll.plus(durRelObjectsSingle);
|
77
|
}
|
78
|
|
79
|
public void startDoPartition(){
|
80
|
startDoPartition = ZonedDateTime.now();
|
81
|
startDoSave = ZonedDateTime.now();
|
82
|
durPartitionRs2Single = Duration.between(startRS2, startDoPartition);
|
83
|
durPartitionRs2All = durPartitionRs2All.plus(durPartitionRs2Single);
|
84
|
}
|
85
|
|
86
|
public void startDoSave(){
|
87
|
startDoSave = ZonedDateTime.now();
|
88
|
//durSaveSingle = new Duration(startRS2, startSave);
|
89
|
//durPartitionRs2All = durPartitionRs2All.withDurationAdded(durPartitionRs2Single, 1);
|
90
|
}
|
91
|
|
92
|
public void startDoCommit(){
|
93
|
startDoCommit = ZonedDateTime.now();
|
94
|
durPartitionSingle = Duration.between(startDoPartition, startDoCommit);
|
95
|
durPartitionAll = durPartitionAll.plus(durPartitionSingle);
|
96
|
durSaveSingle = Duration.between(startDoSave, startDoCommit);
|
97
|
durSaveAll = durSaveAll.plus(durSaveSingle);
|
98
|
}
|
99
|
|
100
|
public void end(){
|
101
|
end = ZonedDateTime.now();
|
102
|
durTxCommitSingle = Duration.between(startDoCommit, end);
|
103
|
durTxCommitAll = durTxCommitAll.plus(durTxCommitSingle);
|
104
|
}
|
105
|
|
106
|
public void print(){
|
107
|
if (logger.isDebugEnabled()){
|
108
|
System.out.println("Durations: " +
|
109
|
"Start Transaction: " + durTxStartSingle.getNano() + "/" + durTxStartAll.getNano() +
|
110
|
"; partitionRS1: " + durPartitionRs1Single.getNano() + "/" + durPartitionRs1All.getNano()+
|
111
|
"; getRelatedObjects: " + durRelObjectsSingle.getNano() + "/" + durRelObjectsAll.getNano() +
|
112
|
"; partitionRS2 " + durPartitionRs2Single.getNano() + "/" + durPartitionRs2All.getNano() +
|
113
|
"; doPartition " + durPartitionSingle.getNano() + "/" + durPartitionAll.getNano() +
|
114
|
"; doSave " + durSaveSingle.getNano() + "/" + durSaveAll.getNano() +
|
115
|
"; commit " + durTxCommitSingle.getNano() + "/" + durTxCommitAll.getNano()
|
116
|
);
|
117
|
}
|
118
|
}
|
119
|
|
120
|
}
|