• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DBAddress类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.mongodb.DBAddress的典型用法代码示例。如果您正苦于以下问题:Java DBAddress类的具体用法?Java DBAddress怎么用?Java DBAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DBAddress类属于com.mongodb包,在下文中一共展示了DBAddress类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: performBenchMark_WriteConcern

import com.mongodb.DBAddress; //导入依赖的package包/类
@Ignore
@Test
public void performBenchMark_WriteConcern() throws UnknownHostException, InterruptedException {
    Mongo mongo = new Mongo(new DBAddress(remoteServer));
    final DB db = mongo.getDB(TEST_DB1);
    final DBCollection nodes = db.getCollection("nodes");
    final DBCollection blobs = db.getCollection("blobs");
    int readers = 0;
    int writers = 2;
    for(WriteConcern wc : namedConcerns.keySet()){
        prepareDB(nodes,blobs);
        final Benchmark b = new Benchmark(nodes, blobs);
        Result r = b.run(readers, writers, true, wc);
        results.add(r);
    }

    prepareDB(nodes,blobs);

    dumpResult();
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:21,代码来源:BlobThroughPutTest.java


示例2: performBenchMark

import com.mongodb.DBAddress; //导入依赖的package包/类
@Ignore
@Test
public void performBenchMark() throws UnknownHostException, InterruptedException {
    Mongo local = new Mongo(new DBAddress(localServer));
    Mongo remote = new Mongo(new DBAddress(remoteServer));

    run(local, false, false);
    run(local, true, false);
    run(remote, false, true);
    run(remote, true, true);

    dumpResult();
}
 
开发者ID:denismo,项目名称:jackrabbit-dynamodb-store,代码行数:14,代码来源:BlobThroughPutTest.java


示例3: discoverResources

import com.mongodb.DBAddress; //导入依赖的package包/类
@Override
public Set<DiscoveredResourceDetails> discoverResources(
        ResourceDiscoveryContext context)
        throws InvalidPluginConfigurationException, Exception {

    Set<DiscoveredResourceDetails> details = new HashSet<DiscoveredResourceDetails>();
    List<ProcessScanResult> processes = context.getAutoDiscoveredProcesses();
    for (ProcessScanResult p : processes) {
        String[] cl = p.getProcessInfo().getCommandLine();
        int port = DBAddress.defaultPort();
        String host = "localhost";
        for (int i = 1; i < cl.length; i++) { // 0 = command
            if (cl[i].equals("--port"))
                port = Integer.parseInt(cl[++i]);
            if (cl[i].equals("--bind_ip"))
                host = cl[++i].split(",")[0];
        }
        // load conf file?
        log.debug("connecting to " + port);
        MongoClient client = new MongoClient(host, port);
        try {
            log.debug("databases " + client.getDatabaseNames());
            discover(context, details, client);
        } catch (Exception e) {
            log.warn("failed connection to " + port, e);
            continue;
        } finally {
            client.close();
        }
    }
    return details;
}
 
开发者ID:genman,项目名称:rhq-plugins,代码行数:33,代码来源:MongoDBServerDiscovery.java


示例4: init

import com.mongodb.DBAddress; //导入依赖的package包/类
/**
 * Initialize any state for this DB. Called once per DB instance; there is
 * one DB instance per client thread.
 */
public void init() throws DBException {
    // initialize MongoDb driver
    Properties props = getProperties();
    String url = props.getProperty("mongodb.url");
    database = props.getProperty("mongodb.database");
    String writeConcernType = props.getProperty("mongodb.writeConcern");

    if ("none".equals(writeConcernType)) {
        writeConcern = WriteConcern.NONE;
    } else if ("strict".equals(writeConcernType)) {
        writeConcern = WriteConcern.SAFE;
    } else if ("normal".equals(writeConcernType)) {
        writeConcern = WriteConcern.NORMAL;
    }

    try {
        // strip out prefix since Java driver doesn't currently support
        // standard connection format URL yet
        // http://www.mongodb.org/display/DOCS/Connections
        if (url.startsWith("mongodb://")) {
            url = url.substring(10);
        }

        // need to append db to url.
        url += "/"+database;
        System.out.println("new database url = "+url);
        mongo = new Mongo(new DBAddress(url));
        System.out.println("mongo connection created with "+url);
    } catch (Exception e1) {
        System.err.println(
                "Could not initialize MongoDB connection pool for Loader: "
                        + e1.toString());
        e1.printStackTrace();
        return;
    }

}
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:42,代码来源:MongoDbClient.java


示例5: PluginMongoDB

import com.mongodb.DBAddress; //导入依赖的package包/类
public PluginMongoDB(String host) {
    try {
        address = new DBAddress(host, dbName);
    } catch(UnknownHostException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:inz,项目名称:indenica-repository,代码行数:8,代码来源:PluginMongoDB.java


示例6: resetBackdropDataSet

import com.mongodb.DBAddress; //导入依赖的package包/类
private void resetBackdropDataSet() throws UnknownHostException {
    DB db = Mongo.connect(new DBAddress("localhost", 27037, "backdrop"));
    db.getCollection("test_test").remove(new BasicDBObject());
}
 
开发者ID:alphagov,项目名称:pp-db-collector-template,代码行数:5,代码来源:EndToEndTest.java


示例7: connect

import com.mongodb.DBAddress; //导入依赖的package包/类
public void connect() throws UnknownHostException {
	db = Mongo.connect(new DBAddress(host, dbname)); 
	db.authenticate(user, pwd.toCharArray());
}
 
开发者ID:sociam,项目名称:trends-observatory,代码行数:5,代码来源:MongoConnection.java


示例8: init

import com.mongodb.DBAddress; //导入依赖的package包/类
@Override
/**
 * Initialize any state for this DB.
 * Called once per DB instance; there is one DB instance per client thread.
 */
public void init() throws DBException {
    // initialize MongoDb driver
    Properties props = getProperties();
    String url = props.getProperty("mongodb.url", "mongodb://localhost:27017");
    database = props.getProperty("mongodb.database", "ycsb");
    String writeConcernType = props.getProperty("mongodb.writeConcern", "safe").toLowerCase();

    if ("none".equals(writeConcernType)) {
        writeConcern = WriteConcern.NONE;
    } else if ("safe".equals(writeConcernType)) {
        writeConcern = WriteConcern.SAFE;
    } else if ("normal".equals(writeConcernType)) {
        writeConcern = WriteConcern.NORMAL;
    } else if ("fsync_safe".equals(writeConcernType)) {
        writeConcern = WriteConcern.FSYNC_SAFE;
    } else if ("replicas_safe".equals(writeConcernType)) {
        writeConcern = WriteConcern.REPLICAS_SAFE;
    } else {
        System.err.println("ERROR: Invalid writeConcern: '" + writeConcernType + "'. " +
            "Must be [ none | safe | normal | fsync_safe | replicas_safe ]");
        System.exit(1);
    }

    try {
        // strip out prefix since Java driver doesn't currently support
        // standard connection format URL yet
        // http://www.mongodb.org/display/DOCS/Connections
        if (url.startsWith("mongodb://")) {
            url = url.substring(10);
        }

        // need to append db to url.
        url += "/"+database;
        System.out.println("new database url = "+url);
        mongo = new Mongo(new DBAddress(url));
        System.out.println("mongo connection created with "+url);
    } catch (Exception e1) {
        System.err.println(
                "Could not initialize MongoDB connection pool for Loader: "
                        + e1.toString());
        e1.printStackTrace();
        return;
    }

}
 
开发者ID:pbailis,项目名称:bolton-sigmod2013-code,代码行数:51,代码来源:MongoDbClient.java



注:本文中的com.mongodb.DBAddress类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Group类代码示例发布时间:2022-05-23
下一篇:
Java EndpointType类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap