Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roman/file split feature #161

Open
wants to merge 11 commits into
base: josh/refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/main/java/org/ngafid/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ private static void initializeConnectionPool() {
config.setUsername(dbUser);
config.setPassword(dbPassword);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should match the Database.java from josh/refactor

config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSize", "64");
config.addDataSourceProperty("prepStmtCacheSize", "64");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
config.setMaximumPoolSize(256);
config.setMaximumPoolSize(32);
config.setMaxLifetime(60000);
CONNECTION_POOL = new HikariDataSource(config);
}
}
}
4 changes: 3 additions & 1 deletion src/main/java/org/ngafid/ProcessUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ public static void main(String[] arguments) throws SQLException {
* non-existant
* upload. This can cause the upload process to crash.
*
* @param connection is the connection to the database
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProcessUpload from josh/refactor currently throw errors for me, needs revisiting.

*/
public static void removeNoUploadFlights() {
try (Connection connection = Database.getConnection()) {
Expand All @@ -134,6 +133,9 @@ public static void removeNoUploadFlights() {
}

public static void operateAsDaemon() throws SQLException {

LOG.info("Operate as daemon log. ");

while (true) {
Instant start = Instant.now();

Expand Down
29 changes: 28 additions & 1 deletion src/main/java/org/ngafid/common/TimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,38 @@ public static String toUTC(String date, String time, String offset) {

}

/**
* List of DateTime formats supported.
*/
private static final List<DateTimeFormatter> dateTimeFormatters = Arrays.asList(
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"),
DateTimeFormatter.ofPattern("M/d/yyyy HH:mm:ss")

);

/**
* Helper method to parse the date and time using the declared formatters
* @param dateTimeString
* @return
*/
public static LocalDateTime parseDateTime(String dateTimeString) {
String normalizedDateTime = dateTimeString.replaceAll("\\s+", " "); // Replaces multiple spaces with a single space
for (DateTimeFormatter formatter : dateTimeFormatters) {
try {
return LocalDateTime.parse(normalizedDateTime, formatter);
} catch (Exception e) {
// Continue trying other formats
}
}
// If none of the formats work, throw an exception or handle it appropriately
throw new IllegalArgumentException("Date format not supported: " + normalizedDateTime);
}

public static OffsetDateTime convertToOffset(String originalDate, String originalTime, String originalOffset, String newOffset) {
//System.out.println("original: \t" + originalTime + " " + originalOffset + " new offset: "+ newOffset);

// create a LocalDateTime using the date time passed as parameter
LocalDateTime ldt = LocalDateTime.parse(originalDate + " " + originalTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime ldt = parseDateTime(originalDate + " " + originalTime);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses parseDateTime method (utilizes multiple parse formats) instead of doing parsing itself.


//fix bad offset values
originalOffset = updateBadOffset(ldt, originalOffset);
Expand Down
Loading