Package com.mongodb

Examples of com.mongodb.BasicDBObject


    @Override
    public List<StreamRule> loadForStreamId(String streamId) throws NotFoundException {
        ObjectId id = new ObjectId(streamId);
        final List<StreamRule> streamRules = new ArrayList<StreamRule>();
        final List<DBObject> respStreamRules = query(StreamRuleImpl.class,
                new BasicDBObject("stream_id", id)
        );

        for (DBObject streamRule : respStreamRules) {
            streamRules.add(load((ObjectId) streamRule.get("_id")));
        }
View Full Code Here


        markAsAlive(node, isMaster, restTransportAddress.toString());
    }

    @Override
    public boolean isOnlyMaster(NodeId nodeId) {
        BasicDBObject query = new BasicDBObject();
        query.put("type", NodeImpl.Type.SERVER.toString());
        query.put("last_seen", new BasicDBObject("$gte", Tools.getUTCTimestamp() - pingTimeout));
        query.put("node_id", new BasicDBObject("$ne", nodeId.toString()));
        query.put("is_master", true);

        return query(NodeImpl.class, query).size() == 0;
    }
View Full Code Here

    private void collectTimerReports(List<DBObject> docs, SortedMap<String,Timer> timers, Date timestamp) {
        if (timers.isEmpty())
            return;
        for (Map.Entry<String, Timer> entry : timers.entrySet()) {
            final BasicDBObject report = getBasicDBObject(timestamp, entry.getKey(), "timer");
            final Timer v = entry.getValue();
            final Snapshot s = v.getSnapshot();
            // meter part
            report.put("count", v.getCount());
            report.put("rate-unit", getRateUnit());
            report.put("1-minute-rate", convertRate(v.getOneMinuteRate()));
            report.put("5-minute-rate", convertRate(v.getFiveMinuteRate()));
            report.put("15-minute-rate", convertRate(v.getFifteenMinuteRate()));
            report.put("mean-rate", convertRate(v.getMeanRate()));

            // histogram part
            report.put("duration-unit", getDurationUnit());
            report.put("75-percentile", convertDuration(s.get75thPercentile()));
            report.put("95-percentile", convertDuration(s.get95thPercentile()));
            report.put("98-percentile", convertDuration(s.get98thPercentile()));
            report.put("99-percentile", convertDuration(s.get99thPercentile()));
            report.put("999-percentile", convertDuration(s.get999thPercentile()));
            report.put("max", convertDuration(s.getMax()));
            report.put("min", convertDuration(s.getMin()));
            report.put("mean", convertDuration(s.getMean()));
            report.put("median", convertDuration(s.getMedian()));
            report.put("stddev", convertDuration(s.getStdDev()));
            docs.add(report);
        }
    }
View Full Code Here

        return query(NodeImpl.class, query).size() == 0;
    }

    @Override
    public boolean isAnyMasterPresent() {
        BasicDBObject query = new BasicDBObject();
        query.put("type", NodeImpl.Type.SERVER.toString());
        query.put("last_seen", new BasicDBObject("$gte", Tools.getUTCTimestamp() - pingTimeout));
        query.put("is_master", true);

        return query(NodeImpl.class, query).size() > 0;
    }
View Full Code Here

    }



    private BasicDBObject getBasicDBObject(Date timestamp, String metricName, String metricType) {
        final BasicDBObject report = new BasicDBObject();

        report.put("_id", new ObjectId());
        report.put("type", metricType);
        report.put("timestamp", timestamp);
        report.put("name", metricName);
        report.put("node", nodeId);

        return report;
    }
View Full Code Here

    }

    @Override
    public List<Input> allOfThisNode(final String nodeId) {
        final List<BasicDBObject> query = ImmutableList.of(
                new BasicDBObject(MessageInput.FIELD_NODE_ID, nodeId),
                new BasicDBObject(MessageInput.FIELD_GLOBAL, true));
        final List<DBObject> ownInputs = query(InputImpl.class, new BasicDBObject("$or", query));

        final ImmutableList.Builder<Input> inputs = ImmutableList.builder();
        for (final DBObject o : ownInputs) {
            inputs.add(new InputImpl((ObjectId) o.get("_id"), o.toMap()));
        }
View Full Code Here

    }

    @Override
    public List<Input> allOfRadio(Node radio) {
        final List<BasicDBObject> query = ImmutableList.of(
                new BasicDBObject(MessageInput.FIELD_RADIO_ID, radio.getNodeId()),
                new BasicDBObject(MessageInput.FIELD_GLOBAL, true));

        final ImmutableList.Builder<Input> inputs = ImmutableList.builder();
        for (DBObject o : query(InputImpl.class, new BasicDBObject("$or", query))) {
            inputs.add(new InputImpl((ObjectId) o.get("_id"), o.toMap()));
        }

        return inputs.build();
    }
View Full Code Here

    }

    @Override
    public Input findForThisNodeOrGlobal(String nodeId, String id) throws NotFoundException {
        final List<BasicDBObject> forThisNodeOrGlobal = ImmutableList.of(
                new BasicDBObject(MessageInput.FIELD_NODE_ID, nodeId),
                new BasicDBObject(MessageInput.FIELD_GLOBAL, true));

        final List<BasicDBObject> query = ImmutableList.of(
                new BasicDBObject("_id", new ObjectId(id)),
                new BasicDBObject("$or", forThisNodeOrGlobal));

        final DBObject o = findOne(InputImpl.class, new BasicDBObject("$and", query));
        return new InputImpl((ObjectId) o.get("_id"), o.toMap());
    }
View Full Code Here

    }

    @Override
    public Input findForThisRadioOrGlobal(final String radioId, String id) throws NotFoundException {
        final List<DBObject> radioIdOrGlobal = ImmutableList.<DBObject>of(
                new BasicDBObject(MessageInput.FIELD_RADIO_ID, radioId),
                new BasicDBObject(MessageInput.FIELD_GLOBAL, true));

        final List<DBObject> query = ImmutableList.<DBObject>of(
                new BasicDBObject("_id", new ObjectId(id)),
                new BasicDBObject("$or", radioIdOrGlobal));

        final DBObject o = findOne(InputImpl.class, new BasicDBObject("$and", query));
        if (o == null) {
            throw new NotFoundException();
        } else {
            return new InputImpl((ObjectId) o.get("_id"), o.toMap());
        }
View Full Code Here

    }

    @Override
    public Input findForThisNode(String nodeId, String id) throws NotFoundException, IllegalArgumentException {
        final List<BasicDBObject> forThisNode = ImmutableList.of(
                new BasicDBObject(MessageInput.FIELD_NODE_ID, nodeId),
                new BasicDBObject(MessageInput.FIELD_GLOBAL, false));

        final List<BasicDBObject> query = ImmutableList.of(
                new BasicDBObject("_id", new ObjectId(id)),
                new BasicDBObject("$and", forThisNode));

        final DBObject o = findOne(InputImpl.class, new BasicDBObject("$and", query));
        if (o == null) {
            throw new NotFoundException();
        } else {
            return new InputImpl((ObjectId) o.get("_id"), o.toMap());
        }
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.