This is an automated email from the ASF dual-hosted git repository. udo pushed a commit to branch feature/GEODE-5705 in repository https://gitbox.apache.org/repos/asf/geode.git
commit cc906d4b48b216a5a96db345c9bc1d11d84c0ea4 Author: Udo Kohlmeyer <[email protected]> AuthorDate: Thu Dec 6 13:39:13 2018 -0800 Interview baseline --- geode-core/build.gradle | 22 +++++++++++ geode-core/src/main/kotlin/demo/Client.kt | 62 ++++++++++++++++++++++++++++++ geode-core/src/main/kotlin/demo/Locator.kt | 38 ++++++++++++++++++ geode-core/src/main/kotlin/demo/Server.kt | 43 +++++++++++++++++++++ geode-core/src/main/resources/cache123.xml | 44 +++++++++++++++++++++ 5 files changed, 209 insertions(+) diff --git a/geode-core/build.gradle b/geode-core/build.gradle index d4a08df..c37d006 100755 --- a/geode-core/build.gradle +++ b/geode-core/build.gradle @@ -18,12 +18,15 @@ apply plugin: 'antlr' apply plugin: 'me.champeau.gradle.jmh' +apply plugin: 'kotlin' sourceSets { jca { compileClasspath += configurations.compileClasspath runtimeClasspath += configurations.runtimeClasspath } + main.kotlin.srcDirs += 'src/main/kotlin' + main.kotlin.srcDirs += 'src/main/java' } idea { @@ -34,6 +37,23 @@ idea { testSourceDirs += project.tasks.generateUpgradeTestGrammarSource.outputs.files } } +sourceCompatibility = 1.8 +targetCompatibility = sourceCompatibility +compileKotlin { kotlinOptions.jvmTarget = sourceCompatibility } +compileTestKotlin { kotlinOptions.jvmTarget = sourceCompatibility } + +buildscript { + ext.kotlin_version = '1.3.10' + + repositories { + mavenCentral() + mavenLocal() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} configurations { //declaring new configuration that will be used to associate with artifacts @@ -45,6 +65,8 @@ dependencies { antlr 'antlr:antlr:' + project.'antlr.version' // External + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" + compileOnly files("${System.getProperty('java.home')}/../lib/tools.jar") compile 'com.github.stephenc.findbugs:findbugs-annotations:' + project.'stephenc-findbugs.version' compile 'org.jgroups:jgroups:' + project.'jgroups.version' diff --git a/geode-core/src/main/kotlin/demo/Client.kt b/geode-core/src/main/kotlin/demo/Client.kt new file mode 100644 index 0000000..6b08d38 --- /dev/null +++ b/geode-core/src/main/kotlin/demo/Client.kt @@ -0,0 +1,62 @@ +package demo/* + * 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. + */ + +import org.apache.geode.cache.client.ClientCacheFactory +import org.apache.geode.cache.client.ClientRegionShortcut +import java.util.* +import java.util.stream.IntStream + +fun main(args: Array<String>) { + val properties = Properties().apply { + setProperty("mcast-port", "0") + setProperty("statistic-sampling-enabled", "true") + } + val cache = ClientCacheFactory(properties).addPoolLocator("10.118.19.22 ", 10334).create() +// val cache = ClientCacheFactory(properties).addPoolLocator(args[0], args[1].toInt()).addPoolLocator(args[2], args[3].toInt()).create() + + val regionFactory = cache.createClientRegionFactory<String, String>(ClientRegionShortcut.PROXY) + regionFactory.setStatisticsEnabled(true) + val region1 = regionFactory.create("Region1") + + val regionFactory2 = cache.createClientRegionFactory<String, String>(ClientRegionShortcut.PROXY) + regionFactory2.setStatisticsEnabled(true) + val region2 = regionFactory2.create("Region3") + + val random = Random() + IntStream.range(0, Int.MAX_VALUE).parallel().forEach { count -> + + region1[count.toString()] = region1.size.toString() + + for (value in 0..random.nextInt(25)) { + region2[(value*count).toString()] = value.toString() + } + + if (random.nextBoolean()) { + for (value in 0..random.nextInt(35)) { + region1[count.toString()] + region2.destroy((value*count).toString()) + } + } else { + for (value in 0..random.nextInt(10)) { + region2[count.toString()] + region1.destroy((value*count).toString()) + } + } + Thread.sleep(100) + + println("Processed value $count") + + } +} \ No newline at end of file diff --git a/geode-core/src/main/kotlin/demo/Locator.kt b/geode-core/src/main/kotlin/demo/Locator.kt new file mode 100644 index 0000000..451ed64 --- /dev/null +++ b/geode-core/src/main/kotlin/demo/Locator.kt @@ -0,0 +1,38 @@ +package demo/* + * 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. + */ +import org.apache.geode.distributed.ConfigurationProperties +import org.apache.geode.distributed.LocatorLauncher + +fun main(args: Array<String>) { + val build = LocatorLauncher.Builder().apply { + port = 10334 + set(ConfigurationProperties.NAME, "locator") + set(ConfigurationProperties.STATISTIC_SAMPLING_ENABLED, "true") + set(ConfigurationProperties.ENABLE_TIME_STATISTICS, "true") + set(ConfigurationProperties.JMX_MANAGER, "false") + set(ConfigurationProperties.JMX_MANAGER_START, "false") + set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false") + hostnameForClients = "10.118.19.22" + set(ConfigurationProperties.BIND_ADDRESS, "10.118.19.22") + set(ConfigurationProperties.LOCATORS, "10.118.19.22[10334]") + set(ConfigurationProperties.ENABLE_NETWORK_PARTITION_DETECTION, "false") + }.build() + + build.start() + + while (true) { + Thread.sleep(5000) + } +} \ No newline at end of file diff --git a/geode-core/src/main/kotlin/demo/Server.kt b/geode-core/src/main/kotlin/demo/Server.kt new file mode 100644 index 0000000..2d48d16 --- /dev/null +++ b/geode-core/src/main/kotlin/demo/Server.kt @@ -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 demo + +import org.apache.geode.cache.CacheFactory +import org.apache.geode.distributed.ConfigurationProperties +import java.util.* + +fun main(args: Array<String>) { + + val properties = Properties().apply { + set(ConfigurationProperties.LOCATORS, "10.118.19.22[10334]") + set(ConfigurationProperties.NAME, "server") + set(ConfigurationProperties.CACHE_XML_FILE, "cache123.xml") + set(ConfigurationProperties.BIND_ADDRESS, "10.118.19.22") + set(ConfigurationProperties.MCAST_PORT, "0") + set(ConfigurationProperties.STATISTIC_SAMPLING_ENABLED, "true") + set(ConfigurationProperties.JMX_MANAGER, "false") + set(ConfigurationProperties.JMX_MANAGER_START, "false") + set(ConfigurationProperties.ENABLE_CLUSTER_CONFIGURATION, "false") + set(ConfigurationProperties.USE_CLUSTER_CONFIGURATION, "false") + set(ConfigurationProperties.CONSERVE_SOCKETS, "false") + set(ConfigurationProperties.ENABLE_NETWORK_PARTITION_DETECTION, "false") + } + val cache = CacheFactory(properties).create() + cache.addCacheServer().apply { + port = 0 + bindAddress = "10.118.19.22" + hostnameForClients = "10.118.19.22" + }.start() +} \ No newline at end of file diff --git a/geode-core/src/main/resources/cache123.xml b/geode-core/src/main/resources/cache123.xml new file mode 100644 index 0000000..c633cc2 --- /dev/null +++ b/geode-core/src/main/resources/cache123.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://geode.apache.org/schema/cache" + xsi:schemaLocation="http://geode.apache.org/schema/cache http://geode.apache.org/schema/cache/cache-1.0.xsd" + version="1.0" lock-lease="120" lock-timeout="60" search-timeout="300" is-server="true" copy-on-read="false"> + + <async-event-queue id="asyncQueue1"> + <async-event-listener> + <class-name>demo.AsyncEventQueueProcessor</class-name> + </async-event-listener> + </async-event-queue> + + <disk-store name="diskStore1" auto-compact="true" disk-usage-critical-percentage="90" max-oplog-size="1024"> + <disk-dirs> + <disk-dir>/tmp/diskstore1</disk-dir> + </disk-dirs> + </disk-store> + + <disk-store name="diskStore2" auto-compact="true" disk-usage-critical-percentage="90" max-oplog-size="1024"> + <disk-dirs> + <disk-dir>/tmp/diskstore2</disk-dir> + </disk-dirs> + </disk-store> + + <region name="Region1"> + <region-attributes async-event-queue-ids="asyncQueue1" disk-store-name="diskStore1" + data-policy="partition" statistics-enabled="true"> + <partition-attributes redundant-copies="1" total-num-buckets="113"/> + <eviction-attributes> + <lru-entry-count action="overflow-to-disk" maximum="55000"/> + </eviction-attributes> + </region-attributes> + </region> + + <region name="Region3"> + <region-attributes disk-store-name="diskStore2" + data-policy="partition" statistics-enabled="true"> + <partition-attributes startup-recovery-delay="10000" redundant-copies="1" total-num-buckets="113"/> + <eviction-attributes> + <lru-entry-count action="overflow-to-disk" maximum="75000"/> + </eviction-attributes> + </region-attributes> + </region> +</cache> +
