This is an automated email from the ASF dual-hosted git repository. rzo1 pushed a commit to branch STORM-4108-Remove-joda-time in repository https://gitbox.apache.org/repos/asf/storm.git
commit 3cb1ea6783e1028ae19b53ef79a90ff44b38a075 Author: Richard Zowalla <[email protected]> AuthorDate: Mon Nov 11 20:48:10 2024 +0100 STORM-4108 - Remove joda-time --- DEPENDENCY-LICENSES | 1 - LICENSE-binary | 1 - docs/storm-sql-example.md | 3 --- integration-test/pom.xml | 4 ---- .../main/java/org/apache/storm/st/utils/TimeUtil.java | 15 ++++++++------- .../apache/storm/st/tests/window/WindowVerifier.java | 19 +++++++++++-------- .../org/apache/storm/st/wrapper/DecoratedLogLine.java | 15 +++++++-------- pom.xml | 6 ------ storm-core/pom.xml | 4 ---- 9 files changed, 26 insertions(+), 42 deletions(-) diff --git a/DEPENDENCY-LICENSES b/DEPENDENCY-LICENSES index b38f864ef..0cd316468 100644 --- a/DEPENDENCY-LICENSES +++ b/DEPENDENCY-LICENSES @@ -234,7 +234,6 @@ List of third-party dependencies grouped by their license type. * JDO API (javax.jdo:jdo-api:3.0.1 - http://db.apache.org/jdo) * JDO API (org.datanucleus:javax.jdo:3.2.0-m3 - http://www.datanucleus.org/#/javax.jdo) * Jettison (org.codehaus.jettison:jettison:1.5.4 - https://github.com/jettison-json/jettison) - * Joda-Time (joda-time:joda-time:2.12.7 - https://www.joda.org/joda-time/) * JPam (net.sf.jpam:jpam:1.1 - http://jpam.sf.net) * jsonschema2pojo-core (org.jsonschema2pojo:jsonschema2pojo-core:1.0.2 - https://github.com/joelittlejohn/jsonschema2pojo/jsonschema2pojo-core) * JSON Small and Fast Parser (net.minidev:json-smart:2.5.1 - https://urielch.github.io/) diff --git a/LICENSE-binary b/LICENSE-binary index 680cb7df7..6614669e3 100644 --- a/LICENSE-binary +++ b/LICENSE-binary @@ -857,7 +857,6 @@ The license texts of these dependencies can be found in the licenses directory. * JDO API (javax.jdo:jdo-api:3.0.1 - http://db.apache.org/jdo) * JDO API (org.datanucleus:javax.jdo:3.2.0-m3 - http://www.datanucleus.org/#/javax.jdo) * Jettison (org.codehaus.jettison:jettison:1.5.4 - no url defined) - * Joda-Time (joda-time:joda-time:2.12.7 - https://www.joda.org/joda-time/) * jsonschema2pojo-core (org.jsonschema2pojo:jsonschema2pojo-core:1.0.2 - https://github.com/joelittlejohn/jsonschema2pojo/jsonschema2pojo-core) * JPam (net.sf.jpam:jpam:1.1 - http://jpam.sf.net) * JSON Small and Fast Parser (net.minidev:json-smart:2.5.1 - https://urielch.github.io/) diff --git a/docs/storm-sql-example.md b/docs/storm-sql-example.md index fbd53185f..0d68d7f67 100644 --- a/docs/storm-sql-example.md +++ b/docs/storm-sql-example.md @@ -243,9 +243,6 @@ The implementation of GetTime2 is here: ``` package org.apache.storm.sql.runtime.functions.scalar.datetime; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - public class GetTime2 { public static Long evaluate(String dateString, String dateFormat) { try { diff --git a/integration-test/pom.xml b/integration-test/pom.xml index c5e0ce1d0..d54a4ff2f 100644 --- a/integration-test/pom.xml +++ b/integration-test/pom.xml @@ -59,10 +59,6 @@ <version>7.10.2</version> <scope>test</scope> </dependency> - <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - </dependency> <dependency> <groupId>org.apache.storm</groupId> <artifactId>storm-client</artifactId> diff --git a/integration-test/src/main/java/org/apache/storm/st/utils/TimeUtil.java b/integration-test/src/main/java/org/apache/storm/st/utils/TimeUtil.java index e43fb05e0..887ff14e6 100644 --- a/integration-test/src/main/java/org/apache/storm/st/utils/TimeUtil.java +++ b/integration-test/src/main/java/org/apache/storm/st/utils/TimeUtil.java @@ -17,10 +17,11 @@ package org.apache.storm.st.utils; +import java.time.Duration; +import java.time.ZonedDateTime; import java.util.concurrent.TimeUnit; import org.apache.commons.lang.exception.ExceptionUtils; -import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -43,13 +44,13 @@ public class TimeUtil { } } - public static DateTime floor(DateTime dateTime, int sec) { - long modValue = dateTime.getMillis() % (1000 * sec); - return dateTime.minus(modValue); + public static ZonedDateTime floor(ZonedDateTime dateTime, int sec) { + long modValue = dateTime.toInstant().toEpochMilli() % (1000 * sec); + return dateTime.minus(Duration.ofMillis(modValue)); } - public static DateTime ceil(DateTime dateTime, int sec) { - long modValue = dateTime.getMillis() % (1000 * sec); - return dateTime.minus(modValue).plusSeconds(sec); + public static ZonedDateTime ceil(ZonedDateTime dateTime, int sec) { + long modValue = dateTime.toInstant().toEpochMilli() % (1000 * sec); + return dateTime.minus(Duration.ofMillis(modValue)).plusSeconds(sec); } } diff --git a/integration-test/src/test/java/org/apache/storm/st/tests/window/WindowVerifier.java b/integration-test/src/test/java/org/apache/storm/st/tests/window/WindowVerifier.java index b59a0ceeb..fda6d44c9 100644 --- a/integration-test/src/test/java/org/apache/storm/st/tests/window/WindowVerifier.java +++ b/integration-test/src/test/java/org/apache/storm/st/tests/window/WindowVerifier.java @@ -17,6 +17,8 @@ package org.apache.storm.st.tests.window; import java.io.IOException; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; import java.util.List; import java.util.stream.Collectors; import org.apache.storm.st.topology.TestableTopology; @@ -27,8 +29,6 @@ import org.apache.storm.st.utils.TimeUtil; import org.apache.storm.st.wrapper.DecoratedLogLine; import org.apache.storm.st.wrapper.TopoWrap; import org.apache.storm.thrift.TException; -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -100,8 +100,11 @@ public class WindowVerifier { final List<TimeDataWindow> allBoltLogLines = topo.getDeserializedDecoratedLogLines(boltName, TimeDataWindow::fromJson); assertTrue(allBoltLogLines.size() >= minBoltEmits, "Expecting min " + minBoltEmits + " bolt emits, found: " + allBoltLogLines.size() + " \n\t" + allBoltLogLines); - - final DateTime firstWindowEndTime = TimeUtil.ceil(new DateTime(allSpoutLogLines.get(0).getDate()).withZone(DateTimeZone.UTC), slideSec); + + ZonedDateTime firstWindowEndTime = TimeUtil.ceil( + ZonedDateTime.ofInstant(allSpoutLogLines.get(0).getDate().toInstant(), ZoneOffset.UTC), + slideSec + ); final int numberOfWindows = allBoltLogLines.size(); /* * Windows should be aligned to the slide size, starting at firstWindowEndTime - windowSec. @@ -109,15 +112,15 @@ public class WindowVerifier { * This checks that the partitioned spout emits fall in the expected windows, based on the logs from the spout and bolt. */ for (int i = 0; i < numberOfWindows; ++i) { - final DateTime windowEnd = firstWindowEndTime.plusSeconds(i * slideSec); - final DateTime windowStart = windowEnd.minusSeconds(windowSec); + final ZonedDateTime windowEnd = firstWindowEndTime.plusSeconds(i * slideSec); + final ZonedDateTime windowStart = windowEnd.minusSeconds(windowSec); LOG.info("Comparing window: " + windowStart + " to " + windowEnd + " iter " + (i+1) + "/" + numberOfWindows); final List<TimeData> expectedSpoutEmitsInWindow = allSpoutLogLines.stream() .filter(spoutLog -> { - DateTime spoutLogTime = new DateTime(spoutLog.getDate()); + final ZonedDateTime spoutLogTime = spoutLog.getDate().toInstant().atZone(ZoneOffset.UTC); //The window boundaries are )windowStart, windowEnd) - return spoutLogTime.isAfter(windowStart) && spoutLogTime.isBefore(windowEnd.plusMillis(1)); + return spoutLogTime.isAfter(windowStart) && spoutLogTime.isBefore(windowEnd.plusNanos(1_000_000)); }).collect(Collectors.toList()); TimeDataWindow expectedWindow = new TimeDataWindow(expectedSpoutEmitsInWindow); diff --git a/integration-test/src/test/java/org/apache/storm/st/wrapper/DecoratedLogLine.java b/integration-test/src/test/java/org/apache/storm/st/wrapper/DecoratedLogLine.java index f9c4c85d4..473e0237c 100644 --- a/integration-test/src/test/java/org/apache/storm/st/wrapper/DecoratedLogLine.java +++ b/integration-test/src/test/java/org/apache/storm/st/wrapper/DecoratedLogLine.java @@ -19,11 +19,10 @@ package org.apache.storm.st.wrapper; import org.apache.storm.st.utils.AssertUtil; import org.apache.commons.lang.StringUtils; -import org.joda.time.DateTime; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; import org.apache.storm.st.utils.StringDecorator; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; import java.util.Arrays; import java.util.List; @@ -32,22 +31,22 @@ import java.util.List; * This provides easy access to the log line timestamp and data. */ public class DecoratedLogLine implements Comparable<DecoratedLogLine> { - private final DateTime logDate; + private final ZonedDateTime logDate; private final String data; private static final int DATE_LEN = "2016-05-04 23:38:10.702".length(); //format of date in worker logs - private static final DateTimeFormatter DATE_FORMAT = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss.SSS"); + private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); public DecoratedLogLine(String logLine) { final List<String> splitOnDecorator = Arrays.asList(StringDecorator.split2(StringUtils.strip(logLine))); AssertUtil.assertTwoElements(splitOnDecorator); - this.logDate = DATE_FORMAT.parseDateTime(splitOnDecorator.get(0).substring(0, DATE_LEN)); + this.logDate = ZonedDateTime.parse(splitOnDecorator.get(0).substring(0, DATE_LEN), DATE_FORMAT); this.data = splitOnDecorator.get(1); } @Override public String toString() { return "LogData{" + - "logDate=" + DATE_FORMAT.print(logDate) + + "logDate=" + DATE_FORMAT.format(logDate) + ", data='" + getData() + '\'' + '}'; } @@ -61,7 +60,7 @@ public class DecoratedLogLine implements Comparable<DecoratedLogLine> { return data; } - public DateTime getLogDate() { + public ZonedDateTime getLogDate() { return logDate; } } diff --git a/pom.xml b/pom.xml index 046b531e3..10e67fe10 100644 --- a/pom.xml +++ b/pom.xml @@ -120,7 +120,6 @@ <hbase.version>2.6.1-hadoop3</hbase.version> <kryo.version>5.6.0</kryo.version> <jakarta.servlet.version>5.0.0</jakarta.servlet.version> - <joda-time.version>2.12.7</joda-time.version> <thrift.version>0.19.0</thrift.version> <junit.jupiter.version>5.11.3</junit.jupiter.version> <surefire.version>3.0.0-M5</surefire.version> @@ -694,11 +693,6 @@ <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> - <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - <version>${joda-time.version}</version> - </dependency> <dependency> <groupId>com.fasterxml.jackson</groupId> <artifactId>jackson-bom</artifactId> diff --git a/storm-core/pom.xml b/storm-core/pom.xml index 8b6640822..2effcf638 100644 --- a/storm-core/pom.xml +++ b/storm-core/pom.xml @@ -155,10 +155,6 @@ <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> </dependency> - <dependency> - <groupId>joda-time</groupId> - <artifactId>joda-time</artifactId> - </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-server</artifactId>
