use of com.cloudant.client.api.model.Shard in project java-cloudant by cloudant.
the class DatabaseTest method shards.
@Test
@RequiresCloudant
public void shards() {
List<Shard> shards = db.getShards();
assert (shards.size() > 0);
for (Shard s : shards) {
assertNotNull(s.getRange());
assertNotNull(s.getNodes());
assertNotNull(s.getNodes().hasNext());
}
}
use of com.cloudant.client.api.model.Shard in project java-cloudant by cloudant.
the class DatabaseTest method shard.
@Test
@RequiresCloudant
public void shard() {
Shard s = db.getShard("snipe");
assertNotNull(s);
assertNotNull(s.getRange());
assertNotNull(s.getNodes());
assert (s.getNodes().hasNext());
}
use of com.cloudant.client.api.model.Shard in project java-cloudant by cloudant.
the class ShardDeserializer method deserialize.
public List<Shard> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
final List<Shard> shards = new ArrayList<Shard>();
final JsonObject jsonObject = json.getAsJsonObject();
Set<Map.Entry<String, JsonElement>> shardsObj = jsonObject.get("shards").getAsJsonObject().entrySet();
for (Map.Entry<String, JsonElement> entry : shardsObj) {
String range = entry.getKey();
List<String> nodeNames = context.deserialize(entry.getValue(), DeserializationTypes.STRINGS);
shards.add(new Shard(range, nodeNames));
}
return shards;
}
Aggregations