当前位置: 首页>>代码示例>>Java>>正文


Java DBCollection.getIndexInfo方法代码示例

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


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

示例1: MongoExecutingJobQueue

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public MongoExecutingJobQueue(Config config) {
    super(config);
    // table name (Collection name) for single table
    setTableName(JobQueueUtils.EXECUTING_JOB_QUEUE);

    // create table
    DBCollection dbCollection = template.getCollection();
    List<DBObject> indexInfo = dbCollection.getIndexInfo();
    // create index if not exist
    if (CollectionUtils.sizeOf(indexInfo) <= 1) {
        template.ensureIndex("idx_jobId", "jobId", true, true);
        template.ensureIndex("idx_taskId_taskTrackerNodeGroup", "taskId, taskTrackerNodeGroup", true, true);
        template.ensureIndex("idx_taskTrackerIdentity", "taskTrackerIdentity");
        template.ensureIndex("idx_gmtCreated", "gmtCreated");
    }
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:17,代码来源:MongoExecutingJobQueue.java

示例2: createQueue

import com.mongodb.DBCollection; //导入方法依赖的package包/类
@Override
public boolean createQueue(String taskTrackerNodeGroup) {
    String tableName = JobQueueUtils.getExecutableQueueName(taskTrackerNodeGroup);
    DBCollection dbCollection = template.getCollection(tableName);
    List<DBObject> indexInfo = dbCollection.getIndexInfo();
    // create index if not exist
    if (CollectionUtils.sizeOf(indexInfo) <= 1) {
        template.ensureIndex(tableName, "idx_jobId", "jobId", true, true);
        template.ensureIndex(tableName, "idx_taskId_taskTrackerNodeGroup", "taskId, taskTrackerNodeGroup", true, true);
        template.ensureIndex(tableName, "idx_taskTrackerIdentity", "taskTrackerIdentity");
        template.ensureIndex(tableName, "idx_triggerTime_priority_gmtCreated", "triggerTime,priority,gmtCreated");
        template.ensureIndex(tableName, "idx_isRunning", "isRunning");
        LOGGER.info("create queue " + tableName);
    }
    EXIST_TABLE.add(tableName);
    return true;
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:18,代码来源:MongoExecutableJobQueue.java

示例3: test1

import com.mongodb.DBCollection; //导入方法依赖的package包/类
@Test
public void test1() {
    IndexDefinition iDef = IndexDefinitionFactory.getDefinition("idField(id) string, fundField(fund) string, sideField(side) string");
    iDef.setIndexName("FOO");
    List<IndexDefinition> indexDefinitions = new ArrayList<IndexDefinition>();
    indexDefinitions.add(iDef);

    store.createIndexHandler(new IndexProducer(indexDefinitions));

    DBCollection collection = MongoDBFactory.getDB("Test").getCollection("strumpet_index_index");
    List<DBObject> indexes = collection.getIndexInfo();

    // we should have the number of indexes in the definition
    // (plus 2 that are always created: _id and key)
    // only test for indexes created by createRelatedTableStore() ...
    // assertEquals(5, indexes.size());

    ArrayList<String> index_names = new ArrayList<>(indexes.size());
    for (DBObject i: indexes) {
        index_names.add((String) i.get("name"));
    }

    //name should be one provided
    assertTrue(index_names.contains("FOO"));

    collection.drop();
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:28,代码来源:MongoIndexDefinitionTest.java

示例4: test2

import com.mongodb.DBCollection; //导入方法依赖的package包/类
@Test
public void test2() {
    IndexDefinition iDef1 = IndexDefinitionFactory.getDefinition("id1Field(id1) string");
    IndexDefinition iDef2 = IndexDefinitionFactory.getDefinition("fooField(foo) string, barField(bar) string");

    List<IndexDefinition> indexDefinitions = new ArrayList<IndexDefinition>();
    indexDefinitions.add(iDef1);
    indexDefinitions.add(iDef2);

    store.createIndexHandler(new IndexProducer(indexDefinitions));

    DBCollection collection = MongoDBFactory.getDB("Test").getCollection("strumpet_index_index");
    List<DBObject> indexes = collection.getIndexInfo();

    // we should have the number of indexes in the definition
    // (plus 2 that are always created: _id and key)
    // only test for indexes created by createRelatedTableStore() ...
    // assertEquals(5, indexes.size());

    ArrayList<String> index_names = new ArrayList<>(indexes.size());

    for (DBObject i: indexes) {
        index_names.add((String) i.get("name"));
    }

    assertTrue(index_names.contains("id1Field_idx"));
    assertTrue(index_names.contains("fooFieldbarField_idx"));

    collection.drop();
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:31,代码来源:MongoIndexDefinitionTest.java

示例5: MongoJobLogger

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public MongoJobLogger(Config config) {
    super(config);
    setTableName("lts_job_log_po");

    // create table
    DBCollection dbCollection = template.getCollection();
    List<DBObject> indexInfo = dbCollection.getIndexInfo();
    // create index if not exist
    if (CollectionUtils.sizeOf(indexInfo) <= 1) {
        template.ensureIndex("idx_logTime", "logTime");
        template.ensureIndex("idx_taskId_taskTrackerNodeGroup", "taskId,taskTrackerNodeGroup");
    }
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:14,代码来源:MongoJobLogger.java

示例6: MongoNodeGroupStore

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public MongoNodeGroupStore(Config config) {
    super(config);
    setTableName(JobQueueUtils.NODE_GROUP_STORE);

    // create table
    DBCollection dbCollection = template.getCollection();
    List<DBObject> indexInfo = dbCollection.getIndexInfo();
    // create index if not exist
    if (CollectionUtils.sizeOf(indexInfo) <= 1) {
        template.ensureIndex("idx_nodeType_name", "nodeType,name", true, true);
    }
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:13,代码来源:MongoNodeGroupStore.java

示例7: createQueue

import com.mongodb.DBCollection; //导入方法依赖的package包/类
@Override
public boolean createQueue(String jobClientNodeGroup) {
    String tableName = JobQueueUtils.getFeedbackQueueName(jobClientNodeGroup);
    DBCollection dbCollection = template.getCollection(tableName);
    List<DBObject> indexInfo = dbCollection.getIndexInfo();
    // create index if not exist
    if (CollectionUtils.sizeOf(indexInfo) <= 1) {
        template.ensureIndex(tableName, "idx_gmtCreated", "gmtCreated");
        LOGGER.info("create queue " + tableName);
    }
    return true;
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:13,代码来源:MongoJobFeedbackQueue.java

示例8: MongoCronJobQueue

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public MongoCronJobQueue(Config config) {
    super(config);
    // table name (Collection name) for single table
    setTableName(JobQueueUtils.CRON_JOB_QUEUE);

    // create table
    DBCollection dbCollection = template.getCollection();
    List<DBObject> indexInfo = dbCollection.getIndexInfo();
    // create index if not exist
    if (CollectionUtils.sizeOf(indexInfo) <= 1) {
        template.ensureIndex("idx_jobId", "jobId", true, true);
        template.ensureIndex("idx_taskId_taskTrackerNodeGroup", "taskId, taskTrackerNodeGroup", true, true);
    }
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:15,代码来源:MongoCronJobQueue.java

示例9: MongoSuspendJobQueue

import com.mongodb.DBCollection; //导入方法依赖的package包/类
public MongoSuspendJobQueue(Config config) {
    super(config);
    // table name (Collection name) for single table
    setTableName(JobQueueUtils.SUSPEND_JOB_QUEUE);

    // create table
    DBCollection dbCollection = template.getCollection();
    List<DBObject> indexInfo = dbCollection.getIndexInfo();
    // create index if not exist
    if (CollectionUtils.sizeOf(indexInfo) <= 1) {
        template.ensureIndex("idx_jobId", "jobId", true, true);
        template.ensureIndex("idx_taskId_taskTrackerNodeGroup", "taskId, taskTrackerNodeGroup", true, true);
    }
}
 
开发者ID:WenZuHuai,项目名称:light-task-scheduler,代码行数:15,代码来源:MongoSuspendJobQueue.java


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