use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class LocalCreateBinarySpeedTest method init.
@Override
public void init() {
Orient.instance().getProfiler().startRecording();
database = new ODatabaseDocumentTx(System.getProperty("url")).open("admin", "admin");
record = new ORecordBytes();
database.declareIntent(new OIntentMassiveInsert());
database.begin(TXTYPE.NOTX);
Random rnd = new Random();
recordContent = new byte[RECORD_SIZE];
for (int i = 0; i < RECORD_SIZE; ++i) recordContent[i] = (byte) rnd.nextInt(256);
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class LocalCreateDocumentMultiThreadSpeedTest method init.
@Override
public void init() {
mainDatabase = new ODatabaseDocumentTx(System.getProperty("url"));
mainDatabase.setSerializer(new ORecordSerializerBinary());
if (mainDatabase.exists()) {
mainDatabase.open("admin", "admin");
// else
mainDatabase.drop();
}
mainDatabase.create();
mainDatabase.set(ODatabase.ATTRIBUTES.MINIMUMCLUSTERS, 8);
mainDatabase.getMetadata().getSchema().createClass("Account");
// database.countClusterElements("Account");
foundObjects = 0;
System.out.println("\nTotal objects in Animal cluster before the test: " + foundObjects);
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class ODirtyManagerRidbagTest method before.
@BeforeMethod
public void before() {
db = new ODatabaseDocumentTx("memory:" + ODirtyManagerRidbagTest.class.getSimpleName());
db.create();
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class OSBTreeRidBagConcurrencyMultiRidBag method testConcurrency.
public void testConcurrency() throws Exception {
ODatabaseDocumentTx db = new ODatabaseDocumentTx(URL);
if (db.exists()) {
db.open("admin", "admin");
db.drop();
}
db.create();
for (int i = 0; i < 100; i++) {
ODocument document = new ODocument();
ORidBag ridBag = new ORidBag();
document.field("ridBag", ridBag);
document.save();
ridTreePerDocument.put(document.getIdentity(), new ConcurrentSkipListSet<ORID>());
lastClusterPosition.set(document.getIdentity().getClusterPosition());
}
final List<Future<?>> futures = new ArrayList<Future<?>>();
Random random = new Random();
for (int i = 0; i < 5; i++) addDocExecutor.scheduleAtFixedRate(new DocumentAdder(), random.nextInt(250), 250, TimeUnit.MILLISECONDS);
for (int i = 0; i < 5; i++) futures.add(threadExecutor.submit(new RidAdder(i)));
for (int i = 0; i < 5; i++) futures.add(threadExecutor.submit(new RidDeleter(i)));
latch.countDown();
Thread.sleep(30 * 60000);
addDocExecutor.shutdown();
addDocExecutor.awaitTermination(30, TimeUnit.SECONDS);
Thread.sleep(30 * 60000);
cont = false;
for (Future<?> future : futures) future.get();
long amountOfRids = 0;
for (ORID rid : ridTreePerDocument.keySet()) {
ODocument document = db.load(rid);
document.setLazyLoad(false);
final ConcurrentSkipListSet<ORID> ridTree = ridTreePerDocument.get(rid);
final ORidBag ridBag = document.field("ridBag");
for (OIdentifiable identifiable : ridBag) Assert.assertTrue(ridTree.remove(identifiable.getIdentity()));
Assert.assertTrue(ridTree.isEmpty());
amountOfRids += ridBag.size();
}
System.out.println("Total records added : " + db.countClusterElements(db.getDefaultClusterId()));
System.out.println("Total rids added : " + amountOfRids);
db.drop();
}
use of com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx in project orientdb by orientechnologies.
the class ORestricetedUserCleanUpTest method testAutoCleanUserAfterDelate.
@Test
public void testAutoCleanUserAfterDelate() {
ODatabaseDocument db = new ODatabaseDocumentTx("memory:" + ORestricetedUserCleanUpTest.class.getSimpleName());
db.create();
try {
OSchema schema = db.getMetadata().getSchema();
schema.createClass("TestRecord", schema.getClass(OSecurityShared.RESTRICTED_CLASSNAME));
OSecurity security = db.getMetadata().getSecurity();
OUser auser = security.createUser("auser", "whereever", new String[] {});
OUser reader = security.getUser("admin");
ODocument doc = new ODocument("TestRecord");
Set<OIdentifiable> users = new HashSet<OIdentifiable>();
users.add(auser.getIdentity());
users.add(reader.getIdentity());
doc.field(OSecurityShared.ALLOW_READ_FIELD, users);
doc.field(OSecurityShared.ALLOW_UPDATE_FIELD, users);
doc.field(OSecurityShared.ALLOW_DELETE_FIELD, users);
doc.field(OSecurityShared.ALLOW_ALL_FIELD, users);
ODocument rid = db.save(doc);
security.dropUser("auser");
db.getLocalCache().clear();
doc = db.load(rid.getIdentity());
Assert.assertEquals(((Set<?>) doc.field(OSecurityShared.ALLOW_ALL_FIELD)).size(), 2);
Assert.assertEquals(((Set<?>) doc.field(OSecurityShared.ALLOW_UPDATE_FIELD)).size(), 2);
Assert.assertEquals(((Set<?>) doc.field(OSecurityShared.ALLOW_DELETE_FIELD)).size(), 2);
Assert.assertEquals(((Set<?>) doc.field(OSecurityShared.ALLOW_ALL_FIELD)).size(), 2);
doc.field("abc", "abc");
doc.save();
db.getLocalCache().clear();
doc = db.load(rid.getIdentity());
((Set<?>) doc.field(OSecurityShared.ALLOW_ALL_FIELD)).remove(null);
((Set<?>) doc.field(OSecurityShared.ALLOW_UPDATE_FIELD)).remove(null);
((Set<?>) doc.field(OSecurityShared.ALLOW_DELETE_FIELD)).remove(null);
((Set<?>) doc.field(OSecurityShared.ALLOW_ALL_FIELD)).remove(null);
Assert.assertEquals(((Set<?>) doc.field(OSecurityShared.ALLOW_ALL_FIELD)).size(), 1);
Assert.assertEquals(((Set<?>) doc.field(OSecurityShared.ALLOW_UPDATE_FIELD)).size(), 1);
Assert.assertEquals(((Set<?>) doc.field(OSecurityShared.ALLOW_DELETE_FIELD)).size(), 1);
Assert.assertEquals(((Set<?>) doc.field(OSecurityShared.ALLOW_ALL_FIELD)).size(), 1);
doc.field("abc", "abc");
doc.save();
} finally {
db.drop();
}
}
Aggregations