Skip to content

Commit

Permalink
GEODE-7812: Cleanup for PutAllOp (apache#4836)
Browse files Browse the repository at this point in the history
Cleanup some collection types and interfaces for PutAllOp and
PutAllClientServerDistributedTest.
  • Loading branch information
kirklund authored Mar 25, 2020
1 parent 382cdcd commit 94e2b99
Show file tree
Hide file tree
Showing 24 changed files with 1,404 additions and 820 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Properties;
import java.util.StringTokenizer;

Expand All @@ -34,6 +37,8 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;

import org.apache.geode.DataSerializable;
import org.apache.geode.DataSerializer;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.CacheFactory;
import org.apache.geode.cache.DataPolicy;
Expand All @@ -46,7 +51,6 @@
import org.apache.geode.cache.client.internal.ClientPartitionAdvisor;
import org.apache.geode.cache.server.CacheServer;
import org.apache.geode.distributed.Locator;
import org.apache.geode.distributed.internal.InternalDistributedSystem;
import org.apache.geode.internal.AvailablePort;
import org.apache.geode.internal.cache.execute.data.CustId;
import org.apache.geode.internal.cache.execute.data.OrderId;
Expand All @@ -62,16 +66,17 @@
import org.apache.geode.test.junit.categories.ClientServerTest;
import org.apache.geode.util.internal.GeodeGlossary;

@Category({ClientServerTest.class})
@Category(ClientServerTest.class)
@SuppressWarnings("serial")
public class PartitionedRegionSingleHopWithServerGroupDUnitTest extends JUnit4CacheTestCase {
private static final Logger logger = LogService.getLogger();

private static final String PR_NAME = "single_hop_pr";
private static final String PR_NAME2 = "single_hop_pr_2";
private static final String PR_NAME3 = "single_hop_pr_3";
private static final String CUSTOMER = "CUSTOMER";
private static final String ORDER = "ORDER";
private static final String SHIPMENT = "SHIPMENT";
protected static InternalDistributedSystem system;

private static final String CUSTOMER2 = "CUSTOMER2";
private static final String ORDER2 = "ORDER2";
Expand Down Expand Up @@ -1223,4 +1228,151 @@ private static void setHonourServerGroupsInPRSingleHop() {
System.setProperty(
GeodeGlossary.GEMFIRE_PREFIX + "PoolImpl.honourServerGroupsInPRSingleHop", "True");
}

private static class Customer implements DataSerializable {
private String name;
private String address;

public Customer() {
// nothing
}

public Customer(String name, String address) {
this.name = name;
this.address = address;
}

@Override
public void fromData(DataInput in) throws IOException {
name = DataSerializer.readString(in);
address = DataSerializer.readString(in);

}

@Override
public void toData(DataOutput out) throws IOException {
DataSerializer.writeString(name, out);
DataSerializer.writeString(address, out);
}

@Override
public String toString() {
return "Customer { name=" + name + " address=" + address + "}";
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}

if (!(o instanceof Customer)) {
return false;
}

Customer cust = (Customer) o;
return cust.name.equals(name) && cust.address.equals(address);
}

@Override
public int hashCode() {
return Objects.hash(name, address);
}
}

private static class Order implements DataSerializable {
private String orderName;

public Order() {
// nothing
}

private Order(String orderName) {
this.orderName = orderName;
}

@Override
public void fromData(DataInput in) throws IOException {
orderName = DataSerializer.readString(in);
}

@Override
public void toData(DataOutput out) throws IOException {
DataSerializer.writeString(orderName, out);
}

@Override
public String toString() {
return orderName;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (obj instanceof Order) {
Order other = (Order) obj;
return other.orderName != null && other.orderName.equals(orderName);
}
return false;
}

@Override
public int hashCode() {
if (orderName == null) {
return super.hashCode();
}
return orderName.hashCode();
}
}

private static class Shipment implements DataSerializable {
private String shipmentName;

public Shipment() {
// nothing
}

private Shipment(String shipmentName) {
this.shipmentName = shipmentName;
}

@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
shipmentName = DataSerializer.readString(in);
}

@Override
public void toData(DataOutput out) throws IOException {
DataSerializer.writeString(shipmentName, out);
}

@Override
public String toString() {
return shipmentName;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}

if (obj instanceof Shipment) {
Shipment other = (Shipment) obj;
return other.shipmentName != null && other.shipmentName.equals(shipmentName);
}
return false;
}

@Override
public int hashCode() {
if (shipmentName == null) {
return super.hashCode();
}
return shipmentName.hashCode();
}
}
}
Loading

0 comments on commit 94e2b99

Please sign in to comment.