示例#1
1
  /**
   * reads all methods by the action-annotations for building agent-actions
   *
   * @param p_class class
   * @param p_root root class
   * @return stream of all methods with inheritance
   */
  private static Stream<Method> methods(final Class<?> p_class, final Class<?> p_root) {
    final Pair<Boolean, IAgentAction.EAccess> l_classannotation = CCommon.isActionClass(p_class);
    if (!l_classannotation.getLeft())
      return p_class.getSuperclass() == null
          ? Stream.of()
          : methods(p_class.getSuperclass(), p_root);

    final Predicate<Method> l_filter =
        IAgentAction.EAccess.WHITELIST.equals(l_classannotation.getRight())
            ? i -> !CCommon.isActionFiltered(i, p_root)
            : i -> CCommon.isActionFiltered(i, p_root);

    return Stream.concat(
        Arrays.stream(p_class.getDeclaredMethods())
            .parallel()
            .map(
                i -> {
                  i.setAccessible(true);
                  return i;
                })
            .filter(i -> !Modifier.isAbstract(i.getModifiers()))
            .filter(i -> !Modifier.isInterface(i.getModifiers()))
            .filter(i -> !Modifier.isNative(i.getModifiers()))
            .filter(i -> !Modifier.isStatic(i.getModifiers()))
            .filter(l_filter),
        methods(p_class.getSuperclass(), p_root));
  }
  @Override
  public void type(
      Resource type,
      List<Pair<Resource, XSDDatatype>> simpleProperties,
      List<Pair<Resource, Object>> linkProperties,
      List<Pair<Resource, String>> geometryProperties)
      throws IOException {
    requestResponse.setFeatureIri(type);

    log.debug("[fe] registering (generic) output type for " + type);

    /*
     * List<String> layerSelectedProperties = layer
     * .getSelectedFeatureParams(session.getLanguage());
     */
    selectedProperties.add(0, "__fid");
    log.debug("- Property:" + "__fid" + " as 0");
    for (Pair<Resource, XSDDatatype> prop : simpleProperties) {

      log.debug("- Property:" + prop.getKey() + " as " + selectedProperties.size());
      selectedPropertiesIndex.put(prop.getKey(), selectedProperties.size());
      selectedProperties.add(prop.getKey().getLocalPart());
    }
    selectedProperties.add("__centerX");
    log.debug("- Property:" + "__centerX" + " as " + selectedProperties.size());
    selectedProperties.add("__centerY");
    log.debug("- Property:" + "__centerY" + " as " + selectedProperties.size());
  }
 @Override
 public void doGet(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
   res.setContentType("application/json");
   Pair<DateTime, DateTime> fromTo = fromTo(req);
   orla.writeHourlyPercentiles(res.getOutputStream(), fromTo.getLeft(), fromTo.getRight());
 }
  private SpillableSetImpl<V> getHelper(@NotNull K key) {
    SpillableSetImpl<V> spillableSet = cache.get(key);

    if (spillableSet == null) {
      long keyTime = -1;
      Pair<Integer, V> meta;
      if (timeExtractor != null) {
        keyTime = timeExtractor.getTime(key);
      }
      meta = map.get(key);

      if (meta == null) {
        return null;
      }

      Slice keyPrefix = keyValueSerdeManager.serializeDataKey(key, false);
      if (timeExtractor != null) {
        spillableSet =
            new SpillableSetImpl<>(
                keyPrefix.toByteArray(), store, valueSerde, new FixedTimeExtractor(keyTime));
      } else {
        spillableSet = new SpillableSetImpl<>(bucket, keyPrefix.toByteArray(), store, valueSerde);
      }
      spillableSet.setSize(meta.getLeft());
      spillableSet.setHead(meta.getRight());
      spillableSet.setup(context);
    }

    cache.put(key, spillableSet);

    return spillableSet;
  }
  /* (non-Javadoc)
   * @see forge.control.home.IControlSubmenu#update()
   */
  @Override
  public void update() {
    updating =
        true; // prevent itemStateChanged causing prefs to be saved or other logic occurring while
    // updating values

    this.view = VSubmenuPreferences.SINGLETON_INSTANCE;
    this.prefs = FModel.getPreferences();

    setPlayerNameButtonText();
    view.getCbDevMode().setSelected(ForgePreferences.DEV_MODE);
    view.getCbEnableMusic().setSelected(prefs.getPrefBoolean(FPref.UI_ENABLE_MUSIC));

    for (final Pair<JCheckBox, FPref> kv : lstControls) {
      kv.getKey().setSelected(prefs.getPrefBoolean(kv.getValue()));
    }
    view.reloadShortcuts();

    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            view.getCbRemoveSmall().requestFocusInWindow();
          }
        });

    updating = false;
  }
