Search in sources :

Example 1 with PerformanceProfiler

use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.

the class EntityManagerSetupImpl method updateProfiler.

/**
 * Check for the PROFILER persistence or system property and set the Session's profiler.
 * This can also set the QueryMonitor.
 */
protected void updateProfiler(Map persistenceProperties, ClassLoader loader) {
    // This must use config property as the profiler is not in the PropertiesHandler and requires
    // supporting generic profiler classes.
    String newProfilerClassName = getConfigPropertyAsStringLogDebug(PersistenceUnitProperties.PROFILER, persistenceProperties, session);
    if (newProfilerClassName == null) {
        ServerPlatformBase plaftorm = ((ServerPlatformBase) session.getServerPlatform());
        if (plaftorm != null) {
            plaftorm.configureProfiler(session);
        }
    } else {
        if (newProfilerClassName.equals(ProfilerType.NoProfiler)) {
            session.setProfiler(null);
            return;
        }
        if (newProfilerClassName.equals(ProfilerType.QueryMonitor)) {
            session.setProfiler(null);
            QueryMonitor.shouldMonitor = true;
            return;
        }
        if (newProfilerClassName.equals(ProfilerType.PerformanceProfiler)) {
            session.setProfiler(new PerformanceProfiler());
            return;
        }
        if (newProfilerClassName.equals(ProfilerType.PerformanceMonitor)) {
            session.setProfiler(new PerformanceMonitor());
            return;
        }
        if (newProfilerClassName.equals(ProfilerType.DMSProfiler)) {
            newProfilerClassName = ProfilerType.DMSProfilerClassName;
        }
        String originalProfilerClassNamer = null;
        if (session.getProfiler() != null) {
            originalProfilerClassNamer = session.getProfiler().getClass().getName();
            if (originalProfilerClassNamer.equals(newProfilerClassName)) {
                return;
            }
        }
        // New profiler - create the new instance and set it.
        try {
            Class<? extends SessionProfiler> newProfilerClass = findClassForProperty(newProfilerClassName, PersistenceUnitProperties.PROFILER, loader);
            SessionProfiler sessionProfiler = (SessionProfiler) buildObjectForClass(newProfilerClass, SessionProfiler.class);
            if (sessionProfiler != null) {
                session.setProfiler(sessionProfiler);
            } else {
                session.handleException(ValidationException.invalidProfilerClass(newProfilerClassName));
            }
        } catch (IllegalAccessException e) {
            session.handleException(ValidationException.cannotInstantiateProfilerClass(newProfilerClassName, e));
        } catch (PrivilegedActionException e) {
            session.handleException(ValidationException.cannotInstantiateProfilerClass(newProfilerClassName, e));
        } catch (InstantiationException e) {
            session.handleException(ValidationException.cannotInstantiateProfilerClass(newProfilerClassName, e));
        }
    }
}
Also used : PerformanceProfiler(org.eclipse.persistence.tools.profiler.PerformanceProfiler) PrivilegedActionException(java.security.PrivilegedActionException) SessionProfiler(org.eclipse.persistence.sessions.SessionProfiler) PerformanceMonitor(org.eclipse.persistence.tools.profiler.PerformanceMonitor) EntityManagerFactoryProvider.getConfigPropertyAsString(org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.getConfigPropertyAsString) ServerPlatformBase(org.eclipse.persistence.platform.server.ServerPlatformBase)

Example 2 with PerformanceProfiler

use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.

the class SessionsFactory method processSessionConfig.

/**
 * INTERNAL:
 * Process the common elements from a SessionConfig.
 */
protected void processSessionConfig(SessionConfig sessionConfig, AbstractSession session) {
    // Name
    session.setName(sessionConfig.getName().trim());
    // Session Event Manager
    processSessionEventManagerConfig(sessionConfig.getSessionEventManagerConfig(), session);
    // server platform
    ((DatabaseSessionImpl) session).setServerPlatform(buildServerPlatformConfig(sessionConfig.getServerPlatformConfig(), (DatabaseSessionImpl) session));
    // Session Log - BUG# 3442865, don't set the log if it is null
    SessionLog log = buildSessionLog(sessionConfig.getLogConfig(), session);
    if (log != null) {
        session.setSessionLog(log);
    }
    // Remote command manager
    buildRemoteCommandManagerConfig(sessionConfig.getRemoteCommandManagerConfig(), session);
    // Profiler - XML Schema default is null
    if (sessionConfig.getProfiler() != null) {
        if (sessionConfig.getProfiler().equals("eclipselink")) {
            session.setProfiler(new PerformanceProfiler());
        }
    }
    // Exception handler
    String exceptionHandlerClassName = sessionConfig.getExceptionHandlerClass();
    if (exceptionHandlerClassName != null) {
        try {
            @SuppressWarnings({ "unchecked" }) Class<ExceptionHandler> exceptionHandlerClass = (Class<ExceptionHandler>) m_classLoader.loadClass(exceptionHandlerClassName);
            if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()) {
                session.setExceptionHandler(AccessController.doPrivileged(new PrivilegedNewInstanceFromClass<>(exceptionHandlerClass)));
            } else {
                session.setExceptionHandler(PrivilegedAccessHelper.newInstanceFromClass(exceptionHandlerClass));
            }
        } catch (Exception e) {
            throw SessionLoaderException.failedToLoadTag("exception-handler-class", exceptionHandlerClassName, e);
        }
    }
