You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@helix.apache.org by "Vinayak Borkar (JIRA)" <ji...@apache.org> on 2015/03/13 10:48:39 UTC

[jira] [Commented] (HELIX-561) Participant receive same transition twice

    [ https://issues.apache.org/jira/browse/HELIX-561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14360149#comment-14360149 ] 

Vinayak Borkar commented on HELIX-561:
--------------------------------------

This issue has been resolved. It turned out that I was adding a Controller listener to HelixManager and hence two listeners were processing Cluster Events. Closing this issue.

> Participant receive same transition twice
> -----------------------------------------
>
>                 Key: HELIX-561
>                 URL: https://issues.apache.org/jira/browse/HELIX-561
>             Project: Apache Helix
>          Issue Type: Bug
>            Reporter: Zhen Zhang
>            Assignee: Zhen Zhang
>
> Some user reports that when upgrade from 0.6.x to 0.7.1, participant receives OFFLINE->SLAVE transition twice for a partition.
> Can't reproduce it with the following test case:
> {noformat}
> package org.apache.helix;
> import java.util.Date;
> import org.apache.helix.api.StateTransitionHandlerFactory;
> import org.apache.helix.api.TransitionHandler;
> import org.apache.helix.api.id.PartitionId;
> import org.apache.helix.api.id.ResourceId;
> import org.apache.helix.api.id.StateModelDefId;
> import org.apache.helix.manager.zk.MockController;
> import org.apache.helix.model.Message;
> import org.apache.helix.participant.statemachine.Transition;
> import org.apache.helix.testutil.TestUtil;
> import org.apache.helix.testutil.ZkTestBase;
> import org.testng.annotations.Test;
> public class AppTest extends ZkTestBase {
>   @Test
>   public void test() throws Exception {
>     String clusterName = TestUtil.getTestName();
>     int n = 2;
>     System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis()));
>     TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port
>         "localhost", // participant name prefix
>         "TestDB", // resource name prefix
>         1, // resources
>         2, // partitions per resource
>         n, // number of nodes
>         2, // replicas
>         "MasterSlave", true); // do rebalance
>     MockController controller = new MockController(_zkaddr, clusterName, "controller");
>     controller.syncStart();
>     String id = "localhost_12918";
>     StateModelDefId masterSlave = StateModelDefId.from("MasterSlave");
>     HelixManager hManager =
>         HelixManagerFactory.getZKHelixManager(clusterName, id, InstanceType.PARTICIPANT, _zkaddr);
>     hManager.getStateMachineEngine().registerStateModelFactory(masterSlave,
>         new MasterSlaveStateModelFactory());
>     hManager.connect();
>     System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis()));
>   }
>   class MasterSlaveStateModelFactory extends StateTransitionHandlerFactory<MasterSlaveStateModel> {
>     public MasterSlaveStateModelFactory() {
>     }
>     @Override
>     public MasterSlaveStateModel createStateTransitionHandler(ResourceId resourceId,
>         PartitionId partitionId) {
>       return new MasterSlaveStateModel();
>     }
>   }
>   public class MasterSlaveStateModel extends TransitionHandler {
>     @Transition(to = "SLAVE", from = "OFFLINE")
>     public void onBecomeSlaveFromOffline(Message message, NotificationContext context)
>         throws Exception {
>       System.out.println(message.getPartitionName() + ": OFFLINE->SLAVE");
>     }
>     @Transition(to = "MASTER", from = "SLAVE")
>     public void onBecomeMasterFromSlave(Message message, NotificationContext context)
>         throws Exception {
>     }
>     @Transition(to = "SLAVE", from = "MASTER")
>     public void onBecomeSlaveFromMaster(Message message, NotificationContext context)
>         throws Exception {
>     }
>     @Transition(to = "OFFLINE", from = "SLAVE")
>     public void onBecomeOfflineFromSlave(Message message, NotificationContext context)
>         throws Exception {
>     }
>     @Transition(to = "DROPPED", from = "OFFLINE")
>     public void onBecomeDroppedFromOffline(Message message, NotificationContext context)
>         throws Exception {
>     }
>     @Transition(to = "OFFLINE", from = "ERROR")
>     public void onBecomeOfflineFromError(Message message, NotificationContext context)
>         throws Exception {
>     }
>   }
> }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)