forked from apache/geode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
866 additions
and
0 deletions.
There are no files selected for viewing
114 changes: 114 additions & 0 deletions
114
geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PrePopulateRegionLong.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 org.apache.geode.benchmark.tasks; | ||
|
||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.CLIENT; | ||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.LOCATOR; | ||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import org.apache.geode.benchmark.LongRange; | ||
import org.apache.geode.cache.Region; | ||
import org.apache.geode.cache.client.ClientCache; | ||
import org.apache.geode.cache.client.ClientCacheFactory; | ||
import org.apache.geode.perftest.Task; | ||
import org.apache.geode.perftest.TestContext; | ||
|
||
|
||
public class PrePopulateRegionLong implements Task { | ||
private static final Logger logger = LoggerFactory.getLogger(PrePopulateRegionLong.class); | ||
|
||
private LongRange keyRangeToPrepopulate = new LongRange(0, 10000); | ||
private int batchSize = 1000; | ||
|
||
public PrePopulateRegionLong() {} | ||
|
||
public PrePopulateRegionLong(LongRange keyRangeToPrepopulate) { | ||
this.keyRangeToPrepopulate = keyRangeToPrepopulate; | ||
} | ||
|
||
/** | ||
* This method prepopulates the region before the actual benchmark starts. | ||
*/ | ||
@Override | ||
public void run(TestContext context) throws InterruptedException { | ||
final ClientCache cache = ClientCacheFactory.getAnyInstance(); | ||
final Region<Long, Long> region = cache.getRegion("region"); | ||
final int numLocators = context.getHostsIDsForRole(LOCATOR).size(); | ||
final int numServers = context.getHostsIDsForRole(SERVER).size(); | ||
final int numClient = context.getHostsIDsForRole(CLIENT).size(); | ||
final int jvmID = context.getJvmID(); | ||
final int clientIndex = jvmID - numLocators - numServers; | ||
|
||
run(region, keyRangeToPrepopulate.sliceFor(numClient, clientIndex)); | ||
} | ||
|
||
void run(final Map<Long, Long> region, final LongRange range) throws InterruptedException { | ||
logger.info("*******************************************"); | ||
logger.info(" Prepopulating the region "); | ||
logger.info("*******************************************"); | ||
final Instant start = Instant.now(); | ||
|
||
final int numThreads = Runtime.getRuntime().availableProcessors(); | ||
final ExecutorService threadPool = Executors.newFixedThreadPool(numThreads); | ||
final List<CompletableFuture<Void>> futures = new ArrayList<>(); | ||
|
||
for (final LongRange slice : range.slice(numThreads)) { | ||
futures.add(CompletableFuture.runAsync(() -> doPuts(region, slice), threadPool)); | ||
} | ||
|
||
futures.forEach(CompletableFuture::join); | ||
|
||
final Instant finish = Instant.now(); | ||
logger.info("*******************************************"); | ||
logger.info(" Prepopulating the region completed"); | ||
logger.info(" Duration = " + Duration.between(start, finish).toMillis() + "ms."); | ||
logger.info("*******************************************"); | ||
|
||
threadPool.shutdownNow(); | ||
threadPool.awaitTermination(5, TimeUnit.MINUTES); | ||
} | ||
|
||
private void doPuts(final Map<Long, Long> region, final LongRange range) { | ||
for (final LongRange slice : range.slicesOfSize(batchSize)) { | ||
final Map<Long, Long> valueMap = new HashMap<>(); | ||
slice.forEach(i -> valueMap.put(i, i)); | ||
region.putAll(valueMap); | ||
} | ||
} | ||
|
||
public int getBatchSize() { | ||
return batchSize; | ||
} | ||
|
||
public void setBatchSize(int batchSize) { | ||
this.batchSize = batchSize; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...enchmarks/src/main/java/org/apache/geode/benchmark/tests/PartitionedGetLongBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.geode.benchmark.tests; | ||
|
||
|
||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.CLIENT; | ||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.apache.geode.benchmark.LongRange; | ||
import org.apache.geode.benchmark.tasks.CreateClientProxyRegion; | ||
import org.apache.geode.benchmark.tasks.CreatePartitionedRegion; | ||
import org.apache.geode.benchmark.tasks.GetTask; | ||
import org.apache.geode.benchmark.tasks.PrePopulateRegionLong; | ||
import org.apache.geode.benchmark.topology.ClientServerTopology; | ||
import org.apache.geode.perftest.PerformanceTest; | ||
import org.apache.geode.perftest.TestConfig; | ||
import org.apache.geode.perftest.TestRunners; | ||
|
||
/** | ||
* Benchmark of gets on a partitioned region. | ||
*/ | ||
public class PartitionedGetLongBenchmark implements PerformanceTest { | ||
|
||
private LongRange keyRange = new LongRange(0, 1000000); | ||
|
||
@Test | ||
public void run() throws Exception { | ||
TestRunners.defaultRunner().runTest(this); | ||
} | ||
|
||
public PartitionedGetLongBenchmark() {} | ||
|
||
public void setKeyRange(final LongRange keyRange) { | ||
this.keyRange = keyRange; | ||
} | ||
|
||
@Override | ||
public TestConfig configure() { | ||
TestConfig config = GeodeBenchmark.createConfig(); | ||
ClientServerTopology.configure(config); | ||
config.before(new CreatePartitionedRegion(), SERVER); | ||
config.before(new CreateClientProxyRegion(), CLIENT); | ||
config.before(new PrePopulateRegionLong(keyRange), CLIENT); | ||
config.workload(new GetTask(keyRange), CLIENT); | ||
return config; | ||
|
||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
...hmarks/src/main/java/org/apache/geode/benchmark/tests/PartitionedPutAllLongBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.geode.benchmark.tests; | ||
|
||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.CLIENT; | ||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.apache.geode.benchmark.LongRange; | ||
import org.apache.geode.benchmark.tasks.CreateClientProxyRegion; | ||
import org.apache.geode.benchmark.tasks.CreatePartitionedRegion; | ||
import org.apache.geode.benchmark.tasks.PrePopulateRegionLong; | ||
import org.apache.geode.benchmark.tasks.PutAllTask; | ||
import org.apache.geode.benchmark.topology.ClientServerTopology; | ||
import org.apache.geode.perftest.PerformanceTest; | ||
import org.apache.geode.perftest.TestConfig; | ||
import org.apache.geode.perftest.TestRunners; | ||
|
||
/** | ||
* Benchmark of putAlls on a partitioned region. | ||
*/ | ||
public class PartitionedPutAllLongBenchmark implements PerformanceTest { | ||
|
||
private LongRange keyRange = new LongRange(0, 1000000); | ||
|
||
private int batchSize = 1000; | ||
|
||
public PartitionedPutAllLongBenchmark() {} | ||
|
||
public void setKeyRange(final LongRange keyRange) { | ||
this.keyRange = keyRange; | ||
} | ||
|
||
@Test | ||
public void run() throws Exception { | ||
TestRunners.defaultRunner().runTest(this); | ||
} | ||
|
||
@Override | ||
public TestConfig configure() { | ||
TestConfig config = GeodeBenchmark.createConfig(); | ||
config.threads(Runtime.getRuntime().availableProcessors() * 2); | ||
ClientServerTopology.configure(config); | ||
config.before(new CreatePartitionedRegion(), SERVER); | ||
config.before(new CreateClientProxyRegion(), CLIENT); | ||
config.before(new PrePopulateRegionLong(keyRange), CLIENT); | ||
config.workload(new PutAllTask(keyRange, batchSize), CLIENT); | ||
return config; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...enchmarks/src/main/java/org/apache/geode/benchmark/tests/PartitionedPutLongBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 org.apache.geode.benchmark.tests; | ||
|
||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.CLIENT; | ||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.apache.geode.benchmark.LongRange; | ||
import org.apache.geode.benchmark.tasks.CreateClientProxyRegion; | ||
import org.apache.geode.benchmark.tasks.CreatePartitionedRegion; | ||
import org.apache.geode.benchmark.tasks.PrePopulateRegionLong; | ||
import org.apache.geode.benchmark.tasks.PutTask; | ||
import org.apache.geode.benchmark.topology.ClientServerTopology; | ||
import org.apache.geode.perftest.PerformanceTest; | ||
import org.apache.geode.perftest.TestConfig; | ||
import org.apache.geode.perftest.TestRunners; | ||
|
||
/** | ||
* Benchmark of puts on a partitioned region. | ||
*/ | ||
public class PartitionedPutLongBenchmark implements PerformanceTest { | ||
|
||
private LongRange keyRange = new LongRange(0, 1000000); | ||
|
||
public PartitionedPutLongBenchmark() {} | ||
|
||
public void setKeyRange(final LongRange keyRange) { | ||
this.keyRange = keyRange; | ||
} | ||
|
||
@Test | ||
public void run() throws Exception { | ||
TestRunners.defaultRunner().runTest(this); | ||
} | ||
|
||
@Override | ||
public TestConfig configure() { | ||
TestConfig config = GeodeBenchmark.createConfig(); | ||
ClientServerTopology.configure(config); | ||
config.before(new CreatePartitionedRegion(), SERVER); | ||
config.before(new CreateClientProxyRegion(), CLIENT); | ||
config.before(new PrePopulateRegionLong(keyRange), CLIENT); | ||
config.workload(new PutTask(keyRange), CLIENT); | ||
return config; | ||
|
||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...benchmarks/src/main/java/org/apache/geode/benchmark/tests/ReplicatedGetLongBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.geode.benchmark.tests; | ||
|
||
|
||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.CLIENT; | ||
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import org.apache.geode.benchmark.LongRange; | ||
import org.apache.geode.benchmark.tasks.CreateClientProxyRegion; | ||
import org.apache.geode.benchmark.tasks.CreateReplicatedRegion; | ||
import org.apache.geode.benchmark.tasks.GetTask; | ||
import org.apache.geode.benchmark.tasks.PrePopulateRegionLong; | ||
import org.apache.geode.benchmark.topology.ClientServerTopology; | ||
import org.apache.geode.perftest.PerformanceTest; | ||
import org.apache.geode.perftest.TestConfig; | ||
import org.apache.geode.perftest.TestRunners; | ||
|
||
/** | ||
* Benchmark of gets on a replicated region. | ||
*/ | ||
public class ReplicatedGetLongBenchmark implements PerformanceTest { | ||
|
||
private LongRange keyRange = new LongRange(0, 1000000); | ||
|
||
@Test | ||
public void run() throws Exception { | ||
TestRunners.defaultRunner().runTest(this); | ||
} | ||
|
||
public ReplicatedGetLongBenchmark() {} | ||
|
||
public void setKeyRange(final LongRange keyRange) { | ||
this.keyRange = keyRange; | ||
} | ||
|
||
@Override | ||
public TestConfig configure() { | ||
TestConfig config = GeodeBenchmark.createConfig(); | ||
ClientServerTopology.configure(config); | ||
config.before(new CreateReplicatedRegion(), SERVER); | ||
config.before(new CreateClientProxyRegion(), CLIENT); | ||
config.before(new PrePopulateRegionLong(keyRange), CLIENT); | ||
config.workload(new GetTask(keyRange), CLIENT); | ||
return config; | ||
|
||
} | ||
} |
Oops, something went wrong.