Search in sources :

Example 1 with IndexRepairJob

use of org.janusgraph.graphdb.olap.job.IndexRepairJob in project janusgraph by JanusGraph.

the class MapReduceIndexJobs method hbaseRepair.

public static ScanMetrics hbaseRepair(Properties janusgraphProperties, String indexName, String relationType, Configuration hadoopBaseConf) throws InterruptedException, IOException, ClassNotFoundException {
    IndexRepairJob job = new IndexRepairJob();
    HBaseHadoopScanRunner cr = new HBaseHadoopScanRunner(job);
    ModifiableConfiguration mc = getIndexJobConf(indexName, relationType);
    copyPropertiesToInputAndOutputConf(hadoopBaseConf, janusgraphProperties);
    cr.scanJobConf(mc);
    cr.scanJobConfRoot(GraphDatabaseConfiguration.class.getName() + "#JOB_NS");
    cr.baseHadoopConf(hadoopBaseConf);
    return cr.run();
}
Also used : IndexRepairJob(org.janusgraph.graphdb.olap.job.IndexRepairJob) HBaseHadoopScanRunner(org.janusgraph.hadoop.scan.HBaseHadoopScanRunner) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration)

Example 2 with IndexRepairJob

use of org.janusgraph.graphdb.olap.job.IndexRepairJob in project janusgraph by JanusGraph.

the class HBaseMapReduceIndexJobsUtils method repair.

public static ScanMetrics repair(Properties janusgraphProperties, String indexName, String relationType, Configuration hadoopBaseConf) throws InterruptedException, IOException, ClassNotFoundException {
    IndexRepairJob job = new IndexRepairJob();
    HBaseHadoopScanRunner cr = new HBaseHadoopScanRunner(job);
    return executeScanRunner(janusgraphProperties, indexName, relationType, hadoopBaseConf, cr);
}
Also used : IndexRepairJob(org.janusgraph.graphdb.olap.job.IndexRepairJob) HBaseHadoopScanRunner(org.janusgraph.hadoop.scan.HBaseHadoopScanRunner)

Example 3 with IndexRepairJob

use of org.janusgraph.graphdb.olap.job.IndexRepairJob in project janusgraph by JanusGraph.

the class CqlMapReduceIndexJobsUtils method repair.

public static ScanMetrics repair(Properties janusgraphProperties, String indexName, String relationType, String partitionerName, Configuration hadoopBaseConf) throws InterruptedException, IOException, ClassNotFoundException {
    IndexRepairJob job = new IndexRepairJob();
    CQLHadoopScanRunner cr = new CQLHadoopScanRunner(job);
    return executeScanRunner(janusgraphProperties, indexName, relationType, partitionerName, hadoopBaseConf, cr);
}
Also used : CQLHadoopScanRunner(org.janusgraph.hadoop.scan.CQLHadoopScanRunner) IndexRepairJob(org.janusgraph.graphdb.olap.job.IndexRepairJob)

Example 4 with IndexRepairJob

use of org.janusgraph.graphdb.olap.job.IndexRepairJob in project janusgraph by JanusGraph.

the class MapReduceIndexJobs method cassandraRepair.

public static ScanMetrics cassandraRepair(Properties janusgraphProperties, String indexName, String relationType, String partitionerName, Configuration hadoopBaseConf) throws InterruptedException, IOException, ClassNotFoundException {
    IndexRepairJob job = new IndexRepairJob();
    CassandraHadoopScanRunner cr = new CassandraHadoopScanRunner(job);
    ModifiableConfiguration mc = getIndexJobConf(indexName, relationType);
    copyPropertiesToInputAndOutputConf(hadoopBaseConf, janusgraphProperties);
    cr.partitionerOverride(partitionerName);
    cr.scanJobConf(mc);
    cr.scanJobConfRoot(GraphDatabaseConfiguration.class.getName() + "#JOB_NS");
    cr.baseHadoopConf(hadoopBaseConf);
    return cr.run();
}
Also used : IndexRepairJob(org.janusgraph.graphdb.olap.job.IndexRepairJob) CassandraHadoopScanRunner(org.janusgraph.hadoop.scan.CassandraHadoopScanRunner) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration)

