-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add simple stream node inspection for testing
- Loading branch information
Showing
11 changed files
with
305 additions
and
222 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
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
44 changes: 44 additions & 0 deletions
44
src/main/scala/io/epiphanous/flinkrunner/model/StreamNodeInfo.scala
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,44 @@ | ||
package io.epiphanous.flinkrunner.model | ||
|
||
import org.apache.flink.streaming.api.graph.StreamGraph | ||
|
||
import scala.collection.JavaConverters._ | ||
|
||
case class StreamNodeInfo( | ||
id: Int, | ||
name: String, | ||
parallelism: Int, | ||
inClasses: List[String], | ||
outClass: Option[String]) { | ||
val isSource: Boolean = inClasses.isEmpty | ||
val isSink: Boolean = outClass.isEmpty | ||
val isTransform: Boolean = !isSource && !isSink | ||
val nodeKind: String = | ||
if (isSource) "source" else if (isTransform) "transform" else "sink" | ||
val simpleInClasses: List[String] = | ||
inClasses.map(_.split("\\.").last) | ||
val simpleOutClass: Option[String] = outClass.map(_.split("\\.").last) | ||
} | ||
|
||
object StreamNodeInfo { | ||
def from(sg: StreamGraph): Seq[StreamNodeInfo] = { | ||
sg.getStreamNodes.asScala.map { sn => | ||
val id = sn.getId | ||
val name = sn.getOperatorName | ||
val parallelism = sn.getParallelism | ||
val inClasses = sn.getTypeSerializersIn.toList.map( | ||
_.createInstance().getClass.getCanonicalName | ||
) | ||
val outClass = | ||
Option(sn.getTypeSerializerOut) | ||
.map(_.createInstance().getClass.getCanonicalName) | ||
StreamNodeInfo( | ||
id = id, | ||
name = name, | ||
parallelism = parallelism, | ||
inClasses = inClasses, | ||
outClass = outClass | ||
) | ||
}.toSeq | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/scala/io/epiphanous/flinkrunner/model/source/EmptySourceConfig.scala
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,42 @@ | ||
package io.epiphanous.flinkrunner.model.source | ||
|
||
import io.epiphanous.flinkrunner.model._ | ||
import org.apache.avro.generic.GenericRecord | ||
import org.apache.flink.api.common.typeinfo.TypeInformation | ||
import org.apache.flink.api.scala.createTypeInformation | ||
import org.apache.flink.streaming.api.scala.{ | ||
DataStream, | ||
StreamExecutionEnvironment | ||
} | ||
import org.apache.flink.table.data.{GenericRowData, RowData} | ||
|
||
case class EmptySourceConfig[ADT <: FlinkEvent]( | ||
name: String, | ||
config: FlinkConfig) | ||
extends SourceConfig[ADT] { | ||
override def connector: FlinkConnectorName = FlinkConnectorName.Empty | ||
|
||
def _emptySource[E: TypeInformation]( | ||
env: StreamExecutionEnvironment): DataStream[E] = { | ||
val x = env.fromCollection(Seq.empty[E]) | ||
x | ||
} | ||
|
||
override def getSourceStream[E <: ADT: TypeInformation]( | ||
env: StreamExecutionEnvironment): DataStream[E] = | ||
_emptySource[E](env) | ||
|
||
override def getAvroSourceStream[ | ||
E <: ADT with EmbeddedAvroRecord[A]: TypeInformation, | ||
A <: GenericRecord: TypeInformation]( | ||
env: StreamExecutionEnvironment)(implicit | ||
fromKV: EmbeddedAvroRecordInfo[A] => E): DataStream[E] = | ||
_emptySource[E](env) | ||
|
||
override def getRowSourceStream[ | ||
E <: ADT with EmbeddedRowType: TypeInformation]( | ||
env: StreamExecutionEnvironment)(implicit | ||
fromRowData: RowData => E): DataStream[E] = | ||
_emptySource[GenericRowData](env).map(fromRowData) | ||
|
||
} |
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.