示例#6
0
 @Override
 public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(
     TransformType cameraTransformType) {
   if (transforms.isEmpty()) return Pair.of(this, null);
   Pair<Baked, TRSRTransformation> p = transforms.get(cameraTransformType);
   return Pair.of(p.getLeft(), p.getRight().getMatrix());
 }
  @SideOnly(Side.CLIENT)
  private static Pair<String, KnowledgeObject<?>> getObject(char type, String identifier) {
    KnowledgeObject<?> obj = null;
    String text = null;

    boolean isHEE = identifier.charAt(0) == '~' && identifier.length() > 1;
    if (isHEE) identifier = identifier.substring(1);

    switch (type) {
      case 'b':
      case 'i':
        int metaIndex = identifier.indexOf('/'), meta = 0;

        if (metaIndex != -1 && metaIndex + 1 < identifier.length()) {
          meta = DragonUtil.tryParse(identifier.substring(metaIndex + 1), 0);
          identifier = identifier.substring(0, metaIndex);
        }

        Item item =
            GameRegistry.findItem(isHEE ? "HardcoreEnderExpansion" : "minecraft", identifier);

        if (item != null) {
          text =
              StatCollector.translateToLocal(
                  item.getUnlocalizedName(new ItemStack(item, 1, meta)) + ".name");
          obj =
              KnowledgeObject.fromObject(
                  type == 'b'
                      ? (item instanceof ItemBlock
                          ? new BlockInfo(((ItemBlock) item).field_150939_a, meta)
                          : null)
                      : item);
        }

        break;

      case 'e':
        if (isHEE)
          text =
              ItemSpawnEggs.getMobName(
                  (Class<?>)
                      EntityList.stringToClassMapping.get(
                          identifier = ("HardcoreEnderExpansion." + identifier)));
        else text = StatCollector.translateToLocal("entity." + identifier + ".name");

        Class<?> cls = (Class<?>) EntityList.stringToClassMapping.get(identifier);
        if (cls != null) obj = KnowledgeObject.fromObject(cls);
        break;

      case 'd':
        obj = KnowledgeObject.fromObject(identifier);
        if (obj != null) text = obj.getTranslatedTooltip();
        break;
    }

    if (text == null || obj == null) {
      Log.warn("Invalid object type or identifier: $0:$1", type, identifier);
      return Pair.<String, KnowledgeObject<?>>of(text == null ? identifier : text, obj);
    } else return Pair.<String, KnowledgeObject<?>>of(text, obj);
  }
