// Path: src/main/java/net/floodlightcontroller/debugcounter/IDebugCounter.java
// public interface IDebugCounter {
//     /**
//      * Increments the counter by 1 thread-locally, and immediately flushes to
//      * the global counter storage. This method should be used for counters that
//      * are updated outside the OF message processing pipeline.
//      */
//     void updateCounterWithFlush();
// 
//     /**
//      * Increments the counter by 1 thread-locally. Flushing to the global
//      * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
//      * resulting in higher performance. This method should be used for counters
//      * updated in the OF message processing pipeline.
//      */
//     void updateCounterNoFlush();
// 
//     /**
//      * Increments the counter thread-locally by the 'incr' specified, and immediately
//      * flushes to the global counter storage. This method should be used for counters
//      * that are updated outside the OF message processing pipeline.
//      */
//     void updateCounterWithFlush(int incr);
// 
//     /**
//      * Increments the counter thread-locally by the 'incr' specified. Flushing to the global
//      * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
//      * resulting in higher performance. This method should be used for counters
//      * updated in the OF message processing pipeline.
//      */
//     void updateCounterNoFlush(int incr);
// 
//     /**
//      * Retrieve the value of the counter from the global counter store
//      */
//     long getCounterValue();
// }
// 
// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCService.java
// protected static class NodeMessage extends Pair<Short,SyncMessage> {
//     private static final long serialVersionUID = -3443080461324647922L;
// 
//     public NodeMessage(Short first, SyncMessage second) {
//         super(first, second);
//     }
// }


import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Map.Entry;
import net.floodlightcontroller.core.annotations.LogMessageCategory;
import net.floodlightcontroller.core.annotations.LogMessageDoc;
import net.floodlightcontroller.debugcounter.IDebugCounter;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.MessageEvent;
import org.sdnplatform.sync.IClosableIterator;
import org.sdnplatform.sync.IStoreClient;
import org.sdnplatform.sync.IVersion;
import org.sdnplatform.sync.Versioned;
import org.sdnplatform.sync.ISyncService.Scope;
import org.sdnplatform.sync.error.AuthException;
import org.sdnplatform.sync.error.ObsoleteVersionException;
import org.sdnplatform.sync.error.SyncException;
import org.sdnplatform.sync.internal.Cursor;
import org.sdnplatform.sync.internal.SyncManager;
import org.sdnplatform.sync.internal.config.AuthScheme;
import org.sdnplatform.sync.internal.config.ClusterConfig;
import org.sdnplatform.sync.internal.config.Node;
import org.sdnplatform.sync.internal.config.SyncStoreCCProvider;
import org.sdnplatform.sync.internal.rpc.RPCService.NodeMessage;
import org.sdnplatform.sync.internal.store.IStorageEngine;
import org.sdnplatform.sync.internal.util.ByteArray;
import org.sdnplatform.sync.internal.util.CryptoUtil;
import org.sdnplatform.sync.internal.version.VectorClock;
import org.sdnplatform.sync.thrift.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
    }

    @Override
    protected AuthScheme getAuthScheme() {
        return syncManager.getClusterConfig().getAuthScheme();
    }

    @Override
    protected byte[] getSharedSecret() throws AuthException {
        String path = syncManager.getClusterConfig().getKeyStorePath();
        String pass = syncManager.getClusterConfig().getKeyStorePassword();
        try {
            return CryptoUtil.getSharedSecret(path, pass);
        } catch (Exception e) {
            throw new AuthException("Could not read challenge/response " +
                    "shared secret from key store " + path, e);
        }
    }

    @Override
    protected SyncMessage getError(int transactionId, Exception error,
                                   MessageType type) {
        updateCounter(SyncManager.counterErrorProcessing, 1);
        return super.getError(transactionId, error, type);
    }

    // *****************
    // Utility functions
    // *****************

