All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.clustermate.client.NodeFailure Maven / Gradle / Ivy

There is a newer version: 0.10.5
Show newest version
package com.fasterxml.clustermate.client;

import java.util.*;

import com.fasterxml.clustermate.client.call.CallFailure;

/**
 * Class that contains information about failure of an operation as it
 * relates to call(s) to a single server node.
 * Each instance contains at least one actual {@link CallFailure}.
 */
public class NodeFailure
{
    protected final ClusterServerNode _server;

    protected LinkedList _failures;
    
    public NodeFailure(ClusterServerNode server, CallFailure firstFail)
    {
        _server = server;
        _failures = new LinkedList();
        _failures.add(firstFail);
    }

    public void addFailure(CallFailure fail) {
        _failures.add(fail);
    }
    
    public ClusterServerNode getServer() { return _server; }

    /**
     * Returns number of attempts that were made before giving up
     */
    public int getFailCount() { return _failures.size(); }

    public CallFailure getFirstCallFailure() { return _failures.getFirst(); }
    public CallFailure getLastCallFailure() { return _failures.getLast(); }

    public Iterable getCallFailures() { return _failures; }

    @Override
    public String toString() {
        return "[Node Failure: "+_failures.size()+" failed; first = "+getFirstCallFailure()+"]";
    }

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy