Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5aee15d
Update README.md
BiyuHuang May 13, 2022
8c66f62
Update README.md
BiyuHuang May 13, 2022
b50f619
Create codacy.yml
BiyuHuang May 18, 2022
a83e809
Delete codacy.yml
BiyuHuang May 18, 2022
d2ae0ed
Bump json-smart from 2.4.1 to 2.4.4
dependabot[bot] May 13, 2022
409e090
add GsonDemo.scala
BiyuHuang May 22, 2022
6141e52
add GsonDemo: update json data
BiyuHuang May 22, 2022
f65b1ac
update pom.xml
BiyuHuang Jun 9, 2022
bef3cc0
update pom.xml
BiyuHuang Jun 9, 2022
3e57a57
Merge branch 'master' into dev
BiyuHuang Jun 9, 2022
a5573cd
feat(scala-demo): add Arage Parser
BiyuHuang Nov 14, 2022
f6f6689
style(scala-demo): use log4j2.properties
BiyuHuang Dec 13, 2022
1a2cb2d
feat(scala-demo): raft algorithm
BiyuHuang Dec 23, 2022
166a97b
feat(scala-demo): raft algorithm
BiyuHuang Jan 12, 2023
62f15f6
feat(scala-demo): raft algorithm
BiyuHuang Jan 18, 2023
572bbc4
feat(scala-demo): raft algorithm
BiyuHuang Jan 18, 2023
f5907d3
feat(scala-demo): raft algorithm
BiyuHuang Jan 31, 2023
53abe2b
feat(scala-demo): add leader election base on zookeeper
BiyuHuang Feb 3, 2023
6cfd1fa
feat(scala-demo): add round-robin service
BiyuHuang Apr 24, 2023
5d2e1eb
Update AlgDemo.scala
BiyuHuang May 24, 2023
df730a1
Create LinkedList.scala
BiyuHuang May 25, 2023
5519536
Update LinkedList.scala
BiyuHuang Jun 1, 2023
cdb3869
feat(scala-demo): add TrieTree
BiyuHuang Jun 2, 2023
16d872f
feat(scala-demo): update TrieTree
BiyuHuang Jun 2, 2023
a76e124
feat(scala-demo): update TrieTree
BiyuHuang Jun 5, 2023
594a425
feat(scala-demo): update TrieTree
BiyuHuang Jun 5, 2023
b232455
feat(scala-demo): add bit filter
BiyuHuang Jun 13, 2023
be5b8c9
feat(scala-demo): add bit filter
BiyuHuang Jun 13, 2023
6017256
Merge branch 'dev' of https://github.com/BiyuHuang/CodePrototypesDemo…
BiyuHuang Jun 13, 2023
c059623
feat(scala-demo): update bit filter
BiyuHuang Jun 13, 2023
f384d68
[add] add flink demo
BiyuHuang Jul 27, 2023
4403d4f
[update] mock more events
BiyuHuang Jul 27, 2023
149c4b4
[update] add new mock events
BiyuHuang Jul 27, 2023
44715c7
Update FlinkCEPDemo.scala
BiyuHuang Aug 8, 2023
725fd3e
Update log4j2.properties
BiyuHuang Aug 18, 2023
9fef13a
Update log4j2.properties
BiyuHuang Aug 18, 2023
3810414
add AkkaClusterSystem
BiyuHuang Nov 1, 2023
8b7fc05
add RowKeyLock
BiyuHuang Nov 3, 2023
9392679
Update README.md
BiyuHuang May 13, 2022
c9800ff
Update README.md
BiyuHuang May 13, 2022
e2d37d9
Create codacy.yml
BiyuHuang May 18, 2022
64d92a3
Delete codacy.yml
BiyuHuang May 18, 2022
150428c
feat(scala-demo): add Arage Parser
BiyuHuang Nov 14, 2022
e7590b2
style(scala-demo): use log4j2.properties
BiyuHuang Dec 13, 2022
98415c0
feat(scala-demo): raft algorithm
BiyuHuang Dec 23, 2022
536275f
feat(scala-demo): raft algorithm
BiyuHuang Jan 12, 2023
71d2d31
feat(scala-demo): raft algorithm
BiyuHuang Jan 18, 2023
8f9c0a2
feat(scala-demo): raft algorithm
BiyuHuang Jan 18, 2023
5327387
feat(scala-demo): raft algorithm
BiyuHuang Jan 31, 2023
46f89b5
feat(scala-demo): add leader election base on zookeeper
BiyuHuang Feb 3, 2023
5338c36
feat(scala-demo): add round-robin service
BiyuHuang Apr 24, 2023
04ba4a1
Update AlgDemo.scala
BiyuHuang May 24, 2023
2ad1ac7
Create LinkedList.scala
BiyuHuang May 25, 2023
f8ea0e3
Update LinkedList.scala
BiyuHuang Jun 1, 2023
cf1490a
feat(scala-demo): add TrieTree
BiyuHuang Jun 2, 2023
7c81065
feat(scala-demo): update TrieTree
BiyuHuang Jun 2, 2023
0a58324
feat(scala-demo): update TrieTree
BiyuHuang Jun 5, 2023
2374b9a
feat(scala-demo): update TrieTree
BiyuHuang Jun 5, 2023
2227b39
feat(scala-demo): add bit filter
BiyuHuang Jun 13, 2023
11f071f
feat(scala-demo): update bit filter
BiyuHuang Jun 13, 2023
e2345d0
[add] add flink demo
BiyuHuang Jul 27, 2023
4816095
[update] mock more events
BiyuHuang Jul 27, 2023
7ad6bc2
[update] add new mock events
BiyuHuang Jul 27, 2023
e57ad8c
Update FlinkCEPDemo.scala
BiyuHuang Aug 8, 2023
ef8a999
Update log4j2.properties
BiyuHuang Aug 18, 2023
742feeb
Update log4j2.properties
BiyuHuang Aug 18, 2023
e2a957f
add AkkaClusterSystem
BiyuHuang Nov 1, 2023
0bf2c4c
add RowKeyLock
BiyuHuang Nov 3, 2023
f246d72
Update pom.xml
BiyuHuang Mar 12, 2024
84a3086
Update pom.xml
BiyuHuang Mar 12, 2024
c1ee8a8
add observer mode(newsdemo)
BiyuHuang Apr 8, 2024
bb0d481
add lockmap
BiyuHuang Apr 12, 2024
fcedf76
Update .gitignore
BiyuHuang Apr 22, 2024
b26b6f8
add stringToHash/BitMap
BiyuHuang May 9, 2024
db902b8
update patterns
BiyuHuang May 13, 2024
b4820cc
add iterator pattern
BiyuHuang May 13, 2024
37fa2bf
ADD config storage
BiyuHuang Jul 24, 2024
f35102c
update
BiyuHuang Sep 19, 2024
3325721
Create MySqlParser.scala
BiyuHuang Oct 22, 2024
892f99a
Create MySqlParserUnitSpec.scala
BiyuHuang Oct 22, 2024
3667931
udpate mysql parser
BiyuHuang Oct 22, 2024
13b2e1d
add xgboostdemo.scala
BiyuHuang Jan 8, 2025
66800e3
update xgboostdemo.scala
BiyuHuang Jan 10, 2025
cffebe9
update xgboostdemo.scala
BiyuHuang Jan 10, 2025
8388710
update xgboostdemo.scala
BiyuHuang Jan 16, 2025
7f14900
Update .gitignore
BiyuHuang Jan 22, 2025
40ec4a9
[update] update pom and add DemoExpression.scala
BiyuHuang Feb 19, 2025
794223a
update log4j2 framework
BiyuHuang Feb 19, 2025
59d4e95
Update RddDemo.scala
BiyuHuang Mar 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Empty file modified .github/workflows/scala.yml
100644 → 100755
Empty file.
4 changes: 4 additions & 0 deletions .gitignore
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ temp/
resources/test/
demo/ScalaDemo/.DS_Store
dependency-reduced-pom.xml
test/
.vscode/
.metals/
.bloop/
Empty file modified .travis.yml
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified bin/run.sh
100644 → 100755
Empty file.
Empty file modified codecov.yml
100644 → 100755
Empty file.
Empty file modified conf/test.conf
100644 → 100755
Empty file.
22 changes: 0 additions & 22 deletions demo/DataLoader/pom.xml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,6 @@
<artifactId>scala-logging_${scala.binary.version}</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>

