blob: 1a08bd4fe2a776573f5a157e61d42f1f19ea9e87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* Copyright (c) 2018 Cisco Systems. 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Name: DataPlatformEvent
* Purpose: Data model class for an avro event on Kafka
* Author: PNDA team
*
* Created: 07/04/2016
*/
package com.cisco.pnda.model;
import java.io.IOException;
import java.io.Serializable;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.ObjectMapper;
public class DataPlatformEvent implements Serializable
{
private static final long serialVersionUID = 1L;
protected static ObjectMapper _mapper = new ObjectMapper();
private String _src;
private Long _timestamp;
private String _hostIp;
private String _rawdata;
public DataPlatformEvent(String src, Long timestamp, String host_ip, String rawdata)
{
_src = src;
_timestamp = timestamp;
_hostIp = host_ip;
_rawdata = rawdata;
}
public String getSrc()
{
return _src;
}
public Long getTimestamp()
{
return _timestamp;
}
public String getHostIp()
{
return _hostIp;
}
public String getRawdata()
{
return _rawdata;
}
@Override
public String toString()
{
try
{
return _mapper.writeValueAsString(this);
}
catch (Exception ex)
{
return null;
}
}
@Override
public boolean equals(Object other)
{
boolean result = false;
if (other instanceof DataPlatformEvent)
{
DataPlatformEvent that = (DataPlatformEvent) other;
result = (this.getSrc() == that.getSrc() || (this.getSrc() != null && this.getSrc().equals(that.getSrc())))
&& (this.getTimestamp() == that.getTimestamp() || (this.getTimestamp() != null && this.getTimestamp().equals(that.getTimestamp())))
&& (this.getHostIp() == that.getHostIp() || (this.getHostIp() != null && this.getHostIp().equals(that.getHostIp())))
&& (this.getRawdata() == that.getRawdata() || (this.getRawdata() != null && this.getRawdata().equals(that.getRawdata())));
}
return result;
}
public JsonNode RawdataAsJsonObj() throws JsonProcessingException, IOException
{
return _mapper.readTree(_rawdata);
}
}
|