// Path: src/main/java/net/floodlightcontroller/debugcounter/IDebugCounter.java
// public interface IDebugCounter {
//     /**
//      * Increments the counter by 1 thread-locally, and immediately flushes to
//      * the global counter storage. This method should be used for counters that
//      * are updated outside the OF message processing pipeline.
//      */
//     void updateCounterWithFlush();
// 
//     /**
//      * Increments the counter by 1 thread-locally. Flushing to the global
//      * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
//      * resulting in higher performance. This method should be used for counters
//      * updated in the OF message processing pipeline.
//      */
//     void updateCounterNoFlush();
// 
//     /**
//      * Increments the counter thread-locally by the 'incr' specified, and immediately
//      * flushes to the global counter storage. This method should be used for counters
//      * that are updated outside the OF message processing pipeline.
//      */
//     void updateCounterWithFlush(int incr);
// 
//     /**
//      * Increments the counter thread-locally by the 'incr' specified. Flushing to the global
//      * counter storage is delayed (happens with flushCounters() in IDebugCounterService),
//      * resulting in higher performance. This method should be used for counters
//      * updated in the OF message processing pipeline.
//      */
//     void updateCounterNoFlush(int incr);
// 
//     /**
//      * Retrieve the value of the counter from the global counter store
//      */
//     long getCounterValue();
// }
// 
// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCService.java
// protected static class NodeMessage extends Pair<Short,SyncMessage> {
//     private static final long serialVersionUID = -3443080461324647922L;
// 
//     public NodeMessage(Short first, SyncMessage second) {
//         super(first, second);
//     }
// }


// Path: src/main/java/org/sdnplatform/sync/internal/rpc/RPCChannelHandler.java
import java.nio.ByteBuffer;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.Map.Entry;
import net.floodlightcontroller.core.annotations.LogMessageCategory;
import net.floodlightcontroller.core.annotations.LogMessageDoc;
import net.floodlightcontroller.debugcounter.IDebugCounter;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.MessageEvent;
import org.sdnplatform.sync.IClosableIterator;
import org.sdnplatform.sync.IStoreClient;
import org.sdnplatform.sync.IVersion;
import org.sdnplatform.sync.Versioned;
import org.sdnplatform.sync.ISyncService.Scope;
import org.sdnplatform.sync.error.AuthException;
import org.sdnplatform.sync.error.ObsoleteVersionException;
import org.sdnplatform.sync.error.SyncException;
import org.sdnplatform.sync.internal.Cursor;
import org.sdnplatform.sync.internal.SyncManager;
import org.sdnplatform.sync.internal.config.AuthScheme;
import org.sdnplatform.sync.internal.config.ClusterConfig;
import org.sdnplatform.sync.internal.config.Node;
import org.sdnplatform.sync.internal.config.SyncStoreCCProvider;
import org.sdnplatform.sync.internal.rpc.RPCService.NodeMessage;
import org.sdnplatform.sync.internal.store.IStorageEngine;
import org.sdnplatform.sync.internal.util.ByteArray;
import org.sdnplatform.sync.internal.util.CryptoUtil;
import org.sdnplatform.sync.internal.version.VectorClock;
import org.sdnplatform.sync.thrift.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

    }

    @Override
    protected AuthScheme getAuthScheme() {
        return syncManager.getClusterConfig().getAuthScheme();
    }

    @Override
    protected byte[] getSharedSecret() throws AuthException {
        String path = syncManager.getClusterConfig().getKeyStorePath();
        String pass = syncManager.getClusterConfig().getKeyStorePassword();
        try {
            return CryptoUtil.getSharedSecret(path, pass);
        } catch (Exception e) {
            throw new AuthException("Could not read challenge/response " +
                    "shared secret from key store " + path, e);
        }
    }

    @Override
    protected SyncMessage getError(int transactionId, Exception error,
                                   MessageType type) {
        updateCounter(SyncManager.counterErrorProcessing, 1);
        return super.getError(transactionId, error, type);
    }

    // *****************
    // Utility functions
    // *****************

    protected void updateCounter(IDebugCounter counter, int incr) {