<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_${scala.binary.version}</artifactId>
Expand Down Expand Up @@ -216,13 +201,6 @@
<artifactId>ganymed-ssh2</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<!-- <scope>test</scope> -->
</dependency>

<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
Expand Down
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions demo/DataLoader/src/main/resources/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Console logger
appender.console.type=Console
appender.console.name=STDOUT
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d{yy/MM/dd HH:mm:ss} %p %c{1}: %m%n
appender.console.filter.threshold.type=ThresholdFilter
appender.console.filter.threshold.level=DEBUG

# configure logger
rootLogger=INFO,STDOUT


103 changes: 0 additions & 103 deletions demo/DataLoader/src/main/resources/logback.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,22 @@ object DataLoader extends LogSupport {
}
} catch {
case e: ReflectiveOperationException =>
log.warn("Failed to register optional signal handler that logs a message when the process is terminated " +
s"by a signal. Reason for registration failure is: $e", e)
logger.warn("Failed to register optional signal handler that logs a message " +
"when the process is terminated by a signal. " +
"Reason for registration failure is: $e", e)
}

// attach shutdown handler to catch terminating signals as well as normal termination
Runtime.getRuntime.addShutdownHook(new Thread("dataloader-shutdown-hook") {
override def run(): Unit = DataLoaderServer.shutdown()
})

