-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathEqStruct.java
More file actions
executable file
·298 lines (267 loc) · 8.88 KB
/
EqStruct.java
File metadata and controls
executable file
·298 lines (267 loc) · 8.88 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
/*
* 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.
*/
/*
* 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 javaobject;
import java.io.*;
import org.apache.geode.DataSerializable;
//import org.apache.geode.Instantiator;
import org.apache.geode.internal.NanoTimer;
import org.apache.geode.cache.Declarable;
import org.apache.geode.*;
import java.util.Properties;
import java.lang.Exception;
/**
* The EqStruct is based on the Lehman Benchmark and provides us with
* a flat object graph with many fields that implements the DataSerializable
* interface and avoids the overhead associated with reflection during
* seralization.
*
*
*/
public class EqStruct implements Declarable,Serializable,DataSerializable {
private int myIndex;
private String state;
private long timestamp;
private double executedPriceSum;
private int cxlQty;
private int isSyntheticOrder;
private long availQty;
private double positionQty;
private int isRestricted;
private String demandInd;
private String side;
private int orderQty;
private double price;
private String ordType;
private double stopPx;
private String senderCompID;
private String tarCompID;
private String tarSubID;
private String handlInst;
private String orderID;
private String timeInForce;
private String clOrdID;
private String orderCapacity;
private int cumQty;
private String symbol;
private String symbolSfx;
private String execInst;
private String oldClOrdID;
private double pegDifference;
private String discretionInst;
private double discretionOffset;
private String financeInd;
private String securityID;
private String targetCompID;
private String targetSubID;
private int isDoneForDay;
private int revisionSeqNum;
private int replaceQty;
private long usedClientAvailability;
private String clientAvailabilityKey;
private int isIrregularSettlmnt;
private String var1;
private String var2;
private String var3;
private String var4;
private String var5;
private String var6;
private String var7;
private String var8;
private String var9;
static {
Instantiator.register(new Instantiator(EqStruct.class, (byte)101) {
public DataSerializable newInstance() {
return new EqStruct();
}
});
}
public void init( Properties props ) {
this.cxlQty = Integer.parseInt(props.getProperty("cxlQty"));
}
public EqStruct() {
}
/**
* Returns the index encoded in the give <code>byte</code> array.
*
* @throws ObjectAccessException
* The index cannot be decoded from <code>bytes</code>
*/
public int getIndex( ) {
return this.myIndex;
}
//--------------------------------------------------------------------------
// Implementation of UpdatableObject interface
//--------------------------------------------------------------------------
public void update()
{
var1 = "abcdefghi";
cumQty = 39;
usedClientAvailability = 0x8000000000001234L;
discretionOffset = 12.3456789;
resetTimestamp();
}
//--------------------------------------------------------------------------
// Implementation of DataSerializable interface
//--------------------------------------------------------------------------
// INSTANTIATORS DISABLED due to bug 35646
//
// Avoid overhead of reflection via the org.apache.geode.Instantiator class
//static {
// Instantiator.register(new Instantiator(EqStruct.class, (byte) 5) {
// public DataSerializable newInstance() {
// return new EqStruct();
// }
// });
//}
public void toData(DataOutput out) throws IOException {
//Strings
out.writeUTF( state );
out.writeUTF( demandInd );
out.writeUTF( side );
out.writeUTF( ordType );
out.writeUTF( senderCompID );
out.writeUTF( tarCompID );
out.writeUTF( tarSubID );
out.writeUTF( handlInst );
out.writeUTF( orderID );
out.writeUTF( timeInForce );
out.writeUTF( clOrdID );
out.writeUTF( orderCapacity );
out.writeUTF( symbol );
out.writeUTF( symbolSfx );
out.writeUTF( execInst );
out.writeUTF( oldClOrdID );
out.writeUTF( discretionInst );
out.writeUTF( financeInd );
out.writeUTF( securityID );
out.writeUTF( targetCompID );
out.writeUTF( targetSubID );
out.writeUTF( clientAvailabilityKey );
out.writeUTF( var1 );
out.writeUTF( var2 );
out.writeUTF( var3 );
out.writeUTF( var4 );
out.writeUTF( var5 );
out.writeUTF( var6 );
out.writeUTF( var7 );
out.writeUTF( var8 );
out.writeUTF( var9 );
//ints
out.writeInt( myIndex );
out.writeInt( cxlQty );
out.writeInt( isSyntheticOrder );
out.writeInt( isRestricted );
out.writeInt( orderQty );
out.writeInt( cumQty );
out.writeInt( isDoneForDay );
out.writeInt( revisionSeqNum );
out.writeInt( replaceQty );
out.writeInt( isIrregularSettlmnt );
//longs
out.writeLong( timestamp );
out.writeLong( availQty );
out.writeLong( usedClientAvailability );
//doubles
out.writeDouble( executedPriceSum );
out.writeDouble( positionQty );
out.writeDouble( price );
out.writeDouble( stopPx );
out.writeDouble( pegDifference );
out.writeDouble( discretionOffset );
}
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
//Strings
state = in.readUTF();
demandInd = in.readUTF();
side = in.readUTF();
ordType = in.readUTF();
senderCompID = in.readUTF();
tarCompID = in.readUTF();
tarSubID = in.readUTF();
handlInst = in.readUTF();
orderID = in.readUTF();
timeInForce = in.readUTF();
clOrdID = in.readUTF();
orderCapacity = in.readUTF();
symbol = in.readUTF();
symbolSfx = in.readUTF();
execInst = in.readUTF();
oldClOrdID = in.readUTF();
discretionInst = in.readUTF();
financeInd = in.readUTF();
securityID = in.readUTF();
targetCompID = in.readUTF();
targetSubID = in.readUTF();
clientAvailabilityKey = in.readUTF();
var1 = in.readUTF();
var2 = in.readUTF();
var3 = in.readUTF();
var4 = in.readUTF();
var5 = in.readUTF();
var6 = in.readUTF();
var7 = in.readUTF();
var8 = in.readUTF();
var9 = in.readUTF();
//ints
myIndex = in.readInt();
cxlQty = in.readInt();
isSyntheticOrder = in.readInt();
isRestricted = in.readInt();
orderQty = in.readInt();
cumQty = in.readInt();
isDoneForDay = in.readInt();
revisionSeqNum = in.readInt();
replaceQty = in.readInt();
isIrregularSettlmnt = in.readInt();
//longs
timestamp = in.readLong();
availQty = in.readLong();
usedClientAvailability = in.readLong();
//doubles
executedPriceSum = in.readDouble();
positionQty = in.readDouble();
price = in.readDouble();
stopPx = in.readDouble();
pegDifference = in.readDouble();
discretionOffset = in.readDouble();
}
//--------------------------------------------------------------------------
// Implementation of TimestampedObject interface
//--------------------------------------------------------------------------
public long getTimestamp() {
return this.timestamp;
}
public void resetTimestamp() {
this.timestamp = NanoTimer.getTime();
}
}