responseObserver) {
169 | serviceImpl.sayHello(request, responseObserver);
170 | }
171 | }))).build();
172 | }
173 | }
174 |
--------------------------------------------------------------------------------
/gRPC/scala/src/main/scala/com/colobu/rpctest/GreeterOuterClass.java:
--------------------------------------------------------------------------------
1 | // Generated by the protocol buffer compiler. DO NOT EDIT!
2 | // source: greeter.proto
3 |
4 | package com.colobu.rpctest;
5 |
6 | public final class GreeterOuterClass {
7 | private GreeterOuterClass() {}
8 | public static void registerAllExtensions(
9 | com.google.protobuf.ExtensionRegistry registry) {
10 | }
11 | public interface HelloRequestOrBuilder extends
12 | // @@protoc_insertion_point(interface_extends:greeter.HelloRequest)
13 | com.google.protobuf.MessageOrBuilder {
14 |
15 | /**
16 | * optional string name = 1;
17 | */
18 | java.lang.String getName();
19 | /**
20 | * optional string name = 1;
21 | */
22 | com.google.protobuf.ByteString
23 | getNameBytes();
24 | }
25 | /**
26 | * Protobuf type {@code greeter.HelloRequest}
27 | *
28 | *
29 | * The request message containing the user's name.
30 | *
31 | */
32 | public static final class HelloRequest extends
33 | com.google.protobuf.GeneratedMessage implements
34 | // @@protoc_insertion_point(message_implements:greeter.HelloRequest)
35 | HelloRequestOrBuilder {
36 | // Use HelloRequest.newBuilder() to construct.
37 | private HelloRequest(com.google.protobuf.GeneratedMessage.Builder builder) {
38 | super(builder);
39 | }
40 | private HelloRequest() {
41 | name_ = "";
42 | }
43 |
44 | @java.lang.Override
45 | public final com.google.protobuf.UnknownFieldSet
46 | getUnknownFields() {
47 | return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
48 | }
49 | private HelloRequest(
50 | com.google.protobuf.CodedInputStream input,
51 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) {
52 | this();
53 | int mutable_bitField0_ = 0;
54 | try {
55 | boolean done = false;
56 | while (!done) {
57 | int tag = input.readTag();
58 | switch (tag) {
59 | case 0:
60 | done = true;
61 | break;
62 | default: {
63 | if (!input.skipField(tag)) {
64 | done = true;
65 | }
66 | break;
67 | }
68 | case 10: {
69 | com.google.protobuf.ByteString bs = input.readBytes();
70 |
71 | name_ = bs;
72 | break;
73 | }
74 | }
75 | }
76 | } catch (com.google.protobuf.InvalidProtocolBufferException e) {
77 | throw new RuntimeException(e.setUnfinishedMessage(this));
78 | } catch (java.io.IOException e) {
79 | throw new RuntimeException(
80 | new com.google.protobuf.InvalidProtocolBufferException(
81 | e.getMessage()).setUnfinishedMessage(this));
82 | } finally {
83 | makeExtensionsImmutable();
84 | }
85 | }
86 | public static final com.google.protobuf.Descriptors.Descriptor
87 | getDescriptor() {
88 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloRequest_descriptor;
89 | }
90 |
91 | protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
92 | internalGetFieldAccessorTable() {
93 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloRequest_fieldAccessorTable
94 | .ensureFieldAccessorsInitialized(
95 | com.colobu.rpctest.GreeterOuterClass.HelloRequest.class, com.colobu.rpctest.GreeterOuterClass.HelloRequest.Builder.class);
96 | }
97 |
98 | public static final int NAME_FIELD_NUMBER = 1;
99 | private volatile java.lang.Object name_;
100 | /**
101 | * optional string name = 1;
102 | */
103 | public java.lang.String getName() {
104 | java.lang.Object ref = name_;
105 | if (ref instanceof java.lang.String) {
106 | return (java.lang.String) ref;
107 | } else {
108 | com.google.protobuf.ByteString bs =
109 | (com.google.protobuf.ByteString) ref;
110 | java.lang.String s = bs.toStringUtf8();
111 | if (bs.isValidUtf8()) {
112 | name_ = s;
113 | }
114 | return s;
115 | }
116 | }
117 | /**
118 | * optional string name = 1;
119 | */
120 | public com.google.protobuf.ByteString
121 | getNameBytes() {
122 | java.lang.Object ref = name_;
123 | if (ref instanceof java.lang.String) {
124 | com.google.protobuf.ByteString b =
125 | com.google.protobuf.ByteString.copyFromUtf8(
126 | (java.lang.String) ref);
127 | name_ = b;
128 | return b;
129 | } else {
130 | return (com.google.protobuf.ByteString) ref;
131 | }
132 | }
133 |
134 | private byte memoizedIsInitialized = -1;
135 | public final boolean isInitialized() {
136 | byte isInitialized = memoizedIsInitialized;
137 | if (isInitialized == 1) return true;
138 | if (isInitialized == 0) return false;
139 |
140 | memoizedIsInitialized = 1;
141 | return true;
142 | }
143 |
144 | public void writeTo(com.google.protobuf.CodedOutputStream output)
145 | throws java.io.IOException {
146 | if (!getNameBytes().isEmpty()) {
147 | output.writeBytes(1, getNameBytes());
148 | }
149 | }
150 |
151 | private int memoizedSerializedSize = -1;
152 | public int getSerializedSize() {
153 | int size = memoizedSerializedSize;
154 | if (size != -1) return size;
155 |
156 | size = 0;
157 | if (!getNameBytes().isEmpty()) {
158 | size += com.google.protobuf.CodedOutputStream
159 | .computeBytesSize(1, getNameBytes());
160 | }
161 | memoizedSerializedSize = size;
162 | return size;
163 | }
164 |
165 | private static final long serialVersionUID = 0L;
166 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseFrom(
167 | com.google.protobuf.ByteString data)
168 | throws com.google.protobuf.InvalidProtocolBufferException {
169 | return PARSER.parseFrom(data);
170 | }
171 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseFrom(
172 | com.google.protobuf.ByteString data,
173 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
174 | throws com.google.protobuf.InvalidProtocolBufferException {
175 | return PARSER.parseFrom(data, extensionRegistry);
176 | }
177 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseFrom(byte[] data)
178 | throws com.google.protobuf.InvalidProtocolBufferException {
179 | return PARSER.parseFrom(data);
180 | }
181 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseFrom(
182 | byte[] data,
183 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
184 | throws com.google.protobuf.InvalidProtocolBufferException {
185 | return PARSER.parseFrom(data, extensionRegistry);
186 | }
187 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseFrom(java.io.InputStream input)
188 | throws java.io.IOException {
189 | return PARSER.parseFrom(input);
190 | }
191 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseFrom(
192 | java.io.InputStream input,
193 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
194 | throws java.io.IOException {
195 | return PARSER.parseFrom(input, extensionRegistry);
196 | }
197 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseDelimitedFrom(java.io.InputStream input)
198 | throws java.io.IOException {
199 | return PARSER.parseDelimitedFrom(input);
200 | }
201 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseDelimitedFrom(
202 | java.io.InputStream input,
203 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
204 | throws java.io.IOException {
205 | return PARSER.parseDelimitedFrom(input, extensionRegistry);
206 | }
207 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseFrom(
208 | com.google.protobuf.CodedInputStream input)
209 | throws java.io.IOException {
210 | return PARSER.parseFrom(input);
211 | }
212 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest parseFrom(
213 | com.google.protobuf.CodedInputStream input,
214 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
215 | throws java.io.IOException {
216 | return PARSER.parseFrom(input, extensionRegistry);
217 | }
218 |
219 | public Builder newBuilderForType() { return newBuilder(); }
220 | public static Builder newBuilder() {
221 | return DEFAULT_INSTANCE.toBuilder();
222 | }
223 | public static Builder newBuilder(com.colobu.rpctest.GreeterOuterClass.HelloRequest prototype) {
224 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
225 | }
226 | public Builder toBuilder() {
227 | return this == DEFAULT_INSTANCE
228 | ? new Builder() : new Builder().mergeFrom(this);
229 | }
230 |
231 | @java.lang.Override
232 | protected Builder newBuilderForType(
233 | com.google.protobuf.GeneratedMessage.BuilderParent parent) {
234 | Builder builder = new Builder(parent);
235 | return builder;
236 | }
237 | /**
238 | * Protobuf type {@code greeter.HelloRequest}
239 | *
240 | *
241 | * The request message containing the user's name.
242 | *
243 | */
244 | public static final class Builder extends
245 | com.google.protobuf.GeneratedMessage.Builder implements
246 | // @@protoc_insertion_point(builder_implements:greeter.HelloRequest)
247 | com.colobu.rpctest.GreeterOuterClass.HelloRequestOrBuilder {
248 | public static final com.google.protobuf.Descriptors.Descriptor
249 | getDescriptor() {
250 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloRequest_descriptor;
251 | }
252 |
253 | protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
254 | internalGetFieldAccessorTable() {
255 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloRequest_fieldAccessorTable
256 | .ensureFieldAccessorsInitialized(
257 | com.colobu.rpctest.GreeterOuterClass.HelloRequest.class, com.colobu.rpctest.GreeterOuterClass.HelloRequest.Builder.class);
258 | }
259 |
260 | // Construct using com.colobu.rpctest.GreeterOuterClass.HelloRequest.newBuilder()
261 | private Builder() {
262 | maybeForceBuilderInitialization();
263 | }
264 |
265 | private Builder(
266 | com.google.protobuf.GeneratedMessage.BuilderParent parent) {
267 | super(parent);
268 | maybeForceBuilderInitialization();
269 | }
270 | private void maybeForceBuilderInitialization() {
271 | if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
272 | }
273 | }
274 | public Builder clear() {
275 | super.clear();
276 | name_ = "";
277 |
278 | return this;
279 | }
280 |
281 | public com.google.protobuf.Descriptors.Descriptor
282 | getDescriptorForType() {
283 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloRequest_descriptor;
284 | }
285 |
286 | public com.colobu.rpctest.GreeterOuterClass.HelloRequest getDefaultInstanceForType() {
287 | return com.colobu.rpctest.GreeterOuterClass.HelloRequest.getDefaultInstance();
288 | }
289 |
290 | public com.colobu.rpctest.GreeterOuterClass.HelloRequest build() {
291 | com.colobu.rpctest.GreeterOuterClass.HelloRequest result = buildPartial();
292 | if (!result.isInitialized()) {
293 | throw newUninitializedMessageException(result);
294 | }
295 | return result;
296 | }
297 |
298 | public com.colobu.rpctest.GreeterOuterClass.HelloRequest buildPartial() {
299 | com.colobu.rpctest.GreeterOuterClass.HelloRequest result = new com.colobu.rpctest.GreeterOuterClass.HelloRequest(this);
300 | result.name_ = name_;
301 | onBuilt();
302 | return result;
303 | }
304 |
305 | public Builder mergeFrom(com.google.protobuf.Message other) {
306 | if (other instanceof com.colobu.rpctest.GreeterOuterClass.HelloRequest) {
307 | return mergeFrom((com.colobu.rpctest.GreeterOuterClass.HelloRequest)other);
308 | } else {
309 | super.mergeFrom(other);
310 | return this;
311 | }
312 | }
313 |
314 | public Builder mergeFrom(com.colobu.rpctest.GreeterOuterClass.HelloRequest other) {
315 | if (other == com.colobu.rpctest.GreeterOuterClass.HelloRequest.getDefaultInstance()) return this;
316 | if (!other.getName().isEmpty()) {
317 | name_ = other.name_;
318 | onChanged();
319 | }
320 | onChanged();
321 | return this;
322 | }
323 |
324 | public final boolean isInitialized() {
325 | return true;
326 | }
327 |
328 | public Builder mergeFrom(
329 | com.google.protobuf.CodedInputStream input,
330 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
331 | throws java.io.IOException {
332 | com.colobu.rpctest.GreeterOuterClass.HelloRequest parsedMessage = null;
333 | try {
334 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
335 | } catch (com.google.protobuf.InvalidProtocolBufferException e) {
336 | parsedMessage = (com.colobu.rpctest.GreeterOuterClass.HelloRequest) e.getUnfinishedMessage();
337 | throw e;
338 | } finally {
339 | if (parsedMessage != null) {
340 | mergeFrom(parsedMessage);
341 | }
342 | }
343 | return this;
344 | }
345 |
346 | private java.lang.Object name_ = "";
347 | /**
348 | * optional string name = 1;
349 | */
350 | public java.lang.String getName() {
351 | java.lang.Object ref = name_;
352 | if (!(ref instanceof java.lang.String)) {
353 | com.google.protobuf.ByteString bs =
354 | (com.google.protobuf.ByteString) ref;
355 | java.lang.String s = bs.toStringUtf8();
356 | if (bs.isValidUtf8()) {
357 | name_ = s;
358 | }
359 | return s;
360 | } else {
361 | return (java.lang.String) ref;
362 | }
363 | }
364 | /**
365 | * optional string name = 1;
366 | */
367 | public com.google.protobuf.ByteString
368 | getNameBytes() {
369 | java.lang.Object ref = name_;
370 | if (ref instanceof String) {
371 | com.google.protobuf.ByteString b =
372 | com.google.protobuf.ByteString.copyFromUtf8(
373 | (java.lang.String) ref);
374 | name_ = b;
375 | return b;
376 | } else {
377 | return (com.google.protobuf.ByteString) ref;
378 | }
379 | }
380 | /**
381 | * optional string name = 1;
382 | */
383 | public Builder setName(
384 | java.lang.String value) {
385 | if (value == null) {
386 | throw new NullPointerException();
387 | }
388 |
389 | name_ = value;
390 | onChanged();
391 | return this;
392 | }
393 | /**
394 | * optional string name = 1;
395 | */
396 | public Builder clearName() {
397 |
398 | name_ = getDefaultInstance().getName();
399 | onChanged();
400 | return this;
401 | }
402 | /**
403 | * optional string name = 1;
404 | */
405 | public Builder setNameBytes(
406 | com.google.protobuf.ByteString value) {
407 | if (value == null) {
408 | throw new NullPointerException();
409 | }
410 |
411 | name_ = value;
412 | onChanged();
413 | return this;
414 | }
415 | public final Builder setUnknownFields(
416 | final com.google.protobuf.UnknownFieldSet unknownFields) {
417 | return this;
418 | }
419 |
420 | public final Builder mergeUnknownFields(
421 | final com.google.protobuf.UnknownFieldSet unknownFields) {
422 | return this;
423 | }
424 |
425 |
426 | // @@protoc_insertion_point(builder_scope:greeter.HelloRequest)
427 | }
428 |
429 | // @@protoc_insertion_point(class_scope:greeter.HelloRequest)
430 | private static final com.colobu.rpctest.GreeterOuterClass.HelloRequest DEFAULT_INSTANCE;
431 | static {
432 | DEFAULT_INSTANCE = new com.colobu.rpctest.GreeterOuterClass.HelloRequest();
433 | }
434 |
435 | public static com.colobu.rpctest.GreeterOuterClass.HelloRequest getDefaultInstance() {
436 | return DEFAULT_INSTANCE;
437 | }
438 |
439 | public static final com.google.protobuf.Parser PARSER =
440 | new com.google.protobuf.AbstractParser() {
441 | public HelloRequest parsePartialFrom(
442 | com.google.protobuf.CodedInputStream input,
443 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
444 | throws com.google.protobuf.InvalidProtocolBufferException {
445 | try {
446 | return new HelloRequest(input, extensionRegistry);
447 | } catch (RuntimeException e) {
448 | if (e.getCause() instanceof
449 | com.google.protobuf.InvalidProtocolBufferException) {
450 | throw (com.google.protobuf.InvalidProtocolBufferException)
451 | e.getCause();
452 | }
453 | throw e;
454 | }
455 | }
456 | };
457 |
458 | public static com.google.protobuf.Parser parser() {
459 | return PARSER;
460 | }
461 |
462 | @java.lang.Override
463 | public com.google.protobuf.Parser getParserForType() {
464 | return PARSER;
465 | }
466 |
467 | public com.colobu.rpctest.GreeterOuterClass.HelloRequest getDefaultInstanceForType() {
468 | return DEFAULT_INSTANCE;
469 | }
470 |
471 | }
472 |
473 | public interface HelloReplyOrBuilder extends
474 | // @@protoc_insertion_point(interface_extends:greeter.HelloReply)
475 | com.google.protobuf.MessageOrBuilder {
476 |
477 | /**
478 | * optional string message = 1;
479 | */
480 | java.lang.String getMessage();
481 | /**
482 | * optional string message = 1;
483 | */
484 | com.google.protobuf.ByteString
485 | getMessageBytes();
486 | }
487 | /**
488 | * Protobuf type {@code greeter.HelloReply}
489 | *
490 | *
491 | * The response message containing the greetings
492 | *
493 | */
494 | public static final class HelloReply extends
495 | com.google.protobuf.GeneratedMessage implements
496 | // @@protoc_insertion_point(message_implements:greeter.HelloReply)
497 | HelloReplyOrBuilder {
498 | // Use HelloReply.newBuilder() to construct.
499 | private HelloReply(com.google.protobuf.GeneratedMessage.Builder builder) {
500 | super(builder);
501 | }
502 | private HelloReply() {
503 | message_ = "";
504 | }
505 |
506 | @java.lang.Override
507 | public final com.google.protobuf.UnknownFieldSet
508 | getUnknownFields() {
509 | return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
510 | }
511 | private HelloReply(
512 | com.google.protobuf.CodedInputStream input,
513 | com.google.protobuf.ExtensionRegistryLite extensionRegistry) {
514 | this();
515 | int mutable_bitField0_ = 0;
516 | try {
517 | boolean done = false;
518 | while (!done) {
519 | int tag = input.readTag();
520 | switch (tag) {
521 | case 0:
522 | done = true;
523 | break;
524 | default: {
525 | if (!input.skipField(tag)) {
526 | done = true;
527 | }
528 | break;
529 | }
530 | case 10: {
531 | com.google.protobuf.ByteString bs = input.readBytes();
532 |
533 | message_ = bs;
534 | break;
535 | }
536 | }
537 | }
538 | } catch (com.google.protobuf.InvalidProtocolBufferException e) {
539 | throw new RuntimeException(e.setUnfinishedMessage(this));
540 | } catch (java.io.IOException e) {
541 | throw new RuntimeException(
542 | new com.google.protobuf.InvalidProtocolBufferException(
543 | e.getMessage()).setUnfinishedMessage(this));
544 | } finally {
545 | makeExtensionsImmutable();
546 | }
547 | }
548 | public static final com.google.protobuf.Descriptors.Descriptor
549 | getDescriptor() {
550 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloReply_descriptor;
551 | }
552 |
553 | protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
554 | internalGetFieldAccessorTable() {
555 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloReply_fieldAccessorTable
556 | .ensureFieldAccessorsInitialized(
557 | com.colobu.rpctest.GreeterOuterClass.HelloReply.class, com.colobu.rpctest.GreeterOuterClass.HelloReply.Builder.class);
558 | }
559 |
560 | public static final int MESSAGE_FIELD_NUMBER = 1;
561 | private volatile java.lang.Object message_;
562 | /**
563 | * optional string message = 1;
564 | */
565 | public java.lang.String getMessage() {
566 | java.lang.Object ref = message_;
567 | if (ref instanceof java.lang.String) {
568 | return (java.lang.String) ref;
569 | } else {
570 | com.google.protobuf.ByteString bs =
571 | (com.google.protobuf.ByteString) ref;
572 | java.lang.String s = bs.toStringUtf8();
573 | if (bs.isValidUtf8()) {
574 | message_ = s;
575 | }
576 | return s;
577 | }
578 | }
579 | /**
580 | * optional string message = 1;
581 | */
582 | public com.google.protobuf.ByteString
583 | getMessageBytes() {
584 | java.lang.Object ref = message_;
585 | if (ref instanceof java.lang.String) {
586 | com.google.protobuf.ByteString b =
587 | com.google.protobuf.ByteString.copyFromUtf8(
588 | (java.lang.String) ref);
589 | message_ = b;
590 | return b;
591 | } else {
592 | return (com.google.protobuf.ByteString) ref;
593 | }
594 | }
595 |
596 | private byte memoizedIsInitialized = -1;
597 | public final boolean isInitialized() {
598 | byte isInitialized = memoizedIsInitialized;
599 | if (isInitialized == 1) return true;
600 | if (isInitialized == 0) return false;
601 |
602 | memoizedIsInitialized = 1;
603 | return true;
604 | }
605 |
606 | public void writeTo(com.google.protobuf.CodedOutputStream output)
607 | throws java.io.IOException {
608 | if (!getMessageBytes().isEmpty()) {
609 | output.writeBytes(1, getMessageBytes());
610 | }
611 | }
612 |
613 | private int memoizedSerializedSize = -1;
614 | public int getSerializedSize() {
615 | int size = memoizedSerializedSize;
616 | if (size != -1) return size;
617 |
618 | size = 0;
619 | if (!getMessageBytes().isEmpty()) {
620 | size += com.google.protobuf.CodedOutputStream
621 | .computeBytesSize(1, getMessageBytes());
622 | }
623 | memoizedSerializedSize = size;
624 | return size;
625 | }
626 |
627 | private static final long serialVersionUID = 0L;
628 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseFrom(
629 | com.google.protobuf.ByteString data)
630 | throws com.google.protobuf.InvalidProtocolBufferException {
631 | return PARSER.parseFrom(data);
632 | }
633 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseFrom(
634 | com.google.protobuf.ByteString data,
635 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
636 | throws com.google.protobuf.InvalidProtocolBufferException {
637 | return PARSER.parseFrom(data, extensionRegistry);
638 | }
639 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseFrom(byte[] data)
640 | throws com.google.protobuf.InvalidProtocolBufferException {
641 | return PARSER.parseFrom(data);
642 | }
643 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseFrom(
644 | byte[] data,
645 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
646 | throws com.google.protobuf.InvalidProtocolBufferException {
647 | return PARSER.parseFrom(data, extensionRegistry);
648 | }
649 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseFrom(java.io.InputStream input)
650 | throws java.io.IOException {
651 | return PARSER.parseFrom(input);
652 | }
653 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseFrom(
654 | java.io.InputStream input,
655 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
656 | throws java.io.IOException {
657 | return PARSER.parseFrom(input, extensionRegistry);
658 | }
659 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseDelimitedFrom(java.io.InputStream input)
660 | throws java.io.IOException {
661 | return PARSER.parseDelimitedFrom(input);
662 | }
663 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseDelimitedFrom(
664 | java.io.InputStream input,
665 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
666 | throws java.io.IOException {
667 | return PARSER.parseDelimitedFrom(input, extensionRegistry);
668 | }
669 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseFrom(
670 | com.google.protobuf.CodedInputStream input)
671 | throws java.io.IOException {
672 | return PARSER.parseFrom(input);
673 | }
674 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply parseFrom(
675 | com.google.protobuf.CodedInputStream input,
676 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
677 | throws java.io.IOException {
678 | return PARSER.parseFrom(input, extensionRegistry);
679 | }
680 |
681 | public Builder newBuilderForType() { return newBuilder(); }
682 | public static Builder newBuilder() {
683 | return DEFAULT_INSTANCE.toBuilder();
684 | }
685 | public static Builder newBuilder(com.colobu.rpctest.GreeterOuterClass.HelloReply prototype) {
686 | return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
687 | }
688 | public Builder toBuilder() {
689 | return this == DEFAULT_INSTANCE
690 | ? new Builder() : new Builder().mergeFrom(this);
691 | }
692 |
693 | @java.lang.Override
694 | protected Builder newBuilderForType(
695 | com.google.protobuf.GeneratedMessage.BuilderParent parent) {
696 | Builder builder = new Builder(parent);
697 | return builder;
698 | }
699 | /**
700 | * Protobuf type {@code greeter.HelloReply}
701 | *
702 | *
703 | * The response message containing the greetings
704 | *
705 | */
706 | public static final class Builder extends
707 | com.google.protobuf.GeneratedMessage.Builder implements
708 | // @@protoc_insertion_point(builder_implements:greeter.HelloReply)
709 | com.colobu.rpctest.GreeterOuterClass.HelloReplyOrBuilder {
710 | public static final com.google.protobuf.Descriptors.Descriptor
711 | getDescriptor() {
712 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloReply_descriptor;
713 | }
714 |
715 | protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
716 | internalGetFieldAccessorTable() {
717 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloReply_fieldAccessorTable
718 | .ensureFieldAccessorsInitialized(
719 | com.colobu.rpctest.GreeterOuterClass.HelloReply.class, com.colobu.rpctest.GreeterOuterClass.HelloReply.Builder.class);
720 | }
721 |
722 | // Construct using com.colobu.rpctest.GreeterOuterClass.HelloReply.newBuilder()
723 | private Builder() {
724 | maybeForceBuilderInitialization();
725 | }
726 |
727 | private Builder(
728 | com.google.protobuf.GeneratedMessage.BuilderParent parent) {
729 | super(parent);
730 | maybeForceBuilderInitialization();
731 | }
732 | private void maybeForceBuilderInitialization() {
733 | if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
734 | }
735 | }
736 | public Builder clear() {
737 | super.clear();
738 | message_ = "";
739 |
740 | return this;
741 | }
742 |
743 | public com.google.protobuf.Descriptors.Descriptor
744 | getDescriptorForType() {
745 | return com.colobu.rpctest.GreeterOuterClass.internal_static_greeter_HelloReply_descriptor;
746 | }
747 |
748 | public com.colobu.rpctest.GreeterOuterClass.HelloReply getDefaultInstanceForType() {
749 | return com.colobu.rpctest.GreeterOuterClass.HelloReply.getDefaultInstance();
750 | }
751 |
752 | public com.colobu.rpctest.GreeterOuterClass.HelloReply build() {
753 | com.colobu.rpctest.GreeterOuterClass.HelloReply result = buildPartial();
754 | if (!result.isInitialized()) {
755 | throw newUninitializedMessageException(result);
756 | }
757 | return result;
758 | }
759 |
760 | public com.colobu.rpctest.GreeterOuterClass.HelloReply buildPartial() {
761 | com.colobu.rpctest.GreeterOuterClass.HelloReply result = new com.colobu.rpctest.GreeterOuterClass.HelloReply(this);
762 | result.message_ = message_;
763 | onBuilt();
764 | return result;
765 | }
766 |
767 | public Builder mergeFrom(com.google.protobuf.Message other) {
768 | if (other instanceof com.colobu.rpctest.GreeterOuterClass.HelloReply) {
769 | return mergeFrom((com.colobu.rpctest.GreeterOuterClass.HelloReply)other);
770 | } else {
771 | super.mergeFrom(other);
772 | return this;
773 | }
774 | }
775 |
776 | public Builder mergeFrom(com.colobu.rpctest.GreeterOuterClass.HelloReply other) {
777 | if (other == com.colobu.rpctest.GreeterOuterClass.HelloReply.getDefaultInstance()) return this;
778 | if (!other.getMessage().isEmpty()) {
779 | message_ = other.message_;
780 | onChanged();
781 | }
782 | onChanged();
783 | return this;
784 | }
785 |
786 | public final boolean isInitialized() {
787 | return true;
788 | }
789 |
790 | public Builder mergeFrom(
791 | com.google.protobuf.CodedInputStream input,
792 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
793 | throws java.io.IOException {
794 | com.colobu.rpctest.GreeterOuterClass.HelloReply parsedMessage = null;
795 | try {
796 | parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
797 | } catch (com.google.protobuf.InvalidProtocolBufferException e) {
798 | parsedMessage = (com.colobu.rpctest.GreeterOuterClass.HelloReply) e.getUnfinishedMessage();
799 | throw e;
800 | } finally {
801 | if (parsedMessage != null) {
802 | mergeFrom(parsedMessage);
803 | }
804 | }
805 | return this;
806 | }
807 |
808 | private java.lang.Object message_ = "";
809 | /**
810 | * optional string message = 1;
811 | */
812 | public java.lang.String getMessage() {
813 | java.lang.Object ref = message_;
814 | if (!(ref instanceof java.lang.String)) {
815 | com.google.protobuf.ByteString bs =
816 | (com.google.protobuf.ByteString) ref;
817 | java.lang.String s = bs.toStringUtf8();
818 | if (bs.isValidUtf8()) {
819 | message_ = s;
820 | }
821 | return s;
822 | } else {
823 | return (java.lang.String) ref;
824 | }
825 | }
826 | /**
827 | * optional string message = 1;
828 | */
829 | public com.google.protobuf.ByteString
830 | getMessageBytes() {
831 | java.lang.Object ref = message_;
832 | if (ref instanceof String) {
833 | com.google.protobuf.ByteString b =
834 | com.google.protobuf.ByteString.copyFromUtf8(
835 | (java.lang.String) ref);
836 | message_ = b;
837 | return b;
838 | } else {
839 | return (com.google.protobuf.ByteString) ref;
840 | }
841 | }
842 | /**
843 | * optional string message = 1;
844 | */
845 | public Builder setMessage(
846 | java.lang.String value) {
847 | if (value == null) {
848 | throw new NullPointerException();
849 | }
850 |
851 | message_ = value;
852 | onChanged();
853 | return this;
854 | }
855 | /**
856 | * optional string message = 1;
857 | */
858 | public Builder clearMessage() {
859 |
860 | message_ = getDefaultInstance().getMessage();
861 | onChanged();
862 | return this;
863 | }
864 | /**
865 | * optional string message = 1;
866 | */
867 | public Builder setMessageBytes(
868 | com.google.protobuf.ByteString value) {
869 | if (value == null) {
870 | throw new NullPointerException();
871 | }
872 |
873 | message_ = value;
874 | onChanged();
875 | return this;
876 | }
877 | public final Builder setUnknownFields(
878 | final com.google.protobuf.UnknownFieldSet unknownFields) {
879 | return this;
880 | }
881 |
882 | public final Builder mergeUnknownFields(
883 | final com.google.protobuf.UnknownFieldSet unknownFields) {
884 | return this;
885 | }
886 |
887 |
888 | // @@protoc_insertion_point(builder_scope:greeter.HelloReply)
889 | }
890 |
891 | // @@protoc_insertion_point(class_scope:greeter.HelloReply)
892 | private static final com.colobu.rpctest.GreeterOuterClass.HelloReply DEFAULT_INSTANCE;
893 | static {
894 | DEFAULT_INSTANCE = new com.colobu.rpctest.GreeterOuterClass.HelloReply();
895 | }
896 |
897 | public static com.colobu.rpctest.GreeterOuterClass.HelloReply getDefaultInstance() {
898 | return DEFAULT_INSTANCE;
899 | }
900 |
901 | public static final com.google.protobuf.Parser PARSER =
902 | new com.google.protobuf.AbstractParser() {
903 | public HelloReply parsePartialFrom(
904 | com.google.protobuf.CodedInputStream input,
905 | com.google.protobuf.ExtensionRegistryLite extensionRegistry)
906 | throws com.google.protobuf.InvalidProtocolBufferException {
907 | try {
908 | return new HelloReply(input, extensionRegistry);
909 | } catch (RuntimeException e) {
910 | if (e.getCause() instanceof
911 | com.google.protobuf.InvalidProtocolBufferException) {
912 | throw (com.google.protobuf.InvalidProtocolBufferException)
913 | e.getCause();
914 | }
915 | throw e;
916 | }
917 | }
918 | };
919 |
920 | public static com.google.protobuf.Parser parser() {
921 | return PARSER;
922 | }
923 |
924 | @java.lang.Override
925 | public com.google.protobuf.Parser getParserForType() {
926 | return PARSER;
927 | }
928 |
929 | public com.colobu.rpctest.GreeterOuterClass.HelloReply getDefaultInstanceForType() {
930 | return DEFAULT_INSTANCE;
931 | }
932 |
933 | }
934 |
935 | private static com.google.protobuf.Descriptors.Descriptor
936 | internal_static_greeter_HelloRequest_descriptor;
937 | private static
938 | com.google.protobuf.GeneratedMessage.FieldAccessorTable
939 | internal_static_greeter_HelloRequest_fieldAccessorTable;
940 | private static com.google.protobuf.Descriptors.Descriptor
941 | internal_static_greeter_HelloReply_descriptor;
942 | private static
943 | com.google.protobuf.GeneratedMessage.FieldAccessorTable
944 | internal_static_greeter_HelloReply_fieldAccessorTable;
945 |
946 | public static com.google.protobuf.Descriptors.FileDescriptor
947 | getDescriptor() {
948 | return descriptor;
949 | }
950 | private static com.google.protobuf.Descriptors.FileDescriptor
951 | descriptor;
952 | static {
953 | java.lang.String[] descriptorData = {
954 | "\n\rgreeter.proto\022\007greeter\"\034\n\014HelloRequest" +
955 | "\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n\007message\030" +
956 | "\001 \001(\t2C\n\007Greeter\0228\n\010SayHello\022\025.greeter.H" +
957 | "elloRequest\032\023.greeter.HelloReply\"\000B\024\n\022co" +
958 | "m.colobu.rpctestb\006proto3"
959 | };
960 | com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
961 | new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
962 | public com.google.protobuf.ExtensionRegistry assignDescriptors(
963 | com.google.protobuf.Descriptors.FileDescriptor root) {
964 | descriptor = root;
965 | return null;
966 | }
967 | };
968 | com.google.protobuf.Descriptors.FileDescriptor
969 | .internalBuildGeneratedFileFrom(descriptorData,
970 | new com.google.protobuf.Descriptors.FileDescriptor[] {
971 | }, assigner);
972 | internal_static_greeter_HelloRequest_descriptor =
973 | getDescriptor().getMessageTypes().get(0);
974 | internal_static_greeter_HelloRequest_fieldAccessorTable = new
975 | com.google.protobuf.GeneratedMessage.FieldAccessorTable(
976 | internal_static_greeter_HelloRequest_descriptor,
977 | new java.lang.String[] { "Name", });
978 | internal_static_greeter_HelloReply_descriptor =
979 | getDescriptor().getMessageTypes().get(1);
980 | internal_static_greeter_HelloReply_fieldAccessorTable = new
981 | com.google.protobuf.GeneratedMessage.FieldAccessorTable(
982 | internal_static_greeter_HelloReply_descriptor,
983 | new java.lang.String[] { "Message", });
984 | }
985 |
986 | // @@protoc_insertion_point(outer_class_scope)
987 | }
988 |
--------------------------------------------------------------------------------
/gRPC/scala/src/templates/bash-template:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ### ------------------------------- ###
4 | ### Helper methods for BASH scripts ###
5 | ### ------------------------------- ###
6 |
7 | die() {
8 | echo "$@" 1>&2
9 | exit 1
10 | }
11 |
12 | realpath () {
13 | (
14 | TARGET_FILE="$1"
15 | CHECK_CYGWIN="$2"
16 |
17 | cd "$(dirname "$TARGET_FILE")"
18 | TARGET_FILE=$(basename "$TARGET_FILE")
19 |
20 | COUNT=0
21 | while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
22 | do
23 | TARGET_FILE=$(readlink "$TARGET_FILE")
24 | cd "$(dirname "$TARGET_FILE")"
25 | TARGET_FILE=$(basename "$TARGET_FILE")
26 | COUNT=$(($COUNT + 1))
27 | done
28 |
29 | if [ "$TARGET_FILE" == "." -o "$TARGET_FILE" == ".." ]; then
30 | cd "$TARGET_FILE"
31 | TARGET_FILEPATH=
32 | else
33 | TARGET_FILEPATH=/$TARGET_FILE
34 | fi
35 |
36 | # make sure we grab the actual windows path, instead of cygwin's path.
37 | if [[ "x$CHECK_CYGWIN" == "x" ]]; then
38 | echo "$(pwd -P)/$TARGET_FILE"
39 | else
40 | echo $(cygwinpath "$(pwd -P)/$TARGET_FILE")
41 | fi
42 | )
43 | }
44 |
45 | # TODO - Do we need to detect msys?
46 |
47 | # Uses uname to detect if we're in the odd cygwin environment.
48 | is_cygwin() {
49 | local os=$(uname -s)
50 | case "$os" in
51 | CYGWIN*) return 0 ;;
52 | *) return 1 ;;
53 | esac
54 | }
55 |
56 | # This can fix cygwin style /cygdrive paths so we get the
57 | # windows style paths.
58 | cygwinpath() {
59 | local file="$1"
60 | if is_cygwin; then
61 | echo $(cygpath -w $file)
62 | else
63 | echo $file
64 | fi
65 | }
66 |
67 | # Make something URI friendly
68 | make_url() {
69 | url="$1"
70 | local nospaces=${url// /%20}
71 | if is_cygwin; then
72 | echo "/${nospaces//\\//}"
73 | else
74 | echo "$nospaces"
75 | fi
76 | }
77 |
78 | # This crazy function reads in a vanilla "linux" classpath string (only : are separators, and all /),
79 | # and returns a classpath with windows style paths, and ; separators.
80 | fixCygwinClasspath() {
81 | OLDIFS=$IFS
82 | IFS=":"
83 | read -a classpath_members <<< "$1"
84 | declare -a fixed_members
85 | IFS=$OLDIFS
86 | for i in "${!classpath_members[@]}"
87 | do
88 | fixed_members[i]=$(realpath "${classpath_members[i]}" "fix")
89 | done
90 | IFS=";"
91 | echo "${fixed_members[*]}"
92 | IFS=$OLDIFS
93 | }
94 |
95 | # Fix the classpath we use for cygwin.
96 | fix_classpath() {
97 | cp="$1"
98 | if is_cygwin; then
99 | echo "$(fixCygwinClasspath "$cp;$app_conf")"
100 | else
101 | echo "$cp:$app_conf"
102 | fi
103 | }
104 | # Detect if we should use JAVA_HOME or just try PATH.
105 | get_java_cmd() {
106 | if [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
107 | echo "$JAVA_HOME/bin/java"
108 | else
109 | echo "java"
110 | fi
111 | }
112 |
113 | echoerr () {
114 | echo 1>&2 "$@"
115 | }
116 | vlog () {
117 | [[ $verbose || $debug ]] && echoerr "$@"
118 | }
119 | dlog () {
120 | [[ $debug ]] && echoerr "$@"
121 | }
122 | execRunner () {
123 | # print the arguments one to a line, quoting any containing spaces
124 | [[ $verbose || $debug ]] && echo "# Executing command line:" && {
125 | for arg; do
126 | if printf "%s\n" "$arg" | grep -q ' '; then
127 | printf "\"%s\"\n" "$arg"
128 | else
129 | printf "%s\n" "$arg"
130 | fi
131 | done
132 | echo ""
133 | }
134 |
135 | # we use "exec" here for our pids to be accurate.
136 | exec "$@"
137 | }
138 | addJava () {
139 | dlog "[addJava] arg = '$1'"
140 | java_args+=( "$1" )
141 | }
142 | addApp () {
143 | dlog "[addApp] arg = '$1'"
144 | app_commands+=( "$1" )
145 | }
146 | addResidual () {
147 | dlog "[residual] arg = '$1'"
148 | residual_args+=( "$1" )
149 | }
150 | addDebugger () {
151 | addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1"
152 | }
153 |
154 | require_arg () {
155 | local type="$1"
156 | local opt="$2"
157 | local arg="$3"
158 | if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then
159 | die "$opt requires <$type> argument"
160 | fi
161 | }
162 | is_function_defined() {
163 | declare -f "$1" > /dev/null
164 | }
165 |
166 | # Attempt to detect if the script is running via a GUI or not
167 | # TODO - Determine where/how we use this generically
168 | detect_terminal_for_ui() {
169 | [[ ! -t 0 ]] && [[ "${#residual_args}" == "0" ]] && {
170 | echo "true"
171 | }
172 | # SPECIAL TEST FOR MAC
173 | [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]] && [[ "${#residual_args}" == "0" ]] && {
174 | echo "true"
175 | }
176 | }
177 |
178 | # Processes incoming arguments and places them in appropriate global variables. called by the run method.
179 | process_args () {
180 | local no_more_snp_opts=0
181 | while [[ $# -gt 0 ]]; do
182 | case "$1" in
183 | --) shift && no_more_snp_opts=1 && break ;;
184 | -h|-help) usage; exit 1 ;;
185 | -v|-verbose) verbose=1 && shift ;;
186 | -d|-debug) debug=1 && shift ;;
187 |
188 | -no-version-check) no_version_check=1 && shift ;;
189 |
190 | -mem) echo "!! WARNING !! -mem option is ignored. Please use -J-Xmx and -J-Xms" && shift 2 ;;
191 | -jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
192 |
193 | -main) custom_mainclass="$2" && shift 2 ;;
194 |
195 | -java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;;
196 |
197 | -D*|-agentlib*) addJava "$1" && shift ;;
198 | -J*) addJava "${1:2}" && shift ;;
199 | *) addResidual "$1" && shift ;;
200 | esac
201 | done
202 |
203 | if [[ no_more_snp_opts ]]; then
204 | while [[ $# -gt 0 ]]; do
205 | addResidual "$1" && shift
206 | done
207 | fi
208 |
209 | is_function_defined process_my_args && {
210 | myargs=("${residual_args[@]}")
211 | residual_args=()
212 | process_my_args "${myargs[@]}"
213 | }
214 | }
215 |
216 | # Actually runs the script.
217 | run() {
218 | # TODO - check for sane environment
219 |
220 | # process the combined args, then reset "$@" to the residuals
221 | process_args "$@"
222 | set -- "${residual_args[@]}"
223 | argumentCount=$#
224 |
225 | #check for jline terminal fixes on cygwin
226 | if is_cygwin; then
227 | stty -icanon min 1 -echo > /dev/null 2>&1
228 | addJava "-Djline.terminal=jline.UnixTerminal"
229 | addJava "-Dsbt.cygwin=true"
230 | fi
231 |
232 | # check java version
233 | if [[ ! $no_version_check ]]; then
234 | java_version_check
235 | fi
236 |
237 | if [ -n "$custom_mainclass" ]; then
238 | mainclass="$custom_mainclass"
239 | else
240 | mainclass="$app_mainclass"
241 | fi
242 |
243 | # Now we check to see if there are any java opts on the environment. These get listed first, with the script able to override them.
244 | if [[ "$JAVA_OPTS" != "" ]]; then
245 | java_opts="${JAVA_OPTS}"
246 | fi
247 |
248 | # run sbt
249 | execRunner "$java_cmd" \
250 | ${java_opts[@]} \
251 | "${java_args[@]}" \
252 | -cp "$(fix_classpath "$app_classpath")" \
253 | $mainclass \
254 | "${app_commands[@]}" \
255 | "${residual_args[@]}"
256 |
257 | local exit_code=$?
258 | if is_cygwin; then
259 | stty icanon echo > /dev/null 2>&1
260 | fi
261 | exit $exit_code
262 | }
263 |
264 | # Loads a configuration file full of default command line options for this script.
265 | loadConfigFile() {
266 | cat "$1" | sed '/^\#/d'
267 | }
268 |
269 | # Now check to see if it's a good enough version
270 | # TODO - Check to see if we have a configured default java version, otherwise use 1.6
271 | java_version_check() {
272 | readonly java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}')
273 | if [[ "$java_version" == "" ]]; then
274 | echo
275 | echo No java installations was detected.
276 | echo Please go to http://www.java.com/getjava/ and download
277 | echo
278 | exit 1
279 | elif [[ ! "$java_version" > "1.6" ]]; then
280 | echo
281 | echo The java installation you have is not up to date
282 | echo $app_name requires at least version 1.6+, you have
283 | echo version $java_version
284 | echo
285 | echo Please go to http://www.java.com/getjava/ and download
286 | echo a valid Java Runtime and install before running $app_name.
287 | echo
288 | exit 1
289 | fi
290 | }
291 |
292 | ### ------------------------------- ###
293 | ### Start of customized settings ###
294 | ### ------------------------------- ###
295 | usage() {
296 | cat < Define a custom main class
304 | -jvm-debug Turn on JVM debugging, open at the given port.
305 |
306 | # java version (default: java from PATH, currently $(java -version 2>&1 | grep version))
307 | -java-home alternate JAVA_HOME
308 |
309 | # jvm options and output control
310 | JAVA_OPTS environment variable, if unset uses "$java_opts"
311 | -Dkey=val pass -Dkey=val directly to the java runtime
312 | -J-X pass option -X directly to the java runtime
313 | (-J is stripped)
314 |
315 | # special option
316 | -- To stop parsing built-in commands from the rest of the command-line.
317 | e.g.) enabling debug and sending -d as app argument
318 | \$ ./start-script -d -- -d
319 |
320 | In the case of duplicated or conflicting options, basically the order above
321 | shows precedence: JAVA_OPTS lowest, command line options highest except "--".
322 | EOM
323 | }
324 |
325 | ### ------------------------------- ###
326 | ### Main script ###
327 | ### ------------------------------- ###
328 |
329 | declare -a residual_args
330 | declare -a java_args
331 | declare -a app_commands
332 | declare -r real_script_path="$(realpath "$0")"
333 | declare -r app_home="$(realpath "$(dirname "$real_script_path")")"
334 | declare -r app_conf="$(realpath "${app_home}/../conf")"
335 | # TODO - Check whether this is ok in cygwin...
336 | declare -r lib_dir="$(realpath "${app_home}/../lib")"
337 | ${{template_declares}}
338 | # java_cmd is overrode in process_args when -java-home is used
339 | declare java_cmd=$(get_java_cmd)
340 |
341 | [ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xms12G -Xmx12G -Xss1M -XX:+UseParallelGC -Xloggc:gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps "
342 |
343 | if [ -n "$APP_CONFIG" ]; then
344 | JAVA_OPTS="$JAVA_OPTS -Dconfig.file=$APP_CONFIG"
345 | fi
346 | if [ -n "$LOGBACK_CONFIG" ]; then
347 | JAVA_OPTS="$JAVA_OPTS -Dlogback.configurationFile=$LOGBACK_CONFIG"
348 | fi
349 |
350 | # if configuration files exist, prepend their contents to $@ so it can be processed by this runner
351 | [[ -f "$script_conf_file" ]] && set -- $(loadConfigFile "$script_conf_file") "$@"
352 |
353 | run "$@"
354 |
--------------------------------------------------------------------------------
/gRPC/scala/src/universal/conf/application.conf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smallnest/RPC-TEST/eace9e69b2d12d1c244402ad0740611feebd11ff/gRPC/scala/src/universal/conf/application.conf
--------------------------------------------------------------------------------
/thrift/golang/.gitignore:
--------------------------------------------------------------------------------
1 | bin/
2 | pkg/
3 |
--------------------------------------------------------------------------------
/thrift/golang/gen.sh:
--------------------------------------------------------------------------------
1 | #go get github.com/golang/protobuf/protoc-gen-go
2 | #go get github.com/golang/protobuf/proto
3 | #go get golang.org/x/net/context
4 | #go get google.golang.org/grpc
5 |
6 | thrift-0.9.2.exe -r --gen go -out src thrift/helloworld.thrift
--------------------------------------------------------------------------------
/thrift/golang/src/client/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "os"
5 | "fmt"
6 | "time"
7 | "strconv"
8 | "sync"
9 |
10 | "greeter"
11 |
12 | "git.apache.org/thrift.git/lib/go/thrift"
13 |
14 | )
15 |
16 | const (
17 | address = "localhost:9090"
18 | defaultName = "world"
19 | )
20 |
21 | func syncTest(client *greeter.GreeterClient, name string) {
22 | i := 10000
23 | t := time.Now().UnixNano()
24 | for ; i>0; i-- {
25 | client.SayHello(name)
26 | }
27 | fmt.Println("took", (time.Now().UnixNano() - t) / 1000000, "ms")
28 | }
29 |
30 | func asyncTest(client [20]*greeter.GreeterClient, name string) {
31 | var locks [20]sync.Mutex
32 | var wg sync.WaitGroup
33 | wg.Add(10000)
34 |
35 | i := 10000
36 | t := time.Now().UnixNano()
37 | for ; i>0; i-- {
38 | go func(index int) {
39 | locks[index % 20].Lock()
40 | client[ index % 20].SayHello(name)
41 | wg.Done()
42 | locks[index % 20].Unlock()
43 | }(i)
44 | }
45 | wg.Wait()
46 | fmt.Println("took", (time.Now().UnixNano() - t) / 1000000, "ms")
47 | }
48 |
49 |
50 | func main() {
51 | transportFactory := thrift.NewTBufferedTransportFactory(8192)
52 | protocolFactory := thrift.NewTBinaryProtocolFactoryDefault()
53 |
54 | var client [20]*greeter.GreeterClient
55 |
56 | //warm up
57 | for i := 0; i < 20; i++ {
58 | transport, err := thrift.NewTSocket(address)
59 | if err != nil {
60 | fmt.Fprintln(os.Stderr, "error resolving address:", err)
61 | os.Exit(1)
62 | }
63 | useTransport := transportFactory.GetTransport(transport)
64 | defer transport.Close()
65 |
66 | if err := transport.Open(); err != nil {
67 | fmt.Fprintln(os.Stderr, "Error opening socket to localhost:9090", " ", err)
68 | os.Exit(1)
69 | }
70 |
71 | client[i] = greeter.NewGreeterClientFactory(useTransport, protocolFactory)
72 | client[i].SayHello(defaultName)
73 | }
74 |
75 | sync := true
76 | if len(os.Args) > 1 {
77 | sync, _ = strconv.ParseBool(os.Args[1])
78 | }
79 |
80 | if sync {
81 | syncTest(client[0], defaultName)
82 | } else {
83 | asyncTest(client, defaultName)
84 | }
85 | }
--------------------------------------------------------------------------------
/thrift/golang/src/greeter/constants.go:
--------------------------------------------------------------------------------
1 | // Autogenerated by Thrift Compiler (0.9.2)
2 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
3 |
4 | package greeter
5 |
6 | import (
7 | "bytes"
8 | "fmt"
9 | "git.apache.org/thrift.git/lib/go/thrift"
10 | )
11 |
12 | // (needed to ensure safety because of naive import list construction.)
13 | var _ = thrift.ZERO
14 | var _ = fmt.Printf
15 | var _ = bytes.Equal
16 |
17 | func init() {
18 | }
19 |
--------------------------------------------------------------------------------
/thrift/golang/src/greeter/greeter-remote/greeter-remote.go:
--------------------------------------------------------------------------------
1 | // Autogenerated by Thrift Compiler (0.9.2)
2 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
3 |
4 | package main
5 |
6 | import (
7 | "flag"
8 | "fmt"
9 | "git.apache.org/thrift.git/lib/go/thrift"
10 | "greeter"
11 | "math"
12 | "net"
13 | "net/url"
14 | "os"
15 | "strconv"
16 | "strings"
17 | )
18 |
19 | func Usage() {
20 | fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:")
21 | flag.PrintDefaults()
22 | fmt.Fprintln(os.Stderr, "\nFunctions:")
23 | fmt.Fprintln(os.Stderr, " string sayHello(string name)")
24 | fmt.Fprintln(os.Stderr)
25 | os.Exit(0)
26 | }
27 |
28 | func main() {
29 | flag.Usage = Usage
30 | var host string
31 | var port int
32 | var protocol string
33 | var urlString string
34 | var framed bool
35 | var useHttp bool
36 | var parsedUrl url.URL
37 | var trans thrift.TTransport
38 | _ = strconv.Atoi
39 | _ = math.Abs
40 | flag.Usage = Usage
41 | flag.StringVar(&host, "h", "localhost", "Specify host and port")
42 | flag.IntVar(&port, "p", 9090, "Specify port")
43 | flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)")
44 | flag.StringVar(&urlString, "u", "", "Specify the url")
45 | flag.BoolVar(&framed, "framed", false, "Use framed transport")
46 | flag.BoolVar(&useHttp, "http", false, "Use http")
47 | flag.Parse()
48 |
49 | if len(urlString) > 0 {
50 | parsedUrl, err := url.Parse(urlString)
51 | if err != nil {
52 | fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
53 | flag.Usage()
54 | }
55 | host = parsedUrl.Host
56 | useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http"
57 | } else if useHttp {
58 | _, err := url.Parse(fmt.Sprint("http://", host, ":", port))
59 | if err != nil {
60 | fmt.Fprintln(os.Stderr, "Error parsing URL: ", err)
61 | flag.Usage()
62 | }
63 | }
64 |
65 | cmd := flag.Arg(0)
66 | var err error
67 | if useHttp {
68 | trans, err = thrift.NewTHttpClient(parsedUrl.String())
69 | } else {
70 | portStr := fmt.Sprint(port)
71 | if strings.Contains(host, ":") {
72 | host, portStr, err = net.SplitHostPort(host)
73 | if err != nil {
74 | fmt.Fprintln(os.Stderr, "error with host:", err)
75 | os.Exit(1)
76 | }
77 | }
78 | trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr))
79 | if err != nil {
80 | fmt.Fprintln(os.Stderr, "error resolving address:", err)
81 | os.Exit(1)
82 | }
83 | if framed {
84 | trans = thrift.NewTFramedTransport(trans)
85 | }
86 | }
87 | if err != nil {
88 | fmt.Fprintln(os.Stderr, "Error creating transport", err)
89 | os.Exit(1)
90 | }
91 | defer trans.Close()
92 | var protocolFactory thrift.TProtocolFactory
93 | switch protocol {
94 | case "compact":
95 | protocolFactory = thrift.NewTCompactProtocolFactory()
96 | break
97 | case "simplejson":
98 | protocolFactory = thrift.NewTSimpleJSONProtocolFactory()
99 | break
100 | case "json":
101 | protocolFactory = thrift.NewTJSONProtocolFactory()
102 | break
103 | case "binary", "":
104 | protocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
105 | break
106 | default:
107 | fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol)
108 | Usage()
109 | os.Exit(1)
110 | }
111 | client := greeter.NewGreeterClientFactory(trans, protocolFactory)
112 | if err := trans.Open(); err != nil {
113 | fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err)
114 | os.Exit(1)
115 | }
116 |
117 | switch cmd {
118 | case "sayHello":
119 | if flag.NArg()-1 != 1 {
120 | fmt.Fprintln(os.Stderr, "SayHello requires 1 args")
121 | flag.Usage()
122 | }
123 | argvalue0 := flag.Arg(1)
124 | value0 := argvalue0
125 | fmt.Print(client.SayHello(value0))
126 | fmt.Print("\n")
127 | break
128 | case "":
129 | Usage()
130 | break
131 | default:
132 | fmt.Fprintln(os.Stderr, "Invalid function ", cmd)
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/thrift/golang/src/greeter/greeter.go:
--------------------------------------------------------------------------------
1 | // Autogenerated by Thrift Compiler (0.9.2)
2 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
3 |
4 | package greeter
5 |
6 | import (
7 | "bytes"
8 | "fmt"
9 | "git.apache.org/thrift.git/lib/go/thrift"
10 | )
11 |
12 | // (needed to ensure safety because of naive import list construction.)
13 | var _ = thrift.ZERO
14 | var _ = fmt.Printf
15 | var _ = bytes.Equal
16 |
17 | type Greeter interface {
18 | // Parameters:
19 | // - Name
20 | SayHello(name string) (r string, err error)
21 | }
22 |
23 | type GreeterClient struct {
24 | Transport thrift.TTransport
25 | ProtocolFactory thrift.TProtocolFactory
26 | InputProtocol thrift.TProtocol
27 | OutputProtocol thrift.TProtocol
28 | SeqId int32
29 | }
30 |
31 | func NewGreeterClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *GreeterClient {
32 | return &GreeterClient{Transport: t,
33 | ProtocolFactory: f,
34 | InputProtocol: f.GetProtocol(t),
35 | OutputProtocol: f.GetProtocol(t),
36 | SeqId: 0,
37 | }
38 | }
39 |
40 | func NewGreeterClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *GreeterClient {
41 | return &GreeterClient{Transport: t,
42 | ProtocolFactory: nil,
43 | InputProtocol: iprot,
44 | OutputProtocol: oprot,
45 | SeqId: 0,
46 | }
47 | }
48 |
49 | // Parameters:
50 | // - Name
51 | func (p *GreeterClient) SayHello(name string) (r string, err error) {
52 | if err = p.sendSayHello(name); err != nil {
53 | return
54 | }
55 | return p.recvSayHello()
56 | }
57 |
58 | func (p *GreeterClient) sendSayHello(name string) (err error) {
59 | oprot := p.OutputProtocol
60 | if oprot == nil {
61 | oprot = p.ProtocolFactory.GetProtocol(p.Transport)
62 | p.OutputProtocol = oprot
63 | }
64 | p.SeqId++
65 | if err = oprot.WriteMessageBegin("sayHello", thrift.CALL, p.SeqId); err != nil {
66 | return
67 | }
68 | args := SayHelloArgs{
69 | Name: name,
70 | }
71 | if err = args.Write(oprot); err != nil {
72 | return
73 | }
74 | if err = oprot.WriteMessageEnd(); err != nil {
75 | return
76 | }
77 | return oprot.Flush()
78 | }
79 |
80 | func (p *GreeterClient) recvSayHello() (value string, err error) {
81 | iprot := p.InputProtocol
82 | if iprot == nil {
83 | iprot = p.ProtocolFactory.GetProtocol(p.Transport)
84 | p.InputProtocol = iprot
85 | }
86 | _, mTypeId, seqId, err := iprot.ReadMessageBegin()
87 | if err != nil {
88 | return
89 | }
90 | if mTypeId == thrift.EXCEPTION {
91 | error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception")
92 | var error1 error
93 | error1, err = error0.Read(iprot)
94 | if err != nil {
95 | return
96 | }
97 | if err = iprot.ReadMessageEnd(); err != nil {
98 | return
99 | }
100 | err = error1
101 | return
102 | }
103 | if p.SeqId != seqId {
104 | err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "sayHello failed: out of sequence response")
105 | return
106 | }
107 | result := SayHelloResult{}
108 | if err = result.Read(iprot); err != nil {
109 | return
110 | }
111 | if err = iprot.ReadMessageEnd(); err != nil {
112 | return
113 | }
114 | value = result.GetSuccess()
115 | return
116 | }
117 |
118 | type GreeterProcessor struct {
119 | processorMap map[string]thrift.TProcessorFunction
120 | handler Greeter
121 | }
122 |
123 | func (p *GreeterProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
124 | p.processorMap[key] = processor
125 | }
126 |
127 | func (p *GreeterProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
128 | processor, ok = p.processorMap[key]
129 | return processor, ok
130 | }
131 |
132 | func (p *GreeterProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
133 | return p.processorMap
134 | }
135 |
136 | func NewGreeterProcessor(handler Greeter) *GreeterProcessor {
137 |
138 | self2 := &GreeterProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
139 | self2.processorMap["sayHello"] = &greeterProcessorSayHello{handler: handler}
140 | return self2
141 | }
142 |
143 | func (p *GreeterProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
144 | name, _, seqId, err := iprot.ReadMessageBegin()
145 | if err != nil {
146 | return false, err
147 | }
148 | if processor, ok := p.GetProcessorFunction(name); ok {
149 | return processor.Process(seqId, iprot, oprot)
150 | }
151 | iprot.Skip(thrift.STRUCT)
152 | iprot.ReadMessageEnd()
153 | x3 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
154 | oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
155 | x3.Write(oprot)
156 | oprot.WriteMessageEnd()
157 | oprot.Flush()
158 | return false, x3
159 |
160 | }
161 |
162 | type greeterProcessorSayHello struct {
163 | handler Greeter
164 | }
165 |
166 | func (p *greeterProcessorSayHello) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
167 | args := SayHelloArgs{}
168 | if err = args.Read(iprot); err != nil {
169 | iprot.ReadMessageEnd()
170 | x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
171 | oprot.WriteMessageBegin("sayHello", thrift.EXCEPTION, seqId)
172 | x.Write(oprot)
173 | oprot.WriteMessageEnd()
174 | oprot.Flush()
175 | return false, err
176 | }
177 |
178 | iprot.ReadMessageEnd()
179 | result := SayHelloResult{}
180 | var retval string
181 | var err2 error
182 | if retval, err2 = p.handler.SayHello(args.Name); err2 != nil {
183 | x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing sayHello: "+err2.Error())
184 | oprot.WriteMessageBegin("sayHello", thrift.EXCEPTION, seqId)
185 | x.Write(oprot)
186 | oprot.WriteMessageEnd()
187 | oprot.Flush()
188 | return true, err2
189 | } else {
190 | result.Success = &retval
191 | }
192 | if err2 = oprot.WriteMessageBegin("sayHello", thrift.REPLY, seqId); err2 != nil {
193 | err = err2
194 | }
195 | if err2 = result.Write(oprot); err == nil && err2 != nil {
196 | err = err2
197 | }
198 | if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
199 | err = err2
200 | }
201 | if err2 = oprot.Flush(); err == nil && err2 != nil {
202 | err = err2
203 | }
204 | if err != nil {
205 | return
206 | }
207 | return true, err
208 | }
209 |
210 | // HELPER FUNCTIONS AND STRUCTURES
211 |
212 | type SayHelloArgs struct {
213 | Name string `thrift:"name,1" json:"name"`
214 | }
215 |
216 | func NewSayHelloArgs() *SayHelloArgs {
217 | return &SayHelloArgs{}
218 | }
219 |
220 | func (p *SayHelloArgs) GetName() string {
221 | return p.Name
222 | }
223 | func (p *SayHelloArgs) Read(iprot thrift.TProtocol) error {
224 | if _, err := iprot.ReadStructBegin(); err != nil {
225 | return fmt.Errorf("%T read error: %s", p, err)
226 | }
227 | for {
228 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
229 | if err != nil {
230 | return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
231 | }
232 | if fieldTypeId == thrift.STOP {
233 | break
234 | }
235 | switch fieldId {
236 | case 1:
237 | if err := p.ReadField1(iprot); err != nil {
238 | return err
239 | }
240 | default:
241 | if err := iprot.Skip(fieldTypeId); err != nil {
242 | return err
243 | }
244 | }
245 | if err := iprot.ReadFieldEnd(); err != nil {
246 | return err
247 | }
248 | }
249 | if err := iprot.ReadStructEnd(); err != nil {
250 | return fmt.Errorf("%T read struct end error: %s", p, err)
251 | }
252 | return nil
253 | }
254 |
255 | func (p *SayHelloArgs) ReadField1(iprot thrift.TProtocol) error {
256 | if v, err := iprot.ReadString(); err != nil {
257 | return fmt.Errorf("error reading field 1: %s", err)
258 | } else {
259 | p.Name = v
260 | }
261 | return nil
262 | }
263 |
264 | func (p *SayHelloArgs) Write(oprot thrift.TProtocol) error {
265 | if err := oprot.WriteStructBegin("sayHello_args"); err != nil {
266 | return fmt.Errorf("%T write struct begin error: %s", p, err)
267 | }
268 | if err := p.writeField1(oprot); err != nil {
269 | return err
270 | }
271 | if err := oprot.WriteFieldStop(); err != nil {
272 | return fmt.Errorf("write field stop error: %s", err)
273 | }
274 | if err := oprot.WriteStructEnd(); err != nil {
275 | return fmt.Errorf("write struct stop error: %s", err)
276 | }
277 | return nil
278 | }
279 |
280 | func (p *SayHelloArgs) writeField1(oprot thrift.TProtocol) (err error) {
281 | if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil {
282 | return fmt.Errorf("%T write field begin error 1:name: %s", p, err)
283 | }
284 | if err := oprot.WriteString(string(p.Name)); err != nil {
285 | return fmt.Errorf("%T.name (1) field write error: %s", p, err)
286 | }
287 | if err := oprot.WriteFieldEnd(); err != nil {
288 | return fmt.Errorf("%T write field end error 1:name: %s", p, err)
289 | }
290 | return err
291 | }
292 |
293 | func (p *SayHelloArgs) String() string {
294 | if p == nil {
295 | return ""
296 | }
297 | return fmt.Sprintf("SayHelloArgs(%+v)", *p)
298 | }
299 |
300 | type SayHelloResult struct {
301 | Success *string `thrift:"success,0" json:"success"`
302 | }
303 |
304 | func NewSayHelloResult() *SayHelloResult {
305 | return &SayHelloResult{}
306 | }
307 |
308 | var SayHelloResult_Success_DEFAULT string
309 |
310 | func (p *SayHelloResult) GetSuccess() string {
311 | if !p.IsSetSuccess() {
312 | return SayHelloResult_Success_DEFAULT
313 | }
314 | return *p.Success
315 | }
316 | func (p *SayHelloResult) IsSetSuccess() bool {
317 | return p.Success != nil
318 | }
319 |
320 | func (p *SayHelloResult) Read(iprot thrift.TProtocol) error {
321 | if _, err := iprot.ReadStructBegin(); err != nil {
322 | return fmt.Errorf("%T read error: %s", p, err)
323 | }
324 | for {
325 | _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
326 | if err != nil {
327 | return fmt.Errorf("%T field %d read error: %s", p, fieldId, err)
328 | }
329 | if fieldTypeId == thrift.STOP {
330 | break
331 | }
332 | switch fieldId {
333 | case 0:
334 | if err := p.ReadField0(iprot); err != nil {
335 | return err
336 | }
337 | default:
338 | if err := iprot.Skip(fieldTypeId); err != nil {
339 | return err
340 | }
341 | }
342 | if err := iprot.ReadFieldEnd(); err != nil {
343 | return err
344 | }
345 | }
346 | if err := iprot.ReadStructEnd(); err != nil {
347 | return fmt.Errorf("%T read struct end error: %s", p, err)
348 | }
349 | return nil
350 | }
351 |
352 | func (p *SayHelloResult) ReadField0(iprot thrift.TProtocol) error {
353 | if v, err := iprot.ReadString(); err != nil {
354 | return fmt.Errorf("error reading field 0: %s", err)
355 | } else {
356 | p.Success = &v
357 | }
358 | return nil
359 | }
360 |
361 | func (p *SayHelloResult) Write(oprot thrift.TProtocol) error {
362 | if err := oprot.WriteStructBegin("sayHello_result"); err != nil {
363 | return fmt.Errorf("%T write struct begin error: %s", p, err)
364 | }
365 | if err := p.writeField0(oprot); err != nil {
366 | return err
367 | }
368 | if err := oprot.WriteFieldStop(); err != nil {
369 | return fmt.Errorf("write field stop error: %s", err)
370 | }
371 | if err := oprot.WriteStructEnd(); err != nil {
372 | return fmt.Errorf("write struct stop error: %s", err)
373 | }
374 | return nil
375 | }
376 |
377 | func (p *SayHelloResult) writeField0(oprot thrift.TProtocol) (err error) {
378 | if p.IsSetSuccess() {
379 | if err := oprot.WriteFieldBegin("success", thrift.STRING, 0); err != nil {
380 | return fmt.Errorf("%T write field begin error 0:success: %s", p, err)
381 | }
382 | if err := oprot.WriteString(string(*p.Success)); err != nil {
383 | return fmt.Errorf("%T.success (0) field write error: %s", p, err)
384 | }
385 | if err := oprot.WriteFieldEnd(); err != nil {
386 | return fmt.Errorf("%T write field end error 0:success: %s", p, err)
387 | }
388 | }
389 | return err
390 | }
391 |
392 | func (p *SayHelloResult) String() string {
393 | if p == nil {
394 | return ""
395 | }
396 | return fmt.Sprintf("SayHelloResult(%+v)", *p)
397 | }
398 |
--------------------------------------------------------------------------------
/thrift/golang/src/greeter/ttypes.go:
--------------------------------------------------------------------------------
1 | // Autogenerated by Thrift Compiler (0.9.2)
2 | // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
3 |
4 | package greeter
5 |
6 | import (
7 | "bytes"
8 | "fmt"
9 | "git.apache.org/thrift.git/lib/go/thrift"
10 | )
11 |
12 | // (needed to ensure safety because of naive import list construction.)
13 | var _ = thrift.ZERO
14 | var _ = fmt.Printf
15 | var _ = bytes.Equal
16 |
17 | var GoUnusedProtection__ int
18 |
--------------------------------------------------------------------------------
/thrift/golang/src/server/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "os"
6 |
7 | "git.apache.org/thrift.git/lib/go/thrift"
8 |
9 | "greeter"
10 | )
11 |
12 | const (
13 | NetworkAddr = "localhost:9090"
14 | )
15 |
16 |
17 | type GreeterHandler struct {
18 |
19 | }
20 |
21 | func NewGreeterHandler() *GreeterHandler {
22 | return &GreeterHandler{}
23 | }
24 |
25 | func (p *GreeterHandler) SayHello(name string)(r string, err error) {
26 | return "Hello " + name, nil
27 | }
28 |
29 | func main() {
30 | var protocolFactory thrift.TProtocolFactory = thrift.NewTBinaryProtocolFactoryDefault()
31 | var transportFactory thrift.TTransportFactory = thrift.NewTBufferedTransportFactory(8192)
32 | transport, err := thrift.NewTServerSocket(NetworkAddr)
33 | if err != nil {
34 | fmt.Println("Error!", err)
35 | os.Exit(1)
36 | }
37 |
38 | handler := NewGreeterHandler()
39 | processor := greeter.NewGreeterProcessor(handler)
40 | server := thrift.NewTSimpleServer4(processor, transport, transportFactory, protocolFactory)
41 | fmt.Println("Starting the simple server... on ", NetworkAddr)
42 | server.Serve()
43 | }
--------------------------------------------------------------------------------
/thrift/golang/thrift/helloworld.thrift:
--------------------------------------------------------------------------------
1 | namespace go greeter
2 |
3 | service Greeter {
4 |
5 | string sayHello(1:string name);
6 |
7 | }
--------------------------------------------------------------------------------
/thrift/java/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .settings/
3 | target/
4 | *.iml
5 | *.log*
6 | .cache
7 | .classpath
8 | .project
9 | .DS_Store
10 |
--------------------------------------------------------------------------------
/thrift/java/dependency-reduced-pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | com.colobu.rpctest
5 | thrift
6 | thrift
7 | 1.0-SNAPSHOT
8 | http://maven.apache.org
9 |
10 |
11 |
12 | org.apache.thrift.tools
13 | maven-thrift-plugin
14 | 0.1.11
15 |
16 |
17 | thrift-sources
18 | generate-sources
19 |
20 | compile
21 |
22 |
23 |
24 | thrift-test-sources
25 | generate-test-sources
26 |
27 | testCompile
28 |
29 |
30 |
31 |
32 | C:/java/thrift-0.9.2.exe
33 |
34 |
35 |
36 | maven-shade-plugin
37 | 2.4.1
38 |
39 |
40 | package
41 |
42 | shade
43 |
44 |
45 |
46 |
47 | com.colobu.rpctest.AppServer
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | junit
59 | junit
60 | 3.8.1
61 | test
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/thrift/java/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | com.colobu.rpctest
5 | thrift
6 | jar
7 | 1.0-SNAPSHOT
8 | thrift
9 | http://maven.apache.org
10 |
11 |
12 | junit
13 | junit
14 | 3.8.1
15 | test
16 |
17 |
18 | org.apache.thrift
19 | libthrift
20 | 0.9.2
21 |
22 |
23 | org.slf4j
24 | slf4j-api
25 | 1.7.12
26 |
27 |
28 | ch.qos.logback
29 | logback-classic
30 | 1.1.3
31 |
32 |
33 |
34 |
35 |
36 | org.apache.thrift.tools
37 | maven-thrift-plugin
38 | 0.1.11
39 |
40 | C:/java/thrift-0.9.2.exe
41 |
42 |
43 |
44 | thrift-sources
45 | generate-sources
46 |
47 | compile
48 |
49 |
50 |
51 | thrift-test-sources
52 | generate-test-sources
53 |
54 | testCompile
55 |
56 |
57 |
58 |
59 |
60 | org.apache.maven.plugins
61 | maven-shade-plugin
62 | 2.4.1
63 |
64 |
65 | package
66 |
67 | shade
68 |
69 |
70 |
71 |
72 | com.colobu.rpctest.AppServer
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/thrift/java/src/main/java/com/colobu/rpctest/AppClient.java:
--------------------------------------------------------------------------------
1 | package com.colobu.rpctest;
2 |
3 | import java.util.concurrent.CountDownLatch;
4 | import java.util.concurrent.ExecutorService;
5 | import java.util.concurrent.Executors;
6 | import org.apache.thrift.TException;
7 | import org.apache.thrift.protocol.TBinaryProtocol;
8 | import org.apache.thrift.protocol.TProtocol;
9 | import org.apache.thrift.transport.TSocket;
10 | import org.apache.thrift.transport.TTransport;
11 |
12 | public class AppClient {
13 | public static void main(String[] args) {
14 | try {
15 | TTransport[] transport = new TTransport[20];
16 | Greeter.Client[] client = new Greeter.Client[20];
17 |
18 | //warmup
19 | String name = "world";
20 | for (int i = 0; i < 20; i++) {
21 | transport[i] = new TSocket("localhost", 9090);
22 | transport[i].open();
23 |
24 | TProtocol protocol = new TBinaryProtocol(transport[i]);
25 | client[i] = new Greeter.Client(protocol);
26 | client[i].sayHello(name);
27 | }
28 |
29 | boolean sync = true;
30 | if (args.length > 0) {
31 | sync = Boolean.parseBoolean(args[0]);
32 | }
33 | if (sync) { syncTest(client[0], name); }
34 | else { asyncTest(client, name); }
35 |
36 | for (int i = 0; i < 20; i++) {
37 | transport[i].close();
38 | }
39 | }
40 | catch (Exception e) {
41 | e.printStackTrace();
42 | }
43 | }
44 |
45 | private static void syncTest(Greeter.Client client, String name) throws TException {
46 | long t = System.nanoTime();
47 | for (int i = 0; i < 10000; i++) {
48 | client.sayHello(name);
49 | }
50 | System.out.println("took: " + (System.nanoTime() - t) / 1000000 + " ms");
51 | }
52 |
53 | private static void asyncTest(final Greeter.Client[] client, final String name) throws InterruptedException {
54 | ExecutorService pool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
55 | final CountDownLatch latch = new CountDownLatch(10000);
56 | long t = System.nanoTime();
57 | for (int i = 0; i < 10000; i++) {
58 | final int j = i;
59 | pool.submit(new Runnable() {
60 | @Override
61 | public void run() {
62 | synchronized (client[j % 20]) {
63 | try {
64 | client[j % 20].sayHello(name);
65 | }
66 | catch (TException e) {
67 | e.printStackTrace();
68 | }
69 | finally {
70 | latch.countDown();
71 | }
72 | }
73 |
74 | }
75 | });
76 |
77 | }
78 |
79 | latch.await();
80 | System.out.println("took: " + (System.nanoTime() - t) / 1000000 + " ms");
81 | pool.shutdownNow();
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/thrift/java/src/main/java/com/colobu/rpctest/AppServer.java:
--------------------------------------------------------------------------------
1 | package com.colobu.rpctest;
2 |
3 | import org.apache.thrift.server.TServer;
4 | import org.apache.thrift.server.TThreadPoolServer;
5 | import org.apache.thrift.transport.TServerSocket;
6 | import org.apache.thrift.transport.TServerTransport;
7 |
8 | public class AppServer
9 | {
10 | public static GreeterHandler handler;
11 |
12 | public static Greeter.Processor processor;
13 |
14 | public static void main( String[] args )
15 | {
16 | try {
17 | handler = new GreeterHandler();
18 | processor = new Greeter.Processor(handler);
19 |
20 | Runnable simple = new Runnable() {
21 | public void run() {
22 | simple(processor);
23 | }
24 | };
25 | new Thread(simple).start();
26 | } catch (Exception e) {
27 | e.printStackTrace();
28 | }
29 |
30 | }
31 |
32 | public static void simple(Greeter.Processor processor) {
33 | try {
34 | TServerTransport serverTransport = new TServerSocket(9090);
35 | //TServer server = new TSimpleServer(new TServer.Args(serverTransport).processor(processor));
36 |
37 | // Use this for a multithreaded server
38 | TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
39 |
40 | System.out.println("Starting the simple server...");
41 | server.serve();
42 | } catch (Exception e) {
43 | e.printStackTrace();
44 | }
45 | }
46 | }
47 |
48 |
49 |
--------------------------------------------------------------------------------
/thrift/java/src/main/java/com/colobu/rpctest/GreeterHandler.java:
--------------------------------------------------------------------------------
1 | package com.colobu.rpctest;
2 |
3 | import org.apache.thrift.TException;
4 |
5 | public class GreeterHandler implements Greeter.Iface {
6 | @Override
7 | public String sayHello(String name) throws TException {
8 | return "Hello " + name;
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/thrift/java/src/main/thrift/helloworld.thrift:
--------------------------------------------------------------------------------
1 | namespace java com.colobu.rpctest
2 |
3 | service Greeter {
4 |
5 | string sayHello(1:string name);
6 |
7 | }
--------------------------------------------------------------------------------
/thrift/scala/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .settings/
3 | target/
4 | *.iml
5 | *.log*
6 |
7 | *.class
8 | *.log
9 |
--------------------------------------------------------------------------------
/thrift/scala/README.md:
--------------------------------------------------------------------------------
1 | There are few sbt thrift plugins:
2 | *
3 | *
4 | *
5 |
6 | But they are too old and required thrift is very old.
7 |
8 | I copy the generated java file from the same helloworld.thrift into this project and it can be used in Scala.
9 |
10 |
--------------------------------------------------------------------------------
/thrift/scala/project/Build.scala:
--------------------------------------------------------------------------------
1 | import java.text.SimpleDateFormat
2 | import java.util.Date
3 |
4 | import com.typesafe.sbt.packager.archetypes.JavaAppPackaging
5 | import com.typesafe.sbt.packager.universal.UniversalDeployPlugin
6 | import sbt.Defaults._
7 | import sbt.Keys._
8 | import sbt._
9 | import sbtbuildinfo.Plugin.{BuildInfoKey, _}
10 | import sbtrelease.ReleasePlugin._
11 |
12 | object ApplicationBuild extends Build {
13 |
14 | lazy val root = Project("thrift", file("."))
15 | .settings(coreDefaultSettings: _*)
16 | .settings(libraryDependencies ++= Seq("org.apache.thrift" % "libthrift" % "0.9.2",
17 | "org.slf4j" % "slf4j-api" % "1.7.12",
18 | "ch.qos.logback" % "logback-classic" % "1.1.3"))
19 | .settings(mainClass in Compile := Some("com.colobu.rpctest.AppServer"))
20 | .enablePlugins(JavaAppPackaging)
21 | }
--------------------------------------------------------------------------------
/thrift/scala/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version = 0.13.8
--------------------------------------------------------------------------------
/thrift/scala/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | logLevel := Level.Warn
2 |
3 | resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
4 |
5 | addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")
6 |
7 | addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.0-RC1")
8 |
9 | addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.8")
10 |
11 | addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.3.2")
12 |
13 | addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")
14 |
15 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.12.0")
16 |
17 | addSbtPlugin("com.github.gseitz" % "sbt-release" % "0.8.5")
18 |
19 |
--------------------------------------------------------------------------------
/thrift/scala/src/main/java/com/colobu/rpctest/Greeter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Autogenerated by Thrift Compiler (0.9.2)
3 | *
4 | * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5 | * @generated
6 | */
7 | package com.colobu.rpctest;
8 |
9 | import org.apache.thrift.scheme.IScheme;
10 | import org.apache.thrift.scheme.SchemeFactory;
11 | import org.apache.thrift.scheme.StandardScheme;
12 |
13 | import org.apache.thrift.scheme.TupleScheme;
14 | import org.apache.thrift.protocol.TTupleProtocol;
15 | import org.apache.thrift.protocol.TProtocolException;
16 | import org.apache.thrift.EncodingUtils;
17 | import org.apache.thrift.TException;
18 | import org.apache.thrift.async.AsyncMethodCallback;
19 | import org.apache.thrift.server.AbstractNonblockingServer.*;
20 | import java.util.List;
21 | import java.util.ArrayList;
22 | import java.util.Map;
23 | import java.util.HashMap;
24 | import java.util.EnumMap;
25 | import java.util.Set;
26 | import java.util.HashSet;
27 | import java.util.EnumSet;
28 | import java.util.Collections;
29 | import java.util.BitSet;
30 | import java.nio.ByteBuffer;
31 | import java.util.Arrays;
32 | import javax.annotation.Generated;
33 | import org.slf4j.Logger;
34 | import org.slf4j.LoggerFactory;
35 |
36 | @SuppressWarnings({"cast", "rawtypes", "serial", "unchecked"})
37 | @Generated(value = "Autogenerated by Thrift Compiler (0.9.2)", date = "2015-7-17")
38 | public class Greeter {
39 |
40 | public interface Iface {
41 |
42 | public String sayHello(String name) throws org.apache.thrift.TException;
43 |
44 | }
45 |
46 | public interface AsyncIface {
47 |
48 | public void sayHello(String name, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException;
49 |
50 | }
51 |
52 | public static class Client extends org.apache.thrift.TServiceClient implements Iface {
53 | public static class Factory implements org.apache.thrift.TServiceClientFactory {
54 | public Factory() {}
55 | public Client getClient(org.apache.thrift.protocol.TProtocol prot) {
56 | return new Client(prot);
57 | }
58 | public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
59 | return new Client(iprot, oprot);
60 | }
61 | }
62 |
63 | public Client(org.apache.thrift.protocol.TProtocol prot)
64 | {
65 | super(prot, prot);
66 | }
67 |
68 | public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {
69 | super(iprot, oprot);
70 | }
71 |
72 | public String sayHello(String name) throws org.apache.thrift.TException
73 | {
74 | send_sayHello(name);
75 | return recv_sayHello();
76 | }
77 |
78 | public void send_sayHello(String name) throws org.apache.thrift.TException
79 | {
80 | sayHello_args args = new sayHello_args();
81 | args.setName(name);
82 | sendBase("sayHello", args);
83 | }
84 |
85 | public String recv_sayHello() throws org.apache.thrift.TException
86 | {
87 | sayHello_result result = new sayHello_result();
88 | receiveBase(result, "sayHello");
89 | if (result.isSetSuccess()) {
90 | return result.success;
91 | }
92 | throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "sayHello failed: unknown result");
93 | }
94 |
95 | }
96 | public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface {
97 | public static class Factory implements org.apache.thrift.async.TAsyncClientFactory {
98 | private org.apache.thrift.async.TAsyncClientManager clientManager;
99 | private org.apache.thrift.protocol.TProtocolFactory protocolFactory;
100 | public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {
101 | this.clientManager = clientManager;
102 | this.protocolFactory = protocolFactory;
103 | }
104 | public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {
105 | return new AsyncClient(protocolFactory, clientManager, transport);
106 | }
107 | }
108 |
109 | public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {
110 | super(protocolFactory, clientManager, transport);
111 | }
112 |
113 | public void sayHello(String name, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException {
114 | checkReady();
115 | sayHello_call method_call = new sayHello_call(name, resultHandler, this, ___protocolFactory, ___transport);
116 | this.___currentMethod = method_call;
117 | ___manager.call(method_call);
118 | }
119 |
120 | public static class sayHello_call extends org.apache.thrift.async.TAsyncMethodCall {
121 | private String name;
122 | public sayHello_call(String name, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {
123 | super(client, protocolFactory, transport, resultHandler, false);
124 | this.name = name;
125 | }
126 |
127 | public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {
128 | prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("sayHello", org.apache.thrift.protocol.TMessageType.CALL, 0));
129 | sayHello_args args = new sayHello_args();
130 | args.setName(name);
131 | args.write(prot);
132 | prot.writeMessageEnd();
133 | }
134 |
135 | public String getResult() throws org.apache.thrift.TException {
136 | if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {
137 | throw new IllegalStateException("Method call not finished!");
138 | }
139 | org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());
140 | org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);
141 | return (new Client(prot)).recv_sayHello();
142 | }
143 | }
144 |
145 | }
146 |
147 | public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor {
148 | private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());
149 | public Processor(I iface) {
150 | super(iface, getProcessMap(new HashMap>()));
151 | }
152 |
153 | protected Processor(I iface, Map> processMap) {
154 | super(iface, getProcessMap(processMap));
155 | }
156 |
157 | private static Map> getProcessMap(Map> processMap) {
158 | processMap.put("sayHello", new sayHello());
159 | return processMap;
160 | }
161 |
162 | public static class sayHello extends org.apache.thrift.ProcessFunction {
163 | public sayHello() {
164 | super("sayHello");
165 | }
166 |
167 | public sayHello_args getEmptyArgsInstance() {
168 | return new sayHello_args();
169 | }
170 |
171 | protected boolean isOneway() {
172 | return false;
173 | }
174 |
175 | public sayHello_result getResult(I iface, sayHello_args args) throws org.apache.thrift.TException {
176 | sayHello_result result = new sayHello_result();
177 | result.success = iface.sayHello(args.name);
178 | return result;
179 | }
180 | }
181 |
182 | }
183 |
184 | public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor {
185 | private static final Logger LOGGER = LoggerFactory.getLogger(AsyncProcessor.class.getName());
186 | public AsyncProcessor(I iface) {
187 | super(iface, getProcessMap(new HashMap>()));
188 | }
189 |
190 | protected AsyncProcessor(I iface, Map> processMap) {
191 | super(iface, getProcessMap(processMap));
192 | }
193 |
194 | private static Map> getProcessMap(Map> processMap) {
195 | processMap.put("sayHello", new sayHello());
196 | return processMap;
197 | }
198 |
199 | public static class sayHello extends org.apache.thrift.AsyncProcessFunction {
200 | public sayHello() {
201 | super("sayHello");
202 | }
203 |
204 | public sayHello_args getEmptyArgsInstance() {
205 | return new sayHello_args();
206 | }
207 |
208 | public AsyncMethodCallback getResultHandler(final AsyncFrameBuffer fb, final int seqid) {
209 | final org.apache.thrift.AsyncProcessFunction fcall = this;
210 | return new AsyncMethodCallback() {
211 | public void onComplete(String o) {
212 | sayHello_result result = new sayHello_result();
213 | result.success = o;
214 | try {
215 | fcall.sendResponse(fb,result, org.apache.thrift.protocol.TMessageType.REPLY,seqid);
216 | return;
217 | } catch (Exception e) {
218 | LOGGER.error("Exception writing to internal frame buffer", e);
219 | }
220 | fb.close();
221 | }
222 | public void onError(Exception e) {
223 | byte msgType = org.apache.thrift.protocol.TMessageType.REPLY;
224 | org.apache.thrift.TBase msg;
225 | sayHello_result result = new sayHello_result();
226 | {
227 | msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION;
228 | msg = (org.apache.thrift.TBase)new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage());
229 | }
230 | try {
231 | fcall.sendResponse(fb,msg,msgType,seqid);
232 | return;
233 | } catch (Exception ex) {
234 | LOGGER.error("Exception writing to internal frame buffer", ex);
235 | }
236 | fb.close();
237 | }
238 | };
239 | }
240 |
241 | protected boolean isOneway() {
242 | return false;
243 | }
244 |
245 | public void start(I iface, sayHello_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws TException {
246 | iface.sayHello(args.name,resultHandler);
247 | }
248 | }
249 |
250 | }
251 |
252 | public static class sayHello_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable {
253 | private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("sayHello_args");
254 |
255 | private static final org.apache.thrift.protocol.TField NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("name", org.apache.thrift.protocol.TType.STRING, (short)1);
256 |
257 | private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
258 | static {
259 | schemes.put(StandardScheme.class, new sayHello_argsStandardSchemeFactory());
260 | schemes.put(TupleScheme.class, new sayHello_argsTupleSchemeFactory());
261 | }
262 |
263 | public String name; // required
264 |
265 | /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
266 | public enum _Fields implements org.apache.thrift.TFieldIdEnum {
267 | NAME((short)1, "name");
268 |
269 | private static final Map byName = new HashMap();
270 |
271 | static {
272 | for (_Fields field : EnumSet.allOf(_Fields.class)) {
273 | byName.put(field.getFieldName(), field);
274 | }
275 | }
276 |
277 | /**
278 | * Find the _Fields constant that matches fieldId, or null if its not found.
279 | */
280 | public static _Fields findByThriftId(int fieldId) {
281 | switch(fieldId) {
282 | case 1: // NAME
283 | return NAME;
284 | default:
285 | return null;
286 | }
287 | }
288 |
289 | /**
290 | * Find the _Fields constant that matches fieldId, throwing an exception
291 | * if it is not found.
292 | */
293 | public static _Fields findByThriftIdOrThrow(int fieldId) {
294 | _Fields fields = findByThriftId(fieldId);
295 | if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
296 | return fields;
297 | }
298 |
299 | /**
300 | * Find the _Fields constant that matches name, or null if its not found.
301 | */
302 | public static _Fields findByName(String name) {
303 | return byName.get(name);
304 | }
305 |
306 | private final short _thriftId;
307 | private final String _fieldName;
308 |
309 | _Fields(short thriftId, String fieldName) {
310 | _thriftId = thriftId;
311 | _fieldName = fieldName;
312 | }
313 |
314 | public short getThriftFieldId() {
315 | return _thriftId;
316 | }
317 |
318 | public String getFieldName() {
319 | return _fieldName;
320 | }
321 | }
322 |
323 | // isset id assignments
324 | public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
325 | static {
326 | Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
327 | tmpMap.put(_Fields.NAME, new org.apache.thrift.meta_data.FieldMetaData("name", org.apache.thrift.TFieldRequirementType.DEFAULT,
328 | new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
329 | metaDataMap = Collections.unmodifiableMap(tmpMap);
330 | org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(sayHello_args.class, metaDataMap);
331 | }
332 |
333 | public sayHello_args() {
334 | }
335 |
336 | public sayHello_args(
337 | String name)
338 | {
339 | this();
340 | this.name = name;
341 | }
342 |
343 | /**
344 | * Performs a deep copy on other.
345 | */
346 | public sayHello_args(sayHello_args other) {
347 | if (other.isSetName()) {
348 | this.name = other.name;
349 | }
350 | }
351 |
352 | public sayHello_args deepCopy() {
353 | return new sayHello_args(this);
354 | }
355 |
356 | @Override
357 | public void clear() {
358 | this.name = null;
359 | }
360 |
361 | public String getName() {
362 | return this.name;
363 | }
364 |
365 | public sayHello_args setName(String name) {
366 | this.name = name;
367 | return this;
368 | }
369 |
370 | public void unsetName() {
371 | this.name = null;
372 | }
373 |
374 | /** Returns true if field name is set (has been assigned a value) and false otherwise */
375 | public boolean isSetName() {
376 | return this.name != null;
377 | }
378 |
379 | public void setNameIsSet(boolean value) {
380 | if (!value) {
381 | this.name = null;
382 | }
383 | }
384 |
385 | public void setFieldValue(_Fields field, Object value) {
386 | switch (field) {
387 | case NAME:
388 | if (value == null) {
389 | unsetName();
390 | } else {
391 | setName((String)value);
392 | }
393 | break;
394 |
395 | }
396 | }
397 |
398 | public Object getFieldValue(_Fields field) {
399 | switch (field) {
400 | case NAME:
401 | return getName();
402 |
403 | }
404 | throw new IllegalStateException();
405 | }
406 |
407 | /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
408 | public boolean isSet(_Fields field) {
409 | if (field == null) {
410 | throw new IllegalArgumentException();
411 | }
412 |
413 | switch (field) {
414 | case NAME:
415 | return isSetName();
416 | }
417 | throw new IllegalStateException();
418 | }
419 |
420 | @Override
421 | public boolean equals(Object that) {
422 | if (that == null)
423 | return false;
424 | if (that instanceof sayHello_args)
425 | return this.equals((sayHello_args)that);
426 | return false;
427 | }
428 |
429 | public boolean equals(sayHello_args that) {
430 | if (that == null)
431 | return false;
432 |
433 | boolean this_present_name = true && this.isSetName();
434 | boolean that_present_name = true && that.isSetName();
435 | if (this_present_name || that_present_name) {
436 | if (!(this_present_name && that_present_name))
437 | return false;
438 | if (!this.name.equals(that.name))
439 | return false;
440 | }
441 |
442 | return true;
443 | }
444 |
445 | @Override
446 | public int hashCode() {
447 | List