Example 5 with IndexRepairJob

use of org.janusgraph.graphdb.olap.job.IndexRepairJob in project janusgraph by JanusGraph.

the class ManagementSystem method updateIndex.

/* --------------
    Schema Update
     --------------- */
@Override
public IndexJobFuture updateIndex(Index index, SchemaAction updateAction) {
    Preconditions.checkArgument(index != null, "Need to provide an index");
    Preconditions.checkArgument(updateAction != null, "Need to provide update action");
    JanusGraphSchemaVertex schemaVertex = getSchemaVertex(index);
    Set<JanusGraphSchemaVertex> dependentTypes;
    Set<PropertyKeyVertex> keySubset = ImmutableSet.of();
    if (index instanceof RelationTypeIndex) {
        dependentTypes = ImmutableSet.of((JanusGraphSchemaVertex) ((InternalRelationType) schemaVertex).getBaseType());
        if (!updateAction.isApplicableStatus(schemaVertex.getStatus()))
            return null;
    } else if (index instanceof JanusGraphIndex) {
        IndexType indexType = schemaVertex.asIndexType();
        dependentTypes = Sets.newHashSet();
        if (indexType.isCompositeIndex()) {
            if (!updateAction.isApplicableStatus(schemaVertex.getStatus()))
                return null;
            for (PropertyKey key : ((JanusGraphIndex) index).getFieldKeys()) {
                dependentTypes.add((PropertyKeyVertex) key);
            }
        } else {
            keySubset = Sets.newHashSet();
            MixedIndexType mixedIndexType = (MixedIndexType) indexType;
            Set<SchemaStatus> applicableStatus = updateAction.getApplicableStatus();
            for (ParameterIndexField field : mixedIndexType.getFieldKeys()) {
                if (applicableStatus.contains(field.getStatus()))
                    keySubset.add((PropertyKeyVertex) field.getFieldKey());
            }
            if (keySubset.isEmpty())
                return null;
            dependentTypes.addAll(keySubset);
        }
    } else
        throw new UnsupportedOperationException("Updates not supported for index: " + index);
    IndexIdentifier indexId = new IndexIdentifier(index);
    StandardScanner.Builder builder;
    IndexJobFuture future;
    switch(updateAction) {
        case REGISTER_INDEX:
            setStatus(schemaVertex, SchemaStatus.INSTALLED, keySubset);
            updatedTypes.add(schemaVertex);
            updatedTypes.addAll(dependentTypes);
            setUpdateTrigger(new UpdateStatusTrigger(graph, schemaVertex, SchemaStatus.REGISTERED, keySubset));
            future = new EmptyIndexJobFuture();
            break;
        case REINDEX:
            builder = graph.getBackend().buildEdgeScanJob();
            builder.setFinishJob(indexId.getIndexJobFinisher(graph, SchemaAction.ENABLE_INDEX));
            builder.setJobId(indexId);
            builder.setJob(VertexJobConverter.convert(graph, new IndexRepairJob(indexId.indexName, indexId.relationTypeName)));
            try {
                future = builder.execute();
            } catch (BackendException e) {
                throw new JanusGraphException(e);
            }
            break;
        case ENABLE_INDEX:
            setStatus(schemaVertex, SchemaStatus.ENABLED, keySubset);
            updatedTypes.add(schemaVertex);
            if (!keySubset.isEmpty())
                updatedTypes.addAll(dependentTypes);
            future = new EmptyIndexJobFuture();
            break;
        case DISABLE_INDEX:
            setStatus(schemaVertex, SchemaStatus.INSTALLED, keySubset);
            updatedTypes.add(schemaVertex);
            if (!keySubset.isEmpty())
                updatedTypes.addAll(dependentTypes);
            setUpdateTrigger(new UpdateStatusTrigger(graph, schemaVertex, SchemaStatus.DISABLED, keySubset));
            future = new EmptyIndexJobFuture();
            break;
        case REMOVE_INDEX:
            if (index instanceof RelationTypeIndex) {
                builder = graph.getBackend().buildEdgeScanJob();
            } else {
                JanusGraphIndex graphIndex = (JanusGraphIndex) index;
                if (graphIndex.isMixedIndex())
                    throw new UnsupportedOperationException("External mixed indexes must be removed in the indexing system directly.");
                builder = graph.getBackend().buildGraphIndexScanJob();
            }
            builder.setFinishJob(indexId.getIndexJobFinisher());
            builder.setJobId(indexId);
            builder.setJob(new IndexRemoveJob(graph, indexId.indexName, indexId.relationTypeName));
            try {
                future = builder.execute();
            } catch (BackendException e) {
                throw new JanusGraphException(e);
            }
            break;
        default:
            throw new UnsupportedOperationException("Update action not supported: " + updateAction);
    }
    return future;
}
Also used : Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) MixedIndexType(org.janusgraph.graphdb.types.MixedIndexType) JanusGraphException(org.janusgraph.core.JanusGraphException) IndexRepairJob(org.janusgraph.graphdb.olap.job.IndexRepairJob) ParameterIndexField(org.janusgraph.graphdb.types.ParameterIndexField) RelationTypeIndex(org.janusgraph.core.schema.RelationTypeIndex) BackendException(org.janusgraph.diskstorage.BackendException) StandardScanner(org.janusgraph.diskstorage.keycolumnvalue.scan.StandardScanner) JanusGraphSchemaVertex(org.janusgraph.graphdb.types.vertices.JanusGraphSchemaVertex) PropertyKeyVertex(org.janusgraph.graphdb.types.vertices.PropertyKeyVertex) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) IndexType(org.janusgraph.graphdb.types.IndexType) CompositeIndexType(org.janusgraph.graphdb.types.CompositeIndexType) MixedIndexType(org.janusgraph.graphdb.types.MixedIndexType) PropertyKey(org.janusgraph.core.PropertyKey) IndexRemoveJob(org.janusgraph.graphdb.olap.job.IndexRemoveJob)

