Commit 54d6d1f5 authored by yazan.halloul's avatar yazan.halloul

Final commit

parent 1ee535dc
...@@ -7,6 +7,20 @@ ...@@ -7,6 +7,20 @@
<groupId>org.example</groupId> <groupId>org.example</groupId>
<artifactId>HW2</artifactId> <artifactId>HW2</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties> <properties>
<maven.compiler.source>17</maven.compiler.source> <maven.compiler.source>17</maven.compiler.source>
......
...@@ -3,18 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; ...@@ -3,18 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import data.RangeArrayBuilder; import data.RangeArrayBuilder;
import parallelCounters.*; import parallelCounters.*;
//import parallelsummers.ParallelSummer2;
/**
* This projects is indented to show different ways of parallel programming in java
* in terms of
* # designing workers
* # executing them
* # getting and combining the results
*
* @author Ahmet Cengizhan Dirican
*/
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
int start = 0; int start = 0;
......
import primeChecker.PrimeChecker; import primeChecker.PrimeChecker;
/**
* This class provides a method to sequentially calculate the sum of an array.
*
* @author Ahmet Cengizhan Dirican
*/
public class SequentialCounter { public class SequentialCounter {
/**
* Returns the sum of all the element of a given array.
* @param data the integer array
* @return the sum
*/
static PrimeChecker primeChecker = new PrimeChecker(); static PrimeChecker primeChecker = new PrimeChecker();
public static long findPrimeNumbers(int[] data) { public static long findPrimeNumbers(int[] data) {
......
package data; package data;
/**
* This class is to produce necessary test data.
*
* @author Ahmet Cengizhan Dirican
*/
public class RangeArrayBuilder { public class RangeArrayBuilder {
public static int[] create(int start, int finish) { public static int[] create(int start, int finish) {
......
...@@ -7,13 +7,6 @@ import java.util.List; ...@@ -7,13 +7,6 @@ import java.util.List;
import primeCounters.PrimeCounterThread; import primeCounters.PrimeCounterThread;
import worker.WorkPartitioner; import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterThread} and conventional thread
* start and join mechanisms.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter0 { public class ParallelCounter0 {
public static long findPrimeNumbers(int[] data, int threadCount) { public static long findPrimeNumbers(int[] data, int threadCount) {
......
...@@ -5,13 +5,6 @@ import java.util.List; ...@@ -5,13 +5,6 @@ import java.util.List;
import primeCounters.PrimeCounterRunnable; import primeCounters.PrimeCounterRunnable;
import worker.WorkPartitioner; import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterRunnable} and conventional thread
* start and join mechanisms placed into {@link PrimeCounterRunnable}.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter1 { public class ParallelCounter1 {
public static long findPrimeNumbers(int[] data, int threadCount) { public static long findPrimeNumbers(int[] data, int threadCount) {
......
...@@ -9,12 +9,6 @@ import java.util.concurrent.Executors; ...@@ -9,12 +9,6 @@ import java.util.concurrent.Executors;
import primeCounters.PrimeCounterThread; import primeCounters.PrimeCounterThread;
import worker.WorkPartitioner; import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterThread} and {@link ExecutorService}
* with a fixed thread pool. The class executes the threads one bye one.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter2 { public class ParallelCounter2 {
public static long findPrimeNumbers(int[] data, int threadCount) { public static long findPrimeNumbers(int[] data, int threadCount) {
......
...@@ -9,14 +9,6 @@ import java.util.concurrent.Future; ...@@ -9,14 +9,6 @@ import java.util.concurrent.Future;
import primeCounters.PrimeCounterCallable; import primeCounters.PrimeCounterCallable;
import worker.WorkPartitioner; import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterCallable} and {@link ExecutorService}
* with a fixed thread pool. The class invokes all the callables at once.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter3 { public class ParallelCounter3 {
public static long findPrimeNumbers(int[] data, int threadCount) { public static long findPrimeNumbers(int[] data, int threadCount) {
......
...@@ -8,14 +8,7 @@ import java.util.concurrent.Future; ...@@ -8,14 +8,7 @@ import java.util.concurrent.Future;
import primeCounters.PrimeCounterCallable; import primeCounters.PrimeCounterCallable;
import primeCounters.PrimeCounterThread; import primeCounters.PrimeCounterThread;
import worker.WorkPartitioner; import worker.WorkPartitioner;
/**
* This class calculates the sum of an array using {@link PrimeCounterThread} and {@link ExecutorService}
* with a fixed thread pool. The class submits the threads one bye one for executions.
*
* @author Ahmet Cengizhan Dirican
*/
public class ParallelCounter4 { public class ParallelCounter4 {
public static long findPrimeNumbers(int[] data, int threadCount) { public static long findPrimeNumbers(int[] data, int threadCount) {
......
...@@ -3,11 +3,6 @@ package primeCounters; ...@@ -3,11 +3,6 @@ package primeCounters;
import worker.WorkPartitioner.Part; import worker.WorkPartitioner.Part;
import worker.Worker; import worker.Worker;
/**
* Base summer/worker class to calculate the sum of an array.
*
* @author Ahmet Cengizhan Dirican
*/
public class PrimeCounter extends Worker { public class PrimeCounter extends Worker {
protected long numberOfPrimeNumbers; protected long numberOfPrimeNumbers;
public PrimeCounter(int[] data, Part part) { public PrimeCounter(int[] data, Part part) {
......
...@@ -4,12 +4,6 @@ import java.util.concurrent.Callable; ...@@ -4,12 +4,6 @@ import java.util.concurrent.Callable;
import primeChecker.PrimeChecker; import primeChecker.PrimeChecker;
import worker.WorkPartitioner.Part; import worker.WorkPartitioner.Part;
/**
* {@link Callable} based {@link PrimeCounter ).
*
* @author Ahmet Cengizhan Dirican
* @see https://github.com/acdirican
*/
public class PrimeCounterCallable extends PrimeCounter implements Callable<Long> { public class PrimeCounterCallable extends PrimeCounter implements Callable<Long> {
PrimeChecker primeChecker = new PrimeChecker(); PrimeChecker primeChecker = new PrimeChecker();
......
...@@ -3,12 +3,6 @@ package primeCounters; ...@@ -3,12 +3,6 @@ package primeCounters;
import primeChecker.PrimeChecker; import primeChecker.PrimeChecker;
import worker.WorkPartitioner.Part; import worker.WorkPartitioner.Part;
/**
* {@link Runnable} based {@link PrimeCounter ).
*
* @author Ahmet Cengizhan Dirican
* @see https://github.com/acdirican
*/
public class PrimeCounterRunnable extends PrimeCounter implements Runnable{ public class PrimeCounterRunnable extends PrimeCounter implements Runnable{
PrimeChecker primeChecker = new PrimeChecker(); PrimeChecker primeChecker = new PrimeChecker();
......
...@@ -3,12 +3,6 @@ package primeCounters; ...@@ -3,12 +3,6 @@ package primeCounters;
import primeChecker.PrimeChecker; import primeChecker.PrimeChecker;
import worker.WorkPartitioner.Part; import worker.WorkPartitioner.Part;
/**
* {@link Thread} based summer/worker Because this class cannot extends the {@link PrimeCounter},
* it had to include the similar code.
*
* @author Ahmet Cengizhan Dirican
*/
public class PrimeCounterThread extends Thread{ public class PrimeCounterThread extends Thread{
PrimeChecker primeChecker = new PrimeChecker(); PrimeChecker primeChecker = new PrimeChecker();
......
...@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test; ...@@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test;
import parallelCounters.*; import parallelCounters.*;
class ParallelCountersTest { class ParallelCountersTest {
private static int start; private static int start;s
private static int finish; private static int finish;
private static int[] data; private static int[] data;
private static long result; private static long result;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment