[ 
https://issues.apache.org/jira/browse/YARN-2030?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Binglin Chang updated YARN-2030:
--------------------------------

    Attachment: YARN-2030.v3.patch

Thanks for the comments [~djp] and [~jianhe]. I update the patch to make 
ApplicationAttempStateData and ApplicationStateData abstract classes. 
bq. Accordingly storeApplicationStateInternal can take in ApplicationStateData 
instead of ApplicationStateDataPBImpl as the argument to avoid the type cast.
I try to change updateApplicationAttemptStateInternal paramter type from PBImpl 
to abstract records, but looks like some RMStateStore(FileSystemRMStateStore 
and ZKRMStateStore) require the parameter to be PBImpl(so they can use toProto 
to serialize)

> Use StateMachine to simplify handleStoreEvent() in RMStateStore
> ---------------------------------------------------------------
>
>                 Key: YARN-2030
>                 URL: https://issues.apache.org/jira/browse/YARN-2030
>             Project: Hadoop YARN
>          Issue Type: Improvement
>            Reporter: Junping Du
>            Assignee: Binglin Chang
>         Attachments: YARN-2030.v1.patch, YARN-2030.v2.patch, 
> YARN-2030.v3.patch
>
>
> Now the logic to handle different store events in handleStoreEvent() is as 
> following:
> {code}
> 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 {
>       ...
>     }
> }
> {code}
> This is not only confuse people but also led to mistake easily. We may 
> leverage state machine to simply this even no state transitions.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to