示例#8
0
  @Override
  public IFlexibleBakedModel bake(
      IModelState state,
      VertexFormat format,
      Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
    IFlexibleBakedModel bakedBase = null;

    if (base != null) bakedBase = base.bake(state, format, bakedTextureGetter);

    ImmutableMap.Builder<String, IFlexibleBakedModel> mapBuilder = ImmutableMap.builder();

    for (Entry<String, Pair<IModel, IModelState>> entry : parts.entrySet()) {
      Pair<IModel, IModelState> pair = entry.getValue();
      mapBuilder.put(
          entry.getKey(), pair.getLeft().bake(pair.getRight(), format, bakedTextureGetter));
    }

    if (bakedBase == null && parts.isEmpty()) {
      FMLLog.log(
          Level.ERROR,
          "MultiModel %s is empty (no base model or parts were provided/resolved)",
          location);
      IModel missing = ModelLoaderRegistry.getMissingModel();
      return missing.bake(missing.getDefaultState(), format, bakedTextureGetter);
    }
    return new Baked(location, true, bakedBase, mapBuilder.build());
  }
示例#9
0
  /**
   * Extract the text from a HTML based string. This is similar to what HTML.fromHtml(...) does, but
   * this method also removes the embedded images instead of replacing them by a small rectangular
   * representation character.
   *
   * @param html
   * @return
   */
  public static String extractText(CharSequence html) {
    String result = html.toString();

    // recognize images in textview HTML contents
    if (html instanceof Spanned) {
      Spanned text = (Spanned) html;
      Object[] styles = text.getSpans(0, text.length(), Object.class);
      ArrayList<Pair<Integer, Integer>> removals = new ArrayList<Pair<Integer, Integer>>();
      for (Object style : styles) {
        if (style instanceof ImageSpan) {
          int start = text.getSpanStart(style);
          int end = text.getSpanEnd(style);
          removals.add(Pair.of(start, end));
        }
      }

      // sort reversed and delete image spans
      Collections.sort(
          removals,
          new Comparator<Pair<Integer, Integer>>() {

            @Override
            public int compare(Pair<Integer, Integer> lhs, Pair<Integer, Integer> rhs) {
              return rhs.getRight().compareTo(lhs.getRight());
            }
          });
      result = text.toString();
      for (Pair<Integer, Integer> removal : removals) {
        result = result.substring(0, removal.getLeft()) + result.substring(removal.getRight());
      }
    }

    // some line breaks are still in the text, source is unknown
    return StringUtils.replace(result, "<br />", "\n").trim();
  }
示例#10
0
  /**
   * Given a frontA with point [2,3] and a frontB with point [1,2], the value of the
   * setCoverage(frontA, frontB) == 0 and setCoverage(frontB, frontA) == 1
   */
  @Test
  public void shouldExecuteReturnTheRightValueIfTheFrontsContainOnePointWhichIsNotTheSame() {
    int numberOfPoints = 1;
    int numberOfDimensions = 2;
    Front frontA = new ArrayFront(numberOfPoints, numberOfDimensions);
    Front frontB = new ArrayFront(numberOfPoints, numberOfDimensions);

    Point point1 = new ArrayPoint(numberOfDimensions);
    point1.setDimensionValue(0, 2.0);
    point1.setDimensionValue(1, 3.0);
    Point point2 = new ArrayPoint(numberOfDimensions);
    point2.setDimensionValue(0, 1.0);
    point2.setDimensionValue(1, 2.0);

    frontA.setPoint(0, point1);
    frontB.setPoint(0, point2);

    Pair<Double, Double> result =
        setCoverage.evaluate(
            new ImmutablePair(
                FrontUtils.convertFrontToSolutionList(frontA),
                FrontUtils.convertFrontToSolutionList(frontB)));

    assertEquals(0.0, result.getLeft(), EPSILON);
    assertEquals(1.0, result.getRight(), EPSILON);
  }
