Skip to content

Commit

Permalink
Merge branch 'master' into db_vector_performance_test
Browse files Browse the repository at this point in the history
  • Loading branch information
abramche authored Oct 7, 2024
2 parents d1c2d97 + 5ee2706 commit aee8f32
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 6 deletions.
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ should be conducted in.

| Property | Example value | Description |
|----------------------------------------|------------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| `name` | `read_only` | The name of the test suite (overriden by test-specific values) |
| `name` | `read_only` | The name of the test suite (overriden by test-specific values) |
| `repititions` | `1` | The number of times this test suite should run (1 or more) |
| `duration` | `300s` | The amount of time this test suite should run for (45m, 1h, 2d, etc.) |
| `clients` | `1` | The number of Hazelcast Clients to use in this test suite (hosted on `loadgenerator_hosts` |
Expand All @@ -430,6 +430,7 @@ should be conducted in.
| `cooldown_seconds` | `0` | The number of seconds before the end of the test to exclude in reporting (only used for report generation) |
| `license_key` | `your_ee_key` | The Hazelcast Enterprise Edition license to use in your test, if using `hazelcast-enterprise5` drivers |
| `parallel` | `True` | Defines whether tests should be run in parallel when multiple tests are defined within 1 suite (default false) |
| `cp_priorities` | <pre>- address: internalIp<br> &nbsp;priority: 1</pre> | Defines the leadership priority of the CP Subsystem members in the cluster. Use the internal IP address of the agent(s) you wish to configure. |

### Specify test class(es) and number of threads per worker

Expand Down Expand Up @@ -1730,6 +1731,30 @@ but on the server side `pps_allowance_exceeded` might show 0 events/s.
For any pair of instances A and B, it is advised to run the PPS test for both A and B as the server.
This ensure a clear picture of all the PPS limits across instances.

### CP subsystem leader priority

It is possible to assign leadership priority to a member or list of members in a CP group(s). This is useful when
you want to attribute certain behaviours to an agent in the cluster. For example, you may wish to inject a latency
on the leader of a CP group. Ensure the internal IP of the agent(s) are used.

Here is an example of usage in the `tests.yaml` file:

```yaml
- name: my-test
<<: *defaults
cp_priorities:
- address: 10.0.55.178
priority: 1
- address: 10.0.55.179
priority: 2
test:
- class: com.hazelcast.simulator.tests.cp.IAtomicLongTest
threadCount: 135
getProb: .8
```

Consult [Configuring Leadership Priority](https://docs.hazelcast.com/hazelcast/5.5/cp-subsystem/configuration#configuring-leadership-priority
) for more information about the CP subsystem priority.

# Get Help

Expand Down
2 changes: 1 addition & 1 deletion java/drivers/driver-hazelcast4plus/conf/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _get_artifact_ids(enterprise:bool, version:str):
return ['hazelcast-enterprise-all']
else:
return ['hazelcast-all']
elif version.startswith("5"):
elif int(version.split('.')[0]) >= 5:
if enterprise:
return ['hazelcast-enterprise', 'hazelcast-sql', 'hazelcast-spring']
else:
Expand Down
2 changes: 1 addition & 1 deletion java/drivers/driver-hazelcast4plus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</parent>

<properties>
<hazelcast.version>5.5.0-SNAPSHOT</hazelcast.version>
<hazelcast.version>5.5.0</hazelcast.version>
<main.basedir>${project.parent.basedir}</main.basedir>
<netty.version>4.1.94.Final</netty.version>
<netty-tcnative.version>2.0.34.Final</netty-tcnative.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.hazelcast.partition.PartitionService;
import com.hazelcast.simulator.coordinator.registry.AgentData;
import com.hazelcast.simulator.drivers.Driver;
import com.hazelcast.simulator.utils.HazelcastUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -90,6 +91,7 @@ public void startDriverInstance() throws IOException {
// this way of loading is preferred so that env-variables and sys properties are picked up
System.setProperty("hazelcast.config", configFile.getAbsolutePath());
Config config = Config.load();
HazelcastUtils.handlePerAgentConfig(properties, config);
hazelcastInstance = Hazelcast.newHazelcastInstance(config);
} catch (NoSuchMethodError e) {
// Fall back in case Config.load doesn't exist (pre 4.2)
Expand Down
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)];
}
}
}
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;
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@
package com.hazelcast.simulator.utils;

