_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q173200 | ODistributedConfiguration.getClustersOnServer | test | public Set<String> getClustersOnServer(final String iNodeName) {
final Set<String> clusters = new HashSet<String>();
for (String cl : getClusterNames()) {
final List<String> servers = getServers(cl, null);
if (servers.contains(iNodeName))
clusters.add(cl);
}
return clusters;
} | java | {
"resource": ""
} |
q173201 | ODistributedConfiguration.getClustersOwnedByServer | test | public Set<String> getClustersOwnedByServer(final String iNodeName) {
final Set<String> clusters = new HashSet<String>();
for (String cl : getClusterNames()) {
if (iNodeName.equals(getClusterOwner(cl)))
clusters.add(cl);
}
return clusters;
} | java | {
"resource": ""
} |
q173202 | ODistributedConfiguration.getClusterOwner | test | public String getClusterOwner(final String iClusterName) {
String owner;
final ODocument clusters = getConfiguredClusters();
// GET THE CLUSTER CFG
final ODocument cfg = iClusterName != null ? (ODocument) clusters.field(iClusterName) : null;
if (cfg != null) {
owner = cfg.field(OWNER);
if (owner != null)
return owner;
final List<String> serverList = cfg.field(SERVERS);
if (serverList != null && !serverList.isEmpty()) {
// RETURN THE FIRST ONE
owner = serverList.get(0);
if (NEW_NODE_TAG.equals(owner) && serverList.size() > 1)
// DON'T RETURN <NEW_NODE>
owner = serverList.get(1);
}
} else
// RETURN THE OWNER OF *
return getClusterOwner(ALL_WILDCARD);
return owner;
} | java | {
"resource": ""
} |
q173203 | ODistributedConfiguration.getConfiguredClusterOwner | test | public String getConfiguredClusterOwner(final String iClusterName) {
String owner = null;
final ODocument clusters = getConfiguredClusters();
// GET THE CLUSTER CFG
final ODocument cfg = clusters.field(iClusterName);
if (cfg != null)
owner = cfg.field(OWNER);
return owner;
} | java | {
"resource": ""
} |
q173204 | ODistributedConfiguration.getConfiguredServers | test | public List<String> getConfiguredServers(final String iClusterName) {
final Collection<? extends String> list = (Collection<? extends String>) getClusterConfiguration(iClusterName).field(SERVERS);
return list != null ? new ArrayList<String>(list) : null;
} | java | {
"resource": ""
} |
q173205 | ODistributedConfiguration.getRegisteredServers | test | public Set<String> getRegisteredServers() {
final ODocument servers = configuration.field(SERVERS);
final Set<String> result = new HashSet<String>();
if (servers != null)
for (String s : servers.fieldNames())
result.add(s);
return result;
} | java | {
"resource": ""
} |
q173206 | ODistributedConfiguration.getDataCenters | test | public Set<String> getDataCenters() {
final ODocument dcs = configuration.field(DCS);
if (dcs == null)
return Collections.EMPTY_SET;
final Set<String> result = new HashSet<String>();
for (String dc : dcs.fieldNames()) {
result.add(dc);
}
return result;
} | java | {
"resource": ""
} |
q173207 | ODistributedConfiguration.getDataCenterWriteQuorum | test | public int getDataCenterWriteQuorum(final String dataCenter) {
final ODocument dc = getDataCenterConfiguration(dataCenter);
Object wq = dc.field(WRITE_QUORUM);
if (wq instanceof String) {
if (wq.toString().equalsIgnoreCase(ODistributedConfiguration.QUORUM_MAJORITY)) {
final List<String> servers = dc.field(SERVERS);
wq = servers.size() / 2 + 1;
} else if (wq.toString().equalsIgnoreCase(ODistributedConfiguration.QUORUM_ALL)) {
final List<String> servers = dc.field(SERVERS);
wq = servers.size();
}
}
return (Integer) wq;
} | java | {
"resource": ""
} |
q173208 | ODistributedConfiguration.isSharded | test | public boolean isSharded() {
final ODocument allCluster = getClusterConfiguration(ALL_WILDCARD);
if (allCluster != null) {
final List<String> allServers = allCluster.field(SERVERS);
if (allServers != null && !allServers.isEmpty()) {
for (String cl : getClusterNames()) {
final List<String> servers = getServers(cl, null);
if (servers != null && !servers.isEmpty() && !allServers.containsAll(servers))
return false;
}
}
}
return false;
} | java | {
"resource": ""
} |
q173209 | ODistributedConfiguration.getDataCenterServers | test | public List<String> getDataCenterServers(final String dataCenter) {
final ODocument dc = getDataCenterConfiguration(dataCenter);
final List<String> servers = dc.field(SERVERS);
if (servers == null || servers.isEmpty())
throw new OConfigurationException(
"Data center '" + dataCenter + "' does not contain any server in distributed database configuration");
return new ArrayList<String>(servers);
} | java | {
"resource": ""
} |
q173210 | ODistributedConfiguration.getDataCenterOfServer | test | public String getDataCenterOfServer(final String server) {
final ODocument dcs = configuration.field(DCS);
if (dcs != null) {
for (String dc : dcs.fieldNames()) {
final ODocument dcConfig = dcs.field(dc);
if (dcConfig != null) {
final List<String> dcServers = dcConfig.field("servers");
if (dcServers != null && !dcServers.isEmpty()) {
if (dcServers.contains(server))
// FOUND
return dc;
}
}
}
}
// NOT FOUND
return null;
} | java | {
"resource": ""
} |
q173211 | ODistributedConfiguration.getGlobalReadQuorum | test | public Object getGlobalReadQuorum(final String iClusterName) {
Object value = getClusterConfiguration(iClusterName).field(READ_QUORUM);
if (value == null)
value = configuration.field(READ_QUORUM);
return value;
} | java | {
"resource": ""
} |
q173212 | ODistributedConfiguration.getWriteQuorum | test | public int getWriteQuorum(final String clusterName, final int totalConfiguredMasterServers, final String server) {
Integer overWrite = overwriteWriteQuorum.get();
if (overWrite != null)
return overWrite.intValue();
else
return getQuorum("writeQuorum", clusterName, totalConfiguredMasterServers, DEFAULT_WRITE_QUORUM, server);
} | java | {
"resource": ""
} |
q173213 | ODistributedConfiguration.getClusterConfiguration | test | protected ODocument getClusterConfiguration(String iClusterName) {
final ODocument clusters = getConfiguredClusters();
if (iClusterName == null)
iClusterName = ALL_WILDCARD;
final ODocument cfg;
if (!clusters.containsField(iClusterName))
// NO CLUSTER IN CFG: GET THE DEFAULT ONE
cfg = clusters.field(ALL_WILDCARD);
else
// GET THE CLUSTER CFG
cfg = clusters.field(iClusterName);
if (cfg == null)
return new ODocument();
return cfg;
} | java | {
"resource": ""
} |
q173214 | ODistributedConfiguration.getDataCenterConfiguration | test | private ODocument getDataCenterConfiguration(final String dataCenter) {
final ODocument dcs = configuration.field(DCS);
if (dcs != null)
return dcs.field(dataCenter);
throw new OConfigurationException("Cannot find the data center '" + dataCenter + "' in distributed database configuration");
} | java | {
"resource": ""
} |
q173215 | OrientBaseGraph.clearInitStack | test | public static void clearInitStack() {
final ThreadLocal<Deque<OrientBaseGraph>> is = initializationStack;
if (is != null)
is.get().clear();
final ThreadLocal<OrientBaseGraph> ag = activeGraph;
if (ag != null)
ag.remove();
} | java | {
"resource": ""
} |
q173216 | OrientBaseGraph.getIndex | test | @SuppressWarnings("unchecked")
@Override
public <T extends Element> Index<T> getIndex(final String indexName, final Class<T> indexClass) {
makeActive();
final OIndexManager indexManager = getDatabase().getMetadata().getIndexManager();
final OIndex idx = indexManager.getIndex(indexName);
if (idx == null || !hasIndexClass(idx))
return null;
final Index<? extends Element> index = new OrientIndex(this, idx);
if (indexClass.isAssignableFrom(index.getIndexClass()))
return (Index<T>) index;
else
throw ExceptionFactory.indexDoesNotSupportClass(indexName, indexClass);
} | java | {
"resource": ""
} |
q173217 | OrientBaseGraph.dropIndex | test | public void dropIndex(final String indexName) {
makeActive();
executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
@Override
public Object call(OrientBaseGraph g) {
try {
final OIndexManager indexManager = getRawGraph().getMetadata().getIndexManager();
final OIndex index = indexManager.getIndex(indexName);
ODocument metadata = index.getConfiguration().field("metadata");
String recordMapIndexName = null;
if (metadata != null) {
recordMapIndexName = metadata.field(OrientIndex.CONFIG_RECORD_MAP_NAME);
}
indexManager.dropIndex(indexName);
if (recordMapIndexName != null)
getRawGraph().getMetadata().getIndexManager().dropIndex(recordMapIndexName);
saveIndexConfiguration();
return null;
} catch (Exception e) {
g.rollback();
throw new RuntimeException(e.getMessage(), e);
}
}
}, "drop index '", indexName, "'");
} | java | {
"resource": ""
} |
q173218 | OrientBaseGraph.addVertex | test | @Override
public OrientVertex addVertex(final Object id) {
makeActive();
return addVertex(id, (Object[]) null);
} | java | {
"resource": ""
} |
q173219 | OrientBaseGraph.addEdge | test | @Override
public OrientEdge addEdge(final Object id, Vertex outVertex, Vertex inVertex, final String label) {
makeActive();
String className = null;
String clusterName = null;
if (id != null) {
if (id instanceof String) {
// PARSE ARGUMENTS
final String[] args = ((String) id).split(",");
for (String s : args) {
if (s.startsWith(CLASS_PREFIX))
// GET THE CLASS NAME
className = s.substring(CLASS_PREFIX.length());
else if (s.startsWith(CLUSTER_PREFIX))
// GET THE CLASS NAME
clusterName = s.substring(CLUSTER_PREFIX.length());
}
}
}
// SAVE THE ID TOO?
final Object[] fields = isSaveOriginalIds() && id != null ? new Object[] { OrientElement.DEF_ORIGINAL_ID_FIELDNAME, id } : null;
if (outVertex instanceof PartitionVertex)
// WRAPPED: GET THE BASE VERTEX
outVertex = ((PartitionVertex) outVertex).getBaseVertex();
if (inVertex instanceof PartitionVertex)
// WRAPPED: GET THE BASE VERTEX
inVertex = ((PartitionVertex) inVertex).getBaseVertex();
return ((OrientVertex) outVertex).addEdge(label, (OrientVertex) inVertex, className, clusterName, fields);
} | java | {
"resource": ""
} |
q173220 | OrientBaseGraph.getVertex | test | public OrientVertex getVertex(final Object id) {
makeActive();
if (null == id)
throw ExceptionFactory.vertexIdCanNotBeNull();
if (id instanceof OrientVertex)
return (OrientVertex) id;
else if (id instanceof ODocument)
return getVertexInstance((OIdentifiable) id);
setCurrentGraphInThreadLocal();
ORID rid;
if (id instanceof OIdentifiable)
rid = ((OIdentifiable) id).getIdentity();
else {
try {
rid = new ORecordId(id.toString());
} catch (IllegalArgumentException iae) {
// orientdb throws IllegalArgumentException: Argument 'xxxx' is
// not a RecordId in form of string. Format must be:
// <cluster-id>:<cluster-position>
return null;
}
}
if (!rid.isValid())
return null;
final ORecord rec = rid.getRecord();
if (rec == null || !(rec instanceof ODocument))
return null;
final OClass cls = ((ODocument) rec).getSchemaClass();
if (cls != null && cls.isEdgeType())
throw new IllegalArgumentException("Cannot retrieve a vertex with the RID " + rid + " because it is an edge");
return getVertexInstance(rec);
} | java | {
"resource": ""
} |
q173221 | OrientBaseGraph.getVerticesOfClass | test | public Iterable<Vertex> getVerticesOfClass(final String iClassName, final boolean iPolymorphic) {
makeActive();
final OClass cls = getRawGraph().getMetadata().getSchema().getClass(iClassName);
if (cls == null)
throw new IllegalArgumentException("Cannot find class '" + iClassName + "' in database schema");
if (!cls.isSubClassOf(OrientVertexType.CLASS_NAME))
throw new IllegalArgumentException("Class '" + iClassName + "' is not a vertex class");
return new OrientElementScanIterable<Vertex>(this, iClassName, iPolymorphic);
} | java | {
"resource": ""
} |
q173222 | OrientBaseGraph.getEdgesOfClass | test | public Iterable<Edge> getEdgesOfClass(final String iClassName, final boolean iPolymorphic) {
makeActive();
final OClass cls = getRawGraph().getMetadata().getSchema().getClass(iClassName);
if (cls == null)
throw new IllegalArgumentException("Cannot find class '" + iClassName + "' in database schema");
if (!cls.isSubClassOf(OrientEdgeType.CLASS_NAME))
throw new IllegalArgumentException("Class '" + iClassName + "' is not an edge class");
return new OrientElementScanIterable<Edge>(this, iClassName, iPolymorphic);
} | java | {
"resource": ""
} |
q173223 | OrientBaseGraph.getEdge | test | public OrientEdge getEdge(final Object id) {
makeActive();
if (null == id)
throw ExceptionFactory.edgeIdCanNotBeNull();
if (id instanceof OrientEdge)
return (OrientEdge) id;
else if (id instanceof ODocument)
return new OrientEdge(this, (OIdentifiable) id);
final OIdentifiable rec;
if (id instanceof OIdentifiable)
rec = (OIdentifiable) id;
else {
final String str = id.toString();
int pos = str.indexOf("->");
if (pos > -1) {
// DUMMY EDGE: CREATE IT IN MEMORY
final String from = str.substring(0, pos);
final String to = str.substring(pos + 2);
return getEdgeInstance(new ORecordId(from), new ORecordId(to), null);
}
try {
rec = new ORecordId(str);
} catch (IllegalArgumentException iae) {
// orientdb throws IllegalArgumentException: Argument 'xxxx' is
// not a RecordId in form of string. Format must be:
// [#]<cluster-id>:<cluster-position>
return null;
}
}
final ODocument doc = rec.getRecord();
if (doc == null)
return null;
final OClass cls = doc.getSchemaClass();
if (cls != null) {
if (cls.isVertexType())
throw new IllegalArgumentException("Cannot retrieve an edge with the RID " + id + " because it is a vertex");
if (!cls.isEdgeType())
throw new IllegalArgumentException("Class '" + doc.getClassName() + "' is not an edge class");
}
return new OrientEdge(this, rec);
} | java | {
"resource": ""
} |
q173224 | OrientBaseGraph.reuse | test | public OrientBaseGraph reuse(final ODatabaseDocumentInternal iDatabase) {
ODatabaseRecordThreadLocal.instance().set(iDatabase);
this.url = iDatabase.getURL();
database = iDatabase;
makeActive();
return this;
} | java | {
"resource": ""
} |
q173225 | OrientBaseGraph.shutdown | test | public void shutdown(boolean closeDb, boolean commitTx) {
makeActive();
try {
if (!isClosed()) {
if (commitTx) {
final OStorage storage = getDatabase().getStorage().getUnderlying();
if (storage instanceof OAbstractPaginatedStorage) {
if (((OAbstractPaginatedStorage) storage).getWALInstance() != null)
getDatabase().commit();
} else {
getDatabase().commit();
}
} else if (closeDb) {
getDatabase().rollback();
}
}
} catch (ONeedRetryException e) {
throw e;
} catch (RuntimeException e) {
OLogManager.instance().error(this, "Error during context close for db " + url, e);
throw e;
} catch (Exception e) {
OLogManager.instance().error(this, "Error during context close for db " + url, e);
throw OException.wrapException(new ODatabaseException("Error during context close for db " + url), e);
} finally {
try {
if (closeDb) {
getDatabase().close();
if (getDatabase().isPooled()) {
database = null;
}
}
pollGraphFromStack(closeDb);
} catch (Exception e) {
OLogManager.instance().error(this, "Error during context close for db " + url, e);
}
}
url = null;
username = null;
password = null;
if (!closeDb)
getDatabase().activateOnCurrentThread();
} | java | {
"resource": ""
} |
q173226 | OrientBaseGraph.getVertexBaseType | test | public OrientVertexType getVertexBaseType() {
makeActive();
return new OrientVertexType(this, getRawGraph().getMetadata().getSchema().getClass(OrientVertexType.CLASS_NAME));
} | java | {
"resource": ""
} |
q173227 | OrientBaseGraph.getVertexType | test | public OrientVertexType getVertexType(final String iTypeName) {
makeActive();
final OClass cls = getRawGraph().getMetadata().getSchema().getClass(iTypeName);
if (cls == null)
return null;
OrientVertexType.checkType(cls);
return new OrientVertexType(this, cls);
} | java | {
"resource": ""
} |
q173228 | OrientBaseGraph.createVertexType | test | public OrientVertexType createVertexType(final String iClassName, final int clusters) {
makeActive();
return createVertexType(iClassName, (String) null, clusters);
} | java | {
"resource": ""
} |
q173229 | OrientBaseGraph.dropVertexType | test | public void dropVertexType(final String iTypeName) {
makeActive();
if (getDatabase().countClass(iTypeName) > 0)
throw new OCommandExecutionException("cannot drop vertex type '" + iTypeName
+ "' because it contains Vertices. Use 'DELETE VERTEX' command first to remove data");
executeOutsideTx(new OCallable<OClass, OrientBaseGraph>() {
@Override
public OClass call(final OrientBaseGraph g) {
ODatabaseDocument rawGraph = getRawGraph();
rawGraph.getMetadata().getSchema().dropClass(iTypeName);
return null;
}
}, "drop vertex type '", iTypeName, "'");
} | java | {
"resource": ""
} |
q173230 | OrientBaseGraph.getEdgeType | test | public OrientEdgeType getEdgeType(final String iTypeName) {
makeActive();
final OClass cls = getRawGraph().getMetadata().getSchema().getClass(iTypeName);
if (cls == null)
return null;
OrientEdgeType.checkType(cls);
return new OrientEdgeType(this, cls);
} | java | {
"resource": ""
} |
q173231 | OrientBaseGraph.createEdgeType | test | public OrientEdgeType createEdgeType(final String iClassName, final int clusters) {
makeActive();
return createEdgeType(iClassName, (String) null, clusters);
} | java | {
"resource": ""
} |
q173232 | OrientBaseGraph.getElement | test | public OrientElement getElement(final Object id) {
makeActive();
if (null == id)
throw new IllegalArgumentException("id cannot be null");
if (id instanceof OrientElement)
return (OrientElement) id;
OIdentifiable rec;
if (id instanceof OIdentifiable)
rec = (OIdentifiable) id;
else
try {
rec = new ORecordId(id.toString());
} catch (IllegalArgumentException iae) {
// orientdb throws IllegalArgumentException: Argument 'xxxx' is
// not a RecordId in form of string. Format must be:
// <cluster-id>:<cluster-position>
return null;
}
final ODocument doc = rec.getRecord();
if (doc != null) {
final OImmutableClass schemaClass = ODocumentInternal.getImmutableSchemaClass(doc);
if (schemaClass != null && schemaClass.isEdgeType())
return getEdge(doc);
else
return getVertexInstance(doc);
}
return null;
} | java | {
"resource": ""
} |
q173233 | OrientBaseGraph.dropKeyIndex | test | public <T extends Element> void dropKeyIndex(final String key, final Class<T> elementClass) {
makeActive();
if (elementClass == null)
throw ExceptionFactory.classForElementCannotBeNull();
executeOutsideTx(new OCallable<OClass, OrientBaseGraph>() {
@Override
public OClass call(final OrientBaseGraph g) {
final String className = getClassName(elementClass);
getRawGraph().getMetadata().getIndexManager().dropIndex(className + "." + key);
return null;
}
}, "drop key index '", elementClass.getSimpleName(), ".", key, "'");
} | java | {
"resource": ""
} |
q173234 | OrientBaseGraph.createKeyIndex | test | @SuppressWarnings({ "rawtypes" })
@Override
public <T extends Element> void createKeyIndex(final String key, final Class<T> elementClass,
final Parameter... indexParameters) {
makeActive();
if (elementClass == null)
throw ExceptionFactory.classForElementCannotBeNull();
executeOutsideTx(new OCallable<OClass, OrientBaseGraph>() {
@Override
public OClass call(final OrientBaseGraph g) {
String indexType = OClass.INDEX_TYPE.NOTUNIQUE.name();
OType keyType = OType.STRING;
String className = null;
String collate = null;
ODocument metadata = null;
final String ancestorClassName = getClassName(elementClass);
// READ PARAMETERS
for (Parameter<?, ?> p : indexParameters) {
if (p.getKey().equals("type"))
indexType = p.getValue().toString().toUpperCase(Locale.ENGLISH);
else if (p.getKey().equals("keytype"))
keyType = OType.valueOf(p.getValue().toString().toUpperCase(Locale.ENGLISH));
else if (p.getKey().equals("class"))
className = p.getValue().toString();
else if (p.getKey().equals("collate"))
collate = p.getValue().toString();
else if (p.getKey().toString().startsWith("metadata.")) {
if (metadata == null)
metadata = new ODocument();
metadata.field(p.getKey().toString().substring("metadata.".length()), p.getValue());
}
}
if (className == null)
className = ancestorClassName;
final ODatabaseDocument db = getRawGraph();
final OSchema schema = db.getMetadata().getSchema();
final OClass cls = schema.getOrCreateClass(className, schema.getClass(ancestorClassName));
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;
}
}, "create key index on '", elementClass.getSimpleName(), ".", key, "'");
} | java | {
"resource": ""
} |
q173235 | OWOWCache.removeBackgroundExceptionListener | test | @Override
public void removeBackgroundExceptionListener(final OBackgroundExceptionListener listener) {
final List<WeakReference<OBackgroundExceptionListener>> itemsToRemove = new ArrayList<>(1);
for (final WeakReference<OBackgroundExceptionListener> ref : backgroundExceptionListeners) {
final OBackgroundExceptionListener l = ref.get();
if (l != null && l.equals(listener)) {
itemsToRemove.add(ref);
}
}
backgroundExceptionListeners.removeAll(itemsToRemove);
} | java | {
"resource": ""
} |
q173236 | OWOWCache.fireBackgroundDataFlushExceptionEvent | test | private void fireBackgroundDataFlushExceptionEvent(final Throwable e) {
for (final WeakReference<OBackgroundExceptionListener> ref : backgroundExceptionListeners) {
final OBackgroundExceptionListener listener = ref.get();
if (listener != null) {
listener.onException(e);
}
}
} | java | {
"resource": ""
} |
q173237 | OPerformanceStatisticManager.stopMonitoring | test | public void stopMonitoring() {
switchLock.acquireWriteLock();
try {
enabled = false;
final PerformanceCountersHolder countersHolder = ComponentType.GENERAL.newCountersHolder();
final Map<String, PerformanceCountersHolder> componentCountersHolder = new HashMap<>();
WritCacheCountersHolder writCacheCountersHolder = deadThreadsStatistic.writCacheCountersHolder;
StorageCountersHolder storageCountersHolder = deadThreadsStatistic.storageCountersHolder;
WALCountersHolder walCountersHolder = deadThreadsStatistic.walCountersHolder;
deadThreadsStatistic.countersHolder.pushData(countersHolder);
componentCountersHolder.putAll(deadThreadsStatistic.countersByComponents);
deadThreadsStatistic = null;
for (OSessionStoragePerformanceStatistic statistic : statistics.values()) {
statistic.pushSystemCounters(countersHolder);
statistic.pushComponentCounters(componentCountersHolder);
writCacheCountersHolder = statistic.pushWriteCacheCounters(writCacheCountersHolder);
storageCountersHolder = statistic.pushStorageCounters(storageCountersHolder);
walCountersHolder = statistic.pushWALCounters(walCountersHolder);
}
statistics.clear();
postMeasurementStatistic = new ImmutableStatistic(countersHolder, componentCountersHolder, writCacheCountersHolder,
storageCountersHolder, walCountersHolder);
} finally {
switchLock.releaseWriteLock();
}
} | java | {
"resource": ""
} |
q173238 | OPerformanceStatisticManager.registerMBean | test | public void registerMBean(String storageName, int storageId) {
if (mbeanIsRegistered.compareAndSet(false, true)) {
try {
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
final ObjectName mbeanName = new ObjectName(getMBeanName(storageName, storageId));
if (!server.isRegistered(mbeanName)) {
server.registerMBean(new OPerformanceStatisticManagerMBean(this), mbeanName);
} else {
mbeanIsRegistered.set(false);
OLogManager.instance().warn(this,
"MBean with name %s has already registered. Probably your system was not shutdown correctly"
+ " or you have several running applications which use OrientDB engine inside", mbeanName.getCanonicalName());
}
} catch (MalformedObjectNameException | InstanceAlreadyExistsException | NotCompliantMBeanException | MBeanRegistrationException e) {
throw OException.wrapException(new OStorageException("Error during registration of profiler MBean"), e);
}
}
} | java | {
"resource": ""
} |
q173239 | OPerformanceStatisticManager.unregisterMBean | test | public void unregisterMBean(String storageName, int storageId) {
if (storageName == null) {
OLogManager.instance().warnNoDb(this, "Can not unregister MBean for performance statistics, storage name is null");
}
if (mbeanIsRegistered.compareAndSet(true, false)) {
try {
final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
final ObjectName mbeanName = new ObjectName(getMBeanName(storageName, storageId));
server.unregisterMBean(mbeanName);
} catch (MalformedObjectNameException | InstanceNotFoundException | MBeanRegistrationException e) {
throw OException.wrapException(new OStorageException("Error during unregistration of profiler MBean"), e);
}
}
} | java | {
"resource": ""
} |
q173240 | OPerformanceStatisticManager.fetchWriteCacheCounters | test | private WritCacheCountersHolder fetchWriteCacheCounters() {
//go through all threads and accumulate statistic only for live threads
//all dead threads will be removed and statistics from them will be
//later accumulated in #deadThreadsStatistic field, then result statistic from this field
//will be aggregated to countersHolder
//To decrease inter thread communication delay we fetch snapshots first
//and only after that we aggregate data from immutable snapshots
final Collection<ORawPair<Thread, PerformanceSnapshot>> snapshots = new ArrayList<>(statistics.size());
final Collection<Thread> threadsToRemove = new ArrayList<>();
for (Map.Entry<Thread, OSessionStoragePerformanceStatistic> entry : statistics.entrySet()) {
final Thread thread = entry.getKey();
final OSessionStoragePerformanceStatistic statistic = entry.getValue();
snapshots.add(new ORawPair<>(thread, statistic.getSnapshot()));
}
WritCacheCountersHolder holder = null;
for (ORawPair<Thread, PerformanceSnapshot> pair : snapshots) {
final Thread thread = pair.getFirst();
if (thread.isAlive()) {
final PerformanceSnapshot snapshot = pair.getSecond();
if (snapshot.writCacheCountersHolder != null) {
if (holder == null)
holder = new WritCacheCountersHolder();
snapshot.writCacheCountersHolder.pushData(holder);
}
} else {
threadsToRemove.add(thread);
}
}
if (!threadsToRemove.isEmpty()) {
updateDeadThreadsStatistic(threadsToRemove);
}
final ImmutableStatistic ds = deadThreadsStatistic;
if (ds != null) {
final WritCacheCountersHolder wch = ds.writCacheCountersHolder;
if (wch != null) {
if (holder == null)
holder = new WritCacheCountersHolder();
wch.pushData(holder);
}
}
return holder;
} | java | {
"resource": ""
} |
q173241 | OPerformanceStatisticManager.fetchSystemCounters | test | private void fetchSystemCounters(PerformanceCountersHolder countersHolder) {
//go through all threads and accumulate statistic only for live threads
//all dead threads will be removed and statistics from them will be
//later accumulated in #deadThreadsStatistic field, then result statistic from this field
//will be aggregated to countersHolder
//To decrease inter thread communication delay we fetch snapshots first
//and only after that we aggregate data from immutable snapshots
final Collection<ORawPair<Thread, PerformanceSnapshot>> snapshots = new ArrayList<>(statistics.size());
final Collection<Thread> threadsToRemove = new ArrayList<>();
for (Map.Entry<Thread, OSessionStoragePerformanceStatistic> entry : statistics.entrySet()) {
final Thread thread = entry.getKey();
final OSessionStoragePerformanceStatistic statistic = entry.getValue();
snapshots.add(new ORawPair<>(thread, statistic.getSnapshot()));
}
for (ORawPair<Thread, PerformanceSnapshot> pair : snapshots) {
final Thread thread = pair.getFirst();
if (thread.isAlive()) {
final PerformanceSnapshot snapshot = pair.getSecond();
snapshot.performanceCountersHolder.pushData(countersHolder);
} else {
threadsToRemove.add(thread);
}
}
if (!threadsToRemove.isEmpty()) {
updateDeadThreadsStatistic(threadsToRemove);
}
final ImmutableStatistic ds = deadThreadsStatistic;
if (ds != null) {
final PerformanceCountersHolder dch = ds.countersHolder;
dch.pushData(countersHolder);
}
} | java | {
"resource": ""
} |
q173242 | OPerformanceStatisticManager.fetchComponentCounters | test | private void fetchComponentCounters(String componentName, PerformanceCountersHolder componentCountersHolder) {
//go through all threads and accumulate statistic only for live threads
//all dead threads will be removed and statistics from them will be
//later accumulated in #deadThreadsStatistic field, then result statistic from this field
//will be aggregated to componentCountersHolder
//To decrease inter thread communication delay we fetch snapshots first
//and only after that we aggregate data from immutable snapshots
final Collection<ORawPair<Thread, PerformanceSnapshot>> snapshots = new ArrayList<>(statistics.size());
final List<Thread> threadsToRemove = new ArrayList<>();
for (Map.Entry<Thread, OSessionStoragePerformanceStatistic> entry : statistics.entrySet()) {
final Thread thread = entry.getKey();
final OSessionStoragePerformanceStatistic statistic = entry.getValue();
snapshots.add(new ORawPair<>(thread, statistic.getSnapshot()));
}
for (ORawPair<Thread, PerformanceSnapshot> pair : snapshots) {
final Thread thread = pair.getFirst();
if (thread.isAlive()) {
final PerformanceSnapshot snapshot = pair.getSecond();
final PerformanceCountersHolder holder = snapshot.countersByComponent.get(componentName);
if (holder != null)
holder.pushData(componentCountersHolder);
} else {
threadsToRemove.add(thread);
}
}
if (!threadsToRemove.isEmpty()) {
updateDeadThreadsStatistic(threadsToRemove);
}
final ImmutableStatistic ds = deadThreadsStatistic;
if (ds != null) {
final PerformanceCountersHolder dch = ds.countersByComponents.get(componentName);
if (dch != null) {
dch.pushData(componentCountersHolder);
}
}
} | java | {
"resource": ""
} |
q173243 | OHttpResponse.compress | test | public byte[] compress(String jsonStr) {
if (jsonStr == null || jsonStr.length() == 0) {
return null;
}
GZIPOutputStream gout = null;
ByteArrayOutputStream baos = null;
try {
byte[] incoming = jsonStr.getBytes("UTF-8");
baos = new ByteArrayOutputStream();
gout = new GZIPOutputStream(baos, 16384); // 16KB
gout.write(incoming);
gout.finish();
return baos.toByteArray();
} catch (Exception ex) {
OLogManager.instance().error(this, "Error on compressing HTTP response", ex);
} finally {
try {
if (gout != null) {
gout.close();
}
if (baos != null) {
baos.close();
}
} catch (Exception ex) {
}
}
return null;
} | java | {
"resource": ""
} |
q173244 | OServerConfiguration.getProperty | test | public String getProperty(final String iName, final String iDefaultValue) {
if (properties == null)
return null;
for (OServerEntryConfiguration p : properties) {
if (p.name.equals(iName))
return p.value;
}
return null;
} | java | {
"resource": ""
} |
q173245 | OObjectDatabaseTx.detach | test | public <RET> RET detach(final Object iPojo, boolean returnNonProxiedInstance) {
return (RET) OObjectEntitySerializer.detach(iPojo, this, returnNonProxiedInstance);
} | java | {
"resource": ""
} |
q173246 | OObjectDatabaseTx.getVersion | test | public int getVersion(final Object iPojo) {
checkOpenness();
final ODocument record = getRecordByUserObject(iPojo, false);
if (record != null)
return record.getVersion();
return OObjectSerializerHelper.getObjectVersion(iPojo);
} | java | {
"resource": ""
} |
q173247 | OObjectDatabaseTx.command | test | public <RET extends OCommandRequest> RET command(final OCommandRequest iCommand) {
return (RET) new OCommandSQLPojoWrapper(this, underlying.command(iCommand));
} | java | {
"resource": ""
} |
q173248 | OObjectDatabaseTx.setDirty | test | public void setDirty(final Object iPojo) {
if (iPojo == null)
return;
final ODocument record = getRecordByUserObject(iPojo, false);
if (record == null)
throw new OObjectNotManagedException("The object " + iPojo + " is not managed by current database");
record.setDirty();
} | java | {
"resource": ""
} |
q173249 | OObjectDatabaseTx.unsetDirty | test | public void unsetDirty(final Object iPojo) {
if (iPojo == null)
return;
final ODocument record = getRecordByUserObject(iPojo, false);
if (record == null)
return;
ORecordInternal.unsetDirty(record);
} | java | {
"resource": ""
} |
q173250 | OIndexes.getIndexTypes | test | private static Set<String> getIndexTypes() {
final Set<String> types = new HashSet<>();
final Iterator<OIndexFactory> ite = getAllFactories();
while (ite.hasNext()) {
types.addAll(ite.next().getTypes());
}
return types;
} | java | {
"resource": ""
} |
q173251 | OIndexes.getIndexEngines | test | public static Set<String> getIndexEngines() {
final Set<String> engines = new HashSet<>();
final Iterator<OIndexFactory> ite = getAllFactories();
while (ite.hasNext()) {
engines.addAll(ite.next().getAlgorithms());
}
return engines;
} | java | {
"resource": ""
} |
q173252 | ODistributedResponseManagerImpl.getMissingNodes | test | public List<String> getMissingNodes() {
synchronousResponsesLock.lock();
try {
final List<String> missingNodes = new ArrayList<String>();
for (Map.Entry<String, Object> entry : responses.entrySet())
if (entry.getValue() == NO_RESPONSE)
missingNodes.add(entry.getKey());
return missingNodes;
} finally {
synchronousResponsesLock.unlock();
}
} | java | {
"resource": ""
} |
q173253 | ODistributedResponseManagerImpl.getConflictResponses | test | protected List<ODistributedResponse> getConflictResponses() {
final List<ODistributedResponse> servers = new ArrayList<ODistributedResponse>();
int bestGroupSoFar = getBestResponsesGroup();
for (int i = 0; i < responseGroups.size(); ++i) {
if (i != bestGroupSoFar) {
for (ODistributedResponse r : responseGroups.get(i))
servers.add(r);
}
}
return servers;
} | java | {
"resource": ""
} |
q173254 | ODistributedResponseManagerImpl.getBestResponsesGroup | test | protected int getBestResponsesGroup() {
int maxCoherentResponses = 0;
int bestGroupSoFar = 0;
for (int i = 0; i < responseGroups.size(); ++i) {
final int currentGroupSize = responseGroups.get(i).size();
if (currentGroupSize > maxCoherentResponses) {
maxCoherentResponses = currentGroupSize;
bestGroupSoFar = i;
}
}
return bestGroupSoFar;
} | java | {
"resource": ""
} |
q173255 | ODistributedResponseManagerImpl.computeQuorumResponse | test | private boolean computeQuorumResponse(boolean reachedTimeout) {
if (quorumResponse != null)
// ALREADY COMPUTED
return true;
if (groupResponsesByResult) {
for (List<ODistributedResponse> group : responseGroups) {
if (group.size() >= quorum) {
int responsesForQuorum = 0;
for (ODistributedResponse r : group) {
if (nodesConcurInQuorum.contains(r.getExecutorNodeName())) {
final Object payload = r.getPayload();
if (payload instanceof Throwable) {
if (payload instanceof ODistributedRecordLockedException)
// JUST ONE ODistributedRecordLockedException IS ENOUGH TO FAIL THE OPERATION BECAUSE RESOURCES CANNOT BE LOCKED
break;
if (payload instanceof OConcurrentCreateException)
// JUST ONE OConcurrentCreateException IS ENOUGH TO FAIL THE OPERATION BECAUSE RID ARE DIFFERENT
break;
} else if (++responsesForQuorum >= quorum) {
// QUORUM REACHED
setQuorumResponse(r);
return true;
}
}
}
}
}
} else {
if (receivedResponses >= quorum) {
int responsesForQuorum = 0;
for (Map.Entry<String, Object> response : responses.entrySet()) {
if (response.getValue() != NO_RESPONSE && nodesConcurInQuorum.contains(response.getKey())
&& ++responsesForQuorum >= quorum) {
// QUORUM REACHED
ODistributedResponse resp = (ODistributedResponse) response.getValue();
if (resp != null && !(resp.getPayload() instanceof Throwable))
setQuorumResponse(resp);
return true;
}
}
}
}
return false;
} | java | {
"resource": ""
} |
q173256 | ODistributedResponseManagerImpl.getReceivedResponses | test | protected List<ODistributedResponse> getReceivedResponses() {
final List<ODistributedResponse> parsed = new ArrayList<ODistributedResponse>();
for (Object r : responses.values())
if (r != NO_RESPONSE)
parsed.add((ODistributedResponse) r);
return parsed;
} | java | {
"resource": ""
} |
q173257 | OExecutionPlanCache.get | test | public static OExecutionPlan get(String statement, OCommandContext ctx, ODatabaseDocumentInternal db) {
if (db == null) {
throw new IllegalArgumentException("DB cannot be null");
}
if (statement == null) {
return null;
}
OExecutionPlanCache resource = db.getSharedContext().getExecutionPlanCache();
OExecutionPlan result = resource.getInternal(statement, ctx, db);
return result;
} | java | {
"resource": ""
} |
q173258 | OBinaryCondition.allowsIndexedFunctionExecutionOnTarget | test | public boolean allowsIndexedFunctionExecutionOnTarget(OFromClause target, OCommandContext context) {
return left.allowsIndexedFunctionExecutionOnTarget(target, context, operator, right.execute((OResult) null, context));
} | java | {
"resource": ""
} |
q173259 | OScriptManager.getLibrary | test | public String getLibrary(final ODatabase<?> db, final String iLanguage) {
if (db == null)
// NO DB = NO LIBRARY
return null;
final StringBuilder code = new StringBuilder();
final Set<String> functions = db.getMetadata().getFunctionLibrary().getFunctionNames();
for (String fName : functions) {
final OFunction f = db.getMetadata().getFunctionLibrary().getFunction(fName);
if (f.getLanguage() == null)
throw new OConfigurationException("Database function '" + fName + "' has no language");
if (f.getLanguage().equalsIgnoreCase(iLanguage)) {
final String def = getFunctionDefinition(f);
if (def != null) {
code.append(def);
code.append("\n");
}
}
}
return code.length() == 0 ? null : code.toString();
} | java | {
"resource": ""
} |
q173260 | OScriptManager.releaseDatabaseEngine | test | public void releaseDatabaseEngine(final String iLanguage, final String iDatabaseName,
final OPartitionedObjectPool.PoolEntry<ScriptEngine> poolEntry) {
final ODatabaseScriptManager dbManager = dbManagers.get(iDatabaseName);
// We check if there is still a valid pool because it could be removed by the function reload
if (dbManager != null) {
dbManager.releaseEngine(iLanguage, poolEntry);
}
} | java | {
"resource": ""
} |
q173261 | OClusterPositionMapV0.getNextPosition | test | long getNextPosition(final OAtomicOperation atomicOperation) throws IOException {
final long filledUpTo = getFilledUpTo(atomicOperation, fileId);
final long pageIndex = filledUpTo - 1;
final OCacheEntry cacheEntry = loadPageForRead(atomicOperation, fileId, pageIndex, false, 1);
try {
final OClusterPositionMapBucket bucket = new OClusterPositionMapBucket(cacheEntry, false);
final int bucketSize = bucket.getSize();
return pageIndex * OClusterPositionMapBucket.MAX_ENTRIES + bucketSize;
} finally {
releasePageFromRead(atomicOperation, cacheEntry);
}
} | java | {
"resource": ""
} |
q173262 | OSBTreeRidBag.updateSize | test | private int updateSize() {
int size = 0;
if (collectionPointer != null) {
final OSBTreeBonsai<OIdentifiable, Integer> tree = loadTree();
if (tree == null) {
throw new IllegalStateException("RidBag is not properly initialized, can not load tree implementation");
}
try {
size = tree.getRealBagSize(changes);
} finally {
releaseTree();
}
} else {
for (Change change : changes.values()) {
size += change.applyTo(0);
}
}
for (OModifiableInteger diff : newEntries.values()) {
size += diff.getValue();
}
this.size = size;
return size;
} | java | {
"resource": ""
} |
q173263 | OHashIndexBucket.getValue | test | public V getValue(int index) {
int entryPosition = getIntValue(POSITIONS_ARRAY_OFFSET + index * OIntegerSerializer.INT_SIZE);
// skip hash code
entryPosition += OLongSerializer.LONG_SIZE;
if (encryption == null) {
// skip key
entryPosition += getObjectSizeInDirectMemory(keySerializer, entryPosition);
} else {
final int encryptedLength = getIntValue(entryPosition);
entryPosition += encryptedLength + OIntegerSerializer.INT_SIZE;
}
return deserializeFromDirectMemory(valueSerializer, entryPosition);
} | java | {
"resource": ""
} |
q173264 | OOrderByOptimizer.canBeUsedByOrderByAfterFilter | test | boolean canBeUsedByOrderByAfterFilter(OIndex<?> index, List<String> equalsFilterFields,
List<OPair<String, String>> orderedFields) {
if (orderedFields.isEmpty())
return false;
if (!index.supportsOrderedIterations())
return false;
final OIndexDefinition definition = index.getDefinition();
final List<String> indexFields = definition.getFields();
int endIndex = Math.min(indexFields.size(), equalsFilterFields.size());
final String firstOrder = orderedFields.get(0).getValue();
//check that all the "equals" clauses are a prefix for the index
for (int i = 0; i < endIndex; i++) {
final String equalsFieldName = equalsFilterFields.get(i);
final String indexFieldName = indexFields.get(i);
if (!equalsFieldName.equals(indexFieldName))
return false;
}
endIndex = Math.min(indexFields.size(), orderedFields.size() + equalsFilterFields.size());
if (endIndex == equalsFilterFields.size()) {
//the index is used only for filtering
return false;
}
//check that after that prefix there all the Order By fields in the right order
for (int i = equalsFilterFields.size(); i < endIndex; i++) {
int fieldOrderInOrderByClause = i - equalsFilterFields.size();
final OPair<String, String> pair = orderedFields.get(fieldOrderInOrderByClause);
if (!firstOrder.equals(pair.getValue()))
return false;
final String orderFieldName = pair.getKey();
final String indexFieldName = indexFields.get(i);
if (!orderFieldName.equals(indexFieldName))
return false;
}
return true;
} | java | {
"resource": ""
} |
q173265 | OStringParser.indexOfOutsideStrings | test | public static int indexOfOutsideStrings(final String iText, final char iToFind, int iFrom, int iTo) {
if (iTo == -1)
iTo = iText.length() - 1;
if (iFrom == -1)
iFrom = iText.length() - 1;
char c;
char stringChar = ' ';
boolean escape = false;
final StringBuilder buffer = new StringBuilder(1024);
int i = iFrom;
while (true) {
c = iText.charAt(i);
if (!escape && c == '\\' && ((i + 1) < iText.length())) {
if (iText.charAt(i + 1) == 'u') {
i = readUnicode(iText, i + 2, buffer);
} else
escape = true;
} else {
if (c == '\'' || c == '"') {
// BEGIN/END STRING
if (stringChar == ' ') {
// BEGIN
stringChar = c;
} else {
// END
if (!escape && c == stringChar)
stringChar = ' ';
}
}
if (c == iToFind && stringChar == ' ')
return i;
if (escape)
escape = false;
}
if (iFrom < iTo) {
// MOVE FORWARD
if (++i > iTo)
break;
} else {
// MOVE BACKWARD
if (--i < iFrom)
break;
}
}
return -1;
} | java | {
"resource": ""
} |
q173266 | OStringParser.jumpWhiteSpaces | test | public static int jumpWhiteSpaces(final CharSequence iText, final int iCurrentPosition, final int iMaxPosition) {
return jump(iText, iCurrentPosition, iMaxPosition, COMMON_JUMP);
} | java | {
"resource": ""
} |
q173267 | OStringParser.jump | test | public static int jump(final CharSequence iText, int iCurrentPosition, final int iMaxPosition, final String iJumpChars) {
if (iCurrentPosition < 0)
return -1;
final int size = iMaxPosition > -1 ? Math.min(iMaxPosition, iText.length()) : iText.length();
final int jumpCharSize = iJumpChars.length();
boolean found = true;
char c;
for (; iCurrentPosition < size; ++iCurrentPosition) {
found = false;
c = iText.charAt(iCurrentPosition);
for (int jumpIndex = 0; jumpIndex < jumpCharSize; ++jumpIndex) {
if (iJumpChars.charAt(jumpIndex) == c) {
found = true;
break;
}
}
if (!found)
break;
}
return iCurrentPosition >= size ? -1 : iCurrentPosition;
} | java | {
"resource": ""
} |
q173268 | OQueryAbstract.setFetchPlan | test | public OQueryAbstract setFetchPlan(final String fetchPlan) {
OFetchHelper.checkFetchPlanValid(fetchPlan);
if (fetchPlan != null && fetchPlan.length() == 0)
this.fetchPlan = null;
else
this.fetchPlan = fetchPlan;
return this;
} | java | {
"resource": ""
} |
q173269 | OConflictResolverDatabaseRepairer.enqueueRepairRecord | test | @Override
public void enqueueRepairRecord(final ORecordId rid) {
if (!active)
return;
if (rid == null || !rid.isPersistent())
return;
if (rid.getClusterPosition() < -1)
// SKIP TRANSACTIONAL RIDS
return;
recordProcessed.incrementAndGet();
// ADD RECORD TO REPAIR
records.put(rid, Boolean.TRUE);
} | java | {
"resource": ""
} |
q173270 | OConflictResolverDatabaseRepairer.cancelRepairRecord | test | @Override
public void cancelRepairRecord(final ORecordId rid) {
if (!active)
return;
if (rid.getClusterPosition() < -1)
// SKIP TRANSACTIONAL RIDS
return;
// REMOVE THE RECORD TO REPAIR
if (records.remove(rid) != null)
// REMOVED
recordCanceled.incrementAndGet();
} | java | {
"resource": ""
} |
q173271 | OConflictResolverDatabaseRepairer.enqueueRepairCluster | test | @Override
public void enqueueRepairCluster(final int clusterId) {
if (!active)
return;
if (clusterId < -1)
// SKIP TRANSACTIONAL RIDS
return;
recordProcessed.incrementAndGet();
// ADD CLUSTER TO REPAIR
clusters.put(clusterId, Boolean.TRUE);
} | java | {
"resource": ""
} |
q173272 | OMatchExecutionPlanner.getDependencies | test | private Map<String, Set<String>> getDependencies(Pattern pattern) {
Map<String, Set<String>> result = new HashMap<String, Set<String>>();
for (PatternNode node : pattern.aliasToNode.values()) {
Set<String> currentDependencies = new HashSet<String>();
OWhereClause filter = aliasFilters.get(node.alias);
if (filter != null && filter.getBaseExpression() != null) {
List<String> involvedAliases = filter.getBaseExpression().getMatchPatternInvolvedAliases();
if (involvedAliases != null) {
currentDependencies.addAll(involvedAliases);
}
}
result.put(node.alias, currentDependencies);
}
return result;
} | java | {
"resource": ""
} |
q173273 | OEntityManager.createPojo | test | public synchronized Object createPojo(final String iClassName) throws OConfigurationException {
if (iClassName == null)
throw new IllegalArgumentException("Cannot create the object: class name is empty");
final Class<?> entityClass = classHandler.getEntityClass(iClassName);
try {
if (entityClass != null)
return createInstance(entityClass);
} catch (Exception e) {
throw OException.wrapException(new OConfigurationException("Error while creating new pojo of class '" + iClassName + "'"), e);
}
try {
// TRY TO INSTANTIATE THE CLASS DIRECTLY BY ITS NAME
return createInstance(Class.forName(iClassName));
} catch (Exception e) {
throw OException.wrapException(new OConfigurationException("The class '" + iClassName
+ "' was not found between the entity classes. Ensure registerEntityClasses(package) has been called first"), e);
}
} | java | {
"resource": ""
} |
q173274 | OEntityManager.registerEntityClasses | test | public synchronized void registerEntityClasses(final Collection<String> iClassNames, final ClassLoader iClassLoader) {
OLogManager.instance().debug(this, "Discovering entity classes for class names: %s", iClassNames);
try {
registerEntityClasses(OReflectionHelper.getClassesFor(iClassNames, iClassLoader));
} catch (ClassNotFoundException e) {
throw OException.wrapException(new ODatabaseException("Entity class cannot be found"), e);
}
} | java | {
"resource": ""
} |
q173275 | OEntityManager.registerEntityClasses | test | public synchronized void registerEntityClasses(Class<?> aClass, boolean recursive) {
if (recursive) {
classHandler.registerEntityClass(aClass);
Field[] declaredFields = aClass.getDeclaredFields();
for (Field declaredField : declaredFields) {
Class<?> declaredFieldType = declaredField.getType();
if (!classHandler.containsEntityClass(declaredFieldType)) {
registerEntityClasses(declaredFieldType, recursive);
}
}
} else {
classHandler.registerEntityClass(aClass);
}
} | java | {
"resource": ""
} |
q173276 | OEntityManager.setClassHandler | test | public synchronized void setClassHandler(final OEntityManagerClassHandler iClassHandler) {
Iterator<Entry<String, Class<?>>> iterator = classHandler.getClassesEntrySet().iterator();
while (iterator.hasNext()){
Entry<String, Class<?>> entry = iterator.next();
boolean forceSchemaReload = !iterator.hasNext();
iClassHandler.registerEntityClass(entry.getValue(), forceSchemaReload);
}
this.classHandler = iClassHandler;
} | java | {
"resource": ""
} |
q173277 | ODatabasePoolBase.acquire | test | public DB acquire(final String iName, final String iUserName, final String iUserPassword) {
setup();
return dbPool.acquire(iName, iUserName, iUserPassword);
} | java | {
"resource": ""
} |
q173278 | ODatabasePoolBase.getAvailableConnections | test | public int getAvailableConnections(final String name, final String userName) {
setup();
return dbPool.getAvailableConnections(name, userName);
} | java | {
"resource": ""
} |
q173279 | ODatabasePoolBase.acquire | test | public DB acquire(final String iName, final String iUserName, final String iUserPassword,
final Map<String, Object> iOptionalParams) {
setup();
return dbPool.acquire(iName, iUserName, iUserPassword, iOptionalParams);
} | java | {
"resource": ""
} |
q173280 | OCommandExecutorSQLHASyncCluster.execute | test | public Object execute(final Map<Object, Object> iArgs) {
final ODatabaseDocumentInternal database = getDatabase();
database.checkSecurity(ORule.ResourceGeneric.CLUSTER, "sync", ORole.PERMISSION_UPDATE);
if (!(database instanceof ODatabaseDocumentDistributed)) {
throw new OCommandExecutionException("OrientDB is not started in distributed mode");
}
final OHazelcastPlugin dManager = (OHazelcastPlugin) ((ODatabaseDocumentDistributed) database).getDistributedManager();
if (dManager == null || !dManager.isEnabled())
throw new OCommandExecutionException("OrientDB is not started in distributed mode");
final String databaseName = database.getName();
try {
if (this.parsedStatement.modeFull) {
return replaceCluster(dManager, database, dManager.getServerInstance(), databaseName, this.parsedStatement.clusterName.getStringValue());
}
// else {
// int merged = 0;
// return String.format("Merged %d records", merged);
// }
} catch (Exception e) {
throw OException.wrapException(new OCommandExecutionException("Cannot execute synchronization of cluster"), e);
}
return "Mode not supported";
} | java | {
"resource": ""
} |
q173281 | OClassLoaderHelper.lookupProviderWithOrientClassLoader | test | public static synchronized <T extends Object> Iterator<T> lookupProviderWithOrientClassLoader(Class<T> clazz) {
return lookupProviderWithOrientClassLoader(clazz, OClassLoaderHelper.class.getClassLoader());
} | java | {
"resource": ""
} |
q173282 | OMemory.checkCacheMemoryConfiguration | test | public static void checkCacheMemoryConfiguration() {
final long maxHeapSize = Runtime.getRuntime().maxMemory();
final long maxCacheSize = getMaxCacheMemorySize();
final ONative.MemoryLimitResult physicalMemory = ONative.instance().getMemoryLimit(false);
if (maxHeapSize != Long.MAX_VALUE && physicalMemory != null && maxHeapSize + maxCacheSize > physicalMemory.memoryLimit)
OLogManager.instance().warnNoDb(OMemory.class,
"The sum of the configured JVM maximum heap size (" + maxHeapSize + " bytes) " + "and the OrientDB maximum cache size ("
+ maxCacheSize + " bytes) is larger than the available physical memory size " + "(" + physicalMemory
+ " bytes). That may cause out of memory errors, please tune the configuration up. Use the "
+ "-Xmx JVM option to lower the JVM maximum heap memory size or storage.diskCache.bufferSize OrientDB option to "
+ "lower memory requirements of the cache.");
} | java | {
"resource": ""
} |
q173283 | OGraphSONUtility.vertexFromJson | test | public static Vertex vertexFromJson(final JSONObject json, final ElementFactory factory, final GraphSONMode mode,
final Set<String> propertyKeys) throws IOException {
final OGraphSONUtility graphson = new OGraphSONUtility(mode, factory, propertyKeys, null);
return graphson.vertexFromJson(json);
} | java | {
"resource": ""
} |
q173284 | OGraphSONUtility.edgeFromJson | test | public static Edge edgeFromJson(final JSONObject json, final Vertex out, final Vertex in, final ElementFactory factory,
final GraphSONMode mode, final Set<String> propertyKeys) throws IOException {
final OGraphSONUtility graphson = new OGraphSONUtility(mode, factory, null, propertyKeys);
return graphson.edgeFromJson(json, out, in);
} | java | {
"resource": ""
} |
q173285 | OGraphSONUtility.jsonFromElement | test | public static JSONObject jsonFromElement(final Element element, final Set<String> propertyKeys, final GraphSONMode mode)
throws JSONException {
final OGraphSONUtility graphson = element instanceof Edge ? new OGraphSONUtility(mode, null, null, propertyKeys)
: new OGraphSONUtility(mode, null, propertyKeys, null);
return graphson.jsonFromElement(element);
} | java | {
"resource": ""
} |
q173286 | OGraphSONUtility.objectNodeFromElement | test | public static ObjectNode objectNodeFromElement(final Element element, final Set<String> propertyKeys, final GraphSONMode mode) {
final OGraphSONUtility graphson = element instanceof Edge ? new OGraphSONUtility(mode, null, null, propertyKeys)
: new OGraphSONUtility(mode, null, propertyKeys, null);
return graphson.objectNodeFromElement(element);
} | java | {
"resource": ""
} |
q173287 | OETLHandler.executeImport | test | public void executeImport(ODocument cfg, OServer server) {
OETLJob job = new OETLJob(cfg, server, new OETLListener() {
@Override
public void onEnd(OETLJob etlJob) {
currentJob = null;
}
});
job.validate();
currentJob = job;
pool.execute(job);
} | java | {
"resource": ""
} |
q173288 | OETLHandler.status | test | public ODocument status() {
ODocument status = new ODocument();
Collection<ODocument> jobs = new ArrayList<ODocument>();
if (currentJob != null) {
jobs.add(currentJob.status());
}
status.field("jobs", jobs);
return status;
} | java | {
"resource": ""
} |
q173289 | ODatabaseDocumentDistributed.getActiveDataCenterMap | test | public Map<String, Set<String>> getActiveDataCenterMap() {
Map<String, Set<String>> result = new HashMap<>();
ODistributedConfiguration cfg = getDistributedConfiguration();
Set<String> servers = cfg.getRegisteredServers();
for (String server : servers) {
String dc = cfg.getDataCenterOfServer(server);
Set<String> dcConfig = result.get(dc);
if (dcConfig == null) {
dcConfig = new HashSet<>();
result.put(dc, dcConfig);
}
dcConfig.add(server);
}
return result;
} | java | {
"resource": ""
} |
q173290 | OSymmetricKey.separateAlgorithm | test | protected static String separateAlgorithm(final String cipherTransform) {
String[] array = cipherTransform.split("/");
if (array.length > 1)
return array[0];
return null;
} | java | {
"resource": ""
} |
q173291 | OSymmetricKey.fromConfig | test | public static OSymmetricKey fromConfig(final OSymmetricKeyConfig keyConfig) {
if (keyConfig.usesKeyString()) {
return fromString(keyConfig.getKeyAlgorithm(), keyConfig.getKeyString());
} else if (keyConfig.usesKeyFile()) {
return fromFile(keyConfig.getKeyAlgorithm(), keyConfig.getKeyFile());
} else if (keyConfig.usesKeystore()) {
return fromKeystore(keyConfig.getKeystoreFile(), keyConfig.getKeystorePassword(), keyConfig.getKeystoreKeyAlias(),
keyConfig.getKeystoreKeyPassword());
} else {
throw new OSecurityException("OSymmetricKey(OSymmetricKeyConfig) Invalid configuration");
}
} | java | {
"resource": ""
} |
q173292 | OSymmetricKey.fromFile | test | public static OSymmetricKey fromFile(final String algorithm, final String path) {
String base64Key = null;
try {
java.io.FileInputStream fis = null;
try {
fis = new java.io.FileInputStream(OSystemVariableResolver.resolveSystemVariables(path));
return fromStream(algorithm, fis);
} finally {
if (fis != null)
fis.close();
}
} catch (Exception ex) {
throw OException.wrapException(new OSecurityException("OSymmetricKey.fromFile() Exception: " + ex.getMessage()), ex);
}
} | java | {
"resource": ""
} |
q173293 | OSymmetricKey.fromStream | test | public static OSymmetricKey fromStream(final String algorithm, final InputStream is) {
String base64Key = null;
try {
base64Key = OIOUtils.readStreamAsString(is);
} catch (Exception ex) {
throw OException.wrapException(new OSecurityException("OSymmetricKey.fromStream() Exception: " + ex.getMessage()), ex);
}
return new OSymmetricKey(algorithm, base64Key);
} | java | {
"resource": ""
} |
q173294 | OSymmetricKey.encrypt | test | public String encrypt(final String transform, final byte[] bytes) {
String encodedJSON = null;
if (secretKey == null)
throw new OSecurityException("OSymmetricKey.encrypt() SecretKey is null");
if (transform == null)
throw new OSecurityException("OSymmetricKey.encrypt() Cannot determine cipher transformation");
try {
// Throws NoSuchAlgorithmException and NoSuchPaddingException.
Cipher cipher = Cipher.getInstance(transform);
// If the cipher transformation requires an initialization vector then init() will create a random one.
// (Use cipher.getIV() to retrieve the IV, if it exists.)
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
// If the cipher does not use an IV, this will be null.
byte[] initVector = cipher.getIV();
// byte[] initVector = encCipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();
byte[] encrypted = cipher.doFinal(bytes);
encodedJSON = encodeJSON(encrypted, initVector);
} catch (Exception ex) {
throw OException.wrapException(new OSecurityException("OSymmetricKey.encrypt() Exception: " + ex.getMessage()), ex);
}
return encodedJSON;
} | java | {
"resource": ""
} |
q173295 | OSymmetricKey.saveToStream | test | public void saveToStream(final OutputStream os) {
if (os == null)
throw new OSecurityException("OSymmetricKey.saveToStream() OutputStream is null");
try {
final OutputStreamWriter osw = new OutputStreamWriter(os);
try {
final BufferedWriter writer = new BufferedWriter(osw);
try {
writer.write(getBase64Key());
} finally {
writer.close();
}
} finally {
os.close();
}
} catch (Exception ex) {
throw OException.wrapException(new OSecurityException("OSymmetricKey.saveToStream() Exception: " + ex.getMessage()), ex);
}
} | java | {
"resource": ""
} |
q173296 | OSymmetricKey.saveToKeystore | test | public void saveToKeystore(final OutputStream os, final String ksPasswd, final String keyAlias, final String keyPasswd) {
if (os == null)
throw new OSecurityException("OSymmetricKey.saveToKeystore() OutputStream is null");
if (ksPasswd == null)
throw new OSecurityException("OSymmetricKey.saveToKeystore() Keystore Password is required");
if (keyAlias == null)
throw new OSecurityException("OSymmetricKey.saveToKeystore() Key Alias is required");
if (keyPasswd == null)
throw new OSecurityException("OSymmetricKey.saveToKeystore() Key Password is required");
try {
KeyStore ks = KeyStore.getInstance("JCEKS");
char[] ksPasswdCA = ksPasswd.toCharArray();
char[] keyPasswdCA = keyPasswd.toCharArray();
// Create a new KeyStore by passing null.
ks.load(null, ksPasswdCA);
KeyStore.ProtectionParameter protParam = new KeyStore.PasswordProtection(keyPasswdCA);
KeyStore.SecretKeyEntry skEntry = new KeyStore.SecretKeyEntry(secretKey);
ks.setEntry(keyAlias, skEntry, protParam);
// Save the KeyStore
ks.store(os, ksPasswdCA);
} catch (Exception ex) {
throw OException.wrapException(new OSecurityException("OSymmetricKey.saveToKeystore() Exception: " + ex.getMessage()), ex);
}
} | java | {
"resource": ""
} |
q173297 | OBasicCommandContext.setChild | test | public OCommandContext setChild(final OCommandContext iContext) {
if (iContext == null) {
if (child != null) {
// REMOVE IT
child.setParent(null);
child = null;
}
} else if (child != iContext) {
// ADD IT
child = iContext;
iContext.setParent(this);
}
return this;
} | java | {
"resource": ""
} |
q173298 | OBasicCommandContext.addToUniqueResult | test | public synchronized boolean addToUniqueResult(Object o) {
Object toAdd = o;
if (o instanceof ODocument && ((ODocument) o).getIdentity().isNew()) {
toAdd = new ODocumentEqualityWrapper((ODocument) o);
}
return this.uniqueResult.add(toAdd);
} | java | {
"resource": ""
} |
q173299 | ORecordSerializerJSON.getValueAsObjectOrMap | test | private Object getValueAsObjectOrMap(ODocument iRecord, String iFieldValue, OType iType, OType iLinkedType,
Map<String, Character> iFieldTypes, boolean iNoMap, String iOptions) {
final String[] fields = OStringParser.getWords(iFieldValue.substring(1, iFieldValue.length() - 1), ":,", true);
if (fields == null || fields.length == 0)
if (iNoMap) {
ODocument res = new ODocument();
ODocumentInternal.addOwner(res, iRecord);
return res;
} else
return new HashMap<String, Object>();
if (iNoMap || hasTypeField(fields)) {
return getValueAsRecord(iRecord, iFieldValue, iType, iOptions, fields);
} else {
return getValueAsMap(iRecord, iFieldValue, iLinkedType, iFieldTypes, false, iOptions, fields);
}
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.