示例#11
0
  public static int getReadCoordinateForReferenceCoordinate(
      final int alignmentStart,
      final Cigar cigar,
      final int refCoord,
      final ClippingTail tail,
      final boolean allowGoalNotReached) {
    final Pair<Integer, Boolean> result =
        getReadCoordinateForReferenceCoordinate(
            alignmentStart, cigar, refCoord, allowGoalNotReached);
    int readCoord = result.getLeft();

    // Corner case one: clipping the right tail and falls on deletion, move to the next
    // read coordinate. It is not a problem for the left tail because the default answer
    // from getReadCoordinateForReferenceCoordinate is to give the previous read coordinate.
    if (result.getRight() && tail == ClippingTail.RIGHT_TAIL) {
      readCoord++;
    }

    // clipping the left tail and first base is insertion, go to the next read coordinate
    // with the same reference coordinate. Advance to the next cigar element, or to the
    // end of the read if there is no next element.
    final CigarElement firstElementIsInsertion = readStartsWithInsertion(cigar);
    if (readCoord == 0 && tail == ClippingTail.LEFT_TAIL && firstElementIsInsertion != null) {
      readCoord = Math.min(firstElementIsInsertion.getLength(), cigar.getReadLength() - 1);
    }

    return readCoord;
  }
 @Test
 public void testMapRowTo3() throws Exception {
   RowReaderFactory<SampleJavaBean> rrf =
       mapRowTo(SampleJavaBean.class, Pair.of("a", "b"), Pair.of("c", "d"));
   assertThat(rrf, instanceOf(ClassBasedRowReaderFactory.class));
   assertThat(rrf.targetClass().getName(), is(SampleJavaBean.class.getName()));
 }
        @Override
        public void call(MessageRunner runner) {
          ItemPattern pattern = runner.<ItemPattern>getValue("pattern");

          WeightedItemList list = OrbAcquirableItems.idList;
          int size = list.size(), damageRemoved = 0;

          for (Iterator<WeightedItem> iter = list.iterator(); iter.hasNext(); ) {
            Pair<Integer, Boolean> info = iter.next().runBlacklistPattern(pattern);

            if (info.getRight()) iter.remove();
            damageRemoved += info.getLeft();
          }

          size = size - list.size();

          if (size == 0 && damageRemoved == 0)
            MessageLogger.logWarn("Did not find any items to remove.");
          else if (size == 0)
            MessageLogger.logOk("Removed $0 damage value(s) from items.", damageRemoved);
          else
            MessageLogger.logOk(
                "Removed $0 item(s) and $1 damage value(s) in total.", size, damageRemoved);

          if (list.size() == 0)
            MessageLogger.logWarn("No items left in the list, falling back to generic chest loot.");
        }
  protected void enumerate(CandidateHostInfo hostInfo) {
    log.debug(
        "Enumerating canditates hostId [{}] pools {}", hostInfo.getHostId(), hostInfo.getPoolIds());

    Long candidateHostId = this.hosts ? hostInfo.getHostId() : null;
    Map<Pair<Class<?>, Long>, Object> cache = new HashMap<Pair<Class<?>, Long>, Object>();

    if (volumeIds.size() == 0) {
      pushCandidate(
          new AllocationCandidate(
              objectManager,
              cache,
              candidateHostId,
              hostInfo.getHostUuid(),
              hostInfo.getUsedPorts(),
              Collections.<Long, Long>emptyMap()));
    }

    for (List<Pair<Long, Long>> pairs : traverse(volumeIds, hostInfo.getPoolIds())) {
      Map<Long, Long> volumeToPool = new HashMap<Long, Long>();
      for (Pair<Long, Long> pair : pairs) {
        volumeToPool.put(pair.getLeft(), pair.getRight());
      }

      pushCandidate(
          new AllocationCandidate(
              objectManager,
              cache,
              candidateHostId,
              hostInfo.getHostUuid(),
              hostInfo.getUsedPorts(),
              volumeToPool));
    }
  }
  @Override
  public Pair<IBakedModel, Matrix4f> handlePerspective(
      ItemCameraTransforms.TransformType cameraTransformType) {
    // gui renders as 2D sprite; this is apparently also what renders when the item is dropped
    if (cameraTransformType == ItemCameraTransforms.TransformType.GUI) {
      RenderItem.applyVanillaTransform(baseModel.getItemCameraTransforms().gui);
      return Pair.of(baseModel, null);
    }

    GlStateManager.pushMatrix();
    GL11.glScalef(0.1F, 0.1F, 0.1F);
    switch (cameraTransformType) {
      case FIRST_PERSON:
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-40.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.75F, 1.5F, 0.5F);
        break;
      case THIRD_PERSON:
        GlStateManager.rotate(100.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(90.0F, 0F, 1.0F, 0.0F);
        GlStateManager.translate(0.3F, -0.3F, 0.2F);
        GlStateManager.scale(0.5F, 0.5F, 0.5F);
        break;
      default:
        break;
    }
    Minecraft.getMinecraft().getTextureManager().bindTexture(getTexture1());
    // first Entity parameter not used for anything in ModelLegendsSword, so null is safe
    swordModel.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0475F);
    GlStateManager.popMatrix();
    // return empty model to render nothing - bomb model already rendered
    return Pair.of(emptyModel, null);
  }
