-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into db_vector_performance_test
- Loading branch information
Showing
10 changed files
with
275 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
91 changes: 91 additions & 0 deletions
91
java/drivers/driver-hazelcast4plus/src/main/java/com/hazelcast/simulator/hz/TTRTest.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,91 @@ | ||
package com.hazelcast.simulator.hz; | ||
|
||
import com.hazelcast.map.IMap; | ||
import com.hazelcast.simulator.test.BaseThreadState; | ||
import com.hazelcast.simulator.test.annotations.Prepare; | ||
import com.hazelcast.simulator.test.annotations.Setup; | ||
import com.hazelcast.simulator.test.annotations.TimeStep; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Random; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Future; | ||
|
||
import static com.hazelcast.simulator.utils.GeneratorUtils.generateAsciiStrings; | ||
|
||
public class TTRTest extends HazelcastTest { | ||
|
||
// properties | ||
public String mapBaseName = "map"; | ||
public int mapCount = 10; | ||
public int batchSize = 1000; | ||
public long keyDomain = 10000; | ||
public int valueCount = 100; | ||
public int minValueLength = 10; | ||
public int maxValueLength = 10; | ||
public int pingCount = 100; | ||
|
||
private String[] values; | ||
private IMap<Object, Object> pingMap; | ||
|
||
|
||
@Setup | ||
public void setUp() { | ||
values = generateAsciiStrings(valueCount, minValueLength, maxValueLength); | ||
pingMap = targetInstance.getMap("pingmap"); | ||
} | ||
|
||
@Prepare(global = true) | ||
public void prepare() throws ExecutionException, InterruptedException { | ||
List<CompletableFuture> batch = new ArrayList<>(batchSize); | ||
Random random = new Random(); | ||
for (long k = 0; k < keyDomain; k++) { | ||
IMap map = targetInstance.getMap(mapBaseName + k % mapCount); | ||
String value = values[random.nextInt(valueCount)]; | ||
batch.add(map.putAsync(k, value).toCompletableFuture()); | ||
|
||
if (k % 1_000_000 == 0) { | ||
testContext.echoCoordinator("Insertion at : " + k); | ||
} | ||
|
||
if (batch.size() == batchSize) { | ||
waitAndClear(batch); | ||
} | ||
} | ||
|
||
waitAndClear(batch); | ||
} | ||
|
||
private void waitAndClear(List<CompletableFuture> batch) throws ExecutionException, InterruptedException { | ||
for (Future f : batch) { | ||
f.get(); | ||
} | ||
|
||
batch.clear(); | ||
} | ||
|
||
@TimeStep | ||
public void ping(ThreadState state) throws ExecutionException, InterruptedException { | ||
List<Future> futures = new ArrayList<>(pingCount); | ||
for (int k = 0; k < pingCount; k++) { | ||
futures.add(pingMap.getAsync(k).toCompletableFuture()); | ||
} | ||
|
||
for (Future future : futures) { | ||
future.get(); | ||
} | ||
} | ||
|
||
public class ThreadState extends BaseThreadState { | ||
|
||
private long randomKey() { | ||
return randomLong(keyDomain); | ||
} | ||
|
||
private String randomValue() { | ||
return values[randomInt(values.length)]; | ||
} | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
...r-hazelcast4plus/src/main/java/com/hazelcast/simulator/tests/map/MetricsCarouselTest.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,103 @@ | ||
/* | ||
* Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed 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.hazelcast.simulator.tests.map; | ||
|
||
import com.hazelcast.collection.IList; | ||
import com.hazelcast.collection.ISet; | ||
import com.hazelcast.core.DistributedObject; | ||
import com.hazelcast.map.IMap; | ||
import com.hazelcast.multimap.MultiMap; | ||
import com.hazelcast.simulator.hz.HazelcastTest; | ||
import com.hazelcast.simulator.test.BaseThreadState; | ||
import com.hazelcast.simulator.test.annotations.Setup; | ||
import com.hazelcast.simulator.test.annotations.TimeStep; | ||
|
||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
public class MetricsCarouselTest extends HazelcastTest { | ||
|
||
private final Map<String, ObjectInfo> createdObjects = new ConcurrentHashMap<>(); | ||
public int keyDomain = 10000; | ||
public int valueCount = 10000; | ||
public int sleepTimeInSeconds = 5000; | ||
public int eligibleForCleanupTimeInSeconds = 30_000; | ||
|
||
@Setup | ||
public void setUp() { | ||
targetInstance.getDistributedObjects() | ||
.forEach(DistributedObject::destroy); | ||
} | ||
|
||
@TimeStep(prob = 1) | ||
// The scenario is designed mainly to check the unique metric IDs overflow | ||
// https://hazelcast.atlassian.net/browse/MC-3012 | ||
// There is a use case where customers create a lot of unique short living objects | ||
// like data structures and/or clients. These objects live long enough to be populated to the MC | ||
// in MC there's an internal in memory storage which stored these objects' IDs and the ID's weren't | ||
// persisted together with the metrics themselves in a timely manner. This with a time may led to OOME | ||
|
||
//The test here doesn't really rely on super high performance | ||
// but rather creates the objects as unique as possible | ||
public void createMapsAndDeleteThemLater(BaseThreadState state) throws InterruptedException { | ||
cleanupOldObjects(); | ||
String name = UUID.randomUUID() + UUID.randomUUID().toString(); | ||
int randomIntOfTheDay = state.randomInt(); | ||
|
||
IMap<Integer, Integer> map = targetInstance.getMap("map-%s".formatted(name)); | ||
map.put(randomIntOfTheDay, randomIntOfTheDay); | ||
|
||
MultiMap<Integer, Integer> multiMap = targetInstance.getMultiMap("multimap-%s".formatted(name)); | ||
multiMap.put(randomIntOfTheDay, randomIntOfTheDay); | ||
|
||
IList<Integer> list = targetInstance.getList("list-%s".formatted(name)); | ||
list.add(randomIntOfTheDay); | ||
|
||
ISet<Integer> set = targetInstance.getSet("set-%s".formatted(name)); | ||
set.add(randomIntOfTheDay); | ||
|
||
ObjectInfo objectInfo = new ObjectInfo(System.currentTimeMillis(), map, multiMap, list, set); | ||
createdObjects.put(name, objectInfo); | ||
Thread.sleep(sleepTimeInSeconds); | ||
} | ||
|
||
private static class ObjectInfo { | ||
long creationTime; | ||
DistributedObject[] dataStructures; | ||
|
||
ObjectInfo(long creationTime, DistributedObject... dataStructures) { | ||
this.creationTime = creationTime; | ||
this.dataStructures = dataStructures; | ||
} | ||
} | ||
|
||
private void cleanupOldObjects() { | ||
long currentTime = System.currentTimeMillis(); | ||
synchronized (createdObjects) { | ||
createdObjects.entrySet().removeIf(entry -> { | ||
ObjectInfo info = entry.getValue(); | ||
if ((currentTime - info.creationTime) > eligibleForCleanupTimeInSeconds) { | ||
Arrays.stream(info.dataStructures).forEach(DistributedObject::destroy); | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
} | ||
} |
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
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
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
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