use of org.atlasapi.equivalence.EquivalenceGraphStore in project atlas-deer by atlasapi.
the class CassandraEquivalentContentStoreIT method suite.
public static junit.framework.Test suite() throws Exception {
TestSuite suite = new TestSuite("CassandraEquivalentContentStoreIT");
final TestCassandraPersistenceModule module = new TestCassandraPersistenceModule();
module.startAsync().awaitRunning(1, TimeUnit.MINUTES);
suite.addTest(EquivalentContentStoreTestSuiteBuilder.using(new EquivalentContentStoreSubjectGenerator() {
@Override
public EquivalentContentStore getEquivalentContentStore() {
return module.equivalentContentStore();
}
@Override
public EquivalenceGraphStore getEquivalenceGraphStore() {
return module.contentEquivalenceGraphStore();
}
@Override
public ContentStore getContentStore() {
return module.contentStore();
}
}).withTearDown(new Runnable() {
@Override
public void run() {
try {
module.reset();
} catch (ConnectionException e) {
throw new RuntimeException(e);
}
}
}).named("CassandraEquivalentContentStoreIntegrationSuite").createTestSuite());
return suite;
}
use of org.atlasapi.equivalence.EquivalenceGraphStore in project atlas-deer by atlasapi.
the class ChannelIntervalScheduleBootstrapTask method writeEquivalences.
private void writeEquivalences(ImmutableList<ScheduleHierarchy> builtSchedule) {
if (!equivalenceUpdater.isPresent()) {
return;
}
List<Item> items = builtSchedule.stream().map(ScheduleHierarchy::getItemAndBroadcast).map(ItemAndBroadcast::getItem).collect(Collectors.toList());
List<Id> ids = items.stream().map(Item::getId).collect(Collectors.toList());
EquivalenceGraphStore graphStore = equivGraphStore.get();
EquivalentScheduleWriter updater = equivalenceUpdater.get();
try {
Map<Id, Optional<EquivalenceGraph>> graphs = graphStore.resolveIds(items.stream().map(Item::getId).collect(Collectors.toList())).get();
for (Id id : ids) {
Optional<EquivalenceGraph> graph = graphs.get(id);
if (graph.isPresent()) {
EquivalenceGraphUpdate update = EquivalenceGraphUpdate.builder(graph.get()).build();
updater.updateEquivalences(update.getAllGraphs());
} else {
log.warn("Failed to resolve graph for {}", id);
}
}
} catch (WriteException | InterruptedException | ExecutionException e) {
log.warn("Failed to update equivs {} {} {}", source, channel, interval);
throw Throwables.propagate(e);
}
}
Aggregations