Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Distributed Number Analyzer (Java RMI)

A distributed Master–Worker system that analyzes numbers in parallel using Java RMI.

The Master splits a numeric range into smaller tasks and submits them to a shared Task Bag (an RMI remote object). Multiple Worker processes connect to the Task Bag, pick up tasks, compute results, and send their findings back. The Master then aggregates all results and prints the final list of numbers.

Currently supported categories:

  • Prime numbers
  • Even numbers
  • Odd numbers
  • Natural numbers

Features

  • Master–Worker architecture using Java RMI
  • Shared Task Bag implemented as a remote object
  • Parallel processing with multiple Worker processes
  • Configurable:
    • MAX – upper bound of the number range
    • GRANULARITY – batch size
    • CATEGORY – PRIME / EVEN / ODD / NATURAL
  • Thread-safe task queue and result storage

Architecture

Components

  • NumberCategory – enum defining the type of numbers to collect
  • NumberTask – serializable task describing a numeric range and category
  • TaskBag – RMI remote interface that exposes operations for:
    • Submitting tasks
    • Taking tasks
    • Submitting results
    • Reading aggregated results
  • TaskBagImpl – implementation of TaskBag, running as an RMI server
  • Master – CLI process that:
    • Reads user input (MAX, GRANULARITY, CATEGORY)
    • Splits the range into tasks
    • Submits tasks to the TaskBag
    • Waits for completion and prints final results
  • Worker – CLI process that:
    • Repeatedly takes one task from the TaskBag
    • Processes the numbers in its range
    • Sends back the filtered numbers (based on category)
    • Exits once no tasks remain

Data flow

  1. Master asks the user for MAX, GRANULARITY, and desired CATEGORY.
  2. Master creates NumberTask objects for ranges like [0..9], [10..19], etc., and calls submitTask(...) on the TaskBag.
  3. Each Worker calls takeTask():
    • If a task exists, it processes that range and calls submitResult(...).
    • If no tasks remain, the Worker exits.
  4. Master periodically checks getCompletedTasks() vs getTotalTasks().
  5. Once all tasks are done (or timeout reached), Master calls getResults(category) and prints the combined list.

How to Run Locally

Requirements:

  • Java 8+
  • javac and java available on your PATH

1. Compile

From the project root:

javac -d bin src/com/elvis/numberanalyzer/*.java

About

Distributed Master–Worker system for parallel number analysis using Java RMI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages