-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add schema and generated java to data model, refactor Gobblin audit p…
…rocessor
- Loading branch information
Showing
15 changed files
with
262 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ modules.each { module -> | |
include "${module}" | ||
} | ||
|
||
gradle.ext.appBuildEnvironment = "OpenSource" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
wherehows-common/src/test/java/wherehows/common/utils/StringUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* 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 wherehows.common.utils; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import static wherehows.common.utils.StringUtil.*; | ||
|
||
|
||
public class StringUtilTest { | ||
|
||
@Test | ||
public void testToStringMap() { | ||
CharSequence key = "foo"; | ||
Object value = "bar"; | ||
|
||
Map<CharSequence, Object> map = new HashMap<>(); | ||
map.put(key, value); | ||
|
||
Map newMap = toStringMap(map); | ||
|
||
Assert.assertTrue(newMap.containsKey("foo")); | ||
Assert.assertEquals(newMap.get("foo"), "bar"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Wherehows Data Model | ||
The module contains the data model used by WhereHows, including the table DDLs for MySQL DB, Elastic search indices, | ||
and avro schemas for Kafka events. It also includes the auto generated Kafka event java classes, to be used by other modules. | ||
|
||
## Code Generation for Avro Schema | ||
The java code here under src/main/java are auto generated by Avro-tool from avro schema (.avsc) of Kafka events. | ||
They should not be edited directly. | ||
|
||
Note that we currently require avro version 1.4 in Kafka related tasks. | ||
|
||
To generate java code, first download avro-tool-1.4.1, then use command line from wherehows-data-model/: | ||
``` | ||
java -jar avro-tools-1.4.1.jar compile schema xxx.avsc src/main/java | ||
``` | ||
|
||
|
||
## Build | ||
``` | ||
$ ../gradlew build | ||
BUILD SUCCESSFUL in 0s | ||
4 actionable tasks: 2 executed, 2 up-to-date | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"type": "record", | ||
"name": "GobblinTrackingEvent_audit", | ||
"namespace": "gobblin.metrics", | ||
"fields": [ | ||
{ | ||
"name": "timestamp", | ||
"type": "long", | ||
"doc": "Time at which event was created.", | ||
"default": 0 | ||
}, | ||
{ | ||
"name": "namespace", | ||
"type": [ | ||
"string", | ||
"null" | ||
], | ||
"doc": "Namespace used for filtering of events." | ||
}, | ||
{ | ||
"name": "name", | ||
"type": "string", | ||
"doc": "Event name." | ||
}, | ||
{ | ||
"name": "metadata", | ||
"type": { | ||
"type": "map", | ||
"values": "string" | ||
}, | ||
"doc": "Event metadata.", | ||
"default": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
sourceSets { | ||
main { | ||
resources { | ||
srcDir 'DDL' | ||
srcDir 'ELASTICSEARCH' | ||
} | ||
plugins { | ||
id "com.commercehub.gradle.plugin.avro" version "0.8.0" apply false | ||
} | ||
|
||
println gradle.appBuildEnvironment | ||
|
||
if ("OpenSource" == gradle.appBuildEnvironment) { | ||
println "apply gradle.plugin.avro" | ||
apply plugin: "com.commercehub.gradle.plugin.avro" | ||
|
||
avro { | ||
fieldVisibility = "PUBLIC" | ||
} | ||
} | ||
|
||
apply plugin: 'java' | ||
|
||
dependencies { | ||
compile externalDependency.avro | ||
} |
35 changes: 35 additions & 0 deletions
35
wherehows-data-model/src/main/avro/GobblinTrackingEvent_audit.avsc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"type": "record", | ||
"name": "GobblinTrackingEvent_audit", | ||
"namespace": "gobblin.metrics", | ||
"fields": [ | ||
{ | ||
"name": "timestamp", | ||
"type": "long", | ||
"doc": "Time at which event was created.", | ||
"default": 0 | ||
}, | ||
{ | ||
"name": "namespace", | ||
"type": [ | ||
"string", | ||
"null" | ||
], | ||
"doc": "Namespace used for filtering of events." | ||
}, | ||
{ | ||
"name": "name", | ||
"type": "string", | ||
"doc": "Event name." | ||
}, | ||
{ | ||
"name": "metadata", | ||
"type": { | ||
"type": "map", | ||
"values": "string" | ||
}, | ||
"doc": "Event metadata.", | ||
"default": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.