Search in sources :

Example 1 with Level

use of org.apache.cassandra.simulator.Debug.Level in project cassandra by apache.

the class Debug method debug.

public ActionListener debug(EventType type, SimulatedTime time, Cluster cluster, String keyspace, Integer primaryKey) {
    List<ActionListener> listeners = new ArrayList<>();
    for (Map.Entry<Info, Levels> e : levels.entrySet()) {
        Info info = e.getKey();
        Level level = e.getValue().get(type);
        if (level == null)
            continue;
        ActionListener listener;
        if (info == LOG) {
            Function<ActionListener, ActionListener> adapt = type == CLUSTER ? LogTermination::new : identity();
            switch(level) {
                default:
                    throw new AssertionError();
                case PLANNED:
                    listener = adapt.apply(new LogOne(time, false));
                    break;
                case CONSEQUENCES:
                case ALL:
                    listener = adapt.apply(recursive(new LogOne(time, true)));
                    break;
            }
        } else {
            Consumer<Action> debug;
            switch(info) {
                default:
                    throw new AssertionError();
                case GOSSIP:
                    debug = debugGossip(cluster);
                    break;
                case RF:
                    debug = debugRf(cluster, keyspace);
                    break;
                case RING:
                    debug = debugRing(cluster, keyspace);
                    break;
                case PAXOS:
                    debug = forKeys(cluster, keyspace, primaryKey, Debug::debugPaxos);
                    break;
                case OWNERSHIP:
                    debug = forKeys(cluster, keyspace, primaryKey, Debug::debugOwnership);
                    break;
            }
            switch(level) {
                default:
                    throw new AssertionError();
                case PLANNED:
                    listener = type == CLUSTER ? runAfterAndTransitivelyAfter(debug) : runAfter(debug);
                    break;
                case CONSEQUENCES:
                    listener = recursive(runAfter(ignoreWakeupAndLogEvents(debug)));
                    break;
                case ALL:
                    listener = recursive(runAfter(ignoreLogEvents(debug)));
                    break;
            }
        }
        listeners.add(listener);
    }
    if (listeners.isEmpty())
        return null;
    return new ActionListener.Combined(listeners);
}
Also used : ArrayList(java.util.ArrayList) Ballots.paxosDebugInfo(org.apache.cassandra.simulator.paxos.Ballots.paxosDebugInfo) Level(org.apache.cassandra.simulator.Debug.Level) Map(java.util.Map) EnumMap(java.util.EnumMap)

Aggregations

ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1 Map (java.util.Map)1 Level (org.apache.cassandra.simulator.Debug.Level)1 Ballots.paxosDebugInfo (org.apache.cassandra.simulator.paxos.Ballots.paxosDebugInfo)1