Refine search
@Override public OMetadata getMetadata() { return dbf.db().getMetadata(); }
private boolean startRecording(final ODatabase db) { if (recordingDatabases.contains(db.getName())) { db.registerListener(this); // this call must be made with the given db active on this thread withActiveDb(db, () -> db.registerHook(this, HOOK_POSITION.LAST)); return true; } return false; }
@Override public OResult next() { OResult res = prevResult.next(); if (count % batchSize == 0) { ODatabase db = ctx.getDatabase(); if (db.getTransaction().isActive()) { db.commit(); db.begin(); } } count++; return res; }
@Override public int addCluster(String type, String clusterName, int requestedId, String location, String dataSegmentName, Object... params) { return dbf.db().addCluster(type, clusterName, requestedId, location, dataSegmentName, params); }
void createUser(final ODatabase<?> database) { database.getMetadata().getSecurity().createUser( userName, new String(password), database.getMetadata().getSecurity().getRole(ORole.ADMIN) ); } }
private OLuceneFullTextIndex searchForIndex(OCommandContext ctx, String className) { OMetadata dbMetadata = ctx.getDatabase().activateOnCurrentThread().getMetadata(); List<OLuceneFullTextIndex> indices = dbMetadata.getSchema().getClass(className).getIndexes().stream() .filter(idx -> idx instanceof OLuceneFullTextIndex).map(idx -> (OLuceneFullTextIndex) idx).collect(Collectors.toList()); if (indices.size() > 1) { throw new IllegalArgumentException("too many full-text indices on given class: " + className); } return indices.size() == 0 ? null : indices.get(0); }
@Override public OResultSet executeSimple(OCommandContext ctx) { List<Object> params = new ArrayList<>(); StringBuilder sb = new StringBuilder(); sb.append("DELETE FROM OUser WHERE "); sb.append(OCreateUserStatement.USER_FIELD_NAME); sb.append(" = ?"); params.add(this.name.getStringValue()); return ctx.getDatabase().command(sb.toString(), params.toArray()); }
@Override protected void doCleanupAfterCompletion(Object transaction) { OrientTransaction tx = (OrientTransaction) transaction; if (!tx.getDatabase().isClosed()) { log.debug("closing transaction, db.hashCode() = {}", tx.getDatabase().hashCode()); tx.getDatabase().close(); } TransactionSynchronizationManager.unbindResource(dbf); }
throw new IllegalArgumentException("invalid number of retries: " + nRetries); OTransaction tx = getTransaction(); boolean txActive = tx.isActive(); if (txActive) { begin(); try { result = function.apply((ODatabaseSession) this); commit(); break; } catch (ONeedRetryException e) { throw e; rollback(); begin(); } catch (Exception e) { throw OException.wrapException(new ODatabaseException("Error during tx retry"), e); begin();
@Override protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException { OrientTransaction tx = (OrientTransaction) transaction; ODatabase<?> db = tx.getDatabase(); if (db == null || db.isClosed()) { db = dbf.openDatabase(); tx.setDatabase(db); TransactionSynchronizationManager.bindResource(dbf, db); } log.debug("beginning transaction, db.hashCode() = {}", db.hashCode()); db.begin(); }
sb.append(ROLE_FIELD_NAME); sb.append(" IN ["); OSecurity security = ctx.getDatabase().getMetadata().getSecurity(); for (int i = 0; i < this.roles.size(); ++i) { String roleName = this.roles.get(i).getStringValue(); return ctx.getDatabase().command(sb.toString(), params.toArray());
protected void createSchema(ODatabaseIdentifier databaseIdentifier) { final ODatabase database = getDocumentDatabase(databaseIdentifier, OStorageRemote.CONNECTION_STRATEGY.STICKY); try { final OSchema schema = database.getMetadata().getSchema(); if (!schema.existsClass(OCRUDWorkload.CLASS_NAME)) { final OClass cls = schema.createClass(OCRUDWorkload.CLASS_NAME); cls.createProperty("name", OType.STRING); // cls.createIndex(INDEX_NAME, OClass.INDEX_TYPE.UNIQUE_HASH_INDEX.toString(), "name"); cls.createIndex(INDEX_NAME, OClass.INDEX_TYPE.UNIQUE.toString(), (OProgressListener) null, (ODocument) null, "AUTOSHARDING", new String[] { "name" }); } } finally { database.close(); } }
result.setProperty("name", db.getName()); result.setProperty("user", db.getUser() == null ? null : db.getUser().getName()); result.setProperty("type", String.valueOf(db.get(ODatabase.ATTRIBUTES.TYPE))); result.setProperty("status", String.valueOf(db.get(ODatabase.ATTRIBUTES.STATUS))); result.setProperty("defaultClusterId", String.valueOf(db.get(ODatabase.ATTRIBUTES.DEFAULTCLUSTERID))); result.setProperty("dateFormat", String.valueOf(db.get(ODatabase.ATTRIBUTES.DATEFORMAT))); result.setProperty("dateTimeFormat", String.valueOf(db.get(ODatabase.ATTRIBUTES.DATETIMEFORMAT))); result.setProperty("timezone", String.valueOf(db.get(ODatabase.ATTRIBUTES.TIMEZONE))); result.setProperty("localeCountry", String.valueOf(db.get(ODatabase.ATTRIBUTES.LOCALECOUNTRY))); result.setProperty("localeLanguage", String.valueOf(db.get(ODatabase.ATTRIBUTES.LOCALELANGUAGE))); result.setProperty("charset", String.valueOf(db.get(ODatabase.ATTRIBUTES.CHARSET))); result.setProperty("clusterSelection", String.valueOf(db.get(ODatabase.ATTRIBUTES.CLUSTERSELECTION))); result.setProperty("minimumClusters", String.valueOf(db.get(ODatabase.ATTRIBUTES.MINIMUMCLUSTERS))); result.setProperty("conflictStrategy", String.valueOf(db.get(ODatabase.ATTRIBUTES.CONFLICTSTRATEGY))); result.setProperty("validation", String.valueOf(db.get(ODatabase.ATTRIBUTES.VALIDATION)));