本文整理汇总了Java中com.orientechnologies.common.util.OCallable类的典型用法代码示例。如果您正苦于以下问题:Java OCallable类的具体用法?Java OCallable怎么用?Java OCallable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OCallable类属于com.orientechnologies.common.util包,在下文中一共展示了OCallable类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.orientechnologies.common.util.OCallable; //导入依赖的package包/类
public <RET> RET execute(final OCallable<RET, OrientGraph> iCallable, final String... iOperationStrings) throws RuntimeException {
makeActive();
if (OLogManager.instance().isWarnEnabled() && iOperationStrings.length > 0) {
// COMPOSE THE MESSAGE
final StringBuilder msg = new StringBuilder(256);
for (String s : iOperationStrings)
msg.append(s);
// ASSURE PENDING TX IF ANY IS COMMITTED
OLogManager.instance().warn(
this,
msg.toString());
}
return iCallable.call(this);
}
示例2: setup
import com.orientechnologies.common.util.OCallable; //导入依赖的package包/类
@Before
public void setup() throws Exception {
File workDir = temporaryFolder.newFolder();
when(applicationDirectories.getWorkDirectory("db")).thenReturn(workDir);
databaseFrozenStateManager = new LocalDatabaseFrozenStateManager(applicationDirectories);
when(distributedServerManager.getMessageService()).thenReturn(distributedMessageService);
when(distributedMessageService.getDatabases()).thenReturn(Collections.singleton("test"));
when(distributedServerManager.executeInDistributedDatabaseLock(eq("test"), anyLong(),
any(OModifiableDistributedConfiguration.class),
(OCallable<Object, OModifiableDistributedConfiguration>) notNull()))
.then(invoc -> ((OCallable) invoc.getArguments()[3]).call(distributedConfiguration));
when(distributedServerManager.getDatabaseConfiguration("test"))
.thenReturn(distributedConfiguration);
when(nodeAccess.isClustered()).thenReturn(false);
providerSet = of(database.getInstanceProvider(), database2.getInstanceProvider()).collect(toSet());
underTest = new DatabaseFreezeServiceImpl(
providerSet,
eventManager,
databaseFrozenStateManager,
() -> server,
nodeAccess,
securityHelper);
when(server.getDistributedManager()).thenReturn(distributedServerManager);
for (Provider<DatabaseInstance> provider : providerSet) {
try (ODatabaseDocumentTx db = provider.get().connect()) {
OSchema schema = db.getMetadata().getSchema();
schema.createClass(DB_CLASS);
}
}
underTest.doStart();
}
示例3: createIndex
import com.orientechnologies.common.util.OCallable; //导入依赖的package包/类
private <E extends Element> void createIndex(final String key, String className, final Configuration configuration) {
makeActive();
prepareIndexConfiguration(configuration);
OCallable<OClass, OrientGraph> callable = new OCallable<OClass, OrientGraph>() {
@Override
public OClass call(final OrientGraph g) {
String indexType = configuration.getString("type");
OType keyType = (OType) configuration.getProperty("keytype");
String collate = configuration.getString("collate");
ODocument metadata = (ODocument) configuration.getProperty("metadata");
final ODatabaseDocumentTx db = getRawDatabase();
final OSchema schema = db.getMetadata().getSchema();
final OClass cls = schema.getClass(className);
final OProperty property = cls.getProperty(key);
if (property != null)
keyType = property.getType();
OPropertyIndexDefinition indexDefinition = new OPropertyIndexDefinition(className, key, keyType);
if (collate != null)
indexDefinition.setCollate(collate);
db.getMetadata().getIndexManager()
.createIndex(className + "." + key, indexType, indexDefinition, cls.getPolymorphicClusterIds(), null, metadata);
return null;
}
};
execute(callable, "create key index on '", className, ".", key, "'");
}
示例4: createSchema
import com.orientechnologies.common.util.OCallable; //导入依赖的package包/类
protected void createSchema()
{
graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Object call(final OrientBaseGraph g)
{
OrientVertexType v = g.getVertexBaseType();
if(!v.existsProperty(NODE_ID)) { // TODO fix schema detection hack later
v.createProperty(NODE_ID, OType.INTEGER);
g.createKeyIndex(NODE_ID, Vertex.class, new Parameter("type", "UNIQUE_HASH_INDEX"), new Parameter(
"keytype", "INTEGER"));
v.createEdgeProperty(Direction.OUT, SIMILAR, OType.LINKBAG);
v.createEdgeProperty(Direction.IN, SIMILAR, OType.LINKBAG);
OrientEdgeType similar = g.createEdgeType(SIMILAR);
similar.createProperty("out", OType.LINK, v);
similar.createProperty("in", OType.LINK, v);
g.createKeyIndex(COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"),
new Parameter("keytype", "INTEGER"));
g.createKeyIndex(NODE_COMMUNITY, Vertex.class, new Parameter("type", "NOTUNIQUE_HASH_INDEX"),
new Parameter("keytype", "INTEGER"));
}
return null;
}
});
}