/// <summary> /// Wait until heartbeat gives expected results, within CAPACITY_ALLOWED_VARIANCE, /// summed over all nodes. /// </summary> /// <remarks> /// Wait until heartbeat gives expected results, within CAPACITY_ALLOWED_VARIANCE, /// summed over all nodes. Times out after TIMEOUT msec. /// </remarks> /// <param name="expectedUsedSpace"/> /// <param name="expectedTotalSpace"/> /// <exception cref="System.IO.IOException">- if getStats() fails</exception> /// <exception cref="Sharpen.TimeoutException"/> private void WaitForHeartBeat(long expectedUsedSpace, long expectedTotalSpace) { long timeout = Timeout; long failtime = (timeout <= 0L) ? long.MaxValue : Runtime.CurrentTimeMillis() + timeout; while (true) { long[] status = client.GetStats(); double totalSpaceVariance = Math.Abs((double)status[0] - expectedTotalSpace) / expectedTotalSpace; double usedSpaceVariance = Math.Abs((double)status[1] - expectedUsedSpace) / expectedUsedSpace; if (totalSpaceVariance < CapacityAllowedVariance && usedSpaceVariance < CapacityAllowedVariance) { break; } //done if (Runtime.CurrentTimeMillis() > failtime) { throw new TimeoutException("Cluster failed to reached expected values of " + "totalSpace (current: " + status[0] + ", expected: " + expectedTotalSpace + "), or usedSpace (current: " + status[1] + ", expected: " + expectedUsedSpace + "), in more than " + timeout + " msec."); } try { Sharpen.Thread.Sleep(100L); } catch (Exception) { } } }