-
-
Save ahmetmircik/ad727c8ae6158a7a4be3e7fae933467e to your computer and use it in GitHub Desktop.
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
/* | |
* 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.map; | |
import com.hazelcast.core.HazelcastInstance; | |
import com.hazelcast.core.IMap; | |
import com.hazelcast.test.HazelcastSerialClassRunner; | |
import com.hazelcast.test.HazelcastTestSupport; | |
import com.hazelcast.test.TestHazelcastInstanceFactory; | |
import com.hazelcast.test.annotation.ParallelTest; | |
import com.hazelcast.test.annotation.QuickTest; | |
import org.junit.Test; | |
import org.junit.experimental.categories.Category; | |
import org.junit.runner.RunWith; | |
import java.util.HashMap; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
import static org.junit.Assert.assertEquals; | |
@RunWith(HazelcastSerialClassRunner.class) | |
@Category({QuickTest.class, ParallelTest.class}) | |
public class TestPutAll extends HazelcastTestSupport { | |
@Test | |
public void name() throws Exception { | |
System.setProperty("hazelcast.map.put.all.batch.size", "2"); | |
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(); | |
HazelcastInstance node1 = factory.newHazelcastInstance(); | |
IMap map = node1.getMap("test"); | |
final AtomicBoolean done = new AtomicBoolean(false); | |
Thread bouncingThread = new Thread() { | |
public void run() { | |
while (!done.get()) { | |
HazelcastInstance hz = factory.newHazelcastInstance(); | |
sleepSeconds(5); | |
factory.terminate(hz); | |
} | |
} | |
}; | |
bouncingThread.start(); | |
HashMap batch = new HashMap(); | |
for (int i = 0; i < 1000; i++) { | |
batch.put(i, i); | |
} | |
try { | |
for (int j = 0; j < 10000; j += 1) { | |
map.clear(); | |
map.putAll(batch); | |
sleepMillis(3); | |
} | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
done.set(true); | |
bouncingThread.join(); | |
assertEquals(1000, map.size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment