Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
theodolite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sören Henning
theodolite
Merge requests
!41
Draft: Feature/avro without registry
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Draft: Feature/avro without registry
stu202077/theodolite:feature/AvroWithoutRegistry
into
master
Overview
1
Commits
1
Pipelines
0
Changes
3
Closed
Björn Vonheiden
requested to merge
stu202077/theodolite:feature/AvroWithoutRegistry
into
master
4 years ago
Overview
1
Commits
1
Pipelines
0
Changes
3
Expand
#5 (closed)
0
0
Merge request reports
Compare
master
version 1
0bb0a159
4 years ago
master (base)
and
latest version
latest version
0bb0a159
1 commit,
4 years ago
version 1
0bb0a159
29 commits,
4 years ago
3 files
+
68
−
3
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
uc1-application/src/main/java/theodolite/uc1/streamprocessing/TopologyBuilder.java
+
25
−
1
Options
package
theodolite.uc1.streamprocessing
;
package
theodolite.uc1.streamprocessing
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
java.io.IOException
;
import
java.util.function.Function
;
import
org.apache.kafka.common.serialization.Serde
;
import
org.apache.kafka.common.serialization.Serdes
;
import
org.apache.kafka.common.serialization.Serdes
;
import
org.apache.kafka.streams.StreamsBuilder
;
import
org.apache.kafka.streams.StreamsBuilder
;
import
org.apache.kafka.streams.Topology
;
import
org.apache.kafka.streams.Topology
;
import
org.apache.kafka.streams.kstream.Consumed
;
import
org.apache.kafka.streams.kstream.Consumed
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
titan.ccp.common.kafka.GenericSerde
;
import
titan.ccp.common.kafka.avro.SchemaRegistryAvroSerdeFactory
;
import
titan.ccp.common.kafka.avro.SchemaRegistryAvroSerdeFactory
;
import
titan.ccp.model.records.ActivePowerRecord
;
import
titan.ccp.model.records.ActivePowerRecord
;
@@ -37,10 +41,30 @@ public class TopologyBuilder {
@@ -37,10 +41,30 @@ public class TopologyBuilder {
* Build the {@link Topology} for the History microservice.
* Build the {@link Topology} for the History microservice.
*/
*/
public
Topology
build
()
{
public
Topology
build
()
{
final
Function
<
ActivePowerRecord
,
byte
[]>
serializer
=
(
apr
)
->
{
try
{
return
apr
.
toByteBuffer
().
array
();
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
};
final
Function
<
byte
[],
ActivePowerRecord
>
deserializer
=
(
bytes
)
->
{
try
{
return
ActivePowerRecord
.
getDecoder
().
decode
(
bytes
);
}
catch
(
final
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
};
final
Serde
<
ActivePowerRecord
>
serde
=
GenericSerde
.
from
(
serializer
,
deserializer
);
this
.
builder
this
.
builder
.
stream
(
this
.
inputTopic
,
Consumed
.
with
(
.
stream
(
this
.
inputTopic
,
Consumed
.
with
(
Serdes
.
String
(),
Serdes
.
String
(),
this
.
srAvroSerdeFactory
.<
ActivePowerRecord
>
forValues
()
))
serde
))
.
mapValues
(
v
->
this
.
gson
.
toJson
(
v
))
.
mapValues
(
v
->
this
.
gson
.
toJson
(
v
))
.
foreach
((
k
,
v
)
->
LOGGER
.
info
(
"Key: "
+
k
+
" Value: "
+
v
));
.
foreach
((
k
,
v
)
->
LOGGER
.
info
(
"Key: "
+
k
+
" Value: "
+
v
));
Loading