Search in sources :

Example 11 with ContainerPlacementStatusDefault

use of org.apache.hadoop.hdds.scm.container.placement.algorithms.ContainerPlacementStatusDefault in project ozone by apache.

the class TestContainerHealthStatus method setup.

@Before
public void setup() {
    placementPolicy = mock(PlacementPolicy.class);
    container = mock(ContainerInfo.class);
    when(container.getReplicationConfig()).thenReturn(RatisReplicationConfig.getInstance(HddsProtos.ReplicationFactor.THREE));
    when(container.containerID()).thenReturn(ContainerID.valueOf(123456));
    when(container.getContainerID()).thenReturn((long) 123456);
    when(placementPolicy.validateContainerPlacement(Mockito.anyList(), Mockito.anyInt())).thenReturn(new ContainerPlacementStatusDefault(1, 1, 1));
}
Also used : PlacementPolicy(org.apache.hadoop.hdds.scm.PlacementPolicy) ContainerInfo(org.apache.hadoop.hdds.scm.container.ContainerInfo) ContainerPlacementStatusDefault(org.apache.hadoop.hdds.scm.container.placement.algorithms.ContainerPlacementStatusDefault) Before(org.junit.Before)

Example 12 with ContainerPlacementStatusDefault

use of org.apache.hadoop.hdds.scm.container.placement.algorithms.ContainerPlacementStatusDefault in project ozone by apache.

the class TestContainerHealthStatus method testMisReplicated.

@Test
public void testMisReplicated() {
    Set<ContainerReplica> replicas = generateReplicas(container, ContainerReplicaProto.State.CLOSED, ContainerReplicaProto.State.CLOSED, ContainerReplicaProto.State.CLOSED);
    when(placementPolicy.validateContainerPlacement(Mockito.anyList(), Mockito.anyInt())).thenReturn(new ContainerPlacementStatusDefault(1, 2, 5));
    ContainerHealthStatus status = new ContainerHealthStatus(container, replicas, placementPolicy);
    assertFalse(status.isHealthy());
    assertFalse(status.isMissing());
    assertFalse(status.isUnderReplicated());
    assertFalse(status.isOverReplicated());
    assertEquals(0, status.replicaDelta());
    assertTrue(status.isMisReplicated());
    assertEquals(1, status.misReplicatedDelta());
}
Also used : ContainerReplica(org.apache.hadoop.hdds.scm.container.ContainerReplica) ContainerPlacementStatusDefault(org.apache.hadoop.hdds.scm.container.placement.algorithms.ContainerPlacementStatusDefault) Test(org.junit.Test)

Aggregations

ContainerPlacementStatusDefault (org.apache.hadoop.hdds.scm.container.placement.algorithms.ContainerPlacementStatusDefault)12 Test (org.junit.Test)9 PlacementPolicy (org.apache.hadoop.hdds.scm.PlacementPolicy)7 Before (org.junit.Before)7 Longs (com.google.common.primitives.Longs)5 File (java.io.File)5 IOException (java.io.IOException)5 Instant (java.time.Instant)5 ZoneId (java.time.ZoneId)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Map (java.util.Map)5 Optional (java.util.Optional)5 Set (java.util.Set)5 UUID (java.util.UUID)5 CompletableFuture (java.util.concurrent.CompletableFuture)5 ExecutionException (java.util.concurrent.ExecutionException)5 TimeUnit (java.util.concurrent.TimeUnit)5 TimeoutException (java.util.concurrent.TimeoutException)5