Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
SharplEr committed Apr 28, 2018
1 parent 52460c2 commit 605b070
Showing 1 changed file with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ public void testRebalanceEstimateFinishTime() throws Exception {

final int KEYS = 4_000_000;

IgniteCache<Object, Object> cache1 = ig1.cache(CACHE1);

try (IgniteDataStreamer<Integer, String> st = ig1.dataStreamer(CACHE1)) {
for (int i = 0; i < KEYS; i++)
st.addData(i, CACHE1 + "-" + i);
Expand Down Expand Up @@ -211,10 +209,10 @@ public void testRebalanceEstimateFinishTime() throws Exception {
CacheMetrics metrics = ig2.cache(CACHE1).localMetrics();

long startTime = metrics.getRebalancingStartTime();
long currentTime = System.currentTimeMillis();
long currTime = U.currentTimeMillis();

assertTrue("Invalid start time: " + startTime + ", but the current time: " + currentTime + '.',
startTime > 0L && (currentTime - startTime) >= 0L && (currentTime - startTime) <= 5000L);
assertTrue("Invalid start time: " + startTime + ", but the current time: " + currTime + '.',
startTime > 0L && (currTime - startTime) >= 0L && (currTime - startTime) <= 5000L);

final CountDownLatch latch = new CountDownLatch(1);

Expand All @@ -223,12 +221,12 @@ public void testRebalanceEstimateFinishTime() throws Exception {
// Waiting 25% keys will be rebalanced.
int partKeys = KEYS / 2;

final long keysLine = partKeys - partKeys / 4;
final long keysLine = partKeys * 3L / 4L;

log.info("Wait until keys left will be less than: " + keysLine + '.');

try {
while (finishRebalanceLatch.getCount() != 0L) {
while (finishRebalanceLatch.getCount() != 0) {
CacheMetrics m = ig2.cache(CACHE1).localMetrics();

long keyLeft = m.getKeysToRebalanceLeft();
Expand All @@ -242,7 +240,7 @@ public void testRebalanceEstimateFinishTime() throws Exception {
Thread.sleep(1_000L);
}
catch (InterruptedException e) {
log.warning("Interrupt thread.", e);
log.warning("Interrupt thread.", e);

Thread.currentThread().interrupt();
}
Expand All @@ -254,8 +252,7 @@ public void testRebalanceEstimateFinishTime() throws Exception {
}
});

assertTrue("Got timeout while waiting 25% keys will be rebalanced.",
latch.await(getTestTimeout(), TimeUnit.MILLISECONDS));
assertTrue(latch.await(getTestTimeout(), TimeUnit.MILLISECONDS));

waitForCondition(new PA() {
@Override public boolean apply() {
Expand All @@ -268,11 +265,11 @@ public void testRebalanceEstimateFinishTime() throws Exception {
assertTrue("Not a positive estimation of rebalancing finish time: " + finishTime + '.',
finishTime > 0L);

currentTime = System.currentTimeMillis();
long timePassed = currentTime - startTime;
long timeLeft = finishTime - currentTime;
currTime = U.currentTimeMillis();
long timePassed = currTime - startTime;
long timeLeft = finishTime - currTime;

assertTrue("Got timeout while waiting to rebalance. Estimated left time: " + timeLeft + '.',
assertTrue("Got timeout while waiting for rebalancing. Estimated left time: " + timeLeft + '.',
finishRebalanceLatch.await(timeLeft + 2_000L, TimeUnit.MILLISECONDS));

log.info(
Expand All @@ -285,13 +282,13 @@ public void testRebalanceEstimateFinishTime() throws Exception {

System.clearProperty(IGNITE_REBALANCE_STATISTICS_TIME_INTERVAL);

currentTime = System.currentTimeMillis();
currTime = U.currentTimeMillis();

log.info("Rebalance time: " + (currentTime - startTime) + '.');
log.info("Rebalance time: " + (currTime - startTime) + '.');

long diff = finishTime - currentTime;
long diff = finishTime - currTime;

assertTrue("Expected less than 5000, but actual: " + diff + '.', Math.abs(diff) < 10_000L);
assertTrue("Expected less than 10000, but actual: " + diff + '.', Math.abs(diff) < 10_000L);
}

/**
Expand Down

0 comments on commit 605b070

Please sign in to comment.