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


Java TitanManagement.getGraphIndex方法代码示例

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


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

示例1: testRemoveGraphIndex

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
@Test
public void testRemoveGraphIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Disable the "name" composite index
    TitanManagement m = graph.openManagement();
    TitanGraphIndex nameIndex = m.getGraphIndex("name");
    m.updateIndex(nameIndex, SchemaAction.DISABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to DISABLED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "name")
            .status(SchemaStatus.DISABLED).call().getSucceeded());

    // Remove index
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    TitanGraphIndex index = m.getGraphIndex("name");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REMOVE_INDEX).get();

    assertEquals(12, metrics.getCustom(IndexRemoveJob.DELETED_RECORDS_COUNT));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:28,代码来源:AbstractIndexManagementIT.java

示例2: waitForCompletion

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
private static void waitForCompletion(TitanManagement mgmt, VertexCompositeIndex compositeIndex) {
  String name = compositeIndex.name;
  TitanGraphIndex graphIndex = mgmt.getGraphIndex(name);
  PropertyKey propertyKey = graphIndex.getFieldKeys()[0];
  // For composite indexes, the propertyKey is ignored and the status of the index as a whole is returned
  if (!SchemaStatus.ENABLED.equals(graphIndex.getIndexStatus(propertyKey))) {
    try {
      GraphIndexStatusReport report = ManagementSystem.awaitGraphIndexStatus(titanGraph, name).call();
      LOG.info("report={}", report);
    } catch (InterruptedException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
  }
}
 
开发者ID:HuygensING,项目名称:antioch,代码行数:16,代码来源:TitanService.java

示例3: testRepairGraphIndex

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
@Test
public void testRepairGraphIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

    // Load the "Graph of the Gods" sample data (WITHOUT mixed index coverage)
    GraphOfTheGodsFactory.loadWithoutMixedIndex(graph, true);

    // Create and enable a graph index on age
    TitanManagement m = graph.openManagement();
    PropertyKey age = m.getPropertyKey("age");
    m.buildIndex("verticesByAge", Vertex.class).addKey(age).buildCompositeIndex();
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to REGISTERED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "verticesByAge")
            .status(SchemaStatus.REGISTERED).call().getSucceeded());

    m = graph.openManagement();
    TitanGraphIndex index = m.getGraphIndex("verticesByAge");
    m.updateIndex(index, SchemaAction.ENABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to ENABLED
    assertTrue(ManagementSystem.awaitGraphIndexStatus(graph, "verticesByAge")
            .status(SchemaStatus.ENABLED).call().getSucceeded());

    // Run a query that hits the index but erroneously returns nothing because we haven't repaired yet
    assertFalse(graph.query().has("age", 10000).vertices().iterator().hasNext());

    // Repair
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    index = m.getGraphIndex("verticesByAge");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get();
    assertEquals(6, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));

    // Test the index
    Iterable<TitanVertex> hits = graph.query().has("age", 4500).vertices();
    assertNotNull(hits);
    assertEquals(1, Iterables.size(hits));
    TitanVertex v = Iterables.getOnlyElement(hits);
    assertNotNull(v);

    assertEquals("neptune", v.value("name"));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:49,代码来源:AbstractIndexManagementIT.java

