http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/company/app/OrdersCacheListener.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/company/app/OrdersCacheListener.java b/geode-core/src/test/java/org/company/app/OrdersCacheListener.java deleted file mode 100755 index ec91dcb..0000000 --- a/geode-core/src/test/java/org/company/app/OrdersCacheListener.java +++ /dev/null @@ -1,51 +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 com.company.app; - -import org.apache.geode.cache.*; - -/** - * com.company.app.OrdersCacheListener. Cache listener impl for CacheXmlxxTest - * - * @since GemFire 5.0 - */ -public class OrdersCacheListener implements CacheListener, Declarable { - - public OrdersCacheListener() {} - - public void afterCreate(EntryEvent event) {} - - public void afterUpdate(EntryEvent event) {} - - public void afterInvalidate(EntryEvent event) {} - - public void afterDestroy(EntryEvent event) {} - - public void afterRegionInvalidate(RegionEvent event) {} - - public void afterRegionDestroy(RegionEvent event) {} - - public void afterRegionClear(RegionEvent event) {} - - public void afterRegionCreate(RegionEvent event) {} - - public void afterRegionLive(RegionEvent event) {} - - public void close() {} - - public void init(java.util.Properties props) {} -}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/company/data/DatabaseLoader.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/company/data/DatabaseLoader.java b/geode-core/src/test/java/org/company/data/DatabaseLoader.java deleted file mode 100644 index 84b1c70..0000000 --- a/geode-core/src/test/java/org/company/data/DatabaseLoader.java +++ /dev/null @@ -1,42 +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 com.company.data; - -import org.apache.geode.cache.*; - -/** - * A <code>CacheLoader</code> that is <code>Declarable</code> - * - * @since GemFire 3.2.1 - */ -public class DatabaseLoader implements CacheLoader, Declarable { - - public Object load(LoaderHelper helper) - throws CacheLoaderException { - - throw new UnsupportedOperationException("I do NOTHING"); - } - - public void init(java.util.Properties props) { - - } - - public void close() { - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/company/data/MyDeclarable.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/company/data/MyDeclarable.java b/geode-core/src/test/java/org/company/data/MyDeclarable.java deleted file mode 100644 index 0545c26..0000000 --- a/geode-core/src/test/java/org/company/data/MyDeclarable.java +++ /dev/null @@ -1,32 +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 com.company.data; - -import org.apache.geode.cache.*; - -/** - * A <code>Declarable</code> object - * - * @since GemFire 3.2.1 - */ -public class MyDeclarable implements Declarable { - - public void init(java.util.Properties props) { - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/company/data/MySizer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/company/data/MySizer.java b/geode-core/src/test/java/org/company/data/MySizer.java deleted file mode 100644 index 30e5e16..0000000 --- a/geode-core/src/test/java/org/company/data/MySizer.java +++ /dev/null @@ -1,39 +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 com.company.data; -/** - * A <code>Declarable</code> <code>ObjectSizer</code> for used for XML testing - * - * @since GemFire 5.0 - */ -import java.util.Properties; - -import org.apache.geode.cache.Declarable; -import org.apache.geode.cache.util.ObjectSizer; - -public class MySizer implements ObjectSizer, Declarable { - - String name; - - public int sizeof( Object o ) { - return ObjectSizer.DEFAULT.sizeof(o); - } - - public void init(Properties props) { - this.name = props.getProperty("name", "defaultName"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/company/data/MyTransactionListener.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/company/data/MyTransactionListener.java b/geode-core/src/test/java/org/company/data/MyTransactionListener.java deleted file mode 100644 index 074e12d..0000000 --- a/geode-core/src/test/java/org/company/data/MyTransactionListener.java +++ /dev/null @@ -1,38 +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 com.company.data; - -import org.apache.geode.cache.*; - -/** - * A <code>TransactionListener</code> that is <code>Declarable</code> - * - * @since GemFire 4.0 - */ -public class MyTransactionListener implements TransactionListener, Declarable { - - public void afterCommit(TransactionEvent event) {} - - public void afterFailedCommit(TransactionEvent event) {} - - public void afterRollback(TransactionEvent event) {} - - public void init(java.util.Properties props) {} - - public void close() {} - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/LinkNode.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/LinkNode.java b/geode-core/src/test/java/org/examples/LinkNode.java deleted file mode 100644 index 97a0438..0000000 --- a/geode-core/src/test/java/org/examples/LinkNode.java +++ /dev/null @@ -1,77 +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 com.examples; - -/** - * A node in a linked list that is used to test that serializing - * non-<code>Serializable</code> objects handle back references - * correctly. - * - * - * @since GemFire 3.5 - */ -public class LinkNode { - - /** The value of this LinkNode */ - private int value; - - /** An object value in this LinkNode */ - public Object object; - - /** The next node in the chain */ - public LinkNode next; - - /** - * Creates a new <code>LinkNode</code> with the given value - */ - public LinkNode(int value) { - this.value = value; - } - - /** - * Two <code>LinkNode</code>s are equal if they have the same - * <code>value</code> and their <code>next</code> node have the same - * value. - */ - public boolean equals(Object o) { - if (!(o instanceof LinkNode)) { - return false; - } - - LinkNode other = (LinkNode) o; - if (this.value != other.value) { - return false; - - } else if (this.next == null) { - return other.next == null; - - } else if (other.next == null) { - return this.next == null; - - } else if (other.next.value != this.next.value) { - return false; - - } else if (this.object != null) { - return this.object.equals(other.object); - - } else { - return other.object == null; - } - - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/SuperClass.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/SuperClass.java b/geode-core/src/test/java/org/examples/SuperClass.java deleted file mode 100644 index 6c6076f..0000000 --- a/geode-core/src/test/java/org/examples/SuperClass.java +++ /dev/null @@ -1,92 +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 com.examples; - -import java.util.*; - -/** - * The super class of another class. Neither is - * <code>Serializable</code>. - * - * - * @since GemFire 3.5 - */ -public class SuperClass { - - protected int intValue; - protected HashMap map; - - /** - * Creates a new <code>SuperClass</code> - */ - protected SuperClass() { - this.intValue = 42; - this.map = new HashMap(); - map.put("one", new Integer(1)); - map.put("two", new Integer(2)); - map.put("three", new Integer(3)); - map.put("four", new Integer(4)); - } - - - public static class SubClass extends SuperClass { - - protected Map anotherMap; - protected long longValue; - - /** - * Creates a new <code>SubClass</code> - */ - public SubClass() { - super(); - - this.longValue = 28L; - this.anotherMap = new HashMap(); - this.anotherMap.put("five", new Integer(5)); - this.anotherMap.put("six", new Integer(6)); - this.anotherMap.put("seven", new Integer(7)); - this.anotherMap.put("eight", new Integer(8)); - } - - public boolean equals(Object o) { - if (!(o instanceof SubClass)) { - return false; - } - - SubClass other = (SubClass) o; - if (this.intValue != other.intValue) { - return false; - - } else if (!this.map.equals(other.map)) { - return false; - - } else if (this.longValue != other.longValue) { - return false; - - } else if (!this.anotherMap.equals(other.anotherMap)) { - return false; - - } else { - return true; - } - } - - } - - - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/TestObject.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/TestObject.java b/geode-core/src/test/java/org/examples/TestObject.java deleted file mode 100644 index 9b871a7..0000000 --- a/geode-core/src/test/java/org/examples/TestObject.java +++ /dev/null @@ -1,54 +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 com.examples; - -/** - * A simple test object used by the - * org.apache.geode.internal.enhancer.serializer.SerializingStreamPerfTest - * (this test no longer exists?) - * that must be in a non-<code>org.apache</code> package. - * - * - * @since GemFire 3.5 - */ -public class TestObject { - - private int intField; - private String stringField; - private Object objectField; - - /** - * Creates a new <code>TestObject</code> - */ - public TestObject() { - this.intField = 42; - this.stringField = "123456789012345678901234567890"; - this.objectField = new Integer(67); - } - - ////////////////////// Inner Classes ////////////////////// - - /** - * A <code>Serializable</code> object that is serialized - */ - public static class SerializableTestObject extends TestObject - implements java.io.Serializable { - - } - -} - http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/ds/Address.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/ds/Address.java b/geode-core/src/test/java/org/examples/ds/Address.java deleted file mode 100644 index 5a82531..0000000 --- a/geode-core/src/test/java/org/examples/ds/Address.java +++ /dev/null @@ -1,23 +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 com.examples.ds; - -import java.io.Serializable; - -public class Address implements Serializable { - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/ds/Company.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/ds/Company.java b/geode-core/src/test/java/org/examples/ds/Company.java deleted file mode 100644 index 6fc93ee..0000000 --- a/geode-core/src/test/java/org/examples/ds/Company.java +++ /dev/null @@ -1,43 +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 com.examples.ds; - -public class Company { - - /** The name of this company */ - private String name; - - /** The address of this company */ - private Address address; - - /** - * Creates a new company - */ - public Company(String name, Address address) { - this.name = name; - this.address = address; - } - - public String getName() { - return this.name; - } - - public Address getAddress() { - return this.address; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/ds/CompanySerializer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/ds/CompanySerializer.java b/geode-core/src/test/java/org/examples/ds/CompanySerializer.java deleted file mode 100644 index 9d69083..0000000 --- a/geode-core/src/test/java/org/examples/ds/CompanySerializer.java +++ /dev/null @@ -1,67 +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 com.examples.ds; - -import org.apache.geode.DataSerializer; -import java.io.*; - -public class CompanySerializer extends DataSerializer { - - static { - DataSerializer.register(CompanySerializer.class); - } - - /** - * May be invoked reflectively if instances of Company are - * distributed to other VMs. - */ - public CompanySerializer() { - - } - - public int getId() { - return 42; - } - - public Class[] getSupportedClasses() { - return new Class[] { Company.class }; - } - - public boolean toData(Object o, DataOutput out) - throws IOException { - if (o instanceof Company) { - Company company = (Company) o; - out.writeUTF(company.getName()); - - // Let's assume that Address is java.io.Serializable - Address address = company.getAddress(); - writeObject(address, out); - return true; - - } else { - return false; - } - } - - public Object fromData(DataInput in) - throws IOException, ClassNotFoundException { - - String name = in.readUTF(); - Address address = (Address) readObject(in); - return new Company(name, address); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/ds/Employee.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/ds/Employee.java b/geode-core/src/test/java/org/examples/ds/Employee.java deleted file mode 100644 index 9165e34..0000000 --- a/geode-core/src/test/java/org/examples/ds/Employee.java +++ /dev/null @@ -1,53 +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 com.examples.ds; - -import org.apache.geode.DataSerializable; -import org.apache.geode.DataSerializer; -import java.io.*; -import java.util.Date; - -public class Employee implements DataSerializable { - private int id; - private String name; - private Date birthday; - private Company employer; - - public Employee(int id, String name, Date birthday, - Company employer){ - this.id = id; - this.name = name; - this.birthday = birthday; - this.employer = employer; - } - - public void toData(DataOutput out) throws IOException { - out.writeInt(this.id); - out.writeUTF(this.name); - DataSerializer.writeDate(this.birthday, out); - DataSerializer.writeObject(this.employer, out); - } - - public void fromData(DataInput in) - throws IOException, ClassNotFoundException { - - this.id = in.readInt(); - this.name = in.readUTF(); - this.birthday = DataSerializer.readDate(in); - this.employer = (Company) DataSerializer.readObject(in); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/ds/PutDataSerializables.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/ds/PutDataSerializables.java b/geode-core/src/test/java/org/examples/ds/PutDataSerializables.java deleted file mode 100644 index 162ce5a..0000000 --- a/geode-core/src/test/java/org/examples/ds/PutDataSerializables.java +++ /dev/null @@ -1,54 +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 com.examples.ds; - -import org.apache.geode.cache.*; -import org.apache.geode.distributed.DistributedSystem; -import java.util.Date; -import java.util.Properties; - -/** - * Places various objects that use {@link org.apache.geode.DataSerializer}s - * and {@link org.apache.geode.Instantiator}s into a cache {@link Region}. - * Among other things, this is used to test bug 31573. - * - * @since GemFire 3.5 - */ -public class PutDataSerializables { - - public static void main(String[] args) throws Throwable { - Properties props = new Properties(); - DistributedSystem system = DistributedSystem.connect(props); - Cache cache = CacheFactory.create(system); - AttributesFactory factory = new AttributesFactory(); - Region region = - cache.createRegion("DataSerializable", - factory.create()); - region.put("User", new User("Fred", 42)); - - new CompanySerializer(); - Address address = new Address(); - Company company = new Company("My Company", address); - - region.put("Company", company); - region.put("Employee", - new Employee(43, "Bob", new Date(), company)); - - Thread.sleep(60 * 1000); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/ds/User.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/ds/User.java b/geode-core/src/test/java/org/examples/ds/User.java deleted file mode 100644 index 4bf4531..0000000 --- a/geode-core/src/test/java/org/examples/ds/User.java +++ /dev/null @@ -1,58 +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 com.examples.ds; - -import org.apache.geode.DataSerializable; -import org.apache.geode.Instantiator; -import java.io.*; - -public class User implements DataSerializable { - private String name; - private int userId; - - static { - Instantiator.register(new Instantiator(User.class, (byte) 45) { - public DataSerializable newInstance() { - return new User(); - } - }); - } - - public User(String name, int userId) { - this.name = name; - this.userId = userId; - } - - /** - * Creates an "empty" User whose contents are filled in by - * invoking its toData() method - */ - protected User() { - - } - - public void toData(DataOutput out) throws IOException { - out.writeUTF(this.name); - out.writeInt(this.userId); - } - - public void fromData(DataInput in) - throws IOException, ClassNotFoundException { - this.name = in.readUTF(); - this.userId = in.readInt(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/snapshot/MyDataSerializer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/snapshot/MyDataSerializer.java b/geode-core/src/test/java/org/examples/snapshot/MyDataSerializer.java deleted file mode 100644 index 0b8d9e6..0000000 --- a/geode-core/src/test/java/org/examples/snapshot/MyDataSerializer.java +++ /dev/null @@ -1,63 +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 com.examples.snapshot; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.geode.DataSerializer; - -public class MyDataSerializer extends DataSerializer { - @Override - public Class<?>[] getSupportedClasses() { - return new Class[] { MyObjectDataSerializable2.class}; - } - - @Override - public boolean toData(Object o, DataOutput out) throws IOException { - MyObject obj = (MyObject) o; - out.writeLong(obj.f1); - out.writeUTF(obj.f2); - - return true; - } - - @Override - public Object fromData(DataInput in) throws IOException, - ClassNotFoundException { - MyObjectDataSerializable2 obj = new MyObjectDataSerializable2(); - obj.f1 = in.readLong(); - obj.f2 = in.readUTF(); - - return obj; - } - - @Override - public int getId() { - return 8892; - } - - public static class MyObjectDataSerializable2 extends MyObject { - public MyObjectDataSerializable2() { - } - - public MyObjectDataSerializable2(long number, String s) { - super(number, s); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/snapshot/MyObject.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/snapshot/MyObject.java b/geode-core/src/test/java/org/examples/snapshot/MyObject.java deleted file mode 100644 index aaada9d..0000000 --- a/geode-core/src/test/java/org/examples/snapshot/MyObject.java +++ /dev/null @@ -1,68 +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 com.examples.snapshot; - -import java.io.Serializable; - -import org.apache.geode.pdx.PdxInstance; - -/** - * Data class for testing snapshots, cannot be located in org.apache.*. - * - */ -public class MyObject implements Serializable { - protected long f1; - protected String f2; - - public MyObject() { - } - - public MyObject(long number, String s) { - f1 = number; - f2 = s; - } - - public long getF1() { - return f1; - } - - public String getF2() { - return f2; - } - - @Override - public boolean equals(Object o) { - if (o instanceof MyObject) { - MyObject obj = (MyObject) o; - return f1 == obj.f1 && f2.equals(obj.f2); - - } else if (o instanceof PdxInstance) { - PdxInstance pdx = (PdxInstance) o; - return pdx.getField("f1").equals(f1) && pdx.getField("f2").equals(f2); - } - return false; - } - - @Override - public int hashCode() { - return (int) (17 * f1 ^ f2.hashCode()); - } - - public String toString() { - return f1 + "-" + f2; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/snapshot/MyObjectDataSerializable.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/snapshot/MyObjectDataSerializable.java b/geode-core/src/test/java/org/examples/snapshot/MyObjectDataSerializable.java deleted file mode 100644 index 1582744..0000000 --- a/geode-core/src/test/java/org/examples/snapshot/MyObjectDataSerializable.java +++ /dev/null @@ -1,45 +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 com.examples.snapshot; - -import java.io.DataInput; -import java.io.DataOutput; -import java.io.IOException; - -import org.apache.geode.DataSerializable; - -public class MyObjectDataSerializable extends MyObject implements DataSerializable { - public MyObjectDataSerializable() { - } - - public MyObjectDataSerializable(long number, String s) { - super(number, s); - } - - @Override - public void toData(DataOutput out) throws IOException { - out.writeLong(f1); - out.writeUTF(f2); - } - - @Override - public void fromData(DataInput in) throws IOException, - ClassNotFoundException { - f1 = in.readLong(); - f2 = in.readUTF(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/snapshot/MyObjectPdx.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/snapshot/MyObjectPdx.java b/geode-core/src/test/java/org/examples/snapshot/MyObjectPdx.java deleted file mode 100644 index 396049d..0000000 --- a/geode-core/src/test/java/org/examples/snapshot/MyObjectPdx.java +++ /dev/null @@ -1,33 +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 com.examples.snapshot; - -public class MyObjectPdx extends MyObject { - public enum MyEnumPdx { - const1, const2, const3, const4, const5; - } - - private MyEnumPdx enumVal; - - public MyObjectPdx() { - } - - public MyObjectPdx(long number, String s, MyEnumPdx enumVal) { - super(number, s); - this.enumVal = enumVal; - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/snapshot/MyObjectPdxSerializable.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/snapshot/MyObjectPdxSerializable.java b/geode-core/src/test/java/org/examples/snapshot/MyObjectPdxSerializable.java deleted file mode 100644 index 3929db4..0000000 --- a/geode-core/src/test/java/org/examples/snapshot/MyObjectPdxSerializable.java +++ /dev/null @@ -1,42 +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 com.examples.snapshot; - -import org.apache.geode.pdx.PdxReader; -import org.apache.geode.pdx.PdxSerializable; -import org.apache.geode.pdx.PdxWriter; - -public class MyObjectPdxSerializable extends MyObject implements PdxSerializable { - public MyObjectPdxSerializable() { - } - - public MyObjectPdxSerializable(long number, String s) { - super(number, s); - } - - @Override - public void toData(PdxWriter writer) { - writer.writeLong("f1", f1); - writer.writeString("f2", f2); - } - - @Override - public void fromData(PdxReader reader) { - f1 = reader.readLong("f1"); - f2 = reader.readString("f2"); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/examples/snapshot/MyPdxSerializer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/examples/snapshot/MyPdxSerializer.java b/geode-core/src/test/java/org/examples/snapshot/MyPdxSerializer.java deleted file mode 100644 index 710e445..0000000 --- a/geode-core/src/test/java/org/examples/snapshot/MyPdxSerializer.java +++ /dev/null @@ -1,64 +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 com.examples.snapshot; - -import java.util.Properties; - -import org.apache.geode.cache.Declarable; -import org.apache.geode.pdx.PdxReader; -import org.apache.geode.pdx.PdxSerializer; -import org.apache.geode.pdx.PdxWriter; -import org.apache.geode.pdx.ReflectionBasedAutoSerializer; - -public class MyPdxSerializer implements PdxSerializer, Declarable { - private final PdxSerializer auto = new ReflectionBasedAutoSerializer("com.examples.snapshot.My.*Pdx"); - - @Override - public void init(Properties props) { - } - @Override - public boolean toData(Object o, PdxWriter out) { - if (o instanceof MyObjectPdx2) { - MyObjectPdx2 obj = (MyObjectPdx2) o; - out.writeLong("f1", obj.f1); - out.writeString("f2", obj.f2); - return true; - } - return auto.toData(o, out); - } - - @Override - public Object fromData(Class<?> clazz, PdxReader in) { - if (clazz == MyObjectPdx2.class) { - MyObjectPdx2 obj = new MyObjectPdx2(); - obj.f1 = in.readLong("f1"); - obj.f2 = in.readString("f2"); - - return obj; - } - return auto.fromData(clazz, in); - } - - public static class MyObjectPdx2 extends MyObject { - public MyObjectPdx2() { - } - - public MyObjectPdx2(long number, String s) { - super(number, s); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/main/MyDistributedSystemListener.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/main/MyDistributedSystemListener.java b/geode-core/src/test/java/org/main/MyDistributedSystemListener.java deleted file mode 100644 index 6206441..0000000 --- a/geode-core/src/test/java/org/main/MyDistributedSystemListener.java +++ /dev/null @@ -1,114 +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 com.main; - -import java.io.IOException; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheClosedException; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.wan.GatewayReceiver; -import org.apache.geode.cache.wan.GatewaySender; -import org.apache.geode.internal.cache.wan.DistributedSystemListener; - -/** - * This is an implementation of DistributedSystemListener. When a - * addedDistributedSystem is called a Region is created on both sites and - * GatewaySender and GatewayReciever is started on site 1 and site 2 - * respectively. - * - * When a removedDistributedSystem is called, GatewaySender and GatewayReceiver - * is stopped on site1 and site2 respectively. - * - * - */ -public class MyDistributedSystemListener implements DistributedSystemListener { - - Cache cache; - - public MyDistributedSystemListener() { - } - - /** - * Please note that dynamic addition of the sender id to region is not yet available. - */ - public void addedDistributedSystem(int remoteDsId) { - cache = CacheFactory.getAnyInstance(); - - //When a site with distributed-system-id = 2 joins, create a region and a gatewaysender with remoteDsId = 2 - if (remoteDsId == 2) { - if (cache != null) { - GatewaySender serialSender= cache - .createGatewaySenderFactory() - .setManualStart(true) - .setPersistenceEnabled(false) - .setDiskStoreName("LN_" + remoteDsId) - .create("LN_"+ remoteDsId, remoteDsId); - System.out.println("Sender Created : " + serialSender.getId()); - - Region region= cache.createRegionFactory() - //.addSerialGatewaySenderId("LN_" + remoteDsId) - .create("MyRegion"); - System.out.println("Created Region : " + region.getName()); - - try { - serialSender.start(); - System.out.println("Sender Started: " + serialSender.getId()); - } - catch (Exception e) { - e.printStackTrace(); - } - } - else { - throw new CacheClosedException("Cache is not initialized here"); - } - }else{ //When a site with distributed-system-id = 1 joins, create a region and a gatewayReceiver with - if (cache != null) { - Region region = cache.createRegionFactory().create("MyRegion"); - System.out.println("Created Region :" + region.getName()); - - GatewayReceiver receiver= cache.createGatewayReceiverFactory() - .setStartPort(12345) - .setManualStart(true) - .create(); - System.out.println("Created GatewayReceiver : " + receiver); - try { - receiver.start(); - System.out.println("GatewayReceiver Started."); - } - catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public void removedDistributedSystem(int remoteDsId) { - cache = CacheFactory.getAnyInstance(); - if (remoteDsId == 2) { //When a site with distributed-system-id = -2 joins, stop gatewaysender with remoteDsId = 2 - if (cache != null) { - GatewaySender sender = cache.getGatewaySender("LN_"+2); - sender.stop(); - } - } - else{ // When a site with distributed-system-id = -1 joins, stop gatewayReceiver - GatewayReceiver receiver = cache.getGatewayReceivers().iterator().next(); - receiver.stop(); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/main/WANBootStrapping_Site1_Add.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/main/WANBootStrapping_Site1_Add.java b/geode-core/src/test/java/org/main/WANBootStrapping_Site1_Add.java deleted file mode 100644 index 9d4bbfc..0000000 --- a/geode-core/src/test/java/org/main/WANBootStrapping_Site1_Add.java +++ /dev/null @@ -1,122 +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 com.main; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.wan.GatewaySender; -import org.apache.geode.distributed.internal.DistributionConfig; - -import java.util.Set; - -import static org.apache.geode.distributed.ConfigurationProperties.*; - -/** - * This is a member representing site 1 who wants to send data to site 2 - * - * On this member a locator with distributed-system-id = 1 is created. On this - * member a cache is created. - * - * A Region and a GatewaySender is created on this member through - * MyDistributedSustemListener#addedDistributedSystemConnection - * (When a remote locator with distributed-system-id = 2 connects to this site, - * MyDistributedSustemListener's addedDistributedSystemConnection will be - * invoked who will create a region and a GatewaySender.) - * - * This member does put for 100 keys on the region. (We have to check that this - * data for 100 entries are sent to remote site) - * - * This member also check for the sender's running status. - * - * A GatewaySender will be stopped through - * MyDistributedSustemListener#removedDistributedSystem - * (When a remote locator with distributed-system-id = -2 connects to this site, - * MyDistributedSustemListener's removedDistributedSystem will be invoked who - * will stop a GatewaySender.) - * - * - */ - -public class WANBootStrapping_Site1_Add { - - public static void main(String[] args) { - - System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DistributedSystemListener", - "com.main.MyDistributedSystemListener"); - - // Create a locator and a cache - System.out.println("Creating cache ...It will take some time.."); - Cache cache = new CacheFactory().set(MCAST_PORT, - "0").set(DISTRIBUTED_SYSTEM_ID, "" + 1).set( - LOCATORS, "localhost[" + 10101 + "]").set( - START_LOCATOR, - "localhost[" + 10101 - + "],server=true,peer=true,hostname-for-clients=localhost").set( - LOG_LEVEL, "warning").create(); - System.out.println("Cache Created"); - - // to create region and a gateway sender ask to run - // WANBootStrapping_Site2_Add program - System.out.println("Run WANBootStrapping_Site2_Add"); - - // get the region - Region region = cache.getRegion("MyRegion"); - while (region == null) { - region = cache.getRegion("MyRegion"); - try { - Thread.sleep(5000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - - // put data in region - for (int i = 0; i < 100; i++) { - System.out.println("Create Entry : key_" + i + ", value_" + i); - region.put("key_" + i, "value_" + i); - } - - System.out.println("Entry Create Operation completed"); - - Set<GatewaySender> gatewaySenders = cache.getGatewaySenders(); - GatewaySender sender = gatewaySenders.iterator().next(); - - // make sure that gateway sender is running - if (sender.isRunning()) { - System.out.println("Sender " + sender.getId() + " is running"); - } - - // to stop gateway sender ask to run WANBootStrapping_Site2_Remove program - while (sender.isRunning()) { - System.out - .println("Waitng for sender to stop through DistributedSystemListener"); - System.out.println("Start WANBootStrapping_Site2_Remove"); - try { - Thread.sleep(5000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - - System.out.println("Sender " + sender.getId() + " is stopped"); - - System.exit(0); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/main/WANBootStrapping_Site1_Remove.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/main/WANBootStrapping_Site1_Remove.java b/geode-core/src/test/java/org/main/WANBootStrapping_Site1_Remove.java deleted file mode 100644 index 6920d7e..0000000 --- a/geode-core/src/test/java/org/main/WANBootStrapping_Site1_Remove.java +++ /dev/null @@ -1,78 +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 com.main; - -import static org.apache.geode.distributed.ConfigurationProperties.*; - -import org.apache.geode.distributed.Locator; -import org.apache.geode.distributed.internal.DistributionConfig; - -import java.io.IOException; -import java.util.Properties; - -import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT; - -/** - * This is a stand alone locator with a distributed-system-id = -1 - * - * This locator is started so that the locator information regarding the site 1 - * is removed from site 2's locator and at the same time - * MyDistributedSystemListener's removeDistributedSystem is invoked on site 2's locator which will stop the GatewayReceiver - * - * - */ -public class WANBootStrapping_Site1_Remove { - - - public static void main(String[] args) { - - //On this locator, I am not expecting a listener to take any action, so a empty listener is a passed - System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DistributedSystemListener", - ""); - - System.out.println("Starting a locator with negative ds id -1"); - - //start a stand alone locator with distributed-system-is = -1 - Properties properties = new Properties(); - properties.setProperty(MCAST_PORT, "0"); - properties.setProperty(DISTRIBUTED_SYSTEM_ID, ""+ (-1)); - properties.setProperty(REMOTE_LOCATORS, "localhost[" + 20202 + "]"); - properties.setProperty(LOG_LEVEL, "warning"); - Locator locator = null; - try { - locator = Locator.startLocatorAndDS(40445, null, properties); - } - catch (IOException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(1000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - - //stop locator - System.out.println("Stoping locator"); - locator.stop(); - System.out.println("Locator stopped "); - - System.exit(0); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/main/WANBootStrapping_Site2_Add.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/main/WANBootStrapping_Site2_Add.java b/geode-core/src/test/java/org/main/WANBootStrapping_Site2_Add.java deleted file mode 100644 index f5abf5d..0000000 --- a/geode-core/src/test/java/org/main/WANBootStrapping_Site2_Add.java +++ /dev/null @@ -1,108 +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 com.main; - -import org.apache.geode.cache.Cache; -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.cache.Region; -import org.apache.geode.cache.wan.GatewayReceiver; -import org.apache.geode.distributed.internal.DistributionConfig; - -import static org.apache.geode.distributed.ConfigurationProperties.*; - -/** - * This is a member representing site 2 who wants to receive data from site 1 - * - * On this member a locator with distributed-system-id = 2 is created. - * On this member a cache is created. - * - * A Region and a GatewayReceiver is created on this member through - * MyDistributedSustemListener#addedDistributedSystemConnection - * - * (When this locator gets the locator information from the site 1, - * MyDistributedSustemListener's addedDistributedSystemConnection will be - * invoked who will create a region and a GatewayReceiver.) - * - * This member expects region size to be 100. (this site received this data from site1) - * - * This member also check for the receiver's running status. - * - * A GatewayReceiver will be stopped through - * MyDistributedSustemListener#removedDistributedSystem - * (When a remote locator with distributed-system-id = -1 connects to this site, - * MyDistributedSustemListener's removedDistributedSystem will be invoked who - * will stop a GatewayReceiver.) - * - * - */ - -public class WANBootStrapping_Site2_Add { - - public static void main(String[] args) { - - System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DistributedSystemListener", - "com.main.MyDistributedSystemListener"); - - //create a locator and a cache - System.out.println("Creating cache ...It will take some time.."); - Cache cache = new CacheFactory() - .set(MCAST_PORT, "0") - .set(DISTRIBUTED_SYSTEM_ID, ""+2) - .set(LOCATORS, "localhost[" + 20202 + "]") - .set(START_LOCATOR, "localhost[" + 20202 + "],server=true,peer=true,hostname-for-clients=localhost") - .set(REMOTE_LOCATORS, "localhost[" + 10101 + "]") - .set(LOG_LEVEL, "warning") - .create(); - System.out.println("Cache Created"); - - //get the region whose size should be 100 - Region region = cache.getRegion("MyRegion"); - while(region == null){ - region = cache.getRegion("MyRegion"); - try { - Thread.sleep(5000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - - //region size should be 100. This is the data which will recieve from remote site - while(region.size()!= 100){ - continue; - } - System.out.println("Checked region size : " + region.size()); - - GatewayReceiver receiver = cache.getGatewayReceivers().iterator().next(); - - // to stop gateway receiver ask to run WANBootStrapping_Site1_Remove program - while (receiver.isRunning()) { - System.out - .println("Waitng for receiver to stop through DistributedSystemListener"); - System.out.println("Start WANBootStrapping_Site1_Remove "); - try { - Thread.sleep(2000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - } - - System.out.println("GatewayReciver " + receiver + " is stopped") ; - System.exit(0); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/main/WANBootStrapping_Site2_Remove.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/main/WANBootStrapping_Site2_Remove.java b/geode-core/src/test/java/org/main/WANBootStrapping_Site2_Remove.java deleted file mode 100644 index 30e0a22..0000000 --- a/geode-core/src/test/java/org/main/WANBootStrapping_Site2_Remove.java +++ /dev/null @@ -1,74 +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 com.main; - -import org.apache.geode.distributed.Locator; -import org.apache.geode.distributed.internal.DistributionConfig; - -import java.io.IOException; -import java.util.Properties; - -import static org.apache.geode.distributed.ConfigurationProperties.*; - -/** - * This is a stand alone locator with a distributed-system-id = -2 - * - * This locator is started so that the locator information regarding the site 2 - * is removed from site 1's locator and at the same time - * MyDistributedSystemListener's removeDistributedSystem is invoked on site 1's locator which will stop the GatewaySender - * - * - */ - -public class WANBootStrapping_Site2_Remove { - - public static void main(String[] args) { - - // On this locator, I am not expecting a listener to take any action, so a - // empty listener is a passed - System.setProperty(DistributionConfig.GEMFIRE_PREFIX + "DistributedSystemListener", - ""); - - System.out.println("Starting a locator with negative ds id -2"); - Properties properties = new Properties(); - properties.setProperty(MCAST_PORT, "0"); - properties.setProperty(DISTRIBUTED_SYSTEM_ID, ""+ (-2)); - properties.setProperty(REMOTE_LOCATORS, "localhost[" + 10101 + "]"); - properties.setProperty(LOG_LEVEL, "warning"); - Locator locator = null; - try { - locator = Locator.startLocatorAndDS(30445, null, properties); - } - catch (IOException e) { - e.printStackTrace(); - } - - try { - Thread.sleep(1000); - } - catch (InterruptedException e) { - e.printStackTrace(); - } - System.out.println("Stoping locator"); - locator.stop(); - System.out.println("Locator stopped "); - - System.exit(0); - } - - -}
