Package org.apache.helix.model

Examples of org.apache.helix.model.ResourceAssignment.addReplicaMap()


          ConstraintBasedAssignment.getDisabledParticipants(cluster.getParticipantMap(),
              partitionId);
      Map<State, String> upperBounds =
          ConstraintBasedAssignment
              .stateConstraints(stateModelDef, resourceId, cluster.getConfig());
      partitionMapping.addReplicaMap(partitionId, ConstraintBasedAssignment
          .computeAutoBestStateForPartition(upperBounds, cluster.getLiveParticipantMap().keySet(),
              stateModelDef, null, currentStateOutput.getCurrentStateMap(resourceId, partitionId),
              disabledParticipantsForPartition, true));
    }
    return partitionMapping;
View Full Code Here


    // Construct a ResourceAssignment object from the map of partition assignments.
    ResourceAssignment ra = new ResourceAssignment(ResourceId.from(jobResource));
    for (Map.Entry<Integer, PartitionAssignment> e : paMap.entrySet()) {
      PartitionAssignment pa = e.getValue();
      ra.addReplicaMap(PartitionId.from(pName(jobResource, e.getKey())),
          ImmutableMap.of(ParticipantId.from(pa._instance), State.from(pa._state)));
    }
    return ra;
  }
View Full Code Here

          currStateOutput.getCurrentStateMap(resourceId, partition);
      Map<ParticipantId, State> replicaMap = Maps.newHashMap();
      for (ParticipantId participantId : currentStateMap.keySet()) {
        replicaMap.put(participantId, State.from(HelixDefinedState.DROPPED));
      }
      assignment.addReplicaMap(partition, replicaMap);
    }
    return assignment;
  }

  private static void addCompletedPartitions(Set<Integer> set, JobContext ctx,
View Full Code Here

    for (IdealState idealState : idealStates) {
      ResourceId resourceId = idealState.getResourceId();
      ResourceAssignment assignment = new ResourceAssignment(resourceId);
      for (PartitionId partitionId : idealState.getPartitionIdSet()) {
        Map<ParticipantId, State> emptyMap = Collections.emptyMap();
        assignment.addReplicaMap(partitionId, emptyMap);
      }
      output.setResourceAssignment(resourceId, assignment);
    }
    return output;
  }
View Full Code Here

        // enforce that a participant can only have one instance of a given lock
        if (!replicaMap.containsKey(participant)) {
          replicaMap.put(participant, lockState);
        }
      }
      assignment.addReplicaMap(partition, replicaMap);
      i++;
    }
    return assignment;
  }
}
View Full Code Here

        Map<ParticipantId, State> replicaMap =
            ConstraintBasedAssignment.computeCustomizedBestStateForPartition(cluster
                .getLiveParticipantMap().keySet(), stateModelDef, newIdealState
                .getParticipantStateMap(partitionId), currentState.getCurrentStateMap(resourceId,
                partitionId), disabledParticipants);
        assignment.addReplicaMap(partitionId, replicaMap);
      }
    } else {
      // other modes use auto assignment
      Map<State, String> upperBounds =
          ConstraintBasedAssignment
View Full Code Here

        Map<ParticipantId, State> replicaMap =
            ConstraintBasedAssignment.computeAutoBestStateForPartition(upperBounds, cluster
                .getLiveParticipantMap().keySet(), stateModelDef, newIdealState
                .getPreferenceList(partitionId), currentState.getCurrentStateMap(resourceId,
                partitionId), disabledParticipants);
        assignment.addReplicaMap(partitionId, replicaMap);
      }
    }
    return assignment;
  }
}
View Full Code Here

          ConstraintBasedAssignment.getDisabledParticipants(cluster.getParticipantMap(), partition);
      Map<ParticipantId, State> bestStateForPartition =
          ConstraintBasedAssignment.computeCustomizedBestStateForPartition(cluster
              .getLiveParticipantMap().keySet(), stateModelDef, config.getPreferenceMap(partition),
              currentStateMap, disabledInstancesForPartition);
      partitionMapping.addReplicaMap(partition, bestStateForPartition);
    }
    return partitionMapping;
  }
}
View Full Code Here

      Map<ParticipantId, State> bestStateForPartition =
          ConstraintBasedAssignment.computeAutoBestStateForPartition(upperBounds,
              liveParticipants.keySet(), stateModelDef, preferenceList,
              currentState.getCurrentStateMap(config.getResourceId(), partition),
              disabledParticipantsForPartition);
      partitionMapping.addReplicaMap(partition, bestStateForPartition);
    }
    return partitionMapping;
  }

  private Map<PartitionId, Map<ParticipantId, State>> currentMapping(
View Full Code Here

   * @return ResourceAssignment
   */
  public ResourceAssignment build() {
    ResourceAssignment assignment = new ResourceAssignment(_resourceId);
    for (PartitionId partitionId : _mapping.keySet()) {
      assignment.addReplicaMap(partitionId, _mapping.get(partitionId));
    }
    return assignment;
  }
}
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.