| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Copyright 2015 LinkedIn Corp. All rights reserved.
 | 
					
						
							|  |  |  |  *
 | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License");
 | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License.
 | 
					
						
							|  |  |  |  * You may obtain a copy of the License at
 | 
					
						
							|  |  |  |  *
 | 
					
						
							|  |  |  |  * http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  *
 | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software
 | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS,
 | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					
						
							|  |  |  |  */
 | 
					
						
							|  |  |  | package msgs;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  | import java.util.HashMap;
 | 
					
						
							|  |  |  | import java.util.Map;
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  |  * Generic communication message between KafkaConsumerMaster and KafkaConsumerWorker
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  |  */
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  | public class KafkaCommMsg {
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  |   // Message type: AUDIT, AUDIT_RESPONSE, FLUSH, FLUSH_RESPONSE, HEARTBEAT, etc
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  |   private String msgType;
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  |   // Kafka topic of the worker
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  |   private String topic;
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  |   // Kafka worker thread number
 | 
					
						
							|  |  |  |   private int thread;
 | 
					
						
							|  |  |  |   // Message content
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  |   private Map<String, Object> content;
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  |   public KafkaCommMsg(String msgType, String topic, int thread) {
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  |     this.msgType = msgType;
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  |     this.topic = topic;
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  |     this.thread = thread;
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  |     this.content = new HashMap<>();
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  |   public String getMsgType() {
 | 
					
						
							|  |  |  |     return msgType;
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  |   public void setMsgType(String msgType) {
 | 
					
						
							|  |  |  |     this.msgType = msgType;
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public String getTopic() {
 | 
					
						
							|  |  |  |     return topic;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public void setTopic(String topic) {
 | 
					
						
							|  |  |  |     this.topic = topic;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  |   public int getThread() {
 | 
					
						
							|  |  |  |     return thread;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public void setThread(int thread) {
 | 
					
						
							|  |  |  |     this.thread = thread;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-10 14:49:14 -07:00
										 |  |  |   public Map<String, Object> getContent() {
 | 
					
						
							|  |  |  |     return content;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public void setContent(Map<String, Object> content) {
 | 
					
						
							|  |  |  |     this.content = content;
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  |   public void putContent(String key, Object value) {
 | 
					
						
							|  |  |  |     this.content.put(key, value);
 | 
					
						
							|  |  |  |   }
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  |   @Override
 | 
					
						
							|  |  |  |   public String toString() {
 | 
					
						
							| 
									
										
										
										
											2016-10-11 11:26:36 -07:00
										 |  |  |     return "KafkaCommMsg [type=" + msgType + ", topic=" + topic + ", thread=" + thread + ", content="
 | 
					
						
							|  |  |  |         + content.toString() + "]";
 | 
					
						
							| 
									
										
										
										
											2016-07-25 14:44:02 -07:00
										 |  |  |   }
 | 
					
						
							|  |  |  | }
 |