Java Code Examples for org.apache.commons.lang.mutable.MutableInt#intValue()

The following examples show how to use org.apache.commons.lang.mutable.MutableInt#intValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlagMaker.java    From datawave with Apache License 2.0 7 votes vote down vote up
/**
 * Determine the number of unprocessed flag files in the flag directory
 * 
 * @param fc
 * @return the flag found for this ingest pool
 */
private int countFlagFileBacklog(final FlagDataTypeConfig fc) {
    final MutableInt fileCounter = new MutableInt(0);
    final FileFilter fileFilter = new WildcardFileFilter("*_" + fc.getIngestPool() + "_" + fc.getDataName() + "_*.flag");
    final FileVisitor<java.nio.file.Path> visitor = new SimpleFileVisitor<java.nio.file.Path>() {
        
        @Override
        public FileVisitResult visitFile(java.nio.file.Path path, BasicFileAttributes attrs) throws IOException {
            if (fileFilter.accept(path.toFile())) {
                fileCounter.increment();
            }
            return super.visitFile(path, attrs);
        }
    };
    try {
        Files.walkFileTree(Paths.get(fmc.getFlagFileDirectory()), visitor);
    } catch (IOException e) {
        // unable to get a flag count....
        log.error("Unable to get flag file count", e);
        return -1;
    }
    return fileCounter.intValue();
}
 
Example 2
Source File: ReaderTextLIBSVM.java    From systemds with Apache License 2.0 6 votes vote down vote up
private static long readLIBSVMMatrixFromInputStream( InputStream is, String srcInfo, MatrixBlock dest, MutableInt rowPos, 
		long rlen, long clen, int blen )
	throws IOException
{
	SparseRowVector vect = new SparseRowVector(1024);
	String value = null;
	int row = rowPos.intValue();
	long lnnz = 0;
	
	// Read the data
	try( BufferedReader br = new BufferedReader(new InputStreamReader(is)) ) {
		while( (value=br.readLine())!=null ) { //for each line
			String rowStr = value.toString().trim();
			lnnz += ReaderTextLIBSVM.parseLibsvmRow(rowStr, vect, (int)clen);
			dest.appendRow(row, vect);
			row++;
		}
	}
	
	rowPos.setValue(row);
	return lnnz;
}
 
Example 3
Source File: RefreshTask.java    From ScoreboardStats with MIT License 6 votes vote down vote up
@Override
public void run() {
    //let the players update smoother
    int remainingUpdates = getNextUpdates();
    for (Map.Entry<Player, MutableInt> entry : queue.entrySet()) {
        Player player = entry.getKey();
        MutableInt remainingTicks = entry.getValue();
        if (remainingTicks.intValue() == 0) {
            if (remainingUpdates != 0) {
                //Smoother refreshing; limit the updates
                plugin.getScoreboardManager().onUpdate(player);
                remainingTicks.setValue(20 * Settings.getInterval());
                remainingUpdates--;
            }
        } else {
            remainingTicks.decrement();
        }
    }

    nextGlobalUpdate--;
    if (nextGlobalUpdate == 0) {
        nextGlobalUpdate = 20 * Settings.getInterval();
        //update globals
        plugin.getReplaceManager().updateGlobals();
    }
}
 
Example 4
Source File: RequestUtils.java    From incubator-pinot with Apache License 2.0 6 votes vote down vote up
private static FilterQuery traverseFilterQueryAndPopulateMap(FilterQueryTree tree,
    Map<Integer, FilterQuery> filterQueryMap, MutableInt currentId) {
  int currentNodeId = currentId.intValue();
  currentId.increment();

  final List<Integer> f = new ArrayList<>();
  if (null != tree.getChildren()) {
    for (final FilterQueryTree c : tree.getChildren()) {
      final FilterQuery q = traverseFilterQueryAndPopulateMap(c, filterQueryMap, currentId);
      int childNodeId = q.getId();
      f.add(childNodeId);
      filterQueryMap.put(childNodeId, q);
    }
  }

  FilterQuery query = new FilterQuery();
  query.setColumn(tree.getColumn());
  query.setId(currentNodeId);
  query.setNestedFilterQueryIds(f);
  query.setOperator(tree.getOperator());
  query.setValue(tree.getValue());
  return query;
}
 
