use of com.thinkaurelius.titan.core.schema.SchemaStatus in project titan by thinkaurelius.
the class IndexRemoveJob method validateIndexStatus.
@Override
protected void validateIndexStatus() {
if (index instanceof RelationTypeIndex) {
//Nothing specific to be done
} else if (index instanceof TitanGraphIndex) {
TitanGraphIndex gindex = (TitanGraphIndex) index;
if (gindex.isMixedIndex())
throw new UnsupportedOperationException("Cannot remove mixed indexes through Titan. This can " + "only be accomplished in the indexing system directly.");
CompositeIndexType indexType = (CompositeIndexType) mgmt.getSchemaVertex(index).asIndexType();
graphIndexId = indexType.getID();
} else
throw new UnsupportedOperationException("Unsupported index found: " + index);
//Must be a relation type index or a composite graph index
TitanSchemaVertex schemaVertex = mgmt.getSchemaVertex(index);
SchemaStatus actualStatus = schemaVertex.getStatus();
Preconditions.checkArgument(actualStatus == SchemaStatus.DISABLED, "The index [%s] must be disabled before it can be removed", indexName);
}
use of com.thinkaurelius.titan.core.schema.SchemaStatus in project titan by thinkaurelius.
the class GraphIndexStatusWatcher method call.
@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)
// Let an exception here propagate up the stack
mgmt.rollback();
}
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());
}
}
use of com.thinkaurelius.titan.core.schema.SchemaStatus in project titan by thinkaurelius.
the class RelationIndexStatusWatcher method call.
/**
* Poll a relation index until it has a certain {@link SchemaStatus},
* or until a configurable timeout is exceeded.
*
* @return a report with information about schema state, execution duration, and the index
*/
@Override
public RelationIndexStatusReport call() throws InterruptedException {
Preconditions.checkNotNull(g, "Graph instance must not be null");
Preconditions.checkNotNull(relationIndexName, "Index name must not be null");
Preconditions.checkNotNull(status, "Target status must not be null");
RelationTypeIndex idx;
Timer t = new Timer(TimestampProviders.MILLI).start();
boolean timedOut;
while (true) {
SchemaStatus actualStatus = null;
TitanManagement mgmt = null;
try {
mgmt = g.openManagement();
idx = mgmt.getRelationIndex(mgmt.getRelationType(relationTypeName), relationIndexName);
actualStatus = idx.getIndexStatus();
LOGGER.info("Index {} (relation type {}) has status {}", relationIndexName, relationTypeName, actualStatus);
if (status.equals(actualStatus)) {
return new RelationIndexStatusReport(true, relationIndexName, relationTypeName, actualStatus, status, t.elapsed());
}
} finally {
if (null != mgmt)
// Let an exception here propagate up the stack
mgmt.rollback();
}
timedOut = null != timeout && 0 < t.elapsed().compareTo(timeout);
if (timedOut) {
LOGGER.info("Timed out ({}) while waiting for index {} (relation type {}) to reach status {}", timeout, relationIndexName, relationTypeName, status);
return new RelationIndexStatusReport(false, relationIndexName, relationTypeName, actualStatus, status, t.elapsed());
}
Thread.sleep(poll.toMillis());
}
}
use of com.thinkaurelius.titan.core.schema.SchemaStatus in project titan by thinkaurelius.
the class ParameterIndexField method getStatus.
public SchemaStatus getStatus() {
SchemaStatus status = ParameterType.STATUS.findParameter(parameters, null);
Preconditions.checkState(status != null, "Field [%s] did not have a status", this);
return status;
}
Aggregations