use of logisticspipes.interfaces.routing.IProvide in project LogisticsPipes by RS485.
the class RequestTreeNode method getProviders.
private static List<Pair<IProvide, List<IFilter>>> getProviders(IRouter destination, IResource item) {
// get all the routers
BitSet routersIndex = ServerRouter.getRoutersInterestedIn(item);
// get the routing table
List<ExitRoute> validSources = new ArrayList<>();
for (int i = routersIndex.nextSetBit(0); i >= 0; i = routersIndex.nextSetBit(i + 1)) {
IRouter r = SimpleServiceLocator.routerManager.getServerRouter(i);
if (r.isCacheInvalid()) {
// Skip Routers without a valid pipe
continue;
}
List<ExitRoute> e = destination.getDistanceTo(r);
if (e != null) {
validSources.addAll(e);
}
}
// closer providers are good
validSources.sort(new workWeightedSorter(1.0));
List<Pair<IProvide, List<IFilter>>> providers = new LinkedList<>();
validSources.stream().filter(r -> r.containsFlag(PipeRoutingConnectionType.canRequestFrom)).forEach(r -> {
CoreRoutedPipe pipe = r.destination.getPipe();
if (pipe instanceof IProvide) {
List<IFilter> list = new LinkedList<>(r.filters);
providers.add(new Pair<>((IProvide) pipe, list));
}
});
return providers;
}
Aggregations