You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by nn...@apache.org on 2018/12/14 06:35:28 UTC
[geode-benchmarks] branch develop updated: GEODE-6146: Cleaned
Portfolio benchmark object. (#26)
This is an automated email from the ASF dual-hosted git repository.
nnag pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git
The following commit(s) were added to refs/heads/develop by this push:
new 54863e3 GEODE-6146: Cleaned Portfolio benchmark object. (#26)
54863e3 is described below
commit 54863e38edb44e78edf71cf8b95585b1319c9ae6
Author: Nabarun Nag <na...@users.noreply.github.com>
AuthorDate: Thu Dec 13 22:35:24 2018 -0800
GEODE-6146: Cleaned Portfolio benchmark object. (#26)
* Using automatic reflection based pdx serialization
* Cleaned up the statics in the constructors
* Generics are used.
* Removed unused member variable.
---
.../geode}/data/CollectionHolder.java | 20 +-
.../org/apache/benchmark/geode/data/Portfolio.java | 278 ++++++++++++++++++++
.../org/apache/benchmark/geode/data/Position.java | 210 +++++++++++++++
.../geode/benchmark/data/ComparableWrapper.java | 65 -----
.../apache/geode/benchmark/data/PortfolioPdx.java | 287 ---------------------
.../apache/geode/benchmark/data/PositionPdx.java | 175 -------------
.../geode/benchmark/tasks/PrePopulateRegion.java | 4 +-
.../org/apache/geode/benchmark/tasks/PutTask.java | 4 +-
.../apache/geode/benchmark/tasks/StartClient.java | 2 +
.../apache/geode/benchmark/tasks/StartServer.java | 2 +
10 files changed, 501 insertions(+), 546 deletions(-)
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/CollectionHolder.java b/geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/CollectionHolder.java
similarity index 75%
rename from geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/CollectionHolder.java
rename to geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/CollectionHolder.java
index b522ddf..efbb490 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/CollectionHolder.java
+++ b/geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/CollectionHolder.java
@@ -12,19 +12,13 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.geode.benchmark.data;
+package org.apache.benchmark.geode.data;
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-import java.io.Serializable;
import java.util.Arrays;
-import org.apache.geode.DataSerializable;
-import org.apache.geode.DataSerializer;
-public class CollectionHolder implements Serializable, DataSerializable {
+public class CollectionHolder {
public String[] arr;
public static String secIds[] = {"SUN", "IBM", "YHOO", "GOOG", "MSFT", "AOL", "APPL", "ORCL",
@@ -43,15 +37,11 @@ public class CollectionHolder implements Serializable, DataSerializable {
}
public String[] getArr() {
- return this.arr;
+ return arr;
}
- public void fromData(DataInput in) throws IOException, ClassNotFoundException {
- this.arr = DataSerializer.readStringArray(in);
- }
-
- public void toData(DataOutput out) throws IOException {
- DataSerializer.writeStringArray(this.arr, out);
+ public void setArr(String[] arr) {
+ this.arr = arr;
}
@Override
diff --git a/geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/Portfolio.java b/geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/Portfolio.java
new file mode 100644
index 0000000..8505893
--- /dev/null
+++ b/geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/Portfolio.java
@@ -0,0 +1,278 @@
+/*
+ * 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.benchmark.geode.data;
+
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.geode.internal.Assert;
+
+
+public class Portfolio {
+
+ public enum Day {
+ Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
+ }
+
+ public Day aDay;
+ public short shortID;
+ private static transient List dayList;
+ private long ID;
+ public String pkid;
+ public Position position1;
+ public Position position2;
+ public Object[] position3;
+ int position3Size;
+ public String description;
+ public long createTime;
+ public HashMap<String, Position> positions = new HashMap<String, Position>();
+ public HashMap<String, CollectionHolder> collectionHolderMap =
+ new HashMap<String, CollectionHolder>();
+ String type;
+ public String status;
+ public String[] names = {"aaa", "bbb", "ccc", "ddd"};
+ public String unicodeṤtring;
+
+ public static String secIds[] = {"SUN", "IBM", "YHOO", "GOOG", "MSFT", "AOL", "APPL", "ORCL",
+ "SAP", "DELL", "RHAT", "NOVL", "HP"};
+
+ static {
+ dayList = new ArrayList();
+ dayList.addAll(EnumSet.allOf(Day.class));
+ }
+
+ public Portfolio() {}
+
+ public Portfolio(long i) {
+ aDay = (Day) (dayList.get((int) (i % dayList.size())));
+ ID = i;
+ if (i % 2 == 0) {
+ description = null;
+ } else {
+ description = "XXXX";
+ }
+ pkid = "" + i;
+ status = i % 2 == 0 ? "active" : "inactive";
+ type = "type" + (i % 3);
+ position1 = new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000L);
+ if (i % 2 != 0) {
+ position2 = new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000L);
+ } else {
+ position2 = null;
+ }
+
+ positions.put(secIds[Position.cnt % secIds.length],
+ new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000L));
+ positions.put(secIds[Position.cnt % secIds.length],
+ new Position(secIds[Position.cnt % secIds.length], Position.cnt * 1000L));
+
+ collectionHolderMap.put("0", new CollectionHolder());
+ collectionHolderMap.put("1", new CollectionHolder());
+ collectionHolderMap.put("2", new CollectionHolder());
+ collectionHolderMap.put("3", new CollectionHolder());
+
+ unicodeṤtring = i % 2 == 0 ? "ṤṶẐ" : "ṤẐṶ";
+ Assert.assertTrue(unicodeṤtring.length() == 3);
+ }
+
+ public Portfolio(int i, int j) {
+ this(i);
+ this.position1.portfolioId = j;
+ this.position3 = new Object[3];
+ for (int k = 0; k < position3.length; k++) {
+ Position p = new Position(secIds[k], (k + 1) * 1000L);
+ p.portfolioId = (k + 1);
+ this.position3[k] = p;
+ }
+ }
+
+ public Day getaDay() {
+ return aDay;
+ }
+
+ public void setaDay(Day aDay) {
+ this.aDay = aDay;
+ }
+
+ public short getShortID() {
+ return shortID;
+ }
+
+ public void setShortID(short shortID) {
+ this.shortID = shortID;
+ }
+
+ public long getID() {
+ return ID;
+ }
+
+ public void setID(long ID) {
+ this.ID = ID;
+ }
+
+ public String getPkid() {
+ return pkid;
+ }
+
+ public void setPkid(String pkid) {
+ this.pkid = pkid;
+ }
+
+ public Position getPosition1() {
+ return position1;
+ }
+
+ public void setPosition1(Position position1) {
+ this.position1 = position1;
+ }
+
+ public Position getPosition2() {
+ return position2;
+ }
+
+ public void setPosition2(Position position2) {
+ this.position2 = position2;
+ }
+
+ public Object[] getPosition3() {
+ return position3;
+ }
+
+ public void setPosition3(Object[] position3) {
+ this.position3 = position3;
+ }
+
+ public int getPosition3Size() {
+ return position3Size;
+ }
+
+ public void setPosition3Size(int position3Size) {
+ this.position3Size = position3Size;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public long getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(long createTime) {
+ this.createTime = createTime;
+ }
+
+ public HashMap<String, Position> getPositions() {
+ return positions;
+ }
+
+ public void setPositions(HashMap<String, Position> positions) {
+ this.positions = positions;
+ }
+
+ public HashMap<String, CollectionHolder> getCollectionHolderMap() {
+ return collectionHolderMap;
+ }
+
+ public void setCollectionHolderMap(HashMap<String, CollectionHolder> collectionHolderMap) {
+ this.collectionHolderMap = collectionHolderMap;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String[] getNames() {
+ return names;
+ }
+
+ public void setNames(String[] names) {
+ this.names = names;
+ }
+
+ public String getUnicodeṤtring() {
+ return unicodeṤtring;
+ }
+
+ public void setUnicodeṤtring(String unicodeṤtring) {
+ this.unicodeṤtring = unicodeṤtring;
+ }
+
+ public long getLongMinValue() {
+ long longMinValue = Long.MIN_VALUE;
+ return longMinValue;
+ }
+
+ public float getFloatMinValue() {
+ float floatMinValue = Float.MIN_VALUE;
+ return floatMinValue;
+ }
+
+ public double getDoubleMinValue() {
+ double doubleMinValue = Double.MIN_VALUE;
+ return doubleMinValue;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof Portfolio)) {
+ return false;
+ }
+ Portfolio p2 = (Portfolio) o;
+ return this.ID == p2.ID;
+ }
+
+ @Override
+ public int hashCode() {
+ return ((Long) this.ID).hashCode();
+ }
+
+
+ public String toString() {
+ String out =
+ "PortfolioPdx [ID=" + ID + " status=" + status + " type=" + type + " pkid=" + pkid + "\n ";
+ Iterator iter = positions.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ out += entry.getKey() + ":" + entry.getValue() + ", ";
+ }
+ out += "\n P1:" + position1 + ", P2:" + position2;
+ return out + "\n]";
+ }
+
+}
diff --git a/geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/Position.java b/geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/Position.java
new file mode 100644
index 0000000..40a7281
--- /dev/null
+++ b/geode-benchmarks/src/main/java/org/apache/benchmark/geode/data/Position.java
@@ -0,0 +1,210 @@
+/*
+ * 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.benchmark.geode.data;
+
+
+public class Position {
+ private long avg20DaysVol = 0;
+ private String bondRating;
+ private double convRatio;
+ private String country;
+ private double delta;
+ private long industry;
+ private long issuer;
+ private double mktValue;
+ private double qty;
+ public String secId;
+ public String secIdIndexed;
+ private String secLinks;
+ public String secType;
+ private double sharesOutstanding;
+ public String underlyer;
+ private long volatility;
+ private int pid;
+ public static int cnt = 0;
+ public int portfolioId = 0;
+
+ public Position() {}
+
+ public Position(String id, double out) {
+ secId = id;
+ secIdIndexed = secId;
+ sharesOutstanding = out;
+ secType = "a";
+ pid = cnt++;
+ this.mktValue = cnt;
+ }
+
+ public long getAvg20DaysVol() {
+ return avg20DaysVol;
+ }
+
+ public void setAvg20DaysVol(long avg20DaysVol) {
+ this.avg20DaysVol = avg20DaysVol;
+ }
+
+ public String getBondRating() {
+ return bondRating;
+ }
+
+ public void setBondRating(String bondRating) {
+ this.bondRating = bondRating;
+ }
+
+ public double getConvRatio() {
+ return convRatio;
+ }
+
+ public void setConvRatio(double convRatio) {
+ this.convRatio = convRatio;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ public double getDelta() {
+ return delta;
+ }
+
+ public void setDelta(double delta) {
+ this.delta = delta;
+ }
+
+ public long getIndustry() {
+ return industry;
+ }
+
+ public void setIndustry(long industry) {
+ this.industry = industry;
+ }
+
+ public long getIssuer() {
+ return issuer;
+ }
+
+ public void setIssuer(long issuer) {
+ this.issuer = issuer;
+ }
+
+ public double getMktValue() {
+ return mktValue;
+ }
+
+ public void setMktValue(double mktValue) {
+ this.mktValue = mktValue;
+ }
+
+ public double getQty() {
+ return qty;
+ }
+
+ public void setQty(double qty) {
+ this.qty = qty;
+ }
+
+ public String getSecId() {
+ return secId;
+ }
+
+ public void setSecId(String secId) {
+ this.secId = secId;
+ }
+
+ public String getSecIdIndexed() {
+ return secIdIndexed;
+ }
+
+ public void setSecIdIndexed(String secIdIndexed) {
+ this.secIdIndexed = secIdIndexed;
+ }
+
+ public String getSecLinks() {
+ return secLinks;
+ }
+
+ public void setSecLinks(String secLinks) {
+ this.secLinks = secLinks;
+ }
+
+ public String getSecType() {
+ return secType;
+ }
+
+ public void setSecType(String secType) {
+ this.secType = secType;
+ }
+
+ public double getSharesOutstanding() {
+ return sharesOutstanding;
+ }
+
+ public void setSharesOutstanding(double sharesOutstanding) {
+ this.sharesOutstanding = sharesOutstanding;
+ }
+
+ public String getUnderlyer() {
+ return underlyer;
+ }
+
+ public void setUnderlyer(String underlyer) {
+ this.underlyer = underlyer;
+ }
+
+ public long getVolatility() {
+ return volatility;
+ }
+
+ public void setVolatility(long volatility) {
+ this.volatility = volatility;
+ }
+
+ public int getPid() {
+ return pid;
+ }
+
+ public void setPid(int pid) {
+ this.pid = pid;
+ }
+
+ public int getPortfolioId() {
+ return portfolioId;
+ }
+
+ public void setPortfolioId(int portfolioId) {
+ this.portfolioId = portfolioId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof Position))
+ return false;
+ return this.secId.equals(((Position) o).secId);
+ }
+
+ @Override
+ public int hashCode() {
+ return this.secId.hashCode();
+ }
+
+ public String toString() {
+ return "PositionPdx [secId=" + this.secId + " out=" + this.sharesOutstanding + " type="
+ + this.secType + " id=" + this.pid + " mktValue=" + this.mktValue + "]";
+ }
+}
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/ComparableWrapper.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/ComparableWrapper.java
deleted file mode 100644
index d887dea..0000000
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/ComparableWrapper.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.geode.benchmark.data;
-
-
-import java.io.Serializable;
-
-public class ComparableWrapper implements Comparable, Serializable {
- private int val;
-
- /** Creates a new instance of ComparableWrapper */
- public ComparableWrapper() {}
-
- public ComparableWrapper(int x) {
- this.val = x;
- }
-
- public int getVal() {
- return this.val;
- }
-
- public int hashCode() {
- return val;
- }
-
- public int compareTo(Object obj) {
- if (!(obj instanceof ComparableWrapper)) {
- throw new ClassCastException(
- "Can't compare Object " + obj + " : Not of type ComparableWrapper");
- } else {
- ComparableWrapper cwObj = (ComparableWrapper) obj;
- if (cwObj.getVal() == this.val) {
- return 0;
- } else if (cwObj.getVal() > this.val) {
- return -1;
- } else
- return 1;
- }
- }
-
- public boolean equals(Object obj) {
- if (!(obj instanceof ComparableWrapper)) {
- return false;
- } else {
- ComparableWrapper cwObj = (ComparableWrapper) obj;
- if (cwObj.getVal() == this.val) {
- return true;
- } else {
- return false;
- }
- }
- }
-}
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/PortfolioPdx.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/PortfolioPdx.java
deleted file mode 100644
index 3a35864..0000000
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/PortfolioPdx.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * 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.geode.benchmark.data;
-
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.geode.internal.Assert;
-import org.apache.geode.pdx.PdxReader;
-import org.apache.geode.pdx.PdxSerializable;
-import org.apache.geode.pdx.PdxWriter;
-
-
-public class PortfolioPdx implements Serializable, PdxSerializable {
- public static boolean DEBUG = false;
-
- public enum Day {
- Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
- }
-
- public Day aDay;
- public short shortID;
- static transient List dayList;
- private long ID;
- public String pkid;
- public PositionPdx position1;
- public PositionPdx position2;
- public Object[] position3;
- int position3Size;
- public String description;
- public long createTime;
- public HashMap positions = new HashMap();
- public HashMap collectionHolderMap = new HashMap();
- String type;
- public String status;
- public String[] names = {"aaa", "bbb", "ccc", "ddd"};
- public String unicodeṤtring;
- private final long longMinValue = Long.MIN_VALUE;
- private final float floatMinValue = Float.MIN_VALUE;
- private final double doubleMinValue = Double.MIN_VALUE;
-
- public static int numInstance = 0;
-
- public long getID() {
- return ID;
- }
-
- public long getCreateTime() {
- return this.createTime;
- }
-
- public void setCreateTime(long time) {
- this.createTime = time;
- }
-
- public String getPk() {
- return pkid;
- }
-
- public HashMap getPositions() {
- return positions;
- }
-
- public HashMap getPositions(String str) {
- return positions;
- }
-
- public HashMap getPositions(Integer i) {
- return positions;
- }
-
- public HashMap getPositions(int i) {
- return positions;
- }
-
- public PositionPdx getP1() {
- return position1;
- }
-
- public PositionPdx getP2() {
- return position2;
- }
-
- public HashMap getCollectionHolderMap() {
- return collectionHolderMap;
- }
-
- public ComparableWrapper getCW(int x) {
- return new ComparableWrapper(x);
- }
-
- public boolean testMethod(boolean booleanArg) {
- return true;
- }
-
- public boolean isActive() {
- return status.equals("active");
- }
-
- public static String secIds[] = {"SUN", "IBM", "YHOO", "GOOG", "MSFT", "AOL", "APPL", "ORCL",
- "SAP", "DELL", "RHAT", "NOVL", "HP"};
-
- static {
- dayList = new ArrayList();
- dayList.addAll(EnumSet.allOf(Day.class));
- }
-
- /* public no-arg constructor required for Deserializable */
- public PortfolioPdx() {
- this.numInstance++;
- if (DEBUG)
- Thread.dumpStack();
- }
-
- public PortfolioPdx(long i) {
- aDay = (Day) (dayList.get((int) (i % dayList.size())));
- if (DEBUG)
- Thread.dumpStack();
- this.numInstance++;
- ID = i;
- if (i % 2 == 0) {
- description = null;
- } else {
- description = "XXXX";
- }
- pkid = "" + i;
- status = i % 2 == 0 ? "active" : "inactive";
- type = "type" + (i % 3);
- position1 = new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt * 1000L);
- if (i % 2 != 0) {
- position2 = new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt * 1000L);
- } else {
- position2 = null;
- }
-
- positions.put(secIds[PositionPdx.cnt % secIds.length],
- new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt * 1000L));
- positions.put(secIds[PositionPdx.cnt % secIds.length],
- new PositionPdx(secIds[PositionPdx.cnt % secIds.length], PositionPdx.cnt * 1000L));
-
- collectionHolderMap.put("0", new CollectionHolder());
- collectionHolderMap.put("1", new CollectionHolder());
- collectionHolderMap.put("2", new CollectionHolder());
- collectionHolderMap.put("3", new CollectionHolder());
-
- unicodeṤtring = i % 2 == 0 ? "ṤṶẐ" : "ṤẐṶ";
- Assert.assertTrue(unicodeṤtring.length() == 3);
- }
-
- public PortfolioPdx(int i, int j) {
- this(i);
- this.position1.portfolioId = j;
- this.position3 = new Object[3];
- for (int k = 0; k < position3.length; k++) {
- PositionPdx p = new PositionPdx(secIds[k], (k + 1) * 1000L);
- p.portfolioId = (k + 1);
- this.position3[k] = p;
- }
- }
-
- private boolean eq(Object o1, Object o2) {
- return o1 == null ? o2 == null : o1.equals(o2);
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof PortfolioPdx)) {
- return false;
- }
- PortfolioPdx p2 = (PortfolioPdx) o;
- return this.ID == p2.ID;
- }
-
- @Override
- public int hashCode() {
- return ((Long) this.ID).hashCode();
- }
-
-
- public String toString() {
- String out =
- "PortfolioPdx [ID=" + ID + " status=" + status + " type=" + type + " pkid=" + pkid + "\n ";
- Iterator iter = positions.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- out += entry.getKey() + ":" + entry.getValue() + ", ";
- }
- out += "\n P1:" + position1 + ", P2:" + position2;
- return out + "\n]";
- }
-
- /**
- * Getter for property type.S
- *
- * @return Value of property type.
- */
- public String getType() {
- return this.type;
- }
-
- public boolean boolFunction(String strArg) {
- return "active".equals(strArg);
- } // added by vikramj
-
- public int intFunction(int j) {
- return j;
- } // added by vikramj
-
- public String funcReturnSecId(Object o) {
- return ((PositionPdx) o).getSecId();
- }
-
- public long longFunction(long j) {
- return j;
- }
-
- public float getFloatMinValue() {
- return this.floatMinValue;
- }
-
- public float getLongMinValue() {
- return this.longMinValue;
- }
-
- public double getDoubleMinValue() {
- return this.doubleMinValue;
- }
-
- public void fromData(PdxReader in) {
- this.ID = in.readLong("ID");
- this.shortID = in.readShort("shortID");
- this.pkid = in.readString("pkid");
- this.position1 = (PositionPdx) in.readObject("position1");
- this.position2 = (PositionPdx) in.readObject("position2");
- this.positions = (HashMap) in.readObject("positions");
- this.collectionHolderMap = (HashMap) in.readObject("collectionHolderMap");
- this.type = in.readString("type");
- this.status = in.readString("status");
- this.names = in.readStringArray("names");
- this.description = in.readString("description");
- this.createTime = in.readLong("createTime");
- // Read Position3
- this.position3 = in.readObjectArray("position3");
- this.aDay = (Day) in.readObject("aDay");
- }
-
- public void toData(PdxWriter out) {
- out.writeLong("ID", this.ID);
- out.writeShort("shortID", this.shortID);
- out.writeString("pkid", this.pkid);
- out.writeObject("position1", this.position1);
- out.writeObject("position2", this.position2);
- out.writeObject("positions", this.positions);
- out.writeObject("collectionHolderMap", this.collectionHolderMap);
- out.writeString("type", this.type);
- out.writeString("status", this.status);
- out.writeStringArray("names", this.names);
- out.writeString("description", this.description);
- out.writeLong("createTime", this.createTime);
- // Write Position3.
- out.writeObjectArray("position3", this.position3);
- out.writeObject("aDay", aDay);
- // Identity Field.
- out.markIdentityField("ID");
- }
-
-}
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/PositionPdx.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/PositionPdx.java
deleted file mode 100644
index f899a78..0000000
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/data/PositionPdx.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * 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.geode.benchmark.data;
-
-
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.geode.pdx.PdxReader;
-import org.apache.geode.pdx.PdxSerializable;
-import org.apache.geode.pdx.PdxWriter;
-
-
-public class PositionPdx implements Serializable, PdxSerializable, Comparable {
- private long avg20DaysVol = 0;
- private String bondRating;
- private double convRatio;
- private String country;
- private double delta;
- private long industry;
- private long issuer;
- private double mktValue;
- private double qty;
- public String secId;
- public String secIdIndexed;
- private String secLinks;
- public String secType;
- private double sharesOutstanding;
- public String underlyer;
- private long volatility;
- private int pid;
- public static int cnt = 0;
- public int portfolioId = 0;
-
- public static int numInstance = 0;
-
- /* public no-arg constructor required for DataSerializable */
- public PositionPdx() {
- this.numInstance++;
- }
-
- public PositionPdx(String id, double out) {
- secId = id;
- secIdIndexed = secId;
- sharesOutstanding = out;
- secType = "a";
- pid = cnt++;
- this.mktValue = cnt;
- this.numInstance++;
- }
-
- @Override
- public boolean equals(Object o) {
- if (!(o instanceof PositionPdx))
- return false;
- return this.secId.equals(((PositionPdx) o).secId);
- }
-
- @Override
- public int hashCode() {
- return this.secId.hashCode();
- }
-
-
- public static void resetCounter() {
- cnt = 0;
- }
-
- public double getMktValue() {
- return this.mktValue;
- }
-
- public String getSecId() {
- return secId;
- }
-
- public int getId() {
- return pid;
- }
-
- public double getSharesOutstanding() {
- return sharesOutstanding;
- }
-
- public String toString() {
- return "PositionPdx [secId=" + this.secId + " out=" + this.sharesOutstanding + " type="
- + this.secType + " id=" + this.pid + " mktValue=" + this.mktValue + "]";
- }
-
- public Set getSet(int size) {
- Set set = new HashSet();
- for (int i = 0; i < size; i++) {
- set.add("" + i);
- }
- return set;
- }
-
- public Set getCol() {
- Set set = new HashSet();
- for (int i = 0; i < 2; i++) {
- set.add("" + i);
- }
- return set;
- }
-
- public int getPid() {
- return pid;
- }
-
- public void fromData(PdxReader in) {
- this.avg20DaysVol = in.readLong("avg20DaysVol");
- this.bondRating = in.readString("bondRating");
- this.convRatio = in.readDouble("convRatio");
- this.country = in.readString("country");
- this.delta = in.readDouble("delta");
- this.industry = in.readLong("industry");
- this.issuer = in.readLong("issuer");
- this.mktValue = in.readDouble("mktValue");
- this.qty = in.readDouble("qty");
- this.secId = in.readString("secId");
- this.secIdIndexed = in.readString("secIdIndexed");
- this.secLinks = in.readString("secLinks");
- this.sharesOutstanding = in.readDouble("sharesOutstanding");
- this.underlyer = in.readString("underlyer");
- this.volatility = in.readLong("volatility");
- this.pid = in.readInt("pid");
- this.portfolioId = in.readInt("portfolioId");
- }
-
- public void toData(PdxWriter out) {
- out.writeLong("avg20DaysVol", this.avg20DaysVol);
- out.writeString("bondRating", this.bondRating);
- out.writeDouble("convRatio", this.convRatio);
- out.writeString("country", this.country);
- out.writeDouble("delta", this.delta);
- out.writeLong("industry", this.industry);
- out.writeLong("issuer", this.issuer);
- out.writeDouble("mktValue", this.mktValue);
- out.writeDouble("qty", this.qty);
- out.writeString("secId", this.secId);
- out.writeString("secIdIndexed", this.secIdIndexed);
- out.writeString("secLinks", this.secLinks);
- out.writeDouble("sharesOutstanding", this.sharesOutstanding);
- out.writeString("underlyer", this.underlyer);
- out.writeLong("volatility", this.volatility);
- out.writeInt("pid", this.pid);
- out.writeInt("portfolioId", this.portfolioId);
- // Identity Field.
- out.markIdentityField("secId");
- }
-
-
- public int compareTo(Object o) {
- if (o == this || ((PositionPdx) o).secId.equals(this.secId)) {
- return 0;
- } else {
- return this.pid < ((PositionPdx) o).pid ? -1 : 1;
- }
-
- }
-
-}
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PrePopulateRegion.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PrePopulateRegion.java
index 462f0b3..4ec028c 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PrePopulateRegion.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PrePopulateRegion.java
@@ -21,10 +21,10 @@ import java.time.Instant;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.LongStream;
+import org.apache.benchmark.geode.data.Portfolio;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.geode.benchmark.data.PortfolioPdx;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.Region;
import org.apache.geode.perftest.Task;
@@ -56,7 +56,7 @@ public class PrePopulateRegion implements Task {
Instant start = Instant.now();
LongStream.range(0, keyRangeToPrepopulate).forEach(i -> {
long value = ThreadLocalRandom.current().nextLong(0, keyRangeToPrepopulate);
- region.put(i, new PortfolioPdx(value));
+ region.put(i, new Portfolio(value));
});
Instant finish = Instant.now();
logger.info("*******************************************");
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PutTask.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PutTask.java
index 348dc05..9650057 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PutTask.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PutTask.java
@@ -21,10 +21,10 @@ import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
+import org.apache.benchmark.geode.data.Portfolio;
import org.yardstickframework.BenchmarkConfiguration;
import org.yardstickframework.BenchmarkDriverAdapter;
-import org.apache.geode.benchmark.data.PortfolioPdx;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientCacheFactory;
@@ -49,7 +49,7 @@ public class PutTask extends BenchmarkDriverAdapter implements Serializable {
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
long key = ThreadLocalRandom.current().nextLong(0, this.keyRange);
- region.put(key, new PortfolioPdx(key));
+ region.put(key, new Portfolio(key));
return true;
}
}
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartClient.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartClient.java
index 393213c..add2309 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartClient.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartClient.java
@@ -24,6 +24,7 @@ import org.apache.geode.benchmark.parameters.GeodeProperties;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientCacheFactory;
import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.pdx.ReflectionBasedAutoSerializer;
import org.apache.geode.perftest.Task;
import org.apache.geode.perftest.TestContext;
@@ -45,6 +46,7 @@ public class StartClient implements Task {
String statsFile = new File(context.getOutputDir(), "stats.gfs").getAbsolutePath();
ClientCache clientCache = new ClientCacheFactory(GeodeProperties.clientProperties())
+ .setPdxSerializer(new ReflectionBasedAutoSerializer("org.apache.benchmark.geode.data.*"))
.addPoolLocator(locator.getHostAddress(), locatorPort)
.set(ConfigurationProperties.STATISTIC_ARCHIVE_FILE, statsFile)
.create();
diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
index b666b60..e1cedde 100644
--- a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
+++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/StartServer.java
@@ -25,6 +25,7 @@ import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.server.CacheServer;
import org.apache.geode.distributed.ConfigurationProperties;
+import org.apache.geode.pdx.ReflectionBasedAutoSerializer;
import org.apache.geode.perftest.Task;
import org.apache.geode.perftest.TestContext;
@@ -45,6 +46,7 @@ public class StartServer implements Task {
String locatorString = LocatorUtil.getLocatorString(context, locatorPort);
String statsFile = new File(context.getOutputDir(), "stats.gfs").getAbsolutePath();
Cache cache = new CacheFactory(GeodeProperties.serverProperties())
+ .setPdxSerializer(new ReflectionBasedAutoSerializer("org.apache.benchmark.geode.data.*"))
.set(ConfigurationProperties.LOCATORS, locatorString)
.set(ConfigurationProperties.NAME,
"server-" + context.getJvmID() + "-" + InetAddress.getLocalHost())