org.mongodb.morphia.AdvancedDatastore Java Examples
The following examples show how to use
org.mongodb.morphia.AdvancedDatastore.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongoLogConnector.java From heimdall with Apache License 2.0 | 6 votes |
/** * Creates a descending list of metrics for a specified period of time. * * @param id * Trace field wanted * @param size * max number of elements to return * @param period * period of time wanted * @return List of metrics */ public List<Metric> findByTop(String id, int size, Periods period) { final AdvancedDatastore datastore = this.datastore(); Query<LogTrace> query = prepareRange(datastore.createQuery(this.collection, LogTrace.class), period); query.field(id).notEqual(null); final AggregationPipeline pipeline = datastore.createAggregation(this.collection, LogTrace.class).match(query) .group(id, Group.grouping(METRIC, Group.last(id)), Group.grouping(VALUE, Accumulator.accumulator("$sum", 1))) .sort(Sort.descending(VALUE)).limit(size); final Iterator<Metric> aggregate = pipeline.aggregate(Metric.class); List<Metric> list = new ArrayList<>(); aggregate.forEachRemaining(list::add); return list; }
Example #2
Source File: MongoLogConnector.java From heimdall with Apache License 2.0 | 6 votes |
public List<Metric> findByMetricBySum(String id, String source, String metric, Periods period) { final AdvancedDatastore datastore = this.datastore(); Query<LogTrace> query = prepareRange(datastore.createQuery(this.collection, LogTrace.class), period); query.field(source).equal(id); final AggregationPipeline aggregation = datastore.createAggregation(this.collection, LogTrace.class) .match(query).group(metric, Group.grouping(METRIC, Group.last(metric)), Group.grouping(VALUE, Accumulator.accumulator("$sum", 1))); final Iterator<Metric> aggregate = aggregation.aggregate(Metric.class); List<Metric> list = new ArrayList<>(); aggregate.forEachRemaining(list::add); return list; }
Example #3
Source File: MongoStoreProvider.java From alchemy with MIT License | 5 votes |
public MongoStoreProvider(MongoClient client, String database) { final Morphia morphia = new Morphia(); morphia.getMapper().getOptions().setStoreEmpties(true); morphia.getMapper().getConverters().addConverter(DateTimeConverter.class); this.client = client; final AdvancedDatastore ds = (AdvancedDatastore) morphia.createDatastore(client, database); final RevisionManager revisionManager = new RevisionManager(ds); this.store = new MongoExperimentsStore(ds, revisionManager); this.cache = new MongoExperimentsCache(ds, revisionManager); }
Example #4
Source File: MongoLogConnector.java From heimdall with Apache License 2.0 | 4 votes |
public List<Metric> findByMetricByAvg(String id, String source, String metric, Periods period) { final AdvancedDatastore datastore = this.datastore(); Query<LogTrace> query = prepareRange(datastore.createQuery(this.collection, LogTrace.class), period); query.field(source).equal(id); final AggregationPipeline aggregation = datastore.createAggregation(this.collection, LogTrace.class) .match(query).group(source, Group.grouping(METRIC, Group.last(source)), Group.grouping(VALUE, Accumulator.accumulator("$avg", metric))); final Iterator<Metric> aggregate = aggregation.aggregate(Metric.class); List<Metric> list = new ArrayList<>(); aggregate.forEachRemaining(list::add); return list; }
Example #5
Source File: RevisionManager.java From alchemy with MIT License | 4 votes |
public RevisionManager(AdvancedDatastore ds) { this.ds = ds; initializeRevision(); }
Example #6
Source File: MongoExperimentsStore.java From alchemy with MIT License | 4 votes |
public MongoExperimentsStore(AdvancedDatastore ds, RevisionManager revisionManager) { this.ds = ds; this.revisionManager = revisionManager; }
Example #7
Source File: MongoPreLoader.java From light-task-scheduler with Apache License 2.0 | 4 votes |
public MongoPreLoader(final AppContext appContext) { super(appContext); this.template = new MongoTemplate( (AdvancedDatastore) DataStoreProvider.getDataStore(appContext.getConfig())); }
Example #8
Source File: MongoTemplate.java From light-task-scheduler with Apache License 2.0 | 4 votes |
public MongoTemplate(AdvancedDatastore ds) { this.ds = ds; }
Example #9
Source File: MongoRepository.java From light-task-scheduler with Apache License 2.0 | 4 votes |
public MongoRepository(Config config) { this.template = new MongoTemplate( (AdvancedDatastore) DataStoreProvider.getDataStore(config)); }
Example #10
Source File: MongoLogConnector.java From heimdall with Apache License 2.0 | 3 votes |
private AdvancedDatastore datastore() { Morphia morphia = new Morphia(); if (this.client == null) { this.createMongoClient(); } return (AdvancedDatastore) morphia.createDatastore(this.client, this.databaseName); }