Package org.apache.helix.model

Examples of org.apache.helix.model.LiveInstance


  void refreshZkPropertyTransferUrl()
  {
    try
    {
      LiveInstance leader = getProperty(keyBuilder().controllerLeader());
      if (leader != null)
      {
        _zkPropertyTransferSvcUrl = leader.getWebserviceUrl();
        LOG.info("_zkPropertyTransferSvcUrl : " + _zkPropertyTransferSvcUrl
            + " Controller " + leader.getInstanceName());
      }
      else
      {
        _zkPropertyTransferSvcUrl = null;
      }
View Full Code Here


    // Update data in the live instance node, should trigger another live instance change
    // event
    HelixDataAccessor helixDataAccessor = manager.getHelixDataAccessor();
    PropertyKey propertyKey =
        helixDataAccessor.keyBuilder().liveInstance(manager.getInstanceName());
    LiveInstance instance = helixDataAccessor.getProperty(propertyKey);

    Map<String, String> map = new TreeMap<String, String>();
    map.put("k1", "v1");
    instance.getRecord().setMapField("test", map);
    Assert.assertTrue(helixDataAccessor.updateProperty(propertyKey, instance),
                      "Failed to update live instance node");

    instances = changeList.poll(1, TimeUnit.SECONDS);
    Assert.assertNotNull(instances, "Expecting a list of live instance");
View Full Code Here

  private List<LiveInstance> deepCopy(List<LiveInstance> instances)
  {
    List<LiveInstance> result = new ArrayList<LiveInstance>();
    for (LiveInstance instance : instances)
    {
      result.add(new LiveInstance(instance.getRecord()));
    }
    return result;
  }
View Full Code Here

  public void testMasterXfer()
  {
    System.out.println("START testMasterXfer at " + new Date(System.currentTimeMillis()));

    Map<String, LiveInstance> liveInstances = new HashMap<String, LiveInstance>();
    liveInstances.put("localhost_0", new LiveInstance("localhost_0"));
    liveInstances.put("localhost_1", new LiveInstance("localhost_1"));

    Map<String, String> currentStates = new HashMap<String, String>();
    currentStates.put("localhost_0", "SLAVE");
    currentStates.put("localhost_1", "MASTER");
View Full Code Here

  {
    System.out.println("START testMasterXferAfterMasterResume at "
        + new Date(System.currentTimeMillis()));

    Map<String, LiveInstance> liveInstances = new HashMap<String, LiveInstance>();
    liveInstances.put("localhost_0", new LiveInstance("localhost_0"));
    liveInstances.put("localhost_1", new LiveInstance("localhost_1"));

    Map<String, String> currentStates = new HashMap<String, String>();
    currentStates.put("localhost_0", "SLAVE");
    currentStates.put("localhost_1", "SLAVE");
View Full Code Here

    Map<String, Map<String, Map<String, CurrentState>>> allCurStateMap =
        new HashMap<String, Map<String, Map<String, CurrentState>>>();
    for (String instanceName : _liveInstanceMap.keySet())
    {
      LiveInstance liveInstance = _liveInstanceMap.get(instanceName);
      String sessionId = liveInstance.getSessionId();
      if (!allCurStateMap.containsKey(instanceName))
      {
        allCurStateMap.put(instanceName, new HashMap<String, Map<String, CurrentState>>());
      }
      Map<String, Map<String, CurrentState>> curStateMap =
View Full Code Here

    logger.info("START: GenericClusterController.onControllerChange()");
    HelixDataAccessor accessor = changeContext.getManager().getHelixDataAccessor();

    // double check if this controller is the leader
    Builder keyBuilder = accessor.keyBuilder();
    LiveInstance leader =
        accessor.getProperty(keyBuilder.controllerLeader());
    if (leader == null)
    {
      logger.warn("No controller exists for cluster:"
          + changeContext.getManager().getClusterName());
      return;
    }
    else
    {
      String leaderName = leader.getInstanceName();

      String instanceName = changeContext.getManager().getInstanceName();
      if (leaderName == null || !leaderName.equals(instanceName))
      {
        logger.warn("leader name does NOT match, my name: " + instanceName + ", leader: "
View Full Code Here

    Builder keyBuilder = accessor.keyBuilder();

    for (int i = 0; i < liveInstances.length; i++)
    {
      String instance = "localhost_" + liveInstances[i];
      LiveInstance liveInstance = new LiveInstance(instance);
      liveInstance.setSessionId("session_" + liveInstances[i]);
      liveInstance.setHelixVersion("0.0.0");
      accessor.setProperty(keyBuilder.liveInstance(instance), liveInstance);
    }
  }
View Full Code Here

                + new Timestamp(timestampVal) + "\nline:" + inputLine);
            lastTestStartTimestamp = timestampVal;
          }

          ZNRecord record = getZNRecord(inputLine);
          LiveInstance liveInstance = new LiveInstance(record);
          String session = getAttributeValue(inputLine, "session:");
          sessionMap.put(session, inputLine);
          System.out.println(new Timestamp(Long.parseLong(timestamp)) + ": create LIVEINSTANCE "
              + liveInstance.getInstanceName());
        }
        else if (inputLine.indexOf("closeSession") != -1)
        {
          // kill any instance
          String session = getAttributeValue(inputLine, "session:");
          if (sessionMap.containsKey(session))
          {
            if (timestampVal < lastTestStartTimestamp)
            {
              System.out.println("KILL node. SETTING lastTestStartTimestamp to " + timestampVal
                  + " line:" + inputLine);
              lastTestStartTimestamp = timestampVal;
            }
            String line = sessionMap.get(session);
            ZNRecord record = getZNRecord(line);
            LiveInstance liveInstance = new LiveInstance(record);

            System.out.println(new Timestamp(Long.parseLong(timestamp)) + ": close session "
                + liveInstance.getInstanceName());
            dump = true;
          }
        }
        else if (inputLine.indexOf("/" + clusterName + "/CONFIGS/PARTICIPANT") != -1)
        {
          // disable a partition
          String type = getAttributeValue(inputLine, "type:");
          if (type.equals("setData") && inputLine.indexOf("HELIX_DISABLED_PARTITION") != -1)
          {
            if (timestampVal < lastTestStartTimestamp)
            {
              System.out.println("DISABLE partition. SETTING lastTestStartTimestamp to " + timestampVal
                  + " line:" + inputLine);
              lastTestStartTimestamp = timestampVal;
            }
          }
        } else if (inputLine.indexOf("/" + clusterName + "/CONTROLLER/LEADER") != -1)
        {
          // leaderLine = inputLine;
          ZNRecord record = getZNRecord(inputLine);
          LiveInstance liveInstance = new LiveInstance(record);
          String session = getAttributeValue(inputLine, "session:");
          leaderSession = session;
          controllerStartTime = Long.parseLong(getAttributeValue(inputLine, "time:"));
          sessionMap.put(session, inputLine);
          System.out.println(new Timestamp(Long.parseLong(timestamp)) + ": create LEADER "
              + liveInstance.getInstanceName());
        }
        else if (inputLine.indexOf("/" + clusterName + "/") != -1
            && inputLine.indexOf("/CURRENTSTATES/") != -1)
        {
          String type = getAttributeValue(inputLine, "type:");
View Full Code Here

    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());
    // AssertJUnit.assertNull(election.getLeader());

    System.out.println("END TestDistControllerElection at " + new Date(System.currentTimeMillis()));
  }
View Full Code Here

TOP

Related Classes of org.apache.helix.model.LiveInstance

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.