Search in sources :

Example 16 with UnsignedLong

use of com.google.common.primitives.UnsignedLong in project nifi by apache.

the class TestBinaryReaderBuilder method putFileTime.

public TestBinaryReaderBuilder putFileTime(Date date) {
    UnsignedLong javaMillis = UnsignedLong.valueOf(date.getTime());
    UnsignedLong windowsMillis = javaMillis.plus(UnsignedLong.valueOf(BinaryReader.EPOCH_OFFSET));
    UnsignedLong windowsStamp = windowsMillis.times(UnsignedLong.valueOf(10000));
    return putQWord(windowsStamp);
}
Also used : UnsignedLong(com.google.common.primitives.UnsignedLong)

Example 17 with UnsignedLong

use of com.google.common.primitives.UnsignedLong in project nifi by apache.

the class Hex64TypeNodeTest method testHex64TypeNode.

@Test
public void testHex64TypeNode() throws IOException {
    UnsignedLong value = UnsignedLong.fromLongBits(Long.MAX_VALUE + 1234);
    String hex = value.toString(16);
    assertEquals(hex, new Hex64TypeNode(testBinaryReaderBuilder.putQWord(value).build(), chunkHeader, parent, -1).getValue().substring(2));
}
Also used : UnsignedLong(com.google.common.primitives.UnsignedLong) Test(org.junit.Test)

Example 18 with UnsignedLong

use of com.google.common.primitives.UnsignedLong in project nifi by apache.

the class SizeTypeNodeTest method testSizeTypeNodeQWord.

@Test
public void testSizeTypeNodeQWord() throws IOException {
    UnsignedLong value = UnsignedLong.fromLongBits(Long.MAX_VALUE + 132);
    assertEquals(value.toString(), new SizeTypeNode(testBinaryReaderBuilder.putQWord(value).build(), chunkHeader, parent, -1).getValue());
}
Also used : UnsignedLong(com.google.common.primitives.UnsignedLong) Test(org.junit.Test)

Example 19 with UnsignedLong

use of com.google.common.primitives.UnsignedLong in project controller by opendaylight.

the class FrontendHistoryMetadataBuilder method onTransactionPurged.

void onTransactionPurged(final TransactionIdentifier txId) {
    final UnsignedLong id = UnsignedLong.fromLongBits(txId.getTransactionId());
    closedTransactions.remove(id);
    purgedTransactions.add(Range.closedOpen(id, UnsignedLong.ONE.plus(id)));
}
Also used : UnsignedLong(com.google.common.primitives.UnsignedLong)

Example 20 with UnsignedLong

use of com.google.common.primitives.UnsignedLong in project controller by opendaylight.

the class AbstractFrontendHistory method handleTransactionPurgeRequest.

private TransactionSuccess<?> handleTransactionPurgeRequest(final TransactionRequest<?> request, final RequestEnvelope envelope, final long now) {
    final TransactionIdentifier id = request.getTarget();
    final UnsignedLong ul = UnsignedLong.fromLongBits(id.getTransactionId());
    if (purgedTransactions.contains(ul)) {
        // Retransmitted purge request: nothing to do
        LOG.debug("{}: transaction {} already purged", persistenceId, id);
        return new TransactionPurgeResponse(id, request.getSequence());
    }
    // to an ImmutableMap, which does not allow remove().
    if (closedTransactions.containsKey(ul)) {
        tree.purgeTransaction(id, () -> {
            closedTransactions.remove(ul);
            if (closedTransactions.isEmpty()) {
                closedTransactions = ImmutableMap.of();
            }
            purgedTransactions.add(Range.closedOpen(ul, UnsignedLong.ONE.plus(ul)));
            LOG.debug("{}: finished purging inherited transaction {}", persistenceId(), id);
            envelope.sendSuccess(new TransactionPurgeResponse(id, request.getSequence()), readTime() - now);
        });
        return null;
    }
    final FrontendTransaction tx = transactions.get(id);
    if (tx == null) {
        // This should never happen because the purge callback removes the transaction and puts it into
        // purged transactions in one go. If it does, we warn about the situation and
        LOG.warn("{}: transaction {} not tracked in {}, but not present in active transactions", persistenceId, id, purgedTransactions);
        purgedTransactions.add(Range.closedOpen(ul, UnsignedLong.ONE.plus(ul)));
        return new TransactionPurgeResponse(id, request.getSequence());
    }
    tree.purgeTransaction(id, () -> {
        purgedTransactions.add(Range.closedOpen(ul, UnsignedLong.ONE.plus(ul)));
        transactions.remove(id);
        LOG.debug("{}: finished purging transaction {}", persistenceId(), id);
        envelope.sendSuccess(new TransactionPurgeResponse(id, request.getSequence()), readTime() - now);
    });
    return null;
}
Also used : TransactionPurgeResponse(org.opendaylight.controller.cluster.access.commands.TransactionPurgeResponse) UnsignedLong(com.google.common.primitives.UnsignedLong) TransactionIdentifier(org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)

Aggregations

UnsignedLong (com.google.common.primitives.UnsignedLong)21 Test (org.junit.Test)8 BigInteger (java.math.BigInteger)4 InOrder (org.mockito.InOrder)3 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)3 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)3 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)3 DataTreeSnapshot (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot)3 ArrayList (java.util.ArrayList)2 ClientIdentifier (org.opendaylight.controller.cluster.access.concepts.ClientIdentifier)2 TransactionIdentifier (org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier)2 CommitTransactionPayload (org.opendaylight.controller.cluster.datastore.persisted.CommitTransactionPayload)2 DataTreeCandidateTip (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateTip)2 CPUStats (com.emc.storageos.systemservices.impl.healthmonitor.models.CPUStats)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Optional (java.util.Optional)1 Nullable (javax.annotation.Nullable)1 ArgumentTypeException (org.matheclipse.core.eval.exception.ArgumentTypeException)1 IExpr (org.matheclipse.core.interfaces.IExpr)1