Tabnine Logo
GroupByContainerCount$TaskGroup
Code IndexAdd Tabnine to your IDE (free)

How to use
GroupByContainerCount$TaskGroup
in
org.apache.samza.container.grouper.task

Best Java code snippets using org.apache.samza.container.grouper.task.GroupByContainerCount$TaskGroup (Showing top 16 results out of 315)

origin: org.apache.samza/samza-core_2.10

/**
 * Converts the task->containerId map to an ordered list of {@link TaskGroup} instances.
 *
 * @param taskToContainerId a map from each task name to the containerId to which it is assigned.
 * @return                  a list of TaskGroups ordered ascending by containerId.
 */
private List<TaskGroup> getOrderedContainers(Map<String, String> taskToContainerId) {
 log.debug("Got task to container map: {}", taskToContainerId);
 // Group tasks by container Id
 HashMap<String, List<String>> containerIdToTaskNames = new HashMap<>();
 for (Map.Entry<String, String> entry : taskToContainerId.entrySet()) {
  String taskName = entry.getKey();
  String containerId = entry.getValue();
  List<String> taskNames = containerIdToTaskNames.get(containerId);
  if (taskNames == null) {
   taskNames = new ArrayList<>();
   containerIdToTaskNames.put(containerId, taskNames);
  }
  taskNames.add(taskName);
 }
 // Build container tasks
 List<TaskGroup> containerTasks = new ArrayList<>(containerIdToTaskNames.size());
 for (int i = 0; i < containerIdToTaskNames.size(); i++) {
  if (containerIdToTaskNames.get(String.valueOf(i)) == null) throw new IllegalStateException("Task mapping is missing container: " + i);
  containerTasks.add(new TaskGroup(String.valueOf(i), containerIdToTaskNames.get(String.valueOf(i))));
 }
 return containerTasks;
}
origin: org.apache.samza/samza-core_2.11

