GEODE-37 renamed pulse package
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/eff7f216 Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/eff7f216 Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/eff7f216 Branch: refs/heads/feature/GEODE-37_1 Commit: eff7f21631a34484fd0e3ffcf3de69020f5d9d3f Parents: 939fcf2 Author: Hitesh Khamesra <[email protected]> Authored: Fri Sep 9 14:33:43 2016 -0700 Committer: Hitesh Khamesra <[email protected]> Committed: Fri Sep 9 14:33:43 2016 -0700 ---------------------------------------------------------------------- .../src/test/java/com/company/app/Customer.java | 36 + .../src/test/java/com/company/app/DBLoader.java | 63 + .../com/company/app/OrdersCacheListener.java | 51 + .../java/com/company/data/DatabaseLoader.java | 42 + .../java/com/company/data/MyDeclarable.java | 32 + .../src/test/java/com/company/data/MySizer.java | 39 + .../com/company/data/MyTransactionListener.java | 38 + .../src/test/java/com/examples/LinkNode.java | 77 + .../src/test/java/com/examples/SuperClass.java | 92 + .../src/test/java/com/examples/TestObject.java | 54 + .../src/test/java/com/examples/ds/Address.java | 23 + .../src/test/java/com/examples/ds/Company.java | 43 + .../java/com/examples/ds/CompanySerializer.java | 67 + .../src/test/java/com/examples/ds/Employee.java | 53 + .../com/examples/ds/PutDataSerializables.java | 54 + .../src/test/java/com/examples/ds/User.java | 58 + .../com/examples/snapshot/MyDataSerializer.java | 63 + .../java/com/examples/snapshot/MyObject.java | 68 + .../snapshot/MyObjectDataSerializable.java | 45 + .../java/com/examples/snapshot/MyObjectPdx.java | 33 + .../snapshot/MyObjectPdxSerializable.java | 42 + .../com/examples/snapshot/MyPdxSerializer.java | 64 + .../com/main/MyDistributedSystemListener.java | 114 + .../com/main/WANBootStrapping_Site1_Add.java | 122 + .../com/main/WANBootStrapping_Site1_Remove.java | 78 + .../com/main/WANBootStrapping_Site2_Add.java | 108 + .../com/main/WANBootStrapping_Site2_Remove.java | 74 + .../geode/internal/ClassPathLoaderTest.java | 2 +- .../src/test/java/org/company/app/Customer.java | 36 - .../src/test/java/org/company/app/DBLoader.java | 63 - .../org/company/app/OrdersCacheListener.java | 51 - .../java/org/company/data/DatabaseLoader.java | 42 - .../java/org/company/data/MyDeclarable.java | 32 - .../src/test/java/org/company/data/MySizer.java | 39 - .../org/company/data/MyTransactionListener.java | 38 - .../src/test/java/org/examples/LinkNode.java | 77 - .../src/test/java/org/examples/SuperClass.java | 92 - .../src/test/java/org/examples/TestObject.java | 54 - .../src/test/java/org/examples/ds/Address.java | 23 - .../src/test/java/org/examples/ds/Company.java | 43 - .../java/org/examples/ds/CompanySerializer.java | 67 - .../src/test/java/org/examples/ds/Employee.java | 53 - .../org/examples/ds/PutDataSerializables.java | 54 - .../src/test/java/org/examples/ds/User.java | 58 - .../org/examples/snapshot/MyDataSerializer.java | 63 - .../java/org/examples/snapshot/MyObject.java | 68 - .../snapshot/MyObjectDataSerializable.java | 45 - .../java/org/examples/snapshot/MyObjectPdx.java | 33 - .../snapshot/MyObjectPdxSerializable.java | 42 - .../org/examples/snapshot/MyPdxSerializer.java | 64 - .../org/main/MyDistributedSystemListener.java | 114 - .../org/main/WANBootStrapping_Site1_Add.java | 122 - .../org/main/WANBootStrapping_Site1_Remove.java | 78 - .../org/main/WANBootStrapping_Site2_Add.java | 108 - .../org/main/WANBootStrapping_Site2_Remove.java | 74 - .../tools/pulse/internal/PulseAppListener.java | 742 ---- .../controllers/ExceptionHandlingAdvice.java | 51 - .../internal/controllers/PulseController.java | 524 --- .../tools/pulse/internal/data/Cluster.java | 3815 ------------------ .../tools/pulse/internal/data/DataBrowser.java | 248 -- .../pulse/internal/data/IClusterUpdater.java | 35 - .../pulse/internal/data/JMXDataUpdater.java | 2392 ----------- .../pulse/internal/data/JmxManagerFinder.java | 169 - .../tools/pulse/internal/data/PulseConfig.java | 139 - .../pulse/internal/data/PulseConstants.java | 434 -- .../tools/pulse/internal/data/PulseVersion.java | 103 - .../tools/pulse/internal/data/Repository.java | 246 -- .../gemfire/tools/pulse/internal/json/CDL.java | 274 -- .../tools/pulse/internal/json/Cookie.java | 164 - .../tools/pulse/internal/json/CookieList.java | 85 - .../gemfire/tools/pulse/internal/json/HTTP.java | 158 - .../tools/pulse/internal/json/HTTPTokener.java | 72 - .../tools/pulse/internal/json/JSONArray.java | 901 ----- .../pulse/internal/json/JSONException.java | 47 - .../tools/pulse/internal/json/JSONML.java | 462 --- .../tools/pulse/internal/json/JSONObject.java | 1585 -------- .../tools/pulse/internal/json/JSONString.java | 37 - .../tools/pulse/internal/json/JSONStringer.java | 73 - .../tools/pulse/internal/json/JSONTokener.java | 441 -- .../tools/pulse/internal/json/JSONWriter.java | 322 -- .../gemfire/tools/pulse/internal/json/README | 68 - .../gemfire/tools/pulse/internal/json/XML.java | 503 --- .../tools/pulse/internal/json/XMLTokener.java | 360 -- .../tools/pulse/internal/log/LogWriter.java | 265 -- .../pulse/internal/log/MessageFormatter.java | 102 - .../pulse/internal/log/PulseLogWriter.java | 299 -- .../tools/pulse/internal/log/PulseLogger.java | 142 - .../security/GemFireAuthentication.java | 91 - .../security/GemFireAuthenticationProvider.java | 80 - .../pulse/internal/security/LogoutHandler.java | 55 - .../internal/service/ClusterDetailsService.java | 104 - .../service/ClusterDiskThroughputService.java | 71 - .../service/ClusterGCPausesService.java | 69 - .../service/ClusterKeyStatisticsService.java | 69 - .../internal/service/ClusterMemberService.java | 132 - .../service/ClusterMembersRGraphService.java | 359 -- .../service/ClusterMemoryUsageService.java | 65 - .../internal/service/ClusterRegionService.java | 211 - .../internal/service/ClusterRegionsService.java | 206 - .../service/ClusterSelectedRegionService.java | 237 -- .../ClusterSelectedRegionsMemberService.java | 143 - .../internal/service/ClusterWANInfoService.java | 75 - .../service/MemberAsynchEventQueuesService.java | 99 - .../internal/service/MemberClientsService.java | 101 - .../internal/service/MemberDetailsService.java | 122 - .../service/MemberDiskThroughputService.java | 76 - .../internal/service/MemberGCPausesService.java | 73 - .../service/MemberGatewayHubService.java | 149 - .../service/MemberHeapUsageService.java | 73 - .../service/MemberKeyStatisticsService.java | 76 - .../internal/service/MemberRegionsService.java | 127 - .../internal/service/MembersListService.java | 75 - .../pulse/internal/service/PulseService.java | 40 - .../internal/service/PulseServiceFactory.java | 55 - .../internal/service/PulseVersionService.java | 65 - .../service/QueryStatisticsService.java | 115 - .../internal/service/SystemAlertsService.java | 127 - .../pulse/internal/util/ConnectionUtil.java | 46 - .../pulse/internal/util/IPAddressUtil.java | 65 - .../tools/pulse/internal/util/StringUtils.java | 85 - .../tools/pulse/internal/util/TimeUtils.java | 120 - .../tools/pulse/internal/PulseAppListener.java | 742 ++++ .../controllers/ExceptionHandlingAdvice.java | 51 + .../internal/controllers/PulseController.java | 524 +++ .../tools/pulse/internal/data/Cluster.java | 3815 ++++++++++++++++++ .../tools/pulse/internal/data/DataBrowser.java | 248 ++ .../pulse/internal/data/IClusterUpdater.java | 35 + .../pulse/internal/data/JMXDataUpdater.java | 2392 +++++++++++ .../pulse/internal/data/JmxManagerFinder.java | 169 + .../tools/pulse/internal/data/PulseConfig.java | 139 + .../pulse/internal/data/PulseConstants.java | 434 ++ .../tools/pulse/internal/data/PulseVersion.java | 103 + .../tools/pulse/internal/data/Repository.java | 246 ++ .../geode/tools/pulse/internal/json/CDL.java | 274 ++ .../geode/tools/pulse/internal/json/Cookie.java | 164 + .../tools/pulse/internal/json/CookieList.java | 85 + .../geode/tools/pulse/internal/json/HTTP.java | 158 + .../tools/pulse/internal/json/HTTPTokener.java | 72 + .../tools/pulse/internal/json/JSONArray.java | 901 +++++ .../pulse/internal/json/JSONException.java | 47 + .../geode/tools/pulse/internal/json/JSONML.java | 462 +++ .../tools/pulse/internal/json/JSONObject.java | 1585 ++++++++ .../tools/pulse/internal/json/JSONString.java | 37 + .../tools/pulse/internal/json/JSONStringer.java | 73 + .../tools/pulse/internal/json/JSONTokener.java | 441 ++ .../tools/pulse/internal/json/JSONWriter.java | 322 ++ .../geode/tools/pulse/internal/json/README | 68 + .../geode/tools/pulse/internal/json/XML.java | 503 +++ .../tools/pulse/internal/json/XMLTokener.java | 360 ++ .../tools/pulse/internal/log/LogWriter.java | 265 ++ .../pulse/internal/log/MessageFormatter.java | 102 + .../pulse/internal/log/PulseLogWriter.java | 299 ++ .../tools/pulse/internal/log/PulseLogger.java | 142 + .../security/GemFireAuthentication.java | 91 + .../security/GemFireAuthenticationProvider.java | 80 + .../pulse/internal/security/LogoutHandler.java | 55 + .../internal/service/ClusterDetailsService.java | 104 + .../service/ClusterDiskThroughputService.java | 71 + .../service/ClusterGCPausesService.java | 69 + .../service/ClusterKeyStatisticsService.java | 69 + .../internal/service/ClusterMemberService.java | 132 + .../service/ClusterMembersRGraphService.java | 359 ++ .../service/ClusterMemoryUsageService.java | 65 + .../internal/service/ClusterRegionService.java | 211 + .../internal/service/ClusterRegionsService.java | 206 + .../service/ClusterSelectedRegionService.java | 237 ++ .../ClusterSelectedRegionsMemberService.java | 143 + .../internal/service/ClusterWANInfoService.java | 75 + .../service/MemberAsynchEventQueuesService.java | 99 + .../internal/service/MemberClientsService.java | 101 + .../internal/service/MemberDetailsService.java | 122 + .../service/MemberDiskThroughputService.java | 76 + .../internal/service/MemberGCPausesService.java | 73 + .../service/MemberGatewayHubService.java | 149 + .../service/MemberHeapUsageService.java | 73 + .../service/MemberKeyStatisticsService.java | 76 + .../internal/service/MemberRegionsService.java | 127 + .../internal/service/MembersListService.java | 75 + .../pulse/internal/service/PulseService.java | 40 + .../internal/service/PulseServiceFactory.java | 55 + .../internal/service/PulseVersionService.java | 65 + .../service/QueryStatisticsService.java | 115 + .../internal/service/SystemAlertsService.java | 127 + .../pulse/internal/util/ConnectionUtil.java | 46 + .../pulse/internal/util/IPAddressUtil.java | 65 + .../tools/pulse/internal/util/StringUtils.java | 85 + .../tools/pulse/internal/util/TimeUtils.java | 120 + .../webapp/WEB-INF/mvc-dispatcher-servlet.xml | 4 +- .../controllers/PulseControllerJUnitTest.java | 816 ---- .../pulse/testbed/GemFireDistributedSystem.java | 324 -- .../tools/pulse/testbed/GemfireTopology.java | 24 - .../tools/pulse/testbed/PropFileHelper.java | 115 - .../pulse/testbed/PropMockDataUpdater.java | 513 --- .../gemfire/tools/pulse/testbed/TestBed.java | 84 - .../tools/pulse/testbed/driver/PulseUITest.java | 277 -- .../tools/pulse/tests/AggregateStatement.java | 217 - .../pulse/tests/AggregateStatementMBean.java | 168 - .../pulse/tests/DataBrowserResultLoader.java | 84 - .../pulse/tests/GemFireXDAggregateTable.java | 46 - .../tests/GemFireXDAggregateTableMBean.java | 28 - .../tools/pulse/tests/GemFireXDCluster.java | 95 - .../pulse/tests/GemFireXDClusterMBean.java | 32 - .../tools/pulse/tests/GemFireXDMember.java | 80 - .../tools/pulse/tests/GemFireXDMemberMBean.java | 31 - .../gemfire/tools/pulse/tests/JMXBaseBean.java | 67 - .../tools/pulse/tests/JMXProperties.java | 47 - .../gemfire/tools/pulse/tests/Member.java | 193 - .../gemfire/tools/pulse/tests/MemberMBean.java | 86 - .../tools/pulse/tests/PulseAbstractTest.java | 1047 ----- .../tools/pulse/tests/PulseAuthTest.java | 33 - .../tools/pulse/tests/PulseAutomatedTest.java | 784 ---- .../tools/pulse/tests/PulseBaseTest.java | 693 ---- .../tools/pulse/tests/PulseNoAuthTest.java | 33 - .../tools/pulse/tests/PulseTestData.java | 106 - .../tools/pulse/tests/PulseTestLocators.java | 225 -- .../gemfire/tools/pulse/tests/Region.java | 187 - .../gemfire/tools/pulse/tests/RegionMBean.java | 59 - .../tools/pulse/tests/RegionOnMember.java | 95 - .../tools/pulse/tests/RegionOnMemberMBean.java | 49 - .../gemfire/tools/pulse/tests/Server.java | 247 -- .../gemfire/tools/pulse/tests/ServerObject.java | 267 -- .../tools/pulse/tests/ServerObjectMBean.java | 79 - .../pulse/tests/junit/BaseServiceTest.java | 254 -- .../junit/ClusterSelectedRegionServiceTest.java | 340 -- ...ClusterSelectedRegionsMemberServiceTest.java | 354 -- .../junit/MemberGatewayHubServiceTest.java | 412 -- .../controllers/PulseControllerJUnitTest.java | 816 ++++ .../pulse/testbed/GemFireDistributedSystem.java | 324 ++ .../tools/pulse/testbed/GemfireTopology.java | 24 + .../tools/pulse/testbed/PropFileHelper.java | 115 + .../pulse/testbed/PropMockDataUpdater.java | 513 +++ .../geode/tools/pulse/testbed/TestBed.java | 84 + .../tools/pulse/testbed/driver/PulseUITest.java | 277 ++ .../tools/pulse/tests/AggregateStatement.java | 217 + .../pulse/tests/AggregateStatementMBean.java | 168 + .../pulse/tests/DataBrowserResultLoader.java | 84 + .../pulse/tests/GemFireXDAggregateTable.java | 46 + .../tests/GemFireXDAggregateTableMBean.java | 28 + .../tools/pulse/tests/GemFireXDCluster.java | 95 + .../pulse/tests/GemFireXDClusterMBean.java | 32 + .../tools/pulse/tests/GemFireXDMember.java | 80 + .../tools/pulse/tests/GemFireXDMemberMBean.java | 31 + .../geode/tools/pulse/tests/JMXBaseBean.java | 67 + .../geode/tools/pulse/tests/JMXProperties.java | 47 + .../apache/geode/tools/pulse/tests/Member.java | 193 + .../geode/tools/pulse/tests/MemberMBean.java | 86 + .../tools/pulse/tests/PulseAbstractTest.java | 1047 +++++ .../geode/tools/pulse/tests/PulseAuthTest.java | 33 + .../tools/pulse/tests/PulseAutomatedTest.java | 784 ++++ .../geode/tools/pulse/tests/PulseBaseTest.java | 693 ++++ .../tools/pulse/tests/PulseNoAuthTest.java | 33 + .../geode/tools/pulse/tests/PulseTestData.java | 106 + .../tools/pulse/tests/PulseTestLocators.java | 225 ++ .../apache/geode/tools/pulse/tests/Region.java | 187 + .../geode/tools/pulse/tests/RegionMBean.java | 59 + .../geode/tools/pulse/tests/RegionOnMember.java | 95 + .../tools/pulse/tests/RegionOnMemberMBean.java | 49 + .../apache/geode/tools/pulse/tests/Server.java | 247 ++ .../geode/tools/pulse/tests/ServerObject.java | 267 ++ .../tools/pulse/tests/ServerObjectMBean.java | 79 + .../pulse/tests/junit/BaseServiceTest.java | 254 ++ .../junit/ClusterSelectedRegionServiceTest.java | 340 ++ ...ClusterSelectedRegionsMemberServiceTest.java | 354 ++ .../junit/MemberGatewayHubServiceTest.java | 412 ++ 264 files changed, 29141 insertions(+), 29141 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/com/company/app/Customer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/company/app/Customer.java b/geode-core/src/test/java/com/company/app/Customer.java new file mode 100644 index 0000000..9dc87ca --- /dev/null +++ b/geode-core/src/test/java/com/company/app/Customer.java @@ -0,0 +1,36 @@ +/* + * 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.Declarable; + +/** + * A class that is <code>Declarable</code> + * + * @since GemFire 3.2.1 + */ +public class Customer implements Declarable { + + public Customer() { + + } + + public void init(java.util.Properties props) { + + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/com/company/app/DBLoader.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/company/app/DBLoader.java b/geode-core/src/test/java/com/company/app/DBLoader.java new file mode 100644 index 0000000..ab22805 --- /dev/null +++ b/geode-core/src/test/java/com/company/app/DBLoader.java @@ -0,0 +1,63 @@ +/* + * 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 java.util.Properties; + +import org.apache.geode.cache.*; + +/** + * A <code>CacheLoader</code> that is <code>Declarable</code> + * + * @since GemFire 3.2.1 + */ +public class DBLoader implements CacheLoader, Declarable { + + private Properties props = new Properties(); + + public Object load(LoaderHelper helper) + throws CacheLoaderException { + + throw new UnsupportedOperationException("I do NOTHING"); + } + + public void init(java.util.Properties props) { + this.props = props; + } + + public void close() { + } + + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + + if (! (obj instanceof DBLoader)) { + return false; + } + + DBLoader other = (DBLoader) obj; + if (! this.props.equals(other.props)) { + return false; + } + + return true; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/com/company/app/OrdersCacheListener.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/company/app/OrdersCacheListener.java b/geode-core/src/test/java/com/company/app/OrdersCacheListener.java new file mode 100755 index 0000000..ec91dcb --- /dev/null +++ b/geode-core/src/test/java/com/company/app/OrdersCacheListener.java @@ -0,0 +1,51 @@ +/* + * 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/com/company/data/DatabaseLoader.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/company/data/DatabaseLoader.java b/geode-core/src/test/java/com/company/data/DatabaseLoader.java new file mode 100644 index 0000000..84b1c70 --- /dev/null +++ b/geode-core/src/test/java/com/company/data/DatabaseLoader.java @@ -0,0 +1,42 @@ +/* + * 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/com/company/data/MyDeclarable.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/company/data/MyDeclarable.java b/geode-core/src/test/java/com/company/data/MyDeclarable.java new file mode 100644 index 0000000..0545c26 --- /dev/null +++ b/geode-core/src/test/java/com/company/data/MyDeclarable.java @@ -0,0 +1,32 @@ +/* + * 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/com/company/data/MySizer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/company/data/MySizer.java b/geode-core/src/test/java/com/company/data/MySizer.java new file mode 100644 index 0000000..30e5e16 --- /dev/null +++ b/geode-core/src/test/java/com/company/data/MySizer.java @@ -0,0 +1,39 @@ +/* + * 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/com/company/data/MyTransactionListener.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/company/data/MyTransactionListener.java b/geode-core/src/test/java/com/company/data/MyTransactionListener.java new file mode 100644 index 0000000..074e12d --- /dev/null +++ b/geode-core/src/test/java/com/company/data/MyTransactionListener.java @@ -0,0 +1,38 @@ +/* + * 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/com/examples/LinkNode.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/LinkNode.java b/geode-core/src/test/java/com/examples/LinkNode.java new file mode 100644 index 0000000..97a0438 --- /dev/null +++ b/geode-core/src/test/java/com/examples/LinkNode.java @@ -0,0 +1,77 @@ +/* + * 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/com/examples/SuperClass.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/SuperClass.java b/geode-core/src/test/java/com/examples/SuperClass.java new file mode 100644 index 0000000..6c6076f --- /dev/null +++ b/geode-core/src/test/java/com/examples/SuperClass.java @@ -0,0 +1,92 @@ +/* + * 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/com/examples/TestObject.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/TestObject.java b/geode-core/src/test/java/com/examples/TestObject.java new file mode 100644 index 0000000..9b871a7 --- /dev/null +++ b/geode-core/src/test/java/com/examples/TestObject.java @@ -0,0 +1,54 @@ +/* + * 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/com/examples/ds/Address.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/ds/Address.java b/geode-core/src/test/java/com/examples/ds/Address.java new file mode 100644 index 0000000..5a82531 --- /dev/null +++ b/geode-core/src/test/java/com/examples/ds/Address.java @@ -0,0 +1,23 @@ +/* + * 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/com/examples/ds/Company.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/ds/Company.java b/geode-core/src/test/java/com/examples/ds/Company.java new file mode 100644 index 0000000..6fc93ee --- /dev/null +++ b/geode-core/src/test/java/com/examples/ds/Company.java @@ -0,0 +1,43 @@ +/* + * 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/com/examples/ds/CompanySerializer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/ds/CompanySerializer.java b/geode-core/src/test/java/com/examples/ds/CompanySerializer.java new file mode 100644 index 0000000..9d69083 --- /dev/null +++ b/geode-core/src/test/java/com/examples/ds/CompanySerializer.java @@ -0,0 +1,67 @@ +/* + * 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/com/examples/ds/Employee.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/ds/Employee.java b/geode-core/src/test/java/com/examples/ds/Employee.java new file mode 100644 index 0000000..9165e34 --- /dev/null +++ b/geode-core/src/test/java/com/examples/ds/Employee.java @@ -0,0 +1,53 @@ +/* + * 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/com/examples/ds/PutDataSerializables.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/ds/PutDataSerializables.java b/geode-core/src/test/java/com/examples/ds/PutDataSerializables.java new file mode 100644 index 0000000..162ce5a --- /dev/null +++ b/geode-core/src/test/java/com/examples/ds/PutDataSerializables.java @@ -0,0 +1,54 @@ +/* + * 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/com/examples/ds/User.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/ds/User.java b/geode-core/src/test/java/com/examples/ds/User.java new file mode 100644 index 0000000..4bf4531 --- /dev/null +++ b/geode-core/src/test/java/com/examples/ds/User.java @@ -0,0 +1,58 @@ +/* + * 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/com/examples/snapshot/MyDataSerializer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/snapshot/MyDataSerializer.java b/geode-core/src/test/java/com/examples/snapshot/MyDataSerializer.java new file mode 100644 index 0000000..0b8d9e6 --- /dev/null +++ b/geode-core/src/test/java/com/examples/snapshot/MyDataSerializer.java @@ -0,0 +1,63 @@ +/* + * 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/com/examples/snapshot/MyObject.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/snapshot/MyObject.java b/geode-core/src/test/java/com/examples/snapshot/MyObject.java new file mode 100644 index 0000000..aaada9d --- /dev/null +++ b/geode-core/src/test/java/com/examples/snapshot/MyObject.java @@ -0,0 +1,68 @@ +/* + * 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/com/examples/snapshot/MyObjectDataSerializable.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/snapshot/MyObjectDataSerializable.java b/geode-core/src/test/java/com/examples/snapshot/MyObjectDataSerializable.java new file mode 100644 index 0000000..1582744 --- /dev/null +++ b/geode-core/src/test/java/com/examples/snapshot/MyObjectDataSerializable.java @@ -0,0 +1,45 @@ +/* + * 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/com/examples/snapshot/MyObjectPdx.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/snapshot/MyObjectPdx.java b/geode-core/src/test/java/com/examples/snapshot/MyObjectPdx.java new file mode 100644 index 0000000..396049d --- /dev/null +++ b/geode-core/src/test/java/com/examples/snapshot/MyObjectPdx.java @@ -0,0 +1,33 @@ +/* + * 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/com/examples/snapshot/MyObjectPdxSerializable.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/snapshot/MyObjectPdxSerializable.java b/geode-core/src/test/java/com/examples/snapshot/MyObjectPdxSerializable.java new file mode 100644 index 0000000..3929db4 --- /dev/null +++ b/geode-core/src/test/java/com/examples/snapshot/MyObjectPdxSerializable.java @@ -0,0 +1,42 @@ +/* + * 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/com/examples/snapshot/MyPdxSerializer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/examples/snapshot/MyPdxSerializer.java b/geode-core/src/test/java/com/examples/snapshot/MyPdxSerializer.java new file mode 100644 index 0000000..710e445 --- /dev/null +++ b/geode-core/src/test/java/com/examples/snapshot/MyPdxSerializer.java @@ -0,0 +1,64 @@ +/* + * 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/com/main/MyDistributedSystemListener.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/MyDistributedSystemListener.java b/geode-core/src/test/java/com/main/MyDistributedSystemListener.java new file mode 100644 index 0000000..6206441 --- /dev/null +++ b/geode-core/src/test/java/com/main/MyDistributedSystemListener.java @@ -0,0 +1,114 @@ +/* + * 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/com/main/WANBootStrapping_Site1_Add.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Add.java b/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Add.java new file mode 100644 index 0000000..9d4bbfc --- /dev/null +++ b/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Add.java @@ -0,0 +1,122 @@ +/* + * 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/com/main/WANBootStrapping_Site1_Remove.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Remove.java b/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Remove.java new file mode 100644 index 0000000..6920d7e --- /dev/null +++ b/geode-core/src/test/java/com/main/WANBootStrapping_Site1_Remove.java @@ -0,0 +1,78 @@ +/* + * 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/com/main/WANBootStrapping_Site2_Add.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Add.java b/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Add.java new file mode 100644 index 0000000..f5abf5d --- /dev/null +++ b/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Add.java @@ -0,0 +1,108 @@ +/* + * 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/com/main/WANBootStrapping_Site2_Remove.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Remove.java b/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Remove.java new file mode 100644 index 0000000..30e0a22 --- /dev/null +++ b/geode-core/src/test/java/com/main/WANBootStrapping_Site2_Remove.java @@ -0,0 +1,74 @@ +/* + * 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); + } + + +} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderTest.java b/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderTest.java index aaeab36..26b3a91 100755 --- a/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/ClassPathLoaderTest.java @@ -46,7 +46,7 @@ import org.apache.geode.test.junit.categories.UnitTest; @Category(UnitTest.class) public class ClassPathLoaderTest { - private static final int GENERATED_CLASS_BYTES_COUNT = 362; + private static final int GENERATED_CLASS_BYTES_COUNT = 354; @Rule public RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties(); http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eff7f216/geode-core/src/test/java/org/company/app/Customer.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/company/app/Customer.java b/geode-core/src/test/java/org/company/app/Customer.java deleted file mode 100644 index 9dc87ca..0000000 --- a/geode-core/src/test/java/org/company/app/Customer.java +++ /dev/null @@ -1,36 +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.Declarable; - -/** - * A class that is <code>Declarable</code> - * - * @since GemFire 3.2.1 - */ -public class Customer implements Declarable { - - public Customer() { - - } - - 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/app/DBLoader.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/company/app/DBLoader.java b/geode-core/src/test/java/org/company/app/DBLoader.java deleted file mode 100644 index ab22805..0000000 --- a/geode-core/src/test/java/org/company/app/DBLoader.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.company.app; - -import java.util.Properties; - -import org.apache.geode.cache.*; - -/** - * A <code>CacheLoader</code> that is <code>Declarable</code> - * - * @since GemFire 3.2.1 - */ -public class DBLoader implements CacheLoader, Declarable { - - private Properties props = new Properties(); - - public Object load(LoaderHelper helper) - throws CacheLoaderException { - - throw new UnsupportedOperationException("I do NOTHING"); - } - - public void init(java.util.Properties props) { - this.props = props; - } - - public void close() { - } - - public boolean equals(Object obj) - { - if (this == obj) { - return true; - } - - if (! (obj instanceof DBLoader)) { - return false; - } - - DBLoader other = (DBLoader) obj; - if (! this.props.equals(other.props)) { - return false; - } - - return true; - } - -}
