com.fasterxml.clustermate.client.operation.InfoOperationResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clustermate-client Show documentation
Show all versions of clustermate-client Show documentation
Building blocks for client libraries that access
ClusterMate-based service.
package com.fasterxml.clustermate.client.operation;
import java.util.*;
import com.fasterxml.clustermate.api.msg.ItemInfo;
import com.fasterxml.clustermate.client.ClusterServerNode;
import com.fasterxml.clustermate.client.NodeFailure;
import com.fasterxml.clustermate.client.call.ReadCallResult;
/**
* Result value produced by EntryInspector
, contains information
* about success of individual call, as well as sequence of listed
* entries in case of successful call.
*/
public class InfoOperationResult
extends OperationResultImpl>
implements Iterable>
{
protected List> _info;
protected int _successCount;
protected int _missingCount;
public InfoOperationResult(OperationConfig config, int approxSize)
{
super(config);
_info = new ArrayList>(Math.max(1, approxSize));
}
/*
/**********************************************************************
/* Building
/**********************************************************************
*/
public InfoOperationResult withSuccess(ReadCallResult callResult) {
++_successCount;
_info.add(callResult);
return this;
}
public InfoOperationResult withFailed(ReadCallResult callResult) {
return withFailed(callResult, new NodeFailure(callResult.getServer(), callResult.getFailure()));
}
public InfoOperationResult withFailed(ReadCallResult callResult, NodeFailure fail) {
_info.add(callResult);
super.withFailed(fail);
return this;
}
public InfoOperationResult withMissing(ReadCallResult callResult) {
++_missingCount;
_info.add(callResult);
return this;
}
@Override
public InfoOperationResult withFailed(Collection fails) {
throw new UnsupportedOperationException();
}
@Override
public InfoOperationResult withIgnored(ClusterServerNode server) {
throw new UnsupportedOperationException();
}
/*
/**********************************************************************
/* Accessors, default
/**********************************************************************
*/
@Override
public int getSuccessCount() {
return _successCount;
}
@Override
public OperationConfig getConfig() {
return _config;
}
/*
/**********************************************************************
/* Accessors, additional
/**********************************************************************
*/
@Override
public Iterator> iterator() {
return _info.iterator();
}
public ReadCallResult get(int index) {
if (index < 0 || index >= _info.size()) {
return null;
}
return _info.get(index);
}
public int getMissingCount() {
return _missingCount;
}
}