示例#16
0
  @SuppressWarnings("unchecked")
  @Override
  protected final void completeInitializationOp(Object[] os) throws HiveException {
    if (os.length != 0) {
      Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]> pair =
          (Pair<MapJoinTableContainer[], MapJoinTableContainerSerDe[]>) os[0];

      boolean spilled = false;
      for (MapJoinTableContainer container : pair.getLeft()) {
        if (container != null) {
          spilled = spilled || container.hasSpill();
        }
      }

      if (!loadCalled && spilled) {
        // we can't use the cached table because it has spilled.
        loadHashTable(getExecContext(), MapredContext.get());
      } else {
        // let's use the table from the cache.
        mapJoinTables = pair.getLeft();
        mapJoinTableSerdes = pair.getRight();
      }
      hashTblInitedOnce = true;
    }

    if (this.getExecContext() != null) {
      // reset exec context so that initialization of the map operator happens
      // properly
      this.getExecContext().setLastInputPath(null);
      this.getExecContext().setCurrentInputPath(null);
    }
  }
    @Override
    public int compare(Pair<BlockPos, IBlockState> o1, Pair<BlockPos, IBlockState> o2) {
      IBlockState s1 = o1.getRight();
      IBlockState s2 = o2.getRight();

      return ((ITinkerStationBlock) s2.getBlock()).getGuiNumber(s2)
          - ((ITinkerStationBlock) s1.getBlock()).getGuiNumber(s1);
    }
 @Override
 public boolean containsKey(Object key) {
   if (cache.contains((K) key)) {
     return true;
   }
   Pair<Integer, V> meta = map.get((K) key);
   return meta != null && meta.getLeft() > 0;
 }
    @Override
    public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(
        ItemCameraTransforms.TransformType cameraTransformType) {
      if (cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON)
        return Pair.of(IFlexibleBakedModel.class.cast(this), ThirdPerson);

      return Pair.of(IFlexibleBakedModel.class.cast(this), null);
    }
  public void processVectors(
      List<Pair<Integer, NamedVector>> vectors, boolean train, SequenceFile.Writer writer)
      throws IOException {

    BytesWritable recordKey = new BytesWritable("".getBytes());
    Text value = new Text();

    if (train) Collections.shuffle(vectors);

    double mu = -1.0;
    double ll = -1.0;
    int actual = -1;
    for (Pair<Integer, NamedVector> pair : vectors) {
      NamedVector v = pair.getValue();
      if (train) {
        actual = pair.getKey();
        mu = Math.min(this.k + 1, 200);
        ll = learningAlgorithm.logLikelihood(actual, v);
        this.averageLL = this.averageLL + (ll - this.averageLL) / mu;
      }

      Vector p = new DenseVector(LABELS);
      learningAlgorithm.classifyFull(p, v);
      int estimated = p.maxValueIndex();
      this.counts[estimated]++;

      if (writer != null) {
        value.set(
            String.format(
                "%s%c%d%c01%f",
                v.getName(),
                SEQUENCE_FILE_FIELD_SEPARATOR,
                estimated,
                SEQUENCE_FILE_FIELD_SEPARATOR,
                p.get(estimated)));
        writer.append(recordKey, value);
      }

      if (train) {
        int correct = (estimated == actual ? 1 : 0);
        this.averageCorrect = this.averageCorrect + (correct - this.averageCorrect) / mu;

        learningAlgorithm.train(actual, v);
        learningAlgorithm.close();
      }
      this.k++;
      int bump = this.BUMPS[(int) Math.floor(this.step) % this.BUMPS.length];
      int scale = (int) Math.pow(10, Math.floor(this.step / this.BUMPS.length));
      if (this.k % Math.min(MAX_STEP, bump * scale) == 0) {
        this.step += 0.25;
        if (train)
          System.out.printf(
              "%10d %10.3f %10.3f %10.2f %d\n",
              this.k, ll, this.averageLL, this.averageCorrect * 100, estimated);
        else System.out.printf("%c%10d, per label: %s\n", CR, this.k, Arrays.toString(this.counts));
      }
    }
  }
 /**
  * Set the api authorizations by parsing the String representation of the authorizations
  *
  * @param throwException true if an exception must be thrown in case of error
  * @throws ApiSignatureException
  */
 private void fillAllowedApiPatterns(boolean throwException) throws ApiSignatureException {
   allowedApiPatterns = new ArrayList<Pair<ApiMethod, Pattern>>();
   for (Pair<ApiMethod, String> apiAuthorization :
       parseAuthorization(
           getApplicationName(), getApiAuthorizationsAsString(), pattern, throwException)) {
     Pattern pattern = Pattern.compile(apiAuthorization.getRight());
     allowedApiPatterns.add(Pair.of(apiAuthorization.getLeft(), pattern));
   }
 }
 private String formatAmbiguousDependencies(List<Pair<Dependency, File>> ambiguousDependencies) {
   StringBuilder msgSb = new StringBuilder();
   for (Pair<Dependency, File> pair : ambiguousDependencies) {
     msgSb.append("BOM " + pair.getValue() + " defines version " + pair.getKey().getVersion());
     msgSb.append(LINE_SEPARATOR);
     msgSb.append(LINE_SEPARATOR);
   }
   return msgSb.toString();
 }