Aggregations

IndexRepairJob (org.janusgraph.graphdb.olap.job.IndexRepairJob)6 HashSet (java.util.HashSet)2 Set (java.util.Set)2 JanusGraphException (org.janusgraph.core.JanusGraphException)2 PropertyKey (org.janusgraph.core.PropertyKey)2 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)2 RelationTypeIndex (org.janusgraph.core.schema.RelationTypeIndex)2 BackendException (org.janusgraph.diskstorage.BackendException)2 ModifiableConfiguration (org.janusgraph.diskstorage.configuration.ModifiableConfiguration)2 StandardScanner (org.janusgraph.diskstorage.keycolumnvalue.scan.StandardScanner)2 IndexRemoveJob (org.janusgraph.graphdb.olap.job.IndexRemoveJob)2 CompositeIndexType (org.janusgraph.graphdb.types.CompositeIndexType)2 IndexType (org.janusgraph.graphdb.types.IndexType)2 MixedIndexType (org.janusgraph.graphdb.types.MixedIndexType)2 ParameterIndexField (org.janusgraph.graphdb.types.ParameterIndexField)2 JanusGraphSchemaVertex (org.janusgraph.graphdb.types.vertices.JanusGraphSchemaVertex)2 PropertyKeyVertex (org.janusgraph.graphdb.types.vertices.PropertyKeyVertex)2 HBaseHadoopScanRunner (org.janusgraph.hadoop.scan.HBaseHadoopScanRunner)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 EmptyScanJobFuture (org.janusgraph.diskstorage.keycolumnvalue.scan.EmptyScanJobFuture)1