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


Java ManagementSystem类代码示例

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


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

示例1: createUniqueCompositeIndex

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
public static void createUniqueCompositeIndex(final Graph newGraph, final String indexName,
        final String[] propertyKeyNames, final Class<?> propertyKeyType) throws InterruptedException {

    Assert.notEmpty(propertyKeyNames);
    newGraph.tx().rollback(); // Never create new indexes while a transaction is active
    TitanManagement mgmt = ((TitanGraph) newGraph).openManagement();
    IndexBuilder indexBuilder = mgmt.buildIndex(indexName, Vertex.class);
    if (!mgmt.containsGraphIndex(indexName)) {
        for (String propertyKeyName : propertyKeyNames) {
            PropertyKey indexPropertyKey = getOrCreatePropertyKey(propertyKeyName, propertyKeyType, mgmt);
            indexBuilder.addKey(indexPropertyKey);
        }
        indexBuilder.unique().buildCompositeIndex();
    }
    mgmt.commit();
    // Wait for the index to become available
    ManagementSystem.awaitGraphIndexStatus((TitanGraph) newGraph, indexName).status(SchemaStatus.ENABLED).call();
}
 
开发者ID:eclipse,项目名称:keti,代码行数:19,代码来源:GraphConfig.java

示例2: setup

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
@Override
public void setup(
        final Mapper<NullWritable, FaunusVertex, NullWritable, NullWritable>.Context context) throws IOException {
    Configuration hadoopConf = DEFAULT_COMPAT.getContextConfiguration(context);
    ModifiableHadoopConfiguration faunusConf = ModifiableHadoopConfiguration.of(hadoopConf);
    BasicConfiguration titanConf = faunusConf.getOutputConf();
    indexName = faunusConf.get(TitanHadoopConfiguration.INDEX_NAME);
    indexType = faunusConf.get(TitanHadoopConfiguration.INDEX_TYPE);

    try {
        Preconditions.checkNotNull(indexName, "Need to provide at least an index name for re-index job");
        log.info("Read index information: name={} type={}", indexName, indexType);
        graph = (StandardTitanGraph)TitanFactory.open(titanConf);
        SchemaContainer schema = new SchemaContainer(graph);
        FaunusSchemaManager typeManager = FaunusSchemaManager.getTypeManager(titanConf);
        typeManager.setSchemaProvider(schema);
        log.info("Opened graph {}", graph);
        mgmt = (ManagementSystem) graph.getManagementSystem();
        validateIndexStatus();
    } catch (final Exception e) {
        if (null != mgmt && mgmt.isOpen())
            mgmt.rollback();
        DEFAULT_COMPAT.incrementContextCounter(context, Counters.FAILED_TRANSACTIONS, 1L);
        throw new IOException(e.getMessage(), e);
    }
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:27,代码来源:TitanIndexRepairMapper.java

示例3: createIndex

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
public static void createIndex(final Graph newGraph, final String indexName, final String indexKey)
        throws InterruptedException {
    newGraph.tx().rollback(); // Never create new indexes while a transaction is active
    TitanManagement mgmt = ((TitanGraph) newGraph).openManagement();
    if (!mgmt.containsGraphIndex(indexName)) {
        PropertyKey indexPropertyKey = mgmt.makePropertyKey(indexKey).dataType(String.class).make();
        mgmt.buildIndex(indexName, Vertex.class).addKey(indexPropertyKey).buildCompositeIndex();
    }
    mgmt.commit();
    // Wait for the index to become available
    ManagementSystem.awaitGraphIndexStatus((TitanGraph) newGraph, indexName).status(SchemaStatus.ENABLED).call();
}
 
开发者ID:eclipse,项目名称:keti,代码行数:13,代码来源:GraphConfig.java

示例4: createUniqueIndexForLabel

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
public static void createUniqueIndexForLabel(final Graph newGraph, final String indexName, final String indexKey,
        final String label) throws InterruptedException {
    newGraph.tx().rollback(); // Never create new indexes while a transaction is active
    TitanManagement mgmt = ((TitanGraph) newGraph).openManagement();
    if (!mgmt.containsGraphIndex(indexName)) {
        PropertyKey indexPropertyKey = mgmt.makePropertyKey(indexKey).dataType(Integer.class).make();
        VertexLabel versionLabel = mgmt.makeVertexLabel(label).make();
        // Create a unique composite index for the property key that indexes only vertices with a given label
        mgmt.buildIndex(indexName, Vertex.class).addKey(indexPropertyKey).indexOnly(versionLabel).unique()
                .buildCompositeIndex();
    }
    mgmt.commit();
    // Wait for the index to become available
    ManagementSystem.awaitGraphIndexStatus((TitanGraph) newGraph, indexName).status(SchemaStatus.ENABLED).call();
}
 
开发者ID:eclipse,项目名称:keti,代码行数:16,代码来源:GraphConfig.java

示例5: createEdgeIndex

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
public static void createEdgeIndex(final Graph newGraph, final String indexName, final String label,
        final String indexKey) throws InterruptedException {
    newGraph.tx().rollback(); // Never create new indexes while a transaction is active
    TitanManagement mgmt = ((TitanGraph) newGraph).openManagement();
    EdgeLabel edgeLabel = mgmt.getOrCreateEdgeLabel(label);
    if (!mgmt.containsRelationIndex(edgeLabel, indexName)) {
        PropertyKey indexPropertyKey = getOrCreatePropertyKey(indexKey, String.class, mgmt);
        mgmt.buildEdgeIndex(edgeLabel, indexName, Direction.OUT, indexPropertyKey);
    }
    mgmt.commit();
    // Wait for the index to become available
    ManagementSystem.awaitRelationIndexStatus((TitanGraph) newGraph, indexName, label).status(SchemaStatus.ENABLED)
            .call();
}
 
开发者ID:eclipse,项目名称:keti,代码行数:15,代码来源:GraphConfig.java

示例6: testRemoveGraphIndex

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的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

示例7: testRemoveRelationIndex

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
@Test
public void testRemoveRelationIndex() throws InterruptedException, BackendException, ExecutionException {
    tx.commit();
    mgmt.commit();

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

    // Disable the "battlesByTime" index
    TitanManagement m = graph.openManagement();
    RelationType battled = m.getRelationType("battled");
    RelationTypeIndex battlesByTime = m.getRelationIndex(battled, "battlesByTime");
    m.updateIndex(battlesByTime, SchemaAction.DISABLE_INDEX);
    m.commit();
    graph.tx().commit();

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

    // Remove index
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    battled = m.getRelationType("battled");
    battlesByTime = m.getRelationIndex(battled, "battlesByTime");
    ScanMetrics metrics = mri.updateIndex(battlesByTime, SchemaAction.REMOVE_INDEX).get();

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

示例8: testRepairRelationIndex

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
@Test
public void testRepairRelationIndex() 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 relation index on lives edges by reason
    TitanManagement m = graph.openManagement();
    PropertyKey reason = m.getPropertyKey("reason");
    EdgeLabel lives = m.getEdgeLabel("lives");
    m.buildEdgeIndex(lives, "livesByReason", Direction.BOTH, Order.decr, reason);
    m.commit();
    graph.tx().commit();

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

    m = graph.openManagement();
    RelationTypeIndex index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason");
    m.updateIndex(index, SchemaAction.ENABLE_INDEX);
    m.commit();
    graph.tx().commit();

    // Block until the SchemaStatus transitions to ENABLED
    assertTrue(ManagementSystem.awaitRelationIndexStatus(graph, "livesByReason", "lives")
            .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("reason", "no fear of death").edges().iterator().hasNext());

    // Repair
    MapReduceIndexManagement mri = new MapReduceIndexManagement(graph);
    m = graph.openManagement();
    index = m.getRelationIndex(m.getRelationType("lives"), "livesByReason");
    ScanMetrics metrics = mri.updateIndex(index, SchemaAction.REINDEX).get();
    assertEquals(8, metrics.getCustom(IndexRepairJob.ADDED_RECORDS_COUNT));
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:41,代码来源:AbstractIndexManagementIT.java

示例9: workerIterationStart

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
public void workerIterationStart(TitanGraph graph, Configuration config, ScanMetrics metrics) {
    this.graph = (StandardTitanGraph)graph;
    Preconditions.checkArgument(config.has(GraphDatabaseConfiguration.JOB_START_TIME),"Invalid configuration for this job. Start time is required.");
    this.jobStartTime = Instant.ofEpochMilli(config.get(GraphDatabaseConfiguration.JOB_START_TIME));
    if (indexName == null) {
        Preconditions.checkArgument(config.has(INDEX_NAME), "Need to configure the name of the index to be repaired");
        indexName = config.get(INDEX_NAME);
        indexRelationTypeName = config.get(INDEX_RELATION_TYPE);
        log.info("Read index information: name={} type={}", indexName, indexRelationTypeName);
    }

    try {
        this.mgmt = (ManagementSystem)graph.openManagement();

        if (isGlobalGraphIndex()) {
            index = mgmt.getGraphIndex(indexName);
        } else {
            indexRelationType = mgmt.getRelationType(indexRelationTypeName);
            Preconditions.checkArgument(indexRelationType!=null,"Could not find relation type: %s", indexRelationTypeName);
            index = mgmt.getRelationIndex(indexRelationType,indexName);
        }
        Preconditions.checkArgument(index!=null,"Could not find index: %s [%s]",indexName,indexRelationTypeName);
        log.info("Found index {}", indexName);
        validateIndexStatus();

        StandardTransactionBuilder txb = this.graph.buildTransaction();
        txb.commitTime(jobStartTime);
        writeTx = (StandardTitanTx)txb.start();
    } catch (final Exception e) {
        if (null != mgmt && mgmt.isOpen())
            mgmt.rollback();
        if (writeTx!=null && writeTx.isOpen())
            writeTx.rollback();
        metrics.incrementCustom(FAILED_TX);
        throw new TitanException(e.getMessage(), e);
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:38,代码来源:IndexUpdateJob.java

示例10: waitForCompletion

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的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

示例11: main

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
public static void main(String[] args) throws Exception {

		Configuration conf = new PropertiesConfiguration( getRelativeResourcePath( "titan-cassandra-es.properties" ) );
		// start elastic search on startup
		Node node = new NodeBuilder().node();
		
		TitanGraph graph = TitanFactory.open(conf);
		/* Comment if you do not want to reload the graph every time */
		graph.close();
		TitanCleanup.clear(graph);
		graph = TitanFactory.open(conf);
		GraphOfTheGodsFactory.load(graph);
		/* graph loaded  */
		
		// create own indexes
		TitanManagement mgmt = graph.openManagement();
		PropertyKey name = mgmt.getPropertyKey("name");
		PropertyKey age = mgmt.getPropertyKey("age");
		mgmt.buildIndex( "byNameComposite", Vertex.class ).addKey(name).buildCompositeIndex();
		// index consisting of multiple properties
		mgmt.buildIndex( "byNameAndAgeComposite", Vertex.class ).addKey(name).addKey(age).buildCompositeIndex();
		mgmt.commit();
		
		// wait for the index to become available
		ManagementSystem.awaitGraphIndexStatus(graph, "byNameComposite").call();
		ManagementSystem.awaitGraphIndexStatus(graph, "byNameAndAgeComposite").call();
		
		// create new vertex
		Vertex me = graph.addVertex("theOneAndOnly");
		me.property( "name", "me" );
		me.property( "age", 1 );
		graph.tx().commit();
		System.out.println("Created the one and only!");
		
		// re index the existing data (not required, just for demo purposes)
		mgmt = graph.openManagement();
		mgmt.updateIndex( mgmt.getGraphIndex("byNameComposite"), SchemaAction.REINDEX ).get();
		mgmt.updateIndex( mgmt.getGraphIndex("byNameAndAgeComposite"), SchemaAction.REINDEX ).get();
		mgmt.commit();
		
		GraphTraversalSource g = graph.traversal();
		GremlinPipeline<GraphTraversal<?, ?>, ?> pipe = new GremlinPipeline();
		
		// read our new vertex
		pipe.start( g.V().has( "name", "me" ) );	
		Vertex v = (Vertex)pipe.next();
		System.out.println();
		System.out.println( "Label: " + v.label() );
		System.out.println( "Name: " + v.property("name").value() );
		System.out.println( "Age: " + v.property("age").value() );
		System.out.println();
		
		// read different vertex
		pipe.start( g.V().has( "name", "hercules" ) );	
		Vertex herclues = (Vertex)pipe.next();
		System.out.println( "Label: " + herclues.label() );
		System.out.println( "Name: " + herclues.property("name").value() );
		System.out.println( "Age: " + herclues.property("age").value() );
		
		// print some edges
		Iterator<Edge> it = herclues.edges( Direction.OUT );
		while( it.hasNext() ) {
			Edge e = it.next();
			System.out.println( "Out: " + e.label()  + " --> " + e.inVertex().property("name").value() );
		}
		System.out.println();
		
		// close graph
		graph.close();
		// close elastic search on shutdown
		node.close();
		
		System.exit(0);
	}
 
开发者ID:maltesander,项目名称:titan-cassandra-elasticsearch-index,代码行数:75,代码来源:TitanStart.java

示例12: testRepairGraphIndex

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的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

示例13: openManagement

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
@Override
public TitanManagement openManagement() {
    return new ManagementSystem(this,backend.getGlobalSystemConfig(),backend.getSystemMgmtLog(), mgmtLogger, schemaCache);
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:5,代码来源:StandardTitanGraph.java

示例14: getMixedIndex

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
private static final MixedIndexType getMixedIndex(String indexName, StandardTitanTx transaction) {
    IndexType index = ManagementSystem.getGraphIndexDirect(indexName, transaction);
    Preconditions.checkArgument(index!=null,"Index with name [%s] is unknown or not configured properly",indexName);
    Preconditions.checkArgument(index.isMixedIndex());
    return (MixedIndexType)index;
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:7,代码来源:IndexSerializer.java

示例15: getManagementSystem

import com.thinkaurelius.titan.graphdb.database.management.ManagementSystem; //导入依赖的package包/类
@Override
public TitanManagement getManagementSystem() {
    return new ManagementSystem(this,backend.getGlobalSystemConfig(),backend.getSystemMgmtLog(), mgmtLogger, schemaCache);
}
 
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:5,代码来源:StandardTitanGraph.java


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