Ejemplo n.º 1
0
 private void moveBricksToUnknown(final VDS vds) {
   List<GlusterBrickEntity> brickEntities =
       DbFacade.getInstance().getGlusterBrickDao().getGlusterVolumeBricksByServerId(vds.getId());
   for (GlusterBrickEntity brick : brickEntities) {
     if (brick.getStatus() == GlusterStatus.UP) {
       brick.setStatus(GlusterStatus.UNKNOWN);
     }
   }
   DbFacade.getInstance().getGlusterBrickDao().updateBrickStatuses(brickEntities);
 }
 private List<GlusterBrickEntity> getBricks(Guid volumeId, int max) {
   List<GlusterBrickEntity> bricks = new ArrayList<>();
   for (Integer i = 0; i < max; i++) {
     GlusterBrickEntity brick1 = new GlusterBrickEntity();
     brick1.setVolumeId(volumeId);
     brick1.setServerName("server1");
     brick1.setStatus(GlusterStatus.UP);
     brick1.setBrickDirectory("/tmp/s" + i.toString());
     bricks.add(brick1);
   }
   return bricks;
 }
Ejemplo n.º 3
0
  private GlusterVolumeEntity getNewVolume() {
    GlusterVolumeEntity volume = new GlusterVolumeEntity();
    volume.setName(NEW_VOL_NAME);
    volume.setClusterId(CLUSTER_ID);
    volume.setId(NEW_VOL_ID);
    volume.setVolumeType(GlusterVolumeType.DISTRIBUTE);
    volume.addTransportType(TransportType.TCP);
    volume.setReplicaCount(0);
    volume.setStripeCount(0);
    volume.setStatus(GlusterStatus.UP);
    volume.setOption("auth.allow", "*");
    volume.addAccessProtocol(AccessProtocol.GLUSTER);
    volume.addAccessProtocol(AccessProtocol.NFS);

    GlusterBrickEntity brick = new GlusterBrickEntity();
    brick.setVolumeId(NEW_VOL_ID);
    brick.setServerId(existingServer1.getId());
    brick.setServerName(existingServer1.getHostName());
    brick.setBrickDirectory("/export/testvol1");
    brick.setStatus(GlusterStatus.UP);
    brick.setBrickOrder(0);
    volume.addBrick(brick);

    return volume;
  }
Ejemplo n.º 4
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;
  }
Ejemplo n.º 5
0
 private GlusterBrickEntity createBrick(Guid existingVolDistId, VDS server, String brickDir) {
   GlusterBrickEntity brick = new GlusterBrickEntity();
   brick.setVolumeId(existingVolDistId);
   brick.setServerId(server.getId());
   brick.setServerName(server.getHostName());
   brick.setBrickDirectory(brickDir);
   brick.setStatus(GlusterStatus.UP);
   return brick;
 }
Ejemplo n.º 6
0
 private void stopGlusterServices(VDS vds) {
   if (vds.getVdsGroupSupportsGlusterService()) {
     // Stop glusterd service first
     boolean succeeded =
         resourceManagerProvider
             .get()
             .runVdsCommand(
                 VDSCommandType.ManageGlusterService,
                 new GlusterServiceVDSParameters(vds.getId(), Arrays.asList("glusterd"), "stop"))
             .getSucceeded();
     if (succeeded) {
       // Stop other gluster related processes on the node
       succeeded =
           resourceManagerProvider
               .get()
               .runVdsCommand(
                   VDSCommandType.StopGlusterProcesses,
                   new VdsIdVDSCommandParametersBase(vds.getId()))
               .getSucceeded();
       // Mark the bricks as DOWN on this node
       if (succeeded) {
         List<GlusterBrickEntity> bricks =
             glusterBrickDao.getGlusterVolumeBricksByServerId(vds.getId());
         for (GlusterBrickEntity brick : bricks) {
           brick.setStatus(GlusterStatus.DOWN);
         }
         glusterBrickDao.updateBrickStatuses(bricks);
       }
     }
     if (!succeeded) {
       log.error(
           "Failed to stop gluster services while moving the host '{}' to maintenance",
           vds.getName());
     }
   }
 }
 @Override
 public List<Statistic> getStatistics(GlusterBrickEntity entity) {
   BrickDetails brickDetails = entity.getBrickDetails();
   MallInfo mallInfo = brickDetails.getMemoryStatus().getMallInfo();
   return asList(
       setDatum(clone(MEM_TOTAL_SIZE), brickDetails.getBrickProperties().getTotalSize() * Mb),
       setDatum(clone(MEM_FREE_SIZE), brickDetails.getBrickProperties().getFreeSize() * Mb),
       setDatum(clone(MEM_BLOCK_SIZE), brickDetails.getBrickProperties().getBlockSize() * Mb),
       setDatum(clone(MEM_MALL_ARENA), mallInfo.getArena()),
       setDatum(clone(MEM_MALL_ORDBLKS), mallInfo.getOrdblks()),
       setDatum(clone(MEM_MALL_SMBLKS), mallInfo.getSmblks()),
       setDatum(clone(MEM_MALL_HBLKS), mallInfo.getHblks()),
       setDatum(clone(MEM_MALL_HBLKSHD), mallInfo.getHblkhd()),
       setDatum(clone(MEM_MALL_USMBLKS), mallInfo.getUsmblks()),
       setDatum(clone(MEM_MALL_FSMBLKS), mallInfo.getFsmblks()),
       setDatum(clone(MEM_MALL_UORDBLKS), mallInfo.getUordblks()),
       setDatum(clone(MEM_MALL_FORDBLKS), mallInfo.getFordblks()),
       setDatum(clone(MEM_MALL_KEEPCOST), mallInfo.getKeepcost()));
 }
 private List<GlusterBrickEntity> getBricks(Guid volumeId, String dirPrefix, int n) {
   List<GlusterBrickEntity> bricks = new ArrayList<>();
   GlusterBrickEntity brick;
   for (Integer i = 0; i < n; i++) {
     brick = new GlusterBrickEntity();
     brick.setVolumeId(volumeId);
     brick.setServerId(serverId);
     brick.setServerName(serverName);
     brick.setBrickDirectory("/tmp/" + dirPrefix + i.toString());
     brick.setStatus(GlusterStatus.UP);
     bricks.add(brick);
   }
   return bricks;
 }
Ejemplo n.º 9
0
 private void replaceBrick(GlusterBrickEntity brick, Guid newServerId, String newBrickDir) {
   brick.setId(Guid.newGuid());
   brick.setServerId(newServerId);
   brick.setBrickDirectory(newBrickDir);
   addedBrickIds.add(brick.getId());
 }