Package org.apache.helix.PropertyKey

Examples of org.apache.helix.PropertyKey.Builder


  // 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


  {
    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: "
            + leader);
        return;
      }
    }

    PauseSignal pauseSignal = accessor.getProperty(keyBuilder.pause());
    if (pauseSignal != null)
    {
      _paused = true;
      logger.info("controller is now paused");
    }
View Full Code Here

  private static final Logger                         LOG =
                                                              Logger.getLogger(ClusterDataCache.class.getName());

  public boolean refresh(HelixDataAccessor accessor)
  {
    Builder keyBuilder = accessor.keyBuilder();
    _idealStateMap = accessor.getChildValuesMap(keyBuilder.idealStates());
    _liveInstanceMap = accessor.getChildValuesMap(keyBuilder.liveInstances());

    for (LiveInstance instance : _liveInstanceMap.values())
    {
      LOG.trace("live instance: " + instance.getInstanceName() + " "
          + instance.getSessionId());
    }

    _stateModelDefMap = accessor.getChildValuesMap(keyBuilder.stateModelDefs());
    _instanceConfigMap = accessor.getChildValuesMap(keyBuilder.instanceConfigs());
    _constraintMap =
        accessor.getChildValuesMap(keyBuilder.constraints());

    Map<String, Map<String, Message>> msgMap =
        new HashMap<String, Map<String, Message>>();
    for (String instanceName : _liveInstanceMap.keySet())
    {
      Map<String, Message> map =
          accessor.getChildValuesMap(keyBuilder.messages(instanceName));
      msgMap.put(instanceName, map);
    }
    _messageMap = Collections.unmodifiableMap(msgMap);

    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 =
          allCurStateMap.get(instanceName);
      Map<String, CurrentState> map =
          accessor.getChildValuesMap(keyBuilder.currentStates(instanceName, sessionId));
      curStateMap.put(sessionId, map);
    }

    for (String instance : allCurStateMap.keySet())
    {
View Full Code Here

    return taskResult;
  }

  private void removeMessageFromZk(HelixDataAccessor accessor, Message message)
  {
    Builder keyBuilder = accessor.keyBuilder();
    if (message.getTgtName().equalsIgnoreCase("controller"))
    {
      // TODO: removeProperty returns boolean
      accessor.removeProperty(keyBuilder.controllerMessage(message.getMsgId()));
    }
    else
    {
      accessor.removeProperty(keyBuilder.message(_manager.getInstanceName(),
                                                 message.getMsgId()));
    }
  }
View Full Code Here

                                     taskResult.getTaskResultMap());
      replyMessage.setSrcInstanceType(_manager.getInstanceType());

      if (message.getSrcInstanceType() == InstanceType.PARTICIPANT)
      {
        Builder keyBuilder = accessor.keyBuilder();
        accessor.setProperty(keyBuilder.message(message.getMsgSrc(),
                                                replyMessage.getMsgId()),
                             replyMessage);
      }
      else if (message.getSrcInstanceType() == InstanceType.CONTROLLER)
      {
        Builder keyBuilder = accessor.keyBuilder();
        accessor.setProperty(keyBuilder.controllerMessage(replyMessage.getMsgId()),
                             replyMessage);
      }
      _statusUpdateUtil.logInfo(message, HelixTask.class, "1 msg replied to "
          + replyMessage.getTgtName(), accessor);
    }
