Examples of ZNRecord


Examples of org.apache.helix.ZNRecord

  {
    ZkClient client = new ZkClient(zkServer);
    client.setZkSerializer(new ZNRecordSerializer());
    String path = HelixUtil.getMessagePath(clusterName, instanceName) + "/" + message.getId();
    client.delete(path);
    ZNRecord record = client.readData(HelixUtil.getLiveInstancePath(clusterName, instanceName));
    message.setTgtSessionId(record.getSimpleField(LiveInstanceProperty.SESSION_ID.toString()).toString());
    message.setTgtName(record.getId());
    //System.out.println(message);
    client.createPersistent(path, message.getRecord());
  }
View Full Code Here

Examples of org.apache.helix.ZNRecord

    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
    ClusterSetup setupTool = new ClusterSetup(zkClient);
    List<String> clusters = setupTool.getClusterManagementTool().getClusters();

    ZNRecord clustersRecord = new ZNRecord("Clusters Summary");
    clustersRecord.setListField("clusters", clusters);
    StringRepresentation representation =
        new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(clustersRecord),
                                 MediaType.APPLICATION_JSON);

    return representation;
View Full Code Here

Examples of org.apache.helix.ZNRecord

    ZkClient zkClient = (ZkClient)getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);
    ClusterSetup setupTool = new ClusterSetup(zkClient);
   
    List<String> models = setupTool.getClusterManagementTool().getStateModelDefs(clusterName);
   
    ZNRecord modelDefinitions = new ZNRecord("modelDefinitions");
    modelDefinitions.setListField("models", models);
   
    StringRepresentation representation = new StringRepresentation(ClusterRepresentationUtil.ZNRecordToJson(modelDefinitions), MediaType.APPLICATION_JSON);
   
    return representation;
  }
View Full Code Here

Examples of org.apache.helix.ZNRecord

      String command = jsonParameters.getCommand();

       
      if(command.equalsIgnoreCase(ClusterSetup.addStateModelDef))
      {
        ZNRecord newStateModel = jsonParameters.getExtraParameter(JsonParameters.NEW_STATE_MODEL_DEF);
        HelixDataAccessor accessor = ClusterRepresentationUtil.getClusterDataAccessor(zkClient, clusterName);
        
        accessor.setProperty(accessor.keyBuilder().stateModelDef(newStateModel.getId()), new StateModelDefinition(newStateModel) );
        getResponse().setEntity(getStateModelsRepresentation());
      }
      else
      {
          throw new HelixException("Unsupported command: " + command
View Full Code Here

Examples of org.apache.helix.ZNRecord

   *
   * @param id
   */
  public ZNRecord createEmptyStatusUpdateRecord(String id)
  {
    return new ZNRecord(id);
  }
View Full Code Here

Examples of org.apache.helix.ZNRecord

   * merged with the previous status update record in the zookeeper. See ZNRecord.merge()
   * for more details.
   * */
  ZNRecord createMessageLogRecord(Message message)
  {
    ZNRecord result = new ZNRecord(getStatusUpdateRecordName(message));
    String mapFieldKey = "MESSAGE " + message.getMsgId();
    result.setMapField(mapFieldKey, new TreeMap<String, String>());

    // Store all the simple fields of the message in the new ZNRecord's map
    // field.
    for (String simpleFieldKey : message.getRecord().getSimpleFields().keySet())
    {
      result.getMapField(mapFieldKey).put(simpleFieldKey,
                                          message.getRecord()
                                                 .getSimpleField(simpleFieldKey));
    }
    if (message.getResultMap() != null)
    {
      result.setMapField("MessageResult", message.getResultMap());
    }
    return result;
  }
View Full Code Here

Examples of org.apache.helix.ZNRecord

  public ZNRecord createMessageStatusUpdateRecord(Message message,
                                                  Level level,
                                                  Class classInfo,
                                                  String additionalInfo)
  {
    ZNRecord result = createEmptyStatusUpdateRecord(getStatusUpdateRecordName(message));
    Map<String, String> contentMap = new TreeMap<String, String>();

    contentMap.put("Message state", message.getMsgState().toString());
    contentMap.put("AdditionalInfo", additionalInfo);
    contentMap.put("Class", classInfo.toString());
    contentMap.put("MSG_ID", message.getMsgId());

    DateFormat formatter = new SimpleDateFormat("yyyyMMdd-HHmmss.SSSSSS");
    String time = formatter.format(new Date());

    String id =
        String.format("%4s %26s ", level.toString(), time)
            + getRecordIdForMessage(message);

    result.setMapField(id, contentMap);

    return result;
  }
View Full Code Here

Examples of org.apache.helix.ZNRecord

                                           String additionalInfo,
                                           HelixDataAccessor accessor)
  {
    try
    {
      ZNRecord record =
          createMessageStatusUpdateRecord(message, level, classInfo, additionalInfo);
      publishStatusUpdateRecord(record, message, level, accessor);
    }
    catch (Exception e)
    {
View Full Code Here

Examples of org.apache.helix.ZNRecord

            keyBuilder.stateTransitionStatus(instanceName,
                                             sessionId,
                                             statusUpdateSubPath,
                                             statusUpdateKey);

        ZNRecord statusUpdateRecord = createMessageLogRecord(message);

        // For now write participant StatusUpdates to log4j.
        // we are using restlet as another data channel to report to controller.
        if(_logger.isTraceEnabled()){
           _logger.trace("StatusUpdate path:" + propertyKey.getPath() + ", updates:"
View Full Code Here

Examples of org.apache.helix.ZNRecord

                                                                        session,
                                                                        resourceGroupName));

            for (String partitionString : partitionStrings)
            {
              ZNRecord partitionRecord =
                  accessor.getProperty(keyBuilder.stateTransitionStatus(instanceName,
                                                                        session,
                                                                        resourceGroupName,
                                                                        partitionString))
                          .getRecord();
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.