Skip to content

Commit

Permalink
fix more timestamp formatting, akka#22774
Browse files Browse the repository at this point in the history
* regression introduced by akka#22716
  (never released)
  • Loading branch information
patriknw committed Apr 25, 2017
1 parent 5ff6995 commit b72ce56
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package akka.remote.artery
import java.io.File
import java.nio.file.Files
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter

import akka.actor.ActorSystem
Expand Down Expand Up @@ -36,7 +38,8 @@ object BenchmarkFileReporter {
Try("git describe".!!.trim).getOrElse("[unknown]")
}
val testResultFile: File = {
val fileName = s"${formatter.format(Instant.now())}-Artery-$testName-$gitCommit-results.txt"
val timestamp = formatter.format(LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()));
val fileName = s"$timestamp-Artery-$testName-$gitCommit-results.txt"
new File(targetDirectory, fileName)
}
val config = system.settings.config
Expand Down
12 changes: 8 additions & 4 deletions akka-remote/src/main/java/akka/remote/artery/AeronErrorLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import java.io.File;
import java.nio.MappedByteBuffer;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.atomic.AtomicLong;

Expand All @@ -41,7 +43,10 @@ public class AeronErrorLog
final DirectBuffer cncMetaDataBuffer;
final int cncVersion;
final AtomicBuffer buffer;
final DateTimeFormatter formatter;
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSZ");
private final ZoneId timeZone = ZoneId.systemDefault();



public AeronErrorLog(File cncFile)
{
Expand All @@ -50,7 +55,6 @@ public AeronErrorLog(File cncFile)
cncMetaDataBuffer = CncFileDescriptor.createMetaDataBuffer(cncByteBuffer);
cncVersion = cncMetaDataBuffer.getInt(CncFileDescriptor.cncVersionOffset(0));
buffer = CncFileDescriptor.createErrorLogBuffer(cncByteBuffer, cncMetaDataBuffer);
formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSZ");

if (CncFileDescriptor.CNC_VERSION != cncVersion)
{
Expand All @@ -70,8 +74,8 @@ public long logErrors(LoggingAdapter log, long sinceTimestamp)
log.error(String.format(
"Aeron error: %d observations from %s to %s for:%n %s",
observationCount,
formatter.format(Instant.ofEpochMilli(firstObservationTimestamp)),
formatter.format(Instant.ofEpochMilli(lastObservationTimestamp)),
formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(firstObservationTimestamp), timeZone)),
formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(lastObservationTimestamp), timeZone)),
encodedException));
lastTimestamp.set(Math.max(lastTimestamp.get(), lastObservationTimestamp));
}, sinceTimestamp);
Expand Down
4 changes: 3 additions & 1 deletion project/TimeStampede.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package akka

import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter

import sbt._
Expand Down Expand Up @@ -32,6 +34,6 @@ object TimeStampede extends AutoPlugin {
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss")

def timestamp(time: Long): String = {
formatter.format(Instant.ofEpochMilli(time))
formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault()))
}
}

0 comments on commit b72ce56

Please sign in to comment.