Fix for jdk 1.8

This commit is contained in:
Remi Boure 2023-03-31 10:01:11 +02:00
parent df77238cc9
commit 9936d4f1b9
2 changed files with 27 additions and 20 deletions

View File

@ -12,6 +12,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class Main { public class Main {
@ -52,27 +53,33 @@ public class Main {
}); });
Cell.setTimeSlotNb(timeSlotNb); Cell.setTimeSlotNb(timeSlotNb);
Cell.setSubCarrierNb(subCarrierNb); Cell.setSubCarrierNb(subCarrierNb);
try(ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())) { ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
for(int i = 2; i <= maximumLoad; i += 2) { for(int i = 2; i <= maximumLoad; i += 2) {
List<User> users = generateUsers(i, timeSlotNb, subCarrierNb); List<User> users = generateUsers(i, timeSlotNb, subCarrierNb);
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb]; ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
//TODO : changes schedulers //TODO : changes schedulers
Scheduler schedulerCell1 = new RoundRobin(frame, users); Scheduler schedulerCell1 = new RoundRobin(frame, users);
Scheduler schedulerCell2 = new RoundRobin(frame, users); Scheduler schedulerCell2 = new RoundRobin(frame, users);
try{ try{
FileOutputStream output = new FileOutputStream("export" + File.separator + users.size() + ".csv", true); FileOutputStream output = new FileOutputStream("export" + File.separator + users.size() + ".csv", true);
output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes()); output.write("tick;x;y;user;bandwidth;delay;cell;\n".getBytes());
Cell cell1 = new Cell(0, schedulerCell1, frame, users, output); Cell cell1 = new Cell(0, schedulerCell1, frame, users, output);
Cell cell2 = new Cell(1, schedulerCell2, frame, users, output); Cell cell2 = new Cell(1, schedulerCell2, frame, users, output);
AccessPoint accessPoint = new AccessPoint(cell1, cell2); AccessPoint accessPoint = new AccessPoint(cell1, cell2);
executor.submit(() -> accessPoint.startSimulation(numberOfTicks, users)); executor.submit(() -> accessPoint.startSimulation(numberOfTicks, users));
} catch(IOException e) { } catch(IOException e) {
System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage()); System.err.println(e.getClass().getSimpleName() + " : " + e.getMessage());
System.exit(1); System.exit(1);
}
} }
} }
executor.shutdown();
try {
executor.awaitTermination(2, TimeUnit.MINUTES);
} catch (InterruptedException e) {
e.printStackTrace();
}
executor.shutdownNow();
} else { } else {
System.err.println("Please give launch arguments"); System.err.println("Please give launch arguments");
System.err.println("gradle run --args=\"<number of ticks> <number of users>\""); System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");

View File

@ -45,9 +45,9 @@ public class User {
public void createPackets(int m, int ticks) { public void createPackets(int m, int ticks) {
timeInterval--; timeInterval--;
if(timeInterval == 0) { if(timeInterval == 0) {
timeInterval = random.nextInt(50, 101); timeInterval = 50 + random.nextInt(51);
// On tire un nombre entre 0 et 2 * m // On tire un nombre entre 0 et 2 * m
mbis = random.nextInt(1, 2 * m + 1) ; mbis = 1 + random.nextInt(2 * m + 1) ;
} }
// On calcule le nombre de paquets qu'on peut transmettre // On calcule le nombre de paquets qu'on peut transmettre