You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by "Vinayak Borkar (JIRA)" <ji...@apache.org> on 2014/12/16 06:58:13 UTC

[jira] [Comment Edited] (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=14247816#comment-14247816 ] 

Vinayak Borkar edited comment on HELIX-561 at 12/16/14 5:58 AM:
----------------------------------------------------------------

In your code I see:

{noformat}
    @Override
    public MasterSlaveStateModel createStateTransitionHandler(ResourceId resourceId,
        PartitionId partitionId) {
      return new MasterSlaveStateModel();
    }
{noformat}


The code I am implementing by extending StateTransitionHandlerFactory<TransitionHandler> implements a create method that has only one arg:

{noformat}
    @Override
    public TransitionHandler createStateTransitionHandler(PartitionId partitionId) {
        return new MasterSlaveStateModel(partitionId.stringify());
    }
{noformat}

I just verified that I am using 0.7.1. Are we using the same version?


was (Author: vinayakb):
In your code I see:

    @Override
    public MasterSlaveStateModel createStateTransitionHandler(ResourceId resourceId,
        PartitionId partitionId) {
      return new MasterSlaveStateModel();
    }


The code I am implementing by extending StateTransitionHandlerFactory<TransitionHandler> implements a create method that has only one arg:

    @Override
    public TransitionHandler createStateTransitionHandler(PartitionId partitionId) {
        return new MasterSlaveStateModel(partitionId.stringify());
    }

I just verified that I am using 0.7.1. Are we using the same version?

> 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)