Package org.apache.helix

Examples of org.apache.helix.NotificationContext


  public void testOnBecomeStandbyFromLeader()
  {
    Message message = new Message(MessageType.STATE_TRANSITION, "0");
    message.setPartitionName(clusterName);
    message.setTgtName("controller_0");
    stateModel.onBecomeStandbyFromLeader(message, new NotificationContext(null));
  }
View Full Code Here


    Message message = new Message(MessageType.STATE_TRANSITION, "0");
    message.setPartitionName(clusterName);
    message.setTgtName("controller_0");
    try
    {
      stateModel.onBecomeLeaderFromStandby(message, new NotificationContext(null));
    }
    catch (Exception e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    stateModel.rollbackOnError(message, new NotificationContext(null), null);
  }
View Full Code Here

    Message message = new Message(MessageType.STATE_TRANSITION, "0");
    message.setPartitionName(clusterName);
    message.setTgtName("controller_0");
    try
    {
      stateModel.onBecomeLeaderFromStandby(message, new NotificationContext(null));
    }
    catch (Exception e)
    {
      // TODO Auto-generated catch block
      e.printStackTrace();
View Full Code Here

    HelixManager manager = new MockZKHelixManager(clusterName, controllerName,
                               InstanceType.CONTROLLER,
                               _gZkClient);

    DistClusterControllerElection election = new DistClusterControllerElection(ZK_ADDR);
    NotificationContext context = new NotificationContext(manager);
    context.setType(NotificationContext.Type.INIT);
    election.onControllerChange(context);

//    path = PropertyPathConfig.getPath(PropertyType.LEADER, clusterName);
//    ZNRecord leaderRecord = _gZkClient.<ZNRecord> readData(path);
    LiveInstance liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
    AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
    // AssertJUnit.assertNotNull(election.getController());
    // AssertJUnit.assertNull(election.getLeader());

    manager = new MockZKHelixManager(clusterName, "controller_1", InstanceType.CONTROLLER,
                               _gZkClient);
    election = new DistClusterControllerElection(ZK_ADDR);
    context = new NotificationContext(manager);
    context.setType(NotificationContext.Type.INIT);
    election.onControllerChange(context);
//    leaderRecord = _gZkClient.<ZNRecord> readData(path);
    liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
    AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
    // AssertJUnit.assertNull(election.getController());
View Full Code Here

    HelixManager manager = new MockZKHelixManager(clusterName, controllerName,
                               InstanceType.CONTROLLER_PARTICIPANT,
                               _gZkClient);

    DistClusterControllerElection election = new DistClusterControllerElection(ZK_ADDR);
    NotificationContext context = new NotificationContext(manager);
    context.setType(NotificationContext.Type.CALLBACK);
    election.onControllerChange(context);

    LiveInstance liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
    AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());

//    path = PropertyPathConfig.getPath(PropertyType.LEADER, clusterName);
//    ZNRecord leaderRecord = _gZkClient.<ZNRecord> readData(path);
//    AssertJUnit.assertEquals(controllerName, leaderRecord.getSimpleField("LEADER"));
    // AssertJUnit.assertNotNull(election.getController());
    // AssertJUnit.assertNotNull(election.getLeader());

    manager = new MockZKHelixManager(clusterName, "controller_1",
                               InstanceType.CONTROLLER_PARTICIPANT,
                               _gZkClient);
    election = new DistClusterControllerElection(ZK_ADDR);
    context = new NotificationContext(manager);
    context.setType(NotificationContext.Type.CALLBACK);
    election.onControllerChange(context);

    liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
    AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
View Full Code Here

    HelixManager manager = new MockZKHelixManager(clusterName, controllerName,
                               InstanceType.PARTICIPANT,
                               _gZkClient);

    DistClusterControllerElection election = new DistClusterControllerElection(ZK_ADDR);
    NotificationContext context = new NotificationContext(manager);
    context.setType(NotificationContext.Type.INIT);
    election.onControllerChange(context);

    path = PropertyPathConfig.getPath(PropertyType.LEADER, clusterName);
    ZNRecord leaderRecord = _gZkClient.<ZNRecord> readData(path, true);
    AssertJUnit.assertNull(leaderRecord);
View Full Code Here

  { "unitTest" })
  public void testAsyncCallbackSvc() throws Exception
  {
    AsyncCallbackService svc = new AsyncCallbackService();
    HelixManager manager = new MockHelixManager();
    NotificationContext changeContext = new NotificationContext(manager);
   
    Message msg = new Message(svc.getMessageType(), UUID.randomUUID().toString());
    msg.setTgtSessionId(manager.getSessionId());
    try
    {
View Full Code Here

    if (_paused) {
      logger.info("Cluster is paused. Ignoring the event:" + event.getName());
      return;
    }

    NotificationContext context = null;
    if (event.getAttribute("changeContext") != null) {
      context = (NotificationContext) (event.getAttribute("changeContext"));
    }

    // Initialize _clusterStatusMonitor
    if (context != null) {
      if (context.getType() == Type.FINALIZE) {
        if (_clusterStatusMonitor != null) {
          _clusterStatusMonitor.reset();
          _clusterStatusMonitor = null;
        }
View Full Code Here

      _manager = manager;
    }

    @Override
    public void run() {
      NotificationContext changeContext = new NotificationContext(_manager);
      changeContext.setType(NotificationContext.Type.CALLBACK);
      ClusterEvent event = new ClusterEvent("periodicalRebalance");
      event.addAttribute("helixmanager", changeContext.getManager());
      event.addAttribute("changeContext", changeContext);
      List<ZNRecord> dummy = new ArrayList<ZNRecord>();
      event.addAttribute("eventData", dummy);
      // Should be able to process
      handleEvent(event);
View Full Code Here

        + new Date(System.currentTimeMillis()));

    DefaultControllerMessageHandlerFactory facotry = new DefaultControllerMessageHandlerFactory();

    Message message = new Message(MessageType.NO_OP, "0");
    NotificationContext context = new NotificationContext(null);

    boolean exceptionCaught = false;
    try {
      MessageHandler handler = facotry.createHandler(message, context);
    } catch (HelixException e) {
View Full Code Here

TOP

Related Classes of org.apache.helix.NotificationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.