Get a new packing plan given an existing packing plan and component-level changes.

@return new packing plan
518097
@Override
  public PackingPlan repack(PackingPlan currentPackingPlan, Map<String, Integer> componentChanges) {
    this.numContainers = currentPackingPlan.getContainers().size();
    resetToFirstContainer();

    int additionalContainers = computeNumAdditionalContainers(componentChanges, currentPackingPlan);
    if (additionalContainers > 0) {
      increaseNumContainers(additionalContainers);
      LOG.info(String.format(
          "Allocated %s additional containers for repack bring the number of containers to %s.",
          additionalContainers, this.numContainers));
    }

    while (true) {
      try {
        PackingPlanBuilder planBuilder = newPackingPlanBuilder(currentPackingPlan);
        planBuilder.updateNumContainers(numContainers);
        planBuilder = getResourceCompliantRRAllocation(planBuilder, componentChanges);

        return planBuilder.build();

      } catch (ConstraintViolationException e) {
        //Not enough containers. Adjust the number of containers.
        LOG.info(String.format(
            "%s Increasing the number of containers to %s and attempting to repack again.",
            e.getMessage(), this.numContainers + 1));
        retryWithAdditionalContainer();
      }
    }
  }
209478
public static Map.Entry<String, Map<String, ?>> currentPackageCommand() {
        return new AbstractMap.SimpleEntry<>(GET_CURRENT_PACKAGE, ImmutableMap.of());
    }
1119642
protected AbcTuneBook newAbcTuneBook() {
		AbcTuneBook ret = new AbcTuneBook();
		for (int i = 0; i < m_listeners.size(); i++) {
			Object o = m_listeners.get(i);
			if (o instanceof TuneBookListenerInterface)
				ret.addListener((TuneBookListenerInterface) o);
		}
		return ret;
	}
34369
public Map<K2, V> getOrPutGetNew(K1 key1,
            Supplier<Map<K2, V>> newMapSupplier) {
        return JMMap.getOrPutGetNew(nestedMap, key1, newMapSupplier);
    }
93462
private PackingPlanBuilder getResourceCompliantRRAllocation(
      PackingPlanBuilder planBuilder, Map<String, Integer> componentChanges)
      throws ConstraintViolationException {

    Map<String, Integer> componentsToScaleDown =
        PackingUtils.getComponentsToScale(componentChanges, PackingUtils.ScalingDirection.DOWN);
    Map<String, Integer> componentsToScaleUp =
        PackingUtils.getComponentsToScale(componentChanges, PackingUtils.ScalingDirection.UP);

    if (!componentsToScaleDown.isEmpty()) {
      resetToFirstContainer();
      removeInstancesFromContainers(planBuilder, componentsToScaleDown);
    }

    if (!componentsToScaleUp.isEmpty()) {
      resetToFirstContainer();
      assignInstancesToContainers(planBuilder, componentsToScaleUp, PolicyType.FLEXIBLE);
    }
    return planBuilder;
  }
1212723
Optional<PackingPlan.InstancePlan> getInstance(String componentName, int componentIndex) {
    for (PackingPlan.InstancePlan instancePlan : this.instances) {
      if (instancePlan.getComponentName().equals(componentName)
          && instancePlan.getComponentIndex() == componentIndex) {
        return Optional.of(instancePlan);
      }
    }
    return Optional.absent();
  }
146718
public Config createConfigWithPackingDetails(Config runtime, PackingPlan packing) {
    return Config.newBuilder()
        .putAll(runtime)
        .put(Key.COMPONENT_RAMMAP, packing.getComponentRamDistribution())
        .put(Key.NUM_CONTAINERS, 1 + packing.getContainers().size())
        .build();
  }
