Package org.apache.commons.lang.mutable

Examples of org.apache.commons.lang.mutable.MutableInt


   * @param curTask task to submit
   * @param curTaskZKVersion current version of task
   */
  void submitTask(final String curTask, final RecoveryMode mode, final int curTaskZKVersion,
      final int reportPeriod) {
    final MutableInt zkVersion = new MutableInt(curTaskZKVersion);

    CancelableProgressable reporter = new CancelableProgressable() {
      private long last_report_at = 0;

      @Override
      public boolean progress() {
        long t = EnvironmentEdgeManager.currentTime();
        if ((t - last_report_at) > reportPeriod) {
          last_report_at = t;
          int latestZKVersion =
              attemptToOwnTask(false, watcher, server.getServerName(), curTask,
                mode, zkVersion.intValue());
          if (latestZKVersion < 0) {
            LOG.warn("Failed to heartbeat the task" + curTask);
            return false;
          }
          zkVersion.setValue(latestZKVersion);
        }
        return true;
      }
    };
    ZkSplitLogWorkerCoordination.ZkSplitTaskDetails splitTaskDetails =
View Full Code Here


        Map<Object, MutableInt> countsByKey = new HashMap<Object, MutableInt>(deserializationState.countObjects());

        for (T obj : deserializationState) {
            Object key = instruction.getKeyFromObject(obj);

            MutableInt count = (MutableInt) countsByKey.get(key);
            if (count == null) {
                count = new MutableInt(0);
                countsByKey.put(key, count);
            }

            count.increment();
        }
        return countsByKey;
    }
View Full Code Here

            return objectFieldDiffScore;
        }


        private void increment(Map<Object, MutableInt> map, Object obj) {
            MutableInt i = map.get(obj);
            if(i == null) {
                i = new MutableInt(0);
                map.put(obj, i);
            }
            i.increment();
        }
View Full Code Here

            }
            i.increment();
        }

        private boolean decrement(Map<Object, MutableInt> map, Object obj) {
            MutableInt i = map.get(obj);
            if(i == null) {
                return false;
            }

            i.decrement();

            if(i.intValue() == 0) {
                map.remove(obj);
            }

            return true;
        }
View Full Code Here

   * Submit a log split task to executor service
   * @param curTask
   * @param curTaskZKVersion
   */
  void submitTask(final String curTask, final int curTaskZKVersion, final int reportPeriod) {
    final MutableInt zkVersion = new MutableInt(curTaskZKVersion);

    CancelableProgressable reporter = new CancelableProgressable() {
      private long last_report_at = 0;

      @Override
      public boolean progress() {
        long t = EnvironmentEdgeManager.currentTimeMillis();
        if ((t - last_report_at) > reportPeriod) {
          last_report_at = t;
          int latestZKVersion =
              attemptToOwnTask(false, watcher, serverName, curTask, zkVersion.intValue());
          if (latestZKVersion < 0) {
            LOG.warn("Failed to heartbeat the task" + curTask);
            return false;
          }
          zkVersion.setValue(latestZKVersion);
        }
        return true;
      }
    };
   
View Full Code Here

    for (Entry<ByteBuffer,
        ? extends Collection<LoadQueueItem>> e: regionGroups.asMap().entrySet()) {
      final Collection<LoadQueueItem> lqis =  e.getValue();
      HashMap<byte[], MutableInt> filesMap = new HashMap<byte[], MutableInt>();
      for (LoadQueueItem lqi: lqis) {
        MutableInt count = filesMap.get(lqi.family);
        if (count == null) {
          count = new MutableInt();
          filesMap.put(lqi.family, count);
        }
        count.increment();
        if (count.intValue() > maxFilesPerRegionPerFamily) {
          LOG.error("Trying to load more than " + maxFilesPerRegionPerFamily
            + " hfiles to family " + Bytes.toStringBinary(lqi.family)
            + " of region with start key "
            + Bytes.toStringBinary(e.getKey()));
          return false;
View Full Code Here

    for (Entry<ByteBuffer,
        ? extends Collection<LoadQueueItem>> e: regionGroups.asMap().entrySet()) {
      final Collection<LoadQueueItem> lqis =  e.getValue();
      HashMap<byte[], MutableInt> filesMap = new HashMap<byte[], MutableInt>();
      for (LoadQueueItem lqi: lqis) {
        MutableInt count = filesMap.get(lqi.family);
        if (count == null) {
          count = new MutableInt();
          filesMap.put(lqi.family, count);
        }
        count.increment();
        if (count.intValue() > maxFilesPerRegionPerFamily) {
          LOG.error("Trying to load more than " + maxFilesPerRegionPerFamily
            + " hfiles to family " + Bytes.toStringBinary(lqi.family)
            + " of region with start key "
            + Bytes.toStringBinary(e.getKey()));
          return false;
View Full Code Here

  @PostConstruct
  public void init() {
    AgentManagerService agentManagerService = mock(AgentManagerService.class);
    Map<String, MutableInt> countMap = new HashMap<String, MutableInt>(1);
    countMap.put(config.getRegion(), new MutableInt(3));
    when(agentManagerService.getAvailableAgentCountMap(userContext.getCurrentUser())).thenReturn(countMap);
    ReflectionTestUtils.setField(this, "agentManagerService", agentManagerService);
  }
View Full Code Here

    }

    int maxAgentSizePerConsole = getMaxAgentSizePerConsole();
    availableShareAgents = (Math.min(availableShareAgents, maxAgentSizePerConsole));
    Map<String, MutableInt> result = new HashMap<String, MutableInt>(1);
    result.put(Config.NONE_REGION, new MutableInt(availableShareAgents + availableUserOwnAgent));
    return result;
  }
View Full Code Here

      checkArgument(duration > 0 && duration <= (((long) agentManager.getMaxRunHour()) *
          3600000L),
          "duration should be equal to or less than %s", agentManager.getMaxRunHour());
    }
    Map<String, MutableInt> agentCountMap = agentManagerService.getAvailableAgentCountMap(user);
    MutableInt agentCountObj = agentCountMap.get(isClustered() ? newOne.getRegion() : Config.NONE_REGION);
    checkNotNull(agentCountObj, "region should be within current region list");
    int agentMaxCount = agentCountObj.intValue();
    checkArgument(newOne.getAgentCount() <= agentMaxCount, "test agent should be equal to or less than %s",
        agentMaxCount);
    if (newOne.getStatus().equals(Status.READY)) {
      checkArgument(newOne.getAgentCount() >= 1, "agentCount should be more than 1 when it's READY status.");
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang.mutable.MutableInt

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.