GithubHelp home page GithubHelp logo

jrmsamson / file-process-concurrently Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 109 KB

Simple java application to process a log file concurrently.

Java 100.00%
java-8 logback hsqldb gradle mockito junit jooq hikaricp powermock jackson-json commons-io

file-process-concurrently's Introduction

file-process-concurrently

Simple java application to process a log file concurrently.

The file should have the following format:

{"id":"scsmbstgra", "state":"STARTED", "type":"APPLICATION_LOG", "host":"12345", "timestamp":1491377495212}
{"id":"scsmbstgrb", "state":"STARTED", "timestamp":1491377495213}
{"id":"scsmbstgrc", "state":"FINISHED", "timestamp":1491377495218}
{"id":"scsmbstgra", "state":"FINISHED", "type":"APPLICATION_LOG", "host":"12345", "timestamp":1491377495217}
{"id":"scsmbstgrc", "state":"STARTED", "timestamp":1491377495210}
{"id":"scsmbstgrb", "state":"FINISHED", "timestamp":1491377495216}

Every line in the file is a JSON object containing event data:

  • id: the unique event identifier
  • state: whether the event was started or finished (can have values "STARTED" or "FINISHED" timestamp)
  • timestamp: the timestamp of the event in milliseconds
  • host: hostname (optional)
  • type: type of log (optional)

This log file is supposed to be created by a server which logs different events to it. Every event has 2 entries in a log:

  • one entry when the event was started
  • another when the event was finished.

The entries in a log file have no specific order (it can occur that a specific event is logged before the event starts)

In the example above, the event scsmbstgrb duration is 1401377495216 - 1491377495213 = 3ms The longest event is scsmbstgrc (1491377495218 - 1491377495210 = 8ms)

The application:

  • Takes the input file path as input argument
  • Flags any long events that take longer than 4ms with a column in the database called "alert" Write the found event details to file-based HSQLDB (http://hsqldb.org/) in the working folder
  • Creates a new table if necessary and enter the following values:
    • Event id
    • Event duration
    • Type and Host if applicable "alert" true is applicable

To test the application:

  • Build the jar file by executing: ./gradlew jar

  • The jar will be located in build/file-process-concurrently-1.0-SNAPSHOT.jar

  • execute the jar: java -jar build/file-process-concurrently-1.0-SNAPSHOT.jar filePath [numberOfThreads]

file-process-concurrently's People

Contributors

jrmsamson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.