Skip to content
Closed
Prev Previous commit
Next Next commit
fixed
  • Loading branch information
Wessam100 committed Dec 7, 2024
commit 61e92bb3955cb76205ffe46a9fc4dfb8651e5065
34 changes: 34 additions & 0 deletions FiniteStateMachine/etc/FiniteStateMachine.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@startuml
package com.iluwatar.trafficlight {
class GreenLightState {
+ GreenLightState()
+ handleEvent(context : TrafficLightContext)
}
class RedLightState {
+ RedLightState()
+ handleEvent(context : TrafficLightContext)
}
class TrafficLightContext {
- currentState : TrafficLightState
+ TrafficLightContext(initialState : TrafficLightState)
+ getCurrentState() : TrafficLightState
+ handleEvent()
+ setState(newState : TrafficLightState)
}
class TrafficLightFsm {
+ TrafficLightFsm()
+ main(args : String[]) {static}
}
interface TrafficLightState {
+ handleEvent(TrafficLightContext) {abstract}
}
class YellowLightState {
+ YellowLightState()
+ handleEvent(context : TrafficLightContext)
}
}
TrafficLightContext --> "-currentState" TrafficLightState
GreenLightState ..|> TrafficLightState
RedLightState ..|> TrafficLightState
YellowLightState ..|> TrafficLightState
@enduml
9 changes: 7 additions & 2 deletions FiniteStateMachine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
</properties>
Comment on lines +13 to +17
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from parent pom.xml and can be left out

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
12 changes: 12 additions & 0 deletions function-composition/etc/function-composition.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@startuml
package com.iluwatar.function.composition {
class App {
+ App()
+ main(args : String[]) {static}
}
class FunctionComposer {
+ FunctionComposer()
+ composeFunctions(f1 : Function<Integer, Integer>, f2 : Function<Integer, Integer>) : Function<Integer, Integer> {static}
}
}
@enduml
2 changes: 2 additions & 0 deletions marker-interface/etc/marker-interface.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@startuml
@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@startuml
@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@startuml
package com.iluwatar.idempotentconsumer {
class App {
- LOGGER : Logger {static}
+ App()
+ main(args : String[]) {static}
+ run(requestService : RequestService, requestRepository : RequestRepository) : CommandLineRunner
}
class Request {
- status : Status
- uuid : UUID
+ Request()
+ Request(uuid : UUID)
+ Request(uuid : UUID, status : Status)
# canEqual(other : Object) : boolean
+ equals(o : Object) : boolean
+ getStatus() : Status
+ getUuid() : UUID
+ hashCode() : int
+ setStatus(status : Status)
+ setUuid(uuid : UUID)
+ toString() : String
}
~enum Status {
+ COMPLETED {static}
+ PENDING {static}
+ STARTED {static}
+ valueOf(name : String) : Status {static}
+ values() : Status[] {static}
}
interface RequestRepository {
}
class RequestService {
~ requestRepository : RequestRepository
~ requestStateMachine : RequestStateMachine
+ RequestService(requestRepository : RequestRepository, requestStateMachine : RequestStateMachine)
+ complete(uuid : UUID) : Request
+ create(uuid : UUID) : Request
+ start(uuid : UUID) : Request
}
class RequestStateMachine {
+ RequestStateMachine()
+ next(req : Request, nextStatus : Status) : Request
}
}
RequestService --> "-requestRepository" RequestRepository
Request --> "-status" Status
RequestService --> "-requestStateMachine" RequestStateMachine
@enduml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@startuml
package com.iluwatar.logaggregation {
class App {
+ App()
+ main(args : String[]) {static}
}
class CentralLogStore {
- LOGGER : Logger {static}
- logs : ConcurrentLinkedQueue<LogEntry>
+ CentralLogStore()
+ displayLogs()
+ storeLog(logEntry : LogEntry)
}
class LogAggregator {
- BUFFER_THRESHOLD : int {static}
- LOGGER : Logger {static}
- buffer : ConcurrentLinkedQueue<LogEntry>
- centralLogStore : CentralLogStore
- executorService : ExecutorService
- logCount : AtomicInteger
- minLogLevel : LogLevel
+ LogAggregator(centralLogStore : CentralLogStore, minLogLevel : LogLevel)
+ collectLog(logEntry : LogEntry)
- flushBuffer()
- startBufferFlusher()
+ stop()
}
class LogEntry {
- level : LogLevel
- message : String
- serviceName : String
- timestamp : LocalDateTime
+ LogEntry(serviceName : String, level : LogLevel, message : String, timestamp : LocalDateTime)
# canEqual(other : Object) : boolean
+ equals(o : Object) : boolean
+ getLevel() : LogLevel
+ getMessage() : String
+ getServiceName() : String
+ getTimestamp() : LocalDateTime
+ hashCode() : int
+ setLevel(level : LogLevel)
+ setMessage(message : String)
+ setServiceName(serviceName : String)
+ setTimestamp(timestamp : LocalDateTime)
+ toString() : String
}
enum LogLevel {
+ DEBUG {static}
+ ERROR {static}
+ INFO {static}
+ valueOf(name : String) : LogLevel {static}
+ values() : LogLevel[] {static}
}
class LogProducer {
- LOGGER : Logger {static}
- aggregator : LogAggregator
- serviceName : String
+ LogProducer(serviceName : String, aggregator : LogAggregator)
+ generateLog(level : LogLevel, message : String)
}
}
LogAggregator --> "-centralLogStore" CentralLogStore
LogEntry --> "-level" LogLevel
CentralLogStore --> "-logs" LogEntry
LogAggregator --> "-buffer" LogEntry
LogAggregator --> "-minLogLevel" LogLevel
LogProducer --> "-aggregator" LogAggregator
@enduml
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
<module>function-composition</module>
<module>microservices-distributed-tracing</module>
<module>microservices-idempotent-consumer</module>
<module>FiniteStateMachine</module>
<module>FiniteStateMachine</module>
</modules>
<repositories>
<repository>
Expand Down
44 changes: 44 additions & 0 deletions queue-based-load-leveling/etc/queue-based-load-leveling.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@startuml
package com.iluwatar.queue.load.leveling {
class App {
- LOGGER : Logger {static}
- SHUTDOWN_TIME : int {static}
+ App()
+ main(args : String[]) {static}
}
class Message {
- msg : String
+ Message(msg : String)
+ getMsg() : String
+ toString() : String
}
class MessageQueue {
- LOGGER : Logger {static}
- blkQueue : BlockingQueue<Message>
+ MessageQueue()
+ retrieveMsg() : Message
+ submitMsg(msg : Message)
}
class ServiceExecutor {
- LOGGER : Logger {static}
- msgQueue : MessageQueue
+ ServiceExecutor(msgQueue : MessageQueue)
+ run()
}
interface Task {
+ submit(Message) {abstract}
}
class TaskGenerator {
- LOGGER : Logger {static}
- msgCount : int
- msgQueue : MessageQueue
+ TaskGenerator(msgQueue : MessageQueue, msgCount : int)
+ run()
+ submit(msg : Message)
}
}
MessageQueue --> "-blkQueue" Message
ServiceExecutor --> "-msgQueue" MessageQueue
TaskGenerator --> "-msgQueue" MessageQueue
TaskGenerator ..|> Task
@enduml
26 changes: 26 additions & 0 deletions virtual-proxy/etc/virtual-proxy.urm.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@startuml
package com.iluwatar.virtual.proxy {
class App {
+ App()
+ main(args : String[]) {static}
}
interface ExpensiveObject {
+ process() {abstract}
}
class RealVideoObject {
- LOGGER : Logger {static}
+ RealVideoObject()
- heavyInitialConfiguration()
+ process()
}
class VideoObjectProxy {
- realVideoObject : RealVideoObject
+ VideoObjectProxy()
+ getRealVideoObject() : RealVideoObject
+ process()
}
}
VideoObjectProxy --> "-realVideoObject" RealVideoObject
RealVideoObject ..|> ExpensiveObject
VideoObjectProxy ..|> ExpensiveObject
@enduml