2

I'm new to Java, I've been mostly a scripter. I recently started working at an all Java shop and have been investigating the architecture. I've encountered more than one project with a directory structure like this:

| src/
---| api/
---| app/
---| dal/
---| sal/
---| metrics/
---| worker/

API, app, metrics are pretty straightforward. API is the public interface, app is the product, metrics is for measurement. I event understand the DAL (data access layer?) and SAL (service access layer) to some extent, but not entirely.

Whats really throwing me off is this "Worker Layer". What is it for? I've read online the the Worker Pattern is meant to distribute a large load across a limited pool of computation resources. Still, how does it work? How does this layer interact with a larger system?

Please help me understand.

1
  • 4
    Have you asked the people on your team? Seems to me they're far more likely to know than a random on the Internet. Sep 29, 2016 at 18:28

1 Answer 1

3

I can't speak to the source code organization in your project. This is not some kind of official standard that I am aware of, but you have a lot of clues based on the folder naming. My guess here is that each of these folders contain the source code for a single independent module in a larger application. Each module may be built as a Jar, or perhaps a War or an Ear that contains other module Jars and libraries if necessary.

Worker may be for a module that follows something as sophisticated to a Master/Worker design pattern, or something potentially much more simple like a Batch program.

enter image description here

Source: http://docs.gigaspaces.com/sbp/master-worker-pattern.html

This graphic gives a general idea of what this might be for. Where other aspects of your application may be request/response based and transactional in nature, a number of long running jobs may need to execute where immediate user feedback is not required or necessary. Jobs can be broken down into Tasks, and Tasks are processed into Results by Workers. A Master process will queue up Tasks to be picked up, and fetch Results. The Master process may optionally compile multiple Results into new Tasks that need to be performed. This pattern is also well known as Map/Reduce.

On the simple side, a Worker process might just be a simple Java program that is executed to perform some specific work, where the result of the program might get picked up and used for a later batch process or used by users later in future reports and transactions with the system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.