logger.info("Starting DataLoaderServer...")
DataLoaderServer.startup()
DataLoaderServer.awaitShutdown()
} catch {
case NonFatal(e) =>
log.error("Failed to run DataLoader", e)
logger.error("Failed to run DataLoader", e)
System.exit(1)
}
System.exit(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.hackerforfuture.codeprototypes.dataloader.clusters

/**
* Author: biyu.huang
* Date: 2023/11/2 11:30
* Description:
*/
trait EventHandler {

def handleHeartbeatEvent(): Unit

def handleRegisterEvent(): Unit

def handleStopEvent(): Unit

def handleRegisterTimeout(): Unit

def handelCheckHeartbeatEvent(): Unit
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.hackerforfuture.codeprototypes.dataloader.clusters

import akka.actor.ActorPath

/**
* Author: biyu.huang
* Date: 2023/11/1 19:06
* Description:
*/
sealed trait Message

case object Heartbeat extends Message

case object CheckHeartbeat extends Message

case object Register extends Message

case object RegisterTimeout extends Message

// 自定义消息类型,带有唯一标识ID
case class CustomMessage(id: ActorPath, content: Any) extends Message

case class SlaveActorTerminated(id: ActorPath, reason: String) extends Message

case object StopActor extends Message
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.hackerforfuture.codeprototypes.dataloader.clusters.master

import akka.actor.{Actor, ActorLogging, ActorPath, Props, Terminated}
import com.hackerforfuture.codeprototypes.dataloader.clusters._
import com.hackerforfuture.codeprototypes.dataloader.common.Using

import scala.collection.mutable
import scala.concurrent.duration._

/**
* Author: biyu.huang
* Date: 2023/11/1 17:15
* Description:
*/
object MasterActor {
def props: Props = Props[MasterActor]
}

class MasterActor extends Actor with ActorLogging with EventHandler with Using {
// 存储已注册的SlaveActor的唯一标识ID和最后一次收到心跳的时间戳
private final val registeredSlaves = mutable.HashMap.empty[ActorPath, Long]

// 心跳超时时间
private final val heartbeatTimeout: FiniteDuration = 10.seconds

private final val initialTimeout: FiniteDuration = 5.seconds

// 启动时设置定时器
override def preStart(): Unit = {
// context.setReceiveTimeout(initialTimeout)

import context.dispatcher
context
.system
.scheduler
.schedule(initialTimeout, heartbeatTimeout, self, CheckHeartbeat)
}

override def handleHeartbeatEvent(): Unit = {
syncableBlock {
val senderId: ActorPath = sender().path
val ts: Long = System.currentTimeMillis()
if (registeredSlaves.contains(senderId)) {
registeredSlaves.put(senderId, ts)
log.info(s"[%s] Received heartbeat from slave: ${senderId.name}".format(ts))
} else {
registeredSlaves.put(senderId, ts)
log.info(s"[%s] Registered slave: ${senderId.name}".format(ts))
context.watch(sender())
}
}
}

override def handleRegisterEvent(): Unit = handleHeartbeatEvent()

override def handelCheckHeartbeatEvent(): Unit = {
val currentTime: Long = System.currentTimeMillis()
val timedOutSlaves = registeredSlaves.filter {
case (_, lastHeartbeatTime) =>
val elapsed = currentTime - lastHeartbeatTime
elapsed > (heartbeatTimeout.toMillis * 10)
}

timedOutSlaves.keys.foreach { id =>
registeredSlaves -= id
log.warning(s"Slave $id timed out and unregistered.")
self ! SlaveActorTerminated(id, "No heartbeat received")
}
}

override def handleStopEvent(): Unit = {
log.info("received StopActor message, shutting down ...")
registeredSlaves.foreach {
case (id, _) =>
log.info("try to stop %s".format(id.name))
context.system.actorSelection(id) ! StopActor
}
registeredSlaves.clear()
context.stop(self)
}

def receive: Receive = {
case Heartbeat => handleHeartbeatEvent()
case Register => handleRegisterEvent()
case CheckHeartbeat => handelCheckHeartbeatEvent()
case StopActor => handleStopEvent()
case CustomMessage(id, content) =>
if (registeredSlaves.contains(id)) {
log.info(s"Processing message from slave $id: $content")
// 处理消息逻辑
} else {
log.warning(s"Received message from unregistered slave: $id")
context.system.actorSelection(id) ! RegisterTimeout
}
case SlaveActorTerminated(id, reason) =>
log.warning(s"Slave $id terminated and unregistered. Reason: $reason")
registeredSlaves.remove(id)
case Terminated(slave) =>
val slaveId = slave.path
registeredSlaves.remove(slaveId)
log.warning(s"Slave ${slaveId.name} terminated.")
}

override def handleRegisterTimeout(): Unit = {}
}
Empty file.
Empty file.
Empty file.
Loading