Skip to content

Commit e4b01e3

Browse files
committed
Improve logging message, remove javax NonNull annotation
Should migrate to using NonNullApi instead
1 parent 68b0ab8 commit e4b01e3

13 files changed

+20
-55
lines changed

ebean-migration/pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@
4747
<version>7.1</version>
4848
</dependency>
4949

50-
<dependency>
51-
<groupId>io.avaje</groupId>
52-
<artifactId>avaje-jsr305</artifactId>
53-
<version>1.2</version>
54-
<scope>provided</scope>
55-
</dependency>
56-
5750
<!-- test dependencies -->
5851

5952
<dependency>

ebean-migration/src/main/java/io/ebean/migration/DbNameUtil.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import io.ebean.migration.runner.MigrationPlatform;
44

5-
import javax.annotation.Nonnull;
65
import java.sql.*;
76

87
import static java.lang.System.Logger.Level.WARNING;
@@ -17,7 +16,6 @@ class DbNameUtil implements DbPlatformNames {
1716
* <p>
1817
* At this point only sql server has platform specific handling required (create table and for update).
1918
*/
20-
@Nonnull
2119
static String normalise(Connection connection) {
2220
try {
2321
final String productName = connection.getMetaData().getDatabaseProductName().toLowerCase();
@@ -68,7 +66,6 @@ private static String readPostgres(Connection connection) {
6866
return POSTGRES;
6967
}
7068

71-
@Nonnull
7269
static MigrationPlatform platform(String platformName) {
7370
switch (platformName) {
7471
case MYSQL:
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package io.ebean.migration;
22

3-
import javax.annotation.Nonnull;
4-
53
/**
64
* Factory to create and initialise a JdbcMigration.
75
*
@@ -12,6 +10,5 @@ public interface JdbcMigrationFactory {
1210
/**
1311
* Create a JDBC based migration given the class name.
1412
*/
15-
@Nonnull
1613
JdbcMigration createInstance(String className);
1714
}

ebean-migration/src/main/java/io/ebean/migration/MigrationConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.ebean.migration;
22

3-
import javax.annotation.Nonnull;
43
import java.sql.Connection;
54
import java.sql.DriverManager;
65
import java.sql.SQLException;
@@ -583,7 +582,6 @@ public void setPlatform(String platform) {
583582
*/
584583
public class DefaultMigrationFactory implements JdbcMigrationFactory {
585584

586-
@Nonnull
587585
@Override
588586
public JdbcMigration createInstance(String className) {
589587
try {

ebean-migration/src/main/java/io/ebean/migration/MigrationRunner.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import io.avaje.applog.AppLog;
44
import io.ebean.migration.runner.*;
55

6-
import javax.annotation.Nonnull;
76
import javax.sql.DataSource;
87
import java.sql.Connection;
98
import java.sql.SQLException;
@@ -29,23 +28,20 @@ public MigrationRunner(MigrationConfig migrationConfig) {
2928
/**
3029
* Return the migrations that would be applied if the migration is run.
3130
*/
32-
@Nonnull
3331
public List<LocalMigrationResource> checkState() {
3432
return checkState(migrationConfig.createConnection());
3533
}
3634

3735
/**
3836
* Return the migrations that would be applied if the migration is run.
3937
*/
40-
@Nonnull
4138
public List<LocalMigrationResource> checkState(DataSource dataSource) {
4239
return checkState(getConnection(dataSource));
4340
}
4441

4542
/**
4643
* Return the migrations that would be applied if the migration is run.
4744
*/
48-
@Nonnull
4945
public List<LocalMigrationResource> checkState(Connection connection) {
5046
run(connection, true);
5147
return checkMigrations;
@@ -97,15 +93,21 @@ protected void run(Connection connection, boolean checkStateMode) {
9793
return;
9894
}
9995

96+
long start = System.currentTimeMillis();
10097
connection.setAutoCommit(false);
10198
MigrationPlatform platform = derivePlatformName(migrationConfig, connection);
10299
new MigrationSchema(migrationConfig, connection).createAndSetIfNeeded();
103100

104101
MigrationTable table = new MigrationTable(migrationConfig, connection, checkStateMode, platform);
105102
table.createIfNeededAndLock();
106103
try {
107-
runMigrations(resources, table, checkStateMode);
104+
List<LocalMigrationResource> migrations = resources.getVersions();
105+
runMigrations(migrations, table, checkStateMode);
108106
connection.commit();
107+
if (!checkStateMode) {
108+
long exeMillis = System.currentTimeMillis() - start;
109+
log.log(INFO, "DB migrations completed in {0}ms - executed:{1} size:{2}", exeMillis, table.count(), migrations.size());
110+
}
109111
table.runNonTransactional();
110112
} finally {
111113
table.unlockMigrationTable();
@@ -127,9 +129,8 @@ protected void run(Connection connection, boolean checkStateMode) {
127129
/**
128130
* Run all the migrations as needed.
129131
*/
130-
private void runMigrations(LocalMigrationResources resources, MigrationTable table, boolean checkStateMode) throws SQLException {
132+
private void runMigrations(List<LocalMigrationResource> localVersions, MigrationTable table, boolean checkStateMode) throws SQLException {
131133
// get the migrations in version order
132-
List<LocalMigrationResource> localVersions = resources.getVersions();
133134
if (table.isEmpty()) {
134135
LocalMigrationResource initVersion = getInitVersion();
135136
if (initVersion != null) {
@@ -139,7 +140,6 @@ private void runMigrations(LocalMigrationResources resources, MigrationTable tab
139140
return;
140141
}
141142
}
142-
log.log(INFO, "Local migrations:{0} existing migrations:{1} checkState:{2}", localVersions.size(), table.size(), checkStateMode);
143143
checkMigrations = table.runAll(localVersions);
144144
}
145145

ebean-migration/src/main/java/io/ebean/migration/runner/LocalDdlMigrationResource.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import io.avaje.classpath.scanner.Resource;
44
import io.ebean.migration.MigrationVersion;
55

6-
import javax.annotation.Nonnull;
76
import java.nio.charset.StandardCharsets;
87
import java.util.List;
98

@@ -25,7 +24,6 @@ public LocalDdlMigrationResource(MigrationVersion version, String location, Reso
2524
/**
2625
* Return the content for the migration apply ddl script.
2726
*/
28-
@Nonnull
2927
public String getContent() {
3028
try {
3129
return resource.loadAsString(StandardCharsets.UTF_8);

ebean-migration/src/main/java/io/ebean/migration/runner/LocalJdbcMigrationResource.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import io.ebean.migration.MigrationChecksumProvider;
55
import io.ebean.migration.MigrationVersion;
66

7-
import javax.annotation.Nonnull;
8-
97
/**
108
* A DB migration resource (JdbcMigration with version).
119
*
@@ -26,7 +24,6 @@ public LocalJdbcMigrationResource(MigrationVersion version, String location, Jdb
2624
/**
2725
* Return the migration
2826
*/
29-
@Nonnull
3027
public JdbcMigration getMigration() {
3128
return migration;
3229
}
@@ -42,7 +39,6 @@ public int getChecksum() {
4239
}
4340
}
4441

45-
@Nonnull
4642
@Override
4743
public String getContent() {
4844
return "location:" + location;

ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResource.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import io.ebean.migration.MigrationVersion;
44

5-
import javax.annotation.Nonnull;
6-
75
/**
86
* A DB migration resource (DDL or Jdbc)
97
*/
@@ -52,7 +50,6 @@ public boolean isRepeatableLast() {
5250
/**
5351
* Return the "key" that identifies the migration.
5452
*/
55-
@Nonnull
5653
public String key() {
5754
if (isRepeatable()) {
5855
return version.getComment().toLowerCase();
@@ -64,7 +61,6 @@ public String key() {
6461
/**
6562
* Return the migration comment.
6663
*/
67-
@Nonnull
6864
public String getComment() {
6965
String comment = version.getComment();
7066
return (comment == null || comment.isEmpty()) ? "-" : comment;
@@ -81,7 +77,6 @@ public int compareTo(LocalMigrationResource o) {
8177
/**
8278
* Return the underlying migration version.
8379
*/
84-
@Nonnull
8580
public MigrationVersion getVersion() {
8681
return version;
8782
}
@@ -96,13 +91,11 @@ public String getLocation() {
9691
/**
9792
* Return the content of the migration.
9893
*/
99-
@Nonnull
10094
public abstract String getContent();
10195

10296
/**
10397
* Return the type code ("R" or "V") for this migration.
10498
*/
105-
@Nonnull
10699
public String getType() {
107100
return type;
108101
}

ebean-migration/src/main/java/io/ebean/migration/runner/LocalMigrationResources.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import io.ebean.migration.MigrationConfig;
77
import io.ebean.migration.MigrationVersion;
88

9-
import javax.annotation.Nonnull;
109
import java.util.ArrayList;
1110
import java.util.Collections;
1211
import java.util.List;
@@ -135,7 +134,6 @@ private LocalMigrationResource createScriptMigration(Resource resource, String f
135134
/**
136135
* Return the list of migration resources in version order.
137136
*/
138-
@Nonnull
139137
public List<LocalMigrationResource> getVersions() {
140138
return versions;
141139
}

ebean-migration/src/main/java/io/ebean/migration/runner/MigrationPlatform.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import io.ebean.ddlrunner.DdlDetect;
44

5-
import javax.annotation.Nonnull;
65
import java.sql.*;
76
import java.util.ArrayList;
87
import java.util.List;
@@ -80,7 +79,6 @@ private int lockRows(String sqlTable, Connection connection) throws SQLException
8079
/**
8180
* Read the existing migrations from the db migration table.
8281
*/
83-
@Nonnull
8482
List<MigrationMetaRow> readExistingMigrations(String sqlTable, Connection connection) throws SQLException {
8583
final String selectSql = sqlSelectForReading(sqlTable);
8684
List<MigrationMetaRow> rows = new ArrayList<>();
@@ -97,15 +95,13 @@ List<MigrationMetaRow> readExistingMigrations(String sqlTable, Connection connec
9795
/**
9896
* Return the SQL to lock the rows in db migration table with row locking.
9997
*/
100-
@Nonnull
10198
String sqlSelectForUpdate(String table) {
10299
return BASE_SELECT_ID + table + forUpdateSuffix;
103100
}
104101

105102
/**
106103
* Return the SQL to read the db migration table.
107104
*/
108-
@Nonnull
109105
String sqlSelectForReading(String table) {
110106
return BASE_SELECT_ALL + table + forUpdateSuffix;
111107
}

0 commit comments

Comments
 (0)