View Full Code Here

    if (sessionId == null)
    {
      sessionId = "*";
    }

    Builder keyBuilder = accessor.keyBuilder();
    if (!_recordedMessages.containsKey(message.getMsgId()))
    {
      // TODO instanceName of a controller might be any string
      if (instanceName.equalsIgnoreCase("Controller"))
      {
        accessor.updateProperty(keyBuilder.controllerTaskStatus(statusUpdateSubPath,
                                                                statusUpdateKey),
                                new StatusUpdate(createMessageLogRecord(message)));

      }
      else
      {
       
        PropertyKey propertyKey =
            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:"
              + statusUpdateRecord);
        }
        accessor.updateProperty(propertyKey, new StatusUpdate(statusUpdateRecord));
       
      }
      _recordedMessages.put(message.getMsgId(), message.getMsgId());
    }

    if (instanceName.equalsIgnoreCase("Controller"))
    {
      accessor.updateProperty(keyBuilder.controllerTaskStatus(statusUpdateSubPath,
                                                              statusUpdateKey),
                              new StatusUpdate(record));
    }
    else
    {
     
      PropertyKey propertyKey =
          keyBuilder.stateTransitionStatus(instanceName,
                                           sessionId,
                                           statusUpdateSubPath,
                                           statusUpdateKey);
      // For now write participant StatusUpdates to log4j.
      // we are using restlet as another data channel to report to controller.
View Full Code Here

    if (sessionId == null)
    {
      sessionId = "*";
    }

    Builder keyBuilder = accessor.keyBuilder();

    // TODO remove the hard code: "controller"
    if (instanceName.equalsIgnoreCase("controller"))
    {
      // TODO need to fix: ERRORS_CONTROLLER doesn't have a form of
      // ../{sessionId}/{subPath}
      // accessor.setProperty(PropertyType.ERRORS_CONTROLLER, record,
      // statusUpdateSubPath);
      accessor.setProperty(keyBuilder.controllerTaskError(statusUpdateSubPath),
                           new Error(record));
    }
    else
    {
      // accessor.updateProperty(PropertyType.ERRORS,
      // record,
      // instanceName,
      // sessionId,
      // statusUpdateSubPath,
      // statusUpdateKey);
      accessor.updateProperty(keyBuilder.stateTransitionError(instanceName,
                                                              sessionId,
                                                              statusUpdateSubPath,
                                                              statusUpdateKey),
                              new Error(record));

View Full Code Here

      JsonMappingException,
      IOException
  {
    String clusterName = (String) getRequest().getAttributes().get("clusterName");
    String instanceName = (String) getRequest().getAttributes().get("instanceName");
    Builder keyBuilder = new PropertyKey.Builder(clusterName);
    ZkClient zkClient =
        (ZkClient) getContext().getAttributes().get(RestAdminApplication.ZKCLIENT);

    String message =
        ClusterRepresentationUtil.getClusterPropertyAsString(zkClient,
                                                             clusterName,
                                                             MediaType.APPLICATION_JSON,
                                                             keyBuilder.instanceConfig(instanceName));

    StringRepresentation representation =
        new StringRepresentation(message, MediaType.APPLICATION_JSON);

    return representation;
View Full Code Here

                                                               String instance,
                                                               String resourceGroup,
                                                               String sessionID,
                                                               String partition)
    {
      Builder keyBuilder = accessor.keyBuilder();

      List<ZNRecord> instances =
          HelixProperty.convertToList(accessor.getChildValues(keyBuilder.instanceConfigs()));
      List<ZNRecord> partitionRecords = new ArrayList<ZNRecord>();
      for (ZNRecord znRecord : instances)
      {
        String instanceName = znRecord.getId();
        if (!instanceName.equals(instance))
        {
          continue;
        }

        List<String> sessions = accessor.getChildNames(keyBuilder.sessions(instanceName));
        for (String session : sessions)
        {
          if (sessionID != null && !session.equals(sessionID))
          {
            continue;
          }

          List<String> resourceGroups =
              accessor.getChildNames(keyBuilder.stateTransitionStatus(instanceName,
                                                                      session));
          for (String resourceGroupName : resourceGroups)
          {
            if (!resourceGroupName.equals(resourceGroup))
            {
              continue;
            }

            List<String> partitionStrings =
                accessor.getChildNames(keyBuilder.stateTransitionStatus(instanceName,
                                                                        session,
                                                                        resourceGroupName));

            for (String partitionString : partitionStrings)
            {
              ZNRecord partitionRecord =
                  accessor.getProperty(keyBuilder.stateTransitionStatus(instanceName,
                                                                        session,
                                                                        resourceGroupName,
                                                                        partitionString))
                          .getRecord();
              if (!partitionString.equals(partition))
View Full Code Here

  @Override
  public void reportHealthReportMessage(ZNRecord healthCheckInfoUpdate)
  {
    HelixDataAccessor accessor = _helixManager.getHelixDataAccessor();
    Builder keyBuilder = accessor.keyBuilder();
//    accessor.setProperty(
//        PropertyType.HEALTHREPORT, healthCheckInfoUpdate, _instanceName,
//        healthCheckInfoUpdate.getId());
    accessor.setProperty(keyBuilder.healthReport(_instanceName, healthCheckInfoUpdate.getId()),
                         new HealthStat(healthCheckInfoUpdate));

  }
View Full Code Here

TOP

Related Classes of org.apache.helix.PropertyKey.Builder

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.