// Session customizer will be processed in the buildSessions method.
// Ensures it is run last.
}
Also used : ExceptionHandler(org.eclipse.persistence.exceptions.ExceptionHandler) DefaultSessionLog(org.eclipse.persistence.logging.DefaultSessionLog) SessionLog(org.eclipse.persistence.logging.SessionLog) PerformanceProfiler(org.eclipse.persistence.tools.profiler.PerformanceProfiler) DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl) PrivilegedNewInstanceFromClass(org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass) PrivilegedNewInstanceFromClass(org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass) ValidationException(org.eclipse.persistence.exceptions.ValidationException) PrivilegedActionException(java.security.PrivilegedActionException) SessionLoaderException(org.eclipse.persistence.exceptions.SessionLoaderException)

Example 3 with PerformanceProfiler

use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.

the class RuntimeServices method printProfileSummaryByQuery.

/**
 *        This method assumes EclipseLink Profiling (as opposed to Java profiling).
 *        This will log at the INFO level a summary of all elements in the profile, categorized
 *        by Query.
 */
public void printProfileSummaryByQuery() {
    if (!this.getUsesEclipseLinkProfiling()) {
        return;
    }
    PerformanceProfiler performanceProfiler = (PerformanceProfiler) getSession().getProfiler();
    getSession().getSessionLog().info(trimProfileString(performanceProfiler.buildProfileSummaryByQuery().toString()));
}
Also used : PerformanceProfiler(org.eclipse.persistence.tools.profiler.PerformanceProfiler)

Example 4 with PerformanceProfiler

use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.

the class RuntimeServices method printProfileSummaryByClass.

/**
 *        This method assumes EclipseLink Profiling (as opposed to Java profiling).
 *        This will log at the INFO level a summary of all elements in the profile, categorized
 *        by Class.
 */
public void printProfileSummaryByClass() {
    if (!this.getUsesEclipseLinkProfiling()) {
        return;
    }
    PerformanceProfiler performanceProfiler = (PerformanceProfiler) getSession().getProfiler();
    // trim the { and } from the beginning at end, because they cause problems for the logger
    getSession().getSessionLog().info(trimProfileString(performanceProfiler.buildProfileSummaryByClass().toString()));
}
Also used : PerformanceProfiler(org.eclipse.persistence.tools.profiler.PerformanceProfiler)

Example 5 with PerformanceProfiler

use of org.eclipse.persistence.tools.profiler.PerformanceProfiler in project eclipselink by eclipse-ee4j.

the class RuntimeServices method printProfileSummary.

/**
 *        This method assumes EclipseLink Profiling (as opposed to Java profiling).
 *        This will log at the INFO level a summary of all elements in the profile.
 */
public void printProfileSummary() {
    if (!this.getUsesEclipseLinkProfiling()) {
        return;
    }
    PerformanceProfiler performanceProfiler = (PerformanceProfiler) getSession().getProfiler();
    getSession().getSessionLog().info(performanceProfiler.buildProfileSummary().toString());
}
Also used : PerformanceProfiler(org.eclipse.persistence.tools.profiler.PerformanceProfiler)

Aggregations

PerformanceProfiler (org.eclipse.persistence.tools.profiler.PerformanceProfiler)5 PrivilegedActionException (java.security.PrivilegedActionException)2 ExceptionHandler (org.eclipse.persistence.exceptions.ExceptionHandler)1 SessionLoaderException (org.eclipse.persistence.exceptions.SessionLoaderException)1 ValidationException (org.eclipse.persistence.exceptions.ValidationException)1 EntityManagerFactoryProvider.getConfigPropertyAsString (org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.getConfigPropertyAsString)1 PrivilegedNewInstanceFromClass (org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass)1 DatabaseSessionImpl (org.eclipse.persistence.internal.sessions.DatabaseSessionImpl)1 DefaultSessionLog (org.eclipse.persistence.logging.DefaultSessionLog)1 SessionLog (org.eclipse.persistence.logging.SessionLog)1 ServerPlatformBase (org.eclipse.persistence.platform.server.ServerPlatformBase)1 SessionProfiler (org.eclipse.persistence.sessions.SessionProfiler)1 PerformanceMonitor (org.eclipse.persistence.tools.profiler.PerformanceMonitor)1