Skip to content
Merged
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
3 changes: 0 additions & 3 deletions docs/storm-sql-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 0 additions & 4 deletions integration-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -43,13 +44,13 @@ public static void sleepMilliSec(int milliSec) {
}
}

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,8 +29,6 @@
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;

Expand Down Expand Up @@ -100,24 +100,27 @@ public void runAndVerifyTime(int windowSec, int slideSec, TestableTopology testa
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.
* Because all windows are aligned to the slide size, we can partition the spout emitted timestamps by which window they should fall in.
* 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@

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;

Expand All @@ -32,22 +31,22 @@
* 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() + '\'' +
'}';
}
Expand All @@ -61,7 +60,7 @@ public String getData() {
return data;
}

public DateTime getLogDate() {
public ZonedDateTime getLogDate() {
return logDate;
}
}
4 changes: 0 additions & 4 deletions storm-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down