Package com.mongodb

Examples of com.mongodb.BasicDBObject


    private void collectCounterReports(List<DBObject> docs, SortedMap<String, Counter> counters, Date timestamp) {
        if (counters.isEmpty())
            return;

        for (Map.Entry<String, Counter> entry : counters.entrySet()) {
            final BasicDBObject report = getBasicDBObject(timestamp, entry.getKey(), "counter");
            report.put("count", entry.getValue().getCount());
            docs.add(report);
        }
    }
View Full Code Here


    private void collectHistogramReports(List<DBObject> docs, SortedMap<String,Histogram> histograms, Date timestamp) {
        if (histograms.isEmpty())
            return;

        for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
            final BasicDBObject report = getBasicDBObject(timestamp, entry.getKey(), "histogram");
            final Histogram histogram = entry.getValue();

            final Snapshot s = histogram.getSnapshot();
            report.put("count", s.size());
            report.put("75th_percentile", s.get75thPercentile());
            report.put("95th_percentile", s.get95thPercentile());
            report.put("98th_percentile", s.get98thPercentile());
            report.put("99th_percentile", s.get99thPercentile());
            report.put("999th_percentile", s.get999thPercentile());
            report.put("max", s.getMax());
            report.put("min", s.getMin());
            report.put("mean", s.getMean());
            report.put("median", s.getMedian());
            report.put("std_dev", s.getStdDev());
            docs.add(report);
        }
    }
View Full Code Here

        if (since != null) {
            qb.and("triggered_at").greaterThanEquals(since.toDate());
        }

        BasicDBObject sort = new BasicDBObject("triggered_at", -1);

        final List<DBObject> alertObjects = query(AlertImpl.class,
                qb.get(),
                sort,
                AlertImpl.MAX_LIST_COUNT,
View Full Code Here

    @Override
    public int triggeredSecondsAgo(String streamId, String conditionId) {
        DBObject query = QueryBuilder.start("stream_id").is(streamId)
                .and("condition_id").is(conditionId).get();
        BasicDBObject sort = new BasicDBObject("triggered_at", -1);

        DBObject alert = findOne(AlertImpl.class, query, sort);

        if (alert == null) {
            return -1;
View Full Code Here

        return collection(AlertImpl.class).count();
    }

    @Override
    public long totalCountForStream(String streamId) {
        DBObject qry = new BasicDBObject("stream_id", streamId);
        return collection(AlertImpl.class).count(qry);
    }
View Full Code Here

        }
    }

    @Override
    public Node byNodeId(String nodeId) throws NodeNotFoundException {
        DBObject query = new BasicDBObject("node_id", nodeId);
        DBObject o = findOne(NodeImpl.class, query);

        if (o == null || !o.containsField("node_id")) {
            throw new NodeNotFoundException("Unable to find node " + nodeId);
        }
View Full Code Here

    private void collectMeterReports(List<DBObject> docs, SortedMap<String, Meter> meters, Date timestamp) {
        if (meters.isEmpty())
            return;
        for (Map.Entry<String, Meter> entry : meters.entrySet()) {
            final BasicDBObject report = getBasicDBObject(timestamp, entry.getKey(), "meter");
            final Meter v = entry.getValue();
            report.put("count", v.getCount());
            report.put("1-minute-rate", v.getOneMinuteRate());
            report.put("5-minute-rate", v.getFiveMinuteRate());
            report.put("15-minute-rate", v.getFifteenMinuteRate());
            report.put("mean-rate", v.getMeanRate());
            docs.add(report);
        }

    }
View Full Code Here

        super(mongoConnection);
    }

    @Override
    public StreamRule load(ObjectId id) throws NotFoundException {
        BasicDBObject o = (BasicDBObject) get(StreamRuleImpl.class, id);

        if (o == null) {
            throw new NotFoundException();
        }

        return new StreamRuleImpl((ObjectId) o.get("_id"), o.toMap());
    }
View Full Code Here

    @Override
    public Map<String, Node> allActive(NodeImpl.Type type) {
        Map<String, Node> nodes = Maps.newHashMap();

        BasicDBObject query = new BasicDBObject();
        query.put("last_seen", new BasicDBObject("$gte", Tools.getUTCTimestamp() - pingTimeout));
        query.put("type", type.toString());

        for (DBObject obj : query(NodeImpl.class, query)) {
            Node node = new NodeImpl((ObjectId) obj.get("_id"), obj.toMap());
            String nodeId = (String) obj.get("node_id");
View Full Code Here

        return nodes;
    }

    @Override
    public void dropOutdated() {
        BasicDBObject query = new BasicDBObject();
        query.put("last_seen", new BasicDBObject("$lt", Tools.getUTCTimestamp() - pingTimeout));

        destroyAll(NodeImpl.class, query);
    }
View Full Code Here

TOP

Related Classes of com.mongodb.BasicDBObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.