本文整理汇总了Java中com.thinkaurelius.titan.core.schema.TitanManagement.rollback方法的典型用法代码示例。如果您正苦于以下问题:Java TitanManagement.rollback方法的具体用法?Java TitanManagement.rollback怎么用?Java TitanManagement.rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.thinkaurelius.titan.core.schema.TitanManagement
的用法示例。
在下文中一共展示了TitanManagement.rollback方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SchemaContainer
import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
public SchemaContainer(TitanGraph graph) {
vertexLabels = Maps.newHashMap();
relationTypes = Maps.newHashMap();
TitanManagement mgmt = graph.openManagement();
try {
for (VertexLabel vl : mgmt.getVertexLabels()) {
VertexLabelDefinition vld = new VertexLabelDefinition(vl);
vertexLabels.put(vld.getName(),vld);
}
for (EdgeLabel el : mgmt.getRelationTypes(EdgeLabel.class)) {
EdgeLabelDefinition eld = new EdgeLabelDefinition(el);
relationTypes.put(eld.getName(),eld);
}
for (PropertyKey pk : mgmt.getRelationTypes(PropertyKey.class)) {
PropertyKeyDefinition pkd = new PropertyKeyDefinition(pk);
relationTypes.put(pkd.getName(), pkd);
}
} finally {
mgmt.rollback();
}
}
示例2: Titan1Graph
import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
public Titan1Graph() {
//determine multi-properties once at startup
TitanManagement mgmt = null;
try {
mgmt = Titan1GraphDatabase.getGraphInstance().openManagement();
Iterable<PropertyKey> keys = mgmt.getRelationTypes(PropertyKey.class);
multiProperties = new HashSet<>();
for (PropertyKey key : keys) {
if (key.cardinality() != Cardinality.SINGLE) {
multiProperties.add(key.name());
}
}
} finally {
if (mgmt != null) {
mgmt.rollback();
}
}
}
示例3: Titan0Graph
import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
public Titan0Graph() {
//determine multi-properties once at startup
TitanManagement mgmt = null;
try {
mgmt = Titan0GraphDatabase.getGraphInstance().getManagementSystem();
Iterable<PropertyKey> keys = mgmt.getRelationTypes(PropertyKey.class);
multiProperties = Collections.synchronizedSet(new HashSet<String>());
for(PropertyKey key : keys) {
if (key.getCardinality() != Cardinality.SINGLE) {
multiProperties.add(key.getName());
}
}
} finally {
if (mgmt != null) {
mgmt.rollback();
}
}
}
示例4: SchemaContainer
import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
public SchemaContainer(TitanGraph graph) {
vertexLabels = Maps.newHashMap();
relationTypes = Maps.newHashMap();
TitanManagement mgmt = graph.getManagementSystem();
try {
for (VertexLabel vl : mgmt.getVertexLabels()) {
VertexLabelDefinition vld = new VertexLabelDefinition(vl);
vertexLabels.put(vld.getName(),vld);
}
for (EdgeLabel el : mgmt.getRelationTypes(EdgeLabel.class)) {
EdgeLabelDefinition eld = new EdgeLabelDefinition(el);
relationTypes.put(eld.getName(),eld);
}
for (PropertyKey pk : mgmt.getRelationTypes(PropertyKey.class)) {
PropertyKeyDefinition pkd = new PropertyKeyDefinition(pk);
relationTypes.put(pkd.getName(), pkd);
}
} finally {
mgmt.rollback();
}
}
示例5: call
import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
/**
* 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)
mgmt.rollback(); // Let an exception here propagate up the stack
}
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());
}
}
示例6: setAndCheckGraphOption
import com.thinkaurelius.titan.core.schema.TitanManagement; //导入方法依赖的package包/类
private <T> void setAndCheckGraphOption(ConfigOption<T> opt, ConfigOption.Type requiredType, T firstValue, T secondValue) {
// Sanity check: make sure the Type of the configoption is what we expect
Preconditions.checkState(opt.getType().equals(requiredType));
final EnumSet<ConfigOption.Type> allowedTypes =
EnumSet.of(ConfigOption.Type.GLOBAL,
ConfigOption.Type.GLOBAL_OFFLINE,
ConfigOption.Type.MASKABLE);
Preconditions.checkState(allowedTypes.contains(opt.getType()));
// Sanity check: it's kind of pointless for the first and second values to be identical
Preconditions.checkArgument(!firstValue.equals(secondValue));
// Get full string path of config option
final String path = ConfigElement.getPath(opt);
// Set and check initial value before and after database restart
mgmt.set(path, firstValue);
assertEquals(firstValue.toString(), mgmt.get(path));
// Close open tx first. This is specific to BDB + GLOBAL_OFFLINE.
// Basically: the BDB store manager throws a fit if shutdown is called
// with one or more transactions still open, and GLOBAL_OFFLINE calls
// shutdown on our behalf when we commit this change.
tx.rollback();
mgmt.commit();
clopen();
// Close tx again following clopen
tx.rollback();
assertEquals(firstValue.toString(), mgmt.get(path));
// Set and check updated value before and after database restart
mgmt.set(path, secondValue);
assertEquals(secondValue.toString(), mgmt.get(path));
mgmt.commit();
clopen();
tx.rollback();
assertEquals(secondValue.toString(), mgmt.get(path));
// Open a separate graph "g2"
TitanGraph g2 = TitanFactory.open(config);
TitanManagement m2 = g2.openManagement();
assertEquals(secondValue.toString(), m2.get(path));
// GLOBAL_OFFLINE options should be unmodifiable with g2 open
if (opt.getType().equals(ConfigOption.Type.GLOBAL_OFFLINE)) {
try {
mgmt.set(path, firstValue);
mgmt.commit();
fail("Option " + path + " with type " + ConfigOption.Type.GLOBAL_OFFLINE + " should not be modifiable with concurrent instances");
} catch (RuntimeException e) {
log.debug("Caught expected exception", e);
}
assertEquals(secondValue.toString(), mgmt.get(path));
// GLOBAL and MASKABLE should be modifiable even with g2 open
} else {
mgmt.set(path, firstValue);
assertEquals(firstValue.toString(), mgmt.get(path));
mgmt.commit();
clopen();
assertEquals(firstValue.toString(), mgmt.get(path));
}
m2.rollback();
g2.close();
}
示例7: 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());
}
}
示例8: 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();
}
}