Examples of ZKHelixDataAccessor


Examples of com.linkedin.helix.manager.zk.ZKHelixDataAccessor

    constraints.put("CONSTRAINT_VALUE", "1");
    constraints.put("INSTANCE", ".*");
    admin.addMessageConstraint(clusterName, "constraint1", constraints);
   

    final ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_gZkClient));

    // make sure we never see more than 1 state transition message for each participant
    final AtomicBoolean success = new AtomicBoolean(true);
    for (int i = 0; i < 5; i++)
    {
      String instanceName = "localhost_" + (12918 + i);
      String msgPath =
          PropertyPathConfig.getPath(PropertyType.MESSAGES, clusterName, instanceName);

      _gZkClient.subscribeChildChanges(msgPath, new IZkChildListener()
      {

        @Override
        public void handleChildChange(String parentPath, List<String> currentChilds) throws Exception
        {
          if (currentChilds != null && currentChilds.size() > 1)
          {
            List<ZNRecord> records = accessor.getBaseDataAccessor().getChildren(parentPath, null, 0);
            int transitionMsgCount = 0;
            for (ZNRecord record : records)
            {
              Message msg = new Message(record);
              if(msg.getMsgType().equals(Message.MessageType.STATE_TRANSITION.toString()))
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

                                                  PropertyKey propertyKey) throws JsonGenerationException,
      JsonMappingException,
      IOException
  {

    ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));

    HelixProperty property = accessor.getProperty(propertyKey);
    ZNRecord record = property == null ? null : property.getRecord();
    return ZNRecordToJson(record);
  }
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

                                                   PropertyKey propertyKey,
                                                   MediaType mediaType) throws JsonGenerationException,
      JsonMappingException,
      IOException
  {
    ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));

    ZNRecord records = accessor.getProperty(propertyKey).getRecord();
    return ZNRecordToJson(records);
  }
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

                                                     MediaType mediaType) throws JsonGenerationException,
      JsonMappingException,
      IOException
  {
    zkClient.setZkSerializer(new ZNRecordSerializer());
    ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));

    List<ZNRecord> records =
        HelixProperty.convertToList(accessor.getChildValues(propertyKey));
    return ObjectToJson(records);
  }
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

                                           PropertyKey propertyKey,
                                           MediaType mediaType) throws JsonGenerationException,
      JsonMappingException,
      IOException
  {
    ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));

    ZNRecord record = EMPTY_ZNRECORD;
    HelixProperty property = accessor.getProperty(propertyKey);
    if (property != null)
    {
      record = property.getRecord();
    }
    return ObjectToJson(record);
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

  }

  public static HelixDataAccessor getClusterDataAccessor(ZkClient zkClient,
                                                         String clusterName)
  {
    return new ZKHelixDataAccessor(clusterName,
                                   new ZkBaseDataAccessor<ZNRecord>(zkClient));
  }
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

  public static String getInstanceSessionId(ZkClient zkClient,
                                            String clusterName,
                                            String instanceName)
  {
    ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));
    Builder keyBuilder = accessor.keyBuilder();

    ZNRecord liveInstance =
        accessor.getProperty(keyBuilder.liveInstance(instanceName)).getRecord();

    return liveInstance.getSimpleField(LiveInstanceProperty.SESSION_ID.toString());
  }
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

    private void clearStatusUpdate(String clusterName, String instance,
      String resource, String partition) {
  // clear status update for error partition so verify() will not fail on
  // old
  // errors
  ZKHelixDataAccessor accessor = new ZKHelixDataAccessor(clusterName,
    new ZkBaseDataAccessor<ZNRecord>(_gZkClient));
  Builder keyBuilder = accessor.keyBuilder();

  LiveInstance liveInstance = accessor.getProperty(keyBuilder
    .liveInstance(instance));
  accessor.removeProperty(keyBuilder.stateTransitionStatus(instance,
    liveInstance.getSessionId(), resource, partition));

    }
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

  {
    Builder keyBuilder = new PropertyKey.Builder(clusterName);
    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

    ZKHelixDataAccessor accessor =
        new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(zkClient));

    ZNRecord record = null;
    LiveInstance leader = accessor.getProperty(keyBuilder.controllerLeader());
    if (leader != null)
    {
      record = leader.getRecord();
    }
    else
    {
      record = new ZNRecord("");
      DateFormat formatter = new SimpleDateFormat("yyyyMMdd-HHmmss.SSSSSS");
      String time = formatter.format(new Date());
      Map<String, String> contentMap = new TreeMap<String, String>();
      contentMap.put("AdditionalInfo", "No leader exists");
      record.setMapField(Level.HELIX_INFO + "-" + time, contentMap);
    }

    boolean paused = (accessor.getProperty(keyBuilder.pause()) == null ? false : true);
    record.setSimpleField(PropertyType.PAUSE.toString(), "" + paused);

    String retVal = ClusterRepresentationUtil.ZNRecordToJson(record);
    StringRepresentation representation =
        new StringRepresentation(retVal, MediaType.APPLICATION_JSON);
View Full Code Here

Examples of org.apache.helix.manager.zk.ZKHelixDataAccessor

    public boolean verify()
    {
      try
      {
        HelixDataAccessor accessor =
            new ZKHelixDataAccessor(clusterName,
                                    new ZkBaseDataAccessor<ZNRecord>(zkClient));

        return ClusterStateVerifier.verifyBestPossAndExtView(accessor, errStates);
      }
      catch (Exception e)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.