Ejemplo n.º 1
0
  private GlusterVolumeAdvancedDetails getVolumeAdvancedDetails(GlusterVolumeEntity volume) {
    GlusterVolumeAdvancedDetails volDetails = new GlusterVolumeAdvancedDetails();
    GlusterVolumeSizeInfo capacityInfo = new GlusterVolumeSizeInfo();
    capacityInfo.setVolumeId(volume.getId());
    capacityInfo.setTotalSize(600000L);
    capacityInfo.setFreeSize(200000L);
    capacityInfo.setUsedSize(400000L);
    volDetails.setCapacityInfo(capacityInfo);

    List<BrickDetails> brickDetailsList = new ArrayList<>();
    for (GlusterBrickEntity brick : volume.getBricks()) {
      BrickDetails brickDetails = new BrickDetails();
      BrickProperties properties = new BrickProperties();
      properties.setBrickId(brick.getId());
      brickDetails.setBrickProperties(properties);
      properties.setStatus(brick.getStatus());
      if (volume == existingReplVol) {
        if (brick.getServerId().equals(SERVER_ID_1)
            && (brick.getBrickDirectory().equals(REPL_BRICK_R1D1)
                || brick.getBrickDirectory().equals(REPL_BRICK_R2D1))) {
          properties.setStatus(GlusterStatus.DOWN);
          bricksWithChangedStatus.add(brick);
        }
      }
      brickDetailsList.add(brickDetails);
    }
    volDetails.setBrickDetails(brickDetailsList);

    return volDetails;
  }
 @Test
 public void testWithNoLists() {
   GlusterVolumeAdvancedDetails volDetailsEntity = new GlusterVolumeAdvancedDetails();
   volDetailsEntity.setBrickDetails(getBrickDetails(0, 0, 0));
   GlusterBrickAdvancedDetails model = GlusterBrickDetailMapper.map(volDetailsEntity, null);
   assertNotNull(model);
   assertNull(model.getGlusterClients());
   assertNull(model.getMntOptions());
 }
  @Test
  public void testWithMultipleClientLists() {
    GlusterVolumeAdvancedDetails volDetailsEntity = new GlusterVolumeAdvancedDetails();
    volDetailsEntity.setBrickDetails(getBrickDetails(2, 2, 2));

    GlusterBrickAdvancedDetails model = GlusterBrickDetailMapper.map(volDetailsEntity, null);
    assertEquals(model.getGlusterClients().getGlusterClients().size(), 2);
    assertEquals(
        model.getMntOptions(),
        volDetailsEntity.getBrickDetails().get(0).getBrickProperties().getMntOptions());
    assertEquals(
        model.getMemoryPools().getGlusterMemoryPools().size(),
        volDetailsEntity.getBrickDetails().get(0).getMemoryStatus().getMemPools().size());
  }
  @Test
  public void testWithNullChildObjects() {
    GlusterVolumeAdvancedDetails volDetailsEntity = new GlusterVolumeAdvancedDetails();
    volDetailsEntity.setBrickDetails(getBrickDetails(1, 0, 0));
    volDetailsEntity.getBrickDetails().get(0).setClients(null);
    volDetailsEntity.getBrickDetails().get(0).setMemoryStatus(null);

    GlusterBrickAdvancedDetails model = GlusterBrickDetailMapper.map(volDetailsEntity, null);
    assertNotNull(model);
    assertNull(model.getGlusterClients());
    assertEquals(
        model.getMntOptions(),
        volDetailsEntity.getBrickDetails().get(0).getBrickProperties().getMntOptions());
    assertNull(model.getMemoryPools());
  }
Ejemplo n.º 5
0
 @Override
 public void render(Context context, GlusterVolumeEntity object, SafeHtmlBuilder sb, String id) {
   GlusterVolumeAdvancedDetails advancedDetails = object.getAdvancedDetails();
   GlusterVolumeSizeInfo sizeInfo = null;
   if (advancedDetails != null) {
     sizeInfo = advancedDetails.getCapacityInfo();
     if (sizeInfo != null) {
       setFreeSize(sizeInfo.getFreeSize().doubleValue());
       setTotalSize(sizeInfo.getTotalSize().doubleValue());
       setUsedSize(sizeInfo.getUsedSize().doubleValue());
       setInUnit(SizeUnit.BYTES);
     }
   }
   super.render(
       context, advancedDetails == null ? null : sizeInfo == null ? null : sizeInfo, sb, id);
 }