Skip to content

Commit

Permalink
[WFLY-8863] Handle locale for start/end time from server to prevent N…
Browse files Browse the repository at this point in the history
…PE and model version bump
  • Loading branch information
bmaxwell committed Jun 13, 2017
1 parent 179d642 commit 2d0ed93
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 23 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ public static void main(String[] args) {


private static void printJdrReportInfo(JdrReport report) { private static void printJdrReportInfo(JdrReport report) {
if(report != null) { if(report != null) {
System.out.println("JDR started: " + report.getStartTime().toString()); System.out.println("JDR started: " + report.getFormattedStartTime());
System.out.println("JDR ended: " + report.getEndTime().toString()); System.out.println("JDR ended: " + report.getFormattedEndTime());
System.out.println("JDR location: " + report.getLocation()); System.out.println("JDR location: " + report.getLocation());
System.out.flush(); System.out.flush();
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/ */
public interface CommonAttributes { public interface CommonAttributes {


SimpleAttributeDefinition START_TIME = new SimpleAttributeDefinitionBuilder("start-time", ModelType.STRING, false).build(); SimpleAttributeDefinition START_TIME = new SimpleAttributeDefinitionBuilder("start-time", ModelType.LONG, false).build();
SimpleAttributeDefinition END_TIME = new SimpleAttributeDefinitionBuilder("end-time", ModelType.STRING, false).build(); SimpleAttributeDefinition END_TIME = new SimpleAttributeDefinitionBuilder("end-time", ModelType.LONG, false).build();
SimpleAttributeDefinition REPORT_LOCATION = new SimpleAttributeDefinitionBuilder("report-location", ModelType.STRING, true).build(); SimpleAttributeDefinition REPORT_LOCATION = new SimpleAttributeDefinitionBuilder("report-location", ModelType.STRING, true).build();
} }
48 changes: 32 additions & 16 deletions jdr/jboss-as-jdr/src/main/java/org/jboss/as/jdr/JdrReport.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.StandardOpenOption; import java.nio.file.StandardOpenOption;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Properties; import java.util.Properties;
Expand Down Expand Up @@ -60,8 +59,8 @@ public class JdrReport {


public static final String DATA_DIR = "data"; public static final String DATA_DIR = "data";


private Date startTime; private Long startTime;
private Date endTime; private Long endTime;
private String location; private String location;
private String jdrUuid; private String jdrUuid;


Expand All @@ -71,42 +70,59 @@ public JdrReport() {
} }


public JdrReport(ModelNode result) { public JdrReport(ModelNode result) {
try { setStartTime(result.get("start-time").asLong());
setStartTime(DATE_FORMAT.parse(result.get("start-time").asString())); setEndTime(result.get("end-time").asLong());
setEndTime(DATE_FORMAT.parse(result.get("end-time").asString()));
} catch(ParseException pe) {
}
setLocation(result.get("report-location").asString()); setLocation(result.get("report-location").asString());
} }


/** /**
* Indicates the time the JDR report collection was initiated. * Indicates the time the JDR report collection was initiated.
*/ */
public Date getStartTime() { public Long getStartTime() {
return startTime; return startTime;
} }


public void setStartTime(Date time) { public String getFormattedStartTime() {
startTime = time; if(startTime == null)
return "";
return DATE_FORMAT.format(startTime);
}

public void setStartTime(Date date) {
startTime = date.getTime();
}

public void setStartTime(long startTime) {
this.startTime = startTime;
} }


public void setStartTime() { public void setStartTime() {
setStartTime(new Date()); setStartTime(new Date().getTime());
} }


/** /**
* Indicates the time the JDR report collection was complete. * Indicates the time the JDR report collection was complete.
*/ */
public Date getEndTime() { public Long getEndTime() {
return endTime; return endTime;
} }


public void setEndTime(Date time) { public String getFormattedEndTime() {
endTime = time; if(endTime == null)
return "";
return DATE_FORMAT.format(endTime);
}

public void setEndTime(Date date) {
endTime = date.getTime();
}

public void setEndTime(long endTime) {
this.endTime = endTime;
} }


public void setEndTime() { public void setEndTime() {
setEndTime(new Date()); setEndTime(new Date().getTime());
} }


/** /**
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class JdrReportExtension implements Extension {


public static final String SUBSYSTEM_NAME = "jdr"; public static final String SUBSYSTEM_NAME = "jdr";


private static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(1, 2, 0); private static final ModelVersion CURRENT_MODEL_VERSION = ModelVersion.create(1, 3, 0);


static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME); static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ public void execute(OperationContext context, ModelNode operation) throws Operat
JdrReport report = jdrCollector.collect(); JdrReport report = jdrCollector.collect();


if (report.getStartTime() != null) { if (report.getStartTime() != null) {
response.get("start-time").set(report.getStartTime().toString()); response.get("start-time").set(report.getStartTime());
} }
if (report.getEndTime() != null) { if (report.getEndTime() != null) {
response.get("end-time").set(report.getEndTime().toString()); response.get("end-time").set(report.getEndTime());
} }
response.get("report-location").set(report.getLocation()); response.get("report-location").set(report.getLocation());


Expand Down

0 comments on commit 2d0ed93

Please sign in to comment.