Coder Social home page Coder Social logo

Comments (5)

harryle95 avatar harryle95 commented on September 26, 2024

Consider the following requirements:

  • Save data associated with Content-Server PUT
  • Data can be retrieved by client using Station ID
  • Data expires after 30s of inactivity or if not the last 20 most recent updates
  • Data can be backedup and restored if needed

from java_server.

harryle95 avatar harryle95 commented on September 26, 2024

Design:
Map<String, Map<String, Map<String, String>>> archive: file system storage (in memory)
Map[ContentServerID] = Map<FileName, Map<FieldName, String>

  • If PUT request for the same file -> overwrite previous file.
  • Fields:
    • Updated: whether an update to the main database using this data has completed succesfully
    • Deleted: boolean flag on whether the data should be removed
    • Content: body of a PUT request.

Map<String, String> database. Where the key is station ID and value is content

PriorityBlockingQueue taskQueue - task queue

LinkedList updateList -> list of updates

from java_server.

harryle95 avatar harryle95 commented on September 26, 2024

ExecutorService connRevPool = Executors.newCachedThreadPool();

Connection receive threadpool:

  • Retrieve request message -> Update TimeStamp
  • Classify - GET/PUT
  • Handle GET:
    • if empty -> Return empty body, do not submite to taskQueue
    • otherwise -> Submit to task Queue
  • Handle PUT: submit to task Queue
  • Get future from taskQueue submission.
  • Poll the future and send the result back to client

from java_server.

harryle95 avatar harryle95 commented on September 26, 2024

ThreadPoolExecutor executorPool = new .... // Only single thread executor. Use Priority queue

from java_server.

harryle95 avatar harryle95 commented on September 26, 2024

ScheduledExecutionService schedPool ... //Executed the following:

  • Run backup
  • Delete outdated files

from java_server.

Related Issues (20)

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.