1372465
public PlainChangesLog getChanges()
   {

      Collections.sort(changesLog.getAllStates(), new PathSorter());

      if (LOG.isDebugEnabled())
      {
         StringBuilder str = new StringBuilder();
         for (int i = 0; i < changesLog.getAllStates().size(); i++)
         {
            str.append(" ").append(ItemState.nameFromValue(changesLog.getAllStates().get(i).getState())).append("\t\t");
            str.append(changesLog.getAllStates().get(i).getData().getIdentifier()).append("\t").append("isPersisted=");
            str.append(changesLog.getAllStates().get(i).isPersisted()).append("\t").append("isEventFire=");
            str.append(changesLog.getAllStates().get(i).isEventFire()).append("\t").append("isInternallyCreated=");
            str.append(changesLog.getAllStates().get(i).isInternallyCreated()).append("\t");
            str.append(changesLog.getAllStates().get(i).getData().getQPath().getAsString()).append("\n");
         }
         LOG.debug(str);
      }
      if (isNeedReloadAncestorToSave)
      {
         PlainChangesLogImpl newChangesLog = new PlainChangesLogImpl();
         for (ItemState itemState : changesLog.getAllStates())
         {
            newChangesLog.add(new ItemState(itemState.getData(), itemState.getState(), itemState.isEventFire(),
               ancestorToSave, itemState.isInternallyCreated(), itemState.isPersisted(), itemState.getOldPath()));
         }
         changesLog.clear();
         changesLog.addAll(newChangesLog.getAllStates());
         isNeedReloadAncestorToSave = false;
      }
      return changesLog;
   }
1203044
public MultipartConfigElement createMultipartConfig() {
		long maxFileSizeBytes = convertToBytes(this.maxFileSize, -1);
		long maxRequestSizeBytes = convertToBytes(this.maxRequestSize, -1);
		long fileSizeThresholdBytes = convertToBytes(this.fileSizeThreshold, 0);
		return new MultipartConfigElement(this.location, maxFileSizeBytes,
				maxRequestSizeBytes, (int) fileSizeThresholdBytes);
	}
1249552
@Override
    public DeploymentPlanBuilder andRemoveUndeployed() {
        DeploymentActionImpl removeMod = DeploymentActionImpl.getRemoveAction(replacementModification.getReplacedDeploymentUnitUniqueName());
        return new DeploymentPlanBuilderImpl(this, removeMod);
    }
1069602
private int computeNumAdditionalContainers(Map<String, Integer> componentChanges,
                                             PackingPlan packingPlan) {

    Resource scaleDownResource = PackingUtils.computeTotalResourceChange(topology, componentChanges,
        defaultInstanceResources, PackingUtils.ScalingDirection.DOWN);
    Resource scaleUpResource = PackingUtils.computeTotalResourceChange(topology, componentChanges,
        defaultInstanceResources, PackingUtils.ScalingDirection.UP);
    Resource additionalResource = scaleUpResource.subtractAbsolute(scaleDownResource);
    return (int) additionalResource.divideBy(packingPlan.getMaxContainerResources());
  }
52534
public List<ChangesContainer> getSortedList()
   {
      List<ChangesContainer> changesContainers = new ArrayList<ChangesContainer>(changes);
      Collections.sort(changesContainers);
      return changesContainers;
   }
436614
public static Planner newPlanner() {
		QueryPlanner qplanner;
		UpdatePlanner uplanner;

		try {
			qplanner = (QueryPlanner) queryPlannerCls.newInstance();
			uplanner = (UpdatePlanner) updatePlannerCls.newInstance();
		} catch (InstantiationException | IllegalAccessException e) {
			e.printStackTrace();
			return null;
		}

		return new Planner(qplanner, uplanner);
	}
1264464
public static TransactionEdit createCommitting(long writePointer, Set<ChangeId> changes) {
    return new TransactionEdit(writePointer, 0L, State.COMMITTING, 0L, changes, 0L, false, null, null, 0L, 0L, null);
  }
420690
public Properties<PartitionPlan<T>> getOrCreateProperties()
   {
      List<Node> nodeList = childNode.get("properties");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new PropertiesImpl<PartitionPlan<T>>(this, "properties", childNode, nodeList.get(0));
      }
      return createProperties();
   }
1118994
public Resource getTotalUsedResources() {
    return getInstances().stream()
        .map(PackingPlan.InstancePlan::getResource)
        .reduce(Resource.EMPTY_RESOURCE, Resource::plus)
        .plus(getPadding());
  }
547719
public static BlankFragment newInstance() {
        BlankFragment fragment = new BlankFragment();
        Bundle args = new Bundle();

        fragment.setArguments(args);
        return fragment;
    }