Examples of ZNRecord


Examples of org.apache.helix.ZNRecord

    ObjectMapper mapper = new ObjectMapper();
    String newIdealStateString = form.getFirstValue(NEW_IDEAL_STATE, true);

    if (newIdealStateString != null)
    {
      ZNRecord newIdealState =
          mapper.readValue(new StringReader(newIdealStateString), ZNRecord.class);
      _extraParameterMap.put(NEW_IDEAL_STATE, newIdealState);
    }

    String newStateModelString = form.getFirstValue(NEW_STATE_MODEL_DEF, true);
    if (newStateModelString != null)
    {
      ZNRecord newStateModel =
          mapper.readValue(new StringReader(newStateModelString), ZNRecord.class);
      _extraParameterMap.put(NEW_STATE_MODEL_DEF, newStateModel);
    }
  }
View Full Code Here

Examples of org.apache.helix.ZNRecord

        try
        {
          Map<String, String> report = provider.getRecentHealthReport();
          Map<String, Map<String, String>> partitionReport = provider
              .getRecentPartitionHealthReport();
          ZNRecord record = new ZNRecord(provider.getReportName());
          if (report != null)
          {
            record.setSimpleFields(report);
          }
          if (partitionReport != null)
          {
            record.setMapFields(partitionReport);
          }
          record.setSimpleField(StatsHolder.TIMESTAMP_NAME, "" + System.currentTimeMillis());
         
          HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
          Builder keyBuilder = accessor.keyBuilder();
          accessor.setProperty(keyBuilder.healthReport(_instanceName, record.getId()),
                               new HealthStat(record));

//          _helixManager.getDataAccessor().setProperty(
//              PropertyType.HEALTHREPORT, record, _instanceName, record.getId());
          // reset stats (for now just the partition stats)
View Full Code Here

Examples of org.apache.helix.ZNRecord

        (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.ZNRecord

    // check resource exists
    String idealStatePath =
        PropertyPathConfig.getPath(PropertyType.IDEALSTATES, clusterName, resourceName);

    ZNRecord idealStateRecord = null;
    try
    {
      idealStateRecord = baseAccessor.get(idealStatePath, null, 0);
    }
    catch (ZkNoNodeException e)
View Full Code Here

Examples of org.apache.helix.ZNRecord

        PropertyPathConfig.getPath(PropertyType.CONFIGS,
                                   clusterName,
                                   ConfigScopeProperty.CLUSTER.toString(),
                                   clusterName);
    _zkClient.createPersistent(path, true);
    _zkClient.writeData(path, new ZNRecord(clusterName));
    path =
        PropertyPathConfig.getPath(PropertyType.CONFIGS,
                                   clusterName,
                                   ConfigScopeProperty.PARTICIPANT.toString());
    _zkClient.createPersistent(path);
    path =
        PropertyPathConfig.getPath(PropertyType.CONFIGS,
                                   clusterName,
                                   ConfigScopeProperty.RESOURCE.toString());
    _zkClient.createPersistent(path);
    // PROPERTY STORE
    path = PropertyPathConfig.getPath(PropertyType.PROPERTYSTORE, clusterName);
    _zkClient.createPersistent(path);
    // LIVE INSTANCES
    _zkClient.createPersistent(HelixUtil.getLiveInstancesPath(clusterName));
    // MEMBER INSTANCES
    _zkClient.createPersistent(HelixUtil.getMemberInstancesPath(clusterName));
    // External view
    _zkClient.createPersistent(HelixUtil.getExternalViewPath(clusterName));
    // State model definition
    _zkClient.createPersistent(HelixUtil.getStateModelDefinitionPath(clusterName));

    // controller
    _zkClient.createPersistent(HelixUtil.getControllerPath(clusterName));
    path = PropertyPathConfig.getPath(PropertyType.HISTORY, clusterName);
    final ZNRecord emptyHistory = new ZNRecord(PropertyType.HISTORY.toString());
    final List<String> emptyList = new ArrayList<String>();
    emptyHistory.setListField(clusterName, emptyList);
    _zkClient.createPersistent(path, emptyHistory);

    path = PropertyPathConfig.getPath(PropertyType.MESSAGES_CONTROLLER, clusterName);
    _zkClient.createPersistent(path);
View Full Code Here

Examples of org.apache.helix.ZNRecord

      public ZNRecord update(ZNRecord statsRec)
      {
        if (statsRec == null)
        {
          // TODO: fix naming of this record, if it matters
          statsRec = new ZNRecord(PersistentStats.nodeName);
        }

        Map<String, Map<String, String>> currStatMap = statsRec.getMapFields();
        Map<String, Map<String, String>> newStatMap = StatsHolder.parseStat(statName);
        for (String newStat : newStatMap.keySet())
View Full Code Here

Examples of org.apache.helix.ZNRecord

      public ZNRecord update(ZNRecord alertsRec)
      {
        if (alertsRec == null)
        {
          // TODO: fix naming of this record, if it matters
          alertsRec = new ZNRecord(Alerts.nodeName);

        }

        Map<String, Map<String, String>> currAlertMap = alertsRec.getMapFields();
        StringBuilder newStatName = new StringBuilder();
View Full Code Here

Examples of org.apache.helix.ZNRecord

    {
      masterStateValue = slaveStateValue;
    }
    if (idealState.getIdealStateMode() != IdealStateModeProperty.AUTO_REBALANCE)
    {
      ZNRecord newIdealState =
          DefaultIdealStateCalculator.calculateIdealState(instanceNames,
                                                                 partitions,
                                                                 replica,
                                                                 keyPrefix,
                                                                 masterStateValue,
                                                                 slaveStateValue);

      // for now keep mapField in AUTO mode and remove listField in CUSTOMIZED mode
      if (idealState.getIdealStateMode() == IdealStateModeProperty.AUTO)
      {
        idealState.getRecord().setListFields(newIdealState.getListFields());
        idealState.getRecord().setMapFields(newIdealState.getMapFields());
      }
      if (idealState.getIdealStateMode() == IdealStateModeProperty.CUSTOMIZED)
      {
        idealState.getRecord().setMapFields(newIdealState.getMapFields());
      }
    }
    else
    {
      for (int i = 0; i < partitions; i++)
View Full Code Here

Examples of org.apache.helix.ZNRecord

  }

  @Override
  public void addIdealState(String clusterName, String resourceName, String idealStateFile) throws IOException
  {
    ZNRecord idealStateRecord =
        (ZNRecord) (new ZNRecordSerializer().deserialize(readFile(idealStateFile)));
    if (idealStateRecord.getId() == null
        || !idealStateRecord.getId().equals(resourceName))
    {
      throw new IllegalArgumentException("ideal state must have same id as resource name");
    }
    setResourceIdealState(clusterName, resourceName, new IdealState(idealStateRecord));
  }
View Full Code Here

Examples of org.apache.helix.ZNRecord

    try
    {
      ZkClient zkClient =
          (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
      ZNRecord result = readZkDataStatAndChild(zkPath, zkClient);

      presentation =
          new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(result),
                                   MediaType.APPLICATION_JSON);
    }
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.