private void mergeTimestamp(JsonElement json, Message.Builder builder)
throws InvalidProtocolBufferException {
try {
Timestamp value = Timestamps.parse(json.getAsString());
builder.mergeFrom(value.toByteString());
} catch (ParseException e) {
throw new InvalidProtocolBufferException("Failed to parse timestamp: " + json);
}
}
java类com.google.protobuf.Timestamp的实例源码
JsonFormat.java 文件源码
项目:seldon-core
阅读 24
收藏 0
点赞 0
评论 0
TimeUtils.java 文件源码
项目:seldon-core
阅读 31
收藏 0
点赞 0
评论 0
@Override
public void merge(JsonElement json, Builder builder) throws InvalidProtocolBufferException {
try {
Timestamp value = Timestamps.parse(json.getAsString());
builder.mergeFrom(value.toByteString());
} catch (ParseException e) {
throw new InvalidProtocolBufferException("Failed to parse timestamp: " + json);
}
}
JsonFormat.java 文件源码
项目:seldon-core
阅读 23
收藏 0
点赞 0
评论 0
private void mergeTimestamp(JsonElement json, Message.Builder builder)
throws InvalidProtocolBufferException {
try {
Timestamp value = Timestamps.parse(json.getAsString());
builder.mergeFrom(value.toByteString());
} catch (ParseException e) {
throw new InvalidProtocolBufferException("Failed to parse timestamp: " + json);
}
}
TimeUtils.java 文件源码
项目:seldon-core
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void merge(JsonElement json, Builder builder) throws InvalidProtocolBufferException {
try {
Timestamp value = Timestamps.parse(json.getAsString());
builder.mergeFrom(value.toByteString());
} catch (ParseException e) {
throw new InvalidProtocolBufferException("Failed to parse timestamp: " + json);
}
}
JsonFormat.java 文件源码
项目:seldon-core
阅读 28
收藏 0
点赞 0
评论 0
private void mergeTimestamp(JsonElement json, Message.Builder builder)
throws InvalidProtocolBufferException {
try {
Timestamp value = Timestamps.parse(json.getAsString());
builder.mergeFrom(value.toByteString());
} catch (ParseException e) {
throw new InvalidProtocolBufferException("Failed to parse timestamp: " + json);
}
}
StackdriverTraceSpanListener.java 文件源码
项目:spring-cloud-gcp
阅读 16
收藏 0
点赞 0
评论 0
protected Timestamp createTimestamp(long milliseconds) {
long seconds = (milliseconds / 1000);
int remainderMicros = (int) (milliseconds % 1000);
int remainderNanos = remainderMicros * 1000000;
return Timestamp.newBuilder().setSeconds(seconds).setNanos(remainderNanos).build();
}
StackdriverTraceSpanListenerTests.java 文件源码
项目:spring-cloud-gcp
阅读 17
收藏 0
点赞 0
评论 0
@Test
public void testSingleServerRemoteSpan() {
Span parent = Span.builder()
.traceId(123L)
.name("http:parent")
.begin(beginTime - 1)
.end(endTime + 1)
.log(new Log(beginTime, Span.SERVER_RECV))
.log(new Log(endTime, Span.SERVER_SEND))
.remote(true)
.build();
this.spanListener.report(parent);
Assert.assertEquals(1, this.test.traceSpans.size());
TraceSpan traceSpan = this.test.traceSpans.get(0);
Assert.assertEquals(0, traceSpan.getParentSpanId());
Assert.assertEquals("http:parent", traceSpan.getName());
// Server side remote span should not report start/end time
Assert.assertEquals(Timestamp.getDefaultInstance(), traceSpan.getStartTime());
Assert.assertEquals(Timestamp.getDefaultInstance(), traceSpan.getEndTime());
Assert.assertEquals(this.dateFormatter.format(new Date(beginTime)),
traceSpan.getLabelsOrThrow("cloud.spring.io/sr"));
Assert.assertEquals(this.dateFormatter.format(new Date(endTime)),
traceSpan.getLabelsOrThrow("cloud.spring.io/ss"));
Assert.assertEquals(TraceSpan.SpanKind.RPC_SERVER, traceSpan.getKind());
}
_ProtobufMappers.java 文件源码
项目:generator-jhipster-grpc
阅读 18
收藏 0
点赞 0
评论 0
public static ZonedDateTime timestampToZonedDateTime(Timestamp timestamp) {
return timestamp == null ? null : ZonedDateTime.ofInstant(
Instant.ofEpochSecond(
timestamp.getSeconds(),
timestamp.getNanos()),
ZoneId.of("UTC")
);
}
Timestamps.java 文件源码
项目:endpoints-management-java
阅读 15
收藏 0
点赞 0
评论 0
@Override
public int compare(Timestamp o1, Timestamp o2) {
int secondsOrder = Long.compare(o1.getSeconds(), o2.getSeconds());
if (secondsOrder != 0) {
return secondsOrder;
} else {
return Long.compare(o1.getNanos(), o2.getNanos());
}
}
Timestamps.java 文件源码
项目:endpoints-management-java
阅读 17
收藏 0
点赞 0
评论 0
/**
* Obtain the current time from the unix epoch
*
* @param epochMillis gives the current time in milliseconds since since the epoch
* @return a {@code Timestamp} corresponding to the ticker's current value
*/
public static Timestamp fromEpoch(long epochMillis) {
return Timestamp
.newBuilder()
.setNanos((int) ((epochMillis % MILLIS_PER_SECOND) * NANOS_PER_MILLI))
.setSeconds(epochMillis / MILLIS_PER_SECOND)
.build();
}