use of org.apache.commons.lang3.mutable.MutableInt in project neo4j by neo4j.
the class DeferringLockClient method addLock.
private void addLock(ResourceType resourceType, long resourceId, boolean exclusive) {
LockUnit lockUnit = new LockUnit(resourceType, resourceId, exclusive);
MutableInt lockCount = locks.get(lockUnit);
if (lockCount == null) {
lockCount = new MutableInt();
locks.put(lockUnit, lockCount);
}
lockCount.increment();
}
use of org.apache.commons.lang3.mutable.MutableInt in project neo4j by neo4j.
the class FullCheckIntegrationTest method createLabel.
private int createLabel() throws Exception {
final MutableInt id = new MutableInt(-1);
fixture.apply(new GraphStoreFixture.Transaction() {
@Override
protected void transactionData(GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next) {
int labelId = next.label();
tx.nodeLabel(labelId, "label");
id.setValue(labelId);
}
});
return id.intValue();
}
use of org.apache.commons.lang3.mutable.MutableInt in project neo4j by neo4j.
the class ShortestPath method internalPaths.
private Iterable<Path> internalPaths(Node start, Node end, boolean stopAsap) {
lastMetadata = new Metadata();
if (start.equals(end)) {
return filterPaths(Collections.singletonList(PathImpl.singular(start)));
}
Hits hits = new Hits();
Collection<Long> sharedVisitedRels = new HashSet<>();
// ShortestPathLengthSoFar
MutableInt sharedFrozenDepth = new MutableInt(NULL);
MutableBoolean sharedStop = new MutableBoolean();
MutableInt sharedCurrentDepth = new MutableInt(0);
final DirectionData startData = new DirectionData(start, sharedVisitedRels, sharedFrozenDepth, sharedStop, sharedCurrentDepth, expander);
final DirectionData endData = new DirectionData(end, sharedVisitedRels, sharedFrozenDepth, sharedStop, sharedCurrentDepth, expander.reverse());
while (startData.hasNext() || endData.hasNext()) {
goOneStep(startData, endData, hits, startData, stopAsap);
goOneStep(endData, startData, hits, startData, stopAsap);
}
Collection<Hit> least = hits.least();
return least != null ? filterPaths(hitsToPaths(least, start, end, stopAsap)) : Collections.<Path>emptyList();
}
use of org.apache.commons.lang3.mutable.MutableInt in project neo4j by neo4j.
the class CrashGenerationCleanerTest method shouldCleanLargeFile.
@Test
public void shouldCleanLargeFile() throws Exception {
// GIVEN
int numberOfPages = randomRule.intBetween(1_000, 10_000);
int corruptionPercent = randomRule.nextInt(90);
MutableInt totalNumberOfCorruptions = new MutableInt(0);
Page[] pages = new Page[numberOfPages];
for (int i = 0; i < numberOfPages; i++) {
Page page = randomPage(corruptionPercent, totalNumberOfCorruptions);
pages[i] = page;
}
initializeFile(pagedFile, pages);
// WHEN
SimpleMonitor monitor = new SimpleMonitor();
crashGenerationCleaner(pagedFile, 0, numberOfPages, monitor).clean();
// THEN
assertPagesVisisted(monitor, numberOfPages);
assertCleanedCrashPointers(monitor, totalNumberOfCorruptions.getValue());
}
use of org.apache.commons.lang3.mutable.MutableInt in project apex-core by apache.
the class StreamingContainerManager method fillLogicalOperatorInfo.
private LogicalOperatorInfo fillLogicalOperatorInfo(OperatorMeta operator) {
LogicalOperatorInfo loi = new LogicalOperatorInfo();
loi.name = operator.getName();
loi.className = operator.getOperator().getClass().getName();
loi.totalTuplesEmitted = operator.getStatus().totalTuplesEmitted;
loi.totalTuplesProcessed = operator.getStatus().totalTuplesProcessed;
loi.failureCount = operator.getStatus().failureCount;
loi.status = new HashMap<>();
loi.partitions = new TreeSet<>();
loi.unifiers = new TreeSet<>();
loi.containerIds = new TreeSet<>();
loi.hosts = new TreeSet<>();
Collection<PTOperator> physicalOperators = getPhysicalPlan().getAllOperators(operator);
NumberAggregate.LongAggregate checkpointTimeAggregate = new NumberAggregate.LongAggregate();
for (PTOperator physicalOperator : physicalOperators) {
OperatorStatus os = physicalOperator.stats;
if (physicalOperator.isUnifier()) {
loi.unifiers.add(physicalOperator.getId());
} else {
loi.partitions.add(physicalOperator.getId());
// exclude unifier, not sure if we should include it in the future
loi.tuplesEmittedPSMA += os.tuplesEmittedPSMA.get();
loi.tuplesProcessedPSMA += os.tuplesProcessedPSMA.get();
// calculate maximum latency for all partitions
long latency = calculateLatency(physicalOperator);
if (latency > loi.latencyMA) {
loi.latencyMA = latency;
}
checkpointTimeAggregate.addNumber(os.checkpointTimeMA.getAvg());
}
loi.cpuPercentageMA += os.cpuNanosPMSMA.getAvg() / 10000;
if (os.lastHeartbeat != null && (loi.lastHeartbeat == 0 || loi.lastHeartbeat > os.lastHeartbeat.getGeneratedTms())) {
loi.lastHeartbeat = os.lastHeartbeat.getGeneratedTms();
}
long currentWindowId = toWsWindowId(os.currentWindowId.get());
if (loi.currentWindowId == 0 || loi.currentWindowId > currentWindowId) {
loi.currentWindowId = currentWindowId;
}
MutableInt count = loi.status.get(physicalOperator.getState().toString());
if (count == null) {
count = new MutableInt();
loi.status.put(physicalOperator.getState().toString(), count);
}
count.increment();
if (physicalOperator.getRecoveryCheckpoint() != null) {
long recoveryWindowId = toWsWindowId(physicalOperator.getRecoveryCheckpoint().windowId);
if (loi.recoveryWindowId == 0 || loi.recoveryWindowId > recoveryWindowId) {
loi.recoveryWindowId = recoveryWindowId;
}
}
PTContainer container = physicalOperator.getContainer();
if (container != null) {
String externalId = container.getExternalId();
if (externalId != null) {
loi.containerIds.add(externalId);
loi.hosts.add(container.host);
}
}
}
if (physicalOperators.size() > 0 && checkpointTimeAggregate.getAvg() != null) {
loi.checkpointTimeMA = checkpointTimeAggregate.getAvg().longValue();
loi.counters = latestLogicalCounters.get(operator.getName());
loi.autoMetrics = latestLogicalMetrics.get(operator.getName());
}
return loi;
}
Aggregations