|
1 |
| -/* |
2 |
| - * Copyright 2019 NAVER Corp. |
3 |
| - * |
4 |
| - * Licensed under the Apache License, Version 2.0 (the "License"); |
5 |
| - * you may not use this file except in compliance with the License. |
6 |
| - * You may obtain a copy of the License at |
7 |
| - * |
8 |
| - * http://www.apache.org/licenses/LICENSE-2.0 |
9 |
| - * |
10 |
| - * Unless required by applicable law or agreed to in writing, software |
11 |
| - * distributed under the License is distributed on an "AS IS" BASIS, |
12 |
| - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 |
| - * See the License for the specific language governing permissions and |
14 |
| - * limitations under the License. |
15 |
| - */ |
16 |
| - |
17 |
| -package com.navercorp.pinpoint.profiler.context.grpc; |
18 |
| - |
19 |
| -import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadCount; |
20 |
| -import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadDump; |
21 |
| -import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadLightDump; |
22 |
| -import com.navercorp.pinpoint.grpc.trace.PCmdEcho; |
23 |
| -import com.navercorp.pinpoint.profiler.context.thrift.MessageConverter; |
24 |
| -import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCount; |
25 |
| -import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump; |
26 |
| -import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump; |
27 |
| -import com.navercorp.pinpoint.thrift.dto.command.TCommandEcho; |
28 |
| - |
29 |
| -import com.google.protobuf.GeneratedMessageV3; |
30 |
| - |
31 |
| -/** |
32 |
| - * @author Taejin Koo |
33 |
| - */ |
34 |
| -public class CommandThriftToGrpcMessageConverter implements MessageConverter<Object, GeneratedMessageV3> { |
35 |
| - |
36 |
| - @Override |
37 |
| - public GeneratedMessageV3 toMessage(Object message) { |
38 |
| - if (message instanceof TCommandEcho) { |
39 |
| - return buildPCommandEcho((TCommandEcho) message); |
40 |
| - } else if (message instanceof TCmdActiveThreadCount) { |
41 |
| - return buildPCmdActiveThreadCount((TCmdActiveThreadCount) message); |
42 |
| - } else if (message instanceof TCmdActiveThreadDump) { |
43 |
| - return buildPCmdActiveThreadDump((TCmdActiveThreadDump) message); |
44 |
| - } else if (message instanceof TCmdActiveThreadLightDump) { |
45 |
| - return buildPCmdActiveThreadLightDump((TCmdActiveThreadLightDump) message); |
46 |
| - } |
47 |
| - return null; |
48 |
| - } |
49 |
| - |
50 |
| - private PCmdEcho buildPCommandEcho(TCommandEcho tCommandEcho) { |
51 |
| - PCmdEcho.Builder builder = PCmdEcho.newBuilder(); |
52 |
| - builder.setMessage(tCommandEcho.getMessage()); |
53 |
| - return builder.build(); |
54 |
| - } |
55 |
| - |
56 |
| - private PCmdActiveThreadCount buildPCmdActiveThreadCount(TCmdActiveThreadCount tCmdActiveThreadCount) { |
57 |
| - PCmdActiveThreadCount.Builder builder = PCmdActiveThreadCount.newBuilder(); |
58 |
| - return builder.build(); |
59 |
| - } |
60 |
| - |
61 |
| - private PCmdActiveThreadDump buildPCmdActiveThreadDump(TCmdActiveThreadDump tCmdActiveThreadDump) { |
62 |
| - PCmdActiveThreadDump.Builder builder = PCmdActiveThreadDump.newBuilder(); |
63 |
| - builder.setLimit(tCmdActiveThreadDump.getLimit()); |
64 |
| - if (tCmdActiveThreadDump.isSetLocalTraceIdList()) { |
65 |
| - builder.addAllLocalTraceId(tCmdActiveThreadDump.getLocalTraceIdList()); |
66 |
| - } |
67 |
| - if (tCmdActiveThreadDump.isSetThreadNameList()) { |
68 |
| - builder.addAllThreadName(tCmdActiveThreadDump.getThreadNameList()); |
69 |
| - } |
70 |
| - |
71 |
| - return builder.build(); |
72 |
| - } |
73 |
| - |
74 |
| - private PCmdActiveThreadLightDump buildPCmdActiveThreadLightDump(TCmdActiveThreadLightDump tCmdActiveThreadLightDump) { |
75 |
| - PCmdActiveThreadLightDump.Builder builder = PCmdActiveThreadLightDump.newBuilder(); |
76 |
| - builder.setLimit(tCmdActiveThreadLightDump.getLimit()); |
77 |
| - if (tCmdActiveThreadLightDump.isSetLocalTraceIdList()) { |
78 |
| - builder.addAllLocalTraceId(tCmdActiveThreadLightDump.getLocalTraceIdList()); |
79 |
| - } |
80 |
| - if (tCmdActiveThreadLightDump.isSetThreadNameList()) { |
81 |
| - builder.addAllThreadName(tCmdActiveThreadLightDump.getThreadNameList()); |
82 |
| - } |
83 |
| - |
84 |
| - return builder.build(); |
85 |
| - } |
86 |
| - |
87 |
| -} |
| 1 | +/* |
| 2 | + * Copyright 2019 NAVER Corp. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package com.navercorp.pinpoint.collector.cluster.grpc; |
| 18 | + |
| 19 | +import com.google.protobuf.GeneratedMessageV3; |
| 20 | +import com.navercorp.pinpoint.common.profiler.message.MessageConverter; |
| 21 | +import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadCount; |
| 22 | +import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadDump; |
| 23 | +import com.navercorp.pinpoint.grpc.trace.PCmdActiveThreadLightDump; |
| 24 | +import com.navercorp.pinpoint.grpc.trace.PCmdEcho; |
| 25 | +import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadCount; |
| 26 | +import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadDump; |
| 27 | +import com.navercorp.pinpoint.thrift.dto.command.TCmdActiveThreadLightDump; |
| 28 | +import com.navercorp.pinpoint.thrift.dto.command.TCommandEcho; |
| 29 | + |
| 30 | +/** |
| 31 | + * @author Taejin Koo |
| 32 | + */ |
| 33 | +public class CommandThriftToGrpcMessageConverter implements MessageConverter<Object, GeneratedMessageV3> { |
| 34 | + |
| 35 | + @Override |
| 36 | + public GeneratedMessageV3 toMessage(Object message) { |
| 37 | + if (message instanceof TCommandEcho) { |
| 38 | + return buildPCommandEcho((TCommandEcho) message); |
| 39 | + } else if (message instanceof TCmdActiveThreadCount) { |
| 40 | + return buildPCmdActiveThreadCount((TCmdActiveThreadCount) message); |
| 41 | + } else if (message instanceof TCmdActiveThreadDump) { |
| 42 | + return buildPCmdActiveThreadDump((TCmdActiveThreadDump) message); |
| 43 | + } else if (message instanceof TCmdActiveThreadLightDump) { |
| 44 | + return buildPCmdActiveThreadLightDump((TCmdActiveThreadLightDump) message); |
| 45 | + } |
| 46 | + return null; |
| 47 | + } |
| 48 | + |
| 49 | + private PCmdEcho buildPCommandEcho(TCommandEcho tCommandEcho) { |
| 50 | + PCmdEcho.Builder builder = PCmdEcho.newBuilder(); |
| 51 | + builder.setMessage(tCommandEcho.getMessage()); |
| 52 | + return builder.build(); |
| 53 | + } |
| 54 | + |
| 55 | + private PCmdActiveThreadCount buildPCmdActiveThreadCount(TCmdActiveThreadCount tCmdActiveThreadCount) { |
| 56 | + PCmdActiveThreadCount.Builder builder = PCmdActiveThreadCount.newBuilder(); |
| 57 | + return builder.build(); |
| 58 | + } |
| 59 | + |
| 60 | + private PCmdActiveThreadDump buildPCmdActiveThreadDump(TCmdActiveThreadDump tCmdActiveThreadDump) { |
| 61 | + PCmdActiveThreadDump.Builder builder = PCmdActiveThreadDump.newBuilder(); |
| 62 | + builder.setLimit(tCmdActiveThreadDump.getLimit()); |
| 63 | + if (tCmdActiveThreadDump.isSetLocalTraceIdList()) { |
| 64 | + builder.addAllLocalTraceId(tCmdActiveThreadDump.getLocalTraceIdList()); |
| 65 | + } |
| 66 | + if (tCmdActiveThreadDump.isSetThreadNameList()) { |
| 67 | + builder.addAllThreadName(tCmdActiveThreadDump.getThreadNameList()); |
| 68 | + } |
| 69 | + |
| 70 | + return builder.build(); |
| 71 | + } |
| 72 | + |
| 73 | + private PCmdActiveThreadLightDump buildPCmdActiveThreadLightDump(TCmdActiveThreadLightDump tCmdActiveThreadLightDump) { |
| 74 | + PCmdActiveThreadLightDump.Builder builder = PCmdActiveThreadLightDump.newBuilder(); |
| 75 | + builder.setLimit(tCmdActiveThreadLightDump.getLimit()); |
| 76 | + if (tCmdActiveThreadLightDump.isSetLocalTraceIdList()) { |
| 77 | + builder.addAllLocalTraceId(tCmdActiveThreadLightDump.getLocalTraceIdList()); |
| 78 | + } |
| 79 | + if (tCmdActiveThreadLightDump.isSetThreadNameList()) { |
| 80 | + builder.addAllThreadName(tCmdActiveThreadLightDump.getThreadNameList()); |
| 81 | + } |
| 82 | + |
| 83 | + return builder.build(); |
| 84 | + } |
| 85 | + |
| 86 | +} |
0 commit comments