diff --git a/alibabacloud-gateway-sls/java/pom.xml b/alibabacloud-gateway-sls/java/pom.xml index 5169f372..9d29cea5 100644 --- a/alibabacloud-gateway-sls/java/pom.xml +++ b/alibabacloud-gateway-sls/java/pom.xml @@ -49,12 +49,12 @@ com.aliyun alibabacloud-gateway-spi - 0.0.2 + 0.0.3 com.aliyun credentials-java - 0.3.6 + 1.0.1 com.aliyun @@ -64,7 +64,7 @@ com.aliyun openapiutil - 0.2.1 + 0.2.2 com.aliyun @@ -84,12 +84,12 @@ com.aliyun darabonba-encode-util - 0.0.2 + 0.0.3 com.aliyun darabonba-signature-util - 0.0.4 + 0.0.5 com.aliyun diff --git a/alibabacloud-gateway-sls/java/src/main/java/com/aliyun/gateway/sls/Client.java b/alibabacloud-gateway-sls/java/src/main/java/com/aliyun/gateway/sls/Client.java index 56d8e2b7..9a537050 100644 --- a/alibabacloud-gateway-sls/java/src/main/java/com/aliyun/gateway/sls/Client.java +++ b/alibabacloud-gateway-sls/java/src/main/java/com/aliyun/gateway/sls/Client.java @@ -73,6 +73,9 @@ public void modifyRequest(com.aliyun.gateway.spi.models.InterceptorContext conte } else if (com.aliyun.darabonbastring.Client.equals(request.reqBodyType, "binary")) { // content-type: application/octet-stream bodyBytes = com.aliyun.teautil.Common.assertAsBytes(request.body); + } else if (com.aliyun.darabonbastring.Client.equals(request.reqBodyType, "protobuf")) { + bodyBytes = com.aliyun.gateway.sls.util.Client.serializeToPbBytes(request.body); + request.headers.put("content-type", "application/x-protobuf"); } } @@ -83,12 +86,12 @@ public void modifyRequest(com.aliyun.gateway.spi.models.InterceptorContext conte // for php bug, Argument #1 ($value) could not be passed by reference if (!com.aliyun.teautil.Common.isUnset(rawSizeRef)) { bodyRawSize = rawSizeRef; - } else if (!com.aliyun.teautil.Common.isUnset(request.body)) { + } else if (!com.aliyun.teautil.Common.isUnset(bodyBytes)) { bodyRawSize = "" + com.aliyun.gateway.sls.util.Client.bytesLength(bodyBytes) + ""; } // compress if needed, and set body and hash - if (!com.aliyun.teautil.Common.isUnset(request.body)) { + if (!com.aliyun.teautil.Common.isUnset(bodyBytes)) { if (!com.aliyun.teautil.Common.empty(finalCompressType)) { byte[] compressed = com.aliyun.gateway.sls.util.Client.compress(bodyBytes, finalCompressType); bodyBytes = compressed; @@ -199,7 +202,9 @@ public String makeContentHash(byte[] content, String signatureVersion) throws Ex public void modifyResponse(com.aliyun.gateway.spi.models.InterceptorContext context, com.aliyun.gateway.spi.models.AttributeMap attributeMap) throws Exception { com.aliyun.gateway.spi.models.InterceptorContext.InterceptorContextRequest request = context.request; com.aliyun.gateway.spi.models.InterceptorContext.InterceptorContextResponse response = context.response; - if (com.aliyun.teautil.Common.is4xx(response.statusCode) || com.aliyun.teautil.Common.is5xx(response.statusCode)) { + Number statusCode = response.statusCode; + String requestId = response.headers.get("x-log-requestid"); + if (com.aliyun.teautil.Common.is4xx(statusCode) || com.aliyun.teautil.Common.is5xx(statusCode)) { Object error = com.aliyun.teautil.Common.readAsJSON(response.body); java.util.Map resMap = com.aliyun.teautil.Common.assertAsMap(error); throw new TeaException(TeaConverter.buildMap( @@ -207,9 +212,9 @@ public void modifyResponse(com.aliyun.gateway.spi.models.InterceptorContext cont new TeaPair("message", resMap.get("errorMessage")), new TeaPair("accessDeniedDetail", resMap.get("accessDeniedDetail")), new TeaPair("data", TeaConverter.buildMap( - new TeaPair("httpCode", response.statusCode), - new TeaPair("requestId", response.headers.get("x-log-requestid")), - new TeaPair("statusCode", response.statusCode) + new TeaPair("httpCode", statusCode), + new TeaPair("requestId", requestId), + new TeaPair("statusCode", statusCode) )) )); } @@ -235,6 +240,9 @@ public void modifyResponse(com.aliyun.gateway.spi.models.InterceptorContext cont response.deserializedBody = obj; } else if (com.aliyun.teautil.Common.equalString(request.bodyType, "array")) { response.deserializedBody = com.aliyun.teautil.Common.readAsJSON(uncompressedData); + } else if (com.aliyun.teautil.Common.equalString(request.bodyType, "protobuf")) { + byte[] pbBytes = com.aliyun.teautil.Common.readAsBytes(uncompressedData); + response.deserializedBody = com.aliyun.gateway.sls.util.Client.deserializeFromPbBytes(pbBytes, statusCode, response.headers); } else { response.deserializedBody = com.aliyun.teautil.Common.readAsString(uncompressedData); } diff --git a/alibabacloud-gateway-sls/main.tea b/alibabacloud-gateway-sls/main.tea index 40cad4a0..2888a6ce 100644 --- a/alibabacloud-gateway-sls/main.tea +++ b/alibabacloud-gateway-sls/main.tea @@ -64,6 +64,9 @@ async function modifyRequest(context: SPI.InterceptorContext, attributeMap: SPI. } else if (String.equals(request.reqBodyType, 'binary')) { // content-type: application/octet-stream bodyBytes = Util.assertAsBytes(request.body); + } else if (String.equals(request.reqBodyType, 'protobuf')) { + bodyBytes = SLS_Util.serializeToPbBytes(request.body); + request.headers['content-type'] = 'application/x-protobuf'; } } @@ -72,12 +75,12 @@ async function modifyRequest(context: SPI.InterceptorContext, attributeMap: SPI. var rawSizeRef = request.headers['x-log-bodyrawsize']; // for php bug, Argument #1 ($value) could not be passed by reference if (!Util.isUnset(rawSizeRef)) { bodyRawSize = rawSizeRef; - } else if (!Util.isUnset(request.body)) { + } else if (!Util.isUnset(bodyBytes)) { bodyRawSize = `${SLS_Util.bytesLength(bodyBytes)}`; } // compress if needed, and set body and hash - if (!Util.isUnset(request.body)) { + if (!Util.isUnset(bodyBytes)) { if (!Util.empty(finalCompressType)) { var compressed = SLS_Util.compress(bodyBytes, finalCompressType); bodyBytes = compressed; @@ -175,7 +178,9 @@ async function makeContentHash(content: bytes, signatureVersion: string) : strin async function modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap): void { var request = context.request; var response = context.response; - if (Util.is4xx(response.statusCode) || Util.is5xx(response.statusCode)) { + var statusCode = response.statusCode; + var requestId = response.headers['x-log-requestid']; + if (Util.is4xx(statusCode) || Util.is5xx(statusCode)) { var error = Util.readAsJSON(response.body); var resMap = Util.assertAsMap(error); throw { @@ -183,9 +188,9 @@ async function modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI message = resMap['errorMessage'], accessDeniedDetail = resMap['accessDeniedDetail'], data = { - httpCode = response.statusCode, - requestId = response.headers['x-log-requestid'], - statusCode = response.statusCode, + httpCode = statusCode, + requestId = requestId, + statusCode = statusCode, } }; } @@ -209,6 +214,9 @@ async function modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI response.deserializedBody = obj; } else if (Util.equalString(request.bodyType, 'array')) { response.deserializedBody = Util.readAsJSON(uncompressedData); + } else if (Util.equalString(request.bodyType, 'protobuf')) { + var pbBytes = Util.readAsBytes(uncompressedData); + response.deserializedBody = SLS_Util.deserializeFromPbBytes(pbBytes, statusCode, response.headers); } else { response.deserializedBody = Util.readAsString(uncompressedData); } diff --git a/alibabacloud-gateway-sls/ts/package.json b/alibabacloud-gateway-sls/ts/package.json index c23f19a3..56f58d2a 100644 --- a/alibabacloud-gateway-sls/ts/package.json +++ b/alibabacloud-gateway-sls/ts/package.json @@ -21,7 +21,7 @@ "dependencies": { "@alicloud/tea-typescript": "^1.7.1", "@alicloud/gateway-spi": "^0.0.8", - "@alicloud/credentials": "^2.3.1", + "@alicloud/credentials": "^2.4.2", "@alicloud/tea-util": "^1.4.9", "@alicloud/openapi-util": "^0.3.2", "@alicloud/darabonba-string": "^1.0.2", diff --git a/alibabacloud-gateway-sls/ts/src/client.ts b/alibabacloud-gateway-sls/ts/src/client.ts index 5d49add3..59f1cd0b 100644 --- a/alibabacloud-gateway-sls/ts/src/client.ts +++ b/alibabacloud-gateway-sls/ts/src/client.ts @@ -84,6 +84,9 @@ export default class Client extends SPI { } else if (String.equals(request.reqBodyType, "binary")) { // content-type: application/octet-stream bodyBytes = Util.assertAsBytes(request.body); + } else if (String.equals(request.reqBodyType, "protobuf")) { + bodyBytes = SLS_Util.serializeToPbBytes(request.body); + request.headers["content-type"] = "application/x-protobuf"; } } @@ -94,12 +97,12 @@ export default class Client extends SPI { // for php bug, Argument #1 ($value) could not be passed by reference if (!Util.isUnset(rawSizeRef)) { bodyRawSize = rawSizeRef; - } else if (!Util.isUnset(request.body)) { + } else if (!Util.isUnset(bodyBytes)) { bodyRawSize = `${await SLS_Util.bytesLength(bodyBytes)}`; } // compress if needed, and set body and hash - if (!Util.isUnset(request.body)) { + if (!Util.isUnset(bodyBytes)) { if (!Util.empty(finalCompressType)) { let compressed = await SLS_Util.compress(bodyBytes, finalCompressType); bodyBytes = compressed; @@ -183,6 +186,7 @@ export default class Client extends SPI { let encodings = this._respBodyDecompressType[action]; if (!Util.isUnset(encodings)) { + for (let c of encodings) { if (await SLS_Util.isDecompressorAvailable(c)) { headers["Accept-Encoding"] = c; @@ -208,7 +212,9 @@ export default class Client extends SPI { async modifyResponse(context: $SPI.InterceptorContext, attributeMap: $SPI.AttributeMap): Promise { let request = context.request; let response = context.response; - if (Util.is4xx(response.statusCode) || Util.is5xx(response.statusCode)) { + let statusCode = response.statusCode; + let requestId = response.headers["x-log-requestid"]; + if (Util.is4xx(statusCode) || Util.is5xx(statusCode)) { let error = await Util.readAsJSON(response.body); let resMap = Util.assertAsMap(error); throw $tea.newError({ @@ -216,9 +222,9 @@ export default class Client extends SPI { message: resMap["errorMessage"], accessDeniedDetail: resMap["accessDeniedDetail"], data: { - httpCode: response.statusCode, - requestId: response.headers["x-log-requestid"], - statusCode: response.statusCode, + httpCode: statusCode, + requestId: requestId, + statusCode: statusCode, }, }); } @@ -244,6 +250,9 @@ export default class Client extends SPI { response.deserializedBody = obj; } else if (Util.equalString(request.bodyType, "array")) { response.deserializedBody = await Util.readAsJSON(uncompressedData); + } else if (Util.equalString(request.bodyType, "protobuf")) { + let pbBytes = await Util.readAsBytes(uncompressedData); + response.deserializedBody = SLS_Util.deserializeFromPbBytes(pbBytes, statusCode, response.headers); } else { response.deserializedBody = await Util.readAsString(uncompressedData); } diff --git a/alibabacloud-gateway-sls/util/java/pom.xml b/alibabacloud-gateway-sls/util/java/pom.xml index e5ad197c..1aa94313 100644 --- a/alibabacloud-gateway-sls/util/java/pom.xml +++ b/alibabacloud-gateway-sls/util/java/pom.xml @@ -51,6 +51,11 @@ lz4 1.3.0 + + com.google.protobuf + protobuf-java + 3.25.4 + com.aliyun tea diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/Client.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/Client.java index 07fdade1..4276dd55 100644 --- a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/Client.java +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/Client.java @@ -1,8 +1,12 @@ // This file is auto-generated, don't edit it. Thanks. package com.aliyun.gateway.sls.util; +import com.aliyun.gateway.sls.util.model.ILog; +import com.aliyun.gateway.sls.util.model.LogsResponseBody; + import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.Map; public class Client { @@ -49,4 +53,32 @@ public static Boolean isDecompressorAvailable(String compressType) throws Except public static Long bytesLength(byte[] src) throws Exception { return (long) src.length; } + + public static byte[] serializeToPbBytes(Object request) { + if (request instanceof ILog) { + return ((ILog) request).serializeToPbBytes(); + } + return null; + } + + public static LogsResponseBody deserializeFromPbBytes(byte[] uncompressedData, Integer statusCode, Map headers) { + return new LogsResponseBody(uncompressedData, statusCode, headers); + } + + public static int[] decodeVarInt32(byte[] dataBytes, int pos, int maxPos) { + int value[] = {0, 0, 0}; + int shift = 0; + int b; + for (int i = pos; i < maxPos; ++i) { + b = dataBytes[i] & 0xff; + value[1] |= (b & 127) << shift; + shift += 7; + if ((b & 128) == 0) { + value[2] = i + 1; + value[0] = 1; + break; + } + } + return value; + } } diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/exception/LogException.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/exception/LogException.java new file mode 100644 index 00000000..e1b34bc0 --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/exception/LogException.java @@ -0,0 +1,20 @@ +package com.aliyun.gateway.sls.util.exception; + +import com.aliyun.tea.TeaConverter; +import com.aliyun.tea.TeaException; +import com.aliyun.tea.TeaPair; + +public class LogException extends TeaException { + public LogException(String code, String message, String requestId, int statusCode) { + super(TeaConverter.buildMap(new TeaPair("code", code), + new TeaPair("message", message), + new TeaPair("data", TeaConverter.buildMap( + new TeaPair("httpCode", statusCode), + new TeaPair("requestId", requestId), + new TeaPair("statusCode", statusCode))))); + } + + public LogException(String code, String message, String requestId) { + this(code, message, requestId, -1); + } +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLog.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLog.java new file mode 100644 index 00000000..84152c3b --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLog.java @@ -0,0 +1,98 @@ +package com.aliyun.gateway.sls.util.model; + +import com.aliyun.gateway.sls.util.Client; + +import java.util.ArrayList; +import java.util.List; + +public class FastLog { + + private final byte[] rawBytes; + // [beginOffset, endOffset) + private final int beginOffset; + private final int endOffset; + private final List contents; + private int time = -1; + private int timeNsPart = 0; + + public FastLog(byte[] rawBytes, int offset, int length) { + this.rawBytes = rawBytes; + this.beginOffset = offset; + this.endOffset = offset + length; + this.contents = new ArrayList(); + if (!parse()) { + this.contents.clear(); + } + } + + private boolean parse() { + int pos = this.beginOffset; + int mode, index; + boolean findTime = false; + while (pos < this.endOffset) { + int[] value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + mode = value[1] & 0x7; + index = value[1] >> 3; + if (mode == 0) { + pos = value[2]; + value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + pos = value[2]; + if (index == 1) { + this.time = value[1]; + findTime = true; + } + } else if (mode == 1) { + pos = value[2] + 8; + } else if (mode == 2) { + pos = value[2]; + value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + pos = value[2] + value[1]; + if (index == 2) { + this.contents.add(new FastLogContent(this.rawBytes, value[2], value[1])); + } + } else if (mode == 5) { + if (index == 4) { + timeNsPart = this.rawBytes[value[2]] & 255 | (this.rawBytes[value[2] + 1] & 255) << 8 | (this.rawBytes[value[2] + 2] & 255) << 16 | (this.rawBytes[value[2] + 3] & 255) << 24; + } + pos = value[2] + 4; + } else { + return false; + } + } + return findTime && (pos == this.endOffset); + } + + public int getTime() { + return this.time; + } + + public int getTimeNsPart() { + return this.timeNsPart; + } + + public int getContentsCount() { + return this.contents.size(); + } + + public List getContents() { + return contents; + } + + public FastLogContent getContents(int i) { + if (i < this.contents.size()) { + return this.contents.get(i); + } else { + return null; + } + } + +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogContent.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogContent.java new file mode 100644 index 00000000..2df83614 --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogContent.java @@ -0,0 +1,94 @@ +package com.aliyun.gateway.sls.util.model; + +import com.aliyun.gateway.sls.util.Client; + +import java.io.UnsupportedEncodingException; + +public class FastLogContent { + + private final byte[] rawBytes; + // [beginOffset, endOffset) + private final int beginOffset; + private final int endOffset; + private int keyOffset = -1; + private int keyLength = -1; + private int valueOffset = -1; + private int valueLength = -1; + + public FastLogContent(byte[] rawBytes, int offset, int length) { + this.rawBytes = rawBytes; + this.beginOffset = offset; + this.endOffset = offset + length; + if (!parse()) { + this.keyOffset = -1; + this.keyLength = -1; + this.valueOffset = -1; + this.valueLength = -1; + } + } + + private boolean parse() { + int pos = this.beginOffset; + int index, mode; + while (pos < this.endOffset) { + int[] value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + mode = value[1] & 0x7; + index = value[1] >> 3; + pos = value[2]; + if (mode == 0) { + value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + pos = value[2]; + } else if (mode == 1) { + pos += 8; + } else if (mode == 2) { + value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + pos = value[2] + value[1]; + if (index == 1) { + keyOffset = value[2]; + keyLength = value[1]; + } else if (index == 2) { + valueOffset = value[2]; + valueLength = value[1]; + } + } else if (mode == 5) { + pos += 4; + } else { + return false; + } + } + return (keyOffset != -1 && valueOffset != -1 && pos == this.endOffset); + } + + public String getKey() { + return decodeString(keyOffset, keyLength); + } + + public String getKey(final String charset) throws UnsupportedEncodingException { + return decodeString(keyOffset, keyLength, charset); + } + + public String getValue() { + return decodeString(valueOffset, valueLength); + } + + public String getValue(final String charset) throws UnsupportedEncodingException { + return decodeString(valueOffset, valueLength, charset); + } + + private String decodeString(int offset, int length) { + return offset < 0 ? null : new String(rawBytes, offset, length); + } + + private String decodeString(int offset, int length, String charset) throws UnsupportedEncodingException { + return offset < 0 ? null : new String(this.rawBytes, offset, length, charset); + } +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogGroup.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogGroup.java new file mode 100644 index 00000000..f0b7ee47 --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogGroup.java @@ -0,0 +1,129 @@ +package com.aliyun.gateway.sls.util.model; + +import com.aliyun.gateway.sls.util.Client; +import com.aliyun.gateway.sls.util.exception.LogException; + +import java.util.ArrayList; +import java.util.List; + +public class FastLogGroup { + private final byte[] rawBytes; + // [beginOffset, endOffset) + private final int beginOffset; + private final int endOffset; + private final List logs; + private final List tags; + private final String requestId; + private int topicOffset; + private int sourceOffset; + + public FastLogGroup(byte[] rawBytes, int offset, int length, String requestId) { + this.rawBytes = rawBytes; + this.beginOffset = offset; + this.endOffset = offset + length; + this.topicOffset = -1; + this.sourceOffset = -1; + this.logs = new ArrayList(); + this.tags = new ArrayList(); + this.requestId = requestId; + if (!parse()) { + throw new LogException("InitFastLogGroupError", "invalid logGroup data", this.requestId); + } + } + + private boolean parse() { + int pos = this.beginOffset; + int mode, index; + while (pos < this.endOffset) { + int[] value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + mode = value[1] & 0x7; + index = value[1] >> 3; + if (mode == 0) { + pos = value[2]; + value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + pos = value[2]; + } else if (mode == 1) { + pos = value[2] + 8; + } else if (mode == 2) { + switch (index) { + case 1: + //logs + break; + case 3: + this.topicOffset = value[2]; + break; + case 4: + this.sourceOffset = value[2]; + break; + case 6: + //tags + break; + default: + } + pos = value[2]; + value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + pos = value[2] + value[1]; + if (index == 1) { + this.logs.add(new FastLog(this.rawBytes, value[2], value[1])); + } else if (index == 6) { + this.tags.add(new FastLogTag(this.rawBytes, value[2], value[1])); + } + } else if (mode == 5) { + pos = value[2] + 4; + } else { + return false; + } + } + return (pos == this.endOffset); + } + + public int getLogTagsCount() { + return this.tags.size(); + } + + public FastLogTag getLogTags(int i) { + if (i < this.tags.size()) { + return this.tags.get(i); + } else { + return null; + } + } + + public List getLogs() { + return logs; + } + + public List getTags() { + return tags; + } + + public int getLogsCount() { + return this.logs.size(); + } + + public FastLog getLogs(int i) { + if (i < this.logs.size()) { + return this.logs.get(i); + } else { + return null; + } + } + + public boolean hasTopic() { + return this.topicOffset >= 0; + } + + public boolean hasSource() { + return this.sourceOffset >= 0; + } +} + diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogTag.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogTag.java new file mode 100644 index 00000000..d32b3abb --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/FastLogTag.java @@ -0,0 +1,101 @@ +package com.aliyun.gateway.sls.util.model; + +import com.aliyun.gateway.sls.util.Client; + +public class FastLogTag { + + private final byte[] rawBytes; + // [beginOffset, endOffset) + private final int beginOffset; + private final int endOffset; + private int keyOffset = -1; + private int keyLength = -1; + private int valueOffset = -1; + private int valueLength = -1; + + public FastLogTag(byte[] rawBytes, int offset, int length) { + this.rawBytes = rawBytes; + this.beginOffset = offset; + this.endOffset = offset + length; + if (!parse()) { + this.keyOffset = -1; + this.keyLength = -1; + this.valueOffset = -1; + this.valueLength = -1; + } + } + + private boolean parse() { + int pos = this.beginOffset; + int mode, index; + while (pos < this.endOffset) { + int[] value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + mode = value[1] & 0x7; + index = value[1] >> 3; + pos = value[2]; + if (mode == 0) { + value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + pos = value[2]; + } else if (mode == 1) { + pos += 8; + } else if (mode == 2) { + value = Client.decodeVarInt32(this.rawBytes, pos, this.endOffset); + if (value[0] == 0) { + return false; + } + pos = value[2] + value[1]; + if (index == 1) { + keyOffset = value[2]; + keyLength = value[1]; + } else if (index == 2) { + valueOffset = value[2]; + valueLength = value[1]; + } + } else if (mode == 5) { + pos += 4; + } else { + return false; + } + } + return (keyOffset != -1 && valueOffset != -1 && pos == this.endOffset); + } + + public String getKey() { + if (this.keyOffset < 0) { + return null; + } + return new String(this.rawBytes, this.keyOffset, this.keyLength); + } + + public String getValue() { + if (this.valueOffset < 0) { + return null; + } + return new String(this.rawBytes, this.valueOffset, this.valueLength); + } + + + public byte[] getKeyBytes() { + if (this.keyOffset < 0) { + return null; + } + byte[] keyBytes = new byte[this.keyLength]; + System.arraycopy(this.rawBytes, this.keyOffset, keyBytes, 0, this.keyLength); + return keyBytes; + } + + public byte[] getValueBytes() { + if (this.valueOffset < 0) { + return null; + } + byte[] valueBytes = new byte[this.valueLength]; + System.arraycopy(this.rawBytes, this.valueOffset, valueBytes, 0, this.valueLength); + return valueBytes; + } +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILog.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILog.java new file mode 100644 index 00000000..831ae9f5 --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILog.java @@ -0,0 +1,5 @@ +package com.aliyun.gateway.sls.util.model; + +public interface ILog { + byte[] serializeToPbBytes(); +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogContent.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogContent.java new file mode 100644 index 00000000..cbc10392 --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogContent.java @@ -0,0 +1,7 @@ +package com.aliyun.gateway.sls.util.model; + +public interface ILogContent { + String getKey(); + + String getValue(); +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogItem.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogItem.java new file mode 100644 index 00000000..cc6b8fee --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogItem.java @@ -0,0 +1,11 @@ +package com.aliyun.gateway.sls.util.model; + +import java.util.List; + +public interface ILogItem { + Integer getTime(); + + Integer getTimeNs(); + + List getLogContents(); +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogTag.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogTag.java new file mode 100644 index 00000000..0af2080c --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/ILogTag.java @@ -0,0 +1,7 @@ +package com.aliyun.gateway.sls.util.model; + +public interface ILogTag { + String getKey(); + + String getValue(); +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/LogGroupBase.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/LogGroupBase.java new file mode 100644 index 00000000..9a5a88f4 --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/LogGroupBase.java @@ -0,0 +1,59 @@ +package com.aliyun.gateway.sls.util.model; + +import com.aliyun.tea.TeaModel; +import com.aliyun.tea.utils.StringUtils; + +import java.util.List; + +public abstract class LogGroupBase extends TeaModel implements ILog { + + @Override + public byte[] serializeToPbBytes() { + Logs.LogGroup.Builder logs = Logs.LogGroup.newBuilder(); + if (!StringUtils.isEmpty(getTopic())) { + logs.setTopic(getTopic()); + } + if (!StringUtils.isEmpty(getSource())) { + logs.setSource(getSource()); + } + + List logTags = getLogTags(); + if (logTags != null && !logTags.isEmpty()) { + for (ILogTag tag : logTags) { + Logs.LogTag.Builder tagBuilder = logs.addLogTagsBuilder(); + tagBuilder.setKey(tag.getKey()); + tagBuilder.setValue(tag.getValue()); + } + } + List logItems = getLogItems(); + if (logItems != null && !logItems.isEmpty()) { + for (ILogItem item : logItems) { + Logs.Log.Builder log = logs.addLogsBuilder(); + log.setTime(item.getTime()); + if (item.getTimeNs() != null && item.getTimeNs() >= 0) { + log.setTimeNs(item.getTimeNs()); + } + + for (ILogContent content : item.getLogContents()) { + Logs.LogContent.Builder contentBuilder = log.addContentsBuilder(); + contentBuilder.setKey(content.getKey()); + if (content.getValue() == null) { + contentBuilder.setValue(""); + } else { + contentBuilder.setValue(content.getValue()); + } + } + } + } + return logs.build().toByteArray(); + } + + public abstract String getSource(); + + public abstract String getTopic(); + + public abstract List getLogTags(); + + public abstract List getLogItems(); + +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/Logs.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/Logs.java new file mode 100644 index 00000000..f33fa124 --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/Logs.java @@ -0,0 +1,4175 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: logs.proto + +// Protobuf Java Version: 3.25.1 +package com.aliyun.gateway.sls.util.model; + +public final class Logs { + private Logs() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface LogContentOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.aliyun.gateway.sls.util.model.LogContent) + com.google.protobuf.MessageOrBuilder { + + /** + * required string Key = 1; + * @return Whether the key field is set. + */ + boolean hasKey(); + /** + * required string Key = 1; + * @return The key. + */ + java.lang.String getKey(); + /** + * required string Key = 1; + * @return The bytes for key. + */ + com.google.protobuf.ByteString + getKeyBytes(); + + /** + * required string Value = 2; + * @return Whether the value field is set. + */ + boolean hasValue(); + /** + * required string Value = 2; + * @return The value. + */ + java.lang.String getValue(); + /** + * required string Value = 2; + * @return The bytes for value. + */ + com.google.protobuf.ByteString + getValueBytes(); + } + /** + * Protobuf type {@code com.aliyun.gateway.sls.util.model.LogContent} + */ + public static final class LogContent extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.aliyun.gateway.sls.util.model.LogContent) + LogContentOrBuilder { + private static final long serialVersionUID = 0L; + // Use LogContent.newBuilder() to construct. + private LogContent(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private LogContent() { + key_ = ""; + value_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new LogContent(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogContent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogContent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.gateway.sls.util.model.Logs.LogContent.class, com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder.class); + } + + private int bitField0_; + public static final int KEY_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object key_ = ""; + /** + * required string Key = 1; + * @return Whether the key field is set. + */ + @java.lang.Override + public boolean hasKey() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required string Key = 1; + * @return The key. + */ + @java.lang.Override + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } + return s; + } + } + /** + * required string Key = 1; + * @return The bytes for key. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VALUE_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private volatile java.lang.Object value_ = ""; + /** + * required string Value = 2; + * @return Whether the value field is set. + */ + @java.lang.Override + public boolean hasValue() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * required string Value = 2; + * @return The value. + */ + @java.lang.Override + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + /** + * required string Value = 2; + * @return The bytes for value. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasKey()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasValue()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); + } + if (((bitField0_ & 0x00000002) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, value_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, value_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.gateway.sls.util.model.Logs.LogContent)) { + return super.equals(obj); + } + com.aliyun.gateway.sls.util.model.Logs.LogContent other = (com.aliyun.gateway.sls.util.model.Logs.LogContent) obj; + + if (hasKey() != other.hasKey()) return false; + if (hasKey()) { + if (!getKey() + .equals(other.getKey())) return false; + } + if (hasValue() != other.hasValue()) return false; + if (hasValue()) { + if (!getValue() + .equals(other.getValue())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasKey()) { + hash = (37 * hash) + KEY_FIELD_NUMBER; + hash = (53 * hash) + getKey().hashCode(); + } + if (hasValue()) { + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValue().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogContent parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.gateway.sls.util.model.Logs.LogContent prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.gateway.sls.util.model.LogContent} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.gateway.sls.util.model.LogContent) + com.aliyun.gateway.sls.util.model.Logs.LogContentOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogContent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogContent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.gateway.sls.util.model.Logs.LogContent.class, com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder.class); + } + + // Construct using com.aliyun.gateway.sls.util.model.Logs.LogContent.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + key_ = ""; + value_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogContent_descriptor; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogContent getDefaultInstanceForType() { + return com.aliyun.gateway.sls.util.model.Logs.LogContent.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogContent build() { + com.aliyun.gateway.sls.util.model.Logs.LogContent result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogContent buildPartial() { + com.aliyun.gateway.sls.util.model.Logs.LogContent result = new com.aliyun.gateway.sls.util.model.Logs.LogContent(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(com.aliyun.gateway.sls.util.model.Logs.LogContent result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.key_ = key_; + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.value_ = value_; + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.gateway.sls.util.model.Logs.LogContent) { + return mergeFrom((com.aliyun.gateway.sls.util.model.Logs.LogContent)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.gateway.sls.util.model.Logs.LogContent other) { + if (other == com.aliyun.gateway.sls.util.model.Logs.LogContent.getDefaultInstance()) return this; + if (other.hasKey()) { + key_ = other.key_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasValue()) { + value_ = other.value_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + if (!hasKey()) { + return false; + } + if (!hasValue()) { + return false; + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + key_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: { + value_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.lang.Object key_ = ""; + /** + * required string Key = 1; + * @return Whether the key field is set. + */ + public boolean hasKey() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required string Key = 1; + * @return The key. + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string Key = 1; + * @return The bytes for key. + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string Key = 1; + * @param value The key to set. + * @return This builder for chaining. + */ + public Builder setKey( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + key_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * required string Key = 1; + * @return This builder for chaining. + */ + public Builder clearKey() { + key_ = getDefaultInstance().getKey(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * required string Key = 1; + * @param value The bytes for key to set. + * @return This builder for chaining. + */ + public Builder setKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + key_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object value_ = ""; + /** + * required string Value = 2; + * @return Whether the value field is set. + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * required string Value = 2; + * @return The value. + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string Value = 2; + * @return The bytes for value. + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string Value = 2; + * @param value The value to set. + * @return This builder for chaining. + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * required string Value = 2; + * @return This builder for chaining. + */ + public Builder clearValue() { + value_ = getDefaultInstance().getValue(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * required string Value = 2; + * @param value The bytes for value to set. + * @return This builder for chaining. + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.aliyun.gateway.sls.util.model.LogContent) + } + + // @@protoc_insertion_point(class_scope:com.aliyun.gateway.sls.util.model.LogContent) + private static final com.aliyun.gateway.sls.util.model.Logs.LogContent DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.gateway.sls.util.model.Logs.LogContent(); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogContent getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated public static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LogContent parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogContent getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface LogOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.aliyun.gateway.sls.util.model.Log) + com.google.protobuf.MessageOrBuilder { + + /** + * required uint32 Time = 1; + * @return Whether the time field is set. + */ + boolean hasTime(); + /** + * required uint32 Time = 1; + * @return The time. + */ + int getTime(); + + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + java.util.List + getContentsList(); + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + com.aliyun.gateway.sls.util.model.Logs.LogContent getContents(int index); + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + int getContentsCount(); + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + java.util.List + getContentsOrBuilderList(); + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + com.aliyun.gateway.sls.util.model.Logs.LogContentOrBuilder getContentsOrBuilder( + int index); + + /** + * optional fixed32 TimeNs = 4; + * @return Whether the timeNs field is set. + */ + boolean hasTimeNs(); + /** + * optional fixed32 TimeNs = 4; + * @return The timeNs. + */ + int getTimeNs(); + } + /** + * Protobuf type {@code com.aliyun.gateway.sls.util.model.Log} + */ + public static final class Log extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.aliyun.gateway.sls.util.model.Log) + LogOrBuilder { + private static final long serialVersionUID = 0L; + // Use Log.newBuilder() to construct. + private Log(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private Log() { + contents_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new Log(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_Log_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_Log_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.gateway.sls.util.model.Logs.Log.class, com.aliyun.gateway.sls.util.model.Logs.Log.Builder.class); + } + + private int bitField0_; + public static final int TIME_FIELD_NUMBER = 1; + private int time_ = 0; + /** + * required uint32 Time = 1; + * @return Whether the time field is set. + */ + @java.lang.Override + public boolean hasTime() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required uint32 Time = 1; + * @return The time. + */ + @java.lang.Override + public int getTime() { + return time_; + } + + public static final int CONTENTS_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private java.util.List contents_; + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + @java.lang.Override + public java.util.List getContentsList() { + return contents_; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + @java.lang.Override + public java.util.List + getContentsOrBuilderList() { + return contents_; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + @java.lang.Override + public int getContentsCount() { + return contents_.size(); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogContent getContents(int index) { + return contents_.get(index); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogContentOrBuilder getContentsOrBuilder( + int index) { + return contents_.get(index); + } + + public static final int TIMENS_FIELD_NUMBER = 4; + private int timeNs_ = 0; + /** + * optional fixed32 TimeNs = 4; + * @return Whether the timeNs field is set. + */ + @java.lang.Override + public boolean hasTimeNs() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * optional fixed32 TimeNs = 4; + * @return The timeNs. + */ + @java.lang.Override + public int getTimeNs() { + return timeNs_; + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasTime()) { + memoizedIsInitialized = 0; + return false; + } + for (int i = 0; i < getContentsCount(); i++) { + if (!getContents(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeUInt32(1, time_); + } + for (int i = 0; i < contents_.size(); i++) { + output.writeMessage(2, contents_.get(i)); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeFixed32(4, timeNs_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(1, time_); + } + for (int i = 0; i < contents_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, contents_.get(i)); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream + .computeFixed32Size(4, timeNs_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.gateway.sls.util.model.Logs.Log)) { + return super.equals(obj); + } + com.aliyun.gateway.sls.util.model.Logs.Log other = (com.aliyun.gateway.sls.util.model.Logs.Log) obj; + + if (hasTime() != other.hasTime()) return false; + if (hasTime()) { + if (getTime() + != other.getTime()) return false; + } + if (!getContentsList() + .equals(other.getContentsList())) return false; + if (hasTimeNs() != other.hasTimeNs()) return false; + if (hasTimeNs()) { + if (getTimeNs() + != other.getTimeNs()) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasTime()) { + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + getTime(); + } + if (getContentsCount() > 0) { + hash = (37 * hash) + CONTENTS_FIELD_NUMBER; + hash = (53 * hash) + getContentsList().hashCode(); + } + if (hasTimeNs()) { + hash = (37 * hash) + TIMENS_FIELD_NUMBER; + hash = (53 * hash) + getTimeNs(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static com.aliyun.gateway.sls.util.model.Logs.Log parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static com.aliyun.gateway.sls.util.model.Logs.Log parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.gateway.sls.util.model.Logs.Log parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.gateway.sls.util.model.Logs.Log prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.gateway.sls.util.model.Log} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.gateway.sls.util.model.Log) + com.aliyun.gateway.sls.util.model.Logs.LogOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_Log_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_Log_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.gateway.sls.util.model.Logs.Log.class, com.aliyun.gateway.sls.util.model.Logs.Log.Builder.class); + } + + // Construct using com.aliyun.gateway.sls.util.model.Logs.Log.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + time_ = 0; + if (contentsBuilder_ == null) { + contents_ = java.util.Collections.emptyList(); + } else { + contents_ = null; + contentsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + timeNs_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_Log_descriptor; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.Log getDefaultInstanceForType() { + return com.aliyun.gateway.sls.util.model.Logs.Log.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.Log build() { + com.aliyun.gateway.sls.util.model.Logs.Log result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.Log buildPartial() { + com.aliyun.gateway.sls.util.model.Logs.Log result = new com.aliyun.gateway.sls.util.model.Logs.Log(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.aliyun.gateway.sls.util.model.Logs.Log result) { + if (contentsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + contents_ = java.util.Collections.unmodifiableList(contents_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.contents_ = contents_; + } else { + result.contents_ = contentsBuilder_.build(); + } + } + + private void buildPartial0(com.aliyun.gateway.sls.util.model.Logs.Log result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.time_ = time_; + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.timeNs_ = timeNs_; + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.gateway.sls.util.model.Logs.Log) { + return mergeFrom((com.aliyun.gateway.sls.util.model.Logs.Log)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.gateway.sls.util.model.Logs.Log other) { + if (other == com.aliyun.gateway.sls.util.model.Logs.Log.getDefaultInstance()) return this; + if (other.hasTime()) { + setTime(other.getTime()); + } + if (contentsBuilder_ == null) { + if (!other.contents_.isEmpty()) { + if (contents_.isEmpty()) { + contents_ = other.contents_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureContentsIsMutable(); + contents_.addAll(other.contents_); + } + onChanged(); + } + } else { + if (!other.contents_.isEmpty()) { + if (contentsBuilder_.isEmpty()) { + contentsBuilder_.dispose(); + contentsBuilder_ = null; + contents_ = other.contents_; + bitField0_ = (bitField0_ & ~0x00000002); + contentsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getContentsFieldBuilder() : null; + } else { + contentsBuilder_.addAllMessages(other.contents_); + } + } + } + if (other.hasTimeNs()) { + setTimeNs(other.getTimeNs()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + if (!hasTime()) { + return false; + } + for (int i = 0; i < getContentsCount(); i++) { + if (!getContents(i).isInitialized()) { + return false; + } + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + time_ = input.readUInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: { + com.aliyun.gateway.sls.util.model.Logs.LogContent m = + input.readMessage( + com.aliyun.gateway.sls.util.model.Logs.LogContent.PARSER, + extensionRegistry); + if (contentsBuilder_ == null) { + ensureContentsIsMutable(); + contents_.add(m); + } else { + contentsBuilder_.addMessage(m); + } + break; + } // case 18 + case 37: { + timeNs_ = input.readFixed32(); + bitField0_ |= 0x00000004; + break; + } // case 37 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private int time_ ; + /** + * required uint32 Time = 1; + * @return Whether the time field is set. + */ + @java.lang.Override + public boolean hasTime() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required uint32 Time = 1; + * @return The time. + */ + @java.lang.Override + public int getTime() { + return time_; + } + /** + * required uint32 Time = 1; + * @param value The time to set. + * @return This builder for chaining. + */ + public Builder setTime(int value) { + + time_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * required uint32 Time = 1; + * @return This builder for chaining. + */ + public Builder clearTime() { + bitField0_ = (bitField0_ & ~0x00000001); + time_ = 0; + onChanged(); + return this; + } + + private java.util.List contents_ = + java.util.Collections.emptyList(); + private void ensureContentsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + contents_ = new java.util.ArrayList(contents_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.LogContent, com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder, com.aliyun.gateway.sls.util.model.Logs.LogContentOrBuilder> contentsBuilder_; + + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public java.util.List getContentsList() { + if (contentsBuilder_ == null) { + return java.util.Collections.unmodifiableList(contents_); + } else { + return contentsBuilder_.getMessageList(); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public int getContentsCount() { + if (contentsBuilder_ == null) { + return contents_.size(); + } else { + return contentsBuilder_.getCount(); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogContent getContents(int index) { + if (contentsBuilder_ == null) { + return contents_.get(index); + } else { + return contentsBuilder_.getMessage(index); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder setContents( + int index, com.aliyun.gateway.sls.util.model.Logs.LogContent value) { + if (contentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureContentsIsMutable(); + contents_.set(index, value); + onChanged(); + } else { + contentsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder setContents( + int index, com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder builderForValue) { + if (contentsBuilder_ == null) { + ensureContentsIsMutable(); + contents_.set(index, builderForValue.build()); + onChanged(); + } else { + contentsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder addContents(com.aliyun.gateway.sls.util.model.Logs.LogContent value) { + if (contentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureContentsIsMutable(); + contents_.add(value); + onChanged(); + } else { + contentsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder addContents( + int index, com.aliyun.gateway.sls.util.model.Logs.LogContent value) { + if (contentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureContentsIsMutable(); + contents_.add(index, value); + onChanged(); + } else { + contentsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder addContents( + com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder builderForValue) { + if (contentsBuilder_ == null) { + ensureContentsIsMutable(); + contents_.add(builderForValue.build()); + onChanged(); + } else { + contentsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder addContents( + int index, com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder builderForValue) { + if (contentsBuilder_ == null) { + ensureContentsIsMutable(); + contents_.add(index, builderForValue.build()); + onChanged(); + } else { + contentsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder addAllContents( + java.lang.Iterable values) { + if (contentsBuilder_ == null) { + ensureContentsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, contents_); + onChanged(); + } else { + contentsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder clearContents() { + if (contentsBuilder_ == null) { + contents_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + contentsBuilder_.clear(); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public Builder removeContents(int index) { + if (contentsBuilder_ == null) { + ensureContentsIsMutable(); + contents_.remove(index); + onChanged(); + } else { + contentsBuilder_.remove(index); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder getContentsBuilder( + int index) { + return getContentsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogContentOrBuilder getContentsOrBuilder( + int index) { + if (contentsBuilder_ == null) { + return contents_.get(index); } else { + return contentsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public java.util.List + getContentsOrBuilderList() { + if (contentsBuilder_ != null) { + return contentsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(contents_); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder addContentsBuilder() { + return getContentsFieldBuilder().addBuilder( + com.aliyun.gateway.sls.util.model.Logs.LogContent.getDefaultInstance()); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder addContentsBuilder( + int index) { + return getContentsFieldBuilder().addBuilder( + index, com.aliyun.gateway.sls.util.model.Logs.LogContent.getDefaultInstance()); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogContent Contents = 2; + */ + public java.util.List + getContentsBuilderList() { + return getContentsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.LogContent, com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder, com.aliyun.gateway.sls.util.model.Logs.LogContentOrBuilder> + getContentsFieldBuilder() { + if (contentsBuilder_ == null) { + contentsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.LogContent, com.aliyun.gateway.sls.util.model.Logs.LogContent.Builder, com.aliyun.gateway.sls.util.model.Logs.LogContentOrBuilder>( + contents_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + contents_ = null; + } + return contentsBuilder_; + } + + private int timeNs_ ; + /** + * optional fixed32 TimeNs = 4; + * @return Whether the timeNs field is set. + */ + @java.lang.Override + public boolean hasTimeNs() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * optional fixed32 TimeNs = 4; + * @return The timeNs. + */ + @java.lang.Override + public int getTimeNs() { + return timeNs_; + } + /** + * optional fixed32 TimeNs = 4; + * @param value The timeNs to set. + * @return This builder for chaining. + */ + public Builder setTimeNs(int value) { + + timeNs_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * optional fixed32 TimeNs = 4; + * @return This builder for chaining. + */ + public Builder clearTimeNs() { + bitField0_ = (bitField0_ & ~0x00000004); + timeNs_ = 0; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.aliyun.gateway.sls.util.model.Log) + } + + // @@protoc_insertion_point(class_scope:com.aliyun.gateway.sls.util.model.Log) + private static final com.aliyun.gateway.sls.util.model.Logs.Log DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.gateway.sls.util.model.Logs.Log(); + } + + public static com.aliyun.gateway.sls.util.model.Logs.Log getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated public static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Log parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.Log getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface LogTagOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.aliyun.gateway.sls.util.model.LogTag) + com.google.protobuf.MessageOrBuilder { + + /** + * required string Key = 1; + * @return Whether the key field is set. + */ + boolean hasKey(); + /** + * required string Key = 1; + * @return The key. + */ + java.lang.String getKey(); + /** + * required string Key = 1; + * @return The bytes for key. + */ + com.google.protobuf.ByteString + getKeyBytes(); + + /** + * required string Value = 2; + * @return Whether the value field is set. + */ + boolean hasValue(); + /** + * required string Value = 2; + * @return The value. + */ + java.lang.String getValue(); + /** + * required string Value = 2; + * @return The bytes for value. + */ + com.google.protobuf.ByteString + getValueBytes(); + } + /** + * Protobuf type {@code com.aliyun.gateway.sls.util.model.LogTag} + */ + public static final class LogTag extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.aliyun.gateway.sls.util.model.LogTag) + LogTagOrBuilder { + private static final long serialVersionUID = 0L; + // Use LogTag.newBuilder() to construct. + private LogTag(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private LogTag() { + key_ = ""; + value_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new LogTag(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogTag_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogTag_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.gateway.sls.util.model.Logs.LogTag.class, com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder.class); + } + + private int bitField0_; + public static final int KEY_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private volatile java.lang.Object key_ = ""; + /** + * required string Key = 1; + * @return Whether the key field is set. + */ + @java.lang.Override + public boolean hasKey() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required string Key = 1; + * @return The key. + */ + @java.lang.Override + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } + return s; + } + } + /** + * required string Key = 1; + * @return The bytes for key. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VALUE_FIELD_NUMBER = 2; + @SuppressWarnings("serial") + private volatile java.lang.Object value_ = ""; + /** + * required string Value = 2; + * @return Whether the value field is set. + */ + @java.lang.Override + public boolean hasValue() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * required string Value = 2; + * @return The value. + */ + @java.lang.Override + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } + } + /** + * required string Value = 2; + * @return The bytes for value. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + if (!hasKey()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasValue()) { + memoizedIsInitialized = 0; + return false; + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); + } + if (((bitField0_ & 0x00000002) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, value_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, value_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.gateway.sls.util.model.Logs.LogTag)) { + return super.equals(obj); + } + com.aliyun.gateway.sls.util.model.Logs.LogTag other = (com.aliyun.gateway.sls.util.model.Logs.LogTag) obj; + + if (hasKey() != other.hasKey()) return false; + if (hasKey()) { + if (!getKey() + .equals(other.getKey())) return false; + } + if (hasValue() != other.hasValue()) return false; + if (hasValue()) { + if (!getValue() + .equals(other.getValue())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasKey()) { + hash = (37 * hash) + KEY_FIELD_NUMBER; + hash = (53 * hash) + getKey().hashCode(); + } + if (hasValue()) { + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValue().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogTag parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.gateway.sls.util.model.Logs.LogTag prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.gateway.sls.util.model.LogTag} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.gateway.sls.util.model.LogTag) + com.aliyun.gateway.sls.util.model.Logs.LogTagOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogTag_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogTag_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.gateway.sls.util.model.Logs.LogTag.class, com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder.class); + } + + // Construct using com.aliyun.gateway.sls.util.model.Logs.LogTag.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + key_ = ""; + value_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogTag_descriptor; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogTag getDefaultInstanceForType() { + return com.aliyun.gateway.sls.util.model.Logs.LogTag.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogTag build() { + com.aliyun.gateway.sls.util.model.Logs.LogTag result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogTag buildPartial() { + com.aliyun.gateway.sls.util.model.Logs.LogTag result = new com.aliyun.gateway.sls.util.model.Logs.LogTag(this); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartial0(com.aliyun.gateway.sls.util.model.Logs.LogTag result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.key_ = key_; + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.value_ = value_; + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.gateway.sls.util.model.Logs.LogTag) { + return mergeFrom((com.aliyun.gateway.sls.util.model.Logs.LogTag)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.gateway.sls.util.model.Logs.LogTag other) { + if (other == com.aliyun.gateway.sls.util.model.Logs.LogTag.getDefaultInstance()) return this; + if (other.hasKey()) { + key_ = other.key_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasValue()) { + value_ = other.value_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + if (!hasKey()) { + return false; + } + if (!hasValue()) { + return false; + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + key_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: { + value_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.lang.Object key_ = ""; + /** + * required string Key = 1; + * @return Whether the key field is set. + */ + public boolean hasKey() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * required string Key = 1; + * @return The key. + */ + public java.lang.String getKey() { + java.lang.Object ref = key_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + key_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string Key = 1; + * @return The bytes for key. + */ + public com.google.protobuf.ByteString + getKeyBytes() { + java.lang.Object ref = key_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + key_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string Key = 1; + * @param value The key to set. + * @return This builder for chaining. + */ + public Builder setKey( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + key_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * required string Key = 1; + * @return This builder for chaining. + */ + public Builder clearKey() { + key_ = getDefaultInstance().getKey(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * required string Key = 1; + * @param value The bytes for key to set. + * @return This builder for chaining. + */ + public Builder setKeyBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + key_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object value_ = ""; + /** + * required string Value = 2; + * @return Whether the value field is set. + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * required string Value = 2; + * @return The value. + */ + public java.lang.String getValue() { + java.lang.Object ref = value_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + value_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * required string Value = 2; + * @return The bytes for value. + */ + public com.google.protobuf.ByteString + getValueBytes() { + java.lang.Object ref = value_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + value_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * required string Value = 2; + * @param value The value to set. + * @return This builder for chaining. + */ + public Builder setValue( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * required string Value = 2; + * @return This builder for chaining. + */ + public Builder clearValue() { + value_ = getDefaultInstance().getValue(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * required string Value = 2; + * @param value The bytes for value to set. + * @return This builder for chaining. + */ + public Builder setValueBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + value_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.aliyun.gateway.sls.util.model.LogTag) + } + + // @@protoc_insertion_point(class_scope:com.aliyun.gateway.sls.util.model.LogTag) + private static final com.aliyun.gateway.sls.util.model.Logs.LogTag DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.gateway.sls.util.model.Logs.LogTag(); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogTag getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated public static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LogTag parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogTag getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface LogGroupOrBuilder extends + // @@protoc_insertion_point(interface_extends:com.aliyun.gateway.sls.util.model.LogGroup) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + java.util.List + getLogsList(); + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + com.aliyun.gateway.sls.util.model.Logs.Log getLogs(int index); + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + int getLogsCount(); + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + java.util.List + getLogsOrBuilderList(); + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + com.aliyun.gateway.sls.util.model.Logs.LogOrBuilder getLogsOrBuilder( + int index); + + /** + * optional string Topic = 3; + * @return Whether the topic field is set. + */ + boolean hasTopic(); + /** + * optional string Topic = 3; + * @return The topic. + */ + java.lang.String getTopic(); + /** + * optional string Topic = 3; + * @return The bytes for topic. + */ + com.google.protobuf.ByteString + getTopicBytes(); + + /** + * optional string Source = 4; + * @return Whether the source field is set. + */ + boolean hasSource(); + /** + * optional string Source = 4; + * @return The source. + */ + java.lang.String getSource(); + /** + * optional string Source = 4; + * @return The bytes for source. + */ + com.google.protobuf.ByteString + getSourceBytes(); + + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + java.util.List + getLogTagsList(); + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + com.aliyun.gateway.sls.util.model.Logs.LogTag getLogTags(int index); + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + int getLogTagsCount(); + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + java.util.List + getLogTagsOrBuilderList(); + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + com.aliyun.gateway.sls.util.model.Logs.LogTagOrBuilder getLogTagsOrBuilder( + int index); + } + /** + * Protobuf type {@code com.aliyun.gateway.sls.util.model.LogGroup} + */ + public static final class LogGroup extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:com.aliyun.gateway.sls.util.model.LogGroup) + LogGroupOrBuilder { + private static final long serialVersionUID = 0L; + // Use LogGroup.newBuilder() to construct. + private LogGroup(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private LogGroup() { + logs_ = java.util.Collections.emptyList(); + topic_ = ""; + source_ = ""; + logTags_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new LogGroup(); + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogGroup_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogGroup_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.gateway.sls.util.model.Logs.LogGroup.class, com.aliyun.gateway.sls.util.model.Logs.LogGroup.Builder.class); + } + + private int bitField0_; + public static final int LOGS_FIELD_NUMBER = 1; + @SuppressWarnings("serial") + private java.util.List logs_; + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + @java.lang.Override + public java.util.List getLogsList() { + return logs_; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + @java.lang.Override + public java.util.List + getLogsOrBuilderList() { + return logs_; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + @java.lang.Override + public int getLogsCount() { + return logs_.size(); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.Log getLogs(int index) { + return logs_.get(index); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogOrBuilder getLogsOrBuilder( + int index) { + return logs_.get(index); + } + + public static final int TOPIC_FIELD_NUMBER = 3; + @SuppressWarnings("serial") + private volatile java.lang.Object topic_ = ""; + /** + * optional string Topic = 3; + * @return Whether the topic field is set. + */ + @java.lang.Override + public boolean hasTopic() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * optional string Topic = 3; + * @return The topic. + */ + @java.lang.Override + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + topic_ = s; + } + return s; + } + } + /** + * optional string Topic = 3; + * @return The bytes for topic. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SOURCE_FIELD_NUMBER = 4; + @SuppressWarnings("serial") + private volatile java.lang.Object source_ = ""; + /** + * optional string Source = 4; + * @return Whether the source field is set. + */ + @java.lang.Override + public boolean hasSource() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * optional string Source = 4; + * @return The source. + */ + @java.lang.Override + public java.lang.String getSource() { + java.lang.Object ref = source_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + source_ = s; + } + return s; + } + } + /** + * optional string Source = 4; + * @return The bytes for source. + */ + @java.lang.Override + public com.google.protobuf.ByteString + getSourceBytes() { + java.lang.Object ref = source_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + source_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LOGTAGS_FIELD_NUMBER = 6; + @SuppressWarnings("serial") + private java.util.List logTags_; + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + @java.lang.Override + public java.util.List getLogTagsList() { + return logTags_; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + @java.lang.Override + public java.util.List + getLogTagsOrBuilderList() { + return logTags_; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + @java.lang.Override + public int getLogTagsCount() { + return logTags_.size(); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogTag getLogTags(int index) { + return logTags_.get(index); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogTagOrBuilder getLogTagsOrBuilder( + int index) { + return logTags_.get(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + for (int i = 0; i < getLogsCount(); i++) { + if (!getLogs(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + for (int i = 0; i < getLogTagsCount(); i++) { + if (!getLogTags(i).isInitialized()) { + memoizedIsInitialized = 0; + return false; + } + } + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < logs_.size(); i++) { + output.writeMessage(1, logs_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, topic_); + } + if (((bitField0_ & 0x00000002) != 0)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, source_); + } + for (int i = 0; i < logTags_.size(); i++) { + output.writeMessage(6, logTags_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < logs_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, logs_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, topic_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, source_); + } + for (int i = 0; i < logTags_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(6, logTags_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.aliyun.gateway.sls.util.model.Logs.LogGroup)) { + return super.equals(obj); + } + com.aliyun.gateway.sls.util.model.Logs.LogGroup other = (com.aliyun.gateway.sls.util.model.Logs.LogGroup) obj; + + if (!getLogsList() + .equals(other.getLogsList())) return false; + if (hasTopic() != other.hasTopic()) return false; + if (hasTopic()) { + if (!getTopic() + .equals(other.getTopic())) return false; + } + if (hasSource() != other.hasSource()) return false; + if (hasSource()) { + if (!getSource() + .equals(other.getSource())) return false; + } + if (!getLogTagsList() + .equals(other.getLogTagsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getLogsCount() > 0) { + hash = (37 * hash) + LOGS_FIELD_NUMBER; + hash = (53 * hash) + getLogsList().hashCode(); + } + if (hasTopic()) { + hash = (37 * hash) + TOPIC_FIELD_NUMBER; + hash = (53 * hash) + getTopic().hashCode(); + } + if (hasSource()) { + hash = (37 * hash) + SOURCE_FIELD_NUMBER; + hash = (53 * hash) + getSource().hashCode(); + } + if (getLogTagsCount() > 0) { + hash = (37 * hash) + LOGTAGS_FIELD_NUMBER; + hash = (53 * hash) + getLogTagsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(com.aliyun.gateway.sls.util.model.Logs.LogGroup prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code com.aliyun.gateway.sls.util.model.LogGroup} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:com.aliyun.gateway.sls.util.model.LogGroup) + com.aliyun.gateway.sls.util.model.Logs.LogGroupOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogGroup_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogGroup_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.aliyun.gateway.sls.util.model.Logs.LogGroup.class, com.aliyun.gateway.sls.util.model.Logs.LogGroup.Builder.class); + } + + // Construct using com.aliyun.gateway.sls.util.model.Logs.LogGroup.newBuilder() + private Builder() { + + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + + } + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (logsBuilder_ == null) { + logs_ = java.util.Collections.emptyList(); + } else { + logs_ = null; + logsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + topic_ = ""; + source_ = ""; + if (logTagsBuilder_ == null) { + logTags_ = java.util.Collections.emptyList(); + } else { + logTags_ = null; + logTagsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return com.aliyun.gateway.sls.util.model.Logs.internal_static_com_aliyun_gateway_sls_util_model_LogGroup_descriptor; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogGroup getDefaultInstanceForType() { + return com.aliyun.gateway.sls.util.model.Logs.LogGroup.getDefaultInstance(); + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogGroup build() { + com.aliyun.gateway.sls.util.model.Logs.LogGroup result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogGroup buildPartial() { + com.aliyun.gateway.sls.util.model.Logs.LogGroup result = new com.aliyun.gateway.sls.util.model.Logs.LogGroup(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { buildPartial0(result); } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.aliyun.gateway.sls.util.model.Logs.LogGroup result) { + if (logsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + logs_ = java.util.Collections.unmodifiableList(logs_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.logs_ = logs_; + } else { + result.logs_ = logsBuilder_.build(); + } + if (logTagsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + logTags_ = java.util.Collections.unmodifiableList(logTags_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.logTags_ = logTags_; + } else { + result.logTags_ = logTagsBuilder_.build(); + } + } + + private void buildPartial0(com.aliyun.gateway.sls.util.model.Logs.LogGroup result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.topic_ = topic_; + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.source_ = source_; + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.aliyun.gateway.sls.util.model.Logs.LogGroup) { + return mergeFrom((com.aliyun.gateway.sls.util.model.Logs.LogGroup)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.aliyun.gateway.sls.util.model.Logs.LogGroup other) { + if (other == com.aliyun.gateway.sls.util.model.Logs.LogGroup.getDefaultInstance()) return this; + if (logsBuilder_ == null) { + if (!other.logs_.isEmpty()) { + if (logs_.isEmpty()) { + logs_ = other.logs_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureLogsIsMutable(); + logs_.addAll(other.logs_); + } + onChanged(); + } + } else { + if (!other.logs_.isEmpty()) { + if (logsBuilder_.isEmpty()) { + logsBuilder_.dispose(); + logsBuilder_ = null; + logs_ = other.logs_; + bitField0_ = (bitField0_ & ~0x00000001); + logsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getLogsFieldBuilder() : null; + } else { + logsBuilder_.addAllMessages(other.logs_); + } + } + } + if (other.hasTopic()) { + topic_ = other.topic_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasSource()) { + source_ = other.source_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (logTagsBuilder_ == null) { + if (!other.logTags_.isEmpty()) { + if (logTags_.isEmpty()) { + logTags_ = other.logTags_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureLogTagsIsMutable(); + logTags_.addAll(other.logTags_); + } + onChanged(); + } + } else { + if (!other.logTags_.isEmpty()) { + if (logTagsBuilder_.isEmpty()) { + logTagsBuilder_.dispose(); + logTagsBuilder_ = null; + logTags_ = other.logTags_; + bitField0_ = (bitField0_ & ~0x00000008); + logTagsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + getLogTagsFieldBuilder() : null; + } else { + logTagsBuilder_.addAllMessages(other.logTags_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + for (int i = 0; i < getLogsCount(); i++) { + if (!getLogs(i).isInitialized()) { + return false; + } + } + for (int i = 0; i < getLogTagsCount(); i++) { + if (!getLogTags(i).isInitialized()) { + return false; + } + } + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + com.aliyun.gateway.sls.util.model.Logs.Log m = + input.readMessage( + com.aliyun.gateway.sls.util.model.Logs.Log.PARSER, + extensionRegistry); + if (logsBuilder_ == null) { + ensureLogsIsMutable(); + logs_.add(m); + } else { + logsBuilder_.addMessage(m); + } + break; + } // case 10 + case 26: { + topic_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 34: { + source_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 34 + case 50: { + com.aliyun.gateway.sls.util.model.Logs.LogTag m = + input.readMessage( + com.aliyun.gateway.sls.util.model.Logs.LogTag.PARSER, + extensionRegistry); + if (logTagsBuilder_ == null) { + ensureLogTagsIsMutable(); + logTags_.add(m); + } else { + logTagsBuilder_.addMessage(m); + } + break; + } // case 50 + default: { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + private int bitField0_; + + private java.util.List logs_ = + java.util.Collections.emptyList(); + private void ensureLogsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + logs_ = new java.util.ArrayList(logs_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.Log, com.aliyun.gateway.sls.util.model.Logs.Log.Builder, com.aliyun.gateway.sls.util.model.Logs.LogOrBuilder> logsBuilder_; + + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public java.util.List getLogsList() { + if (logsBuilder_ == null) { + return java.util.Collections.unmodifiableList(logs_); + } else { + return logsBuilder_.getMessageList(); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public int getLogsCount() { + if (logsBuilder_ == null) { + return logs_.size(); + } else { + return logsBuilder_.getCount(); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public com.aliyun.gateway.sls.util.model.Logs.Log getLogs(int index) { + if (logsBuilder_ == null) { + return logs_.get(index); + } else { + return logsBuilder_.getMessage(index); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder setLogs( + int index, com.aliyun.gateway.sls.util.model.Logs.Log value) { + if (logsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogsIsMutable(); + logs_.set(index, value); + onChanged(); + } else { + logsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder setLogs( + int index, com.aliyun.gateway.sls.util.model.Logs.Log.Builder builderForValue) { + if (logsBuilder_ == null) { + ensureLogsIsMutable(); + logs_.set(index, builderForValue.build()); + onChanged(); + } else { + logsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder addLogs(com.aliyun.gateway.sls.util.model.Logs.Log value) { + if (logsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogsIsMutable(); + logs_.add(value); + onChanged(); + } else { + logsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder addLogs( + int index, com.aliyun.gateway.sls.util.model.Logs.Log value) { + if (logsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogsIsMutable(); + logs_.add(index, value); + onChanged(); + } else { + logsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder addLogs( + com.aliyun.gateway.sls.util.model.Logs.Log.Builder builderForValue) { + if (logsBuilder_ == null) { + ensureLogsIsMutable(); + logs_.add(builderForValue.build()); + onChanged(); + } else { + logsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder addLogs( + int index, com.aliyun.gateway.sls.util.model.Logs.Log.Builder builderForValue) { + if (logsBuilder_ == null) { + ensureLogsIsMutable(); + logs_.add(index, builderForValue.build()); + onChanged(); + } else { + logsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder addAllLogs( + java.lang.Iterable values) { + if (logsBuilder_ == null) { + ensureLogsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, logs_); + onChanged(); + } else { + logsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder clearLogs() { + if (logsBuilder_ == null) { + logs_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + logsBuilder_.clear(); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public Builder removeLogs(int index) { + if (logsBuilder_ == null) { + ensureLogsIsMutable(); + logs_.remove(index); + onChanged(); + } else { + logsBuilder_.remove(index); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public com.aliyun.gateway.sls.util.model.Logs.Log.Builder getLogsBuilder( + int index) { + return getLogsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogOrBuilder getLogsOrBuilder( + int index) { + if (logsBuilder_ == null) { + return logs_.get(index); } else { + return logsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public java.util.List + getLogsOrBuilderList() { + if (logsBuilder_ != null) { + return logsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(logs_); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public com.aliyun.gateway.sls.util.model.Logs.Log.Builder addLogsBuilder() { + return getLogsFieldBuilder().addBuilder( + com.aliyun.gateway.sls.util.model.Logs.Log.getDefaultInstance()); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public com.aliyun.gateway.sls.util.model.Logs.Log.Builder addLogsBuilder( + int index) { + return getLogsFieldBuilder().addBuilder( + index, com.aliyun.gateway.sls.util.model.Logs.Log.getDefaultInstance()); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.Log Logs = 1; + */ + public java.util.List + getLogsBuilderList() { + return getLogsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.Log, com.aliyun.gateway.sls.util.model.Logs.Log.Builder, com.aliyun.gateway.sls.util.model.Logs.LogOrBuilder> + getLogsFieldBuilder() { + if (logsBuilder_ == null) { + logsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.Log, com.aliyun.gateway.sls.util.model.Logs.Log.Builder, com.aliyun.gateway.sls.util.model.Logs.LogOrBuilder>( + logs_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + logs_ = null; + } + return logsBuilder_; + } + + private java.lang.Object topic_ = ""; + /** + * optional string Topic = 3; + * @return Whether the topic field is set. + */ + public boolean hasTopic() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * optional string Topic = 3; + * @return The topic. + */ + public java.lang.String getTopic() { + java.lang.Object ref = topic_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + topic_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string Topic = 3; + * @return The bytes for topic. + */ + public com.google.protobuf.ByteString + getTopicBytes() { + java.lang.Object ref = topic_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + topic_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string Topic = 3; + * @param value The topic to set. + * @return This builder for chaining. + */ + public Builder setTopic( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + topic_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * optional string Topic = 3; + * @return This builder for chaining. + */ + public Builder clearTopic() { + topic_ = getDefaultInstance().getTopic(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * optional string Topic = 3; + * @param value The bytes for topic to set. + * @return This builder for chaining. + */ + public Builder setTopicBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + topic_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object source_ = ""; + /** + * optional string Source = 4; + * @return Whether the source field is set. + */ + public boolean hasSource() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * optional string Source = 4; + * @return The source. + */ + public java.lang.String getSource() { + java.lang.Object ref = source_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (bs.isValidUtf8()) { + source_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string Source = 4; + * @return The bytes for source. + */ + public com.google.protobuf.ByteString + getSourceBytes() { + java.lang.Object ref = source_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + source_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string Source = 4; + * @param value The source to set. + * @return This builder for chaining. + */ + public Builder setSource( + java.lang.String value) { + if (value == null) { throw new NullPointerException(); } + source_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * optional string Source = 4; + * @return This builder for chaining. + */ + public Builder clearSource() { + source_ = getDefaultInstance().getSource(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * optional string Source = 4; + * @param value The bytes for source to set. + * @return This builder for chaining. + */ + public Builder setSourceBytes( + com.google.protobuf.ByteString value) { + if (value == null) { throw new NullPointerException(); } + source_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private java.util.List logTags_ = + java.util.Collections.emptyList(); + private void ensureLogTagsIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + logTags_ = new java.util.ArrayList(logTags_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.LogTag, com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder, com.aliyun.gateway.sls.util.model.Logs.LogTagOrBuilder> logTagsBuilder_; + + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public java.util.List getLogTagsList() { + if (logTagsBuilder_ == null) { + return java.util.Collections.unmodifiableList(logTags_); + } else { + return logTagsBuilder_.getMessageList(); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public int getLogTagsCount() { + if (logTagsBuilder_ == null) { + return logTags_.size(); + } else { + return logTagsBuilder_.getCount(); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogTag getLogTags(int index) { + if (logTagsBuilder_ == null) { + return logTags_.get(index); + } else { + return logTagsBuilder_.getMessage(index); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder setLogTags( + int index, com.aliyun.gateway.sls.util.model.Logs.LogTag value) { + if (logTagsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogTagsIsMutable(); + logTags_.set(index, value); + onChanged(); + } else { + logTagsBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder setLogTags( + int index, com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder builderForValue) { + if (logTagsBuilder_ == null) { + ensureLogTagsIsMutable(); + logTags_.set(index, builderForValue.build()); + onChanged(); + } else { + logTagsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder addLogTags(com.aliyun.gateway.sls.util.model.Logs.LogTag value) { + if (logTagsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogTagsIsMutable(); + logTags_.add(value); + onChanged(); + } else { + logTagsBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder addLogTags( + int index, com.aliyun.gateway.sls.util.model.Logs.LogTag value) { + if (logTagsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureLogTagsIsMutable(); + logTags_.add(index, value); + onChanged(); + } else { + logTagsBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder addLogTags( + com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder builderForValue) { + if (logTagsBuilder_ == null) { + ensureLogTagsIsMutable(); + logTags_.add(builderForValue.build()); + onChanged(); + } else { + logTagsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder addLogTags( + int index, com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder builderForValue) { + if (logTagsBuilder_ == null) { + ensureLogTagsIsMutable(); + logTags_.add(index, builderForValue.build()); + onChanged(); + } else { + logTagsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder addAllLogTags( + java.lang.Iterable values) { + if (logTagsBuilder_ == null) { + ensureLogTagsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, logTags_); + onChanged(); + } else { + logTagsBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder clearLogTags() { + if (logTagsBuilder_ == null) { + logTags_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + logTagsBuilder_.clear(); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public Builder removeLogTags(int index) { + if (logTagsBuilder_ == null) { + ensureLogTagsIsMutable(); + logTags_.remove(index); + onChanged(); + } else { + logTagsBuilder_.remove(index); + } + return this; + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder getLogTagsBuilder( + int index) { + return getLogTagsFieldBuilder().getBuilder(index); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogTagOrBuilder getLogTagsOrBuilder( + int index) { + if (logTagsBuilder_ == null) { + return logTags_.get(index); } else { + return logTagsBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public java.util.List + getLogTagsOrBuilderList() { + if (logTagsBuilder_ != null) { + return logTagsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(logTags_); + } + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder addLogTagsBuilder() { + return getLogTagsFieldBuilder().addBuilder( + com.aliyun.gateway.sls.util.model.Logs.LogTag.getDefaultInstance()); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder addLogTagsBuilder( + int index) { + return getLogTagsFieldBuilder().addBuilder( + index, com.aliyun.gateway.sls.util.model.Logs.LogTag.getDefaultInstance()); + } + /** + * repeated .com.aliyun.gateway.sls.util.model.LogTag LogTags = 6; + */ + public java.util.List + getLogTagsBuilderList() { + return getLogTagsFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.LogTag, com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder, com.aliyun.gateway.sls.util.model.Logs.LogTagOrBuilder> + getLogTagsFieldBuilder() { + if (logTagsBuilder_ == null) { + logTagsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + com.aliyun.gateway.sls.util.model.Logs.LogTag, com.aliyun.gateway.sls.util.model.Logs.LogTag.Builder, com.aliyun.gateway.sls.util.model.Logs.LogTagOrBuilder>( + logTags_, + ((bitField0_ & 0x00000008) != 0), + getParentForChildren(), + isClean()); + logTags_ = null; + } + return logTagsBuilder_; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:com.aliyun.gateway.sls.util.model.LogGroup) + } + + // @@protoc_insertion_point(class_scope:com.aliyun.gateway.sls.util.model.LogGroup) + private static final com.aliyun.gateway.sls.util.model.Logs.LogGroup DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.aliyun.gateway.sls.util.model.Logs.LogGroup(); + } + + public static com.aliyun.gateway.sls.util.model.Logs.LogGroup getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + @java.lang.Deprecated public static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LogGroup parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.aliyun.gateway.sls.util.model.Logs.LogGroup getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_gateway_sls_util_model_LogContent_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_aliyun_gateway_sls_util_model_LogContent_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_gateway_sls_util_model_Log_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_aliyun_gateway_sls_util_model_Log_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_gateway_sls_util_model_LogTag_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_aliyun_gateway_sls_util_model_LogTag_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_com_aliyun_gateway_sls_util_model_LogGroup_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_com_aliyun_gateway_sls_util_model_LogGroup_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\nlogs.proto\022!com.aliyun.gateway.sls.uti" + + "l.model\"(\n\nLogContent\022\013\n\003Key\030\001 \002(\t\022\r\n\005Va" + + "lue\030\002 \002(\t\"d\n\003Log\022\014\n\004Time\030\001 \002(\r\022?\n\010Conten" + + "ts\030\002 \003(\0132-.com.aliyun.gateway.sls.util.m" + + "odel.LogContent\022\016\n\006TimeNs\030\004 \001(\007\"$\n\006LogTa" + + "g\022\013\n\003Key\030\001 \002(\t\022\r\n\005Value\030\002 \002(\t\"\233\001\n\010LogGro" + + "up\0224\n\004Logs\030\001 \003(\0132&.com.aliyun.gateway.sl" + + "s.util.model.Log\022\r\n\005Topic\030\003 \001(\t\022\016\n\006Sourc" + + "e\030\004 \001(\t\022:\n\007LogTags\030\006 \003(\0132).com.aliyun.ga" + + "teway.sls.util.model.LogTag" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_com_aliyun_gateway_sls_util_model_LogContent_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_com_aliyun_gateway_sls_util_model_LogContent_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_gateway_sls_util_model_LogContent_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_com_aliyun_gateway_sls_util_model_Log_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_com_aliyun_gateway_sls_util_model_Log_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_gateway_sls_util_model_Log_descriptor, + new java.lang.String[] { "Time", "Contents", "TimeNs", }); + internal_static_com_aliyun_gateway_sls_util_model_LogTag_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_com_aliyun_gateway_sls_util_model_LogTag_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_gateway_sls_util_model_LogTag_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_com_aliyun_gateway_sls_util_model_LogGroup_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_com_aliyun_gateway_sls_util_model_LogGroup_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_com_aliyun_gateway_sls_util_model_LogGroup_descriptor, + new java.lang.String[] { "Logs", "Topic", "Source", "LogTags", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/LogsResponseBody.java b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/LogsResponseBody.java new file mode 100644 index 00000000..83934ddf --- /dev/null +++ b/alibabacloud-gateway-sls/util/java/src/main/java/com/aliyun/gateway/sls/util/model/LogsResponseBody.java @@ -0,0 +1,114 @@ +package com.aliyun.gateway.sls.util.model; + +import com.aliyun.gateway.sls.util.Client; +import com.aliyun.gateway.sls.util.exception.LogException; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +public class LogsResponseBody { + // init fields + private final byte[] rawData; + private final Map headers; + private final int statusCode; + // parsed fields + private List logGroups; + private int count; + private String requestId; + private long cursorTime; + private boolean isEndOfCursor; + + public LogsResponseBody(byte[] rawData, int statusCode, Map headers) { + this.rawData = rawData; + this.statusCode = statusCode; + this.headers = headers; + parseHeaders(); + } + + public List getLogGroups() throws LogException { + if (logGroups == null) { + parseFastLogGroupList(rawData); + } + return logGroups; + } + + /** + * Get number of logGroups + * + * @return number of logGroups fetched + */ + public int getCount() { + return count; + } + + public long getCursorTime() { + return cursorTime; + } + + public boolean isEndOfCursor() { + return isEndOfCursor; + } + + private void parseHeaders() { + requestId = headers.get("x-request-id"); + isEndOfCursor = "1".equals(headers.get("x-log-end-of-cursor")); + try { + count = Integer.parseInt(headers.get("x-log-count")); + String cursorTimeHeader = headers.get("x-log-cursor-time"); + cursorTime = cursorTimeHeader != null && !cursorTimeHeader.isEmpty() ? Long.parseLong(cursorTimeHeader.trim()) : 0; + } catch (NumberFormatException e) { + throw new LogException("ParsePullLogHeaderError", e.getMessage(), requestId); + } + } + + /** + * Parse LogGroupList using fast deserialize method. + * + * @param data is LogGroupList bytes + * @throws LogException if parse fails + */ + private void parseFastLogGroupList(byte[] data) throws LogException { + logGroups = new ArrayList<>(); + if (data == null || data.length == 0) { + return; + } + int pos = 0; + int rawSize = data.length; + int mode, index; + while (pos < rawSize) { + int[] value = Client.decodeVarInt32(data, pos, rawSize); + if (value[0] == 0) { + throw new LogException("InitLogGroupsError", "decode varint32 error", requestId, statusCode); + } + pos = value[2]; + mode = value[1] & 0x7; + index = value[1] >> 3; + if (mode == 0) { + value = Client.decodeVarInt32(data, pos, rawSize); + if (value[0] == 0) { + throw new LogException("InitLogGroupsError", "decode varint32 error", requestId, statusCode); + } + pos = value[2]; + } else if (mode == 1) { + pos += 8; + } else if (mode == 2) { + value = Client.decodeVarInt32(data, pos, rawSize); + if (value[0] == 0) { + throw new LogException("InitLogGroupsError", "decode varint32 error", requestId, statusCode); + } + if (index == 1) { + logGroups.add(new FastLogGroup(data, value[2], value[1], requestId)); + } + pos = value[1] + value[2]; + } else if (mode == 5) { + pos += 4; + } else { + throw new LogException("InitLogGroupsError", "mode: " + mode, requestId, statusCode); + } + } + if (pos != rawSize) { + throw new LogException("InitLogGroupsError", "parse LogGroupList fail", requestId, statusCode); + } + } +} diff --git a/alibabacloud-gateway-sls/util/logs.proto b/alibabacloud-gateway-sls/util/logs.proto new file mode 100644 index 00000000..baf3cfe6 --- /dev/null +++ b/alibabacloud-gateway-sls/util/logs.proto @@ -0,0 +1,30 @@ +syntax = "proto2"; + +package com.aliyun.gateway.sls.util.model; + +message LogContent +{ + required string Key = 1; + required string Value = 2; +} + +message Log +{ + required uint32 Time = 1; + repeated LogContent Contents= 2; + optional fixed32 TimeNs = 4; +} + +message LogTag +{ + required string Key = 1; + required string Value = 2; +} + +message LogGroup +{ + repeated Log Logs= 1; + optional string Topic = 3; + optional string Source = 4; + repeated LogTag LogTags = 6; +} \ No newline at end of file diff --git a/alibabacloud-gateway-sls/util/main.tea b/alibabacloud-gateway-sls/util/main.tea index 287942c7..4daeaf69 100644 --- a/alibabacloud-gateway-sls/util/main.tea +++ b/alibabacloud-gateway-sls/util/main.tea @@ -18,4 +18,6 @@ static async function compress(src: bytes, compressType: string): bytes static async function isCompressorAvailable(compressType: string): boolean static async function isDecompressorAvailable(compressType: string): boolean -static async function bytesLength(src: bytes): int64 \ No newline at end of file +static async function bytesLength(src: bytes): int64 +static function serializeToPbBytes(request: any) : bytes; +static function deserializeFromPbBytes(data: bytes, statusCode: integer, headers: map[string]string) : any; diff --git a/alibabacloud-gateway-sls/util/ts/package.json b/alibabacloud-gateway-sls/util/ts/package.json index 70560501..ec5ee381 100644 --- a/alibabacloud-gateway-sls/util/ts/package.json +++ b/alibabacloud-gateway-sls/util/ts/package.json @@ -20,7 +20,10 @@ "typescript": "^3.7.5" }, "dependencies": { - "lz4": "^0.6.5" + "lz4": "^0.6.5", + "@alicloud/tea-typescript": "^1.7.1", + "zlib": "^1.0.5", + "pomelo-protobuf": "^0.4.0" }, "files": [ "dist", diff --git a/alibabacloud-gateway-sls/util/ts/src/client.ts b/alibabacloud-gateway-sls/util/ts/src/client.ts index d90c2512..d59121cd 100644 --- a/alibabacloud-gateway-sls/util/ts/src/client.ts +++ b/alibabacloud-gateway-sls/util/ts/src/client.ts @@ -10,6 +10,56 @@ import { Readable } from 'stream'; import {gzipCompress, isCompressorAvailable, lz4Compress} from './compress'; import {lz4Decompress, gzipDecompress, DecompressFunc, isDecompressorAvailable} from './decompress'; +const zlib = require('zlib'); +import * as po_protobuf from 'pomelo-protobuf'; +import * as $tea from '@alicloud/tea-typescript'; + +// 定义 proto_json 对象类型 +interface ProtoJson { + [key: string]: any; +} + +const proto_json: ProtoJson = { + "message Log": { + "required uInt32 time": 1, + "message Content": { + "required string key": 1, + "required string value": 2, + }, + "repeated Content contents": 2, + }, + "message LogTag": { + "required string Key": 1, + "required string Value": 2, + }, + "LogGroup": { + "repeated Log logs": 1, + "optional string category": 2, + "optional string topic": 3, + "optional string source": 4, + "optional string MachineUUID": 5, + "repeated LogTag LogTags": 6, + }, + "LogStore": { + "repeated Log logs": 1, + "optional string category": 2, + "optional string topic": 3, + "optional string source": 4, + }, + "LogGroupList": { + "message LogGroup": { + "repeated Log logs": 1, + "optional string category": 2, + "optional string topic": 3, + "optional string source": 4, + "optional string MachineUUID": 5, + "repeated LogTag LogTags": 6, + }, + "repeated LogGroup logGroupList": 1, + }, +}; + +const protos = po_protobuf.parse(proto_json); export default class Client { @@ -74,4 +124,59 @@ export default class Client { return src.length; } + static serializeToPbBytes(request: any): Buffer { + po_protobuf.init({ + encoderProtos: protos, + decoderProtos: protos, + }); + const logGroup = JSON.parse(request.body); + + if (!logGroup.logs) { + throw $tea.newError({ + code: 'ContentError', + message: 'Logitems is empty.', + }); + } + + if (logGroup.logs.length > 4096) { + throw $tea.newError({ + code: 'ContentError', + message: 'Logitems length exceed 4096.', + }); + } + + const pb = po_protobuf.encode('LogGroup', logGroup); + + if (pb.length > 3 * 1024 * 1024) { + throw $tea.newError({ + code: 'ContentError', + message: 'Logitems size exceed 5MB', + }); + } + + return pb; + } + + static deserializeFromPbBytes(data: Buffer, statusCode: number, headers: { [key: string]: string }): any { + try { + po_protobuf.init({ + encoderProtos: protos, + decoderProtos: protos, + }); + + const pb = po_protobuf.decode("LogGroupList", data); + return pb; + } catch (error) { + var requestId = headers['x-log-requestid']; + throw $tea.newError({ + code: 'ContentError', + message: 'Protobuf parse failed.', + data: { + requestId: requestId, + statusCode: statusCode, + }, + }); + } + } + }