com.orientechnologies.orient.core.db.ODatabaseInternal Java Examples

The following examples show how to use com.orientechnologies.orient.core.db.ODatabaseInternal. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityHook.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
private boolean recordEvent(final ODocument document, final EventKind eventKind) {
  final String typeName = document.getClassName();
  if (typeName != null) {
    final EntityAdapter adapter = recordingAdapters.get(typeName);
    if (adapter != null) {
      final ODatabaseInternal db = getCurrrentDb();
      if (db != null) {
        // workaround OrientDB 2.1 issue where in-TX dictionary updates are not replicated
        if (db.getStorage().isDistributed() && adapter instanceof SingletonEntityAdapter) {
          ((SingletonEntityAdapter) adapter).singleton.replicate(document, eventKind);
        }
        List<Object> events = dbEvents.get(db);
        if (events == null) {
          events = new ArrayList<>();
          dbEvents.put(db, events);
        }
        upsertEvent(events, document, eventKind);
        return true;
      }
    }
  }
  return false;
}
 
Example #2
Source File: EntityHook.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onOpen(final ODatabaseInternal db) {
  unregisterLiveQueryHook(db);
  if (OSecurityNull.class.equals(db.getProperty(ODatabase.OPTIONS.SECURITY.toString()))) {
    return; // ignore maintenance operations which run without security, such as index repair
  }
  if (!startRecording(db)) {
    pendingDbs.add(db);
  }
  // reload metadata when (re-)opening a DB connection if old schema is gone
  // (can be removed after upgrading to OrientDB 2.2.33 as it does it for us)
  if (db.getMetadata().getSchema().countClasses() == 0) {
    log.debug("Reloading metadata for {} as storage has changed", db.getName());
    db.getMetadata().reload();
  }
}
 
Example #3
Source File: EntityHook.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onClose(final ODatabaseInternal db) {
  if (!pendingDbs.remove(db)) {
    stopRecording(db);
    flushEvents(db);
  }
}
 
Example #4
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 5 votes vote down vote up
@Override
public void onDrop(final ODatabaseInternal iDatabase) {
  try {
    OLogManager.instance().debug(this, "Dropping Lucene indexes...");
    for (OIndex idx : iDatabase.getMetadata().getIndexManager().getIndexes()) {
      if (idx.getInternal() instanceof OLuceneIndex) {
        OLogManager.instance().debug(this, "- index '%s'", idx.getName());
        idx.delete();
      }
    }
  } catch (Exception e) {
    OLogManager.instance().warn(this, "Error on dropping Lucene indexes", e);
  }
}
 
Example #5
Source File: OLuceneIndexPlugin.java    From orientdb-lucene with Apache License 2.0 5 votes vote down vote up
@Override
public void onDrop(final ODatabaseInternal iDatabase) {
  OLogManager.instance().info(this, "Dropping Lucene indexes...");
  for (OIndex idx : iDatabase.getMetadata().getIndexManager().getIndexes()) {
    if (idx.getInternal() instanceof OLuceneIndex) {
      OLogManager.instance().info(this, "- index '%s'", idx.getName());
      idx.delete();
    }
  }
}
 
Example #6
Source File: DefaultODatabaseThreadLocalFactory.java    From wicket-orientdb with Apache License 2.0 5 votes vote down vote up
/**
 * Utility method to obtain {@link ODatabaseDocument} from {@link ODatabase}
 * @param db {@link ODatabase} to cast from
 * @return {@link ODatabaseDocument} for a specified {@link ODatabase}
 */
public static ODatabaseDocument castToODatabaseDocument(ODatabase<?> db)
{
	while(db!=null && !(db instanceof ODatabaseDocument))
	{
		if(db instanceof ODatabaseInternal<?>)
		{
			db = ((ODatabaseInternal<?>)db).getUnderlying();
		}
	}
	return (ODatabaseDocument)db;
}
 
Example #7
Source File: OLuceneIndexPlugin.java    From orientdb-lucene with Apache License 2.0 4 votes vote down vote up
@Override
public void onOpen(final ODatabaseInternal iDatabase) {
}
 
Example #8
Source File: OLuceneIndexPlugin.java    From orientdb-lucene with Apache License 2.0 4 votes vote down vote up
@Override
public void onDropClass(final ODatabaseInternal iDatabase, final OClass iClass) {
}
 
Example #9
Source File: OLuceneIndexPlugin.java    From orientdb-lucene with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreateClass(final ODatabaseInternal iDatabase, final OClass iClass) {
}
 
Example #10
Source File: OLuceneIndexPlugin.java    From orientdb-lucene with Apache License 2.0 4 votes vote down vote up
@Override
public void onClose(final ODatabaseInternal iDatabase) {
}
 
Example #11
Source File: OLuceneIndexPlugin.java    From orientdb-lucene with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(final ODatabaseInternal iDatabase) {
}
 
Example #12
Source File: DatabaseListenerSupport.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onDropClass(final ODatabaseInternal db, final OClass type) {
  // no-op
}
 
Example #13
Source File: DatabaseListenerSupport.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onCreateClass(final ODatabaseInternal db, final OClass type) {
  // no-op
}
 
Example #14
Source File: DatabaseListenerSupport.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onClose(final ODatabaseInternal db) {
  // no-op
}
 
Example #15
Source File: DatabaseListenerSupport.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onOpen(final ODatabaseInternal db) {
  // no-op
}
 
Example #16
Source File: DatabaseListenerSupport.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onDrop(final ODatabaseInternal db) {
  // no-op
}
 
Example #17
Source File: DatabaseListenerSupport.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void onCreate(final ODatabaseInternal db) {
  // no-op
}
 
Example #18
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 2 votes vote down vote up
@Override
public void onCreate(ODatabaseInternal iDatabase) {

}
 
Example #19
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 2 votes vote down vote up
@Override
public void onOpen(ODatabaseInternal iDatabase) {

}
 
Example #20
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 2 votes vote down vote up
@Override
public void onClose(ODatabaseInternal iDatabase) {

}
 
Example #21
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 2 votes vote down vote up
@Override
public void onCreateClass(ODatabaseInternal iDatabase, OClass iClass) {

}
 
Example #22
Source File: OLuceneIndexFactory.java    From orientdb-lucene with Apache License 2.0 2 votes vote down vote up
@Override
public void onDropClass(ODatabaseInternal iDatabase, OClass iClass) {

}