Search in sources :

Example 1 with FailureDetectorListener

use of voldemort.cluster.failuredetector.FailureDetectorListener in project voldemort by voldemort.

the class SocketStoreClientFactory method initFailureDetector.

@Override
protected FailureDetector initFailureDetector(final ClientConfig config, Cluster cluster) {
    failureDetectorListener = new FailureDetectorListener() {

        public void nodeAvailable(Node node) {
        }

        public void nodeUnavailable(Node node) {
            if (logger.isInfoEnabled())
                logger.info(node + " has been marked as unavailable, destroying socket pool");
            // Kill the socket pool for this node...
            SocketDestination destination = new SocketDestination(node.getHost(), node.getSocketPort(), config.getRequestFormatType());
            storeFactory.close(destination);
        }
    };
    ClientStoreConnectionVerifier verifier = new ClientStoreConnectionVerifier() {

        @Override
        protected Store<ByteArray, byte[], byte[]> getStoreInternal(Node node) {
            logger.debug("Returning a new store verifier for node: " + node);
            return SocketStoreClientFactory.this.getStore(MetadataStore.METADATA_STORE_NAME, node.getHost(), node.getSocketPort(), config.getRequestFormatType());
        }
    };
    FailureDetectorConfig failureDetectorConfig = new FailureDetectorConfig(config).setCluster(cluster).setConnectionVerifier(verifier);
    return create(failureDetectorConfig, false, failureDetectorListener);
}
Also used : FailureDetectorListener(voldemort.cluster.failuredetector.FailureDetectorListener) SocketDestination(voldemort.store.socket.SocketDestination) Node(voldemort.cluster.Node) FailureDetectorConfig(voldemort.cluster.failuredetector.FailureDetectorConfig) ClientStoreConnectionVerifier(voldemort.cluster.failuredetector.ClientStoreConnectionVerifier) ByteArray(voldemort.utils.ByteArray)

Aggregations

Node (voldemort.cluster.Node)1 ClientStoreConnectionVerifier (voldemort.cluster.failuredetector.ClientStoreConnectionVerifier)1 FailureDetectorConfig (voldemort.cluster.failuredetector.FailureDetectorConfig)1 FailureDetectorListener (voldemort.cluster.failuredetector.FailureDetectorListener)1 SocketDestination (voldemort.store.socket.SocketDestination)1 ByteArray (voldemort.utils.ByteArray)1