示例#23
0
 /**
  * Validate certain tel
  *
  * @param tel tel to validate
  * @return a pair, key represents if tel is valid, value represents invalid information if invalid
  */
 public Pair<Boolean, String> validate(String tel) {
   if (StringUtils.isBlank(tel)) {
     return Pair.of(false, "电话号码不能为空");
   } else if (!tel.matches("^\\d{11}$")) {
     return Pair.of(false, "电话号码必须为11位数字");
   } else {
     return Pair.of(true, null);
   }
 }
 @Override
 public Pair<? extends IBakedModel, Matrix4f> handlePerspective(
     TransformType cameraTransformType) {
   if (itemModel instanceof IPerspectiveAwareModel)
     return Pair.of(
         this,
         ((IPerspectiveAwareModel) itemModel).handlePerspective(cameraTransformType).getRight());
   return Pair.of(this, TRSRTransformation.identity().getMatrix());
 }
示例#25
0
 public <M extends IModel, S extends IModelState> MultiModelState(
     ImmutableList<Pair<M, S>> states) {
   ImmutableMap.Builder<MultiModelPart, S> builder = ImmutableMap.builder();
   for (int i = 0; i < states.size(); i++) {
     Pair<M, S> pair = states.get(i);
     builder.put(new MultiModelPart(pair.getLeft(), i), pair.getRight());
   }
   this.states = builder.build();
 }
