Uploaded image for project: 'Hadoop YARN'
  1. Hadoop YARN
  2. YARN-2030

Use StateMachine to simplify handleStoreEvent() in RMStateStore

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.0
    • Component/s: None
    • Labels:
      None
    • Target Version/s:
    • Hadoop Flags:
      Reviewed

      Description

      Now the logic to handle different store events in handleStoreEvent() is as following:

      if (event.getType().equals(RMStateStoreEventType.STORE_APP)
              || event.getType().equals(RMStateStoreEventType.UPDATE_APP)) {
            ...
            if (event.getType().equals(RMStateStoreEventType.STORE_APP)) {
              ...
            } else {
              ...
            }
            ...
            try {
              if (event.getType().equals(RMStateStoreEventType.STORE_APP)) {
                ...
              } else {
                ...
              }
            } 
            ...
          } else if (event.getType().equals(RMStateStoreEventType.STORE_APP_ATTEMPT)
              || event.getType().equals(RMStateStoreEventType.UPDATE_APP_ATTEMPT)) {
            ...
            if (event.getType().equals(RMStateStoreEventType.STORE_APP_ATTEMPT)) {
              ...
            } else {
              ...
            }
              ...
              if (event.getType().equals(RMStateStoreEventType.STORE_APP_ATTEMPT)) {
                ...
              } else {
                ...
              }
            }
            ...
          } else if (event.getType().equals(RMStateStoreEventType.REMOVE_APP)) {
          ...
          } else {
            ...
          }
      }
      

      This is not only confuse people but also led to mistake easily. We may leverage state machine to simply this even no state transitions.

        Attachments

        1. YARN-2030.v1.patch
          18 kB
          Binglin Chang
        2. YARN-2030.v2.patch
          19 kB
          Binglin Chang
        3. YARN-2030.v3.patch
          33 kB
          Binglin Chang
        4. YARN-2030.v4.patch
          52 kB
          Binglin Chang
        5. YARN-2030.v5.patch
          54 kB
          Binglin Chang
        6. YARN-2030.v6.patch
          54 kB
          Jian He

          Activity

            People

            • Assignee:
              decster Binglin Chang
              Reporter:
              djp Junping Du
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: