use of com.google.common.primitives.UnsignedLong in project controller by opendaylight.
the class SimpleShardDataTreeCohortTest method testPreCommitAndCommitSuccess.
@Test
public void testPreCommitAndCommitSuccess() throws Exception {
canCommitSuccess();
final DataTreeCandidateTip candidate = preCommitSuccess();
doAnswer(invocation -> {
invocation.getArgumentAt(0, SimpleShardDataTreeCohort.class).successfulCommit(UnsignedLong.valueOf(0), () -> {
});
return null;
}).when(mockShardDataTree).startCommit(cohort, candidate);
@SuppressWarnings("unchecked") final FutureCallback<UnsignedLong> mockCommitCallback = mock(FutureCallback.class);
cohort.commit(mockCommitCallback);
verify(mockCommitCallback).onSuccess(any(UnsignedLong.class));
verifyNoMoreInteractions(mockCommitCallback);
verify(mockUserCohorts).commit();
}
use of com.google.common.primitives.UnsignedLong in project controller by opendaylight.
the class FrontendShardDataTreeSnapshotMetadataTest method createFrontedClientMetadata.
private static FrontendClientMetadata createFrontedClientMetadata(final long num) {
final String index = String.valueOf(num);
final String indexName = "test_" + index;
final FrontendIdentifier frontendIdentifier = FrontendIdentifier.create(MemberName.forName(indexName), FrontendType.forName(index));
final ClientIdentifier clientIdentifier = ClientIdentifier.create(frontendIdentifier, num);
final RangeSet<UnsignedLong> purgedHistories = TreeRangeSet.create();
purgedHistories.add(Range.closed(UnsignedLong.ZERO, UnsignedLong.ONE));
final Collection<FrontendHistoryMetadata> currentHistories = Collections.singleton(new FrontendHistoryMetadata(num, num, true, ImmutableMap.of(UnsignedLong.ZERO, Boolean.TRUE), purgedHistories));
return new FrontendClientMetadata(clientIdentifier, purgedHistories, currentHistories);
}
use of com.google.common.primitives.UnsignedLong in project controller by opendaylight.
the class AbstractFrontendHistory method handleTransactionRequest.
@Nullable
final TransactionSuccess<?> handleTransactionRequest(final TransactionRequest<?> request, final RequestEnvelope envelope, final long now) throws RequestException {
if (request instanceof TransactionPurgeRequest) {
return handleTransactionPurgeRequest(request, envelope, now);
}
final TransactionIdentifier id = request.getTarget();
final UnsignedLong ul = UnsignedLong.fromLongBits(id.getTransactionId());
if (purgedTransactions.contains(ul)) {
LOG.warn("{}: Request {} is contained purged transactions {}", persistenceId, request, purgedTransactions);
throw new DeadTransactionException(purgedTransactions);
}
final Boolean closed = closedTransactions.get(ul);
if (closed != null) {
final boolean successful = closed.booleanValue();
LOG.debug("{}: Request {} refers to a {} transaction", persistenceId, request, successful ? "successful" : "failed");
throw new ClosedTransactionException(successful);
}
FrontendTransaction tx = transactions.get(id);
if (tx == null) {
// The transaction does not exist and we are about to create it, check sequence number
if (request.getSequence() != 0) {
LOG.warn("{}: no transaction state present, unexpected request {}", persistenceId(), request);
throw new OutOfOrderRequestException(0);
}
tx = createTransaction(request, id);
transactions.put(id, tx);
} else if (!(request instanceof IncrementTransactionSequenceRequest)) {
final Optional<TransactionSuccess<?>> maybeReplay = tx.replaySequence(request.getSequence());
if (maybeReplay.isPresent()) {
final TransactionSuccess<?> replay = maybeReplay.get();
LOG.debug("{}: envelope {} replaying response {}", persistenceId(), envelope, replay);
return replay;
}
}
return tx.handleRequest(request, envelope, now);
}
use of com.google.common.primitives.UnsignedLong in project symja_android_library by axkr.
the class NumericArrayExpr method arrayUnsignedLongRecursive.
private static boolean arrayUnsignedLongRecursive(IAST nestedListsOfValues, int level, long[] longArr, int[] index) throws RangeException, TypeException {
level--;
for (int i = 1; i < nestedListsOfValues.size(); i++) {
IExpr arg = nestedListsOfValues.get(i);
if (level == 0) {
if (!arg.isInteger()) {
throw new TypeException("Not a valid Integers type");
}
BigInteger value = ((IInteger) arg).toBigNumerator();
UnsignedLong uint64 = UnsignedLong.valueOf(value);
longArr[index[0]++] = uint64.longValue();
} else {
if (!arg.isList() || !arrayUnsignedLongRecursive((IAST) arg, level, longArr, index)) {
return false;
}
}
}
return true;
}
use of com.google.common.primitives.UnsignedLong in project coprhd-controller by CoprHD.
the class NodeStatsExtractor method getCPUTimeDeltaMS.
/**
* Returns the cpu time spent in MS. If interval is > 0 delta value is returned.
* This is used to calculate per sec values.
*/
protected static double getCPUTimeDeltaMS(CPUStats oldCPUStats, CPUStats newCPUStats) {
if (oldCPUStats != null) {
double statsDiff;
UnsignedLong oldTotal = oldCPUStats.getUserMode().plus(oldCPUStats.getSystemMode().plus(oldCPUStats.getIdle().plus(oldCPUStats.getIowait())));
if (newCPUStats != null) {
UnsignedLong newTotal = newCPUStats.getUserMode().plus(newCPUStats.getSystemMode().plus(newCPUStats.getIdle().plus(newCPUStats.getIowait())));
statsDiff = newTotal.minus(oldTotal).doubleValue();
} else {
statsDiff = oldTotal.doubleValue();
}
return ProcStats.getCPUCount() > 0 ? 1000.0 * statsDiff / ProcStats.getCPUCount() / HZ : 0;
} else {
return 0;
}
}
Aggregations