is it possible to completely avoid this scenario in 0.7.1+ On Tue, Dec 16, 2014 at 10:19 AM, Zhen Zhang (JIRA) <[email protected]> wrote:
> > [ > https://issues.apache.org/jira/browse/HELIX-561?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14248601#comment-14248601 > ] > > Zhen Zhang commented on HELIX-561: > ---------------------------------- > > [~vinayakb] are you using same partition name for different resources? we > recently fixed a bug (see https://issues.apache.org/jira/browse/HELIX-552) > regarding this. Previously a state model is indexed by partition id only > and the assumption is we use the naming convention like > resourceName_partitionId. If you are using the same partition name for > different resources, then it's possible that the same state model is > invoked for different resources. > > > 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) >
