hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
/**
   * Compacts the mob files in the current table.
   * @param request the request.
   * @param tableName the current table name.
   * @return The response of the mob file compaction.
   * @throws IOException
   */
Compacts the mob files in the current table.
@param request the request.
@param tableName the current table name.
@return The response of the mob file compaction.
Compacts the mob files in the current table . @param request the request . @param tableName the current table name . @return The response of the mob file compaction .
private CompactRegionResponse compactMob(final CompactRegionRequest request,
    TableName tableName) throws IOException {
    if (!master.getTableStateManager().isTableState(tableName, TableState.State.ENABLED)) {
      throw new DoNotRetryIOException("Table " + tableName + " is not enabled");
    }
    boolean allFiles = false;
    List<ColumnFamilyDescriptor> compactedColumns = new ArrayList<>();
    ColumnFamilyDescriptor[] hcds = master.getTableDescriptors().get(tableName).getColumnFamilies();
    byte[] family = null;
    if (request.hasFamily()) {
      family = request.getFamily().toByteArray();
      for (ColumnFamilyDescriptor hcd : hcds) {
        if (Bytes.equals(family, hcd.getName())) {
          if (!hcd.isMobEnabled()) {
            LOG.error("Column family " + hcd.getNameAsString() + " is not a mob column family");
            throw new DoNotRetryIOException("Column family " + hcd.getNameAsString()
                    + " is not a mob column family");
          }
          compactedColumns.add(hcd);
        }
      }
    } else {
      for (ColumnFamilyDescriptor hcd : hcds) {
        if (hcd.isMobEnabled()) {
          compactedColumns.add(hcd);
        }
      }
    }
    if (compactedColumns.isEmpty()) {
      LOG.error("No mob column families are assigned in the mob compaction");
      throw new DoNotRetryIOException(
              "No mob column families are assigned in the mob compaction");
    }
    if (request.hasMajor() && request.getMajor()) {
      allFiles = true;
    }
    String familyLogMsg = (family != null) ? Bytes.toString(family) : "";
    if (LOG.isTraceEnabled()) {
      LOG.trace("User-triggered mob compaction requested for table: "
              + tableName.getNameAsString() + " for column family: " + familyLogMsg);
    }
    master.requestMobCompaction(tableName, compactedColumns, allFiles);
    return CompactRegionResponse.newBuilder().build();
  }
private CompactRegionResponse compactMob ( final CompactRegionRequest request , TableName tableName ) throws IOException { if ( ! master . getTableStateManager ( ) . isTableState ( tableName , TableState . State . ENABLED ) ) { throw new DoNotRetryIOException ( "Table " + tableName + " is not enabled" ) ; } boolean allFiles = false ; List < ColumnFamilyDescriptor > compactedColumns = new ArrayList < > ( ) ; ColumnFamilyDescriptor [ ] hcds = master . getTableDescriptors ( ) . get ( tableName ) . getColumnFamilies ( ) ; byte [ ] family = null ; if ( request . hasFamily ( ) ) { family = request . getFamily ( ) . toByteArray ( ) ; for ( ColumnFamilyDescriptor hcd : hcds ) { if ( Bytes . equals ( family , hcd . getName ( ) ) ) { if ( ! hcd . isMobEnabled ( ) ) { LOG . error ( "Column family " + hcd . getNameAsString ( ) + " is not a mob column family" ) ; throw new DoNotRetryIOException ( "Column family " + hcd . getNameAsString ( ) + " is not a mob column family" ) ; } compactedColumns . add ( hcd ) ; } } } else { for ( ColumnFamilyDescriptor hcd : hcds ) { if ( hcd . isMobEnabled ( ) ) { compactedColumns . add ( hcd ) ; } } } if ( compactedColumns . isEmpty ( ) ) { LOG . error ( "No mob column families are assigned in the mob compaction" ) ; throw new DoNotRetryIOException ( "No mob column families are assigned in the mob compaction" ) ; } if ( request . hasMajor ( ) && request . getMajor ( ) ) { allFiles = true ; } String familyLogMsg = ( family != null ) ? Bytes . toString ( family ) : "" ; if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "User-triggered mob compaction requested for table: " + tableName . getNameAsString ( ) + " for column family: " + familyLogMsg ) ; } master . requestMobCompaction ( tableName , compactedColumns , allFiles ) ; return CompactRegionResponse . newBuilder ( ) . build ( ) ; }
Compacts the mob files in the current table.
Compacts the mob files in the current table .