示例#26
0
  protected void modifyDisk(long hostId, Instance instance, boolean add) {
    CacheManager cm = CacheManager.getCacheManagerInstance(this.objectManager);
    HostInfo hostInfo = cm.getHostInfo(hostId, false);
    if (hostInfo == null) {
      // we never tried to schedule disks at all in the past
      return;
    }
    InstanceInfo instanceInfo = hostInfo.getInstanceInfo(instance.getId());
    if (instanceInfo == null) {
      // we never tried to schedule disks at all during constraint scheduling
      return;
    }
    if (add) {
      Map<Pair<String, Long>, DiskInfo> volumeToDiskMapping =
          AllocatorUtils.allocateDiskForVolumes(hostId, instance, this.objectManager);
      if (volumeToDiskMapping == null) {
        return;
      }

      for (Entry<Pair<String, Long>, DiskInfo> mapping : volumeToDiskMapping.entrySet()) {
        Pair<String, Long> vol = mapping.getKey();
        DiskInfo disk = mapping.getValue();
        Long allocated = disk.getAllocatedSize();
        disk.addAllocatedSize(vol.getRight());
        log.info(
            "allocated disk space on disk [{}] with total = {}, {} {} {} = {} as used",
            disk.getDiskDevicePath(),
            disk.getCapacity(),
            allocated,
            "+",
            vol.getRight(),
            allocated + vol.getRight());

        // record to cache for deletion purpose
        instanceInfo.addReservedSize(disk.getDiskDevicePath(), vol.getRight());
      }

    } else {
      for (Entry<String, Long> diskAllocated : instanceInfo.getAllocatedDisks()) {
        String diskDevicePath = diskAllocated.getKey();
        Long reserveSize = diskAllocated.getValue();
        DiskInfo diskInfo = hostInfo.getDiskInfo(diskDevicePath);
        diskInfo.freeAllocatedSize(reserveSize);
        log.info(
            "freed disk space on disk [{}] with total = {}, {} {} {} = {} as used",
            diskInfo.getDiskDevicePath(),
            diskInfo.getCapacity(),
            diskInfo.getAllocatedSize(),
            "-",
            reserveSize,
            diskInfo.getAllocatedSize() - reserveSize);

        // release the reserved disk for this instance
        instanceInfo.releaseDisk(diskDevicePath);
      }
    }
  }
  @Test
  public void testConvertToMap() throws Exception {
    Map<String, String> map1 = convertToMap(new Pair[0]);
    assertThat(map1.size(), is(0));

    Map<String, String> map2 = convertToMap(new Pair[] {Pair.of("one", "1"), Pair.of("two", "2")});
    assertThat(map2.size(), is(2));
    assertThat(map2.get("one"), is("1"));
    assertThat(map2.get("two"), is("2"));
  }
示例#28
0
  @Override
  public Collection<ResourceLocation> getTextures() {
    Set<ResourceLocation> deps = Sets.newHashSet();

    if (base != null) deps.addAll(base.getTextures());

    for (Pair<IModel, IModelState> pair : parts.values()) deps.addAll(pair.getLeft().getTextures());

    return deps;
  }
示例#29
0
  @Test
  public void testGetMinAndMaxCharacter() {
    Pair<Character, Character> result = RangeSplitUtil.getMinAndMaxCharacter("abc%^&");
    Assert.assertEquals('%', result.getLeft().charValue());
    Assert.assertEquals('c', result.getRight().charValue());

    result = RangeSplitUtil.getMinAndMaxCharacter("\tAabcZx");
    Assert.assertEquals('\t', result.getLeft().charValue());
    Assert.assertEquals('x', result.getRight().charValue());
  }
  @SuppressWarnings("unchecked")
  public <TE extends TileEntity> TE getTinkerTE(Class<TE> clazz) {
    for (Pair<BlockPos, IBlockState> pair : tinkerStationBlocks) {
      TileEntity te = this.world.getTileEntity(pair.getLeft());

      if (te != null && clazz.isAssignableFrom(te.getClass())) {
        return (TE) te;
      }
    }
    return null;
  }