Search in sources :

Example 16 with MutableInt

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();
}
Also used : MutableInt(org.apache.commons.lang3.mutable.MutableInt)

Example 17 with MutableInt

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();
}
Also used : TransactionDataBuilder(org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder) MutableInt(org.apache.commons.lang3.mutable.MutableInt) IdGenerator(org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator) GraphStoreFixture(org.neo4j.consistency.checking.GraphStoreFixture)

Example 18 with MutableInt

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();
}
Also used : MutableInt(org.apache.commons.lang3.mutable.MutableInt) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) TraversalMetadata(org.neo4j.graphdb.traversal.TraversalMetadata) HashSet(java.util.HashSet)

Example 19 with MutableInt

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());
}
Also used : MutableInt(org.apache.commons.lang3.mutable.MutableInt) Test(org.junit.Test)

Example 20 with MutableInt

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;
}
Also used : NumberAggregate(com.datatorrent.common.util.NumberAggregate) LogicalOperatorInfo(com.datatorrent.stram.webapp.LogicalOperatorInfo) PTOperator(com.datatorrent.stram.plan.physical.PTOperator) OperatorStatus(com.datatorrent.stram.plan.physical.OperatorStatus) LogicalOperatorStatus(com.datatorrent.stram.plan.logical.LogicalOperatorStatus) MutableInt(org.apache.commons.lang3.mutable.MutableInt) PTContainer(com.datatorrent.stram.plan.physical.PTContainer)

Aggregations

MutableInt (org.apache.commons.lang3.mutable.MutableInt)28 Test (org.junit.Test)10 HashMap (java.util.HashMap)5 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)5 Map (java.util.Map)4 TimeoutException (java.util.concurrent.TimeoutException)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 List (java.util.List)2 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 AllelicCount (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCount)2 AllelicCountCollection (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection)2 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)2 Utils (org.broadinstitute.hellbender.utils.Utils)2 IOUtils (org.broadinstitute.hellbender.utils.io.IOUtils)2 ParamUtils (org.broadinstitute.hellbender.utils.param.ParamUtils)2 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)2 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)2