-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IGNITE-13508: Test scenario of two-phased rebalance #8385
Changes from 14 commits
08c0c1a
600c0ba
ecf4b1d
9a642b2
7257a29
df0aef6
233943f
5eb455b
46ce2eb
3a9ef2b
bb49d93
40d61a5
33562ed
0290e1c
2d2b88e
1f396d2
987caba
c617c3a
6234090
78df8d1
ca3976e
0dd8561
31de1d4
d7788a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* 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.ignite.internal.ducktest.tests; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.TreeSet; | ||
import java.util.concurrent.TimeUnit; | ||
import javax.cache.Cache; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import org.apache.ignite.IgniteCache; | ||
import org.apache.ignite.internal.ducktest.utils.IgniteAwareApplication; | ||
import org.apache.ignite.lang.IgniteFuture; | ||
|
||
/** | ||
* Deleting data from the cache. | ||
*/ | ||
public class DeleteDataApplication extends IgniteAwareApplication { | ||
/** {@inheritDoc} */ | ||
@Override public void run(JsonNode jNode) { | ||
String cacheName = jNode.get("cacheName").asText(); | ||
|
||
int size = jNode.get("size").asInt(); | ||
|
||
int batchSize = Optional.ofNullable(jNode.get("batchSize")) | ||
.map(JsonNode::asInt) | ||
.orElse(1000); | ||
|
||
IgniteCache<Object, Object> cache = ignite.getOrCreateCache(cacheName); | ||
|
||
log.info("Cache size before: " + cache.size()); | ||
|
||
markInitialized(); | ||
|
||
long start = System.currentTimeMillis(); | ||
|
||
Iterator<Cache.Entry<Object, Object>> iter = cache.iterator(); | ||
|
||
ArrayList<Object> keys = new ArrayList<>(size); | ||
|
||
for (int cnt = 0; iter.hasNext() && cnt < size; cnt++) | ||
keys.add(iter.next().getKey()); | ||
|
||
log.info("Start removing: " + keys.size()); | ||
|
||
int listSize = keys.size(); | ||
|
||
List<IgniteFuture<Void>> futures = new LinkedList<>(); | ||
|
||
for (int from = 0; from < listSize; from += batchSize) { | ||
int to = Math.min(from + batchSize, listSize); | ||
|
||
futures.add(cache.removeAllAsync(new TreeSet<>(keys.subList(from, to)))); | ||
} | ||
|
||
futures.forEach(f -> f.get(TimeUnit.MINUTES.toMillis(5))); | ||
|
||
log.info("Cache size after: " + cache.size()); | ||
|
||
recordResult("DURATION_SECONDS", TimeUnit.MILLISECONDS.toSeconds( System.currentTimeMillis() - start)); | ||
|
||
markFinished(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,17 +15,43 @@ | |
limitations under the License. | ||
#} | ||
|
||
|
||
{% macro rendezvous_backup_filter(affinity) %} | ||
<bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction"> | ||
<property name="affinityBackupFilter"> | ||
<bean class="org.apache.ignite.internal.ducktest.tests.cellular_affinity_test.CellularAffinityBackupFilter"> | ||
<constructor-arg value="{{ affinity.attr_name }}"/> | ||
</bean> | ||
</property> | ||
</bean> | ||
{% endmacro %} | ||
|
||
{% macro cache_configs(caches) %} | ||
{% if caches %} | ||
<property name="cacheConfiguration"> | ||
<list> | ||
{% for cache in caches %} | ||
<bean class="org.apache.ignite.configuration.CacheConfiguration"> | ||
<property name="name" value="{{ cache.name }}"/> | ||
{% if cache.cache_mode == 'PARTITIONED' %} | ||
<property name="backups" value="{{ cache.backups or 0 }}"/> | ||
<property name="backups" value="{{ cache.backups }}"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 0 is default |
||
<property name="cacheMode" value="{{ cache.cache_mode }}"/> | ||
<property name="atomicityMode" value="{{ cache.atomicity_mode }}"/> | ||
|
||
{% if cache.indexed_types %} | ||
<property name="indexedTypes"> | ||
<list> | ||
{% for class in cache.indexed_types %} | ||
<value>{{ class }}</value> | ||
{% endfor %} | ||
</list> | ||
</property> | ||
{% endif %} | ||
|
||
{% if cache.affinity and cache.affinity.name == 'BACKUP_FILTER' %} | ||
<property name="affinity"> | ||
{{ rendezvous_backup_filter(cache.affinity) }} | ||
</property> | ||
{% endif %} | ||
<property name="atomicityMode" value="{{ cache.atomicity_mode or 'ATOMIC' }}"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'ATOMIC' is default |
||
</bean> | ||
{% endfor %} | ||
</list> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 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. | ||
|
||
""" | ||
This module contains utility methods. | ||
""" | ||
import os | ||
|
||
|
||
def copy_file_to_dest(node, file_path: str, dest_dir: str): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You used this method only once, so there is no need to create a separate module for this method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it will be useful in the future when we need to save some data for the result. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will do it after the future comes. No need for a new module right now. |
||
""" | ||
Copy file to destination directory. | ||
:return new path to file. | ||
""" | ||
node.account.ssh_output(f'cp {file_path} {dest_dir}') | ||
|
||
file_name = os.path.basename(file_path) | ||
|
||
return os.path.join(dest_dir, file_name) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,6 @@ discovery: | |
|
||
snapshot: | ||
- ../snapshot_test.py | ||
|
||
two_phased_rebalance: | ||
- ../two_phased_rebalanced_test.py.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unuseful var. There is already rebalanced var declared on the 475 line. If
self.nodes
is empty then code raises TimeoutError, but it is actually wrong. Please replace it with logic that shold handle empty nodes list if it is required.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an announcement of a variable in order to expand the zone of its visibility.
added
assert self.nodes, 'Node list is empty.'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed