mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-22 15:10:02 +00:00
Use AppLog and System.Logger for logging rather than slf4j-api
The avaje-applog-slf4j dependency means this is still using slf4j-api for implementation. Remove that dependency and service load the desired implementation.
This commit is contained in:
1 parent
d145e6494d
commit
a23f241fff
108 files changed
+665
-755
No files matched your search
+18
-14
@@ -13,15 +13,17 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!--
|
|
||||||
Projects are expected to explicit depend on version
|
|
||||||
of slf4j that they want to use
|
|
||||||
-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>avaje-applog</artifactId>
|
||||||
<version>1.7.36</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- exclude avaje-applog-slf4j to direct logging to something else -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.avaje</groupId>
|
||||||
|
<artifactId>avaje-applog-slf4j</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -30,12 +32,6 @@
|
|||||||
<version>2.2</version>
|
<version>2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.avaje</groupId>
|
|
||||||
<artifactId>avaje-applog-slf4j</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Class retention Nonnull and Nullable annotations
|
Class retention Nonnull and Nullable annotations
|
||||||
to assist with IDE auto-completion with Ebean API
|
to assist with IDE auto-completion with Ebean API
|
||||||
@@ -70,6 +66,14 @@
|
|||||||
<version>${ebean-datasource.version}</version>
|
<version>${ebean-datasource.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Support MdcBackgroundExecutorWrapper -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.7.36</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- Jackson core used internally by Ebean -->
|
<!-- Jackson core used internally by Ebean -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package io.ebean;
|
|||||||
|
|
||||||
import io.ebean.config.BeanNotEnhancedException;
|
import io.ebean.config.BeanNotEnhancedException;
|
||||||
import io.ebean.datasource.DataSourceConfigurationException;
|
import io.ebean.datasource.DataSourceConfigurationException;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@@ -15,7 +14,8 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
final class DbContext {
|
final class DbContext {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean");
|
private static final System.Logger log = EbeanVersion.log;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
EbeanVersion.getVersion();
|
EbeanVersion.getVersion();
|
||||||
}
|
}
|
||||||
@@ -52,7 +52,7 @@ final class DbContext {
|
|||||||
throw new DataSourceConfigurationException(msg, e);
|
throw new DataSourceConfigurationException(msg, e);
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Error trying to create the default Database", e);
|
log.log(Level.ERROR, "Error trying to create the default Database", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
package io.ebean;
|
package io.ebean;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import io.avaje.applog.AppLog;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.LineNumberReader;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13,7 +16,7 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
public final class EbeanVersion {
|
public final class EbeanVersion {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean");
|
public static final System.Logger log = AppLog.getLogger("io.ebean");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maintain the minimum ebean-agent version manually based on required ebean-agent bug fixes.
|
* Maintain the minimum ebean-agent version manually based on required ebean-agent bug fixes.
|
||||||
@@ -21,6 +24,7 @@ public final class EbeanVersion {
|
|||||||
private static final int MIN_AGENT_MAJOR_VERSION = 12;
|
private static final int MIN_AGENT_MAJOR_VERSION = 12;
|
||||||
private static final int MIN_AGENT_MINOR_VERSION = 12;
|
private static final int MIN_AGENT_MINOR_VERSION = 12;
|
||||||
private static String version = "unknown";
|
private static String version = "unknown";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
readVersion();
|
readVersion();
|
||||||
checkAgentVersion();
|
checkAgentVersion();
|
||||||
@@ -32,12 +36,12 @@ public final class EbeanVersion {
|
|||||||
if (in != null) {
|
if (in != null) {
|
||||||
try (LineNumberReader reader = new LineNumberReader(new InputStreamReader(in))) {
|
try (LineNumberReader reader = new LineNumberReader(new InputStreamReader(in))) {
|
||||||
version = reader.readLine();
|
version = reader.readLine();
|
||||||
log.info("ebean version: {}", version);
|
log.log(Level.INFO, "ebean version: {0}", version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warn("Could not determine ebean version: {}", e.getMessage());
|
log.log(Level.WARNING, "Could not determine ebean version: {0}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,13 +53,13 @@ public final class EbeanVersion {
|
|||||||
String agentVersion = readVersion(in);
|
String agentVersion = readVersion(in);
|
||||||
if (agentVersion != null) {
|
if (agentVersion != null) {
|
||||||
if (checkMinAgentVersion(agentVersion)) {
|
if (checkMinAgentVersion(agentVersion)) {
|
||||||
log.error("Expected minimum ebean-agent version {}.{}.0 but we have {}, please update the ebean-agent", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, agentVersion);
|
log.log(Level.ERROR, "Expected minimum ebean-agent version {0}.{1}.0 but we have {2}, please update the ebean-agent", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, agentVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warn("Could not check minimum ebean-agent version {}.{}.0 required due to - {}", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, e.getMessage());
|
log.log(Level.WARNING, "Could not check minimum ebean-agent version {0}.{1}.0 required due to - {2}", MIN_AGENT_MAJOR_VERSION, MIN_AGENT_MINOR_VERSION, e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,25 @@
|
|||||||
package io.ebean.config.dbplatform;
|
package io.ebean.config.dbplatform;
|
||||||
|
|
||||||
import io.ebean.BackgroundExecutor;
|
import io.ebean.BackgroundExecutor;
|
||||||
|
import io.ebean.EbeanVersion;
|
||||||
import io.ebean.Query;
|
import io.ebean.Query;
|
||||||
import io.ebean.annotation.PartitionMode;
|
|
||||||
import io.ebean.annotation.PersistBatch;
|
import io.ebean.annotation.PersistBatch;
|
||||||
import io.ebean.annotation.Platform;
|
import io.ebean.annotation.Platform;
|
||||||
import io.ebean.config.CustomDbTypeMapping;
|
import io.ebean.config.CustomDbTypeMapping;
|
||||||
import io.ebean.config.PlatformConfig;
|
import io.ebean.config.PlatformConfig;
|
||||||
import io.ebean.util.JdbcClose;
|
import io.ebean.util.JdbcClose;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.sql.Connection;
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.DatabaseMetaData;
|
import java.sql.*;
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.sql.Types;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database platform specific settings.
|
* Database platform specific settings.
|
||||||
*/
|
*/
|
||||||
public class DatabasePlatform {
|
public class DatabasePlatform {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean");
|
private static final System.Logger log = EbeanVersion.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Behavior used when ending a query only transaction (at read committed isolation level).
|
* Behavior used when ending a query only transaction (at read committed isolation level).
|
||||||
@@ -60,7 +53,7 @@ public class DatabasePlatform {
|
|||||||
* Can we use native java time API objects in
|
* Can we use native java time API objects in
|
||||||
* {@link ResultSet#getObject(int, Class)} and
|
* {@link ResultSet#getObject(int, Class)} and
|
||||||
* {@link PreparedStatement#setObject(int, Object)}.
|
* {@link PreparedStatement#setObject(int, Object)}.
|
||||||
*
|
* <p>
|
||||||
* Not all drivers (DB2 e.g.) will support this.
|
* Not all drivers (DB2 e.g.) will support this.
|
||||||
*/
|
*/
|
||||||
protected boolean supportsNativeJavaTime = true;
|
protected boolean supportsNativeJavaTime = true;
|
||||||
@@ -165,7 +158,7 @@ public class DatabasePlatform {
|
|||||||
* want to use quoted identifiers for. The backticks get converted to the
|
* want to use quoted identifiers for. The backticks get converted to the
|
||||||
* appropriate characters in convertQuotedIdentifiers
|
* appropriate characters in convertQuotedIdentifiers
|
||||||
*/
|
*/
|
||||||
private static final char[] QUOTED_IDENTIFIERS = new char[] { '"', '\'', '[', ']', '`' };
|
private static final char[] QUOTED_IDENTIFIERS = new char[]{'"', '\'', '[', ']', '`'};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The non-escaped like clause (to stop slash being escaped on some platforms).
|
* The non-escaped like clause (to stop slash being escaped on some platforms).
|
||||||
@@ -666,7 +659,7 @@ public class DatabasePlatform {
|
|||||||
if (isQuote(dbName.charAt(dbName.length() - 1))) {
|
if (isQuote(dbName.charAt(dbName.length() - 1))) {
|
||||||
return openQuote + dbName.substring(1, dbName.length() - 1) + closeQuote;
|
return openQuote + dbName.substring(1, dbName.length() - 1) + closeQuote;
|
||||||
} else {
|
} else {
|
||||||
log.error("Missing backquote on [" + dbName + "]");
|
log.log(Level.ERROR, "Missing backquote on [" + dbName + "]");
|
||||||
}
|
}
|
||||||
} else if (allQuotedIdentifiers) {
|
} else if (allQuotedIdentifiers) {
|
||||||
return openQuote + dbName + closeQuote;
|
return openQuote + dbName + closeQuote;
|
||||||
@@ -729,7 +722,7 @@ public class DatabasePlatform {
|
|||||||
|
|
||||||
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
|
protected String withForUpdate(String sql, Query.LockWait lockWait, Query.LockType lockType) {
|
||||||
// silently assume the database does not support the "for update" clause.
|
// silently assume the database does not support the "for update" clause.
|
||||||
log.info("it seems your database does not support the 'for update' clause");
|
log.log(Level.INFO, "it seems your database does not support the 'for update' clause");
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,7 +756,7 @@ public class DatabasePlatform {
|
|||||||
if (!schemaExists(dbSchema, connection)) {
|
if (!schemaExists(dbSchema, connection)) {
|
||||||
Statement query = connection.createStatement();
|
Statement query = connection.createStatement();
|
||||||
try {
|
try {
|
||||||
log.debug("create schema:{}", dbSchema);
|
log.log(Level.DEBUG, "create schema:{0}", dbSchema);
|
||||||
query.executeUpdate("create schema " + dbSchema);
|
query.executeUpdate("create schema " + dbSchema);
|
||||||
} finally {
|
} finally {
|
||||||
JdbcClose.close(query);
|
JdbcClose.close(query);
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package io.ebean.config.dbplatform;
|
package io.ebean.config.dbplatform;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.BackgroundExecutor;
|
import io.ebean.BackgroundExecutor;
|
||||||
import io.ebean.Transaction;
|
import io.ebean.Transaction;
|
||||||
import io.ebean.util.JdbcClose;
|
import io.ebean.util.JdbcClose;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -24,7 +24,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
||||||
|
|
||||||
protected static final Logger log = LoggerFactory.getLogger("io.ebean.SEQ");
|
protected static final System.Logger log = AppLog.getLogger("io.ebean.SEQ");
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
protected final String seqName;
|
protected final String seqName;
|
||||||
@@ -120,7 +120,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
protected void loadInBackground(final int requestSize) {
|
protected void loadInBackground(final int requestSize) {
|
||||||
if (currentlyBackgroundLoading.get()) {
|
if (currentlyBackgroundLoading.get()) {
|
||||||
// skip as already background loading
|
// skip as already background loading
|
||||||
log.debug("... skip background sequence load (another load in progress)");
|
log.log(Level.DEBUG, "... skip background sequence load (another load in progress)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
currentlyBackgroundLoading.set(true);
|
currentlyBackgroundLoading.set(true);
|
||||||
@@ -152,9 +152,6 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
List<Long> newIds = readIds(resultSet, requestSize);
|
List<Long> newIds = readIds(resultSet, requestSize);
|
||||||
if (log.isTraceEnabled()) {
|
|
||||||
log.trace("seq:{} loaded:{} sql:{}", seqName, newIds.size(), sql);
|
|
||||||
}
|
|
||||||
if (newIds.isEmpty()) {
|
if (newIds.isEmpty()) {
|
||||||
throw new PersistenceException("Always expecting more than 1 row from " + sql);
|
throw new PersistenceException("Always expecting more than 1 row from " + sql);
|
||||||
}
|
}
|
||||||
@@ -164,7 +161,7 @@ public abstract class SequenceIdGenerator implements PlatformIdGenerator {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
if (e.getMessage().contains("Database is already closed")) {
|
if (e.getMessage().contains("Database is already closed")) {
|
||||||
String msg = "Error getting SEQ when DB shutting down " + e.getMessage();
|
String msg = "Error getting SEQ when DB shutting down " + e.getMessage();
|
||||||
log.error(msg);
|
log.log(Level.ERROR, msg);
|
||||||
System.out.println(msg);
|
System.out.println(msg);
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.ebean.event;
|
package io.ebean.event;
|
||||||
|
|
||||||
import io.ebean.Database;
|
import io.ebean.Database;
|
||||||
|
import io.ebean.EbeanVersion;
|
||||||
import io.ebean.service.SpiContainer;
|
import io.ebean.service.SpiContainer;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Driver;
|
import java.sql.Driver;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -20,13 +20,14 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public final class ShutdownManager {
|
public final class ShutdownManager {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean");
|
private static final System.Logger log = EbeanVersion.log;
|
||||||
private static final ReentrantLock lock = new ReentrantLock();
|
private static final ReentrantLock lock = new ReentrantLock();
|
||||||
private static final List<Database> databases = new ArrayList<>();
|
private static final List<Database> databases = new ArrayList<>();
|
||||||
private static final ShutdownHook shutdownHook = new ShutdownHook();
|
private static final ShutdownHook shutdownHook = new ShutdownHook();
|
||||||
|
|
||||||
private static boolean stopping;
|
private static boolean stopping;
|
||||||
private static SpiContainer container;
|
private static SpiContainer container;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// Register the Shutdown hook
|
// Register the Shutdown hook
|
||||||
registerShutdownHook();
|
registerShutdownHook();
|
||||||
@@ -120,8 +121,8 @@ public final class ShutdownManager {
|
|||||||
// Already run shutdown...
|
// Already run shutdown...
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("Ebean shutting down");
|
log.log(Level.DEBUG, "Ebean shutting down");
|
||||||
}
|
}
|
||||||
stopping = true;
|
stopping = true;
|
||||||
deregisterShutdownHook();
|
deregisterShutdownHook();
|
||||||
@@ -133,7 +134,7 @@ public final class ShutdownManager {
|
|||||||
Runnable r = (Runnable) ClassUtil.newInstance(shutdownRunner);
|
Runnable r = (Runnable) ClassUtil.newInstance(shutdownRunner);
|
||||||
r.run();
|
r.run();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error running custom shutdown runnable", e);
|
log.log(Level.ERROR, "Error running custom shutdown runnable", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ public final class ShutdownManager {
|
|||||||
try {
|
try {
|
||||||
server.shutdown();
|
server.shutdown();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("Error executing shutdown runnable", ex);
|
log.log(Level.ERROR, "Error executing shutdown runnable", ex);
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,10 +166,10 @@ public final class ShutdownManager {
|
|||||||
while (drivers.hasMoreElements()) {
|
while (drivers.hasMoreElements()) {
|
||||||
Driver driver = drivers.nextElement();
|
Driver driver = drivers.nextElement();
|
||||||
try {
|
try {
|
||||||
log.info("De-registering jdbc driver: " + driver);
|
log.log(Level.INFO, "De-registering jdbc driver: " + driver);
|
||||||
DriverManager.deregisterDriver(driver);
|
DriverManager.deregisterDriver(driver);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Error de-registering driver " + driver, e);
|
log.log(Level.ERROR, "Error de-registering driver " + driver, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -204,6 +205,7 @@ public final class ShutdownManager {
|
|||||||
private ShutdownHook() {
|
private ShutdownHook() {
|
||||||
super("EbeanHook");
|
super("EbeanHook");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ShutdownManager.shutdown();
|
ShutdownManager.shutdown();
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package io.ebean.text.csv;
|
package io.ebean.text.csv;
|
||||||
|
|
||||||
import io.ebean.Database;
|
import io.ebean.Database;
|
||||||
|
import io.ebean.EbeanVersion;
|
||||||
import io.ebean.Transaction;
|
import io.ebean.Transaction;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the default implementation of CsvCallback.
|
* Provides the default implementation of CsvCallback.
|
||||||
@@ -20,7 +21,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(DefaultCsvCallback.class);
|
private static final System.Logger log = EbeanVersion.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The transaction to use (if not using CsvCallback).
|
* The transaction to use (if not using CsvCallback).
|
||||||
@@ -128,7 +129,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
|||||||
// related beans (e.g. customer -> customer.billingAddress
|
// related beans (e.g. customer -> customer.billingAddress
|
||||||
server.save(bean, transaction);
|
server.save(bean, transaction);
|
||||||
if (logInfoFrequency > 0 && (row % logInfoFrequency == 0)) {
|
if (logInfoFrequency > 0 && (row % logInfoFrequency == 0)) {
|
||||||
log.debug("processed {} rows", row);
|
log.log(Level.DEBUG, "processed {0} rows", row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +140,7 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
|||||||
public void end(int row) {
|
public void end(int row) {
|
||||||
commitTransactionIfCreated();
|
commitTransactionIfCreated();
|
||||||
exeTime = System.currentTimeMillis() - startTime;
|
exeTime = System.currentTimeMillis() - startTime;
|
||||||
log.info("Csv finished, rows[{}] exeMillis[{}]", row, exeTime);
|
log.log(Level.INFO, "Csv finished, rows[{0}] exeMillis[{1}]", row, exeTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,7 +161,6 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
|||||||
transaction = server.beginTransaction();
|
transaction = server.beginTransaction();
|
||||||
createdTransaction = true;
|
createdTransaction = true;
|
||||||
if (persistBatchSize > 1) {
|
if (persistBatchSize > 1) {
|
||||||
log.debug("Creating transaction, batchSize[{}]", persistBatchSize);
|
|
||||||
transaction.setBatchMode(true);
|
transaction.setBatchMode(true);
|
||||||
transaction.setBatchSize(persistBatchSize);
|
transaction.setBatchSize(persistBatchSize);
|
||||||
transaction.setGetGeneratedKeys(false);
|
transaction.setGetGeneratedKeys(false);
|
||||||
@@ -168,7 +168,6 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
|||||||
// explicitly turn off JDBC batching in case
|
// explicitly turn off JDBC batching in case
|
||||||
// is has been turned on globally
|
// is has been turned on globally
|
||||||
transaction.setBatchMode(false);
|
transaction.setBatchMode(false);
|
||||||
log.debug("Creating transaction with no JDBC batching");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,7 +179,6 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
|||||||
protected void commitTransactionIfCreated() {
|
protected void commitTransactionIfCreated() {
|
||||||
if (createdTransaction) {
|
if (createdTransaction) {
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
log.debug("Committed transaction");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +189,6 @@ public class DefaultCsvCallback<T> implements CsvCallback<T> {
|
|||||||
protected void rollbackTransactionIfCreated(Throwable e) {
|
protected void rollbackTransactionIfCreated(Throwable e) {
|
||||||
if (createdTransaction) {
|
if (createdTransaction) {
|
||||||
transaction.rollback(e);
|
transaction.rollback(e);
|
||||||
log.debug("Rolled back transaction");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package io.ebean.util;
|
package io.ebean.util;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import io.ebean.EbeanVersion;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -13,7 +13,7 @@ import java.sql.Statement;
|
|||||||
*/
|
*/
|
||||||
public final class JdbcClose {
|
public final class JdbcClose {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean");
|
private static final System.Logger log = EbeanVersion.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the resultSet logging if an error occurs.
|
* Close the resultSet logging if an error occurs.
|
||||||
@@ -24,7 +24,7 @@ public final class JdbcClose {
|
|||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.warn("Error closing statement", e);
|
log.log(Level.WARNING, "Error closing statement", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public final class JdbcClose {
|
|||||||
resultSet.close();
|
resultSet.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.warn("Error closing resultSet", e);
|
log.log(Level.WARNING, "Error closing resultSet", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ public final class JdbcClose {
|
|||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.warn("Error closing connection", e);
|
log.log(Level.WARNING, "Error closing connection", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ public final class JdbcClose {
|
|||||||
connection.rollback();
|
connection.rollback();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.warn("Error on connection rollback", e);
|
log.log(Level.WARNING, "Error on connection rollback", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public final class JdbcClose {
|
|||||||
stmt.cancel();
|
stmt.cancel();
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.warn("Error on cancelling statement", e);
|
log.log(Level.WARNING, "Error on cancelling statement", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,8 +15,9 @@ module io.ebean.api {
|
|||||||
requires transitive persistence.api;
|
requires transitive persistence.api;
|
||||||
requires transitive io.ebean.annotation;
|
requires transitive io.ebean.annotation;
|
||||||
requires transitive io.ebean.datasource.api;
|
requires transitive io.ebean.datasource.api;
|
||||||
requires transitive org.slf4j;
|
requires transitive io.avaje.applog;
|
||||||
|
|
||||||
|
requires static org.slf4j;
|
||||||
requires static io.ebean.types;
|
requires static io.ebean.types;
|
||||||
requires static com.fasterxml.jackson.core;
|
requires static com.fasterxml.jackson.core;
|
||||||
requires static com.fasterxml.jackson.databind;
|
requires static com.fasterxml.jackson.databind;
|
||||||
|
|||||||
+14
-14
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.server.autotune.service;
|
package io.ebeaninternal.server.autotune.service;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.config.AutoTuneConfig;
|
import io.ebean.config.AutoTuneConfig;
|
||||||
import io.ebean.config.DatabaseConfig;
|
import io.ebean.config.DatabaseConfig;
|
||||||
import io.ebeaninternal.api.SpiEbeanServer;
|
import io.ebeaninternal.api.SpiEbeanServer;
|
||||||
@@ -7,12 +8,11 @@ import io.ebeaninternal.api.SpiQuery;
|
|||||||
import io.ebeaninternal.server.autotune.AutoTuneService;
|
import io.ebeaninternal.server.autotune.AutoTuneService;
|
||||||
import io.ebeaninternal.server.autotune.model.Autotune;
|
import io.ebeaninternal.server.autotune.model.Autotune;
|
||||||
import io.ebeaninternal.server.autotune.model.Origin;
|
import io.ebeaninternal.server.autotune.model.Origin;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public class DefaultAutoTuneService implements AutoTuneService {
|
public class DefaultAutoTuneService implements AutoTuneService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DefaultAutoTuneService.class);
|
private static final System.Logger logger = AppLog.getLogger(DefaultAutoTuneService.class);
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
if (stream != null) {
|
if (stream != null) {
|
||||||
loadAutoTuneProfiling(AutoTuneXmlReader.read(stream));
|
loadAutoTuneProfiling(AutoTuneXmlReader.read(stream));
|
||||||
} else {
|
} else {
|
||||||
logger.warn("AutoTune file {} not found - no initial automatic query tuning", tuningFile);
|
logger.log(Level.WARNING, "AutoTune file {0} not found - no initial automatic query tuning", tuningFile);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Error on auto close of " + tuningFile, e);
|
throw new IllegalStateException("Error on auto close of " + tuningFile, e);
|
||||||
@@ -120,7 +120,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadAutoTuneProfiling(Autotune profiling) {
|
private void loadAutoTuneProfiling(Autotune profiling) {
|
||||||
logger.info("AutoTune loading {} tuning entries", profiling.getOrigin().size());
|
logger.log(Level.INFO, "AutoTune loading {0} tuning entries", profiling.getOrigin().size());
|
||||||
for (Origin origin : profiling.getOrigin()) {
|
for (Origin origin : profiling.getOrigin()) {
|
||||||
queryTuner.put(origin);
|
queryTuner.put(origin);
|
||||||
}
|
}
|
||||||
@@ -141,17 +141,17 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
event.process();
|
event.process();
|
||||||
if (event.isEmpty()) {
|
if (event.isEmpty()) {
|
||||||
long exeMillis = System.currentTimeMillis() - start;
|
long exeMillis = System.currentTimeMillis() - start;
|
||||||
logger.debug("No query tuning updates for server:{} executionMillis:{}", serverName, exeMillis);
|
logger.log(Level.DEBUG, "No query tuning updates for server:{0} executionMillis:{1}", serverName, exeMillis);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// report the query tuning changes that have been made
|
// report the query tuning changes that have been made
|
||||||
runtimeChangeCount += event.getChangeCount();
|
runtimeChangeCount += event.getChangeCount();
|
||||||
event.writeFile(profilingFile + "-" + serverName + "-update");
|
event.writeFile(profilingFile + "-" + serverName + "-update");
|
||||||
long exeMillis = System.currentTimeMillis() - start;
|
long exeMillis = System.currentTimeMillis() - start;
|
||||||
logger.info("query tuning updates - new:{} diff:{} for server:{} executionMillis:{}", event.getNewCount(), event.getDiffCount(), serverName, exeMillis);
|
logger.log(Level.INFO, "query tuning updates - new:{0} diff:{1} for server:{2} executionMillis:{3}", event.getNewCount(), event.getDiffCount(), serverName, exeMillis);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Error collecting or applying automatic query tuning", e);
|
logger.log(Level.ERROR, "Error collecting or applying automatic query tuning", e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -172,11 +172,11 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
AutoTuneDiffCollection event = new AutoTuneDiffCollection(profiling, queryTuner, false);
|
AutoTuneDiffCollection event = new AutoTuneDiffCollection(profiling, queryTuner, false);
|
||||||
event.process();
|
event.process();
|
||||||
if (event.isEmpty()) {
|
if (event.isEmpty()) {
|
||||||
logger.info("No new or diff entries for profiling server:{}", serverName);
|
logger.log(Level.INFO, "No new or diff entries for profiling server:{0}", serverName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
event.writeFile(profilingFile + "-" + serverName);
|
event.writeFile(profilingFile + "-" + serverName);
|
||||||
logger.info("writing new:{} diff:{} profiling entries for server:{}", event.getNewCount(), event.getDiffCount(), serverName);
|
logger.log(Level.INFO, "writing new:{0} diff:{1} profiling entries for server:{2}", event.getNewCount(), event.getDiffCount(), serverName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -196,7 +196,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
private void outputAllTuning() {
|
private void outputAllTuning() {
|
||||||
|
|
||||||
if (runtimeChangeCount == 0) {
|
if (runtimeChangeCount == 0) {
|
||||||
logger.info("no runtime query tuning changes for server:{}", serverName);
|
logger.log(Level.INFO, "no runtime query tuning changes for server:{0}", serverName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
AutoTuneAllCollection event = new AutoTuneAllCollection(queryTuner);
|
AutoTuneAllCollection event = new AutoTuneAllCollection(queryTuner);
|
||||||
@@ -205,12 +205,12 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
if (existingTuning.exists()) {
|
if (existingTuning.exists()) {
|
||||||
// rename the existing autotune.xml file (appending 'now')
|
// rename the existing autotune.xml file (appending 'now')
|
||||||
if (!existingTuning.renameTo(new File(tuningFile + "." + AutoTuneXmlWriter.now()))) {
|
if (!existingTuning.renameTo(new File(tuningFile + "." + AutoTuneXmlWriter.now()))) {
|
||||||
logger.warn("Failed to rename autotune file [{}]", tuningFile);
|
logger.log(Level.WARNING, "Failed to rename autotune file [{0}]", tuningFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.writeFile(tuningFile, false);
|
event.writeFile(tuningFile, false);
|
||||||
logger.info("query tuning detected [{}] changes, writing all [{}] tuning entries for server:{}", runtimeChangeCount, size, serverName);
|
logger.log(Level.INFO, "query tuning detected [{0}] changes, writing all [{1}] tuning entries for server:{2}", runtimeChangeCount, size, serverName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ public class DefaultAutoTuneService implements AutoTuneService {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// restore the interrupted status
|
// restore the interrupted status
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
logger.warn("Error while sleeping after System.gc() request.", e);
|
logger.log(Level.WARNING, "Error while sleeping after System.gc() request.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.server.autotune.service;
|
package io.ebeaninternal.server.autotune.service;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.bean.NodeUsageCollector;
|
import io.ebean.bean.NodeUsageCollector;
|
||||||
import io.ebean.text.PathProperties;
|
import io.ebean.text.PathProperties;
|
||||||
import io.ebean.util.SplitName;
|
import io.ebean.util.SplitName;
|
||||||
@@ -7,9 +8,8 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
|
|||||||
import io.ebeaninternal.server.deploy.BeanProperty;
|
import io.ebeaninternal.server.deploy.BeanProperty;
|
||||||
import io.ebeaninternal.server.deploy.BeanPropertyAssoc;
|
import io.ebeaninternal.server.deploy.BeanPropertyAssoc;
|
||||||
import io.ebeaninternal.server.el.ElPropertyValue;
|
import io.ebeaninternal.server.el.ElPropertyValue;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@@ -19,7 +19,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public class ProfileOriginNodeUsage {
|
public class ProfileOriginNodeUsage {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ProfileOriginNodeUsage.class);
|
private static final System.Logger logger = AppLog.getLogger(ProfileOriginNodeUsage.class);
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public class ProfileOriginNodeUsage {
|
|||||||
if (path != null) {
|
if (path != null) {
|
||||||
ElPropertyValue elGetValue = rootDesc.elGetValue(path);
|
ElPropertyValue elGetValue = rootDesc.elGetValue(path);
|
||||||
if (elGetValue == null) {
|
if (elGetValue == null) {
|
||||||
logger.warn("AutoTune: Can't find join for path[" + path + "] for " + rootDesc.name());
|
logger.log(Level.WARNING, "AutoTune: Can't find join for path[" + path + "] for " + rootDesc.name());
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
BeanProperty beanProperty = elGetValue.beanProperty();
|
BeanProperty beanProperty = elGetValue.beanProperty();
|
||||||
@@ -61,7 +61,7 @@ public class ProfileOriginNodeUsage {
|
|||||||
for (String propName : aggregateUsed) {
|
for (String propName : aggregateUsed) {
|
||||||
BeanProperty beanProp = desc.findPropertyFromPath(propName);
|
BeanProperty beanProp = desc.findPropertyFromPath(propName);
|
||||||
if (beanProp == null) {
|
if (beanProp == null) {
|
||||||
logger.warn("AutoTune: Can't find property[" + propName + "] for " + desc.name());
|
logger.log(Level.WARNING, "AutoTune: Can't find property[" + propName + "] for " + desc.name());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (beanProp.isId()) {
|
if (beanProp.isId()) {
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package io.ebeaninternal.api;
|
package io.ebeaninternal.api;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import io.avaje.applog.AppLog;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common loggers used in ebean-core.
|
* Common loggers used in ebean-core.
|
||||||
*/
|
*/
|
||||||
public final class CoreLog {
|
public final class CoreLog {
|
||||||
|
|
||||||
public static final Logger log = LoggerFactory.getLogger("io.ebean.core");
|
public static final System.Logger log = AppLog.getLogger("io.ebean.core");
|
||||||
public static final Logger internal = LoggerFactory.getLogger("io.ebean.internal");
|
public static final System.Logger internal = AppLog.getLogger("io.ebean.internal");
|
||||||
}
|
}
|
||||||
@@ -7,17 +7,18 @@ import io.ebeaninternal.server.core.BindPadding;
|
|||||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||||
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request for loading Associated Many Beans.
|
* Request for loading Associated Many Beans.
|
||||||
*/
|
*/
|
||||||
public final class LoadManyRequest extends LoadRequest {
|
public final class LoadManyRequest extends LoadRequest {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.log;
|
private static final System.Logger log = CoreLog.log;
|
||||||
|
|
||||||
private final List<BeanCollection<?>> batch;
|
private final List<BeanCollection<?>> batch;
|
||||||
private final LoadManyBuffer loadContext;
|
private final LoadManyBuffer loadContext;
|
||||||
@@ -113,10 +114,10 @@ public final class LoadManyRequest extends LoadRequest {
|
|||||||
// in the +query or +lazy load due to no rows (predicates)
|
// in the +query or +lazy load due to no rows (predicates)
|
||||||
for (BeanCollection<?> bc : batch) {
|
for (BeanCollection<?> bc : batch) {
|
||||||
if (bc.checkEmptyLazyLoad()) {
|
if (bc.checkEmptyLazyLoad()) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(DEBUG)) {
|
||||||
EntityBean ownerBean = bc.getOwnerBean();
|
EntityBean ownerBean = bc.getOwnerBean();
|
||||||
Object parentId = desc.getId(ownerBean);
|
Object parentId = desc.getId(ownerBean);
|
||||||
log.debug("BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean);
|
log.log(DEBUG, "BeanCollection after lazy load was empty. type:" + ownerBean.getClass().getName() + " id:" + parentId + " owner:" + ownerBean);
|
||||||
}
|
}
|
||||||
} else if (loadCache && many.isUseCache()) {
|
} else if (loadCache && many.isUseCache()) {
|
||||||
desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean()));
|
desc.cacheManyPropPut(many, bc, desc.getId(bc.getOwnerBean()));
|
||||||
|
|||||||
+6
-6
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.server.cache;
|
package io.ebeaninternal.server.cache;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.annotation.Cache;
|
import io.ebean.annotation.Cache;
|
||||||
import io.ebean.annotation.CacheBeanTuning;
|
import io.ebean.annotation.CacheBeanTuning;
|
||||||
import io.ebean.annotation.CacheQueryTuning;
|
import io.ebean.annotation.CacheQueryTuning;
|
||||||
@@ -7,9 +8,8 @@ import io.ebean.cache.*;
|
|||||||
import io.ebean.config.CurrentTenantProvider;
|
import io.ebean.config.CurrentTenantProvider;
|
||||||
import io.ebean.meta.MetricVisitor;
|
import io.ebean.meta.MetricVisitor;
|
||||||
import io.ebean.util.AnnotationUtil;
|
import io.ebean.util.AnnotationUtil;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListSet;
|
import java.util.concurrent.ConcurrentSkipListSet;
|
||||||
@@ -20,7 +20,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
final class DefaultCacheHolder {
|
final class DefaultCacheHolder {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.cache.ALL");
|
private static final System.Logger log = AppLog.getLogger("io.ebean.cache.ALL");
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
private final ConcurrentHashMap<String, ServerCache> allCaches = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<String, ServerCache> allCaches = new ConcurrentHashMap<>();
|
||||||
@@ -89,7 +89,7 @@ final class DefaultCacheHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clearAll() {
|
void clearAll() {
|
||||||
log.debug("clearAll");
|
log.log(Level.DEBUG, "clearAll");
|
||||||
for (ServerCache serverCache : allCaches.values()) {
|
for (ServerCache serverCache : allCaches.values()) {
|
||||||
serverCache.clear();
|
serverCache.clear();
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ final class DefaultCacheHolder {
|
|||||||
|
|
||||||
|
|
||||||
public void clear(String name) {
|
public void clear(String name) {
|
||||||
log.debug("clear {}", name);
|
log.log(Level.DEBUG, "clear {0}", name);
|
||||||
clearIfExists(key(name, ServerCacheType.QUERY));
|
clearIfExists(key(name, ServerCacheType.QUERY));
|
||||||
clearIfExists(key(name, ServerCacheType.BEAN));
|
clearIfExists(key(name, ServerCacheType.BEAN));
|
||||||
clearIfExists(key(name, ServerCacheType.NATURAL_KEY));
|
clearIfExists(key(name, ServerCacheType.NATURAL_KEY));
|
||||||
@@ -112,7 +112,7 @@ final class DefaultCacheHolder {
|
|||||||
private void clearIfExists(String fullKey) {
|
private void clearIfExists(String fullKey) {
|
||||||
ServerCache cache = allCaches.get(fullKey);
|
ServerCache cache = allCaches.get(fullKey);
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
log.trace("clear cache {}", fullKey);
|
log.log(Level.TRACE, "clear cache {0}", fullKey);
|
||||||
cache.clear();
|
cache.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -1,15 +1,15 @@
|
|||||||
package io.ebeaninternal.server.cache;
|
package io.ebeaninternal.server.cache;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.BackgroundExecutor;
|
import io.ebean.BackgroundExecutor;
|
||||||
import io.ebean.cache.ServerCache;
|
import io.ebean.cache.ServerCache;
|
||||||
import io.ebean.cache.ServerCacheStatistics;
|
import io.ebean.cache.ServerCacheStatistics;
|
||||||
import io.ebean.meta.MetricVisitor;
|
import io.ebean.meta.MetricVisitor;
|
||||||
import io.ebean.metric.CountMetric;
|
import io.ebean.metric.CountMetric;
|
||||||
import io.ebean.metric.MetricFactory;
|
import io.ebean.metric.MetricFactory;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.lang.ref.SoftReference;
|
import java.lang.ref.SoftReference;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -25,7 +25,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public class DefaultServerCache implements ServerCache {
|
public class DefaultServerCache implements ServerCache {
|
||||||
|
|
||||||
protected static final Logger logger = LoggerFactory.getLogger(DefaultServerCache.class);
|
protected static final System.Logger logger = AppLog.getLogger(DefaultServerCache.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare by last access time (for LRU eviction).
|
* Compare by last access time (for LRU eviction).
|
||||||
@@ -287,13 +287,13 @@ public class DefaultServerCache implements ServerCache {
|
|||||||
evictCount.add(trimmedByGC);
|
evictCount.add(trimmedByGC);
|
||||||
evictCount.add(trimmedByTTL);
|
evictCount.add(trimmedByTTL);
|
||||||
evictCount.add(trimmedByLRU);
|
evictCount.add(trimmedByLRU);
|
||||||
if (logger.isTraceEnabled()) {
|
if (logger.isLoggable(Level.TRACE)) {
|
||||||
long exeMicros = TimeUnit.MICROSECONDS.convert(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
|
long exeMicros = TimeUnit.MICROSECONDS.convert(System.nanoTime() - startNanos, TimeUnit.NANOSECONDS);
|
||||||
logger.trace("Executed trim of cache {} in [{}]millis idle[{}] timeToLive[{}] accessTime[{}] gc[{}]",
|
logger.log(Level.TRACE, "Executed trim of cache {0} in [{1}]millis idle[{2}] timeToLive[{3}] accessTime[{4}] gc[{5}]",
|
||||||
name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU, trimmedByGC);
|
name, exeMicros, trimmedByIdle, trimmedByTTL, trimmedByLRU, trimmedByGC);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.warn("Error during trim of DefaultServerCache [" + name + "]. Cache might be bigger than desired.", e);
|
logger.log(Level.WARNING, "Error during trim of DefaultServerCache [" + name + "]. Cache might be bigger than desired.", e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|||||||
+7
-7
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.server.cache;
|
package io.ebeaninternal.server.cache;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.cache.ServerCache;
|
import io.ebean.cache.ServerCache;
|
||||||
import io.ebean.cache.ServerCacheRegion;
|
import io.ebean.cache.ServerCacheRegion;
|
||||||
import io.ebean.cache.ServerCacheType;
|
import io.ebean.cache.ServerCacheType;
|
||||||
@@ -7,9 +8,8 @@ import io.ebean.meta.MetricVisitor;
|
|||||||
import io.ebeaninternal.api.SpiCacheRegion;
|
import io.ebeaninternal.api.SpiCacheRegion;
|
||||||
import io.ebeaninternal.server.cluster.ClusterManager;
|
import io.ebeaninternal.server.cluster.ClusterManager;
|
||||||
import io.ebeaninternal.server.deploy.DCacheRegion;
|
import io.ebeaninternal.server.deploy.DCacheRegion;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +17,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public final class DefaultServerCacheManager implements SpiCacheManager {
|
public final class DefaultServerCacheManager implements SpiCacheManager {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.cache.REGION");
|
private static final System.Logger log = AppLog.getLogger("io.ebean.cache.REGION");
|
||||||
|
|
||||||
private final Map<String, SpiCacheRegion> regionMap = new HashMap<>();
|
private final Map<String, SpiCacheRegion> regionMap = new HashMap<>();
|
||||||
private final ClusterManager clusterManager;
|
private final ClusterManager clusterManager;
|
||||||
@@ -65,23 +65,23 @@ public final class DefaultServerCacheManager implements SpiCacheManager {
|
|||||||
enabled.add(region.name());
|
enabled.add(region.name());
|
||||||
if (!region.isEnabled()) {
|
if (!region.isEnabled()) {
|
||||||
region.setEnabled(true);
|
region.setEnabled(true);
|
||||||
log.debug("Cache region[{}] enabled", region.name());
|
log.log(Level.DEBUG, "Cache region[{0}] enabled", region.name());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
disabled.add(region.name());
|
disabled.add(region.name());
|
||||||
if (region.isEnabled()) {
|
if (region.isEnabled()) {
|
||||||
region.setEnabled(false);
|
region.setEnabled(false);
|
||||||
log.debug("Cache region[{}] disabled", region.name());
|
log.log(Level.DEBUG, "Cache region[{0}] disabled", region.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("Cache regions enabled:{} disabled:{}", enabled, disabled);
|
log.log(Level.INFO, "Cache regions enabled:{0} disabled:{1}", enabled, disabled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAllRegionsEnabled(boolean enabled) {
|
public void setAllRegionsEnabled(boolean enabled) {
|
||||||
log.debug("All cache regions enabled[{}]", enabled);
|
log.log(Level.DEBUG, "All cache regions enabled[{0}]", enabled);
|
||||||
for (SpiCacheRegion region : regionMap.values()) {
|
for (SpiCacheRegion region : regionMap.values()) {
|
||||||
region.setEnabled(enabled);
|
region.setEnabled(enabled);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.server.changelog;
|
package io.ebeaninternal.server.changelog;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.event.changelog.BeanChange;
|
import io.ebean.event.changelog.BeanChange;
|
||||||
import io.ebean.event.changelog.ChangeLogListener;
|
import io.ebean.event.changelog.ChangeLogListener;
|
||||||
import io.ebean.event.changelog.ChangeSet;
|
import io.ebean.event.changelog.ChangeSet;
|
||||||
@@ -7,10 +8,9 @@ import io.ebean.event.changelog.ChangeType;
|
|||||||
import io.ebean.plugin.Plugin;
|
import io.ebean.plugin.Plugin;
|
||||||
import io.ebean.plugin.SpiServer;
|
import io.ebean.plugin.SpiServer;
|
||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -21,7 +21,7 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
|
|||||||
/**
|
/**
|
||||||
* The named logger we send the change set payload to. Can be externally configured as desired.
|
* The named logger we send the change set payload to. Can be externally configured as desired.
|
||||||
*/
|
*/
|
||||||
private static final Logger changeLog = LoggerFactory.getLogger("io.ebean.ChangeLog");
|
private static final System.Logger changeLog = AppLog.getLogger("io.ebean.ChangeLog");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to build the JSON.
|
* Used to build the JSON.
|
||||||
@@ -65,9 +65,9 @@ public final class DefaultChangeLogListener implements ChangeLogListener, Plugin
|
|||||||
try {
|
try {
|
||||||
StringWriter writer = new StringWriter(getBufferSize(beanChange));
|
StringWriter writer = new StringWriter(getBufferSize(beanChange));
|
||||||
jsonBuilder.writeBeanJson(writer, beanChange, changeSet);
|
jsonBuilder.writeBeanJson(writer, beanChange, changeSet);
|
||||||
changeLog.info(writer.toString());
|
changeLog.log(Level.INFO, writer.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CoreLog.log.error("Exception logging beanChange " + beanChange, e);
|
CoreLog.log.log(Level.ERROR, "Exception logging beanChange " + beanChange, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package io.ebeaninternal.server.cluster;
|
package io.ebeaninternal.server.cluster;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.Database;
|
import io.ebean.Database;
|
||||||
import io.ebean.config.ContainerConfig;
|
import io.ebean.config.ContainerConfig;
|
||||||
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
|
import io.ebeaninternal.server.transaction.RemoteTransactionEvent;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -16,7 +16,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public class ClusterManager implements ServerLookup {
|
public class ClusterManager implements ServerLookup {
|
||||||
|
|
||||||
private static final Logger clusterLogger = LoggerFactory.getLogger("io.ebean.Cluster");
|
private static final System.Logger clusterLogger = AppLog.getLogger("io.ebean.Cluster");
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
||||||
@@ -112,8 +112,8 @@ public class ClusterManager implements ServerLookup {
|
|||||||
*/
|
*/
|
||||||
public void broadcast(RemoteTransactionEvent event) {
|
public void broadcast(RemoteTransactionEvent event) {
|
||||||
if (broadcast != null) {
|
if (broadcast != null) {
|
||||||
if (clusterLogger.isDebugEnabled()) {
|
if (clusterLogger.isLoggable(Level.DEBUG)) {
|
||||||
clusterLogger.debug("sending: {}", event);
|
clusterLogger.log(Level.DEBUG, "sending: {0}", event);
|
||||||
}
|
}
|
||||||
broadcast.broadcast(event);
|
broadcast.broadcast(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import io.ebeaninternal.api.SpiEbeanServer;
|
|||||||
import io.ebeaninternal.api.SpiTransaction;
|
import io.ebeaninternal.api.SpiTransaction;
|
||||||
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for find and persist requests.
|
* Base class for find and persist requests.
|
||||||
*/
|
*/
|
||||||
@@ -61,7 +63,7 @@ public abstract class BeanRequest {
|
|||||||
// Just log this and carry on. A previous exception has been
|
// Just log this and carry on. A previous exception has been
|
||||||
// thrown and if this rollback throws exception it likely means
|
// thrown and if this rollback throws exception it likely means
|
||||||
// that the connection is broken (and the dataSource and db will cleanup)
|
// that the connection is broken (and the dataSource and db will cleanup)
|
||||||
CoreLog.log.error("Error trying to rollback a transaction (after a prior exception thrown)", e);
|
CoreLog.log.log(Level.ERROR, "Error trying to rollback a transaction (after a prior exception thrown)", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import io.ebeaninternal.api.DbOffline;
|
|||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -38,7 +39,7 @@ public class DatabasePlatformFactory {
|
|||||||
try {
|
try {
|
||||||
String offlinePlatform = DbOffline.getPlatform();
|
String offlinePlatform = DbOffline.getPlatform();
|
||||||
if (offlinePlatform != null) {
|
if (offlinePlatform != null) {
|
||||||
CoreLog.log.info("offline platform [{}]", offlinePlatform);
|
CoreLog.log.log(Level.INFO, "offline platform [{0}]", offlinePlatform);
|
||||||
return byDatabaseName(offlinePlatform);
|
return byDatabaseName(offlinePlatform);
|
||||||
}
|
}
|
||||||
if (config.getDatabasePlatformName() != null) {
|
if (config.getDatabasePlatformName() != null) {
|
||||||
@@ -87,7 +88,7 @@ public class DatabasePlatformFactory {
|
|||||||
String dbProductName = metaData.getDatabaseProductName().toLowerCase();
|
String dbProductName = metaData.getDatabaseProductName().toLowerCase();
|
||||||
final int majorVersion = metaData.getDatabaseMajorVersion();
|
final int majorVersion = metaData.getDatabaseMajorVersion();
|
||||||
final int minorVersion = metaData.getDatabaseMinorVersion();
|
final int minorVersion = metaData.getDatabaseMinorVersion();
|
||||||
CoreLog.log.debug("platform for productName[{}] version[{}.{}]", dbProductName, majorVersion, minorVersion);
|
CoreLog.log.log(Level.DEBUG, "platform for productName[{0}] version[{1}.{2}]", dbProductName, majorVersion, minorVersion);
|
||||||
for (DatabasePlatformProvider provider : providers) {
|
for (DatabasePlatformProvider provider : providers) {
|
||||||
if (provider.matchByProductName(dbProductName)) {
|
if (provider.matchByProductName(dbProductName)) {
|
||||||
return provider.create(majorVersion, minorVersion, metaData, connection);
|
return provider.create(majorVersion, minorVersion, metaData, connection);
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ import io.ebeaninternal.server.deploy.BeanDescriptor;
|
|||||||
import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
|
import io.ebeaninternal.server.deploy.BeanDescriptor.EntityType;
|
||||||
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||||
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.persistence.EntityNotFoundException;
|
import javax.persistence.EntityNotFoundException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
final class DefaultBeanLoader {
|
final class DefaultBeanLoader {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final DefaultServer server;
|
private final DefaultServer server;
|
||||||
private final boolean onIterateUseExtraTxn;
|
private final boolean onIterateUseExtraTxn;
|
||||||
@@ -108,8 +108,8 @@ final class DefaultBeanLoader {
|
|||||||
server.findOne(query, null);
|
server.findOne(query, null);
|
||||||
if (beanCollection != null) {
|
if (beanCollection != null) {
|
||||||
if (beanCollection.checkEmptyLazyLoad()) {
|
if (beanCollection.checkEmptyLazyLoad()) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("BeanCollection after load was empty. Owner:" + beanCollection.getOwnerBean());
|
log.log(Level.DEBUG, "BeanCollection after load was empty. Owner:" + beanCollection.getOwnerBean());
|
||||||
}
|
}
|
||||||
} else if (useManyIdCache) {
|
} else if (useManyIdCache) {
|
||||||
parentDesc.cacheManyPropPut(many, beanCollection, parentId);
|
parentDesc.cacheManyPropPut(many, beanCollection, parentId);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.ebeaninternal.server.core;
|
package io.ebeaninternal.server.core;
|
||||||
|
|
||||||
import io.ebean.config.*;
|
import io.ebean.config.*;
|
||||||
import io.ebean.config.EntityClassRegister;
|
|
||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||||
import io.ebean.event.ShutdownManager;
|
import io.ebean.event.ShutdownManager;
|
||||||
import io.ebean.service.SpiContainer;
|
import io.ebean.service.SpiContainer;
|
||||||
@@ -13,9 +12,9 @@ import io.ebeaninternal.server.cluster.ClusterManager;
|
|||||||
import io.ebeaninternal.server.core.bootup.BootupClassPathSearch;
|
import io.ebeaninternal.server.core.bootup.BootupClassPathSearch;
|
||||||
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
||||||
import io.ebeaninternal.server.executor.DefaultBackgroundExecutor;
|
import io.ebeaninternal.server.executor.DefaultBackgroundExecutor;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -28,7 +27,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public final class DefaultContainer implements SpiContainer {
|
public final class DefaultContainer implements SpiContainer {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.log;
|
private static final System.Logger log = CoreLog.log;
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
private final ClusterManager clusterManager;
|
private final ClusterManager clusterManager;
|
||||||
@@ -108,7 +107,7 @@ public final class DefaultContainer implements SpiContainer {
|
|||||||
startServer(online, server);
|
startServer(online, server);
|
||||||
}
|
}
|
||||||
DbOffline.reset();
|
DbOffline.reset();
|
||||||
log.info("Started database[{}] platform[{}] in {}ms", config.getName(), config.getDatabasePlatform().getPlatform(), System.currentTimeMillis() - start);
|
log.log(Level.INFO, "Started database[{0}] platform[{1}] in {2}ms", config.getName(), config.getDatabasePlatform().getPlatform(), System.currentTimeMillis() - start);
|
||||||
return server;
|
return server;
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -137,7 +136,7 @@ public final class DefaultContainer implements SpiContainer {
|
|||||||
private void checkMissingModulePathProvides() {
|
private void checkMissingModulePathProvides() {
|
||||||
URL servicesFile = ClassLoader.getSystemResource("META-INF/services/io.ebean.config.EntityClassRegister");
|
URL servicesFile = ClassLoader.getSystemResource("META-INF/services/io.ebean.config.EntityClassRegister");
|
||||||
if (servicesFile != null) {
|
if (servicesFile != null) {
|
||||||
log.error("module-info.java is probably missing 'provides io.ebean.config.EntityClassRegister with EbeanEntityRegister' clause. EntityClassRegister exists but was not service loaded.");
|
log.log(Level.ERROR, "module-info.java is probably missing 'provides io.ebean.config.EntityClassRegister with EbeanEntityRegister' clause. EntityClassRegister exists but was not service loaded.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +200,7 @@ public final class DefaultContainer implements SpiContainer {
|
|||||||
DatabasePlatform platform = config.getDatabasePlatform();
|
DatabasePlatform platform = config.getDatabasePlatform();
|
||||||
if (platform == null) {
|
if (platform == null) {
|
||||||
if (config.getTenantMode().isDynamicDataSource()) {
|
if (config.getTenantMode().isDynamicDataSource()) {
|
||||||
throw new IllegalStateException("DatabasePlatform must be explicitly set on DatabaseConfig for TenantMode "+config.getTenantMode());
|
throw new IllegalStateException("DatabasePlatform must be explicitly set on DatabaseConfig for TenantMode " + config.getTenantMode());
|
||||||
}
|
}
|
||||||
// automatically determine the platform
|
// automatically determine the platform
|
||||||
platform = new DatabasePlatformFactory().create(config);
|
platform = new DatabasePlatformFactory().create(config);
|
||||||
@@ -215,7 +214,7 @@ public final class DefaultContainer implements SpiContainer {
|
|||||||
*/
|
*/
|
||||||
private void setDataSource(DatabaseConfig config) {
|
private void setDataSource(DatabaseConfig config) {
|
||||||
if (isOfflineMode(config)) {
|
if (isOfflineMode(config)) {
|
||||||
log.debug("... DbOffline using platform [{}]", DbOffline.getPlatform());
|
log.log(Level.DEBUG, "... DbOffline using platform [{0}]", DbOffline.getPlatform());
|
||||||
} else {
|
} else {
|
||||||
InitDataSource.init(config);
|
InitDataSource.init(config);
|
||||||
}
|
}
|
||||||
@@ -251,7 +250,7 @@ public final class DefaultContainer implements SpiContainer {
|
|||||||
}
|
}
|
||||||
try (Connection connection = config.getDataSource().getConnection()) {
|
try (Connection connection = config.getDataSource().getConnection()) {
|
||||||
if (connection.getAutoCommit()) {
|
if (connection.getAutoCommit()) {
|
||||||
log.warn("DataSource [{}] has autoCommit defaulting to true!", config.getName());
|
log.log(Level.WARNING, "DataSource [{0}] has autoCommit defaulting to true!", config.getName());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
package io.ebeaninternal.server.core;
|
package io.ebeaninternal.server.core;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.config.QueryPlanCapture;
|
import io.ebean.config.QueryPlanCapture;
|
||||||
import io.ebean.config.QueryPlanListener;
|
import io.ebean.config.QueryPlanListener;
|
||||||
import io.ebean.meta.MetaQueryPlan;
|
import io.ebean.meta.MetaQueryPlan;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import static java.lang.System.Logger.Level.INFO;
|
||||||
|
|
||||||
final class DefaultQueryPlanListener implements QueryPlanListener {
|
final class DefaultQueryPlanListener implements QueryPlanListener {
|
||||||
|
|
||||||
static final QueryPlanListener INSTANT = new DefaultQueryPlanListener();
|
static final QueryPlanListener INSTANT = new DefaultQueryPlanListener();
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.QUERYPLAN");
|
private static final System.Logger log = AppLog.getLogger("io.ebean.QUERYPLAN");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(QueryPlanCapture capture) {
|
public void process(QueryPlanCapture capture) {
|
||||||
// better to log this in JSON form?
|
// better to log this in JSON form?
|
||||||
String dbName = capture.database().name();
|
String dbName = capture.database().name();
|
||||||
for (MetaQueryPlan plan : capture.plans()) {
|
for (MetaQueryPlan plan : capture.plans()) {
|
||||||
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
|
log.log(INFO, "queryPlan db:{0} label:{1} queryTimeMicros:{2} loc:{3} sql:{4} bind:{5} plan:{6}",
|
||||||
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
|
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
|
||||||
plan.sql(), plan.bind(), plan.plan());
|
plan.sql(), plan.bind(), plan.plan());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,49 +2,11 @@ package io.ebeaninternal.server.core;
|
|||||||
|
|
||||||
import io.avaje.lang.NonNullApi;
|
import io.avaje.lang.NonNullApi;
|
||||||
import io.avaje.lang.Nullable;
|
import io.avaje.lang.Nullable;
|
||||||
import io.ebean.AutoTune;
|
import io.ebean.*;
|
||||||
import io.ebean.BackgroundExecutor;
|
|
||||||
import io.ebean.BeanState;
|
|
||||||
import io.ebean.CallableSql;
|
|
||||||
import io.ebean.DocumentStore;
|
|
||||||
import io.ebean.DtoQuery;
|
|
||||||
import io.ebean.ExpressionFactory;
|
|
||||||
import io.ebean.ExpressionList;
|
|
||||||
import io.ebean.ExtendedServer;
|
|
||||||
import io.ebean.Filter;
|
|
||||||
import io.ebean.FutureIds;
|
|
||||||
import io.ebean.FutureList;
|
|
||||||
import io.ebean.FutureRowCount;
|
|
||||||
import io.ebean.MergeOptions;
|
|
||||||
import io.ebean.MergeOptionsBuilder;
|
|
||||||
import io.ebean.PagedList;
|
|
||||||
import io.ebean.PersistenceContextScope;
|
|
||||||
import io.ebean.ProfileLocation;
|
|
||||||
import io.ebean.Query;
|
|
||||||
import io.ebean.QueryIterator;
|
|
||||||
import io.ebean.RowConsumer;
|
|
||||||
import io.ebean.RowMapper;
|
|
||||||
import io.ebean.ScriptRunner;
|
|
||||||
import io.ebean.SqlQuery;
|
|
||||||
import io.ebean.SqlRow;
|
|
||||||
import io.ebean.SqlUpdate;
|
|
||||||
import io.ebean.Transaction;
|
|
||||||
import io.ebean.TransactionCallback;
|
|
||||||
import io.ebean.TxScope;
|
|
||||||
import io.ebean.Update;
|
|
||||||
import io.ebean.UpdateQuery;
|
|
||||||
import io.ebean.ValuePair;
|
|
||||||
import io.ebean.Version;
|
|
||||||
import io.ebean.annotation.Platform;
|
import io.ebean.annotation.Platform;
|
||||||
import io.ebean.annotation.TxIsolation;
|
import io.ebean.annotation.TxIsolation;
|
||||||
import io.ebean.bean.BeanCollection;
|
import io.ebean.bean.*;
|
||||||
import io.ebean.bean.BeanLoader;
|
|
||||||
import io.ebean.bean.CallOrigin;
|
|
||||||
import io.ebean.bean.EntityBean;
|
|
||||||
import io.ebean.bean.EntityBeanIntercept;
|
|
||||||
import io.ebean.bean.PersistenceContext;
|
|
||||||
import io.ebean.bean.PersistenceContext.WithOption;
|
import io.ebean.bean.PersistenceContext.WithOption;
|
||||||
import io.ebean.bean.SingleBeanLoader;
|
|
||||||
import io.ebean.cache.ServerCacheManager;
|
import io.ebean.cache.ServerCacheManager;
|
||||||
import io.ebean.common.CopyOnFirstWriteList;
|
import io.ebean.common.CopyOnFirstWriteList;
|
||||||
import io.ebean.config.*;
|
import io.ebean.config.*;
|
||||||
@@ -53,11 +15,7 @@ import io.ebean.event.BeanPersistController;
|
|||||||
import io.ebean.event.ShutdownManager;
|
import io.ebean.event.ShutdownManager;
|
||||||
import io.ebean.event.readaudit.ReadAuditLogger;
|
import io.ebean.event.readaudit.ReadAuditLogger;
|
||||||
import io.ebean.event.readaudit.ReadAuditPrepare;
|
import io.ebean.event.readaudit.ReadAuditPrepare;
|
||||||
import io.ebean.meta.MetaInfoManager;
|
import io.ebean.meta.*;
|
||||||
import io.ebean.meta.MetaQueryPlan;
|
|
||||||
import io.ebean.meta.MetricVisitor;
|
|
||||||
import io.ebean.meta.QueryPlanInit;
|
|
||||||
import io.ebean.meta.QueryPlanRequest;
|
|
||||||
import io.ebean.migration.auto.AutoMigrationRunner;
|
import io.ebean.migration.auto.AutoMigrationRunner;
|
||||||
import io.ebean.plugin.BeanType;
|
import io.ebean.plugin.BeanType;
|
||||||
import io.ebean.plugin.Plugin;
|
import io.ebean.plugin.Plugin;
|
||||||
@@ -78,21 +36,8 @@ import io.ebeaninternal.server.dto.DtoBeanDescriptor;
|
|||||||
import io.ebeaninternal.server.dto.DtoBeanManager;
|
import io.ebeaninternal.server.dto.DtoBeanManager;
|
||||||
import io.ebeaninternal.server.el.ElFilter;
|
import io.ebeaninternal.server.el.ElFilter;
|
||||||
import io.ebeaninternal.server.grammer.EqlParser;
|
import io.ebeaninternal.server.grammer.EqlParser;
|
||||||
import io.ebeaninternal.server.query.CQuery;
|
import io.ebeaninternal.server.query.*;
|
||||||
import io.ebeaninternal.server.query.CQueryEngine;
|
import io.ebeaninternal.server.querydefn.*;
|
||||||
import io.ebeaninternal.server.query.CallableQueryCount;
|
|
||||||
import io.ebeaninternal.server.query.CallableQueryIds;
|
|
||||||
import io.ebeaninternal.server.query.CallableQueryList;
|
|
||||||
import io.ebeaninternal.server.query.DtoQueryEngine;
|
|
||||||
import io.ebeaninternal.server.query.LimitOffsetPagedList;
|
|
||||||
import io.ebeaninternal.server.query.QueryFutureIds;
|
|
||||||
import io.ebeaninternal.server.query.QueryFutureList;
|
|
||||||
import io.ebeaninternal.server.query.QueryFutureRowCount;
|
|
||||||
import io.ebeaninternal.server.querydefn.DefaultDtoQuery;
|
|
||||||
import io.ebeaninternal.server.querydefn.DefaultOrmQuery;
|
|
||||||
import io.ebeaninternal.server.querydefn.DefaultOrmUpdate;
|
|
||||||
import io.ebeaninternal.server.querydefn.DefaultRelationalQuery;
|
|
||||||
import io.ebeaninternal.server.querydefn.DefaultUpdateQuery;
|
|
||||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||||
import io.ebeaninternal.server.text.csv.TCsvReader;
|
import io.ebeaninternal.server.text.csv.TCsvReader;
|
||||||
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
||||||
@@ -101,12 +46,12 @@ import io.ebeaninternal.server.transaction.TransactionManager;
|
|||||||
import io.ebeaninternal.util.ParamTypeHelper;
|
import io.ebeaninternal.util.ParamTypeHelper;
|
||||||
import io.ebeaninternal.util.ParamTypeHelper.TypeInfo;
|
import io.ebeaninternal.util.ParamTypeHelper.TypeInfo;
|
||||||
import io.ebeanservice.docstore.api.DocStoreIntegration;
|
import io.ebeanservice.docstore.api.DocStoreIntegration;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.persistence.NonUniqueResultException;
|
import javax.persistence.NonUniqueResultException;
|
||||||
import javax.persistence.OptimisticLockException;
|
import javax.persistence.OptimisticLockException;
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -129,7 +74,7 @@ import static java.util.stream.StreamSupport.stream;
|
|||||||
@NonNullApi
|
@NonNullApi
|
||||||
public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
private final DatabaseConfig config;
|
private final DatabaseConfig config;
|
||||||
@@ -386,7 +331,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
if (config.isQueryPlanCapture()) {
|
if (config.isQueryPlanCapture()) {
|
||||||
long secs = config.getQueryPlanCapturePeriodSecs();
|
long secs = config.getQueryPlanCapturePeriodSecs();
|
||||||
if (secs > 10) {
|
if (secs > 10) {
|
||||||
log.info("capture query plan enabled, every {}secs", secs);
|
log.log(Level.INFO, "capture query plan enabled, every {0}secs", secs);
|
||||||
backgroundExecutor.scheduleWithFixedDelay(this::collectQueryPlans, secs, secs, TimeUnit.SECONDS);
|
backgroundExecutor.scheduleWithFixedDelay(this::collectQueryPlans, secs, secs, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -434,7 +379,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
* Shutdown the services like threads and DataSource.
|
* Shutdown the services like threads and DataSource.
|
||||||
*/
|
*/
|
||||||
private void shutdownInternal(boolean shutdownDataSource, boolean deregisterDriver) {
|
private void shutdownInternal(boolean shutdownDataSource, boolean deregisterDriver) {
|
||||||
log.trace("shutting down instance {}", serverName);
|
log.log(Level.TRACE, "shutting down instance {0}", serverName);
|
||||||
if (shutdown) {
|
if (shutdown) {
|
||||||
// already shutdown
|
// already shutdown
|
||||||
return;
|
return;
|
||||||
@@ -463,7 +408,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
try {
|
try {
|
||||||
plugin.shutdown();
|
plugin.shutdown();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error when shutting down plugin", e);
|
log.log(Level.ERROR, "Error when shutting down plugin", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2038,7 +1983,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
return desc(bean.getClass()).getId(eb);
|
return desc(bean.getClass()).getId(eb);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> BeanDescriptor<T> desc(Class<T> beanClass) {
|
private <T> BeanDescriptor<T> desc(Class<T> beanClass) {
|
||||||
BeanDescriptor<T> desc = descriptorManager.descriptor(beanClass);
|
BeanDescriptor<T> desc = descriptorManager.descriptor(beanClass);
|
||||||
if (desc == null) {
|
if (desc == null) {
|
||||||
throw new PersistenceException(beanClass.getName() + " is NOT an Entity Bean registered with this server?");
|
throw new PersistenceException(beanClass.getName() + " is NOT an Entity Bean registered with this server?");
|
||||||
@@ -2130,7 +2075,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
try {
|
try {
|
||||||
serverCacheManager.clearLocal(Class.forName(cache));
|
serverCacheManager.clearLocal(Class.forName(cache));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error clearing local cache for type " + cache, e);
|
log.log(Level.ERROR, "Error clearing local cache for type " + cache, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
package io.ebeaninternal.server.core;
|
package io.ebeaninternal.server.core;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.bean.ObjectGraphNode;
|
import io.ebean.bean.ObjectGraphNode;
|
||||||
import io.ebean.config.SlowQueryEvent;
|
import io.ebean.config.SlowQueryEvent;
|
||||||
import io.ebean.config.SlowQueryListener;
|
import io.ebean.config.SlowQueryListener;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default slow query listener implementation that logs a warning message.
|
* Default slow query listener implementation that logs a warning message.
|
||||||
*/
|
*/
|
||||||
final class DefaultSlowQueryListener implements SlowQueryListener {
|
final class DefaultSlowQueryListener implements SlowQueryListener {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.SlowQuery");
|
private static final System.Logger log = AppLog.getLogger("io.ebean.SlowQuery");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(SlowQueryEvent event) {
|
public void process(SlowQueryEvent event) {
|
||||||
@@ -20,6 +21,6 @@ final class DefaultSlowQueryListener implements SlowQueryListener {
|
|||||||
if (node != null) {
|
if (node != null) {
|
||||||
firstStack = node.getOriginQueryPoint().getTopElement();
|
firstStack = node.getOriginQueryPoint().getTopElement();
|
||||||
}
|
}
|
||||||
log.warn("Slow query warning - millis:{} rows:{} caller[{}] sql[{}]", event.getTimeMillis(), event.getRowCount(), firstStack, event.getSql());
|
log.log(WARNING, "Slow query warning - millis:{0} rows:{1} caller[{2}] sql[{3}]", event.getTimeMillis(), event.getRowCount(), firstStack, event.getSql());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import io.ebeaninternal.xmapping.api.XmapDto;
|
|||||||
import io.ebeaninternal.xmapping.api.XmapEbean;
|
import io.ebeaninternal.xmapping.api.XmapEbean;
|
||||||
import io.ebeaninternal.xmapping.api.XmapRawSql;
|
import io.ebeaninternal.xmapping.api.XmapRawSql;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -55,7 +56,7 @@ final class InternalConfigXmlMap {
|
|||||||
try {
|
try {
|
||||||
dtoClass = Class.forName(dto.getClazz(), false, classLoader);
|
dtoClass = Class.forName(dto.getClazz(), false, classLoader);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CoreLog.internal.error("Could not load dto bean class " + dto.getClazz() + " for ebean xml entry");
|
CoreLog.internal.log(Level.ERROR, "Could not load dto bean class " + dto.getClazz() + " for ebean xml entry");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DtoNamedQueries namedQueries = dtoNamedQueries.computeIfAbsent(dtoClass, aClass -> new DtoNamedQueries());
|
DtoNamedQueries namedQueries = dtoNamedQueries.computeIfAbsent(dtoClass, aClass -> new DtoNamedQueries());
|
||||||
|
|||||||
@@ -56,8 +56,8 @@ import io.ebeanservice.docstore.api.DocStoreFactory;
|
|||||||
import io.ebeanservice.docstore.api.DocStoreIntegration;
|
import io.ebeanservice.docstore.api.DocStoreIntegration;
|
||||||
import io.ebeanservice.docstore.api.DocStoreUpdateProcessor;
|
import io.ebeanservice.docstore.api.DocStoreUpdateProcessor;
|
||||||
import io.ebeanservice.docstore.none.NoneDocStoreFactory;
|
import io.ebeanservice.docstore.none.NoneDocStoreFactory;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -66,7 +66,7 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public final class InternalConfiguration {
|
public final class InternalConfiguration {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final TableModState tableModState;
|
private final TableModState tableModState;
|
||||||
private final boolean online;
|
private final boolean online;
|
||||||
@@ -246,7 +246,7 @@ public final class InternalConfiguration {
|
|||||||
*/
|
*/
|
||||||
ReadAuditLogger getReadAuditLogger() {
|
ReadAuditLogger getReadAuditLogger() {
|
||||||
ReadAuditLogger found = bootupClasses.getReadAuditLogger();
|
ReadAuditLogger found = bootupClasses.getReadAuditLogger();
|
||||||
return plugin(found != null ? found : jacksonCorePresent? new DefaultReadAuditLogger(): null);
|
return plugin(found != null ? found : jacksonCorePresent ? new DefaultReadAuditLogger() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -433,7 +433,7 @@ public final class InternalConfiguration {
|
|||||||
externalTransactionManager = new JtaTransactionManager();
|
externalTransactionManager = new JtaTransactionManager();
|
||||||
}
|
}
|
||||||
if (externalTransactionManager != null) {
|
if (externalTransactionManager != null) {
|
||||||
log.info("Using Transaction Manager [" + externalTransactionManager.getClass() + "]");
|
log.log(Level.INFO, "Using Transaction Manager {0}", externalTransactionManager.getClass());
|
||||||
return new ExternalTransactionScopeManager(externalTransactionManager);
|
return new ExternalTransactionScopeManager(externalTransactionManager);
|
||||||
} else {
|
} else {
|
||||||
return new DefaultTransactionScopeManager();
|
return new DefaultTransactionScopeManager();
|
||||||
@@ -523,7 +523,7 @@ public final class InternalConfiguration {
|
|||||||
if (iterator.hasNext()) {
|
if (iterator.hasNext()) {
|
||||||
// use the cacheFactory (via classpath service loader)
|
// use the cacheFactory (via classpath service loader)
|
||||||
plugin = iterator.next();
|
plugin = iterator.next();
|
||||||
log.debug("using ServerCacheFactory {}", plugin.getClass());
|
log.log(Level.DEBUG, "using ServerCacheFactory {0}", plugin.getClass());
|
||||||
} else {
|
} else {
|
||||||
// use the built in default l2 caching which is local cache based
|
// use the built in default l2 caching which is local cache based
|
||||||
localL2Caching = true;
|
localL2Caching = true;
|
||||||
@@ -605,6 +605,7 @@ public final class InternalConfiguration {
|
|||||||
|
|
||||||
private static class NoopDdl implements SpiDdlGenerator {
|
private static class NoopDdl implements SpiDdlGenerator {
|
||||||
private final boolean ddlRun;
|
private final boolean ddlRun;
|
||||||
|
|
||||||
NoopDdl(boolean ddlRun) {
|
NoopDdl(boolean ddlRun) {
|
||||||
this.ddlRun = ddlRun;
|
this.ddlRun = ddlRun;
|
||||||
}
|
}
|
||||||
@@ -612,7 +613,7 @@ public final class InternalConfiguration {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(boolean online) {
|
public void execute(boolean online) {
|
||||||
if (online && ddlRun) {
|
if (online && ddlRun) {
|
||||||
CoreLog.log.error("Configured to run DDL but ebean-ddl-generator is not in the classpath (or ebean-test in the test classpath?)");
|
CoreLog.log.log(Level.ERROR, "Configured to run DDL but ebean-ddl-generator is not in the classpath (or ebean-test in the test classpath?)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ import java.util.*;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps the objects involved in executing a Query.
|
* Wraps the objects involved in executing a Query.
|
||||||
*/
|
*/
|
||||||
@@ -244,7 +246,7 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
|
|||||||
// Just log this and carry on. A previous exception has been
|
// Just log this and carry on. A previous exception has been
|
||||||
// thrown and if this rollback throws exception it likely means
|
// thrown and if this rollback throws exception it likely means
|
||||||
// that the connection is broken (and the dataSource and db will cleanup)
|
// that the connection is broken (and the dataSource and db will cleanup)
|
||||||
CoreLog.log.error("Error trying to rollback a transaction (after a prior exception thrown)", e);
|
CoreLog.log.log(ERROR, "Error trying to rollback a transaction (after a prior exception thrown)", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -4,8 +4,8 @@ import io.avaje.classpath.scanner.ClassPathScanner;
|
|||||||
import io.ebean.config.DatabaseConfig;
|
import io.ebean.config.DatabaseConfig;
|
||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import io.ebeaninternal.server.core.ClassPathScanners;
|
import io.ebeaninternal.server.core.ClassPathScanners;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class BootupClassPathSearch {
|
public class BootupClassPathSearch {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final List<String> packages;
|
private final List<String> packages;
|
||||||
private final List<ClassPathScanner> scanners;
|
private final List<ClassPathScanner> scanners;
|
||||||
@@ -42,7 +42,6 @@ public class BootupClassPathSearch {
|
|||||||
* Search the classPath for the classes we are interested in.
|
* Search the classPath for the classes we are interested in.
|
||||||
*/
|
*/
|
||||||
private BootupClasses getBootupClasses() {
|
private BootupClasses getBootupClasses() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BootupClasses bc = new BootupClasses();
|
BootupClasses bc = new BootupClasses();
|
||||||
|
|
||||||
@@ -59,7 +58,7 @@ public class BootupClassPathSearch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
long searchTime = System.currentTimeMillis() - st;
|
long searchTime = System.currentTimeMillis() - st;
|
||||||
log.debug("Classpath search entities[{}] searchTime[{}] in packages[{}]", bc.getEntities().size(), searchTime, packages);
|
log.log(Level.DEBUG, "Classpath search entities[{0}] searchTime[{1}] in packages[{2}]", bc.getEntities().size(), searchTime, packages);
|
||||||
return bc;
|
return bc;
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
|||||||
@@ -13,12 +13,12 @@ import io.ebean.event.readaudit.ReadAuditLogger;
|
|||||||
import io.ebean.event.readaudit.ReadAuditPrepare;
|
import io.ebean.event.readaudit.ReadAuditPrepare;
|
||||||
import io.ebean.util.AnnotationUtil;
|
import io.ebean.util.AnnotationUtil;
|
||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.persistence.AttributeConverter;
|
import javax.persistence.AttributeConverter;
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -31,7 +31,7 @@ import java.util.function.Predicate;
|
|||||||
*/
|
*/
|
||||||
public class BootupClasses implements Predicate<Class<?>> {
|
public class BootupClasses implements Predicate<Class<?>> {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final List<Class<?>> embeddableList = new ArrayList<>();
|
private final List<Class<?>> embeddableList = new ArrayList<>();
|
||||||
private final List<Class<?>> entityList = new ArrayList<>();
|
private final List<Class<?>> entityList = new ArrayList<>();
|
||||||
@@ -205,13 +205,13 @@ public class BootupClasses implements Predicate<Class<?>> {
|
|||||||
try {
|
try {
|
||||||
return cls.getConstructor().newInstance();
|
return cls.getConstructor().newInstance();
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
log.debug("Ignore/expected - no default constructor: " +e.getMessage());
|
log.log(Level.DEBUG, "Ignore/expected - no default constructor: " + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (logOnException) {
|
if (logOnException) {
|
||||||
// not expected but we log and carry on
|
// not expected but we log and carry on
|
||||||
log.error("Error creating " + cls, e);
|
log.log(Level.ERROR, "Error creating " + cls, e);
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package io.ebeaninternal.server.core.bootup;
|
|||||||
import io.ebean.util.StringHelper;
|
import io.ebean.util.StringHelper;
|
||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import io.ebeaninternal.util.UrlHelper;
|
import io.ebeaninternal.util.UrlHelper;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@@ -20,7 +20,7 @@ import java.util.jar.Manifest;
|
|||||||
*/
|
*/
|
||||||
class ManifestReader {
|
class ManifestReader {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final Set<String> packageSet = new HashSet<>();
|
private final Set<String> packageSet = new HashSet<>();
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
@@ -55,7 +55,6 @@ class ManifestReader {
|
|||||||
* Read all the specific manifest files and return the set of packages containing type query beans.
|
* Read all the specific manifest files and return the set of packages containing type query beans.
|
||||||
*/
|
*/
|
||||||
private Set<String> read(ClassLoader classLoader, String resourcePath) {
|
private Set<String> read(ClassLoader classLoader, String resourcePath) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Enumeration<URL> resources = classLoader.getResources(resourcePath);
|
Enumeration<URL> resources = classLoader.getResources(resourcePath);
|
||||||
while (resources.hasMoreElements()) {
|
while (resources.hasMoreElements()) {
|
||||||
@@ -64,7 +63,7 @@ class ManifestReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warn("Error reading " + resourcePath + " manifest resources", e);
|
log.log(Level.WARNING, "Error reading " + resourcePath + " manifest resources", e);
|
||||||
}
|
}
|
||||||
return packageSet;
|
return packageSet;
|
||||||
}
|
}
|
||||||
@@ -73,7 +72,6 @@ class ManifestReader {
|
|||||||
* Read the entity packages from the manifest.
|
* Read the entity packages from the manifest.
|
||||||
*/
|
*/
|
||||||
private void read(Manifest manifest) throws IOException {
|
private void read(Manifest manifest) throws IOException {
|
||||||
|
|
||||||
Attributes attributes = manifest.getMainAttributes();
|
Attributes attributes = manifest.getMainAttributes();
|
||||||
String agentOnlyUse = attributes.getValue("agent-use-only");
|
String agentOnlyUse = attributes.getValue("agent-use-only");
|
||||||
if (agentOnlyUse == null || !"true".equalsIgnoreCase(agentOnlyUse.trim())) {
|
if (agentOnlyUse == null || !"true".equalsIgnoreCase(agentOnlyUse.trim())) {
|
||||||
|
|||||||
@@ -54,11 +54,11 @@ import io.ebeanservice.docstore.api.DocStoreUpdates;
|
|||||||
import io.ebeanservice.docstore.api.mapping.DocMappingBuilder;
|
import io.ebeanservice.docstore.api.mapping.DocMappingBuilder;
|
||||||
import io.ebeanservice.docstore.api.mapping.DocPropertyMapping;
|
import io.ebeanservice.docstore.api.mapping.DocPropertyMapping;
|
||||||
import io.ebeanservice.docstore.api.mapping.DocumentMapping;
|
import io.ebeanservice.docstore.api.mapping.DocumentMapping;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
@@ -74,7 +74,7 @@ import static io.ebeaninternal.server.persist.DmlUtil.isNullOrZero;
|
|||||||
*/
|
*/
|
||||||
public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
public enum EntityType {
|
public enum EntityType {
|
||||||
ORM, EMBEDDED, VIEW, SQL, DOC
|
ORM, EMBEDDED, VIEW, SQL, DOC
|
||||||
@@ -494,9 +494,6 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
* as they are used to get the imported and exported properties.
|
* as they are used to get the imported and exported properties.
|
||||||
*/
|
*/
|
||||||
void initialiseId(BeanDescriptorInitContext initContext) {
|
void initialiseId(BeanDescriptorInitContext initContext) {
|
||||||
if (log.isTraceEnabled()) {
|
|
||||||
log.trace("BeanDescriptor initialise " + fullName);
|
|
||||||
}
|
|
||||||
if (draftable) {
|
if (draftable) {
|
||||||
initContext.addDraft(baseTable, draftTable);
|
initContext.addDraft(baseTable, draftTable);
|
||||||
}
|
}
|
||||||
@@ -795,7 +792,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
changeJson.flush();
|
changeJson.flush();
|
||||||
return beanChange(ChangeType.UPDATE, request.beanId(), changeJson.newJson(), changeJson.oldJson());
|
return beanChange(ChangeType.UPDATE, request.beanId(), changeJson.newJson(), changeJson.oldJson());
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
log.error("Failed to write ChangeLog entry for update", e);
|
log.log(Level.ERROR, "Failed to write ChangeLog entry for update", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -811,7 +808,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
jsonWriter.flush();
|
jsonWriter.flush();
|
||||||
return beanChange(ChangeType.INSERT, request.beanId(), writer.toString(), null);
|
return beanChange(ChangeType.INSERT, request.beanId(), writer.toString(), null);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to write ChangeLog entry for insert", e);
|
log.log(Level.ERROR, "Failed to write ChangeLog entry for insert", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2291,11 +2288,11 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
private ElComparator<T> createPropertyComparator(SortByClause.Property sortProp) {
|
private ElComparator<T> createPropertyComparator(SortByClause.Property sortProp) {
|
||||||
ElPropertyValue elGetValue = elGetValue(sortProp.getName());
|
ElPropertyValue elGetValue = elGetValue(sortProp.getName());
|
||||||
if (elGetValue == null) {
|
if (elGetValue == null) {
|
||||||
log.error("Sort property [" + sortProp + "] not found in " + beanType + ". Cannot sort.");
|
log.log(Level.ERROR, "Sort property [" + sortProp + "] not found in " + beanType + ". Cannot sort.");
|
||||||
return new ElComparatorNoop<>();
|
return new ElComparatorNoop<>();
|
||||||
}
|
}
|
||||||
if (elGetValue.isAssocMany()) {
|
if (elGetValue.isAssocMany()) {
|
||||||
log.error("Sort property [" + sortProp + "] in " + beanType + " is a many-property. Cannot sort.");
|
log.log(Level.ERROR, "Sort property [" + sortProp + "] in " + beanType + " is a many-property. Cannot sort.");
|
||||||
return new ElComparatorNoop<>();
|
return new ElComparatorNoop<>();
|
||||||
}
|
}
|
||||||
Boolean nullsHigh = sortProp.getNullsHigh();
|
Boolean nullsHigh = sortProp.getNullsHigh();
|
||||||
@@ -2771,7 +2768,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
|||||||
public void markAsDeleted(EntityBean bean) {
|
public void markAsDeleted(EntityBean bean) {
|
||||||
if (softDeleteProperty == null) {
|
if (softDeleteProperty == null) {
|
||||||
Object id = getId(bean);
|
Object id = getId(bean);
|
||||||
log.info("(Lazy) loading unsuccessful for type:{} id:{} - expecting when bean has been deleted", name(), id);
|
log.log(Level.INFO, "(Lazy) loading unsuccessful for type:{0} id:{1} - expecting when bean has been deleted", name(), id);
|
||||||
bean._ebean_getIntercept().setLazyLoadFailure(id);
|
bean._ebean_getIntercept().setLazyLoadFailure(id);
|
||||||
} else {
|
} else {
|
||||||
softDeleteValue(bean);
|
softDeleteValue(bean);
|
||||||
|
|||||||
+73
-73
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.server.deploy;
|
package io.ebeaninternal.server.deploy;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.bean.BeanCollection;
|
import io.ebean.bean.BeanCollection;
|
||||||
import io.ebean.bean.EntityBean;
|
import io.ebean.bean.EntityBean;
|
||||||
import io.ebean.bean.EntityBeanIntercept;
|
import io.ebean.bean.EntityBeanIntercept;
|
||||||
@@ -13,10 +14,9 @@ import io.ebeaninternal.server.core.CacheOptions;
|
|||||||
import io.ebeaninternal.server.core.PersistRequest;
|
import io.ebeaninternal.server.core.PersistRequest;
|
||||||
import io.ebeaninternal.server.core.PersistRequestBean;
|
import io.ebeaninternal.server.core.PersistRequestBean;
|
||||||
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
import io.ebeaninternal.server.transaction.DefaultPersistenceContext;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,12 +26,12 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
final class BeanDescriptorCacheHelp<T> {
|
final class BeanDescriptorCacheHelp<T> {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private static final Logger queryLog = LoggerFactory.getLogger("io.ebean.cache.QUERY");
|
private static final System.Logger queryLog = AppLog.getLogger("io.ebean.cache.QUERY");
|
||||||
private static final Logger beanLog = LoggerFactory.getLogger("io.ebean.cache.BEAN");
|
private static final System.Logger beanLog = AppLog.getLogger("io.ebean.cache.BEAN");
|
||||||
private static final Logger manyLog = LoggerFactory.getLogger("io.ebean.cache.COLL");
|
private static final System.Logger manyLog = AppLog.getLogger("io.ebean.cache.COLL");
|
||||||
private static final Logger natLog = LoggerFactory.getLogger("io.ebean.cache.NATKEY");
|
private static final System.Logger natLog = AppLog.getLogger("io.ebean.cache.NATKEY");
|
||||||
|
|
||||||
private final BeanDescriptor<T> desc;
|
private final BeanDescriptor<T> desc;
|
||||||
private final SpiCacheManager cacheManager;
|
private final SpiCacheManager cacheManager;
|
||||||
@@ -104,10 +104,10 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
void deriveNotifyFlags() {
|
void deriveNotifyFlags() {
|
||||||
cacheNotifyOnAll = (invalidateQueryCache || beanCache != null || queryCache != null);
|
cacheNotifyOnAll = (invalidateQueryCache || beanCache != null || queryCache != null);
|
||||||
cacheNotifyOnDelete = !cacheNotifyOnAll && isNotifyOnDeletes();
|
cacheNotifyOnDelete = !cacheNotifyOnAll && isNotifyOnDeletes();
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
if (cacheNotifyOnAll || cacheNotifyOnDelete) {
|
if (cacheNotifyOnAll || cacheNotifyOnDelete) {
|
||||||
String notifyMode = cacheNotifyOnAll ? "All" : "Delete";
|
String notifyMode = cacheNotifyOnAll ? "All" : "Delete";
|
||||||
log.debug("l2 caching on {} - beanCaching:{} queryCaching:{} notifyMode:{} ",
|
log.log(Level.DEBUG, "l2 caching on {0} - beanCaching:{1} queryCaching:{2} notifyMode:{3} ",
|
||||||
desc.fullName(), isBeanCaching(), isQueryCaching(), notifyMode);
|
desc.fullName(), isBeanCaching(), isQueryCaching(), notifyMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,8 +178,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
*/
|
*/
|
||||||
void queryCacheClear() {
|
void queryCacheClear() {
|
||||||
if (queryCache != null) {
|
if (queryCache != null) {
|
||||||
if (queryLog.isDebugEnabled()) {
|
if (queryLog.isLoggable(Level.DEBUG)) {
|
||||||
queryLog.debug(" CLEAR {}", cacheName);
|
queryLog.log(Level.DEBUG, " CLEAR {0}", cacheName);
|
||||||
}
|
}
|
||||||
queryCache.clear();
|
queryCache.clear();
|
||||||
}
|
}
|
||||||
@@ -202,11 +202,11 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
throw new IllegalStateException("No query cache enabled on " + desc + ". Need explicit @Cache(enableQueryCache=true)");
|
throw new IllegalStateException("No query cache enabled on " + desc + ". Need explicit @Cache(enableQueryCache=true)");
|
||||||
}
|
}
|
||||||
Object queryResult = queryCache.get(id);
|
Object queryResult = queryCache.get(id);
|
||||||
if (queryLog.isDebugEnabled()) {
|
if (queryLog.isLoggable(Level.DEBUG)) {
|
||||||
if (queryResult == null) {
|
if (queryResult == null) {
|
||||||
queryLog.debug(" GET {}({}) - cache miss", cacheName, id);
|
queryLog.log(Level.DEBUG, " GET {0}({1}) - cache miss", cacheName, id);
|
||||||
} else {
|
} else {
|
||||||
queryLog.debug(" GET {}({}) - hit", cacheName, id);
|
queryLog.log(Level.DEBUG, " GET {0}({1}) - hit", cacheName, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return queryResult;
|
return queryResult;
|
||||||
@@ -219,8 +219,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
if (queryCache == null) {
|
if (queryCache == null) {
|
||||||
throw new IllegalStateException("No query cache enabled on " + desc + ". Need explicit @Cache(enableQueryCache=true)");
|
throw new IllegalStateException("No query cache enabled on " + desc + ". Need explicit @Cache(enableQueryCache=true)");
|
||||||
}
|
}
|
||||||
if (queryLog.isDebugEnabled()) {
|
if (queryLog.isLoggable(Level.DEBUG)) {
|
||||||
queryLog.debug(" PUT {}({})", cacheName, id);
|
queryLog.log(Level.DEBUG, " PUT {0}({1})", cacheName, id);
|
||||||
}
|
}
|
||||||
queryCache.put(id, entry);
|
queryCache.put(id, entry);
|
||||||
}
|
}
|
||||||
@@ -228,16 +228,16 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
|
|
||||||
void manyPropRemove(String propertyName, Object parentId) {
|
void manyPropRemove(String propertyName, Object parentId) {
|
||||||
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
||||||
if (manyLog.isTraceEnabled()) {
|
if (manyLog.isLoggable(Level.TRACE)) {
|
||||||
manyLog.trace(" REMOVE {}({}).{}", cacheName, parentId, propertyName);
|
manyLog.log(Level.TRACE, " REMOVE {0}({1}).{2}", cacheName, parentId, propertyName);
|
||||||
}
|
}
|
||||||
collectionIdsCache.remove(parentId);
|
collectionIdsCache.remove(parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void manyPropClear(String propertyName) {
|
void manyPropClear(String propertyName) {
|
||||||
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
||||||
if (manyLog.isDebugEnabled()) {
|
if (manyLog.isLoggable(Level.DEBUG)) {
|
||||||
manyLog.debug(" CLEAR {}(*).{} ", cacheName, propertyName);
|
manyLog.log(Level.DEBUG, " CLEAR {0}(*).{1} ", cacheName, propertyName);
|
||||||
}
|
}
|
||||||
collectionIdsCache.clear();
|
collectionIdsCache.clear();
|
||||||
}
|
}
|
||||||
@@ -249,11 +249,11 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, propertyName);
|
||||||
CachedManyIds entry = (CachedManyIds) collectionIdsCache.get(parentId);
|
CachedManyIds entry = (CachedManyIds) collectionIdsCache.get(parentId);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
if (manyLog.isTraceEnabled()) {
|
if (manyLog.isLoggable(Level.TRACE)) {
|
||||||
manyLog.trace(" GET {}({}).{} - cache miss", cacheName, parentId, propertyName);
|
manyLog.log(Level.TRACE, " GET {0}({1}).{2} - cache miss", cacheName, parentId, propertyName);
|
||||||
}
|
}
|
||||||
} else if (manyLog.isDebugEnabled()) {
|
} else if (manyLog.isLoggable(Level.DEBUG)) {
|
||||||
manyLog.debug(" GET {}({}).{} - hit", cacheName, parentId, propertyName);
|
manyLog.log(Level.DEBUG, " GET {0}({1}).{2} - hit", cacheName, parentId, propertyName);
|
||||||
}
|
}
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
@@ -303,12 +303,12 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
changes.put(many.name(), asJson);
|
changes.put(many.name(), asJson);
|
||||||
|
|
||||||
CachedBeanData newData = data.update(changes, data.getVersion());
|
CachedBeanData newData = data.update(changes, data.getVersion());
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" UPDATE {}({}) changes:{}", cacheName, parentId, changes);
|
beanLog.log(Level.DEBUG, " UPDATE {0}({1}) changes:{2}", cacheName, parentId, changes);
|
||||||
}
|
}
|
||||||
beanCache.put(parentId, newData);
|
beanCache.put(parentId, newData);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error updating L2 cache", e);
|
log.log(Level.ERROR, "Error updating L2 cache", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -321,8 +321,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
|
|
||||||
void cachePutManyIds(Object parentId, String manyName, CachedManyIds entry) {
|
void cachePutManyIds(Object parentId, String manyName, CachedManyIds entry) {
|
||||||
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, manyName);
|
ServerCache collectionIdsCache = cacheManager.getCollectionIdsCache(beanType, manyName);
|
||||||
if (manyLog.isDebugEnabled()) {
|
if (manyLog.isLoggable(Level.DEBUG)) {
|
||||||
manyLog.debug(" PUT {}({}).{} - ids:{}", cacheName, parentId, manyName, entry);
|
manyLog.log(Level.DEBUG, " PUT {0}({1}).{2} - ids:{3}", cacheName, parentId, manyName, entry);
|
||||||
}
|
}
|
||||||
collectionIdsCache.put(parentId, entry);
|
collectionIdsCache.put(parentId, entry);
|
||||||
}
|
}
|
||||||
@@ -353,8 +353,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
return new BeanCacheResult<>();
|
return new BeanCacheResult<>();
|
||||||
}
|
}
|
||||||
Map<Object, Object> beanDataMap = beanCache.getAll(keys);
|
Map<Object, Object> beanDataMap = beanCache.getAll(keys);
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" MGET {}({}) - hits:{}", cacheName, ids, beanDataMap.keySet());
|
beanLog.log(Level.TRACE, " MGET {0}({1}) - hits:{2}", cacheName, ids, beanDataMap.keySet());
|
||||||
}
|
}
|
||||||
BeanCacheResult<T> result = new BeanCacheResult<>();
|
BeanCacheResult<T> result = new BeanCacheResult<>();
|
||||||
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
|
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
|
||||||
@@ -375,8 +375,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
|
|
||||||
// naturalKey -> Id map
|
// naturalKey -> Id map
|
||||||
Map<Object, Object> naturalKeyMap = naturalKeyCache.getAll(keys);
|
Map<Object, Object> naturalKeyMap = naturalKeyCache.getAll(keys);
|
||||||
if (natLog.isTraceEnabled()) {
|
if (natLog.isLoggable(Level.TRACE)) {
|
||||||
natLog.trace(" MLOOKUP {}({}) - hits:{}", cacheName, keys, naturalKeyMap);
|
natLog.log(Level.TRACE, " MLOOKUP {0}({1}) - hits:{2}", cacheName, keys, naturalKeyMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
BeanCacheResult<T> result = new BeanCacheResult<>();
|
BeanCacheResult<T> result = new BeanCacheResult<>();
|
||||||
@@ -392,8 +392,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
|
|
||||||
Set<Object> ids = new HashSet<>(naturalKeyMap.values());
|
Set<Object> ids = new HashSet<>(naturalKeyMap.values());
|
||||||
Map<Object, Object> beanDataMap = beanCache.getAll(ids);
|
Map<Object, Object> beanDataMap = beanCache.getAll(ids);
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" MGET {}({}) - hits:{}", cacheName, ids, beanDataMap.keySet());
|
beanLog.log(Level.TRACE, " MGET {0}({1}) - hits:{2}", cacheName, ids, beanDataMap.keySet());
|
||||||
}
|
}
|
||||||
// process the hits into beans etc
|
// process the hits into beans etc
|
||||||
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
|
for (Map.Entry<Object, Object> entry : beanDataMap.entrySet()) {
|
||||||
@@ -437,8 +437,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
*/
|
*/
|
||||||
void beanCacheClear() {
|
void beanCacheClear() {
|
||||||
if (beanCache != null) {
|
if (beanCache != null) {
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" CLEAR {}", cacheName);
|
beanLog.log(Level.DEBUG, " CLEAR {0}", cacheName);
|
||||||
}
|
}
|
||||||
beanCache.clear();
|
beanCache.clear();
|
||||||
}
|
}
|
||||||
@@ -507,14 +507,14 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" MPUT {}({})", cacheName, map.keySet());
|
beanLog.log(Level.DEBUG, " MPUT {0}({1})", cacheName, map.keySet());
|
||||||
}
|
}
|
||||||
getBeanCache().putAll(map);
|
getBeanCache().putAll(map);
|
||||||
|
|
||||||
if (natKeys != null && !natKeys.isEmpty()) {
|
if (natKeys != null && !natKeys.isEmpty()) {
|
||||||
if (natLog.isDebugEnabled()) {
|
if (natLog.isLoggable(Level.DEBUG)) {
|
||||||
natLog.debug(" MPUT {}({}, {})", cacheName, naturalKey, natKeys.keySet());
|
natLog.log(Level.DEBUG, " MPUT {0}({1}, {2})", cacheName, naturalKey, natKeys.keySet());
|
||||||
}
|
}
|
||||||
naturalKeyCache.putAll(natKeys);
|
naturalKeyCache.putAll(natKeys);
|
||||||
}
|
}
|
||||||
@@ -526,15 +526,15 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
void beanCachePutDirect(EntityBean bean) {
|
void beanCachePutDirect(EntityBean bean) {
|
||||||
CachedBeanData beanData = beanExtractData(desc, bean);
|
CachedBeanData beanData = beanExtractData(desc, bean);
|
||||||
String key = desc.cacheKeyForBean(bean);
|
String key = desc.cacheKeyForBean(bean);
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" PUT {}({}) data:{}", cacheName, key, beanData);
|
beanLog.log(Level.DEBUG, " PUT {0}({1}) data:{2}", cacheName, key, beanData);
|
||||||
}
|
}
|
||||||
getBeanCache().put(key, beanData);
|
getBeanCache().put(key, beanData);
|
||||||
if (naturalKey != null) {
|
if (naturalKey != null) {
|
||||||
String naturalKey = calculateNaturalKey(beanData);
|
String naturalKey = calculateNaturalKey(beanData);
|
||||||
if (naturalKey != null) {
|
if (naturalKey != null) {
|
||||||
if (natLog.isDebugEnabled()) {
|
if (natLog.isLoggable(Level.DEBUG)) {
|
||||||
natLog.debug(" PUT {}({}, {})", cacheName, naturalKey, key);
|
natLog.log(Level.DEBUG, " PUT {0}({1}, {2})", cacheName, naturalKey, key);
|
||||||
}
|
}
|
||||||
naturalKeyCache.put(naturalKey, key);
|
naturalKeyCache.put(naturalKey, key);
|
||||||
}
|
}
|
||||||
@@ -575,13 +575,13 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
private T beanCacheGetInternal(String key, Boolean readOnly, PersistenceContext context) {
|
private T beanCacheGetInternal(String key, Boolean readOnly, PersistenceContext context) {
|
||||||
CachedBeanData data = (CachedBeanData) getBeanCache().get(key);
|
CachedBeanData data = (CachedBeanData) getBeanCache().get(key);
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" GET {}({}) - cache miss", cacheName, key);
|
beanLog.log(Level.TRACE, " GET {0}({1}) - cache miss", cacheName, key);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" GET {}({}) - hit", cacheName, key);
|
beanLog.log(Level.TRACE, " GET {0}({1}) - hit", cacheName, key);
|
||||||
}
|
}
|
||||||
return convertToBean(key, readOnly, context, data);
|
return convertToBean(key, readOnly, context, data);
|
||||||
}
|
}
|
||||||
@@ -591,8 +591,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
if (cacheSharableBeans && !Boolean.FALSE.equals(readOnly)) {
|
if (cacheSharableBeans && !Boolean.FALSE.equals(readOnly)) {
|
||||||
Object bean = data.getSharableBean();
|
Object bean = data.getSharableBean();
|
||||||
if (bean != null) {
|
if (bean != null) {
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" GET {}({}) - hit shared bean", cacheName, id);
|
beanLog.log(Level.TRACE, " GET {0}({1}) - hit shared bean", cacheName, id);
|
||||||
}
|
}
|
||||||
if (desc.isReadAuditing()) {
|
if (desc.isReadAuditing()) {
|
||||||
desc.readAuditBean("l2", "", bean);
|
desc.readAuditBean("l2", "", bean);
|
||||||
@@ -680,8 +680,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
*/
|
*/
|
||||||
void beanCacheApplyInvalidate(Collection<String> keys) {
|
void beanCacheApplyInvalidate(Collection<String> keys) {
|
||||||
if (beanCache != null) {
|
if (beanCache != null) {
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" MREMOVE {}({})", cacheName, keys);
|
beanLog.log(Level.DEBUG, " MREMOVE {0}({1})", cacheName, keys);
|
||||||
}
|
}
|
||||||
beanCache.removeAll(new HashSet<>(keys));
|
beanCache.removeAll(new HashSet<>(keys));
|
||||||
}
|
}
|
||||||
@@ -700,8 +700,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<Object, Object> hits = getBeanCache().getAll(ebis.keySet());
|
Map<Object, Object> hits = getBeanCache().getAll(ebis.keySet());
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" MLOAD {}({}) - got hits ({})", cacheName, ebis.keySet(), hits.size());
|
beanLog.log(Level.TRACE, " MLOAD {0}({1}) - got hits ({2})", cacheName, ebis.keySet(), hits.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<EntityBeanIntercept> loaded = new HashSet<>();
|
Set<EntityBeanIntercept> loaded = new HashSet<>();
|
||||||
@@ -713,19 +713,19 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
CachedBeanData cacheData = (CachedBeanData) hit.getValue();
|
CachedBeanData cacheData = (CachedBeanData) hit.getValue();
|
||||||
|
|
||||||
if (lazyLoadProperty > -1 && !cacheData.isLoaded(propertyName)) {
|
if (lazyLoadProperty > -1 && !cacheData.isLoaded(propertyName)) {
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" load {}({}) - cache miss on property({})", cacheName, key, propertyName);
|
beanLog.log(Level.TRACE, " load {0}({1}) - cache miss on property({2})", cacheName, key, propertyName);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CachedBeanDataToBean.load(desc, ebi.getOwner(), cacheData, context);
|
CachedBeanDataToBean.load(desc, ebi.getOwner(), cacheData, context);
|
||||||
loaded.add(ebi);
|
loaded.add(ebi);
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" load {}({}) - hit", cacheName, key);
|
beanLog.log(Level.DEBUG, " load {0}({1}) - hit", cacheName, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ebis.isEmpty() && beanLog.isTraceEnabled()) {
|
if (!ebis.isEmpty() && beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" load {}({}) - cache miss", cacheName, ebis.keySet());
|
beanLog.log(Level.TRACE, " load {0}({1}) - cache miss", cacheName, ebis.keySet());
|
||||||
}
|
}
|
||||||
return loaded;
|
return loaded;
|
||||||
}
|
}
|
||||||
@@ -736,21 +736,21 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
boolean beanCacheLoad(EntityBean bean, EntityBeanIntercept ebi, String key, PersistenceContext context) {
|
boolean beanCacheLoad(EntityBean bean, EntityBeanIntercept ebi, String key, PersistenceContext context) {
|
||||||
CachedBeanData cacheData = (CachedBeanData) getBeanCache().get(key);
|
CachedBeanData cacheData = (CachedBeanData) getBeanCache().get(key);
|
||||||
if (cacheData == null) {
|
if (cacheData == null) {
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" LOAD {}({}) - cache miss", cacheName, key);
|
beanLog.log(Level.TRACE, " LOAD {0}({1}) - cache miss", cacheName, key);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int lazyLoadProperty = ebi.getLazyLoadPropertyIndex();
|
int lazyLoadProperty = ebi.getLazyLoadPropertyIndex();
|
||||||
if (lazyLoadProperty > -1 && !cacheData.isLoaded(ebi.getLazyLoadProperty())) {
|
if (lazyLoadProperty > -1 && !cacheData.isLoaded(ebi.getLazyLoadProperty())) {
|
||||||
if (beanLog.isTraceEnabled()) {
|
if (beanLog.isLoggable(Level.TRACE)) {
|
||||||
beanLog.trace(" LOAD {}({}) - cache miss on property({})", cacheName, key, ebi.getLazyLoadProperty());
|
beanLog.log(Level.TRACE, " LOAD {0}({1}) - cache miss on property({2})", cacheName, key, ebi.getLazyLoadProperty());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CachedBeanDataToBean.load(desc, bean, cacheData, context);
|
CachedBeanDataToBean.load(desc, bean, cacheData, context);
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" LOAD {}({}) - hit", cacheName, key);
|
beanLog.log(Level.DEBUG, " LOAD {0}({1}) - hit", cacheName, key);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -874,8 +874,8 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
if (existingData != null) {
|
if (existingData != null) {
|
||||||
long currentVersion = existingData.getVersion();
|
long currentVersion = existingData.getVersion();
|
||||||
if (version > 0 && version < currentVersion) {
|
if (version > 0 && version < currentVersion) {
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" REMOVE {}({}) - version conflict old:{} new:{}", cacheName, key, currentVersion, version);
|
beanLog.log(Level.DEBUG, " REMOVE {0}({1}) - version conflict old:{2} new:{3}", cacheName, key, currentVersion, version);
|
||||||
}
|
}
|
||||||
cache.remove(key);
|
cache.remove(key);
|
||||||
} else {
|
} else {
|
||||||
@@ -883,16 +883,16 @@ final class BeanDescriptorCacheHelp<T> {
|
|||||||
version = currentVersion;
|
version = currentVersion;
|
||||||
}
|
}
|
||||||
CachedBeanData newData = existingData.update(changes, version);
|
CachedBeanData newData = existingData.update(changes, version);
|
||||||
if (beanLog.isDebugEnabled()) {
|
if (beanLog.isLoggable(Level.DEBUG)) {
|
||||||
beanLog.debug(" UPDATE {}({}) changes:{}", cacheName, key, changes);
|
beanLog.log(Level.DEBUG, " UPDATE {0}({1}) changes:{2}", cacheName, key, changes);
|
||||||
}
|
}
|
||||||
cache.put(key, newData);
|
cache.put(key, newData);
|
||||||
}
|
}
|
||||||
if (updateNaturalKey) {
|
if (updateNaturalKey) {
|
||||||
Object oldKey = calculateNaturalKey(existingData);
|
Object oldKey = calculateNaturalKey(existingData);
|
||||||
if (oldKey != null) {
|
if (oldKey != null) {
|
||||||
if (natLog.isDebugEnabled()) {
|
if (natLog.isLoggable(Level.DEBUG)) {
|
||||||
natLog.debug(".. update {} REMOVE({}) - old key for ({})", cacheName, oldKey, key);
|
natLog.log(Level.DEBUG, ".. update {0} REMOVE({1}) - old key for ({2})", cacheName, oldKey, key);
|
||||||
}
|
}
|
||||||
naturalKeyCache.remove(oldKey);
|
naturalKeyCache.remove(oldKey);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-15
@@ -41,13 +41,13 @@ import io.ebeaninternal.xmapping.api.XmapNamedQuery;
|
|||||||
import io.ebeaninternal.xmapping.api.XmapRawSql;
|
import io.ebeaninternal.xmapping.api.XmapRawSql;
|
||||||
import io.ebeanservice.docstore.api.DocStoreBeanAdapter;
|
import io.ebeanservice.docstore.api.DocStoreBeanAdapter;
|
||||||
import io.ebeanservice.docstore.api.DocStoreFactory;
|
import io.ebeanservice.docstore.api.DocStoreFactory;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -58,7 +58,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTypeManager {
|
public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTypeManager {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private static final BeanDescComparator beanDescComparator = new BeanDescComparator();
|
private static final BeanDescComparator beanDescComparator = new BeanDescComparator();
|
||||||
public static final String JAVA_LANG_RECORD = "java.lang.Record";
|
public static final String JAVA_LANG_RECORD = "java.lang.Record";
|
||||||
@@ -309,7 +309,7 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
} catch (BeanNotEnhancedException e) {
|
} catch (BeanNotEnhancedException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
log.error("Error in deployment", e);
|
log.log(Level.ERROR, "Error in deployment", e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -332,13 +332,13 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
try {
|
try {
|
||||||
entityClass = Class.forName(entityClassName, false, classLoader);
|
entityClass = Class.forName(entityClassName, false, classLoader);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Could not load entity bean class " + entityClassName + " for ebean.xml entry");
|
log.log(Level.ERROR, "Could not load entity bean class " + entityClassName + " for ebean.xml entry");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeployBeanInfo<?> info = deployInfoMap.get(entityClass);
|
DeployBeanInfo<?> info = deployInfoMap.get(entityClass);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
log.error("No entity bean for ebean.xml entry " + entityClassName);
|
log.log(Level.ERROR, "No entity bean for ebean.xml entry " + entityClassName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (XmapRawSql sql : entityDeploy.getRawSql()) {
|
for (XmapRawSql sql : entityDeploy.getRawSql()) {
|
||||||
@@ -601,11 +601,11 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
int pc = postConstructManager.getRegisterCount();
|
int pc = postConstructManager.getRegisterCount();
|
||||||
int lc = persistListenerManager.getRegisterCount();
|
int lc = persistListenerManager.getRegisterCount();
|
||||||
int fc = beanFinderManager.getRegisterCount();
|
int fc = beanFinderManager.getRegisterCount();
|
||||||
log.debug("BeanPersistControllers[{}] BeanFinders[{}] BeanPersistListeners[{}] BeanQueryAdapters[{}] BeanPostLoaders[{}] BeanPostConstructors[{}]", cc, fc, lc, qa, pl, pc);
|
log.log(Level.DEBUG, "BeanPersistControllers[{0}] BeanFinders[{1}] BeanPersistListeners[{2}] BeanQueryAdapters[{3}] BeanPostLoaders[{4}] BeanPostConstructors[{5}]", cc, fc, lc, qa, pl, pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logStatus() {
|
private void logStatus() {
|
||||||
log.debug("Entities[{}]", entityBeanCount);
|
log.log(Level.DEBUG, "Entities[{0}]", entityBeanCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -865,13 +865,13 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
for (String possibleMappedBy : matchSet) {
|
for (String possibleMappedBy : matchSet) {
|
||||||
String possibleLower = possibleMappedBy.toLowerCase();
|
String possibleLower = possibleMappedBy.toLowerCase();
|
||||||
if (possibleLower.contains(searchName)) {
|
if (possibleLower.contains(searchName)) {
|
||||||
// we have a match..
|
// we have a match
|
||||||
prop.setMappedBy(possibleMappedBy);
|
prop.setMappedBy(possibleMappedBy);
|
||||||
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
String m = "Implicitly found mappedBy for " + targetDesc + "." + prop;
|
String m = "Implicitly found mappedBy for " + targetDesc + "." + prop;
|
||||||
m += " by searching for [" + searchName + "] against " + matchSet;
|
m += " by searching for [" + searchName + "] against " + matchSet;
|
||||||
log.debug(m);
|
log.log(Level.DEBUG, m);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1207,12 +1207,12 @@ public final class BeanDescriptorManager implements BeanDescriptorMap, SpiBeanTy
|
|||||||
final DeployIdentityMode identityMode = desc.getIdentityMode();
|
final DeployIdentityMode identityMode = desc.getIdentityMode();
|
||||||
if (identityMode.isSequence() && !dbIdentity.isSupportsSequence()) {
|
if (identityMode.isSequence() && !dbIdentity.isSupportsSequence()) {
|
||||||
// explicit sequence but not supported by the DatabasePlatform
|
// explicit sequence but not supported by the DatabasePlatform
|
||||||
log.info("Explicit sequence on " + desc.getFullName() + " but not supported by DB Platform - ignored");
|
log.log(Level.INFO, "Explicit sequence on {0} but not supported by DB Platform - ignored", desc.getFullName());
|
||||||
identityMode.setIdType(IdType.AUTO);
|
identityMode.setIdType(IdType.AUTO);
|
||||||
}
|
}
|
||||||
if (identityMode.isIdentity() && !dbIdentity.isSupportsIdentity()) {
|
if (identityMode.isIdentity() && !dbIdentity.isSupportsIdentity()) {
|
||||||
// explicit identity but not supported by the DatabasePlatform
|
// explicit identity but not supported by the DatabasePlatform
|
||||||
log.info("Explicit Identity on " + desc.getFullName() + " but not supported by DB Platform - ignored");
|
log.log(Level.INFO, "Explicit Identity on {0} but not supported by DB Platform - ignored", desc.getFullName());
|
||||||
identityMode.setIdType(IdType.AUTO);
|
identityMode.setIdType(IdType.AUTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,16 +4,17 @@ import io.ebean.event.BeanFindController;
|
|||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
import io.ebeaninternal.server.core.bootup.BootupClasses;
|
||||||
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation for BeanFinderFactory.
|
* Default implementation for BeanFinderFactory.
|
||||||
*/
|
*/
|
||||||
final class BeanFinderManager {
|
final class BeanFinderManager {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final List<BeanFindController> list;
|
private final List<BeanFindController> list;
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@ final class BeanFinderManager {
|
|||||||
void addFindControllers(DeployBeanDescriptor<?> deployDesc) {
|
void addFindControllers(DeployBeanDescriptor<?> deployDesc) {
|
||||||
for (BeanFindController c : list) {
|
for (BeanFindController c : list) {
|
||||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||||
log.debug("BeanFindController on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
log.log(DEBUG, "BeanFindController on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||||
deployDesc.setBeanFinder(c);
|
deployDesc.setBeanFinder(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import javax.persistence.PersistenceException;
|
|||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
@@ -1433,7 +1434,7 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
|
|||||||
objValue = null;
|
objValue = null;
|
||||||
String msg = "Error trying to use Jackson ObjectMapper to read transient property "
|
String msg = "Error trying to use Jackson ObjectMapper to read transient property "
|
||||||
+ fullName() + " - consider marking this property with @JsonIgnore";
|
+ fullName() + " - consider marking this property with @JsonIgnore";
|
||||||
CoreLog.log.error(msg, e);
|
CoreLog.log.log(Level.ERROR, msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (jsonDeserialize) {
|
if (jsonDeserialize) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import io.ebeanservice.docstore.api.mapping.DocPropertyMapping;
|
|||||||
import io.ebeanservice.docstore.api.support.DocStructure;
|
import io.ebeanservice.docstore.api.support.DocStructure;
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -432,7 +433,7 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
|
|||||||
if (!idProp.isEmbedded()) {
|
if (!idProp.isEmbedded()) {
|
||||||
// simple single scalar id
|
// simple single scalar id
|
||||||
if (cols.length != 1) {
|
if (cols.length != 1) {
|
||||||
CoreLog.log.error("No Imported Id column for [" + idProp + "] in table [" + join.getTable() + "]");
|
CoreLog.log.log(Level.ERROR, "No Imported Id column for [" + idProp + "] in table [" + join.getTable() + "]");
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
BeanProperty[] idProps = {idProp};
|
BeanProperty[] idProps = {idProp};
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import io.ebeaninternal.server.query.SqlBeanLoad;
|
|||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -667,7 +668,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
|||||||
}
|
}
|
||||||
} catch (PersistenceException e) {
|
} catch (PersistenceException e) {
|
||||||
// not found as individual scalar properties
|
// not found as individual scalar properties
|
||||||
CoreLog.log.error("Could not find a exported property?", e);
|
CoreLog.log.log(Level.ERROR, "Could not find a exported property?", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (idProp != null) {
|
if (idProp != null) {
|
||||||
@@ -962,7 +963,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
|||||||
setValue(bean, collection);
|
setValue(bean, collection);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CoreLog.log.error("Error setting value from L2 cache", e);
|
CoreLog.log.log(Level.ERROR, "Error setting value from L2 cache", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -975,7 +976,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
|
|||||||
}
|
}
|
||||||
return jsonWriteCollection(collection);
|
return jsonWriteCollection(collection);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CoreLog.log.error("Error building value element collection json for L2 cache", e);
|
CoreLog.log.log(Level.ERROR, "Error building value element collection json for L2 cache", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation for creating BeanControllers.
|
* Default implementation for creating BeanControllers.
|
||||||
*/
|
*/
|
||||||
@@ -28,7 +30,7 @@ final class BeanQueryAdapterManager {
|
|||||||
void addQueryAdapter(DeployBeanDescriptor<?> deployDesc) {
|
void addQueryAdapter(DeployBeanDescriptor<?> deployDesc) {
|
||||||
for (BeanQueryAdapter c : list) {
|
for (BeanQueryAdapter c : list) {
|
||||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||||
CoreLog.internal.debug("BeanQueryAdapter on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
CoreLog.internal.log(DEBUG, "BeanQueryAdapter on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||||
deployDesc.addQueryAdapter(c);
|
deployDesc.addQueryAdapter(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanTable;
|
|||||||
import io.ebeaninternal.server.deploy.meta.DeployTableJoin;
|
import io.ebeaninternal.server.deploy.meta.DeployTableJoin;
|
||||||
import io.ebeaninternal.server.deploy.meta.DeployTableJoinColumn;
|
import io.ebeaninternal.server.deploy.meta.DeployTableJoinColumn;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for associated beans in place of a BeanDescriptor. This is done to avoid
|
* Used for associated beans in place of a BeanDescriptor. This is done to avoid
|
||||||
@@ -105,7 +107,7 @@ public final class BeanTable {
|
|||||||
if (complexKey) {
|
if (complexKey) {
|
||||||
// just to copy the column name rather than prefix with the foreignKeyPrefix.
|
// just to copy the column name rather than prefix with the foreignKeyPrefix.
|
||||||
// I think that with complex keys this is the more common approach.
|
// I think that with complex keys this is the more common approach.
|
||||||
CoreLog.internal.debug("On table[{}] foreign key column [{}]", baseTable, lc);
|
CoreLog.internal.log(Level.DEBUG, "On table[{0}] foreign key column [{1}]", baseTable, lc);
|
||||||
fk = lc;
|
fk = lc;
|
||||||
}
|
}
|
||||||
if (sqlFormulaSelect != null) {
|
if (sqlFormulaSelect != null) {
|
||||||
|
|||||||
+3
-1
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation for creating BeanControllers.
|
* Default implementation for creating BeanControllers.
|
||||||
*/
|
*/
|
||||||
@@ -28,7 +30,7 @@ final class PersistControllerManager {
|
|||||||
void addPersistControllers(DeployBeanDescriptor<?> deployDesc) {
|
void addPersistControllers(DeployBeanDescriptor<?> deployDesc) {
|
||||||
for (BeanPersistController c : list) {
|
for (BeanPersistController c : list) {
|
||||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||||
CoreLog.log.debug("BeanPersistController on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
CoreLog.log.log(DEBUG, "BeanPersistController on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||||
deployDesc.addPersistController(c);
|
deployDesc.addPersistController(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages the assignment/registration of BeanPersistListener with their
|
* Manages the assignment/registration of BeanPersistListener with their
|
||||||
* respective DeployBeanDescriptor's.
|
* respective DeployBeanDescriptor's.
|
||||||
@@ -29,7 +31,7 @@ final class PersistListenerManager {
|
|||||||
<T> void addPersistListeners(DeployBeanDescriptor<T> deployDesc) {
|
<T> void addPersistListeners(DeployBeanDescriptor<T> deployDesc) {
|
||||||
for (BeanPersistListener listener : list) {
|
for (BeanPersistListener listener : list) {
|
||||||
if (listener.isRegisterFor(deployDesc.getBeanType())) {
|
if (listener.isRegisterFor(deployDesc.getBeanType())) {
|
||||||
CoreLog.log.debug("BeanPersistListener on[{}] {}", deployDesc.getFullName(), listener.getClass().getName());
|
CoreLog.log.log(DEBUG, "BeanPersistListener on[{0}] {1}", deployDesc.getFullName(), listener.getClass().getName());
|
||||||
deployDesc.addPersistListener(listener);
|
deployDesc.addPersistListener(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation for creating BeanControllers.
|
* Default implementation for creating BeanControllers.
|
||||||
*/
|
*/
|
||||||
@@ -28,7 +30,7 @@ final class PostConstructManager {
|
|||||||
void addPostConstructListeners(DeployBeanDescriptor<?> deployDesc) {
|
void addPostConstructListeners(DeployBeanDescriptor<?> deployDesc) {
|
||||||
for (BeanPostConstructListener c : list) {
|
for (BeanPostConstructListener c : list) {
|
||||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||||
CoreLog.log.debug("BeanPostLoad on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
CoreLog.log.log(DEBUG, "BeanPostLoad on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||||
deployDesc.addPostConstructListener(c);
|
deployDesc.addPostConstructListener(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import io.ebeaninternal.server.deploy.meta.DeployBeanDescriptor;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.DEBUG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation for creating BeanControllers.
|
* Default implementation for creating BeanControllers.
|
||||||
*/
|
*/
|
||||||
@@ -28,7 +30,7 @@ final class PostLoadManager {
|
|||||||
void addPostLoad(DeployBeanDescriptor<?> deployDesc) {
|
void addPostLoad(DeployBeanDescriptor<?> deployDesc) {
|
||||||
for (BeanPostLoad c : list) {
|
for (BeanPostLoad c : list) {
|
||||||
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
if (c.isRegisterFor(deployDesc.getBeanType())) {
|
||||||
CoreLog.log.debug("BeanPostLoad on[{}] {}", deployDesc.getFullName(), c.getClass().getName());
|
CoreLog.log.log(DEBUG, "BeanPostLoad on[{0}] {1}", deployDesc.getFullName(), c.getClass().getName());
|
||||||
deployDesc.addPostLoad(c);
|
deployDesc.addPostLoad(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -11,6 +11,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper object to classify BeanProperties into appropriate lists.
|
* Helper object to classify BeanProperties into appropriate lists.
|
||||||
*/
|
*/
|
||||||
@@ -222,7 +224,7 @@ public final class DeployBeanPropertyLists {
|
|||||||
if (versionProperty == null) {
|
if (versionProperty == null) {
|
||||||
versionProperty = prop;
|
versionProperty = prop;
|
||||||
} else {
|
} else {
|
||||||
CoreLog.internal.warn("Multiple @Version properties - property " + prop.fullName() + " not treated as a version property");
|
CoreLog.internal.log(WARNING, "Multiple @Version properties - property " + prop.fullName() + " not treated as a version property");
|
||||||
}
|
}
|
||||||
} else if (prop.isDraftDirty()) {
|
} else if (prop.isDraftDirty()) {
|
||||||
draftDirty = prop;
|
draftDirty = prop;
|
||||||
|
|||||||
+3
-2
@@ -15,6 +15,7 @@ import io.ebeaninternal.server.deploy.meta.DeployTableJoinColumn;
|
|||||||
import io.ebeaninternal.server.query.SqlJoinType;
|
import io.ebeaninternal.server.query.SqlJoinType;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read the deployment annotations for Associated One beans.
|
* Read the deployment annotations for Associated One beans.
|
||||||
@@ -213,10 +214,10 @@ final class AnnotationAssocOnes extends AnnotationAssoc {
|
|||||||
prop.setPrimaryKeyJoin(true);
|
prop.setPrimaryKeyJoin(true);
|
||||||
|
|
||||||
if (!primaryKeyJoin.name().isEmpty()) {
|
if (!primaryKeyJoin.name().isEmpty()) {
|
||||||
CoreLog.internal.info("Automatically determining join columns for @PrimaryKeyJoinColumn - ignoring PrimaryKeyJoinColumn.name attribute [{}] on {}", primaryKeyJoin.name(), prop.getFullBeanName());
|
CoreLog.internal.log(Level.INFO, "Automatically determining join columns for @PrimaryKeyJoinColumn - ignoring PrimaryKeyJoinColumn.name attribute [{0}] on {1}", primaryKeyJoin.name(), prop.getFullBeanName());
|
||||||
}
|
}
|
||||||
if (!primaryKeyJoin.referencedColumnName().isEmpty()) {
|
if (!primaryKeyJoin.referencedColumnName().isEmpty()) {
|
||||||
CoreLog.internal.info("Automatically determining join columns for @PrimaryKeyJoinColumn - Ignoring PrimaryKeyJoinColumn.referencedColumnName attribute [{}] on {}", primaryKeyJoin.referencedColumnName(), prop.getFullBeanName());
|
CoreLog.internal.log(Level.INFO, "Automatically determining join columns for @PrimaryKeyJoinColumn - Ignoring PrimaryKeyJoinColumn.referencedColumnName attribute [{0}] on {1}", primaryKeyJoin.referencedColumnName(), prop.getFullBeanName());
|
||||||
}
|
}
|
||||||
BeanTable baseBeanTable = factory.beanTable(info.getDescriptor().getBeanType());
|
BeanTable baseBeanTable = factory.beanTable(info.getDescriptor().getBeanType());
|
||||||
String localPrimaryKey = baseBeanTable.getIdColumn();
|
String localPrimaryKey = baseBeanTable.getIdColumn();
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ import javax.persistence.NamedQuery;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
import static io.ebean.util.AnnotationUtil.typeGet;
|
import static io.ebean.util.AnnotationUtil.typeGet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,7 +67,7 @@ final class AnnotationClass extends AnnotationParser {
|
|||||||
Column column = override.column();
|
Column column = override.column();
|
||||||
DeployBeanProperty beanProperty = descriptor.getBeanProperty(propertyName);
|
DeployBeanProperty beanProperty = descriptor.getBeanProperty(propertyName);
|
||||||
if (beanProperty == null) {
|
if (beanProperty == null) {
|
||||||
CoreLog.log.error("AttributeOverride property [" + propertyName + "] not found on " + descriptor.getFullName());
|
CoreLog.log.log(Level.ERROR, "AttributeOverride property [" + propertyName + "] not found on " + descriptor.getFullName());
|
||||||
} else {
|
} else {
|
||||||
readColumn(column, beanProperty);
|
readColumn(column, beanProperty);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-4
@@ -11,6 +11,7 @@ import io.ebeaninternal.server.type.TypeManager;
|
|||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,7 +85,7 @@ public final class DeployCreateProperties {
|
|||||||
if (replaced != null && !replaced.isTransient()) {
|
if (replaced != null && !replaced.isTransient()) {
|
||||||
String msg = "Huh??? property " + prop.getFullBeanName() + " being defined twice";
|
String msg = "Huh??? property " + prop.getFullBeanName() + " being defined twice";
|
||||||
msg += " but replaced property was not transient? This is not expected?";
|
msg += " but replaced property was not transient? This is not expected?";
|
||||||
CoreLog.log.warn(msg);
|
CoreLog.log.log(Level.WARNING, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,7 +112,7 @@ public final class DeployCreateProperties {
|
|||||||
return new DeployBeanPropertySimpleCollection(desc, targetType, manyType);
|
return new DeployBeanPropertySimpleCollection(desc, targetType, manyType);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
CoreLog.internal.debug("expected non-scalar type {}", e.getMessage());
|
CoreLog.internal.log(Level.DEBUG, "expected non-scalar type {0}", e.getMessage());
|
||||||
}
|
}
|
||||||
return new DeployBeanPropertyAssocMany(desc, targetType, manyType);
|
return new DeployBeanPropertyAssocMany(desc, targetType, manyType);
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ public final class DeployCreateProperties {
|
|||||||
// not supporting this field (generic type used)
|
// not supporting this field (generic type used)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
CoreLog.internal.warn("Could not find parameter type (via reflection) on " + desc.getFullName() + " " + field.getName());
|
CoreLog.internal.log(Level.WARNING, "Could not find parameter type (via reflection) on " + desc.getFullName() + " " + field.getName());
|
||||||
}
|
}
|
||||||
return createManyType(desc, targetType, manyType);
|
return createManyType(desc, targetType, manyType);
|
||||||
}
|
}
|
||||||
@@ -151,7 +152,7 @@ public final class DeployCreateProperties {
|
|||||||
return new DeployBeanPropertyAssocOne(desc, propertyType);
|
return new DeployBeanPropertyAssocOne(desc, propertyType);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CoreLog.log.error("Error with " + desc + " field:" + field.getName(), e);
|
CoreLog.log.log(Level.ERROR, "Error with " + desc + " field:" + field.getName(), e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package io.ebeaninternal.server.dto;
|
|||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import io.ebeaninternal.server.type.TypeManager;
|
import io.ebeaninternal.server.type.TypeManager;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@@ -39,7 +40,7 @@ final class DtoMetaBuilder {
|
|||||||
final String name = propertyName(method.getName());
|
final String name = propertyName(method.getName());
|
||||||
properties.add(new DtoMetaProperty(typeManager, dtoType, method, name));
|
properties.add(new DtoMetaProperty(typeManager, dtoType, method, name));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CoreLog.log.debug("exclude on " + dtoType + " method " + method, e);
|
CoreLog.log.log(Level.DEBUG, "exclude on " + dtoType + " method " + method, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +78,7 @@ final class DtoMetaBuilder {
|
|||||||
constructorList.add(new DtoMetaConstructor(typeManager, constructor, dtoType));
|
constructorList.add(new DtoMetaConstructor(typeManager, constructor, dtoType));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// we don't want that constructor
|
// we don't want that constructor
|
||||||
CoreLog.log.debug("exclude on " + dtoType + " constructor " + constructor, e);
|
CoreLog.log.log(Level.DEBUG, "exclude on " + dtoType + " constructor " + constructor, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-8
@@ -1,9 +1,8 @@
|
|||||||
package io.ebeaninternal.server.executor;
|
package io.ebeaninternal.server.executor;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import java.lang.System.Logger.Level;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@@ -14,7 +13,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
final class DaemonExecutorService {
|
final class DaemonExecutorService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DaemonExecutorService.class);
|
private static final System.Logger logger = AppLog.getLogger(DaemonExecutorService.class);
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock(false);
|
private final ReentrantLock lock = new ReentrantLock(false);
|
||||||
private final String namePrefix;
|
private final String namePrefix;
|
||||||
@@ -44,19 +43,19 @@ final class DaemonExecutorService {
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
if (service.isShutdown()) {
|
if (service.isShutdown()) {
|
||||||
logger.debug("DaemonExecutorService[{}] already shut down", namePrefix);
|
logger.log(Level.DEBUG, "DaemonExecutorService[{0}] already shut down", namePrefix);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
logger.debug("DaemonExecutorService[{}] shutting down...", namePrefix);
|
logger.log(Level.DEBUG, "DaemonExecutorService[{0}] shutting down...", namePrefix);
|
||||||
service.shutdown();
|
service.shutdown();
|
||||||
if (!service.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) {
|
if (!service.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) {
|
||||||
logger.info("DaemonExecutorService[{}] shut down timeout exceeded. Terminating running threads.", namePrefix);
|
logger.log(Level.INFO, "DaemonExecutorService[{0}] shut down timeout exceeded. Terminating running threads.", namePrefix);
|
||||||
service.shutdownNow();
|
service.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error during shutdown of DaemonThreadPool[" + namePrefix + "]", e);
|
logger.log(Level.ERROR, "Error during shutdown of DaemonThreadPool[" + namePrefix + "]", e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+7
-7
@@ -1,8 +1,8 @@
|
|||||||
package io.ebeaninternal.server.executor;
|
package io.ebeaninternal.server.executor;
|
||||||
|
|
||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
@@ -12,7 +12,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
*/
|
*/
|
||||||
public final class DaemonScheduleThreadPool extends ScheduledThreadPoolExecutor {
|
public final class DaemonScheduleThreadPool extends ScheduledThreadPoolExecutor {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.log;
|
private static final System.Logger log = CoreLog.log;
|
||||||
|
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
private final String namePrefix;
|
private final String namePrefix;
|
||||||
@@ -38,19 +38,19 @@ public final class DaemonScheduleThreadPool extends ScheduledThreadPoolExecutor
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
if (super.isShutdown()) {
|
if (super.isShutdown()) {
|
||||||
log.debug("Already shutdown threadPool {}", namePrefix);
|
log.log(Level.DEBUG, "Already shutdown threadPool {0}", namePrefix);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
log.trace("shutting down threadPool {}", namePrefix);
|
log.log(Level.TRACE, "shutting down threadPool {0}", namePrefix);
|
||||||
super.shutdown();
|
super.shutdown();
|
||||||
if (!super.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) {
|
if (!super.awaitTermination(shutdownWaitSeconds, TimeUnit.SECONDS)) {
|
||||||
log.info("Shutdown wait timeout exceeded. Terminating running threads for {}", namePrefix);
|
log.log(Level.INFO, "Shutdown wait timeout exceeded. Terminating running threads for {0}", namePrefix);
|
||||||
super.shutdownNow();
|
super.shutdownNow();
|
||||||
}
|
}
|
||||||
log.trace("shutdown complete for threadPool {}", namePrefix);
|
log.log(Level.TRACE, "shutdown complete for threadPool {0}", namePrefix);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error during shutdown of threadPool " + namePrefix, e);
|
log.log(Level.ERROR, "Error during shutdown of threadPool " + namePrefix, e);
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
+12
-13
@@ -1,21 +1,20 @@
|
|||||||
package io.ebeaninternal.server.executor;
|
package io.ebeaninternal.server.executor;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.avaje.lang.NonNullApi;
|
import io.avaje.lang.NonNullApi;
|
||||||
import io.ebean.config.BackgroundExecutorWrapper;
|
import io.ebean.config.BackgroundExecutorWrapper;
|
||||||
import io.ebeaninternal.api.SpiBackgroundExecutor;
|
import io.ebeaninternal.api.SpiBackgroundExecutor;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default implementation of the BackgroundExecutor.
|
* The default implementation of the BackgroundExecutor.
|
||||||
*/
|
*/
|
||||||
@NonNullApi
|
@NonNullApi
|
||||||
public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.BackgroundExecutor");
|
private static final System.Logger log = AppLog.getLogger("io.ebean.BackgroundExecutor");
|
||||||
|
|
||||||
private final ScheduledExecutorService schedulePool;
|
private final ScheduledExecutorService schedulePool;
|
||||||
private final DaemonExecutorService pool;
|
private final DaemonExecutorService pool;
|
||||||
@@ -28,7 +27,7 @@ public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
|||||||
this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix + "-periodic-");
|
this.schedulePool = new DaemonScheduleThreadPool(schedulePoolSize, shutdownWaitSeconds, namePrefix + "-periodic-");
|
||||||
this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix);
|
this.pool = new DaemonExecutorService(shutdownWaitSeconds, namePrefix);
|
||||||
this.wrapper = wrapper;
|
this.wrapper = wrapper;
|
||||||
log.debug("Created backgroundExecutor {} (schedulePoolSize={}, shutdownWaitSeconds={})", namePrefix, schedulePoolSize, shutdownWaitSeconds);
|
log.log(Level.DEBUG, "Created backgroundExecutor {0} (schedulePoolSize={1}, shutdownWaitSeconds={2})", namePrefix, schedulePoolSize, shutdownWaitSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,20 +58,20 @@ public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
|||||||
* This is used in methods that accepts a <code>Runnable</code> and return
|
* This is used in methods that accepts a <code>Runnable</code> and return
|
||||||
* either <code>void</code> or <code>ScheduledFuture</code>, as there is
|
* either <code>void</code> or <code>ScheduledFuture</code>, as there is
|
||||||
* normally no Future.get() call.
|
* normally no Future.get() call.
|
||||||
*
|
* <p>
|
||||||
* Note: When submitting a <code>Callable</code>, you must check
|
* Note: When submitting a <code>Callable</code>, you must check
|
||||||
* <code>Future.get()</code> for exceptions.
|
* <code>Future.get()</code> for exceptions.
|
||||||
*/
|
*/
|
||||||
private Runnable logExceptions(Runnable task) {
|
private Runnable logExceptions(Runnable task) {
|
||||||
long queued = System.nanoTime();
|
long queued = System.nanoTime();
|
||||||
log.trace("Queued {}", task);
|
log.log(Level.TRACE, "Queued {0}", task);
|
||||||
return () -> {
|
return () -> {
|
||||||
try {
|
try {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isLoggable(Level.TRACE)) {
|
||||||
long start = System.nanoTime();
|
long start = System.nanoTime();
|
||||||
log.trace("Start {} (delay time {} us)", task, (start - queued) / 1000L);
|
log.log(Level.TRACE, "Start {0} (delay time {1} us)", task, (start - queued) / 1000L);
|
||||||
task.run();
|
task.run();
|
||||||
log.trace("Stop {} (exec time {} us)", task, (System.nanoTime() - start) / 1000L);
|
log.log(Level.TRACE, "Stop {0} (exec time {1} us)", task, (System.nanoTime() - start) / 1000L);
|
||||||
} else {
|
} else {
|
||||||
task.run();
|
task.run();
|
||||||
}
|
}
|
||||||
@@ -80,7 +79,7 @@ public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
|||||||
// log any exception here. Note they will not bubble up to the calling user
|
// log any exception here. Note they will not bubble up to the calling user
|
||||||
// unless Future.get() is checked. (Which is almost never done on scheduled
|
// unless Future.get() is checked. (Which is almost never done on scheduled
|
||||||
// background executions)
|
// background executions)
|
||||||
log.error("Error while executing the task {}", task, t);
|
log.log(Level.ERROR, "Error while executing the task " + task, t);
|
||||||
throw t;
|
throw t;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -128,10 +127,10 @@ public final class DefaultBackgroundExecutor implements SpiBackgroundExecutor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
log.trace("BackgroundExecutor shutting down");
|
log.log(Level.TRACE, "BackgroundExecutor shutting down");
|
||||||
schedulePool.shutdown();
|
schedulePool.shutdown();
|
||||||
pool.shutdown();
|
pool.shutdown();
|
||||||
log.debug("BackgroundExecutor stopped");
|
log.log(Level.DEBUG, "BackgroundExecutor stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.ebeaninternal.server.idgen;
|
package io.ebeaninternal.server.idgen;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -8,12 +9,11 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* IdGenerator for java util UUID.
|
* IdGenerator for java util UUID.
|
||||||
*
|
* <p>
|
||||||
* It extends the UuidV1RndIdGenerator so that it can generate rfc4122 compliant Type 1 UUIDs.
|
* It extends the UuidV1RndIdGenerator so that it can generate rfc4122 compliant Type 1 UUIDs.
|
||||||
*
|
* <p>
|
||||||
* This generator produces real Type 1 UUIDs (best for sqlserver) - You should use this generator only,
|
* This generator produces real Type 1 UUIDs (best for sqlserver) - You should use this generator only,
|
||||||
* if you can guarantee, that mac addess is uniqe or specify 'ebean.uuidNodeId' in your config file.
|
* if you can guarantee, that mac addess is uniqe or specify 'ebean.uuidNodeId' in your config file.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
* Returns an instance for given file.
|
* Returns an instance for given file.
|
||||||
*/
|
*/
|
||||||
public static UuidV1IdGenerator getInstance(File file, String nodeId) {
|
public static UuidV1IdGenerator getInstance(File file, String nodeId) {
|
||||||
return INSTANCES.computeIfAbsent(file, f ->new UuidV1IdGenerator(f, nodeId == null ? null : nodeId.toLowerCase()));
|
return INSTANCES.computeIfAbsent(file, f -> new UuidV1IdGenerator(f, nodeId == null ? null : nodeId.toLowerCase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,7 +60,7 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find hardware ID.
|
* Find hardware ID.
|
||||||
*
|
* <p>
|
||||||
* We check all non-loopback networkinterfaces for valid hardwareAddresses
|
* We check all non-loopback networkinterfaces for valid hardwareAddresses
|
||||||
* We prefer to take the first non virtual "up" device. If no device (with valid addr) is up,
|
* We prefer to take the first non virtual "up" device. If no device (with valid addr) is up,
|
||||||
* we take the first down device.
|
* we take the first down device.
|
||||||
@@ -71,21 +71,18 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
while (e.hasMoreElements()) {
|
while (e.hasMoreElements()) {
|
||||||
NetworkInterface network = e.nextElement();
|
NetworkInterface network = e.nextElement();
|
||||||
try {
|
try {
|
||||||
log.trace("Probing interface {}", network);
|
|
||||||
if (!network.isLoopback()) {
|
if (!network.isLoopback()) {
|
||||||
byte[] addr = network.getHardwareAddress();
|
byte[] addr = network.getHardwareAddress();
|
||||||
if (validAddr(addr)) {
|
if (validAddr(addr)) {
|
||||||
if (network.isUp() && !network.isVirtual()) {
|
if (network.isUp() && !network.isVirtual()) {
|
||||||
log.debug("Using interface {}", network);
|
|
||||||
return addr;
|
return addr;
|
||||||
} else if (fallbackAddr == null) {
|
} else if (fallbackAddr == null) {
|
||||||
log.debug("Using interface {} as fallback", network);
|
|
||||||
fallbackAddr = addr;
|
fallbackAddr = addr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SocketException ex) {
|
} catch (SocketException ex) {
|
||||||
log.debug("Skipping {}", network, ex);
|
log.log(Level.DEBUG, "Skipping " + network, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fallbackAddr;
|
return fallbackAddr;
|
||||||
@@ -98,7 +95,7 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
if (addr != null && addr.length >= 6) { // valid addr has 6 bytes
|
if (addr != null && addr.length >= 6) { // valid addr has 6 bytes
|
||||||
// check if vendor is != 0x000000 or 0xFFFFFF
|
// check if vendor is != 0x000000 or 0xFFFFFF
|
||||||
return (addr[0] != 0x00 && addr[1] != 0x00 && addr[2] != 0x00)
|
return (addr[0] != 0x00 && addr[1] != 0x00 && addr[2] != 0x00)
|
||||||
||(addr[0] != 0xFF && addr[1] != 0xFF && addr[2] != 0xFF);
|
|| (addr[0] != 0xFF && addr[1] != 0xFF && addr[2] != 0xFF);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -122,7 +119,7 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
// See, if there is an alternative MAC address set.
|
// See, if there is an alternative MAC address set.
|
||||||
nodeId = parseAlternativeNodeId(altNodeId);
|
nodeId = parseAlternativeNodeId(altNodeId);
|
||||||
restoreState();
|
restoreState();
|
||||||
log.info("Explicitly using ID {} to generate Type 1 UUIDs", getNodeIdentifier());
|
log.log(Level.INFO, "Explicitly using ID {0} to generate Type 1 UUIDs", getNodeIdentifier());
|
||||||
}
|
}
|
||||||
UUID uuid = nextId(null);
|
UUID uuid = nextId(null);
|
||||||
long ts = timeStamp.get();
|
long ts = timeStamp.get();
|
||||||
@@ -130,9 +127,9 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
ts /= MILLIS_TO_UUID;
|
ts /= MILLIS_TO_UUID;
|
||||||
|
|
||||||
saveState();
|
saveState();
|
||||||
log.debug("Saved state: clockSeq {}, timestamp {}, uuid {}, stateFile: {})", clockSeq.get(), new Date(ts), uuid, stateFile);
|
log.log(Level.DEBUG, "Saved state: clockSeq {0}, timestamp {1}, uuid {2}, stateFile: {3})", clockSeq.get(), new Date(ts), uuid, stateFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("There was a problem while detecting the nodeId. Falling back to random mode. Try using to specify 'ebean.uuidNodeId' property", e);
|
log.log(Level.ERROR, "There was a problem while detecting the nodeId. Falling back to random mode. Try using to specify 'ebean.uuidNodeId' property", e);
|
||||||
useRandomMode();
|
useRandomMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,16 +146,16 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
try {
|
try {
|
||||||
nodeId = getHardwareId();
|
nodeId = getHardwareId();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error while reading MAC address. Fall back to 'generate' mode", e);
|
log.log(Level.ERROR, "Error while reading MAC address. Fall back to 'generate' mode", e);
|
||||||
tryGenerateMode();
|
tryGenerateMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeId != null) {
|
if (nodeId != null) {
|
||||||
restoreState();
|
restoreState();
|
||||||
log.info("Using MAC {} to generate Type 1 UUIDs", getNodeIdentifier());
|
log.log(Level.INFO, "Using MAC {0} to generate Type 1 UUIDs", getNodeIdentifier());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
log.warn("No suitable network interface found. Fall back to 'generate' mode");
|
log.log(Level.WARNING, "No suitable network interface found. Fall back to 'generate' mode");
|
||||||
tryGenerateMode();
|
tryGenerateMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,11 +165,11 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
*/
|
*/
|
||||||
private void tryGenerateMode() throws IOException {
|
private void tryGenerateMode() throws IOException {
|
||||||
if (restoreState()) {
|
if (restoreState()) {
|
||||||
log.info("Using recently generated nodeId {} to generate Type 1 UUIDs", getNodeIdentifier());
|
log.log(Level.INFO, "Using recently generated nodeId {0} to generate Type 1 UUIDs", getNodeIdentifier());
|
||||||
} else {
|
} else {
|
||||||
// RFC 4.5 use random portion for node
|
// RFC 4.5 use random portion for node
|
||||||
nodeId = super.getNodeIdBytes();
|
nodeId = super.getNodeIdBytes();
|
||||||
log.info("Using a newly generated nodeId {} to generate Type 1 UUIDs", getNodeIdentifier());
|
log.log(Level.INFO, "Using a newly generated nodeId {0} to generate Type 1 UUIDs", getNodeIdentifier());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +180,7 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
private void useRandomMode() {
|
private void useRandomMode() {
|
||||||
canSaveState = false;
|
canSaveState = false;
|
||||||
nodeId = super.getNodeIdBytes();
|
nodeId = super.getNodeIdBytes();
|
||||||
log.info("Explicitly using a new random ID {} to generate Type 1 UUIDs", getNodeIdentifier());
|
log.log(Level.INFO, "Explicitly using a new random ID {0} to generate Type 1 UUIDs", getNodeIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -206,7 +203,6 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
private boolean restoreState() throws IOException {
|
private boolean restoreState() throws IOException {
|
||||||
Properties prop = new Properties();
|
Properties prop = new Properties();
|
||||||
if (!stateFile.exists()) {
|
if (!stateFile.exists()) {
|
||||||
log.debug("State file '{}' does not exist", stateFile);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try (InputStream is = new FileInputStream(stateFile)) {
|
try (InputStream is = new FileInputStream(stateFile)) {
|
||||||
@@ -215,28 +211,27 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
|
|
||||||
String propNodeId = prop.getProperty("nodeId");
|
String propNodeId = prop.getProperty("nodeId");
|
||||||
if (propNodeId == null || propNodeId.isEmpty()) {
|
if (propNodeId == null || propNodeId.isEmpty()) {
|
||||||
log.warn("State file '{}' is incomplete", stateFile);
|
log.log(Level.WARNING, "State file '{0}' is incomplete", stateFile);
|
||||||
return false; // we cannot restore
|
return false; // we cannot restore
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (nodeId == null) {
|
if (nodeId == null) {
|
||||||
nodeId = parseAlternativeNodeId(propNodeId);
|
nodeId = parseAlternativeNodeId(propNodeId);
|
||||||
} else if (!getNodeIdentifier().equals(propNodeId)) {
|
} else if (!getNodeIdentifier().equals(propNodeId)) {
|
||||||
log.warn(
|
log.log(Level.WARNING,
|
||||||
"The nodeId in the state file '{}' has changed from {} to {}. "
|
"The nodeId in the state file '{0}' has changed from {1} to {2}. "
|
||||||
+ "This can happen when MAC address changes or when two containers share the same state file",
|
+ "This can happen when MAC address changes or when two containers share the same state file",
|
||||||
stateFile, propNodeId, getNodeIdentifier());
|
stateFile, propNodeId, getNodeIdentifier());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Integer seq = Integer.valueOf(prop.getProperty("clockSeq")) & 0x3FFF;
|
Integer seq = Integer.valueOf(prop.getProperty("clockSeq")) & 0x3FFF;
|
||||||
Long ts = Long.valueOf(prop.getProperty("timeStamp"));
|
Long ts = Long.valueOf(prop.getProperty("timeStamp"));
|
||||||
clockSeq.set(seq);
|
clockSeq.set(seq);
|
||||||
timeStamp.set(ts);
|
timeStamp.set(ts);
|
||||||
log.debug("State successfully restored: {}", prop);
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} catch (IllegalArgumentException nfe) {
|
} catch (IllegalArgumentException nfe) {
|
||||||
log.error("State file '{}' is corrupt", stateFile, nfe);
|
log.log(Level.ERROR, "State file corrupt: " + stateFile, nfe);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -259,9 +254,8 @@ public class UuidV1IdGenerator extends UuidV1RndIdGenerator {
|
|||||||
}
|
}
|
||||||
try (OutputStream os = new FileOutputStream(stateFile)) {
|
try (OutputStream os = new FileOutputStream(stateFile)) {
|
||||||
prop.store(os, "ebean uuid state file");
|
prop.store(os, "ebean uuid state file");
|
||||||
log.debug("Persisted state to '{}'", stateFile);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Could not persist uuid state to '{}'", stateFile, e);
|
log.log(Level.ERROR, "Could not persist uuid state to: " + stateFile, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package io.ebeaninternal.server.idgen;
|
package io.ebeaninternal.server.idgen;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.Transaction;
|
import io.ebean.Transaction;
|
||||||
import io.ebean.config.dbplatform.PlatformIdGenerator;
|
import io.ebean.config.dbplatform.PlatformIdGenerator;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IdGenerator for (pseudo) type 1 UUIDs.
|
* IdGenerator for (pseudo) type 1 UUIDs.
|
||||||
*
|
*
|
||||||
@@ -27,7 +26,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class UuidV1RndIdGenerator implements PlatformIdGenerator {
|
public class UuidV1RndIdGenerator implements PlatformIdGenerator {
|
||||||
|
|
||||||
protected static final Logger log = LoggerFactory.getLogger("io.ebean.IDGEN");
|
protected static final System.Logger log = AppLog.getLogger("io.ebean.IDGEN");
|
||||||
|
|
||||||
// UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
|
// UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
|
||||||
protected static final long UUID_EPOCH_OFFSET = 0x01B21DD213814000L;
|
protected static final long UUID_EPOCH_OFFSET = 0x01B21DD213814000L;
|
||||||
@@ -106,7 +105,7 @@ public class UuidV1RndIdGenerator implements PlatformIdGenerator {
|
|||||||
|
|
||||||
delta = current - last;
|
delta = current - last;
|
||||||
if (delta < -10000 * 20000) {
|
if (delta < -10000 * 20000) {
|
||||||
log.info("Clock skew of {} ms detected", delta / -10000);
|
log.log(Level.INFO, "Clock skew of {} ms detected", delta / -10000);
|
||||||
// The clock was adjusted back about 2 seconds, or we were generating a lot of ids too fast
|
// The clock was adjusted back about 2 seconds, or we were generating a lot of ids too fast
|
||||||
// if so, we try to set the current as last and also increment the clockSeq.
|
// if so, we try to set the current as last and also increment the clockSeq.
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package io.ebeaninternal.server.logger;
|
package io.ebeaninternal.server.logger;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebeaninternal.api.SpiLogger;
|
import io.ebeaninternal.api.SpiLogger;
|
||||||
import io.ebeaninternal.api.SpiLoggerFactory;
|
import io.ebeaninternal.api.SpiLoggerFactory;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default SpiLoggerFactory implementation.
|
* Default SpiLoggerFactory implementation.
|
||||||
@@ -14,6 +14,6 @@ public final class DLoggerFactory implements SpiLoggerFactory {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SpiLogger create(String name) {
|
public SpiLogger create(String name) {
|
||||||
return new DSpiLogger(LoggerFactory.getLogger(name));
|
return new DSpiLogger(AppLog.getLogger(name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,33 +1,34 @@
|
|||||||
package io.ebeaninternal.server.logger;
|
package io.ebeaninternal.server.logger;
|
||||||
|
|
||||||
import io.ebeaninternal.api.SpiLogger;
|
import io.ebeaninternal.api.SpiLogger;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
final class DSpiLogger implements SpiLogger {
|
final class DSpiLogger implements SpiLogger {
|
||||||
|
|
||||||
private final Logger logger;
|
private final System.Logger logger;
|
||||||
|
|
||||||
DSpiLogger(Logger logger) {
|
DSpiLogger(System.Logger logger) {
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isDebug() {
|
public boolean isDebug() {
|
||||||
return logger.isDebugEnabled();
|
return logger.isLoggable(Level.DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTrace() {
|
public boolean isTrace() {
|
||||||
return logger.isTraceEnabled();
|
return logger.isLoggable(Level.TRACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void debug(String msg) {
|
public void debug(String msg) {
|
||||||
logger.debug(msg);
|
logger.log(Level.DEBUG, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void trace(String msg) {
|
public void trace(String msg) {
|
||||||
logger.trace(msg);
|
logger.log(Level.TRACE, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,7 @@ import io.ebeaninternal.api.SpiTransaction;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -135,7 +136,7 @@ public final class BatchedPstmt implements SpiProfileTransactionEvent {
|
|||||||
try {
|
try {
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.warn("BatchedPstmt Error closing statement", e);
|
CoreLog.log.log(Level.WARNING, "BatchedPstmt Error closing statement", e);
|
||||||
} finally {
|
} finally {
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
@@ -201,7 +202,7 @@ public final class BatchedPstmt implements SpiProfileTransactionEvent {
|
|||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoreLog.log.warn("BatchedPstmt Error closing inputStream ", e);
|
CoreLog.log.log(Level.WARNING, "BatchedPstmt Error closing inputStream ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputStreams = null;
|
inputStreams = null;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import io.ebeaninternal.server.persist.platform.MultiValueBind;
|
|||||||
import io.ebeaninternal.server.type.*;
|
import io.ebeaninternal.server.type.*;
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -132,7 +133,7 @@ public final class Binder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
CoreLog.log.warn("error binding parameter [{}][{}]", (dataBind.currentPos() - 1), value);
|
CoreLog.log.log(Level.WARNING, "error binding parameter [{0}][{1}]", (dataBind.currentPos() - 1), value);
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.server.persist;
|
package io.ebeaninternal.server.persist;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.*;
|
import io.ebean.*;
|
||||||
import io.ebean.bean.BeanCollection;
|
import io.ebean.bean.BeanCollection;
|
||||||
import io.ebean.bean.BeanCollection.ModifyListenMode;
|
import io.ebean.bean.BeanCollection.ModifyListenMode;
|
||||||
@@ -11,9 +12,8 @@ import io.ebeaninternal.api.*;
|
|||||||
import io.ebeaninternal.server.core.*;
|
import io.ebeaninternal.server.core.*;
|
||||||
import io.ebeaninternal.server.core.PersistRequest.Type;
|
import io.ebeaninternal.server.core.PersistRequest.Type;
|
||||||
import io.ebeaninternal.server.deploy.*;
|
import io.ebeaninternal.server.deploy.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public final class DefaultPersister implements Persister {
|
public final class DefaultPersister implements Persister {
|
||||||
|
|
||||||
private static final Logger PUB = LoggerFactory.getLogger("io.ebean.PUB");
|
private static final System.Logger PUB = AppLog.getLogger("io.ebean.PUB");
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actually does the persisting work.
|
* Actually does the persisting work.
|
||||||
@@ -143,7 +143,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
DraftHandler<T> draftHandler = new DraftHandler<>(desc, transaction);
|
DraftHandler<T> draftHandler = new DraftHandler<>(desc, transaction);
|
||||||
|
|
||||||
List<T> liveBeans = draftHandler.fetchSourceBeans(query, false);
|
List<T> liveBeans = draftHandler.fetchSourceBeans(query, false);
|
||||||
PUB.debug("draftRestore [{}] count[{}]", desc.name(), liveBeans.size());
|
PUB.log(Level.DEBUG, "draftRestore [{0}] count[{1}]", desc.name(), liveBeans.size());
|
||||||
if (liveBeans.isEmpty()) {
|
if (liveBeans.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@@ -156,11 +156,11 @@ public final class DefaultPersister implements Persister {
|
|||||||
// reset @DraftDirty and @DraftReset properties
|
// reset @DraftDirty and @DraftReset properties
|
||||||
draftHandler.resetDraft(draftBean);
|
draftHandler.resetDraft(draftBean);
|
||||||
|
|
||||||
PUB.trace("draftRestore bean [{}] id[{}]", desc.name(), draftHandler.getId());
|
PUB.log(Level.TRACE, "draftRestore bean [{0}] id[{1}]", desc.name(), draftHandler.getId());
|
||||||
update(createRequest(draftBean, transaction, null, mgr, Type.UPDATE, Flags.RECURSE));
|
update(createRequest(draftBean, transaction, null, mgr, Type.UPDATE, Flags.RECURSE));
|
||||||
}
|
}
|
||||||
|
|
||||||
PUB.debug("draftRestore - complete for [{}]", desc.name());
|
PUB.log(Level.DEBUG, "draftRestore - complete for [{0}]", desc.name());
|
||||||
return draftHandler.getDrafts();
|
return draftHandler.getDrafts();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
DraftHandler<T> draftHandler = new DraftHandler<>(desc, transaction);
|
DraftHandler<T> draftHandler = new DraftHandler<>(desc, transaction);
|
||||||
|
|
||||||
List<T> draftBeans = draftHandler.fetchSourceBeans(query, true);
|
List<T> draftBeans = draftHandler.fetchSourceBeans(query, true);
|
||||||
PUB.debug("publish [{}] count[{}]", desc.name(), draftBeans.size());
|
PUB.log(Level.DEBUG, "publish [{0}] count[{1}]", desc.name(), draftBeans.size());
|
||||||
if (draftBeans.isEmpty()) {
|
if (draftBeans.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
draftHandler.resetDraft(draftBean);
|
draftHandler.resetDraft(draftBean);
|
||||||
|
|
||||||
Type persistType = draftHandler.isInsert() ? Type.INSERT : Type.UPDATE;
|
Type persistType = draftHandler.isInsert() ? Type.INSERT : Type.UPDATE;
|
||||||
PUB.trace("publish bean [{}] id[{}] type[{}]", desc.name(), draftHandler.getId(), persistType);
|
PUB.log(Level.TRACE, "publish bean [{0}] id[{1}] type[{2}]", desc.name(), draftHandler.getId(), persistType);
|
||||||
|
|
||||||
PersistRequestBean<T> request = createRequest(liveBean, transaction, null, mgr, persistType, Flags.PUBLISH_RECURSE);
|
PersistRequestBean<T> request = createRequest(liveBean, transaction, null, mgr, persistType, Flags.PUBLISH_RECURSE);
|
||||||
if (persistType == Type.INSERT) {
|
if (persistType == Type.INSERT) {
|
||||||
@@ -214,7 +214,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
}
|
}
|
||||||
|
|
||||||
draftHandler.updateDrafts(transaction, mgr);
|
draftHandler.updateDrafts(transaction, mgr);
|
||||||
PUB.debug("publish - complete for [{}]", desc.name());
|
PUB.log(Level.DEBUG, "publish - complete for [{0}]", desc.name());
|
||||||
return livePublish;
|
return livePublish;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ public final class DefaultPersister implements Persister {
|
|||||||
void updateDrafts(Transaction transaction, BeanManager<T> mgr) {
|
void updateDrafts(Transaction transaction, BeanManager<T> mgr) {
|
||||||
if (!draftUpdates.isEmpty()) {
|
if (!draftUpdates.isEmpty()) {
|
||||||
// update the dirty status on the drafts that have been published
|
// update the dirty status on the drafts that have been published
|
||||||
PUB.debug("publish - update dirty status on [{}] drafts", draftUpdates.size());
|
PUB.log(Level.DEBUG, "publish - update dirty status on [{0}] drafts", draftUpdates.size());
|
||||||
for (T draftUpdate : draftUpdates) {
|
for (T draftUpdate : draftUpdates) {
|
||||||
update(createRequest(draftUpdate, transaction, null, mgr, Type.UPDATE, Flags.ZERO));
|
update(createRequest(draftUpdate, transaction, null, mgr, Type.UPDATE, Flags.ZERO));
|
||||||
}
|
}
|
||||||
@@ -491,8 +491,8 @@ public final class DefaultPersister implements Persister {
|
|||||||
}
|
}
|
||||||
if (request.isDirty()) {
|
if (request.isDirty()) {
|
||||||
request.executeOrQueue();
|
request.executeOrQueue();
|
||||||
} else if (log.isDebugEnabled()) {
|
} else if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("Update skipped as bean is unchanged: {}", request.bean());
|
log.log(Level.DEBUG, "Update skipped as bean is unchanged: {0}", request.bean());
|
||||||
}
|
}
|
||||||
if (request.isPersistCascade()) {
|
if (request.isPersistCascade()) {
|
||||||
// save all the beans in assocMany's after
|
// save all the beans in assocMany's after
|
||||||
@@ -538,8 +538,8 @@ public final class DefaultPersister implements Persister {
|
|||||||
if (req.isRegisteredForDeleteBean()) {
|
if (req.isRegisteredForDeleteBean()) {
|
||||||
// skip deleting bean. Used where cascade is on
|
// skip deleting bean. Used where cascade is on
|
||||||
// both sides of a relationship
|
// both sides of a relationship
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("skipping delete on alreadyRegistered {}", req.bean());
|
log.log(Level.DEBUG, "skipping delete on alreadyRegistered {0}", req.bean());
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import io.ebeaninternal.server.core.PersistRequestBean;
|
|||||||
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
import io.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base for saving entity bean collections and element collections.
|
* Base for saving entity bean collections and element collections.
|
||||||
@@ -71,7 +72,7 @@ abstract class SaveManyBase implements SaveMany {
|
|||||||
String asJson = many.jsonWriteCollection(value);
|
String asJson = many.jsonWriteCollection(value);
|
||||||
request.addCollectionChange(many.name(), asJson);
|
request.addCollectionChange(many.name(), asJson);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoreLog.log.error("Error build element collection entry for L2 cache", e);
|
CoreLog.log.log(Level.ERROR, "Error build element collection entry for L2 cache", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,7 +318,7 @@ final class SaveManyBeans extends SaveManyBase {
|
|||||||
if (transaction.isLogSummary()) {
|
if (transaction.isLogSummary()) {
|
||||||
transaction.logSummary(m);
|
transaction.logSummary(m);
|
||||||
}
|
}
|
||||||
CoreLog.log.warn(m);
|
CoreLog.log.log(System.Logger.Level.WARNING, m);
|
||||||
} else {
|
} else {
|
||||||
if (!many.hasImportedId(otherBean)) {
|
if (!many.hasImportedId(otherBean)) {
|
||||||
throw new PersistenceException("ManyToMany bean " + otherBean + " does not have an Id value.");
|
throw new PersistenceException("ManyToMany bean " + otherBean + " does not have an Id value.");
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for Handler implementations.
|
* Base class for Handler implementations.
|
||||||
*/
|
*/
|
||||||
@@ -123,7 +125,7 @@ public abstract class DmlHandler implements PersistHandler, BindableRequest {
|
|||||||
dataBind.close();
|
dataBind.close();
|
||||||
}
|
}
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
CoreLog.log.error(null, ex);
|
CoreLog.log.log(ERROR, "Error closing DataBind", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import java.sql.SQLException;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object that represents a SqlSelect statement.
|
* An object that represents a SqlSelect statement.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -344,7 +346,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
|||||||
auditIterateLogMessage();
|
auditIterateLogMessage();
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
CoreLog.log.error("Error logging read audit logs", e);
|
CoreLog.log.log(ERROR, "Error logging read audit logs", e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (dataReader != null) {
|
if (dataReader != null) {
|
||||||
@@ -352,7 +354,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
|||||||
dataReader = null;
|
dataReader = null;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.error("Error closing dataReader", e);
|
CoreLog.log.log(ERROR, "Error closing dataReader", e);
|
||||||
}
|
}
|
||||||
JdbcClose.close(pstmt);
|
JdbcClose.close(pstmt);
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
@@ -548,7 +550,7 @@ public final class CQuery<T> implements DbReadContext, CancelableQuery, SpiProfi
|
|||||||
}
|
}
|
||||||
transaction().profileEvent(this);
|
transaction().profileEvent(this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CoreLog.log.error("Error updating execution statistics", e);
|
CoreLog.log.log(ERROR, "Error updating execution statistics", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,16 +11,14 @@ import io.ebean.config.DatabaseConfig;
|
|||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||||
import io.ebean.util.JdbcClose;
|
import io.ebean.util.JdbcClose;
|
||||||
import io.ebean.util.StringHelper;
|
import io.ebean.util.StringHelper;
|
||||||
import io.ebeaninternal.api.CoreLog;
|
|
||||||
import io.ebeaninternal.api.SpiQuery;
|
import io.ebeaninternal.api.SpiQuery;
|
||||||
import io.ebeaninternal.api.SpiTransaction;
|
import io.ebeaninternal.api.SpiTransaction;
|
||||||
import io.ebeaninternal.server.core.DiffHelp;
|
import io.ebeaninternal.server.core.DiffHelp;
|
||||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||||
import io.ebeaninternal.server.core.SpiResultSet;
|
import io.ebeaninternal.server.core.SpiResultSet;
|
||||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||||
import io.ebeaninternal.server.util.Str;
|
|
||||||
import io.ebeaninternal.server.persist.Binder;
|
import io.ebeaninternal.server.persist.Binder;
|
||||||
import org.slf4j.Logger;
|
import io.ebeaninternal.server.util.Str;
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@@ -32,7 +30,6 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
public final class CQueryEngine {
|
public final class CQueryEngine {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.log;
|
|
||||||
private static final String T0 = "t0";
|
private static final String T0 = "t0";
|
||||||
|
|
||||||
private final int defaultFetchSizeFindList;
|
private final int defaultFetchSizeFindList;
|
||||||
@@ -195,7 +192,6 @@ public final class CQueryEngine {
|
|||||||
}
|
}
|
||||||
if (!cquery.prepareBindExecuteQueryForwardOnly(forwardOnlyHintOnFindIterate)) {
|
if (!cquery.prepareBindExecuteQueryForwardOnly(forwardOnlyHintOnFindIterate)) {
|
||||||
// query has been cancelled already
|
// query has been cancelled already
|
||||||
log.trace("Future fetch already cancelled");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (request.logSql()) {
|
if (request.logSql()) {
|
||||||
@@ -349,7 +345,6 @@ public final class CQueryEngine {
|
|||||||
}
|
}
|
||||||
if (!cquery.prepareBindExecuteQuery()) {
|
if (!cquery.prepareBindExecuteQuery()) {
|
||||||
// query has been cancelled already
|
// query has been cancelled already
|
||||||
log.trace("Future fetch already cancelled");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (request.logSql()) {
|
if (request.logSql()) {
|
||||||
|
|||||||
+3
-1
@@ -19,6 +19,8 @@ import java.util.Collection;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base compiled query request for single attribute queries.
|
* Base compiled query request for single attribute queries.
|
||||||
*/
|
*/
|
||||||
@@ -153,7 +155,7 @@ final class CQueryFetchSingleAttribute implements SpiProfileTransactionEvent, Ca
|
|||||||
dataReader = null;
|
dataReader = null;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.error("Error closing DataReader", e);
|
CoreLog.log.log(ERROR, "Error closing DataReader", e);
|
||||||
}
|
}
|
||||||
JdbcClose.close(pstmt);
|
JdbcClose.close(pstmt);
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.ERROR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a query for a given SQL statement.
|
* Represents a query for a given SQL statement.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -313,7 +315,7 @@ public class CQueryPlan implements SpiQueryPlan {
|
|||||||
predicates.bind(capture);
|
predicates.bind(capture);
|
||||||
bindCapture.setBind(capture.bindCapture(), executionTimeMicros, startNanos);
|
bindCapture.setBind(capture.bindCapture(), executionTimeMicros, startNanos);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.error("Error capturing bind values", e);
|
CoreLog.log.log(ERROR, "Error capturing bind values", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import io.ebeaninternal.api.*;
|
|||||||
import io.ebeaninternal.server.transaction.TransactionManager;
|
import io.ebeaninternal.server.transaction.TransactionManager;
|
||||||
import io.ebeaninternal.server.type.bindcapture.BindCapture;
|
import io.ebeaninternal.server.type.bindcapture.BindCapture;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -64,7 +65,7 @@ public final class CQueryPlanManager implements QueryPlanManager {
|
|||||||
}
|
}
|
||||||
return req.plans();
|
return req.plans();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.error("Error during query plan collection", e);
|
CoreLog.log.log(Level.ERROR, "Error during query plan collection", e);
|
||||||
return emptyList();
|
return emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile Query Predicates.
|
* Compile Query Predicates.
|
||||||
* <p>
|
* <p>
|
||||||
@@ -339,7 +341,7 @@ public final class CQueryPredicates {
|
|||||||
msg += "] with an incorrect orderBy [" + orderBy + "]. The id property [" + orderById + "]";
|
msg += "] with an incorrect orderBy [" + orderBy + "]. The id property [" + orderById + "]";
|
||||||
msg += " must come before the many property [" + manyProp.name() + "] in the orderBy.";
|
msg += " must come before the many property [" + manyProp.name() + "] in the orderBy.";
|
||||||
msg += " Ebean has automatically modified the orderBy clause to do this.";
|
msg += " Ebean has automatically modified the orderBy clause to do this.";
|
||||||
CoreLog.log.warn(msg);
|
CoreLog.log.log(WARNING, msg);
|
||||||
}
|
}
|
||||||
// the id needs to come before the manyPropName
|
// the id needs to come before the manyPropName
|
||||||
orderBy = orderBy.substring(0, manyPos) + orderById + ", " + orderBy.substring(manyPos);
|
orderBy = orderBy.substring(0, manyPos) + orderById + ", " + orderBy.substring(manyPos);
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A QueryPlanLogger that prefixes "EXPLAIN " to the query. This works for Postgres, H2 and MySql.
|
* A QueryPlanLogger that prefixes "EXPLAIN " to the query. This works for Postgres, H2 and MySql.
|
||||||
*/
|
*/
|
||||||
@@ -23,7 +25,7 @@ public final class QueryPlanLoggerExplain extends QueryPlanLogger {
|
|||||||
return readQueryPlan(plan, bind, rset);
|
return readQueryPlan(plan, bind, rset);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.warn("Could not log query plan", e);
|
CoreLog.log.log(WARNING, "Could not log query plan", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A QueryPlanLogger for oracle.
|
* A QueryPlanLogger for oracle.
|
||||||
*
|
*
|
||||||
@@ -30,7 +32,7 @@ public final class QueryPlanLoggerOracle extends QueryPlanLogger {
|
|||||||
return readQueryPlan(plan, bind, rset);
|
return readQueryPlan(plan, bind, rset);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.warn("Could not log query plan", e);
|
CoreLog.log.log(WARNING, "Could not log query plan", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A QueryPlanLogger for Postgres that prefixes "EXPLAIN ANALYZE" to the query.
|
* A QueryPlanLogger for Postgres that prefixes "EXPLAIN ANALYZE" to the query.
|
||||||
*/
|
*/
|
||||||
@@ -24,7 +26,7 @@ public final class QueryPlanLoggerPostgres extends QueryPlanLogger {
|
|||||||
return readQueryPlanBasic(plan, bind, rset);
|
return readQueryPlanBasic(plan, bind, rset);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.warn("Could not log query plan: " + explain, e);
|
CoreLog.log.log(WARNING, "Could not log query plan: " + explain, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -11,6 +11,8 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import static java.lang.System.Logger.Level.WARNING;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A QueryPlanLogger for SqlServer. It will return the plan as XML, which can be opened in
|
* A QueryPlanLogger for SqlServer. It will return the plan as XML, which can be opened in
|
||||||
* Microsoft SQL Server Management Studio.
|
* Microsoft SQL Server Management Studio.
|
||||||
@@ -42,13 +44,13 @@ public final class QueryPlanLoggerSqlServer extends QueryPlanLogger {
|
|||||||
return createPlan(plan, bind.toString(), xml);
|
return createPlan(plan, bind.toString(), xml);
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.warn("Could not log query plan", e);
|
CoreLog.log.log(WARNING, "Could not log query plan", e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
stmt.execute("set statistics xml off");
|
stmt.execute("set statistics xml off");
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
CoreLog.log.warn("Could not log query plan", e);
|
CoreLog.log.log(WARNING, "Could not log query plan", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,23 +11,16 @@ import io.ebeaninternal.server.deploy.InheritInfo;
|
|||||||
import io.ebeaninternal.server.deploy.TableJoin;
|
import io.ebeaninternal.server.deploy.TableJoin;
|
||||||
import io.ebeaninternal.server.querydefn.OrmQueryDetail;
|
import io.ebeaninternal.server.querydefn.OrmQueryDetail;
|
||||||
import io.ebeaninternal.server.querydefn.OrmQueryProperties;
|
import io.ebeaninternal.server.querydefn.OrmQueryProperties;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory for SqlTree.
|
* Factory for SqlTree.
|
||||||
*/
|
*/
|
||||||
public final class SqlTreeBuilder {
|
public final class SqlTreeBuilder {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final SpiQuery<?> query;
|
private final SpiQuery<?> query;
|
||||||
private final STreeType desc;
|
private final STreeType desc;
|
||||||
@@ -92,10 +85,10 @@ public final class SqlTreeBuilder {
|
|||||||
this.disableLazyLoad = query.isDisableLazyLoading();
|
this.disableLazyLoad = query.isDisableLazyLoading();
|
||||||
this.readOnly = Boolean.TRUE.equals(query.isReadOnly());
|
this.readOnly = Boolean.TRUE.equals(query.isReadOnly());
|
||||||
this.subQuery = Type.SQ_EXISTS == query.getType()
|
this.subQuery = Type.SQ_EXISTS == query.getType()
|
||||||
|| Type.SQ_IN == query.getType()
|
|| Type.SQ_IN == query.getType()
|
||||||
|| Type.ID_LIST == query.getType()
|
|| Type.ID_LIST == query.getType()
|
||||||
|| Type.DELETE == query.getType()
|
|| Type.DELETE == query.getType()
|
||||||
|| query.isCountDistinct();
|
|| query.isCountDistinct();
|
||||||
this.includeJoin = query.getM2mIncludeJoin();
|
this.includeJoin = query.getM2mIncludeJoin();
|
||||||
this.manyWhereJoins = query.getManyWhereJoins();
|
this.manyWhereJoins = query.getManyWhereJoins();
|
||||||
this.queryDetail = query.getDetail();
|
this.queryDetail = query.getDetail();
|
||||||
@@ -392,7 +385,7 @@ public final class SqlTreeBuilder {
|
|||||||
private void addPropertyToSubQuery(SqlTreeProperties selectProps, STreeType desc, String propName, String path) {
|
private void addPropertyToSubQuery(SqlTreeProperties selectProps, STreeType desc, String propName, String path) {
|
||||||
STreeProperty p = desc.findPropertyWithDynamic(propName, path);
|
STreeProperty p = desc.findPropertyWithDynamic(propName, path);
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
log.error("property [" + propName + "]not found on " + desc + " for query - excluding it.");
|
log.log(Level.ERROR, "property [{0}] not found on {1} for query - excluding it.", propName, desc);
|
||||||
return;
|
return;
|
||||||
} else if (p instanceof STreePropertyAssoc && p.isEmbedded()) {
|
} else if (p instanceof STreePropertyAssoc && p.isEmbedded()) {
|
||||||
// if the property is embedded we need to lookup the real column name
|
// if the property is embedded we need to lookup the real column name
|
||||||
@@ -427,13 +420,13 @@ public final class SqlTreeBuilder {
|
|||||||
if (p != null) {
|
if (p != null) {
|
||||||
selectProps.add(p);
|
selectProps.add(p);
|
||||||
} else {
|
} else {
|
||||||
log.error("property [" + propName + "] not found on " + desc + " for query - excluding it.");
|
log.log(Level.ERROR, "property [{0}] not found on {1} for query - excluding it.", propName, desc);
|
||||||
}
|
}
|
||||||
} else if (p.isEmbedded() || (p instanceof STreePropertyAssoc && !queryProps.isIncludedBeanJoin(p.name()))) {
|
} else if (p.isEmbedded() || (p instanceof STreePropertyAssoc && !queryProps.isIncludedBeanJoin(p.name()))) {
|
||||||
// add the embedded bean or the *ToOne assoc bean. We skip the check that the *ToOne propName maps to Id property ...
|
// add the embedded bean or the *ToOne assoc bean. We skip the check that the *ToOne propName maps to Id property ...
|
||||||
selectProps.add(p);
|
selectProps.add(p);
|
||||||
} else {
|
} else {
|
||||||
log.error("property [" + p.fullName() + "] expected to be an embedded or *ToOne bean for query - excluding it.");
|
log.log(Level.ERROR, "property [{0}] expected to be an embedded or *ToOne bean for query - excluding it.", p.fullName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,7 +435,7 @@ public final class SqlTreeBuilder {
|
|||||||
// sub class hierarchy if required
|
// sub class hierarchy if required
|
||||||
STreeProperty p = desc.findPropertyWithDynamic(propName, queryProps.getPath());
|
STreeProperty p = desc.findPropertyWithDynamic(propName, queryProps.getPath());
|
||||||
if (p == null) {
|
if (p == null) {
|
||||||
log.error("property [" + propName + "] not found on " + desc + " for query - excluding it.");
|
log.log(Level.ERROR, "property [{0}] not found on {1} for query - excluding it.", propName, desc);
|
||||||
p = desc.findProperty("id");
|
p = desc.findProperty("id");
|
||||||
selectProps.add(p);
|
selectProps.add(p);
|
||||||
|
|
||||||
@@ -542,9 +535,6 @@ public final class SqlTreeBuilder {
|
|||||||
if (queryDetail.includesPath(propName)) {
|
if (queryDetail.includesPath(propName)) {
|
||||||
if (manyProperty != null) {
|
if (manyProperty != null) {
|
||||||
// only one many associated allowed to be included in fetch
|
// only one many associated allowed to be included in fetch
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Not joining [" + propName + "] as already joined to a Many[" + manyProperty + "].");
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
manyProperty = manyProp;
|
manyProperty = manyProp;
|
||||||
@@ -559,7 +549,6 @@ public final class SqlTreeBuilder {
|
|||||||
* Return true if this node is FULLY included resulting in table join. If the
|
* Return true if this node is FULLY included resulting in table join. If the
|
||||||
* node is not included but its parent has been included then a "bean proxy"
|
* node is not included but its parent has been included then a "bean proxy"
|
||||||
* is added and false is returned.
|
* is added and false is returned.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
private boolean isIncludeBean(String prefix) {
|
private boolean isIncludeBean(String prefix) {
|
||||||
if (queryDetail.includesPath(prefix)) {
|
if (queryDetail.includesPath(prefix)) {
|
||||||
|
|||||||
+10
-10
@@ -1,17 +1,17 @@
|
|||||||
package io.ebeaninternal.server.readaudit;
|
package io.ebeaninternal.server.readaudit;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonFactory;
|
||||||
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.event.readaudit.ReadAuditLogger;
|
import io.ebean.event.readaudit.ReadAuditLogger;
|
||||||
import io.ebean.event.readaudit.ReadAuditQueryPlan;
|
import io.ebean.event.readaudit.ReadAuditQueryPlan;
|
||||||
import io.ebean.event.readaudit.ReadEvent;
|
import io.ebean.event.readaudit.ReadEvent;
|
||||||
import io.ebean.text.json.EJson;
|
import io.ebean.text.json.EJson;
|
||||||
import com.fasterxml.jackson.core.JsonFactory;
|
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
|
||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,8 +19,8 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class DefaultReadAuditLogger implements ReadAuditLogger {
|
public class DefaultReadAuditLogger implements ReadAuditLogger {
|
||||||
|
|
||||||
private static final Logger queryLogger = LoggerFactory.getLogger("io.ebean.ReadAuditQuery");
|
private static final System.Logger queryLogger = AppLog.getLogger("io.ebean.ReadAuditQuery");
|
||||||
private static final Logger auditLogger = LoggerFactory.getLogger("io.ebean.ReadAudit");
|
private static final System.Logger auditLogger = AppLog.getLogger("io.ebean.ReadAudit");
|
||||||
|
|
||||||
protected final JsonFactory jsonFactory = new JsonFactory();
|
protected final JsonFactory jsonFactory = new JsonFactory();
|
||||||
protected int defaultQueryBuffer = 500;
|
protected int defaultQueryBuffer = 500;
|
||||||
@@ -48,9 +48,9 @@ public class DefaultReadAuditLogger implements ReadAuditLogger {
|
|||||||
}
|
}
|
||||||
gen.writeEndObject();
|
gen.writeEndObject();
|
||||||
gen.flush();
|
gen.flush();
|
||||||
queryLogger.info(writer.toString());
|
queryLogger.log(Level.INFO, writer.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoreLog.log.error("Error writing Read audit event", e);
|
CoreLog.log.log(Level.ERROR, "Error writing Read audit event", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +75,9 @@ public class DefaultReadAuditLogger implements ReadAuditLogger {
|
|||||||
StringWriter writer = new StringWriter(defaultReadBuffer);
|
StringWriter writer = new StringWriter(defaultReadBuffer);
|
||||||
JsonGenerator gen = jsonFactory.createGenerator(writer);
|
JsonGenerator gen = jsonFactory.createGenerator(writer);
|
||||||
writeDetails(gen, event);
|
writeDetails(gen, event);
|
||||||
auditLogger.info(writer.toString());
|
auditLogger.log(Level.INFO, writer.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoreLog.log.error("Error writing Read audit event", e);
|
CoreLog.log.log(Level.ERROR, "Error writing Read audit event", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-12
@@ -7,9 +7,11 @@ import io.ebean.plugin.SpiServer;
|
|||||||
import io.ebean.util.IOUtils;
|
import io.ebean.util.IOUtils;
|
||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import io.ebeaninternal.api.SpiProfileHandler;
|
import io.ebeaninternal.api.SpiProfileHandler;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeFormatterBuilder;
|
import java.time.format.DateTimeFormatterBuilder;
|
||||||
@@ -31,8 +33,9 @@ import static java.time.temporal.ChronoField.*;
|
|||||||
*/
|
*/
|
||||||
public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
|
public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
private static final DateTimeFormatter DTF;
|
private static final DateTimeFormatter DTF;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
DTF = new DateTimeFormatterBuilder()
|
DTF = new DateTimeFormatterBuilder()
|
||||||
.parseCaseInsensitive()
|
.parseCaseInsensitive()
|
||||||
@@ -76,7 +79,7 @@ public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
|
|||||||
this.executor = Executors.newSingleThreadExecutor();
|
this.executor = Executors.newSingleThreadExecutor();
|
||||||
this.dir = new File(config.getDirectory());
|
this.dir = new File(config.getDirectory());
|
||||||
if (!dir.exists() && !dir.mkdirs()) {
|
if (!dir.exists() && !dir.mkdirs()) {
|
||||||
log.error("failed to mkdirs " + dir.getAbsolutePath());
|
log.log(Level.ERROR, "failed to mkdirs " + dir.getAbsolutePath());
|
||||||
}
|
}
|
||||||
incrementFile();
|
incrementFile();
|
||||||
}
|
}
|
||||||
@@ -106,7 +109,7 @@ public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
|
|||||||
out.close();
|
out.close();
|
||||||
out = null;
|
out = null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to flush and close transaction profiling file ", e);
|
log.log(Level.ERROR, "Failed to flush and close transaction profiling file ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -126,7 +129,7 @@ public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
|
|||||||
File file = new File(dir, "txprofile-" + now + ".tprofile");
|
File file = new File(dir, "txprofile-" + now + ".tprofile");
|
||||||
out = IOUtils.newWriter(file);
|
out = IOUtils.newWriter(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Not expected", e);
|
log.log(Level.ERROR, "Not expected", e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
@@ -149,7 +152,7 @@ public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
|
|||||||
}
|
}
|
||||||
flushCurrentFile();
|
flushCurrentFile();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Error on collect", e);
|
log.log(Level.WARNING, "Error on collect", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,10 +183,10 @@ public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
|
|||||||
|
|
||||||
if (profileCounter % profilesPerFile == 0) {
|
if (profileCounter % profilesPerFile == 0) {
|
||||||
incrementFile();
|
incrementFile();
|
||||||
log.debug("profiled {} transactions", profileCounter);
|
log.log(Level.DEBUG, "profiled {0} transactions", profileCounter);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.warn("Error writing transaction profiling", e);
|
log.log(Level.WARNING, "Error writing transaction profiling", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,16 +250,16 @@ public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
|
|||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
shutdown = true;
|
shutdown = true;
|
||||||
log.trace("shutting down");
|
log.log(Level.TRACE, "shutting down");
|
||||||
try {
|
try {
|
||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
if (!executor.awaitTermination(4, TimeUnit.SECONDS)) {
|
if (!executor.awaitTermination(4, TimeUnit.SECONDS)) {
|
||||||
log.info("Shut down timeout exceeded. Terminating profiling consumer thread.");
|
log.log(Level.INFO, "Shut down timeout exceeded. Terminating profiling consumer thread.");
|
||||||
executor.shutdownNow();
|
executor.shutdownNow();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
log.warn("Interrupt on shutdown", e);
|
log.log(Level.WARNING, "Interrupt on shutdown", e);
|
||||||
}
|
}
|
||||||
flushCurrentFile();
|
flushCurrentFile();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -12,6 +12,7 @@ import io.ebeaninternal.server.persist.BatchControl;
|
|||||||
import io.ebeanservice.docstore.api.DocStoreTransaction;
|
import io.ebeanservice.docstore.api.DocStoreTransaction;
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -483,7 +484,7 @@ final class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEve
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// the connection pool will automatically remove the
|
// the connection pool will automatically remove the
|
||||||
// connection if it does not pass the test
|
// connection if it does not pass the test
|
||||||
CoreLog.log.error("Error closing connection", ex);
|
CoreLog.log.log(Level.ERROR, "Error closing connection", ex);
|
||||||
}
|
}
|
||||||
connection = null;
|
connection = null;
|
||||||
active = false;
|
active = false;
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import io.ebeaninternal.server.persist.BatchControl;
|
|||||||
import io.ebeaninternal.server.persist.BatchedSqlException;
|
import io.ebeaninternal.server.persist.BatchedSqlException;
|
||||||
import io.ebeaninternal.server.util.Str;
|
import io.ebeaninternal.server.util.Str;
|
||||||
import io.ebeanservice.docstore.api.DocStoreTransaction;
|
import io.ebeanservice.docstore.api.DocStoreTransaction;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.persistence.RollbackException;
|
import javax.persistence.RollbackException;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -28,7 +28,7 @@ import java.util.function.Consumer;
|
|||||||
*/
|
*/
|
||||||
class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.log;
|
private static final System.Logger log = CoreLog.log;
|
||||||
private static final Object PLACEHOLDER = new Object();
|
private static final Object PLACEHOLDER = new Object();
|
||||||
private static final String illegalStateMessage = "Transaction is Inactive";
|
private static final String illegalStateMessage = "Transaction is Inactive";
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
|||||||
try {
|
try {
|
||||||
consumer.accept(callbackList.get(i));
|
consumer.accept(callbackList.get(i));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error executing transaction callback", e);
|
log.log(Level.ERROR, "Error executing transaction callback", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -884,7 +884,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
|||||||
connection.setReadOnly(false);
|
connection.setReadOnly(false);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Error setting to readOnly?", e);
|
log.log(Level.ERROR, "Error setting to readOnly?", e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (autoCommit) {
|
if (autoCommit) {
|
||||||
@@ -892,14 +892,14 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
|||||||
connection.setAutoCommit(true);
|
connection.setAutoCommit(true);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Error setting to readOnly?", e);
|
log.log(Level.ERROR, "Error setting to readOnly?", e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
connection.close();
|
connection.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// the connection pool will automatically remove the
|
// the connection pool will automatically remove the
|
||||||
// connection if it does not pass the test
|
// connection if it does not pass the test
|
||||||
log.error("Error closing connection", ex);
|
log.log(Level.ERROR, "Error closing connection", ex);
|
||||||
}
|
}
|
||||||
connection = null;
|
connection = null;
|
||||||
active = false;
|
active = false;
|
||||||
@@ -932,7 +932,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
|||||||
}
|
}
|
||||||
withEachCallback(TransactionCallback::postCommit);
|
withEachCallback(TransactionCallback::postCommit);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Error when ending a query only transaction via " + onQueryOnly, e);
|
log.log(Level.ERROR, "Error when ending a query only transaction via " + onQueryOnly, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1056,7 +1056,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
|
|||||||
private RuntimeException wrapIfNeeded(Exception e) {
|
private RuntimeException wrapIfNeeded(Exception e) {
|
||||||
if (e instanceof PersistenceException) {
|
if (e instanceof PersistenceException) {
|
||||||
// keep more specific exception if we have it
|
// keep more specific exception if we have it
|
||||||
return (PersistenceException)e;
|
return (PersistenceException) e;
|
||||||
}
|
}
|
||||||
return new RollbackException(e);
|
return new RollbackException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-14
@@ -4,7 +4,6 @@ import io.ebean.config.ExternalTransactionManager;
|
|||||||
import io.ebean.util.JdbcClose;
|
import io.ebean.util.JdbcClose;
|
||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import io.ebeaninternal.api.SpiTransaction;
|
import io.ebeaninternal.api.SpiTransaction;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.naming.InitialContext;
|
import javax.naming.InitialContext;
|
||||||
import javax.naming.NamingException;
|
import javax.naming.NamingException;
|
||||||
@@ -14,13 +13,14 @@ import javax.transaction.Status;
|
|||||||
import javax.transaction.Synchronization;
|
import javax.transaction.Synchronization;
|
||||||
import javax.transaction.TransactionSynchronizationRegistry;
|
import javax.transaction.TransactionSynchronizationRegistry;
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook into external JTA transaction manager.
|
* Hook into external JTA transaction manager.
|
||||||
*/
|
*/
|
||||||
public final class JtaTransactionManager implements ExternalTransactionManager {
|
public final class JtaTransactionManager implements ExternalTransactionManager {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
private static final String EBEAN_TXN_RESOURCE = "EBEAN_TXN_RESOURCE";
|
private static final String EBEAN_TXN_RESOURCE = "EBEAN_TXN_RESOURCE";
|
||||||
|
|
||||||
private TransactionManager transactionManager;
|
private TransactionManager transactionManager;
|
||||||
@@ -87,15 +87,15 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
|||||||
SpiTransaction currentEbeanTransaction = scope.inScope();
|
SpiTransaction currentEbeanTransaction = scope.inScope();
|
||||||
if (currentEbeanTransaction != null) {
|
if (currentEbeanTransaction != null) {
|
||||||
// NOT expecting this so log WARNING
|
// NOT expecting this so log WARNING
|
||||||
log.warn("JTA Transaction - no current txn BUT using current Ebean one {}", currentEbeanTransaction.getId());
|
log.log(Level.WARNING, "JTA Transaction - no current txn BUT using current Ebean one {0}", currentEbeanTransaction.getId());
|
||||||
return currentEbeanTransaction;
|
return currentEbeanTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
UserTransaction ut = getUserTransaction();
|
UserTransaction ut = getUserTransaction();
|
||||||
if (ut == null) {
|
if (ut == null) {
|
||||||
// no current JTA transaction
|
// no current JTA transaction
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("JTA Transaction - no current txn");
|
log.log(Level.DEBUG, "JTA Transaction - no current txn");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -181,27 +181,21 @@ public final class JtaTransactionManager implements ExternalTransactionManager {
|
|||||||
public void afterCompletion(int status) {
|
public void afterCompletion(int status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case Status.STATUS_COMMITTED:
|
case Status.STATUS_COMMITTED:
|
||||||
if (log.isDebugEnabled()) {
|
log.log(Level.DEBUG, "Jta Txn [{0}] committed", transaction.getId());
|
||||||
log.debug("Jta Txn [" + transaction.getId() + "] committed");
|
|
||||||
}
|
|
||||||
transaction.postCommit();
|
transaction.postCommit();
|
||||||
// Remove this transaction object as it is completed
|
// Remove this transaction object as it is completed
|
||||||
transactionManager.scope().clearExternal();
|
transactionManager.scope().clearExternal();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Status.STATUS_ROLLEDBACK:
|
case Status.STATUS_ROLLEDBACK:
|
||||||
if (log.isDebugEnabled()) {
|
log.log(Level.DEBUG, "Jta Txn [{0}] rollback", transaction.getId());
|
||||||
log.debug("Jta Txn [" + transaction.getId() + "] rollback");
|
|
||||||
}
|
|
||||||
transaction.postRollback(null);
|
transaction.postRollback(null);
|
||||||
// Remove this transaction object as it is completed
|
// Remove this transaction object as it is completed
|
||||||
transactionManager.scope().clearExternal();
|
transactionManager.scope().clearExternal();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (log.isDebugEnabled()) {
|
log.log(Level.DEBUG, "Jta Txn [{0}] status:{1}", transaction.getId(), status);
|
||||||
log.debug("Jta Txn [" + transaction.getId() + "] status:" + status);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No matter the completion status of the transaction, we release the connection we got from the pool.
|
// No matter the completion status of the transaction, we release the connection we got from the pool.
|
||||||
|
|||||||
+4
-4
@@ -10,8 +10,8 @@ import io.ebeaninternal.server.cache.CacheChangeSet;
|
|||||||
import io.ebeaninternal.server.cluster.ClusterManager;
|
import io.ebeaninternal.server.cluster.ClusterManager;
|
||||||
import io.ebeaninternal.server.core.PersistRequestBean;
|
import io.ebeaninternal.server.core.PersistRequestBean;
|
||||||
import io.ebeanservice.docstore.api.DocStoreUpdates;
|
import io.ebeanservice.docstore.api.DocStoreUpdates;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
final class PostCommitProcessing {
|
final class PostCommitProcessing {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final ClusterManager clusterManager;
|
private final ClusterManager clusterManager;
|
||||||
private final TransactionEvent event;
|
private final TransactionEvent event;
|
||||||
@@ -104,8 +104,8 @@ final class PostCommitProcessing {
|
|||||||
private void notifyCluster() {
|
private void notifyCluster() {
|
||||||
if (remoteTransactionEvent != null && !remoteTransactionEvent.isEmpty()) {
|
if (remoteTransactionEvent != null && !remoteTransactionEvent.isEmpty()) {
|
||||||
// send the interesting events to the cluster
|
// send the interesting events to the cluster
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("Cluster Send: {}", remoteTransactionEvent);
|
log.log(Level.DEBUG, "Cluster Send: {0}", remoteTransactionEvent);
|
||||||
}
|
}
|
||||||
clusterManager.broadcast(remoteTransactionEvent);
|
clusterManager.broadcast(remoteTransactionEvent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package io.ebeaninternal.server.transaction;
|
package io.ebeaninternal.server.transaction;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.cache.QueryCacheEntry;
|
import io.ebean.cache.QueryCacheEntry;
|
||||||
import io.ebean.cache.QueryCacheEntryValidate;
|
import io.ebean.cache.QueryCacheEntryValidate;
|
||||||
import io.ebean.cache.ServerCacheNotification;
|
import io.ebean.cache.ServerCacheNotification;
|
||||||
import io.ebean.cache.ServerCacheNotify;
|
import io.ebean.cache.ServerCacheNotify;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
*/
|
*/
|
||||||
public final class TableModState implements QueryCacheEntryValidate, ServerCacheNotify {
|
public final class TableModState implements QueryCacheEntryValidate, ServerCacheNotify {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger("io.ebean.cache.TABLEMOD");
|
private static final System.Logger log = AppLog.getLogger("io.ebean.cache.TABLEMOD");
|
||||||
|
|
||||||
private final Map<String, Long> tableModStamp = new ConcurrentHashMap<>();
|
private final Map<String, Long> tableModStamp = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@@ -34,8 +34,8 @@ public final class TableModState implements QueryCacheEntryValidate, ServerCache
|
|||||||
for (String tableName : touchedTables) {
|
for (String tableName : touchedTables) {
|
||||||
tableModStamp.put(tableName, modNanoTime);
|
tableModStamp.put(tableName, modNanoTime);
|
||||||
}
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("TableModState updated - touched:{} modNanoTime:{}", touchedTables, modNanoTime);
|
log.log(Level.DEBUG, "TableModState updated - touched:{0} modNanoTime:{1}", touchedTables, modNanoTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,8 +46,8 @@ public final class TableModState implements QueryCacheEntryValidate, ServerCache
|
|||||||
for (String tableName : tables) {
|
for (String tableName : tables) {
|
||||||
Long modTime = tableModStamp.get(tableName);
|
Long modTime = tableModStamp.get(tableName);
|
||||||
if (modTime != null && modTime >= sinceNanoTime) {
|
if (modTime != null && modTime >= sinceNanoTime) {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isLoggable(Level.TRACE)) {
|
||||||
log.trace("Invalidate on table:{}", tableName);
|
log.log(Level.TRACE, "Invalidate on table:{0}", tableName);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -68,15 +68,13 @@ public final class TableModState implements QueryCacheEntryValidate, ServerCache
|
|||||||
* Update the table modification timestamps based on remote table modification events.
|
* Update the table modification timestamps based on remote table modification events.
|
||||||
* <p>
|
* <p>
|
||||||
* Generally this is used with distributed caches (Hazelcast, Ignite etc) via topic.
|
* Generally this is used with distributed caches (Hazelcast, Ignite etc) via topic.
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void notify(ServerCacheNotification notification) {
|
public void notify(ServerCacheNotification notification) {
|
||||||
|
|
||||||
// use local clock - for slightly more aggressive invalidation (as later)
|
// use local clock - for slightly more aggressive invalidation (as later)
|
||||||
// that removes any concern regarding clock syncing across cluster
|
// that removes any concern regarding clock syncing across cluster
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("ServerCacheNotification:{}", notification);
|
log.log(Level.DEBUG, "ServerCacheNotification:{0}", notification);
|
||||||
}
|
}
|
||||||
touch(notification.getDependentTables());
|
touch(notification.getDependentTables());
|
||||||
}
|
}
|
||||||
@@ -85,14 +83,12 @@ public final class TableModState implements QueryCacheEntryValidate, ServerCache
|
|||||||
* Update from Remote transaction event.
|
* Update from Remote transaction event.
|
||||||
* <p>
|
* <p>
|
||||||
* Generally this is used with Clustering (ebean-cluster, k8scache).
|
* Generally this is used with Clustering (ebean-cluster, k8scache).
|
||||||
* </p>
|
|
||||||
*/
|
*/
|
||||||
public void notify(RemoteTableMod tableMod) {
|
public void notify(RemoteTableMod tableMod) {
|
||||||
|
|
||||||
// use local clock - for slightly more aggressive invalidation (as later)
|
// use local clock - for slightly more aggressive invalidation (as later)
|
||||||
// that removes any concern regarding clock syncing across cluster
|
// that removes any concern regarding clock syncing across cluster
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isLoggable(Level.DEBUG)) {
|
||||||
log.debug("RemoteTableMod:{}", tableMod);
|
log.log(Level.DEBUG, "RemoteTableMod:{0}", tableMod);
|
||||||
}
|
}
|
||||||
touch(tableMod.getTables());
|
touch(tableMod.getTables());
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.server.transaction;
|
package io.ebeaninternal.server.transaction;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.BackgroundExecutor;
|
import io.ebean.BackgroundExecutor;
|
||||||
import io.ebean.ProfileLocation;
|
import io.ebean.ProfileLocation;
|
||||||
import io.ebean.TxScope;
|
import io.ebean.TxScope;
|
||||||
@@ -28,11 +29,10 @@ import io.ebeaninternal.server.profile.TimedProfileLocationRegistry;
|
|||||||
import io.ebeanservice.docstore.api.DocStoreTransaction;
|
import io.ebeanservice.docstore.api.DocStoreTransaction;
|
||||||
import io.ebeanservice.docstore.api.DocStoreUpdateProcessor;
|
import io.ebeanservice.docstore.api.DocStoreUpdateProcessor;
|
||||||
import io.ebeanservice.docstore.api.DocStoreUpdates;
|
import io.ebeanservice.docstore.api.DocStoreUpdates;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -47,8 +47,8 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||||||
*/
|
*/
|
||||||
public class TransactionManager implements SpiTransactionManager {
|
public class TransactionManager implements SpiTransactionManager {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.log;
|
private static final System.Logger log = CoreLog.log;
|
||||||
private static final Logger clusterLogger = LoggerFactory.getLogger("io.ebean.Cluster");
|
private static final System.Logger clusterLogger = AppLog.getLogger("io.ebean.Cluster");
|
||||||
|
|
||||||
private final SpiServer server;
|
private final SpiServer server;
|
||||||
private final BeanDescriptorManager beanDescriptorManager;
|
private final BeanDescriptorManager beanDescriptorManager;
|
||||||
@@ -365,7 +365,7 @@ public class TransactionManager implements SpiTransactionManager {
|
|||||||
txnLogger.debug(msg);
|
txnLogger.debug(msg);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("Error while notifying TransactionEventListener of rollback event", ex);
|
log.log(Level.ERROR, "Error while notifying TransactionEventListener of rollback event", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ public class TransactionManager implements SpiTransactionManager {
|
|||||||
postCommit.notifyLocalCache();
|
postCommit.notifyLocalCache();
|
||||||
backgroundExecutor.execute(postCommit.backgroundNotify());
|
backgroundExecutor.execute(postCommit.backgroundNotify());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("NotifyOfCommit failed. L2 Cache potentially not notified.", ex);
|
log.log(Level.ERROR, "NotifyOfCommit failed. L2 Cache potentially not notified.", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,8 +442,8 @@ public class TransactionManager implements SpiTransactionManager {
|
|||||||
* Notify local BeanPersistListeners etc of events from another server in the cluster.
|
* Notify local BeanPersistListeners etc of events from another server in the cluster.
|
||||||
*/
|
*/
|
||||||
public final void remoteTransactionEvent(RemoteTransactionEvent remoteEvent) {
|
public final void remoteTransactionEvent(RemoteTransactionEvent remoteEvent) {
|
||||||
if (clusterLogger.isDebugEnabled()) {
|
if (clusterLogger.isLoggable(Level.DEBUG)) {
|
||||||
clusterLogger.debug("processing {}", remoteEvent);
|
clusterLogger.log(Level.DEBUG, "processing {0}", remoteEvent);
|
||||||
}
|
}
|
||||||
CacheChangeSet changeSet = new CacheChangeSet();
|
CacheChangeSet changeSet = new CacheChangeSet();
|
||||||
|
|
||||||
|
|||||||
@@ -4,18 +4,10 @@ import io.ebean.core.type.DataBinder;
|
|||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
import io.ebeaninternal.server.core.timezone.DataTimeZone;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.*;
|
||||||
import java.io.IOException;
|
import java.lang.System.Logger.Level;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Array;
|
import java.sql.*;
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Time;
|
|
||||||
import java.sql.Timestamp;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -109,7 +101,7 @@ public class DataBind implements DataBinder {
|
|||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoreLog.log.warn("Error closing InputStream that was bound to PreparedStatement", e);
|
CoreLog.log.log(Level.WARNING, "Error closing InputStream that was bound to PreparedStatement", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputStreams = null;
|
inputStreams = null;
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ import org.joda.time.DateTime;
|
|||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.joda.time.LocalTime;
|
import org.joda.time.LocalTime;
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import javax.persistence.AttributeConverter;
|
import javax.persistence.AttributeConverter;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
@@ -52,7 +52,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
*/
|
*/
|
||||||
public final class DefaultTypeManager implements TypeManager {
|
public final class DefaultTypeManager implements TypeManager {
|
||||||
|
|
||||||
private static final Logger log = CoreLog.internal;
|
private static final System.Logger log = CoreLog.internal;
|
||||||
|
|
||||||
private final ConcurrentHashMap<Class<?>, ScalarType<?>> typeMap;
|
private final ConcurrentHashMap<Class<?>, ScalarType<?>> typeMap;
|
||||||
private final ConcurrentHashMap<Integer, ScalarType<?>> nativeMap;
|
private final ConcurrentHashMap<Integer, ScalarType<?>> nativeMap;
|
||||||
@@ -194,7 +194,6 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
ExtraTypeFactory plugin = iterator.next();
|
ExtraTypeFactory plugin = iterator.next();
|
||||||
List<? extends ScalarType<?>> types = plugin.createTypes(config, objectMapper);
|
List<? extends ScalarType<?>> types = plugin.createTypes(config, objectMapper);
|
||||||
for (ScalarType<?> type : types) {
|
for (ScalarType<?> type : types) {
|
||||||
log.debug("adding ScalarType {}", type.getClass());
|
|
||||||
add(type);
|
add(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,10 +219,10 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void logAdd(ScalarType<?> scalarType) {
|
private void logAdd(ScalarType<?> scalarType) {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isLoggable(Level.TRACE)) {
|
||||||
String msg = "ScalarType register [" + scalarType.getClass().getName() + "]";
|
String msg = "ScalarType register [" + scalarType.getClass().getName() + "]";
|
||||||
msg += " for [" + scalarType.getType().getName() + "]";
|
msg += " for [" + scalarType.getType().getName() + "]";
|
||||||
log.trace(msg);
|
log.log(Level.TRACE, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,7 +675,7 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
}
|
}
|
||||||
add(scalarType);
|
add(scalarType);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error loading ScalarType [" + cls.getName() + "]", e);
|
log.log(Level.ERROR, "Error loading ScalarType [" + cls.getName() + "]", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -707,10 +706,10 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
}
|
}
|
||||||
ScalarTypeConverter converter = foundType.getDeclaredConstructor().newInstance();
|
ScalarTypeConverter converter = foundType.getDeclaredConstructor().newInstance();
|
||||||
ScalarTypeWrapper stw = new ScalarTypeWrapper(logicalType, wrappedType, converter);
|
ScalarTypeWrapper stw = new ScalarTypeWrapper(logicalType, wrappedType, converter);
|
||||||
log.debug("Register ScalarTypeWrapper from {} -> {} using:{}", logicalType, persistType, foundType);
|
log.log(Level.DEBUG, "Register ScalarTypeWrapper from {0} -> {1} using:{2}", logicalType, persistType, foundType);
|
||||||
add(stw);
|
add(stw);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error registering ScalarTypeConverter [" + foundType.getName() + "]", e);
|
log.log(Level.ERROR, "Error registering ScalarTypeConverter [" + foundType.getName() + "]", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -731,10 +730,10 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
}
|
}
|
||||||
AttributeConverter converter = foundType.getDeclaredConstructor().newInstance();
|
AttributeConverter converter = foundType.getDeclaredConstructor().newInstance();
|
||||||
ScalarTypeWrapper stw = new ScalarTypeWrapper(logicalType, wrappedType, new AttributeConverterAdapter(converter));
|
ScalarTypeWrapper stw = new ScalarTypeWrapper(logicalType, wrappedType, new AttributeConverterAdapter(converter));
|
||||||
log.debug("Register ScalarTypeWrapper from {} -> {} using:{}", logicalType, persistType, foundType);
|
log.log(Level.DEBUG, "Register ScalarTypeWrapper from {0} -> {1} using:{2}", logicalType, persistType, foundType);
|
||||||
add(stw);
|
add(stw);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error registering AttributeConverter [" + foundType.getName() + "]", e);
|
log.log(Level.ERROR, "Error registering AttributeConverter [" + foundType.getName() + "]", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -744,7 +743,6 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
*/
|
*/
|
||||||
private void initialiseJacksonTypes(DatabaseConfig config) {
|
private void initialiseJacksonTypes(DatabaseConfig config) {
|
||||||
if (objectMapper != null) {
|
if (objectMapper != null) {
|
||||||
log.trace("Registering JsonNode type support");
|
|
||||||
ObjectMapper mapper = (ObjectMapper) objectMapper;
|
ObjectMapper mapper = (ObjectMapper) objectMapper;
|
||||||
jsonNodeClob = new ScalarTypeJsonNode.Clob(mapper);
|
jsonNodeClob = new ScalarTypeJsonNode.Clob(mapper);
|
||||||
jsonNodeBlob = new ScalarTypeJsonNode.Blob(mapper);
|
jsonNodeBlob = new ScalarTypeJsonNode.Blob(mapper);
|
||||||
@@ -807,7 +805,7 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
// detect if Joda classes are in the classpath
|
// detect if Joda classes are in the classpath
|
||||||
if (config.getClassLoadConfig().isJodaTimePresent()) {
|
if (config.getClassLoadConfig().isJodaTimePresent()) {
|
||||||
// Joda classes are in the classpath so register the types
|
// Joda classes are in the classpath so register the types
|
||||||
log.debug("Registering Joda data types");
|
log.log(Level.DEBUG, "Registering Joda data types");
|
||||||
addType(LocalDateTime.class, new ScalarTypeJodaLocalDateTime(jsonDateTime));
|
addType(LocalDateTime.class, new ScalarTypeJodaLocalDateTime(jsonDateTime));
|
||||||
addType(DateTime.class, new ScalarTypeJodaDateTime(jsonDateTime));
|
addType(DateTime.class, new ScalarTypeJodaDateTime(jsonDateTime));
|
||||||
if (config.getDatabasePlatform().supportsNativeJavaTime()) {
|
if (config.getDatabasePlatform().supportsNativeJavaTime()) {
|
||||||
@@ -822,11 +820,9 @@ public final class DefaultTypeManager implements TypeManager {
|
|||||||
if ("normal".equalsIgnoreCase(jodaLocalTimeMode)) {
|
if ("normal".equalsIgnoreCase(jodaLocalTimeMode)) {
|
||||||
// use the expected/normal local time zone
|
// use the expected/normal local time zone
|
||||||
addType(LocalTime.class, new ScalarTypeJodaLocalTime());
|
addType(LocalTime.class, new ScalarTypeJodaLocalTime());
|
||||||
log.debug("registered ScalarTypeJodaLocalTime");
|
|
||||||
} else if ("utc".equalsIgnoreCase(jodaLocalTimeMode)) {
|
} else if ("utc".equalsIgnoreCase(jodaLocalTimeMode)) {
|
||||||
// use the old UTC based
|
// use the old UTC based
|
||||||
addType(LocalTime.class, new ScalarTypeJodaLocalTimeUTC());
|
addType(LocalTime.class, new ScalarTypeJodaLocalTimeUTC());
|
||||||
log.debug("registered ScalarTypeJodaLocalTimeUTC");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import io.ebean.text.TextException;
|
|||||||
import io.ebeaninternal.api.CoreLog;
|
import io.ebeaninternal.api.CoreLog;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
@@ -169,14 +170,14 @@ final class ScalarTypeFile extends ScalarTypeBase<File> {
|
|||||||
try {
|
try {
|
||||||
output.close();
|
output.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoreLog.log.error("Error when closing outputstream", e);
|
CoreLog.log.log(Level.ERROR, "Error when closing outputStream", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
try {
|
try {
|
||||||
input.close();
|
input.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CoreLog.log.error("Error when closing inputstream ", e);
|
CoreLog.log.log(Level.ERROR, "Error when closing inputStream ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ module io.ebean.core {
|
|||||||
requires io.avaje.classpath.scanner.api;
|
requires io.avaje.classpath.scanner.api;
|
||||||
requires io.avaje.classpath.scanner;
|
requires io.avaje.classpath.scanner;
|
||||||
requires io.ebean.types;
|
requires io.ebean.types;
|
||||||
requires org.slf4j;
|
|
||||||
|
|
||||||
requires static io.avaje.jsr305x;
|
requires static io.avaje.jsr305x;
|
||||||
requires static com.fasterxml.jackson.annotation;
|
requires static com.fasterxml.jackson.annotation;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.dbmigration;
|
package io.ebeaninternal.dbmigration;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.annotation.Platform;
|
import io.ebean.annotation.Platform;
|
||||||
import io.ebean.config.DatabaseConfig;
|
import io.ebean.config.DatabaseConfig;
|
||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||||
@@ -11,11 +12,10 @@ import io.ebeaninternal.api.SpiDdlGenerator;
|
|||||||
import io.ebeaninternal.api.SpiEbeanServer;
|
import io.ebeaninternal.api.SpiEbeanServer;
|
||||||
import io.ebeaninternal.dbmigration.model.CurrentModel;
|
import io.ebeaninternal.dbmigration.model.CurrentModel;
|
||||||
import io.ebeaninternal.extraddl.model.ExtraDdlXmlReader;
|
import io.ebeaninternal.extraddl.model.ExtraDdlXmlReader;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ import java.sql.SQLException;
|
|||||||
*/
|
*/
|
||||||
public class DdlGenerator implements SpiDdlGenerator {
|
public class DdlGenerator implements SpiDdlGenerator {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(DdlGenerator.class);
|
private static final System.Logger log = AppLog.getLogger(DdlGenerator.class);
|
||||||
private static final String[] BUILD_DIRS = {"target", "build"};
|
private static final String[] BUILD_DIRS = {"target", "build"};
|
||||||
|
|
||||||
private final SpiEbeanServer server;
|
private final SpiEbeanServer server;
|
||||||
@@ -60,7 +60,7 @@ public class DdlGenerator implements SpiDdlGenerator {
|
|||||||
this.platform = databasePlatform.getPlatform();
|
this.platform = databasePlatform.getPlatform();
|
||||||
this.platformName = platform.base().name();
|
this.platformName = platform.base().name();
|
||||||
if (!config.getTenantMode().isDdlEnabled() && config.isDdlRun()) {
|
if (!config.getTenantMode().isDdlEnabled() && config.isDdlRun()) {
|
||||||
log.warn("DDL can't be run on startup with TenantMode " + config.getTenantMode());
|
log.log(Level.WARNING, "DDL can't be run on startup with TenantMode " + config.getTenantMode());
|
||||||
this.runDdl = false;
|
this.runDdl = false;
|
||||||
this.useMigrationStoredProcedures = false;
|
this.useMigrationStoredProcedures = false;
|
||||||
} else {
|
} else {
|
||||||
@@ -224,7 +224,7 @@ public class DdlGenerator implements SpiDdlGenerator {
|
|||||||
if (sqlScript != null) {
|
if (sqlScript != null) {
|
||||||
try (InputStream is = getClassLoader().getResourceAsStream(sqlScript)) {
|
try (InputStream is = getClassLoader().getResourceAsStream(sqlScript)) {
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
log.warn("sql script {} was not found as a resource", sqlScript);
|
log.log(Level.WARNING, "sql script {0} was not found as a resource", sqlScript);
|
||||||
} else {
|
} else {
|
||||||
String content = readContent(IOUtils.newReader(is)); // 'is' is closed
|
String content = readContent(IOUtils.newReader(is)); // 'is' is closed
|
||||||
runScript(connection, false, content, sqlScript);
|
runScript(connection, false, content, sqlScript);
|
||||||
|
|||||||
+7
-7
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.dbmigration;
|
package io.ebeaninternal.dbmigration;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.DB;
|
import io.ebean.DB;
|
||||||
import io.ebean.Database;
|
import io.ebean.Database;
|
||||||
import io.ebean.annotation.Platform;
|
import io.ebean.annotation.Platform;
|
||||||
@@ -21,12 +22,11 @@ import io.ebeaninternal.dbmigration.model.*;
|
|||||||
import io.ebeaninternal.extraddl.model.DdlScript;
|
import io.ebeaninternal.extraddl.model.DdlScript;
|
||||||
import io.ebeaninternal.extraddl.model.ExtraDdl;
|
import io.ebeaninternal.extraddl.model.ExtraDdl;
|
||||||
import io.ebeaninternal.extraddl.model.ExtraDdlXmlReader;
|
import io.ebeaninternal.extraddl.model.ExtraDdlXmlReader;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@@ -57,7 +57,7 @@ import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
|
|||||||
*/
|
*/
|
||||||
public class DefaultDbMigration implements DbMigration {
|
public class DefaultDbMigration implements DbMigration {
|
||||||
|
|
||||||
protected static final Logger logger = LoggerFactory.getLogger("io.ebean.GenerateMigration");
|
protected static final System.Logger logger = AppLog.getLogger("io.ebean.GenerateMigration");
|
||||||
private static final String initialVersion = "1.0";
|
private static final String initialVersion = "1.0";
|
||||||
private static final String GENERATED_COMMENT = "THIS IS A GENERATED FILE - DO NOT MODIFY";
|
private static final String GENERATED_COMMENT = "THIS IS A GENERATED FILE - DO NOT MODIFY";
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ public class DefaultDbMigration implements DbMigration {
|
|||||||
*/
|
*/
|
||||||
private void writeExtraDdl(File migrationDir, DdlScript script) throws IOException {
|
private void writeExtraDdl(File migrationDir, DdlScript script) throws IOException {
|
||||||
String fullName = repeatableMigrationName(script.isInit(), script.getName());
|
String fullName = repeatableMigrationName(script.isInit(), script.getName());
|
||||||
logger.debug("writing repeatable script {}", fullName);
|
logger.log(Level.DEBUG, "writing repeatable script {0}", fullName);
|
||||||
File file = new File(migrationDir, fullName);
|
File file = new File(migrationDir, fullName);
|
||||||
try (Writer writer = IOUtils.newWriter(file)) {
|
try (Writer writer = IOUtils.newWriter(file)) {
|
||||||
writer.write(script.getValue());
|
writer.write(script.getValue());
|
||||||
@@ -419,7 +419,7 @@ public class DefaultDbMigration implements DbMigration {
|
|||||||
if (logToSystemOut) {
|
if (logToSystemOut) {
|
||||||
System.out.println("DbMigration> " + message);
|
System.out.println("DbMigration> " + message);
|
||||||
} else {
|
} else {
|
||||||
logger.error(message);
|
logger.log(Level.ERROR, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,7 +430,7 @@ public class DefaultDbMigration implements DbMigration {
|
|||||||
if (logToSystemOut) {
|
if (logToSystemOut) {
|
||||||
System.out.println("DbMigration> " + message);
|
System.out.println("DbMigration> " + message);
|
||||||
} else {
|
} else {
|
||||||
logger.info(message);
|
logger.log(Level.INFO, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,7 +792,7 @@ public class DefaultDbMigration implements DbMigration {
|
|||||||
case SQLSERVER:
|
case SQLSERVER:
|
||||||
throw new IllegalArgumentException("Please choose the more specific SQLSERVER16 or SQLSERVER17 platform. Refer to issue #1340 for details");
|
throw new IllegalArgumentException("Please choose the more specific SQLSERVER16 or SQLSERVER17 platform. Refer to issue #1340 for details");
|
||||||
case DB2:
|
case DB2:
|
||||||
logger.warn("Using DB2LegacyPlatform. It is recommended to migrate to db2luw/db2zos/db2fori. Refer to issue #2514 for details");
|
logger.log(Level.WARNING, "Using DB2LegacyPlatform. It is recommended to migrate to db2luw/db2zos/db2fori. Refer to issue #2514 for details");
|
||||||
case GENERIC:
|
case GENERIC:
|
||||||
return new DatabasePlatform();
|
return new DatabasePlatform();
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package io.ebeaninternal.dbmigration.model;
|
package io.ebeaninternal.dbmigration.model;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebeaninternal.dbmigration.ddlgeneration.platform.DdlHelp;
|
import io.ebeaninternal.dbmigration.ddlgeneration.platform.DdlHelp;
|
||||||
import io.ebeaninternal.dbmigration.migration.*;
|
import io.ebeaninternal.dbmigration.migration.*;
|
||||||
import io.ebeaninternal.server.deploy.*;
|
import io.ebeaninternal.server.deploy.*;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static io.ebeaninternal.dbmigration.ddlgeneration.platform.SplitColumns.split;
|
import static io.ebeaninternal.dbmigration.ddlgeneration.platform.SplitColumns.split;
|
||||||
import static io.ebeaninternal.dbmigration.model.MTableIdentity.fromCreateTable;
|
import static io.ebeaninternal.dbmigration.model.MTableIdentity.fromCreateTable;
|
||||||
import static io.ebeaninternal.dbmigration.model.MTableIdentity.toCreateTable;
|
import static io.ebeaninternal.dbmigration.model.MTableIdentity.toCreateTable;
|
||||||
|
import static java.lang.System.Logger.Level.TRACE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the logical model for a given Table and everything associated to it.
|
* Holds the logical model for a given Table and everything associated to it.
|
||||||
@@ -26,7 +26,7 @@ import static io.ebeaninternal.dbmigration.model.MTableIdentity.toCreateTable;
|
|||||||
*/
|
*/
|
||||||
public class MTable {
|
public class MTable {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MTable.class);
|
private static final System.Logger logger = AppLog.getLogger(MTable.class);
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private MTable draftTable;
|
private MTable draftTable;
|
||||||
@@ -298,7 +298,7 @@ public class MTable {
|
|||||||
diffDropColumn(modelDiff, existingColumn);
|
diffDropColumn(modelDiff, existingColumn);
|
||||||
} else if (newColumn.isDraftOnly() && !draft) {
|
} else if (newColumn.isDraftOnly() && !draft) {
|
||||||
// effectively a drop column (draft only column on a non-draft table)
|
// effectively a drop column (draft only column on a non-draft table)
|
||||||
logger.trace("... drop column {} from table {} as now draftOnly", newColumn.getName(), name);
|
logger.log(TRACE, "... drop column {0} from table {1} as now draftOnly", newColumn.getName(), name);
|
||||||
diffDropColumn(modelDiff, existingColumn);
|
diffDropColumn(modelDiff, existingColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-5
@@ -1,11 +1,10 @@
|
|||||||
package io.ebeaninternal.dbmigration.model;
|
package io.ebeaninternal.dbmigration.model;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import io.avaje.applog.AppLog;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import io.ebean.migration.MigrationVersion;
|
import io.ebean.migration.MigrationVersion;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,7 +14,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class MigrationModel {
|
public class MigrationModel {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(MigrationModel.class);
|
private static final System.Logger logger = AppLog.getLogger(MigrationModel.class);
|
||||||
|
|
||||||
private final ModelContainer model = new ModelContainer();
|
private final ModelContainer model = new ModelContainer();
|
||||||
private final File modelDirectory;
|
private final File modelDirectory;
|
||||||
@@ -53,7 +52,7 @@ public class MigrationModel {
|
|||||||
|
|
||||||
if (!initMigration) {
|
if (!initMigration) {
|
||||||
for (MigrationResource migrationResource : resources) {
|
for (MigrationResource migrationResource : resources) {
|
||||||
logger.debug("read {}", migrationResource);
|
logger.log(Level.DEBUG, "read {0}", migrationResource);
|
||||||
model.apply(migrationResource.read(), migrationResource.version());
|
model.apply(migrationResource.read(), migrationResource.version());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -1,5 +1,6 @@
|
|||||||
package io.ebeaninternal.dbmigration.model;
|
package io.ebeaninternal.dbmigration.model;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.config.DatabaseConfig;
|
import io.ebean.config.DatabaseConfig;
|
||||||
import io.ebean.config.dbplatform.DatabasePlatform;
|
import io.ebean.config.dbplatform.DatabasePlatform;
|
||||||
import io.ebean.util.IOUtils;
|
import io.ebean.util.IOUtils;
|
||||||
@@ -10,12 +11,11 @@ import io.ebeaninternal.dbmigration.ddlgeneration.platform.PlatformDdl;
|
|||||||
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
import io.ebeaninternal.dbmigration.migration.ChangeSet;
|
||||||
import io.ebeaninternal.dbmigration.migration.ChangeSetType;
|
import io.ebeaninternal.dbmigration.migration.ChangeSetType;
|
||||||
import io.ebeaninternal.dbmigration.migration.Migration;
|
import io.ebeaninternal.dbmigration.migration.Migration;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,7 +23,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class PlatformDdlWriter {
|
public class PlatformDdlWriter {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(PlatformDdlWriter.class);
|
private static final System.Logger logger = AppLog.getLogger(PlatformDdlWriter.class);
|
||||||
|
|
||||||
private final DatabaseConfig databaseConfig;
|
private final DatabaseConfig databaseConfig;
|
||||||
private final PlatformDdl platformDdl;
|
private final PlatformDdl platformDdl;
|
||||||
@@ -107,7 +107,7 @@ public class PlatformDdlWriter {
|
|||||||
File subPath = new File(path, suffix);
|
File subPath = new File(path, suffix);
|
||||||
if (!subPath.exists()) {
|
if (!subPath.exists()) {
|
||||||
if (!subPath.mkdirs()) {
|
if (!subPath.mkdirs()) {
|
||||||
logger.error("failed to create directories for " + subPath.getAbsolutePath());
|
logger.log(Level.ERROR, "failed to create directories for " + subPath.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return subPath;
|
return subPath;
|
||||||
|
|||||||
+4
-4
@@ -1,14 +1,14 @@
|
|||||||
package io.ebeaninternal.extraddl.model;
|
package io.ebeaninternal.extraddl.model;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.annotation.Platform;
|
import io.ebean.annotation.Platform;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
|
|
||||||
import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
|
import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
|
|||||||
*/
|
*/
|
||||||
public class ExtraDdlXmlReader {
|
public class ExtraDdlXmlReader {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ExtraDdlXmlReader.class);
|
private static final System.Logger logger = AppLog.getLogger(ExtraDdlXmlReader.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the combined extra DDL that should be run given the platform name.
|
* Return the combined extra DDL that should be run given the platform name.
|
||||||
@@ -42,7 +42,7 @@ public class ExtraDdlXmlReader {
|
|||||||
StringBuilder sb = new StringBuilder(300);
|
StringBuilder sb = new StringBuilder(300);
|
||||||
for (DdlScript script : read.getDdlScript()) {
|
for (DdlScript script : read.getDdlScript()) {
|
||||||
if (script.isDrop() == drops && matchPlatform(platform, script.getPlatforms())) {
|
if (script.isDrop() == drops && matchPlatform(platform, script.getPlatforms())) {
|
||||||
logger.debug("include script {}", script.getName());
|
logger.log(Level.DEBUG, "include script {}", script.getName());
|
||||||
String value = script.getValue();
|
String value = script.getValue();
|
||||||
sb.append(value);
|
sb.append(value);
|
||||||
if (value.lastIndexOf(';') == -1) {
|
if (value.lastIndexOf(';') == -1) {
|
||||||
|
|||||||
@@ -1,24 +1,24 @@
|
|||||||
package io.localtest;
|
package io.localtest;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.DB;
|
import io.ebean.DB;
|
||||||
import io.ebean.Database;
|
import io.ebean.Database;
|
||||||
import io.ebean.annotation.PersistBatch;
|
import io.ebean.annotation.PersistBatch;
|
||||||
import io.ebean.annotation.Platform;
|
import io.ebean.annotation.Platform;
|
||||||
import io.ebeaninternal.api.SpiEbeanServer;
|
import io.ebeaninternal.api.SpiEbeanServer;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
public abstract class BaseTestCase {
|
public abstract class BaseTestCase {
|
||||||
|
|
||||||
protected static Logger logger = LoggerFactory.getLogger(BaseTestCase.class);
|
protected static System.Logger logger = AppLog.getLogger(BaseTestCase.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this is the clock delta that may occur between testing machine and db server.
|
* this is the clock delta that may occur between testing machine and db server.
|
||||||
* If the clock delta of DB server is in future, an "asOf" query may not find the
|
* If the clock delta of DB server is in future, an "asOf" query may not find the
|
||||||
* correct entry.
|
* correct entry.
|
||||||
*
|
* <p>
|
||||||
* Note: That some tests may use a Thread.sleep to wait, so that the local system clock
|
* Note: That some tests may use a Thread.sleep to wait, so that the local system clock
|
||||||
* can catch up. So don't set that to a too high value.
|
* can catch up. So don't set that to a too high value.
|
||||||
*/
|
*/
|
||||||
@@ -35,7 +35,7 @@ public abstract class BaseTestCase {
|
|||||||
// First try, if we get the default server. If this fails, all tests will fail.
|
// First try, if we get the default server. If this fails, all tests will fail.
|
||||||
DB.getDefault();
|
DB.getDefault();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
logger.error("Fatal error while getting ebean-server. Exiting...", e);
|
logger.log(Level.ERROR, "Fatal error while getting ebean-server. Exiting...", e);
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,6 @@
|
|||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
<version>1.7.33</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.ebean</groupId>
|
<groupId>io.ebean</groupId>
|
||||||
<artifactId>ebean-externalmapping-api</artifactId>
|
<artifactId>ebean-externalmapping-api</artifactId>
|
||||||
|
|||||||
-7
@@ -4,8 +4,6 @@ import io.avaje.classpath.scanner.ClassPathScanner;
|
|||||||
import io.avaje.classpath.scanner.ClassPathScannerFactory;
|
import io.avaje.classpath.scanner.ClassPathScannerFactory;
|
||||||
import io.avaje.classpath.scanner.Resource;
|
import io.avaje.classpath.scanner.Resource;
|
||||||
import io.ebeaninternal.xmapping.api.XmapEbean;
|
import io.ebeaninternal.xmapping.api.XmapEbean;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,8 +14,6 @@ import java.util.ServiceLoader;
|
|||||||
*/
|
*/
|
||||||
class InternalConfigXmlRead {
|
class InternalConfigXmlRead {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(InternalConfigXmlRead.class);
|
|
||||||
|
|
||||||
private final ToXmapEbean to = new ToXmapEbean();
|
private final ToXmapEbean to = new ToXmapEbean();
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
private final List<String> mappingLocations;
|
private final List<String> mappingLocations;
|
||||||
@@ -40,7 +36,6 @@ class InternalConfigXmlRead {
|
|||||||
private List<Resource> xmlMappingResources() {
|
private List<Resource> xmlMappingResources() {
|
||||||
List<ClassPathScanner> scanners = scanners();
|
List<ClassPathScanner> scanners = scanners();
|
||||||
List<Resource> resourceList = new ArrayList<>();
|
List<Resource> resourceList = new ArrayList<>();
|
||||||
long st = System.currentTimeMillis();
|
|
||||||
if (mappingLocations != null && !mappingLocations.isEmpty()) {
|
if (mappingLocations != null && !mappingLocations.isEmpty()) {
|
||||||
for (ClassPathScanner finder : scanners) {
|
for (ClassPathScanner finder : scanners) {
|
||||||
for (String mappingLocation : mappingLocations) {
|
for (String mappingLocation : mappingLocations) {
|
||||||
@@ -48,8 +43,6 @@ class InternalConfigXmlRead {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long searchTime = System.currentTimeMillis() - st;
|
|
||||||
log.debug("Classpath search mappings[{}] searchTime[{}]", resourceList.size(), searchTime);
|
|
||||||
return resourceList;
|
return resourceList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ module io.ebean.xmapping.xml {
|
|||||||
requires transitive java.xml.bind;
|
requires transitive java.xml.bind;
|
||||||
requires io.avaje.classpath.scanner.api;
|
requires io.avaje.classpath.scanner.api;
|
||||||
requires io.avaje.classpath.scanner;
|
requires io.avaje.classpath.scanner;
|
||||||
requires static org.slf4j;
|
|
||||||
requires static java.sql; // for testing
|
requires static java.sql; // for testing
|
||||||
|
|
||||||
uses ClassPathScannerFactory;
|
uses ClassPathScannerFactory;
|
||||||
|
|||||||
@@ -54,14 +54,6 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- expected to be provided -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-api</artifactId>
|
|
||||||
<version>1.7.33</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- optionally use geolatte-geom -->
|
<!-- optionally use geolatte-geom -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.geolatte</groupId>
|
<groupId>org.geolatte</groupId>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.ebean.redis;
|
package io.ebean.redis;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.cache.ServerCache;
|
import io.ebean.cache.ServerCache;
|
||||||
import io.ebean.cache.ServerCacheConfig;
|
import io.ebean.cache.ServerCacheConfig;
|
||||||
import io.ebean.cache.ServerCacheOptions;
|
import io.ebean.cache.ServerCacheOptions;
|
||||||
@@ -11,19 +12,20 @@ import io.ebean.metric.TimedMetric;
|
|||||||
import io.ebean.metric.TimedMetricStats;
|
import io.ebean.metric.TimedMetricStats;
|
||||||
import io.ebean.redis.encode.Encode;
|
import io.ebean.redis.encode.Encode;
|
||||||
import io.ebean.redis.encode.EncodePrefixKey;
|
import io.ebean.redis.encode.EncodePrefixKey;
|
||||||
import org.slf4j.Logger;
|
import redis.clients.jedis.Jedis;
|
||||||
import org.slf4j.LoggerFactory;
|
import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.*;
|
import redis.clients.jedis.Transaction;
|
||||||
import redis.clients.jedis.params.ScanParams;
|
import redis.clients.jedis.params.ScanParams;
|
||||||
import redis.clients.jedis.params.SetParams;
|
import redis.clients.jedis.params.SetParams;
|
||||||
import redis.clients.jedis.resps.ScanResult;
|
import redis.clients.jedis.resps.ScanResult;
|
||||||
import redis.clients.jedis.util.SafeEncoder;
|
import redis.clients.jedis.util.SafeEncoder;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
final class RedisCache implements ServerCache {
|
final class RedisCache implements ServerCache {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RedisCache.class);
|
private static final System.Logger log = AppLog.getLogger(RedisCache.class);
|
||||||
|
|
||||||
private static final String CURSOR_0 = "0";
|
private static final String CURSOR_0 = "0";
|
||||||
private static final byte[] CURSOR_0_BYTES = SafeEncoder.encode(CURSOR_0);
|
private static final byte[] CURSOR_0_BYTES = SafeEncoder.encode(CURSOR_0);
|
||||||
@@ -67,7 +69,7 @@ final class RedisCache implements ServerCache {
|
|||||||
if (cacheOptions != null) {
|
if (cacheOptions != null) {
|
||||||
final int maxSecsToLive = cacheOptions.getMaxSecsToLive();
|
final int maxSecsToLive = cacheOptions.getMaxSecsToLive();
|
||||||
if (maxSecsToLive > 0) {
|
if (maxSecsToLive > 0) {
|
||||||
return new SetParams().ex((long)maxSecsToLive);
|
return new SetParams().ex((long) maxSecsToLive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -104,17 +106,17 @@ final class RedisCache implements ServerCache {
|
|||||||
}
|
}
|
||||||
return valueEncode.decode(data);
|
return valueEncode.decode(data);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error decoding data, treated as cache miss", e);
|
log.log(Level.ERROR, "Error decoding data, treated as cache miss", e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void errorOnRead(Exception e) {
|
private void errorOnRead(Exception e) {
|
||||||
log.warn("Error when reading redis cache", e);
|
log.log(Level.WARNING, "Error when reading redis cache", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void errorOnWrite(Exception e) {
|
private void errorOnWrite(Exception e) {
|
||||||
log.warn("Error when writing redis cache", e);
|
log.log(Level.WARNING, "Error when writing redis cache", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package io.ebean.redis;
|
package io.ebean.redis;
|
||||||
|
|
||||||
|
import io.avaje.applog.AppLog;
|
||||||
import io.ebean.BackgroundExecutor;
|
import io.ebean.BackgroundExecutor;
|
||||||
import io.ebean.cache.ServerCache;
|
import io.ebean.cache.*;
|
||||||
import io.ebean.cache.ServerCacheConfig;
|
|
||||||
import io.ebean.cache.ServerCacheFactory;
|
|
||||||
import io.ebean.cache.ServerCacheNotification;
|
|
||||||
import io.ebean.cache.ServerCacheNotify;
|
|
||||||
import io.ebean.config.DatabaseConfig;
|
import io.ebean.config.DatabaseConfig;
|
||||||
import io.ebean.meta.MetricVisitor;
|
import io.ebean.meta.MetricVisitor;
|
||||||
import io.ebean.metric.MetricFactory;
|
import io.ebean.metric.MetricFactory;
|
||||||
@@ -18,18 +15,13 @@ import io.ebean.redis.topic.DaemonTopicRunner;
|
|||||||
import io.ebeaninternal.server.cache.DefaultServerCache;
|
import io.ebeaninternal.server.cache.DefaultServerCache;
|
||||||
import io.ebeaninternal.server.cache.DefaultServerCacheConfig;
|
import io.ebeaninternal.server.cache.DefaultServerCacheConfig;
|
||||||
import io.ebeaninternal.server.cache.DefaultServerQueryCache;
|
import io.ebeaninternal.server.cache.DefaultServerQueryCache;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import redis.clients.jedis.BinaryJedisPubSub;
|
import redis.clients.jedis.BinaryJedisPubSub;
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.util.SafeEncoder;
|
import redis.clients.jedis.util.SafeEncoder;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.*;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.lang.System.Logger.Level;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -41,11 +33,11 @@ import static java.util.Arrays.asList;
|
|||||||
|
|
||||||
final class RedisCacheFactory implements ServerCacheFactory {
|
final class RedisCacheFactory implements ServerCacheFactory {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RedisCacheFactory.class);
|
private static final System.Logger log = AppLog.getLogger(RedisCacheFactory.class);
|
||||||
|
|
||||||
private static final Logger queryLogger = LoggerFactory.getLogger("io.ebean.cache.QUERY");
|
private static final System.Logger queryLogger = AppLog.getLogger("io.ebean.cache.QUERY");
|
||||||
private static final Logger logger = LoggerFactory.getLogger("io.ebean.cache.CACHE");
|
private static final System.Logger logger = AppLog.getLogger("io.ebean.cache.CACHE");
|
||||||
private static final Logger tableModLogger = LoggerFactory.getLogger("io.ebean.cache.TABLEMODS");
|
private static final System.Logger tableModLogger = AppLog.getLogger("io.ebean.cache.TABLEMODS");
|
||||||
|
|
||||||
private static final int MSG_NEARCACHE_CLEAR = 1;
|
private static final int MSG_NEARCACHE_CLEAR = 1;
|
||||||
private static final int MSG_NEARCACHE_KEYS = 2;
|
private static final int MSG_NEARCACHE_KEYS = 2;
|
||||||
@@ -113,7 +105,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
redisConfig = new RedisConfig();
|
redisConfig = new RedisConfig();
|
||||||
}
|
}
|
||||||
redisConfig.loadProperties(config.getProperties());
|
redisConfig.loadProperties(config.getProperties());
|
||||||
log.info("using l2cache redis host {}:{}", redisConfig.getServer(), redisConfig.getPort());
|
log.log(Level.INFO, "using l2cache redis host {0}:{1}", redisConfig.getServer(), redisConfig.getPort());
|
||||||
return redisConfig.createPool();
|
return redisConfig.createPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +160,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
try {
|
try {
|
||||||
RQueryCache cache = queryCaches.get(config.getCacheKey());
|
RQueryCache cache = queryCaches.get(config.getCacheKey());
|
||||||
if (cache == null) {
|
if (cache == null) {
|
||||||
logger.debug("create query cache [{}]", config.getCacheKey());
|
logger.log(Level.DEBUG, "create query cache [{0}]", config.getCacheKey());
|
||||||
cache = new RQueryCache(new DefaultServerCacheConfig(config));
|
cache = new RQueryCache(new DefaultServerCacheConfig(config));
|
||||||
cache.periodicTrim(executor);
|
cache.periodicTrim(executor);
|
||||||
queryCaches.put(config.getCacheKey(), cache);
|
queryCaches.put(config.getCacheKey(), cache);
|
||||||
@@ -222,7 +214,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
* Process the invalidation message coming from the cluster.
|
* Process the invalidation message coming from the cluster.
|
||||||
*/
|
*/
|
||||||
private void invalidate() {
|
private void invalidate() {
|
||||||
queryLogger.debug(" CLEAR {}(*) - cluster invalidate", name);
|
queryLogger.log(Level.DEBUG, " CLEAR {0}(*) - cluster invalidate", name);
|
||||||
super.clear();
|
super.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,8 +233,8 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
msg.append(table).append(",");
|
msg.append(table).append(",");
|
||||||
}
|
}
|
||||||
String formattedMsg = msg.toString();
|
String formattedMsg = msg.toString();
|
||||||
if (tableModLogger.isDebugEnabled()) {
|
if (tableModLogger.isLoggable(Level.DEBUG)) {
|
||||||
tableModLogger.debug("Publish TableMods - {}", formattedMsg);
|
tableModLogger.log(Level.DEBUG, "Publish TableMods - {0}", formattedMsg);
|
||||||
}
|
}
|
||||||
sendTableMod(formattedMsg);
|
sendTableMod(formattedMsg);
|
||||||
}
|
}
|
||||||
@@ -270,8 +262,8 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
private void processTableNotify(String rawMessage) {
|
private void processTableNotify(String rawMessage) {
|
||||||
long nanos = System.nanoTime();
|
long nanos = System.nanoTime();
|
||||||
try {
|
try {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isLoggable(Level.DEBUG)) {
|
||||||
logger.debug("processTableNotify {}", rawMessage);
|
logger.log(Level.DEBUG, "processTableNotify {0}", rawMessage);
|
||||||
}
|
}
|
||||||
Set<String> tables = new HashSet<>(asList(rawMessage.split(",")));
|
Set<String> tables = new HashSet<>(asList(rawMessage.split(",")));
|
||||||
listener.notify(new ServerCacheNotification(tables));
|
listener.notify(new ServerCacheNotification(tables));
|
||||||
@@ -290,7 +282,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
try {
|
try {
|
||||||
sendMessage(messageInvalidateKeys(cacheKey, keySet));
|
sendMessage(messageInvalidateKeys(cacheKey, keySet));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("failed to transmit invalidateKeys() message", e);
|
logger.log(Level.ERROR, "failed to transmit invalidateKeys() message", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -299,7 +291,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
try {
|
try {
|
||||||
sendMessage(messageInvalidateKey(cacheKey, id));
|
sendMessage(messageInvalidateKey(cacheKey, id));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("failed to transmit invalidateKeys() message", e);
|
logger.log(Level.ERROR, "failed to transmit invalidateKeys() message", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +300,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
try {
|
try {
|
||||||
sendMessage(messageInvalidateClear(cacheKey));
|
sendMessage(messageInvalidateClear(cacheKey));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("failed to transmit invalidateKeys() message", e);
|
logger.log(Level.ERROR, "failed to transmit invalidateKeys() message", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +364,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyConnected() {
|
public void notifyConnected() {
|
||||||
logger.info("Established connection to Redis");
|
logger.log(Level.INFO, "Established connection to Redis");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -403,8 +395,8 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
}
|
}
|
||||||
msgType = oi.readInt();
|
msgType = oi.readInt();
|
||||||
cacheKey = oi.readUTF();
|
cacheKey = oi.readUTF();
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isLoggable(Level.DEBUG)) {
|
||||||
logger.debug("processNearCacheMessage serverId:{} type:{} cacheKey:{}", sourceServerId, msgType, cacheKey);
|
logger.log(Level.DEBUG, "processNearCacheMessage serverId:{0} type:{1} cacheKey:{2}", sourceServerId, msgType, cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
@@ -431,7 +423,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException | ClassNotFoundException e) {
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
logger.error("failed to decode near cache message [" + SafeEncoder.encode(message) + "] for cache:" + cacheKey, e);
|
logger.log(Level.ERROR, "failed to decode near cache message [" + SafeEncoder.encode(message) + "] for cache:" + cacheKey, e);
|
||||||
if (cacheKey != null) {
|
if (cacheKey != null) {
|
||||||
nearCacheInvalidateClear(cacheKey);
|
nearCacheInvalidateClear(cacheKey);
|
||||||
}
|
}
|
||||||
@@ -457,10 +449,10 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
queryCacheInvalidate(split[2]);
|
queryCacheInvalidate(split[2]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger.error("Unknown L2 message type[{}] on redis channel - message[{}] ", split[0], message);
|
logger.log(Level.ERROR, "Unknown L2 message type[{0}] on redis channel - message[{1}] ", split[0], message);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error handling L2 message[" + message + "]", e);
|
logger.log(Level.ERROR, "Error handling L2 message[" + message + "]", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -503,7 +495,7 @@ final class RedisCacheFactory implements ServerCacheFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void warnNearCacheNotFound(String cacheKey) {
|
private void warnNearCacheNotFound(String cacheKey) {
|
||||||
logger.warn("No near cache found for cacheKey [" + cacheKey + "] yet - probably on startup");
|
logger.log(Level.WARNING, "No near cache found for cacheKey [" + cacheKey + "] yet - probably on startup");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
package io.ebean.redis.topic;
|
package io.ebean.redis.topic;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import io.avaje.applog.AppLog;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import redis.clients.jedis.Jedis;
|
import redis.clients.jedis.Jedis;
|
||||||
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.exceptions.JedisException;
|
import redis.clients.jedis.exceptions.JedisException;
|
||||||
|
|
||||||
|
import java.lang.System.Logger.Level;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ import java.util.TimerTask;
|
|||||||
*/
|
*/
|
||||||
public final class DaemonTopicRunner {
|
public final class DaemonTopicRunner {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(DaemonTopicRunner.class);
|
private static final System.Logger log = AppLog.getLogger(DaemonTopicRunner.class);
|
||||||
|
|
||||||
private static final long reconnectWaitMillis = 1000;
|
private static final long reconnectWaitMillis = 1000;
|
||||||
|
|
||||||
@@ -49,13 +49,13 @@ public final class DaemonTopicRunner {
|
|||||||
try {
|
try {
|
||||||
subscribe();
|
subscribe();
|
||||||
} catch (JedisException e) {
|
} catch (JedisException e) {
|
||||||
log.debug("... redis subscribe connection attempt:{} failed:{}", attempts, e.getMessage());
|
log.log(Level.DEBUG, "... redis subscribe connection attempt:{0} failed:{1}", attempts, e.getMessage());
|
||||||
try {
|
try {
|
||||||
// wait a little before retrying
|
// wait a little before retrying
|
||||||
Thread.sleep(reconnectWaitMillis);
|
Thread.sleep(reconnectWaitMillis);
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
log.warn("Interrupted redis re-connection wait", e1);
|
log.log(Level.WARNING, "Interrupted redis re-connection wait", e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,13 +70,13 @@ public final class DaemonTopicRunner {
|
|||||||
try {
|
try {
|
||||||
daemonTopic.subscribe(jedis);
|
daemonTopic.subscribe(jedis);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Lost connection to topic, starting re-connection loop", e);
|
log.log(Level.ERROR, "Lost connection to topic, starting re-connection loop", e);
|
||||||
attemptConnections();
|
attemptConnections();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
jedis.close();
|
jedis.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Error closing probably broken Redis connection", e);
|
log.log(Level.WARNING, "Error closing probably broken Redis connection", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -14,10 +14,9 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>io.avaje</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>avaje-applog</artifactId>
|
||||||
<version>1.7.32</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
Loaded 100 of 108 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user