Search in sources :

Example 1 with ParamType

use of org.apache.cassandra.net.ParamType in project cassandra by apache.

the class ReadCallback method onResponse.

@Override
public void onResponse(Message<ReadResponse> message) {
    assertWaitingFor(message.from());
    Map<ParamType, Object> params = message.header.params();
    InetAddressAndPort from = message.from();
    if (WarningContext.isSupported(params.keySet())) {
        RequestFailureReason reason = getWarningContext().updateCounters(params, from);
        if (reason != null) {
            onFailure(message.from(), reason);
            return;
        }
    }
    resolver.preprocess(message);
    /*
         * Ensure that data is present and the response accumulator has properly published the
         * responses it has received. This may result in not signaling immediately when we receive
         * the minimum number of required results, but it guarantees at least the minimum will
         * be accessible when we do signal. (see CASSANDRA-16807)
         */
    if (resolver.isDataPresent() && resolver.responses.size() >= blockFor)
        condition.signalAll();
}
Also used : InetAddressAndPort(org.apache.cassandra.locator.InetAddressAndPort) RequestFailureReason(org.apache.cassandra.exceptions.RequestFailureReason) ParamType(org.apache.cassandra.net.ParamType)

Example 2 with ParamType

use of org.apache.cassandra.net.ParamType in project cassandra by apache.

the class WarningContext method updateCounters.

public RequestFailureReason updateCounters(Map<ParamType, Object> params, InetAddressAndPort from) {
    for (Map.Entry<ParamType, Object> entry : params.entrySet()) {
        WarnAbortCounter counter = null;
        RequestFailureReason reason = null;
        switch(entry.getKey()) {
            case ROW_INDEX_SIZE_ABORT:
                reason = RequestFailureReason.READ_SIZE;
            case ROW_INDEX_SIZE_WARN:
                counter = rowIndexTooLarge;
                break;
            case LOCAL_READ_SIZE_ABORT:
                reason = RequestFailureReason.READ_SIZE;
            case LOCAL_READ_SIZE_WARN:
                counter = localReadSize;
                break;
            case TOMBSTONE_ABORT:
                reason = RequestFailureReason.READ_TOO_MANY_TOMBSTONES;
            case TOMBSTONE_WARNING:
                counter = tombstones;
                break;
        }
        if (reason != null) {
            counter.addAbort(from, ((Number) entry.getValue()).longValue());
            return reason;
        }
        if (counter != null)
            counter.addWarning(from, ((Number) entry.getValue()).longValue());
    }
    return null;
}
Also used : RequestFailureReason(org.apache.cassandra.exceptions.RequestFailureReason) Map(java.util.Map) ParamType(org.apache.cassandra.net.ParamType)

Example 3 with ParamType

use of org.apache.cassandra.net.ParamType in project cassandra by apache.

the class MessageOutBench method setup.

@Setup
public void setup() {
    DatabaseDescriptor.daemonInitialization();
    UUID uuid = UUIDGen.getTimeUUID();
    Map<ParamType, Object> parameters = new EnumMap<>(ParamType.class);
    if (withParams) {
        parameters.put(ParamType.TRACE_SESSION, uuid);
    }
    addr = InetAddressAndPort.getByAddress(InetAddresses.forString("127.0.73.101"));
    msgOut = Message.builder(ECHO_REQ, NoPayload.noPayload).from(addr).build();
    // 1k should be enough for everybody!
    buf = Unpooled.buffer(1024, 1024);
}
Also used : UUID(java.util.UUID) EnumMap(java.util.EnumMap) ParamType(org.apache.cassandra.net.ParamType) Setup(org.openjdk.jmh.annotations.Setup)

Aggregations

ParamType (org.apache.cassandra.net.ParamType)3 RequestFailureReason (org.apache.cassandra.exceptions.RequestFailureReason)2 EnumMap (java.util.EnumMap)1 Map (java.util.Map)1 UUID (java.util.UUID)1 InetAddressAndPort (org.apache.cassandra.locator.InetAddressAndPort)1 Setup (org.openjdk.jmh.annotations.Setup)1