示例4: call

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
@Override
public GraphIndexStatusReport call() throws InterruptedException {
    Preconditions.checkNotNull(g, "Graph instance must not be null");
    Preconditions.checkNotNull(graphIndexName, "Index name must not be null");
    Preconditions.checkNotNull(status, "Target status must not be null");

    Map<String, SchemaStatus> notConverged = new HashMap<>();
    Map<String, SchemaStatus> converged = new HashMap<>();
    TitanGraphIndex idx;

    Timer t = new Timer(TimestampProviders.MILLI).start();
    boolean timedOut;
    while (true) {
        TitanManagement mgmt = null;
        try {
            mgmt = g.openManagement();
            idx = mgmt.getGraphIndex(graphIndexName);
            for (PropertyKey pk : idx.getFieldKeys()) {
                SchemaStatus s = idx.getIndexStatus(pk);
                LOGGER.debug("Key {} has status {}", pk, s);
                if (!status.equals(s))
                    notConverged.put(pk.toString(), s);
                else
                    converged.put(pk.toString(), s);
            }
        } finally {
            if (null != mgmt)
                mgmt.rollback(); // Let an exception here propagate up the stack
        }

        String waitingOn = Joiner.on(",").withKeyValueSeparator("=").join(notConverged);
        if (!notConverged.isEmpty()) {
            LOGGER.info("Some key(s) on index {} do not currently have status {}: {}", graphIndexName, status, waitingOn);
        } else {
            LOGGER.info("All {} key(s) on index {} have status {}", converged.size(), graphIndexName, status);
            return new GraphIndexStatusReport(true, graphIndexName, status, notConverged, converged, t.elapsed());
        }

        timedOut = null != timeout && 0 < t.elapsed().compareTo(timeout);

        if (timedOut) {
            LOGGER.info("Timed out ({}) while waiting for index {} to converge on status {}",
                    timeout, graphIndexName, status);
            return new GraphIndexStatusReport(false, graphIndexName, status, notConverged, converged, t.elapsed());
        }
        notConverged.clear();
        converged.clear();

        Thread.sleep(poll.toMillis());
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:52,代码来源:GraphIndexStatusWatcher.java

示例5: awaitGraphIndexStatus

import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
/**
 * Do not use this method.  This may be removed or refactored in future Titan versions.
 *
 * Final API pending resolution of https://github.com/thinkaurelius/titan/issues/709.
 *
 */
public static boolean awaitGraphIndexStatus(TitanGraph g, String indexName, SchemaStatus status, long timeout, TimeUnit timeoutUnit) {
    Preconditions.checkNotNull(g);
    Preconditions.checkNotNull(indexName);
    Preconditions.checkNotNull(status);
    Preconditions.checkArgument(0L <= timeout);
    Preconditions.checkNotNull(timeoutUnit);

    Map<PropertyKey, SchemaStatus> notConverged = new HashMap<PropertyKey, SchemaStatus>();
    Map<PropertyKey, SchemaStatus> converged = new HashMap<PropertyKey, SchemaStatus>();
    TitanGraphIndex idx;

    Timer t = new Timer(Timestamps.MILLI).start();
    boolean timedOut;
    while (true) {
        TitanManagement mgmt = g.getManagementSystem();
        idx  = mgmt.getGraphIndex(indexName);
        for (PropertyKey pk : idx.getFieldKeys()) {
            SchemaStatus s = idx.getIndexStatus(pk);
            LOGGER.debug("Key {} has status {}", pk, s);
            if (!status.equals(s))
                notConverged.put(pk, s);
            else
                converged.put(pk, s);
        }
        /* Rollback must follow the Joiner...(notConverged).  The Joiner calls toString on
         * PropertyKeys, and the current implementation calls the getName method on the key,
         * and this expects the attached transaction to be open and usable to read the name.
         * Rolling back or committing the managementsystem before calling getName results
         * in an IllegalStateException in the guts of Joiner calling toString on a key.
         */
        String waitingOn = Joiner.on(",").withKeyValueSeparator("=").join(notConverged);
        mgmt.rollback();
        if (!notConverged.isEmpty()) {
            LOGGER.info("Some key(s) on index {} do not currently have status {}: ", indexName, status, waitingOn);
        } else {
            LOGGER.info("All {} key(s) on index {} have status {}", converged.size(), indexName, status);
            return true;
        }
        timedOut = timeout <= t.elapsed().getLength(timeoutUnit);
        if (timedOut) {
            LOGGER.info("Timed out ({} {}) while waiting for index {} to converge on status {}",
                    timeout, timeoutUnit, indexName, status);
            return false;
        }
        notConverged.clear();
        converged.clear();
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:55,代码来源:ManagementSystem.java


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