Refine search
/** * Return the type by ID. * * @param iId The id to search * * @return The type if any, otherwise null */ public static OType getById(final byte iId) { if (iId >= 0 && iId < TYPES_BY_ID.length) return TYPES_BY_ID[iId]; OLogManager.instance().warn(OType.class, "Invalid type index: " + iId, (Object[]) null); return null; }
public Future<?> submit(final Runnable runnable) { engineLock.readLock().lock(); try { if (active) return workers.submit(runnable); else { OLogManager.instance().warn(this, "OrientDB engine is down. Task will not be submitted."); throw new IllegalStateException("OrientDB engine is down. Task will not be submitted."); } } finally { engineLock.readLock().unlock(); } }
public <V> Future<V> submit(final Callable<V> callable) { engineLock.readLock().lock(); try { if (active) return workers.submit(callable); else { OLogManager.instance().warn(this, "OrientDB engine is down. Task will not be submitted."); throw new IllegalStateException("OrientDB engine is down. Task will not be submitted."); } } finally { engineLock.readLock().unlock(); } }
public void scheduleTask(final TimerTask task, final long delay, final long period) { engineLock.readLock().lock(); try { if (active) { if (period > 0) timer.schedule(task, delay, period); else timer.schedule(task, delay); } else OLogManager.instance().warn(this, "OrientDB engine is down. Task will not be scheduled."); } finally { engineLock.readLock().unlock(); } }
/** * Prepares the path for a file creation or replacement. If the file pointed by the path already exists, it will be deleted, a * warning will be emitted to the log in this case. All absent directories along the path will be created. * * @param path the file path. * @param requester the requester of an operation being performed to produce user-friendly log messages. * @param operation the description of an operation being performed to produce user-friendly log messages. Use descriptions like * "exporting", "backing up", etc. */ public static void prepareForFileCreationOrReplacement(Path path, Object requester, String operation) throws IOException { if (Files.deleteIfExists(path)) OLogManager.instance().warn(requester, "'%s' deleted while %s", path, operation); final Path parent = path.getParent(); if (parent != null) Files.createDirectories(parent); }
public void scheduleTask(final TimerTask task, final Date firstTime, final long period) { engineLock.readLock().lock(); try { if (active) if (period > 0) timer.schedule(task, firstTime, period); else timer.schedule(task, firstTime); else OLogManager.instance().warn(this, "OrientDB engine is down. Task will not be scheduled."); } finally { engineLock.readLock().unlock(); } }
public OException newException(String message, Throwable parent) { final String fullMessage = String.format("%1$06d_%2$06d - %3$s", category.code, code, message); try { return OException.wrapException(exceptionClass.getConstructor(String.class).newInstance(fullMessage), parent); } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { OLogManager.instance().warn(this, "Cannot instantiate exception " + exceptionClass); } return null; }
private void lockFile() throws IOException { try { fileLock = channel.tryLock(); } catch (OverlappingFileLockException e) { OLogManager.instance().warn(this, "File is already locked by other thread", e); } if (fileLock == null) throw new OStorageException("Database is locked by another process, please shutdown process and try again"); }
public static synchronized <T extends Object> Iterator<T> lookupProviderWithOrientClassLoader(Class<T> clazz, ClassLoader orientClassLoader) { final ClassLoader origClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(orientClassLoader); try { return ServiceLoader.load(clazz).iterator(); } catch (Exception e) { OLogManager.instance().warn(null, "Cannot lookup in service registry", e); throw OException.wrapException(new OConfigurationException("Cannot lookup in service registry"), e); } finally { Thread.currentThread().setContextClassLoader(origClassLoader); } }
public void pop(final OIdentifiable currentRecord) { if (currentRecord != null) { final ORID rid = currentRecord.getIdentity(); if (!history.remove(rid)) OLogManager.instance().warn(this, "Element '" + rid + "' not found in traverse history"); } try { memory.dropFrame(); } catch (NoSuchElementException e) { throw new IllegalStateException("Traverse stack is empty", e); } }
@Override public String[] getFieldNamesRoot(ODocument reference, byte[] iSource) { if (iSource == null || iSource.length == 0) return new String[0]; final BytesContainer container = new BytesContainer(iSource); try { return getFieldNames(reference, container); } catch (RuntimeException e) { OLogManager.instance().warn(this, "Error deserializing record to get field-names, send this data for debugging: %s ", Base64.getEncoder().encodeToString(iSource)); throw e; } }
public synchronized void queryStarted(String id, OResultSet rs) { if (this.activeQueries.size() > 1 && this.activeQueries.size() % 10 == 0) { StringBuilder msg = new StringBuilder(); msg.append("This database instance has "); msg.append(activeQueries.size()); msg.append(" open command/query result sets, please make sure you close them with OResultSet.close()"); OLogManager.instance().warn(this, msg.toString(), null); if (OLogManager.instance().isDebugEnabled()) { activeQueries.values().stream().map(pendingQuery -> pendingQuery.getExecutionPlan()).filter(plan -> plan != null) .forEach(plan -> OLogManager.instance().debug(this, plan.toString())); } } this.activeQueries.put(id, rs); }
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); }
public OSecurityRole checkIfAllowed(final ORule.ResourceGeneric resourceGeneric, final String resourceSpecific, final int iOperation) { for (OImmutableRole r : roles) { if (r == null) OLogManager.instance().warn(this, "User '%s' has a null role, ignoring it. Consider fixing this user's roles before continuing", getName()); else if (r.allow(resourceGeneric, resourceSpecific, iOperation)) return r; } return null; }
public boolean isRuleDefined(final ORule.ResourceGeneric resourceGeneric, String resourceSpecific) { for (OImmutableRole r : roles) if (r == null) OLogManager.instance().warn(this, "User '%s' has a null role, ignoring it. Consider fixing this user's roles before continuing", getName()); else if (r.hasRule(resourceGeneric, resourceSpecific)) return true; return false; }
@Override public String[] getFieldNamesRoot(ODocument reference, byte[] iSource) { if (iSource == null || iSource.length == 0) return new String[0]; final BytesContainer container = new BytesContainer(iSource).skip(1); try { return serializerByVersion[iSource[0]].getFieldNames(reference, container, false); } catch (RuntimeException e) { OLogManager.instance().warn(this, "Error deserializing record to get field-names, send this data for debugging: %s ", Base64.getEncoder().encodeToString(iSource)); throw e; } }
/** * Checks if a rule was defined for the user. * * @return True is a rule is defined, otherwise false */ public boolean isRuleDefined(final ORule.ResourceGeneric resourceGeneric, String resourceSpecific) { for (ORole r : roles) if (r == null) OLogManager.instance() .warn(this, "User '%s' has a null role, bypass it. Consider to fix this user roles before to continue", getName()); else if (r.hasRule(resourceGeneric, resourceSpecific)) return true; return false; }