コード例 #1
0
  /** @throws Exception If failed. */
  public void testRangeUpdate1() throws Exception {
    IgfsFileMap map = new IgfsFileMap();

    IgniteUuid affKey = IgniteUuid.randomUuid();

    for (int i = 0; i < 4; i++)
      map.addRange(new IgfsFileAffinityRange(i * 20 + 10, i * 20 + 19, affKey));

    // Middle, first, last.
    map.updateRangeStatus(new IgfsFileAffinityRange(30, 39, affKey), RANGE_STATUS_MOVING);
    map.updateRangeStatus(new IgfsFileAffinityRange(10, 19, affKey), RANGE_STATUS_MOVING);
    map.updateRangeStatus(new IgfsFileAffinityRange(70, 79, affKey), RANGE_STATUS_MOVING);

    List<IgfsFileAffinityRange> ranges = map.ranges();

    assertEquals(RANGE_STATUS_MOVING, ranges.get(0).status());
    assertEquals(RANGE_STATUS_MOVING, ranges.get(1).status());
    assertEquals(RANGE_STATUS_INITIAL, ranges.get(2).status());
    assertEquals(RANGE_STATUS_MOVING, ranges.get(3).status());

    // Middle, first, last.
    map.updateRangeStatus(new IgfsFileAffinityRange(30, 39, affKey), RANGE_STATUS_MOVED);
    map.updateRangeStatus(new IgfsFileAffinityRange(10, 19, affKey), RANGE_STATUS_MOVED);
    map.updateRangeStatus(new IgfsFileAffinityRange(70, 79, affKey), RANGE_STATUS_MOVED);

    ranges = map.ranges();

    assertEquals(RANGE_STATUS_MOVED, ranges.get(0).status());
    assertEquals(RANGE_STATUS_MOVED, ranges.get(1).status());
    assertEquals(RANGE_STATUS_INITIAL, ranges.get(2).status());
    assertEquals(RANGE_STATUS_MOVED, ranges.get(3).status());

    // Middle, first, last.
    map.deleteRange(new IgfsFileAffinityRange(30, 39, affKey));
    map.deleteRange(new IgfsFileAffinityRange(10, 19, affKey));
    map.deleteRange(new IgfsFileAffinityRange(70, 79, affKey));

    ranges = map.ranges();

    assertEquals(1, ranges.size());
    assertEquals(RANGE_STATUS_INITIAL, ranges.get(0).status());
    assertTrue(ranges.get(0).regionEqual(new IgfsFileAffinityRange(50, 59, affKey)));
  }
コード例 #2
0
  /** @throws Exception If failed. */
  public void testAddUpdateAdd() throws Exception {
    IgfsFileMap map = new IgfsFileMap();

    IgniteUuid affKey = IgniteUuid.randomUuid();

    map.addRange(new IgfsFileAffinityRange(0, 9, affKey));

    map.updateRangeStatus(new IgfsFileAffinityRange(0, 9, affKey), RANGE_STATUS_MOVING);

    map.addRange(new IgfsFileAffinityRange(10, 19, affKey));

    List<IgfsFileAffinityRange> ranges = map.ranges();

    assertEquals(2, ranges.size());

    assertEquals(RANGE_STATUS_MOVING, ranges.get(0).status());
    assertTrue(ranges.get(0).regionEqual(new IgfsFileAffinityRange(0, 9, affKey)));

    assertEquals(RANGE_STATUS_INITIAL, ranges.get(1).status());
    assertTrue(ranges.get(1).regionEqual(new IgfsFileAffinityRange(10, 19, affKey)));
  }