Package com.linkedin.helix.model

Examples of com.linkedin.helix.model.Resource


    HelixDataAccessor dataAccessor = manager.getHelixDataAccessor();
    List<Message> messagesToSend = new ArrayList<Message>();
    for (String resourceName : resourceMap.keySet())
    {
      Resource resource = resourceMap.get(resourceName);
      for (Partition partition : resource.getPartitions())
      {
        List<Message> messages = messageOutput.getMessages(resourceName, partition);
        messagesToSend.addAll(messages);
      }
    }
View Full Code Here


    Iterator<Message> iter = messages.iterator();
    while (iter.hasNext())
    {
      Message message = iter.next();
      String resourceName = message.getResourceName();
      Resource resource = resourceMap.get(resourceName);
      if (resource == null || !resource.getGroupMessageMode())
      {
        outputMessages.add(message);
        continue;
      }
View Full Code Here

        String resourceName = idealState.getResourceName();

        for (String partition : partitionSet)
        {
          addPartition(partition, resourceName, resourceMap);
          Resource resource = resourceMap.get(resourceName);
          resource.setStateModelDefRef(idealState.getStateModelDefRef());
          resource.setStateModelFactoryName(idealState.getStateModelFactoryName());
          resource.setBucketSize(idealState.getBucketSize());
          resource.setGroupMessageMode(idealState.getGroupMessageMode());
        }
      }
    }

    // It's important to get partitions from CurrentState as well since the
    // idealState might be removed.
    Map<String, LiveInstance> availableInstances = cache.getLiveInstances();

    if (availableInstances != null && availableInstances.size() > 0)
    {
      for (LiveInstance instance : availableInstances.values())
      {
        String instanceName = instance.getInstanceName();
        String clientSessionId = instance.getSessionId();

        Map<String, CurrentState> currentStateMap = cache.getCurrentState(instanceName,
            clientSessionId);
        if (currentStateMap == null || currentStateMap.size() == 0)
        {
          continue;
        }
        for (CurrentState currentState : currentStateMap.values())
        {

          String resourceName = currentState.getResourceName();
          Map<String, String> resourceStateMap = currentState.getPartitionStateMap();

          // don't overwrite ideal state settings
          if (!resourceMap.containsKey(resourceName))
          {
            addResource(resourceName, resourceMap);
            Resource resource = resourceMap.get(resourceName);
            resource.setStateModelDefRef(currentState.getStateModelDefRef());
            resource.setStateModelFactoryName(currentState.getStateModelFactoryName());
            resource.setBucketSize(currentState.getBucketSize());
            resource.setGroupMessageMode(currentState.getGroupMessageMode());
          }
         
          if (currentState.getStateModelDefRef() == null)
          {
            LOG.error("state model def is null." + "resource:" + currentState.getResourceName()
View Full Code Here

    {
      return;
    }
    if (!resourceMap.containsKey(resource))
    {
      resourceMap.put(resource, new Resource(resource));
    }
  }
View Full Code Here

    {
      return;
    }
    if (!resourceMap.containsKey(resourceName))
    {
      resourceMap.put(resourceName, new Resource(resourceName));
    }
    Resource resource = resourceMap.get(resourceName);
    resource.addPartition(partition);

  }
View Full Code Here

    for (String resourceName : resourceMap.keySet())
    {
      ExternalView view = new ExternalView(resourceName);
      // if resource ideal state has bucket size, set it
      // otherwise resource has been dropped, use bucket size from current state instead
      Resource resource = resourceMap.get(resourceName);
      if (resource.getBucketSize() > 0)
      {
        view.setBucketSize(resource.getBucketSize());
      } else
      {
        view.setBucketSize(currentStateOutput.getBucketSize(resourceName));
      }
     
      for (Partition partition : resource.getPartitions())
      {
        Map<String, String> currentStateMap =
            currentStateOutput.getCurrentStateMap(resourceName, partition);
        if (currentStateMap != null && currentStateMap.size() > 0)
        {
View Full Code Here

    // go through all new messages, throttle if necessary
    // assume messages should be sorted by state transition priority in messageSelection stage
    for (String resourceName : resourceMap.keySet())
    {
      Resource resource = resourceMap.get(resourceName);
      for (Partition partition : resource.getPartitions())
      {
        List<Message> messages = msgSelectionOutput.getMessages(resourceName, partition);
        if (constraint != null && messages != null && messages.size() > 0)
        {
          messages = throttle(throttleCounterMap, constraint, messages, true);
View Full Code Here

  }

  protected Map<String, Resource> getResourceMap()
  {
    Map<String, Resource> resourceMap = new HashMap<String, Resource>();
    Resource testResource = new Resource("testResourceName");
    testResource.setStateModelDefRef("MasterSlave");
    testResource.addPartition("testResourceName_0");
    testResource.addPartition("testResourceName_1");
    testResource.addPartition("testResourceName_2");
    testResource.addPartition("testResourceName_3");
    testResource.addPartition("testResourceName_4");
    resourceMap.put("testResourceName", testResource);

    return resourceMap;
  }
View Full Code Here

    MessageSelectionStageOutput output = new MessageSelectionStageOutput();

    for (String resourceName : resourceMap.keySet())
    {
      Resource resource = resourceMap.get(resourceName);
      StateModelDefinition stateModelDef =
          cache.getStateModelDef(resource.getStateModelDefRef());

      Map<String, Integer> stateTransitionPriorities =
          getStateTransitionPriorityMap(stateModelDef);
      IdealState idealState = cache.getIdealState(resourceName);
      Map<String, Bounds> stateConstraints =
          computeStateConstraints(stateModelDef, idealState, cache);

      for (Partition partition : resource.getPartitions())
      {
        List<Message> messages = messageGenOutput.getMessages(resourceName, partition);
        List<Message> selectedMessages =
            selectMessages(cache.getLiveInstances(),
                           currentStateOutput.getCurrentStateMap(resourceName, partition),
View Full Code Here

        if (!instance.getSessionId().equals(message.getTgtSessionId()))
        {
          continue;
        }
        String resourceName = message.getResourceName();
        Resource resource = resourceMap.get(resourceName);
        if (resource == null)
        {
          continue;
        }

        if (!message.getGroupMessageMode())
        {
          String partitionName = message.getPartitionName();
          Partition partition = resource.getPartition(partitionName);
          if (partition != null)
          {
            currentStateOutput.setPendingState(resourceName,
                                               partition,
                                               instanceName,
                                               message.getToState());
          }
          else
          {
            // log
          }
        }
        else
        {
          List<String> partitionNames = message.getPartitionNames();
          if (!partitionNames.isEmpty())
          {
            for (String partitionName : partitionNames)
            {
              Partition partition = resource.getPartition(partitionName);
              if (partition != null)
              {
                currentStateOutput.setPendingState(resourceName,
                                                   partition,
                                                   instanceName,
                                                   message.getToState());
              }
              else
              {
                // log
              }
            }
          }
        }
      }
    }
    for (LiveInstance instance : liveInstances.values())
    {
      String instanceName = instance.getInstanceName();

      String clientSessionId = instance.getSessionId();
      Map<String, CurrentState> currentStateMap =
          cache.getCurrentState(instanceName, clientSessionId);
      for (CurrentState currentState : currentStateMap.values())
      {

        if (!instance.getSessionId().equals(currentState.getSessionId()))
        {
          continue;
        }
        String resourceName = currentState.getResourceName();
        String stateModelDefName = currentState.getStateModelDefRef();
        Resource resource = resourceMap.get(resourceName);
        if (resource == null)
        {
          continue;
        }
        if (stateModelDefName != null)
        {
          currentStateOutput.setResourceStateModelDef(resourceName, stateModelDefName);
        }

        currentStateOutput.setBucketSize(resourceName, currentState.getBucketSize());

        Map<String, String> partitionStateMap = currentState.getPartitionStateMap();
        for (String partitionName : partitionStateMap.keySet())
        {
          Partition partition = resource.getPartition(partitionName);
          if (partition != null)
          {
            currentStateOutput.setCurrentState(resourceName,
                                               partition,
                                               instanceName,
View Full Code Here

TOP

Related Classes of com.linkedin.helix.model.Resource

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.