Skip to content

Commit

Permalink
IGNITE-8601 Add to control.sh utility information about transaction s…
Browse files Browse the repository at this point in the history
…tart time and date
  • Loading branch information
a-polyakov committed Jun 6, 2018
1 parent 56f39d6 commit c9b2955
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Expand Up @@ -97,8 +97,6 @@ else if ("SIZE".equals(order))

PrintWriter w = new PrintWriter(sw);

DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS");

for (Map.Entry<ClusterNode, VisorTxTaskResult> entry : res.entrySet()) {
if (entry.getValue().getInfos().isEmpty())
continue;
Expand All @@ -111,7 +109,7 @@ else if ("SIZE".equals(order))
w.println(" Tx: [xid=" + info.getXid() +
", label=" + info.getLabel() +
", state=" + info.getState() +
", startTime=" + dateFormat.format(info.getStartTime()) +
", startTime=" + info.getFormattedStartTime() +
", duration=" + info.getDuration() / 1000 +
", isolation=" + info.getIsolation() +
", concurrency=" + info.getConcurrency() +
Expand Down
Expand Up @@ -977,8 +977,6 @@ else if (arg.getOperation() == VisorTxOperation.KILL)
else
log("Matching transactions:");

DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss.SSS");

for (Map.Entry<ClusterNode, VisorTxTaskResult> entry : res.entrySet()) {
if (entry.getValue().getInfos().isEmpty())
continue;
Expand All @@ -991,7 +989,7 @@ else if (arg.getOperation() == VisorTxOperation.KILL)
log(" Tx: [xid=" + info.getXid() +
", label=" + info.getLabel() +
", state=" + info.getState() +
", startTime=" + dateFormat.format(info.getStartTime()) +
", startTime=" + info.getFormattedStartTime() +
", duration=" + info.getDuration() / 1000 +
", isolation=" + info.getIsolation() +
", concurrency=" + info.getConcurrency() +
Expand Down
Expand Up @@ -20,8 +20,11 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collection;
import java.util.TimeZone;
import java.util.UUID;
import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.internal.util.typedef.internal.U;
Expand All @@ -37,6 +40,9 @@ public class VisorTxInfo extends VisorDataTransferObject {
/** */
private static final long serialVersionUID = 0L;

/** */
private static DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");

/** */
private IgniteUuid xid;

Expand Down Expand Up @@ -113,6 +119,10 @@ public long getStartTime() {
return startTime;
}

public String getFormattedStartTime() {
return dateTimeFormatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), TimeZone.getDefault().toZoneId()));
}

/** */
public long getDuration() {
return duration;
Expand Down Expand Up @@ -153,10 +163,14 @@ public int getSize() {
return size;
}

/** {@inheritDoc} */
@Override public byte getProtocolVersion() {
return V2;
}

/** {@inheritDoc} */
@Override protected void writeExternalData(ObjectOutput out) throws IOException {
U.writeGridUuid(out, xid);
out.writeLong(startTime);
out.writeLong(duration);
U.writeEnum(out, isolation);
U.writeEnum(out, concurrency);
Expand All @@ -165,12 +179,13 @@ public int getSize() {
U.writeCollection(out, primaryNodes);
U.writeEnum(out, state);
out.writeInt(size);
out.writeLong(startTime);
}

/** {@inheritDoc} */
@Override protected void readExternalData(byte protoVer, ObjectInput in) throws IOException, ClassNotFoundException {
@Override protected void readExternalData(byte protoVer,
ObjectInput in) throws IOException, ClassNotFoundException {
xid = U.readGridUuid(in);
startTime = in.readLong();
duration = in.readLong();
isolation = TransactionIsolation.fromOrdinal(in.readByte());
concurrency = TransactionConcurrency.fromOrdinal(in.readByte());
Expand All @@ -179,6 +194,7 @@ public int getSize() {
primaryNodes = U.readCollection(in);
state = TransactionState.fromOrdinal(in.readByte());
size = in.readInt();
startTime = protoVer >= V2 ? in.readLong() : 0L;
}

/** {@inheritDoc} */
Expand Down

0 comments on commit c9b2955

Please sign in to comment.