Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
<name>Russell Brown</name>
<email>russelldb@basho.com</email>
</developer>
<developer>
<name>Brian Roach</name>
<email>roach@basho.com</email>
</developer>
</developers>

<scm>
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/basho/riak/client/DefaultRiakClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import com.basho.riak.client.query.BucketKeyMapReduce;
import com.basho.riak.client.query.BucketMapReduce;
import com.basho.riak.client.query.IndexMapReduce;
import com.basho.riak.client.query.LinkWalk;
import com.basho.riak.client.query.SearchMapReduce;
import com.basho.riak.client.query.LinkWalk;
import com.basho.riak.client.query.NodeStats;
import com.basho.riak.client.raw.RawClient;
import com.basho.riak.client.raw.Transport;
import com.basho.riak.client.raw.http.HTTPClientAdapter;
Expand Down Expand Up @@ -220,4 +221,15 @@ public Transport getTransport() {
public void shutdown(){
rawClient.shutdown();
}

/* (non-Javadoc)
* @see com.basho.riak.client.IRiakClient#stats()
*/
public Iterable<NodeStats> stats() throws RiakException {
try {
return rawClient.stats();
} catch (Exception e) {
throw new RiakException(e);
}
}
}
21 changes: 15 additions & 6 deletions src/main/java/com/basho/riak/client/IRiakClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@
import com.basho.riak.client.bucket.FetchBucket;
import com.basho.riak.client.bucket.WriteBucket;
import com.basho.riak.client.cap.ClientId;
import com.basho.riak.client.query.BucketKeyMapReduce;
import com.basho.riak.client.query.BucketMapReduce;
import com.basho.riak.client.query.IndexMapReduce;
import com.basho.riak.client.query.LinkWalk;
import com.basho.riak.client.query.MapReduce;
import com.basho.riak.client.query.SearchMapReduce;
import com.basho.riak.client.query.*;
import com.basho.riak.client.query.indexes.FetchIndex;
import com.basho.riak.client.raw.Transport;
import com.basho.riak.client.raw.query.indexes.IndexQuery;
import java.util.Iterator;

/**
* Primary high-level interface for accessing Riak.
Expand Down Expand Up @@ -207,4 +203,17 @@ public interface IRiakClient {
Transport getTransport();

void shutdown();

/**
*
* Perform the Riak <code>/stats</code> operation on the node(s) this client
* is connected to.
* <p>
* <b>This is not supported by the Riak Protobuf API</b>
* <p>
* @return an {@link Iterable} object that contains one or more {@link NodeStats}
*
* @throws RiakException If Riak does not respond or if the protobuf API is being used
*/
Iterable<NodeStats> stats() throws RiakException;
}
10 changes: 10 additions & 0 deletions src/main/java/com/basho/riak/client/http/RiakClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,16 @@ public HttpResponse ping() {
return helper.ping();
}

/**
* GET Riak's <code>/stats</code> (status) resource.
*
* @return an {@link HttpResponse} with the result of GET
*/
public HttpResponse stats() {
return helper.stats();
}


/**
* Fetch the keys for <code>index</code> with <code>value</code>
*
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/basho/riak/client/http/RiakConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class RiakConfig {
private String baseUrl = null;
private String mapredPath = "/mapred";
private String pingPath = "/ping";
private String statsPath = "/stats";
private HttpClient httpClient = null;
private Integer timeout = null;
private Integer maxConnections = null;
Expand Down Expand Up @@ -105,6 +106,14 @@ public String getPingUrl() {
return baseUrl + pingPath;
}

/**
* The full URL of the Riak status (stats) resource, which is calculated by
* combining the host and port from the Riak URL and the stats path.
*/
public String getStatsUrl() {
return baseUrl + statsPath;
}

/**
* The host and port of the Riak server, which is extracted from the
* specified Riak URL.
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/basho/riak/client/http/util/ClientHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,17 @@ public RiakExceptionHandler getExceptionHandler() {
return exceptionHandler;
}

/**
* Same as {@link RiakClient#stats}
*
* @return an {@link HttpResponse} whose body should be the result of asking
* Riak for its stats (status).
*/
public HttpResponse stats() {
HttpGet get = new HttpGet(config.getStatsUrl());
return executeMethod(null, null, get, null);
}

/**
* Install an exception handler. If an exception handler is provided, then
* the Riak client will hand exceptions to the handler rather than throwing
Expand Down
Loading