import com.hazelcast.cluster.Member;
import com.hazelcast.config.Config;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.shaded.org.json.JSONArray;
import com.hazelcast.shaded.org.json.JSONObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.net.InetSocketAddress;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -30,6 +36,7 @@
public final class HazelcastUtils {

private static final int TIMEOUT_SECONDS = 60;
private static final Logger LOGGER = LogManager.getLogger(HazelcastUtils.class);

private HazelcastUtils() {
}
Expand All @@ -53,6 +60,46 @@ public static boolean isOldestMember(HazelcastInstance hazelcastInstance) {
return memberIterator.hasNext() && memberIterator.next().equals(hazelcastInstance.getLocalEndpoint());
}

/**
* Handles configuration settings for a member, based on properties bound to an agent's internal IP address.
* <p>
* This method is designed to be extendable for future configuration
* properties that may be applied on exclusive agents.
* </p>
*
* <p>
* Currently, the method supports the following configuration:
* </p>
* <ul>
* <li><b>CP Member Priority:</b> If the "cp_priority" property is provided,
* the method will set the CP member priority for the agent based on the agent's private IP address.</li>
* </ul>
*
* <p>
* Future configurations may extend the use of additional properties in a similar manner.
* </p>
*
*/
public static void handlePerAgentConfig(Map<String, String> properties, Config config) {
String cpPriorities = properties.get("cp_priority");
if (cpPriorities == null) {
return;
}

String agentPrivateAddress = properties.get("PRIVATE_ADDRESS");
JSONArray cpPriorityArray = new JSONArray(cpPriorities);

cpPriorityArray.forEach(item -> {
JSONObject jsonObject = (JSONObject) item;
String address = jsonObject.getString("address");
int priority = jsonObject.getInt("priority");
if (address.equals(agentPrivateAddress)) {
LOGGER.info("Setting CP member priority to " + priority + " for agent " + agentPrivateAddress);
config.getCPSubsystemConfig().setCPMemberPriority(priority);
}
});
}

public static String getHazelcastAddress(String workerType, String publicAddress, HazelcastInstance hazelcastInstance) {
if (hazelcastInstance != null) {
InetSocketAddress socketAddress = getInetSocketAddress(hazelcastInstance);
Expand Down
3 changes: 2 additions & 1 deletion src/inventory_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
--url=https://download.java.net/java/GA/jdk19.0.1/afdd2e245b014143b62ccb916125e3ce/10/GPL/openjdk-19.0.1_linux-aarch64_bin.tar.gz
--url=https://download.java.net/java/GA/jdk20.0.2/6e380f22cbe7469fa75fb448bd903d8e/9/GPL/openjdk-20.0.2_linux-x64_bin.tar.gz
--url=https://download.java.net/java/GA/jdk21/fd2272bbf8e04c3dbaee13770090416c/35/GPL/openjdk-21_linux-x64_bin.tar.gz
--url=https://download.java.net/java/GA/jdk22.0.1/c7ec1332f7bb44aeba2eb341ae18aca4/8/GPL/openjdk-22.0.1_linux-x64_bin.tar.gz
AdoptOpenJDK:
https://github.com/AdoptOpenJDK/
Expand Down
2 changes: 1 addition & 1 deletion templates/hazelcast5-sql-ec2-tstore/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
loadgenerator_hosts: &loadgenerator_hosts loadgenerators
node_hosts: &node_hosts nodes
driver: &driver hazelcast-enterprise5
version: &version maven=5.4.0-SNAPSHOT
version: &version maven=5.4.0
client_args: &client_args >
-Xms10G
-Xmx10G
Expand Down
2 changes: 1 addition & 1 deletion templates/hazelcast5-sql-prunability-ec2/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
node_hosts: &node_hosts nodes
driver: &driver hazelcast5
version: &version maven=5.3.2
# version: &version maven=5.4.0-SNAPSHOT # Tested functionality works since version 5.4
# version: &version maven=5.4.0 # Tested functionality works since version 5.4
client_args: &client_args >
-Xms8G
-Xmx8G
Expand Down

0 comments on commit aee8f32

Please sign in to comment.