Return-Path: X-Original-To: apmail-hadoop-yarn-issues-archive@minotaur.apache.org Delivered-To: apmail-hadoop-yarn-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4638D10E09 for ; Fri, 16 May 2014 13:52:00 +0000 (UTC) Received: (qmail 22857 invoked by uid 500); 16 May 2014 11:53:20 -0000 Delivered-To: apmail-hadoop-yarn-issues-archive@hadoop.apache.org Received: (qmail 40021 invoked by uid 500); 16 May 2014 11:44:57 -0000 Mailing-List: contact yarn-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: yarn-issues@hadoop.apache.org Delivered-To: mailing list yarn-issues@hadoop.apache.org Received: (qmail 10333 invoked by uid 99); 16 May 2014 11:23:53 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2014 11:23:53 +0000 Date: Fri, 16 May 2014 11:23:53 +0000 (UTC) From: "Tsuyoshi OZAWA (JIRA)" To: yarn-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (YARN-2030) Use StateMachine to simplify handleStoreEvent() in RMStateStore MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/YARN-2030?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13998635#comment-13998635 ] Tsuyoshi OZAWA commented on YARN-2030: -------------------------------------- +1 for this idea too. Using state machine makes the code cleaner and simpler. > 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 > > 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)