/** * Helper method to generate an "external" QueryId. * * This is the only method that can generate external query Id. * * @return generated QueryId */ public static ExternalId generateExternalId() { ThreadLocalRandom r = ThreadLocalRandom.current(); // create a new internalId where the first four bytes are a growing time (each new value comes earlier in sequence). // Last 11 bytes are random. // last byte is set to 0 final long time = (int) (System.currentTimeMillis()/1000); final long p1 = ((Integer.MAX_VALUE - time) << 32) + r.nextInt(); // generate a long from 7 random bytes + 1 zero byte // I could also just generate a random long then mask it's last bit // but not sure how this will affect it's randomness final byte[] bytes = new byte[7]; r.nextBytes(bytes); long p2 = 0; for (int i = 0; i < 7; i++) { p2 += (bytes[i] & 0xFFL) << (8 * i); } p2 = p2 << 8; return ExternalId.newBuilder().setPart1(p1).setPart2(p2).build(); }
/** * <code>required .exec.shared.ExternalId external_Id = 1;</code> */ public Builder mergeExternalId(com.dremio.exec.proto.UserBitShared.ExternalId value) { if (externalIdBuilder_ == null) { if (((bitField0_ & 0x00000001) == 0x00000001) && externalId_ != com.dremio.exec.proto.UserBitShared.ExternalId.getDefaultInstance()) { externalId_ = com.dremio.exec.proto.UserBitShared.ExternalId.newBuilder(externalId_).mergeFrom(value).buildPartial(); } else { externalId_ = value; } onChanged(); } else { externalIdBuilder_.mergeFrom(value); } bitField0_ |= 0x00000001; return this; } /**
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.dremio.exec.proto.CoordRPC.JobCancelRequest)) { return super.equals(obj); } com.dremio.exec.proto.CoordRPC.JobCancelRequest other = (com.dremio.exec.proto.CoordRPC.JobCancelRequest) obj; boolean result = true; result = result && (hasExternalId() == other.hasExternalId()); if (hasExternalId()) { result = result && getExternalId() .equals(other.getExternalId()); } result = result && (hasCancelReason() == other.hasCancelReason()); if (hasCancelReason()) { result = result && getCancelReason() .equals(other.getCancelReason()); } result = result && getUnknownFields().equals(other.getUnknownFields()); return result; }
public void mergeFrom(io.protostuff.Input input, com.dremio.exec.proto.CoordRPC.JobCancelRequest.Builder builder) throws java.io.IOException { for(int number = input.readFieldNumber(this);; number = input.readFieldNumber(this)) { switch(number) { case 0: return; case 1: builder.setExternalId(input.mergeObject(com.dremio.exec.proto.UserBitShared.ExternalId.newBuilder(), com.dremio.exec.proto.SchemaUserBitShared.ExternalId.MERGE)); break; case 2: builder.setCancelReason(input.readString()); break; default: input.handleUnknownField(number, this); } } } public boolean isInitialized(com.dremio.exec.proto.CoordRPC.JobCancelRequest.Builder builder)
public com.dremio.exec.proto.UserBitShared.ExternalId buildPartial() { com.dremio.exec.proto.UserBitShared.ExternalId result = new com.dremio.exec.proto.UserBitShared.ExternalId(this); int from_bitField0_ = bitField0_; int to_bitField0_ = 0; if (((from_bitField0_ & 0x00000001) == 0x00000001)) { to_bitField0_ |= 0x00000001; } result.part1_ = part1_; if (((from_bitField0_ & 0x00000002) == 0x00000002)) { to_bitField0_ |= 0x00000002; } result.part2_ = part2_; result.bitField0_ = to_bitField0_; onBuilt(); return result; }
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(com.dremio.exec.proto.UserBitShared.ExternalId prototype) {
/** * <code>required .exec.shared.ExternalId external_Id = 1;</code> */ public Builder clearExternalId() { if (externalIdBuilder_ == null) { externalId_ = com.dremio.exec.proto.UserBitShared.ExternalId.getDefaultInstance(); onChanged(); } else { externalIdBuilder_.clear(); } bitField0_ = (bitField0_ & ~0x00000001); return this; } /**
public static boolean isValid(final ExternalId externalId) { return (externalId.getPart2() & ~MASK) == 0; }
public com.dremio.exec.proto.UserBitShared.ExternalId getDefaultInstanceForType() { return com.dremio.exec.proto.UserBitShared.ExternalId.getDefaultInstance(); }
public static Builder newBuilder(com.dremio.exec.proto.UserBitShared.ExternalId prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
/** * Translate job id to external id. * * @param jobId job id * @return external id */ static ExternalId getJobIdAsExternalId(JobId jobId) { UUID id = UUID.fromString(jobId.getId()); return ExternalId.newBuilder() .setPart1(id.getMostSignificantBits()) .setPart2(id.getLeastSignificantBits()) .build(); }
public static AttemptId fromString(final String attemptIdStr) { final UUID uuid = UUID.fromString(attemptIdStr); final long part1 = uuid.getMostSignificantBits(); final long part2 = uuid.getLeastSignificantBits(); final ExternalId externalId = ExternalId.newBuilder() .setPart1(part1) .setPart2(part2 & ExternalIdHelper.MASK) .build(); final int attempt = (int) part2 & 0xFF; return new AttemptId(externalId, attempt); } }
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { getSerializedSize(); if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeSFixed64(1, part1_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeSFixed64(2, part2_); } getUnknownFields().writeTo(output); }
@Deprecated // Dremio still uses QueryId internally, once we switch to using AttemptId we can get rid of this public static ExternalId toExternal(final QueryId queryId) { return ExternalId.newBuilder() .setPart1(queryId.getPart1()) .setPart2(queryId.getPart2() & MASK) .build(); }
private void initFields() { externalId_ = com.dremio.exec.proto.UserBitShared.ExternalId.getDefaultInstance(); cancelReason_ = ""; } private byte memoizedIsInitialized = -1;
public void writeTo(io.protostuff.Output output, com.dremio.exec.proto.UserBitShared.ExternalId message) throws java.io.IOException { if(message.hasPart1()) output.writeSFixed64(1, message.getPart1(), false); if(message.hasPart2()) output.writeSFixed64(2, message.getPart2(), false); } public boolean isInitialized(com.dremio.exec.proto.UserBitShared.ExternalId message)