use of com.newcosoft.cache.Shard in project disgear by yangbutao.
the class ZookeeperController method waitForCoreNodeName.
private void waitForCoreNodeName(CollectionDesc descriptor) {
int retryCount = 320;
log.info("look for our core node name");
while (retryCount-- > 0) {
Map<String, Shard> slicesMap = zkStateReader.getClusterState().getSlicesMap(descriptor.getCollectionName());
if (slicesMap != null) {
for (Shard slice : slicesMap.values()) {
for (Replica replica : slice.getReplicas()) {
String baseUrl = replica.getStr(ZkStateReader.BASE_URL_PROP);
String core = replica.getStr(ZkStateReader.CORE_NAME_PROP);
String msgBaseUrl = getBaseUrl();
String msgCore = descriptor.getCollectionName();
if (baseUrl.equals(msgBaseUrl) && core.equals(msgCore)) {
descriptor.setCoreNodeName(replica.getName());
return;
}
}
}
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
use of com.newcosoft.cache.Shard in project disgear by yangbutao.
the class ClusterState method collectionFromObjects.
private static CacheCollection collectionFromObjects(String name, Map<String, Object> objs) {
Map<String, Object> props;
Map<String, Shard> slices;
Map<String, Object> sliceObjs = (Map<String, Object>) objs.get(CacheCollection.SHARDS);
if (sliceObjs == null) {
slices = makeShards(objs);
props = Collections.emptyMap();
} else {
slices = makeShards(sliceObjs);
props = new HashMap<String, Object>(objs);
objs.remove(CacheCollection.SHARDS);
}
Router router = Router.DEFAULT;
return new CacheCollection(name, slices, props, router);
}
Aggregations