for (int i = 0; i < prevContainerCount; i++) {
 TaskGroup taskGroup = containers.get(i);
 while (taskGroup.size() > expectedTaskCountPerContainer[i]) {
  taskNamesToReassign.add(taskGroup.removeTask());
origin: org.apache.samza/samza-core

for (int i = 0; i < prevContainerCount; i++) {
 TaskGroup taskGroup = containers.get(i);
 while (taskGroup.size() > expectedTaskCountPerContainer[i]) {
  taskNamesToReassign.add(taskGroup.removeTask());
origin: org.apache.samza/samza-core_2.12

for (int i = 0; i < prevContainerCount; i++) {
 TaskGroup taskGroup = containers.get(i);
 while (taskGroup.size() > expectedTaskCountPerContainer[i]) {
  taskNamesToReassign.add(taskGroup.removeTask());
origin: org.apache.samza/samza-core_2.10

for (int i = 0; i < prevContainerCount; i++) {
 TaskGroup taskGroup = containers.get(i);
 while (taskGroup.size() > expectedTaskCountPerContainer[i]) {
  taskNamesToReassign.add(taskGroup.removeTask());
origin: org.apache.samza/samza-core_2.12

/**
 * Converts the task->containerId map to an ordered list of {@link TaskGroup} instances.
 *
 * @param taskToContainerId a map from each task name to the containerId to which it is assigned.
 * @return                  a list of TaskGroups ordered ascending by containerId.
 */
private List<TaskGroup> getOrderedContainers(Map<String, String> taskToContainerId) {
 log.debug("Got task to container map: {}", taskToContainerId);
 // Group tasks by container Id
 HashMap<String, List<String>> containerIdToTaskNames = new HashMap<>();
 for (Map.Entry<String, String> entry : taskToContainerId.entrySet()) {
  String taskName = entry.getKey();
  String containerId = entry.getValue();
  List<String> taskNames = containerIdToTaskNames.get(containerId);
  if (taskNames == null) {
   taskNames = new ArrayList<>();
   containerIdToTaskNames.put(containerId, taskNames);
  }
  taskNames.add(taskName);
 }
 // Build container tasks
 List<TaskGroup> containerTasks = new ArrayList<>(containerIdToTaskNames.size());
 for (int i = 0; i < containerIdToTaskNames.size(); i++) {
  if (containerIdToTaskNames.get(String.valueOf(i)) == null) throw new IllegalStateException("Task mapping is missing container: " + i);
  containerTasks.add(new TaskGroup(String.valueOf(i), containerIdToTaskNames.get(String.valueOf(i))));
 }
 return containerTasks;
}
origin: org.apache.samza/samza-core

/**
 * Converts the task->containerId map to an ordered list of {@link TaskGroup} instances.
 *
 * @param taskToContainerId a map from each task name to the containerId to which it is assigned.
 * @return                  a list of TaskGroups ordered ascending by containerId.
 */
private List<TaskGroup> getOrderedContainers(Map<String, String> taskToContainerId) {
 log.debug("Got task to container map: {}", taskToContainerId);
 // Group tasks by container Id
 HashMap<String, List<String>> containerIdToTaskNames = new HashMap<>();
 for (Map.Entry<String, String> entry : taskToContainerId.entrySet()) {
  String taskName = entry.getKey();
  String containerId = entry.getValue();
  List<String> taskNames = containerIdToTaskNames.get(containerId);
  if (taskNames == null) {
   taskNames = new ArrayList<>();
   containerIdToTaskNames.put(containerId, taskNames);
  }
  taskNames.add(taskName);
 }
 // Build container tasks
 List<TaskGroup> containerTasks = new ArrayList<>(containerIdToTaskNames.size());
 for (int i = 0; i < containerIdToTaskNames.size(); i++) {
  if (containerIdToTaskNames.get(String.valueOf(i)) == null) throw new IllegalStateException("Task mapping is missing container: " + i);
  containerTasks.add(new TaskGroup(String.valueOf(i), containerIdToTaskNames.get(String.valueOf(i))));
 }
 return containerTasks;
}
origin: org.apache.samza/samza-core_2.11

/**
 * Converts the task->containerId map to an ordered list of {@link TaskGroup} instances.
 *
 * @param taskToContainerId a map from each task name to the containerId to which it is assigned.
 * @return                  a list of TaskGroups ordered ascending by containerId.
 */
private List<TaskGroup> getOrderedContainers(Map<String, String> taskToContainerId) {
 log.debug("Got task to container map: {}", taskToContainerId);
 // Group tasks by container Id
 HashMap<String, List<String>> containerIdToTaskNames = new HashMap<>();
 for (Map.Entry<String, String> entry : taskToContainerId.entrySet()) {
  String taskName = entry.getKey();
  String containerId = entry.getValue();
  List<String> taskNames = containerIdToTaskNames.get(containerId);
  if (taskNames == null) {
   taskNames = new ArrayList<>();
   containerIdToTaskNames.put(containerId, taskNames);
  }
  taskNames.add(taskName);
 }
 // Build container tasks
 List<TaskGroup> containerTasks = new ArrayList<>(containerIdToTaskNames.size());
 for (int i = 0; i < containerIdToTaskNames.size(); i++) {
  if (containerIdToTaskNames.get(String.valueOf(i)) == null) throw new IllegalStateException("Task mapping is missing container: " + i);
  containerTasks.add(new TaskGroup(String.valueOf(i), containerIdToTaskNames.get(String.valueOf(i))));
 }
 return containerTasks;
}
origin: org.apache.samza/samza-core

/**
 * Assigns tasks from the specified list to containers that have fewer containers than indicated
 * in taskCountPerContainer.
 *
 * @param taskCountPerContainer the expected number of tasks for each container.
 * @param taskNamesToAssign     the list of tasks to assign to the containers.
 * @param containers            the containers (as {@link TaskGroup}) to which the tasks will be assigned.
 */
// TODO: Change logic from using int arrays to a Map<String, Integer> (id -> taskCount)
private void assignTasksToContainers(int[] taskCountPerContainer, List<String> taskNamesToAssign,
  List<TaskGroup> containers) {
 for (TaskGroup taskGroup : containers) {
  for (int j = taskGroup.size(); j < taskCountPerContainer[Integer.valueOf(taskGroup.getContainerId())]; j++) {
   String taskName = taskNamesToAssign.remove(0);
   taskGroup.addTaskName(taskName);
   log.info("Assigned task {} to container {}", taskName, taskGroup.getContainerId());
  }
 }
}
origin: org.apache.samza/samza-core_2.11

/**
 * Creates a list of empty {@link TaskGroup} instances for a range of container id's
 * from the start(inclusive) to end(exclusive) container id.
 *
 * @param startContainerId  the first container id for which a TaskGroup is needed.
 * @param endContainerId    the first container id AFTER the last TaskGroup that is needed.
 * @return                  a set of empty TaskGroup instances corresponding to the range
 *                          [startContainerId, endContainerId)
 */
private List<TaskGroup> createContainers(int startContainerId, int endContainerId) {
 List<TaskGroup> containers = new ArrayList<>(endContainerId - startContainerId);
 for (int i = startContainerId; i < endContainerId; i++) {
  TaskGroup taskGroup = new TaskGroup(String.valueOf(i), new ArrayList<String>());
  containers.add(taskGroup);
 }
 return containers;
}
origin: org.apache.samza/samza-core_2.10

/**
 * Creates a list of empty {@link TaskGroup} instances for a range of container id's
 * from the start(inclusive) to end(exclusive) container id.
 *
 * @param startContainerId  the first container id for which a TaskGroup is needed.
 * @param endContainerId    the first container id AFTER the last TaskGroup that is needed.
 * @return                  a set of empty TaskGroup instances corresponding to the range
 *                          [startContainerId, endContainerId)
 */
private List<TaskGroup> createContainers(int startContainerId, int endContainerId) {
 List<TaskGroup> containers = new ArrayList<>(endContainerId - startContainerId);
 for (int i = startContainerId; i < endContainerId; i++) {
  TaskGroup taskGroup = new TaskGroup(String.valueOf(i), new ArrayList<String>());
  containers.add(taskGroup);
 }
 return containers;
}
origin: org.apache.samza/samza-core_2.12

/**
 * Assigns tasks from the specified list to containers that have fewer containers than indicated
 * in taskCountPerContainer.
 *
 * @param taskCountPerContainer the expected number of tasks for each container.
 * @param taskNamesToAssign     the list of tasks to assign to the containers.
 * @param containers            the containers (as {@link TaskGroup}) to which the tasks will be assigned.
 */
// TODO: Change logic from using int arrays to a Map<String, Integer> (id -> taskCount)
private void assignTasksToContainers(int[] taskCountPerContainer, List<String> taskNamesToAssign,
  List<TaskGroup> containers) {
 for (TaskGroup taskGroup : containers) {
  for (int j = taskGroup.size(); j < taskCountPerContainer[Integer.valueOf(taskGroup.getContainerId())]; j++) {
   String taskName = taskNamesToAssign.remove(0);
   taskGroup.addTaskName(taskName);
   log.info("Assigned task {} to container {}", taskName, taskGroup.getContainerId());
  }
 }
}
origin: org.apache.samza/samza-core_2.11

/**
 * Assigns tasks from the specified list to containers that have fewer containers than indicated
 * in taskCountPerContainer.
 *
 * @param taskCountPerContainer the expected number of tasks for each container.
 * @param taskNamesToAssign     the list of tasks to assign to the containers.
 * @param containers            the containers (as {@link TaskGroup}) to which the tasks will be assigned.
 */
// TODO: Change logic from using int arrays to a Map<String, Integer> (id -> taskCount)
private void assignTasksToContainers(int[] taskCountPerContainer, List<String> taskNamesToAssign,
  List<TaskGroup> containers) {
 for (TaskGroup taskGroup : containers) {
  for (int j = taskGroup.size(); j < taskCountPerContainer[Integer.valueOf(taskGroup.getContainerId())]; j++) {
   String taskName = taskNamesToAssign.remove(0);
   taskGroup.addTaskName(taskName);
   log.info("Assigned task {} to container {}", taskName, taskGroup.getContainerId());
  }
 }
}
origin: org.apache.samza/samza-core

/**
 * Creates a list of empty {@link TaskGroup} instances for a range of container id's
 * from the start(inclusive) to end(exclusive) container id.
 *
 * @param startContainerId  the first container id for which a TaskGroup is needed.
 * @param endContainerId    the first container id AFTER the last TaskGroup that is needed.
 * @return                  a set of empty TaskGroup instances corresponding to the range
 *                          [startContainerId, endContainerId)
 */
private List<TaskGroup> createContainers(int startContainerId, int endContainerId) {
 List<TaskGroup> containers = new ArrayList<>(endContainerId - startContainerId);
 for (int i = startContainerId; i < endContainerId; i++) {
  TaskGroup taskGroup = new TaskGroup(String.valueOf(i), new ArrayList<String>());
  containers.add(taskGroup);
 }
 return containers;
}
origin: org.apache.samza/samza-core_2.12

/**
 * Creates a list of empty {@link TaskGroup} instances for a range of container id's
 * from the start(inclusive) to end(exclusive) container id.
 *
 * @param startContainerId  the first container id for which a TaskGroup is needed.
 * @param endContainerId    the first container id AFTER the last TaskGroup that is needed.
 * @return                  a set of empty TaskGroup instances corresponding to the range
 *                          [startContainerId, endContainerId)
 */
private List<TaskGroup> createContainers(int startContainerId, int endContainerId) {
 List<TaskGroup> containers = new ArrayList<>(endContainerId - startContainerId);
 for (int i = startContainerId; i < endContainerId; i++) {
  TaskGroup taskGroup = new TaskGroup(String.valueOf(i), new ArrayList<String>());
  containers.add(taskGroup);
 }
 return containers;
}
origin: org.apache.samza/samza-core_2.10

/**
 * Assigns tasks from the specified list to containers that have fewer containers than indicated
 * in taskCountPerContainer.
 *
 * @param taskCountPerContainer the expected number of tasks for each container.
 * @param taskNamesToAssign     the list of tasks to assign to the containers.
 * @param containers            the containers (as {@link TaskGroup}) to which the tasks will be assigned.
 */
// TODO: Change logic from using int arrays to a Map<String, Integer> (id -> taskCount)
private void assignTasksToContainers(int[] taskCountPerContainer, List<String> taskNamesToAssign,
  List<TaskGroup> containers) {
 for (TaskGroup taskGroup : containers) {
  for (int j = taskGroup.size(); j < taskCountPerContainer[Integer.valueOf(taskGroup.getContainerId())]; j++) {
   String taskName = taskNamesToAssign.remove(0);
   taskGroup.addTaskName(taskName);
   log.info("Assigned task {} to container {}", taskName, taskGroup.getContainerId());
  }
 }
}
org.apache.samza.container.grouper.taskGroupByContainerCount$TaskGroup

Javadoc

A mutable group of tasks and an associated container id. Used as a temporary mutable container until the final ContainerModel is known.

Most used methods

  • <init>
  • addTaskName
  • getContainerId
  • removeTask
  • size

Popular in Java

  • Making http post requests using okhttp
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • getContentResolver (Context)
  • Menu (java.awt)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now