Exemplo n.º 1
0
void BaseCounterOperation::writeConfiguration(infinispan::hotrod::transport::Transport& transport,
        const CounterConfiguration& c) {
    uint8_t flags = 0;
    switch (c.getType()) {
    case CounterType::WEAK:
        flags |= 0x01;
        break;
    case CounterType::BOUNDED_STRONG:
        flags |= 0x02;
        break;
    case CounterType::UNBOUNDED_STRONG:
        break;
    }

    switch (c.getStorage()) {
    case Storage::PERSISTENT:
        flags |= 0x04;
        break;
    case Storage::VOLATILE:
        break;
    }
    transport.writeByte(flags);

    if (c.getType() == CounterType::WEAK) {
        transport.writeVInt(c.getConcurrencyLevel());
    }

    if (c.getType() == CounterType::BOUNDED_STRONG)
            {
        transport.writeLong(c.getLowerBound());
        transport.writeLong(c.getUpperBound());
    }
    transport.writeLong(c.getInitialValue());
}
Exemplo n.º 2
0
long AddAndGetCounterValueOperation::executeOperation(infinispan::hotrod::transport::Transport& transport) {
    TRACE("Executing GetCounterValue(flags=%u)", flags);
    std::unique_ptr<HeaderParams> params(RetryOnFailureOperation<long>::writeHeader(transport, COUNTER_ADD_AND_GET_REQUEST));
    writeName(transport, counterName);
    transport.writeLong(delta);
    transport.flush();
    uint8_t status = readHeaderAndValidate(transport, *params);
    assertBoundaries(status);
    TRACE("Finished GetCounterValue");
    if (!isSuccess(status)) {
        throw HotRodClientException(
                std::string("Error in GetCounterValue operation, counter name: ") + counterName + " status: "
                        + std::to_string(status));
    }
    return (long)transport.readLong();
}
Exemplo 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;
}