Ejemplo n.º 1
0
CounterConfiguration BaseCounterOperation::readConfiguration(infinispan::hotrod::transport::Transport& transport) {
    uint8_t flags;
    CounterType ct;
    Storage st;
    long concurrentLevel = 0;
    long lower = 0;
    long upper = 0;
    long initial = 0;
    flags = transport.readByte();
    switch (flags & 0x03) {
    case 0x00:
        ct = CounterType::UNBOUNDED_STRONG;
        break;
    case 0x01:
        ct = CounterType::WEAK;
        break;
    case 0x02:
        ct = CounterType::BOUNDED_STRONG;
        break;
    default:
        throw HotRodClientException(std::string("Unknown counter type: ") + std::to_string(flags));
    }
    st = (flags & 0x04) ? Storage::PERSISTENT : Storage::VOLATILE;

    if (ct == WEAK) {
        concurrentLevel = transport.readVInt();
    }
    if (ct == BOUNDED_STRONG) {
        lower = transport.readLong();
        upper = transport.readLong();
    }
    initial = transport.readLong();
    return CounterConfiguration(initial, lower, upper, concurrentLevel, ct, st);
}
Ejemplo n.º 2
0
long GetCounterValueOperation::executeOperation(infinispan::hotrod::transport::Transport& transport) {
    TRACE("Executing IsCounterDefinedOperation(flags=%u)", flags);
    std::unique_ptr<HeaderParams> params(RetryOnFailureOperation<long>::writeHeader(transport, COUNTER_GET_REQUEST));
    writeName(transport, counterName);
    transport.flush();
    uint8_t status = readHeaderAndValidate(transport, *params);
    if (!isSuccess(status)) {
        throw HotRodClientException(
                std::string("Error in GetCountervalue operation, counter name: ") + counterName + " status: "
                        + std::to_string(status));
    }
    auto ret = (long)transport.readLong();
    TRACE("Finished IsCounterDefinedOperation");
    return ret;
}
Ejemplo n.º 3
0
long CompareAndSwapCounterValueOperation::executeOperation(infinispan::hotrod::transport::Transport& transport) {
    TRACE("Executing CompareAndSwapOperation(flags=%u)", flags);
    std::unique_ptr<HeaderParams> params(RetryOnFailureOperation<long>::writeHeader(transport, COUNTER_CAS_REQUEST));
    writeName(transport, counterName);
    transport.writeLong(expect);
    transport.writeLong(update);
    transport.flush();
    uint8_t status = readHeaderAndValidate(transport, *params);
    assertBoundaries(status);
    if (status != NO_ERROR_STATUS) {
        throw HotRodClientException(
                std::string("Error in CompareAndSwap operation, counter name: ") + counterName + " status: "
                        + std::to_string(status));
    }
    auto ret = (long)transport.readLong();
    TRACE("Finished CompareAndSwapDefinedOperation");
    return ret;
}