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
@Component | |
class MessageListenerImpl( | |
@Autowired private val saveMessageUseCase: SaveMessageUseCase | |
): MessageListener { | |
private val logger: Logger = LoggerFactory.getLogger(this.javaClass) | |
@RabbitListener(queues = ["\${messages.processor.queue.name}"]) | |
override fun process(event: MessageEvent) { | |
logger.debug("operation=process, message='received MessageEvent {}'", event) |
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
@Repository | |
class MessageRepositoryImpl( | |
@Autowired private val jdbcTemplate: JdbcTemplate | |
): MessageRepository { | |
private val logger: Logger = LoggerFactory.getLogger(this.javaClass) | |
override fun save(entity: Message) { | |
val insertQuery = """ | |
INSERT INTO public.message(message_timestamp, message_value) |
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
interface MessageListener { | |
fun process(event: MessageEvent) | |
} |
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
interface MessageRepository { | |
fun save(entity: Message) | |
} |
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
@Component | |
class SaveMessageUseCase( | |
@Autowired private val repository: MessageRepository | |
): { | |
private val logger: Logger = LoggerFactory.getLogger(this.javaClass) | |
override fun execute(message: Message) { | |
logger.debug("operation=save, message='saving message {}'", message) | |
repository.save(message) |
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
data class Message( | |
val timestamp: OffsetDateTime, | |
val value: String | |
) |
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
$ time python most_common_combinations.py | |
[2] 10731 killed python3 most_common_combinations.py | |
python3 most_common_combinations.py 103,54s user 19,39s system 93% cpu 2:12,04 total | |
$ time ./most_common_combinations.py | |
./most_common_combinations.sh 162,86s user 24,32s system 113% cpu 2:44,33 total |
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
$ time python most_common_combinations.py | |
python3 most_common_combinations.py 13,45s user 1,62s system 99% cpu 15,072 total | |
$ time ./most_common_combinations.py | |
./most_common_combinations.sh 22,89s user 2,48s system 112% cpu 22,638 total |
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
tail -n +1 Dataset-Unicauca-Version2-87Atts.csv | |
| awk -F',' '{print $2, $3, $4, $5}' | |
| sort | |
| uniq -c | |
| sort -nr | |
| head -n 20 | |
> "processed_data_bash.tsv" |
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
import pandas as pd | |
pd.read_csv('Dataset-Unicauca-Version2-87Atts.csv', header = 0) | |
.groupby(['Source.IP', 'Source.Port', 'Destination.IP', 'Destination.Port']) | |
.size() | |
.sort_values(ascending=False)[:20] | |
.to_csv('processed_data_python.csv') |
NewerOlder