-
Notifications
You must be signed in to change notification settings - Fork 993
/
Scenario.java
232 lines (200 loc) · 5.85 KB
/
Scenario.java
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
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.phoenix.pherf.configuration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.phoenix.pherf.util.PhoenixUtil;
@XmlRootElement(namespace = "org.apache.phoenix.pherf.configuration.DataModel")
public class Scenario {
private String tableName;
private int rowCount;
private Map<String, String> phoenixProperties;
private DataOverride dataOverride;
private List<QuerySet> querySet = new ArrayList<>();
private WriteParams writeParams = null;
private String name;
private String tenantId;
private List<Ddl> preScenarioDdls;
private List<Ddl> postScenarioDdls;
public Scenario() {
}
/**
* Scenarios have to have unique table names
*
* @param object
* @return
*/
@Override
public boolean equals(Object object) {
Scenario scenario = (Scenario) object;
return (this.tableName.equals(scenario.getTableName()));
}
@Override
public int hashCode() {
return new HashCodeBuilder(11, 38).appendSuper(super.hashCode())
.append(tableName)
.toHashCode();
}
/**
* Table name for a scenario
*
* @return
*/
@XmlAttribute()
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
/**
* Row count for a table
*
* @return
*/
@XmlAttribute()
public int getRowCount() {
return PhoenixUtil.getRowCountOverride() == 0 ?
rowCount : PhoenixUtil.getRowCountOverride();
}
public void setRowCount(int rowCount) {
this.rowCount = rowCount;
}
/**
* Phoenix properties
*
* @return
*/
public Map<String, String> getPhoenixProperties() {
return phoenixProperties;
}
public void setPhoenixProperties(Map<String, String> phoenixProperty) {
this.phoenixProperties = phoenixProperty;
}
/**
* Data override
*
* @return
*/
@XmlElement()
public DataOverride getDataOverride() {
return dataOverride;
}
public void setDataOverride(DataOverride dataOverride) {
this.dataOverride = dataOverride;
}
/**
* List of Query Set
*
* @return
*/
public List<QuerySet> getQuerySet() {
return querySet;
}
@SuppressWarnings("unused")
public void setQuerySet(List<QuerySet> querySet) {
this.querySet = querySet;
}
/**
* Extract schema name from table name
*
* @return
*/
public String getSchemaName() {
return XMLConfigParser.parseSchemaName(this.tableName);
}
/**
* Extract table name without schema name
*
* @return
*/
public String getTableNameWithoutSchemaName() {
return XMLConfigParser.parseTableName(this.tableName);
}
/**
* Name of scenario
*
* @return
*/
@XmlAttribute()
public String getName() {
Preconditions.checkNotNull(name);
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* Tenant Id used by connection of this query
* @return
*/
@XmlAttribute
public String getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public WriteParams getWriteParams() {
return writeParams;
}
public void setWriteParams(WriteParams writeParams) {
this.writeParams = writeParams;
}
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Name:" + name);
stringBuilder.append("Table Name:" + tableName);
stringBuilder.append("Row Count:" + rowCount);
stringBuilder.append("Data Override:" + dataOverride);
for (QuerySet query : querySet) {
stringBuilder.append(query + ";");
}
return stringBuilder.toString();
}
public List<Ddl> getPreScenarioDdls() {
return preScenarioDdls;
}
/**
* Scenario level DDLs (for views/index/async) that are executed before data load
*/
@XmlElementWrapper(name = "preScenarioDdls")
@XmlElement(name = "ddl")
public void setPreScenarioDdls(List<Ddl> preScenarioDdls) {
this.preScenarioDdls = preScenarioDdls;
}
public List<Ddl> getPostScenarioDdls() {
return postScenarioDdls;
}
/**
* Scenario level DDLs (for views/index/async) that are executed after data load
*/
@XmlElementWrapper(name = "postScenarioDdls")
@XmlElement(name = "ddl")
public void setPostScenarioDdls(List<Ddl> postScenarioDdls) {
this.postScenarioDdls = postScenarioDdls;
}
}