Example 5
Source File: DagAwareYarnTaskScheduler.java    From tez with Apache License 2.0 5 votes vote down vote up
private void decrVertexTaskCount(Priority priority, RequestPriorityStats stats, int vertexIndex) {
  Integer vertexIndexInt = vertexIndex;
  MutableInt taskCount = stats.vertexTaskCount.get(vertexIndexInt);
  taskCount.decrement();
  if (taskCount.intValue() <= 0) {
    removeVertexFromRequestStats(priority, stats, vertexIndexInt);
  }
}
 
Example 6
Source File: HashTestSink.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
public int getCount(T key)
{
  int ret = -1;
  MutableInt val = map.get(key);
  if (val != null) {
    ret = val.intValue();
  }
  return ret;
}
 
Example 7
Source File: TransactionRetryInterceptor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void processException(Exception e, MethodInvocation invocation, MutableInt attempt) {

	StringBuilder message = new StringBuilder("When invoking method ")
		.append(invocation.getMethod().getDeclaringClass().getName()).append("#")
		.append(invocation.getMethod().getName()).append(" caught \"").append(e.getMessage())
		.append("\". Attempt #").append(attempt);

	attempt.increment();
	if (attempt.intValue() <= TransactionRetryInterceptor.MAX_ATTEMPTS) {
	    message.append(". Retrying.");
	} else {
	    message.append(". Giving up.");
	}
	TransactionRetryInterceptor.log.warn(message);
    }
 
Example 8
Source File: TypeDiffOperation.java    From zeno with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 9
Source File: RunatoriumReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPvpKillsByRace(Race race, int points) {
	MutableInt racePoints = getPvpKillsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 10
Source File: RunatoriumReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPointsByRace(Race race, int points) {
	MutableInt racePoints = getPointsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 11
Source File: RunatoriumRuinsReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPvpKillsByRace(Race race, int points) {
	MutableInt racePoints = getPvpKillsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 12
Source File: RunatoriumRuinsReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPointsByRace(Race race, int points) {
	MutableInt racePoints = getPointsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 13
Source File: SteelWallBastionBattlefieldReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPvpKillsByRace(Race race, int points) {
	MutableInt racePoints = getPvpKillsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 14
Source File: NeviwindCanyonReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPointsByRace(Race race, int points) {
    MutableInt pointsByRace = getPointsByRace(race);
    pointsByRace.add(points);
    if (pointsByRace.intValue() < 0) {
        pointsByRace.setValue(0);
    }
}
 
Example 15
Source File: ArrayListTestSink.java    From attic-apex-malhar with Apache License 2.0 5 votes vote down vote up
public int getCount(T key)
{
  int ret = -1;
  MutableInt val = map.get(key);
  if (val != null) {
    ret = val.intValue();
  }
  return ret;
}
 
Example 16
Source File: KamarBattlefieldReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPvpKillsByRace(Race race, int points) {
	MutableInt racePoints = getPvpKillsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 17
Source File: KamarBattlefieldReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPointsByRace(Race race, int points) {
	MutableInt racePoints = getPointsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 18
Source File: DredgionReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPointsByRace(Race race, int points) {
	MutableInt racePoints = getPointsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 19
Source File: JormungandReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPointsByRace(Race race, int points) {
	MutableInt racePoints = getPointsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}
 
Example 20
Source File: JormungandReward.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
public void addPvpKillsByRace(Race race, int points) {
	MutableInt racePoints = getPvpKillsByRace(race);
	racePoints.add(points);
	if (racePoints.intValue() < 0) {
		racePoints.setValue(0);
	}
}