public WorkerInfo generateWorkerInfo(Set<WorkerInfoField> fieldRange, boolean isLiveWorker) {
    WorkerInfo info = new WorkerInfo();
    Set<WorkerInfoField> checkedFieldRange = fieldRange != null ? fieldRange :
        new HashSet<>(Arrays.asList(WorkerInfoField.values()));
    for (WorkerInfoField field : checkedFieldRange) {
      switch (field) {
        case ADDRESS:
          info.setAddress(mWorkerAddress);
          break;
        case WORKER_CAPACITY_BYTES:
          info.setCapacityBytes(mCapacityBytes);
          break;
        case WORKER_CAPACITY_BYTES_ON_TIERS:
          info.setCapacityBytesOnTiers(mTotalBytesOnTiers);
          break;
        case ID:
          info.setId(mId);
          break;
        case LAST_CONTACT_SEC:
          info.setLastContactSec(
              (int) ((CommonUtils.getCurrentMs() - mLastUpdatedTimeMs) / Constants.SECOND_MS));
          break;
        case START_TIME_MS:
          info.setStartTimeMs(mStartTimeMs);
          break;
        case STATE:
          if (isLiveWorker) {
            info.setState(LIVE_WORKER_STATE);
          } else {
            info.setState(LOST_WORKER_STATE);
          }
          break;
        case WORKER_USED_BYTES:
          info.setUsedBytes(mUsedBytes);
          break;
        case WORKER_USED_BYTES_ON_TIERS:
          info.setUsedBytesOnTiers(mUsedBytesOnTiers);
          break;
        default:
          LOG.warn("Unrecognized worker info field: " + field);
      }
    }
    return info;
  }
public WorkerInfo generateWorkerInfo ( Set < WorkerInfoField > fieldRange , boolean isLiveWorker ) { WorkerInfo info = new WorkerInfo ( ) ; Set < WorkerInfoField > checkedFieldRange = fieldRange != null ? fieldRange : new HashSet < > ( Arrays . asList ( WorkerInfoField . values ( ) ) ) ; for ( WorkerInfoField field : checkedFieldRange ) { switch ( field ) { case ADDRESS : info . setAddress ( mWorkerAddress ) ; break ; case WORKER_CAPACITY_BYTES : info . setCapacityBytes ( mCapacityBytes ) ; break ; case WORKER_CAPACITY_BYTES_ON_TIERS : info . setCapacityBytesOnTiers ( mTotalBytesOnTiers ) ; break ; case ID : info . setId ( mId ) ; break ; case LAST_CONTACT_SEC : info . setLastContactSec ( ( int ) ( ( CommonUtils . getCurrentMs ( ) - mLastUpdatedTimeMs ) / Constants . SECOND_MS ) ) ; break ; case START_TIME_MS : info . setStartTimeMs ( mStartTimeMs ) ; break ; case STATE : if ( isLiveWorker ) { info . setState ( LIVE_WORKER_STATE ) ; } else { info . setState ( LOST_WORKER_STATE ) ; } break ; case WORKER_USED_BYTES : info . setUsedBytes ( mUsedBytes ) ; break ; case WORKER_USED_BYTES_ON_TIERS : info . setUsedBytesOnTiers ( mUsedBytesOnTiers ) ; break ; default : LOG . warn ( "Unrecognized worker info field: " + field ) ; } } return info ; }
Gets the selected field information for this worker.

@param fieldRange the client selected fields
@param isLiveWorker the worker is live or not
@return generated worker information