diff --git a/lab-02/by/Dzenia/docks_and_hobos/Controller/Model.java b/lab-02/by/Dzenia/docks_and_hobos/Controller/Model.java new file mode 100644 index 0000000..d5e6b92 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/Controller/Model.java @@ -0,0 +1,99 @@ +package by.Dzenia.docks_and_hobos.Controller; +import by.Dzenia.docks_and_hobos.Persons.Cargo; +import by.Dzenia.docks_and_hobos.Persons.Tunnel; +import by.Dzenia.docks_and_hobos.RunnableObjects.Dock; +import by.Dzenia.docks_and_hobos.RunnableObjects.Hobos; +import by.Dzenia.docks_and_hobos.RunnableObjects.ShipGenerator; +import org.json.JSONArray; +import org.json.JSONObject; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; +import java.util.stream.Collectors; + + +public class Model { + private final Tunnel tunnel; + private final Hobos hobos; + private final ShipGenerator shipGenerator; + private final ArrayList cargos; + private final ArrayList docks; + + public Model(Tunnel tunnel, Hobos hobos, ShipGenerator shipGenerator, ArrayList cargos, ArrayList docks) { + this.tunnel = tunnel; + this.hobos = hobos; + this.shipGenerator = shipGenerator; + this.cargos = cargos; + this.docks = docks; + } + + public Model(String pathToJson) throws IOException { + String jsonContent = new String(Files.readAllBytes(Paths.get(pathToJson))); + JSONObject jsonObject = new JSONObject(jsonContent); + JSONObject generatorJson = jsonObject.getJSONObject("generator"); + int generatingTime = Integer.parseInt(generatorJson.get("generating_time").toString()); + JSONObject ship = jsonObject.getJSONObject("ship"); + int shipCapacityMin = Integer.parseInt(ship.get("ship_capacity_min").toString()); + int shipCapacityMax = Integer.parseInt(ship.get("ship_capacity_max").toString()); + this.shipGenerator = new ShipGenerator(generatingTime, shipCapacityMin, shipCapacityMax, this); + JSONArray cargoTypes = (JSONArray) ship.get("cargo_types"); + cargos = new ArrayList<>(); + for (Object cargoType : cargoTypes) { + cargos.add(new Cargo(cargoType.toString())); + } + JSONObject tunnel = jsonObject.getJSONObject("tunnel"); + int maxShips = Integer.parseInt(tunnel.get("max_ships").toString()); + this.tunnel = new Tunnel(maxShips); + this.docks = new ArrayList<>(); + JSONArray docksArray = jsonObject.getJSONArray("docks"); + for (Object dockObject : docksArray) { + JSONObject dock = (JSONObject) dockObject; + int speed = Integer.parseInt(dock.get("unloading_speed").toString()); + JSONObject dockCapacity = dock.getJSONObject("dock_capacity"); + HashMap capacities = new HashMap<>(); + Map mp = dockCapacity.toMap(); + Set keys = dockCapacity.toMap().keySet(); + for (String cargoType: keys) { + capacities.put(cargoType, (Integer)mp.get(cargoType)); + } + docks.add(new Dock(speed, capacities, this)); + } + JSONObject hobosJson = jsonObject.getJSONObject("hobos"); + this.hobos = new Hobos(hobosJson.getJSONObject("ingredients_count") + .toMap() + .entrySet().stream() + .collect(Collectors.toMap( + Map.Entry::getKey, + entry -> (Integer)entry.getValue() + )), + hobosJson.getJSONObject("hobos_stealing_time") + .toMap() + .entrySet().stream() + .collect(Collectors.toMap( + Map.Entry::getKey, + entry -> (Integer)entry.getValue() + )), + (int)hobosJson.get("eating_time"), this); + } + + public Tunnel getTunnel() { + return tunnel; + } + + public Hobos getHobos() { + return hobos; + } + + public ShipGenerator getShipGenerator() { + return shipGenerator; + } + + public ArrayList getCargos() { + return cargos; + } + + public ArrayList getDocks() { + return docks; + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/Controller/Program.java b/lab-02/by/Dzenia/docks_and_hobos/Controller/Program.java new file mode 100644 index 0000000..1b0a67d --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/Controller/Program.java @@ -0,0 +1,34 @@ +package by.Dzenia.docks_and_hobos.Controller; +import by.Dzenia.docks_and_hobos.RunnableObjects.Dock; +import java.io.IOException; +import java.util.ArrayList; + +public class Program implements Runnable{ + private final Model model; + public Program(String pathToFile) throws IOException { + this.model = new Model(pathToFile); + } + + public void start() { + run(); + } + @Override + public void run() { + ArrayList threads = new ArrayList<>(); + threads.add(new Thread(model.getShipGenerator())); + for (Dock dock: model.getDocks()) { + threads.add(new Thread(dock)); + } + threads.add(new Thread(model.getHobos())); + for (Thread thread: threads) { + thread.start(); + } + for (Thread thread: threads) { + try { + thread.join(); + } catch (InterruptedException ignored) { + + } + } + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/CustomLogger.java b/lab-02/by/Dzenia/docks_and_hobos/CustomLogger.java new file mode 100644 index 0000000..46c4c55 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/CustomLogger.java @@ -0,0 +1,55 @@ +package by.Dzenia.docks_and_hobos; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.logging.*; + +public class CustomLogger extends Logger { + private static CustomLogger instance; + private static final int FILE_COUNT = 5; + private static final int MAX_FILE_SIZE_BYTES = 100_000; + protected CustomLogger(String name, String resourceBundleName) { + super(name, resourceBundleName); + } + public static CustomLogger getLogger(String name) { + if (instance == null) { + instance = new CustomLogger(name, null); + instance.configureLogger(); + } + return instance; + } + + private String getLogFileName() { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); + String timestamp = dateFormat.format(new Date()); + return "lab-02/by/Dzenia/docks_and_hobos/logs/log_" + timestamp + ".log"; + } + private void configureLogger() { + setLevel(Level.CONFIG); + try { + // Используем FileHandler с шаблоном времени для имени файла + String logFilePath = getLogFileName(); + FileHandler fileHandler = new FileHandler(logFilePath, MAX_FILE_SIZE_BYTES, FILE_COUNT, false); + fileHandler.setFormatter(new CustomFormatter()); + addHandler(fileHandler); + + ConsoleHandler consoleHandler = new ConsoleHandler(); + consoleHandler.setFormatter(new CustomFormatter()); + addHandler(consoleHandler); + } catch (IOException e) { + e.printStackTrace(); + } + } + + static class CustomFormatter extends Formatter { + private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + @Override + public String format(LogRecord record) { + return dateFormat.format(new Date(record.getMillis())) + + " " + + record.getLevel() + + " " + + record.getMessage() + "\n"; + } + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/Main.java b/lab-02/by/Dzenia/docks_and_hobos/Main.java new file mode 100644 index 0000000..58973e6 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/Main.java @@ -0,0 +1,15 @@ +package by.Dzenia.docks_and_hobos; +import by.Dzenia.docks_and_hobos.Controller.Program; +import java.io.IOException; +import java.util.logging.*; +public class Main { + private static final Logger logger = CustomLogger.getLogger("all"); + public static void main(String[] args) throws IOException { + if (args.length != 1) { + throw new IllegalArgumentException("Must be only one arg!"); + } + logger.log(Level.CONFIG, "Path=" + args[0]); + Program program = new Program(args[0]); + program.start(); + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/Persons/Cargo.java b/lab-02/by/Dzenia/docks_and_hobos/Persons/Cargo.java new file mode 100644 index 0000000..a8bb0f9 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/Persons/Cargo.java @@ -0,0 +1,13 @@ +package by.Dzenia.docks_and_hobos.Persons; + +public class Cargo { + private final String type; + + public Cargo(String type) { + this.type = type; + } + + public String getType() { + return type; + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/Persons/Ship.java b/lab-02/by/Dzenia/docks_and_hobos/Persons/Ship.java new file mode 100644 index 0000000..a0d02f4 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/Persons/Ship.java @@ -0,0 +1,19 @@ +package by.Dzenia.docks_and_hobos.Persons; + +public class Ship { + private final Cargo cargo; + private final int weight; + + public Ship(String cargoType, int weight) { + cargo = new Cargo(cargoType); + this.weight = weight; + } + + public Cargo getCargo() { + return cargo; + } + + public int getWeight() { + return weight; + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/Persons/Tunnel.java b/lab-02/by/Dzenia/docks_and_hobos/Persons/Tunnel.java new file mode 100644 index 0000000..f42d4c5 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/Persons/Tunnel.java @@ -0,0 +1,31 @@ +package by.Dzenia.docks_and_hobos.Persons; +import by.Dzenia.docks_and_hobos.CustomLogger; +import java.util.*; +import java.util.logging.Level; + +public class Tunnel { + + private final Queue queue = new LinkedList<>(); + private final int maxShips; + private final CustomLogger logger = CustomLogger.getLogger("all"); + + public Tunnel(int maxShips) { + this.maxShips = maxShips; + } + + public synchronized void addShip(Ship ship) { + if (queue.size() == maxShips) { + logger.log(Level.INFO, "Ship go down with cargo=" + ship.getCargo().getType() + ", weight=" + ship.getWeight()); + return; + } + queue.add(ship); + notify(); + } + + public synchronized Ship getShip() throws InterruptedException { + if (queue.isEmpty()) { + wait(); + } + return queue.remove(); + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/Dock.java b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/Dock.java new file mode 100644 index 0000000..2874b87 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/Dock.java @@ -0,0 +1,70 @@ +package by.Dzenia.docks_and_hobos.RunnableObjects; + +import by.Dzenia.docks_and_hobos.Controller.Model; +import by.Dzenia.docks_and_hobos.CustomLogger; +import by.Dzenia.docks_and_hobos.Persons.Ship; + +import java.util.HashMap; +import java.util.logging.Level; +import java.util.logging.Logger; + +import static java.lang.Math.max; +import static java.lang.Math.min; + +public class Dock implements Runnable { + private final HashMap dockCapacity; + private final HashMap currentWeight = new HashMap<>(); + private final Logger logger = CustomLogger.getLogger("all"); + private final int speed; + private final Model model; + + public Dock(int speed, HashMap dockCapacity, Model model) { + if (speed <= 0) { + throw new IllegalArgumentException("Speed should be positive"); + } + for (Integer capacity: dockCapacity.values()) { + if (capacity < 0) { + throw new IllegalArgumentException("Cargo capacity should be none negative"); + } + } + this.dockCapacity = dockCapacity; + this.speed = speed; + this.model = model; + for (String typeCargo: dockCapacity.keySet()) { + currentWeight.put(typeCargo, 0); + } + } + + public synchronized Integer stealCargo(String cargo, Integer count) { + if (!currentWeight.containsKey(cargo)) { + return 0; + } + Integer was = currentWeight.get(cargo); + currentWeight.put(cargo, max(was - count, 0)); + return was - currentWeight.get(cargo); + } + + + private void shipUnloading(Ship ship) throws InterruptedException { + logger.log(Level.INFO, "Ship come to dock cargo=" + ship.getCargo().getType() + ", weight=" + ship.getWeight()); + Thread.sleep((int)(ship.getWeight() / speed) * 1000); + synchronized (currentWeight) { + Integer weight = currentWeight.get(ship.getCargo().getType()); + currentWeight.put(ship.getCargo().getType(), min( + dockCapacity.get(ship.getCargo().getType()), + weight + (Integer) ship.getWeight() + )); + } + } + + @Override + public void run() { + while (true) { + try { + shipUnloading(model.getTunnel().getShip()); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/Hobos.java b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/Hobos.java new file mode 100644 index 0000000..34f2fe8 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/Hobos.java @@ -0,0 +1,118 @@ +package by.Dzenia.docks_and_hobos.RunnableObjects; +import by.Dzenia.docks_and_hobos.Controller.Model; +import by.Dzenia.docks_and_hobos.CustomLogger; +import by.Dzenia.docks_and_hobos.RunnableObjects.StealingStrategy.StealingStrategy; +import by.Dzenia.docks_and_hobos.RunnableObjects.StealingStrategy.StealingStrategyHobByCargo; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class Hobos implements Runnable { + private final Model model; + private final Map ingredientsCount; + private final int eatingTime; + final List hobos = new ArrayList<>(); + private final Map current = new HashMap<>(); + private final Logger logger = CustomLogger.getLogger("all"); + private StealingStrategy stealingStrategy = new StealingStrategyHobByCargo(); + public Map getIngredientsCount() { + return ingredientsCount; + } + public int getEatingTime() { + return eatingTime; + } + public List getHobos() { + return hobos; + } + public Logger getLogger() { + return logger; + } + public Hobos(Map ingredientsCount, Map hobosTimesToSteal, int eatingTime, Model model) { + if (eatingTime < 0) { + throw new IllegalArgumentException("Eating time cannot be negative"); + } + if (!ingredientsCount.values().stream().allMatch(number -> number >= 0)) { + throw new IllegalArgumentException("Ingredient count cannot be negative"); + } + if (!hobosTimesToSteal.values().stream().allMatch(number -> number >= 0)) { + throw new IllegalArgumentException("Hobo time to steal cannot be negative"); + } + if (hobosTimesToSteal.values().size() <= 2) { + throw new IllegalArgumentException("Hobos group too little"); + } + for (String hoboName: hobosTimesToSteal.keySet()) { + hobos.add(new Hobo(hobosTimesToSteal.get(hoboName), hoboName)); + } + this.ingredientsCount = ingredientsCount; + this.eatingTime = eatingTime; + this.model = model; + } + public void setStealingStrategy(StealingStrategy stealingStrategy) { + this.stealingStrategy = stealingStrategy; + } + + @Override + public void run() { + while (true) { + for (String cargo: ingredientsCount.keySet()) { + current.put(cargo, 0); + } + stealingStrategy.goStealing(this); + logger.info("Hobos start eating"); + try { + Thread.sleep(eatingTime * 1000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + + } + public class Hobo implements Runnable { + private final int stealingSpeed; + private final String name; + private String cargoToSteal = null; + public Hobo(int stealingSpeed, String name) { + if (stealingSpeed <= 0) { + throw new IllegalArgumentException("Time to steal must be positive"); + } + this.stealingSpeed = stealingSpeed; + this.name = name; + } + public void setCargoToSteal(String cargoToSteal) { + this.cargoToSteal = cargoToSteal; + } + @Override + public void run() { + if (cargoToSteal == null) { + return; + } + int pos = 0; + logger.log(Level.INFO, name + " start stealing " + cargoToSteal); + long startTime = System.currentTimeMillis(); + while (true) { + Dock dock = model.getDocks().get(pos); + pos = (pos + 1) % model.getDocks().size(); + while (true) { + Integer stole = dock.stealCargo(cargoToSteal, stealingSpeed); + try { + Thread.sleep((long) ((1.0 * stole / stealingSpeed) * 1000)); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + synchronized (current) { + current.put(cargoToSteal, current.get(cargoToSteal) + stole); + if (current.get(cargoToSteal) > ingredientsCount.get(cargoToSteal)) { + long endTime = System.currentTimeMillis(); + logger.log(Level.INFO, name + " end stealing " + cargoToSteal + " time=" + + (endTime - startTime) / 1000 + "s"); + return; + } + } + if (stole == 0) { + break; + } + } + } + } + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/ShipGenerator.java b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/ShipGenerator.java new file mode 100644 index 0000000..2d7b135 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/ShipGenerator.java @@ -0,0 +1,49 @@ +package by.Dzenia.docks_and_hobos.RunnableObjects; +import by.Dzenia.docks_and_hobos.Controller.Model; +import by.Dzenia.docks_and_hobos.CustomLogger; +import by.Dzenia.docks_and_hobos.Persons.Ship; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ThreadLocalRandom; +import java.util.logging.Level; + +public class ShipGenerator implements Runnable { + private final int generationTime; + private final Timer timer; + private final int shipCapacityMin; + private final int shipCapacityMax; + private final Model model; + private final CustomLogger logger = CustomLogger.getLogger("all"); + + public ShipGenerator(int generationTime, int shipCapacityMin, int shipCapacityMax, Model model) { + if (generationTime <= 0) { + throw new IllegalArgumentException("Generation time must be positive"); + } + if (shipCapacityMin <= 0 || shipCapacityMax < shipCapacityMin) { + throw new IllegalArgumentException("Bounds of capacity is incorrect"); + } + this.generationTime = generationTime; + this.shipCapacityMin = shipCapacityMin; + this.shipCapacityMax = shipCapacityMax; + this.model = model; + this.timer = new Timer(); + } + + + @Override + public void run() { + TimerTask generateShip = new TimerTask() { + @Override + public void run() { + Ship ship = new Ship( + model.getCargos().get(ThreadLocalRandom.current().nextInt(0, model.getCargos().size())).getType(), + ThreadLocalRandom.current().nextInt(shipCapacityMin, shipCapacityMax + 1) + ); + logger.log(Level.INFO, "New ship with cargo=" + ship.getCargo().getType() + ", weight=" + ship.getWeight()); + model.getTunnel().addShip(ship); + } + }; + + timer.scheduleAtFixedRate(generateShip, 0, generationTime * 1000L); + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/StealingStrategy/StealingStrategy.java b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/StealingStrategy/StealingStrategy.java new file mode 100644 index 0000000..86fdc63 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/StealingStrategy/StealingStrategy.java @@ -0,0 +1,7 @@ +package by.Dzenia.docks_and_hobos.RunnableObjects.StealingStrategy; + +import by.Dzenia.docks_and_hobos.RunnableObjects.Hobos; + +public interface StealingStrategy { + void goStealing(Hobos hobos); +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/StealingStrategy/StealingStrategyHobByCargo.java b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/StealingStrategy/StealingStrategyHobByCargo.java new file mode 100644 index 0000000..30bd8e3 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/RunnableObjects/StealingStrategy/StealingStrategyHobByCargo.java @@ -0,0 +1,39 @@ +package by.Dzenia.docks_and_hobos.RunnableObjects.StealingStrategy; + +import by.Dzenia.docks_and_hobos.RunnableObjects.Hobos; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class StealingStrategyHobByCargo implements StealingStrategy { + + @Override + public void goStealing(Hobos hobos) { + List hoboList = hobos.getHobos(); + List ingredientsToSteal = new ArrayList<>(hobos.getIngredientsCount().keySet()); + Collections.shuffle(hoboList); + int count = 0; + while (count < ingredientsToSteal.size()) { + ArrayList hoboThreads = new ArrayList<>(); + for (int i = 2; i < hoboList.size(); ++i) { + hoboList.get(i).setCargoToSteal(ingredientsToSteal.get(count)); + count++; + hoboThreads.add(new Thread(hobos.getHobos().get(i))); + if (count >= ingredientsToSteal.size()) { + break; + } + } + for (Thread thread: hoboThreads) { + thread.start(); + } + for (Thread thread: hoboThreads) { + try { + thread.join(); + } catch (InterruptedException ignored) { + + } + } + } + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/config.json b/lab-02/by/Dzenia/docks_and_hobos/config.json new file mode 100644 index 0000000..3f09837 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/config.json @@ -0,0 +1,51 @@ +{ + "generator": { + "generating_time": 2 + }, + "ship": { + "ship_capacity_min": 10, + "ship_capacity_max": 20, + "cargo_types": [ + "bear", + "milk", + "pork" + ] + }, + "tunnel": { + "max_ships": 4 + }, + "docks": [ + { + "unloading_speed": 3, + "dock_capacity": { + "bear": 50, + "milk": 30, + "pork": 70 + } + }, + { + "unloading_speed": 4, + "dock_capacity": { + "bear": 40, + "milk": 25, + "pork": 60 + } + } + ], + "hobos": { + "ingredients_count": + { + "bear": 2, + "milk": 1, + "pork": 3 + }, + "eating_time": 5, + "hobos_stealing_time": + { + "BB": 1, + "Larson": 2, + "Steve": 1, + "Ramzes": 3 + } + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/config_long_stealing.json b/lab-02/by/Dzenia/docks_and_hobos/config_long_stealing.json new file mode 100644 index 0000000..aafc6b3 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/config_long_stealing.json @@ -0,0 +1,52 @@ +{ + "generator": { + "generating_time": 3 + }, + "ship": { + "ship_capacity_min": 100, + "ship_capacity_max": 100, + "cargo_types": [ + "bear", + "milk", + "pork" + ] + }, + "tunnel": { + "max_ships": 4 + }, + "docks": [ + { + "unloading_speed": 10, + "dock_capacity": { + "bear": 100, + "milk": 100, + "pork": 100 + } + }, + { + "unloading_speed": 10, + "dock_capacity": { + "bear": 100, + "milk": 100, + "pork": 100 + } + } + ], + "hobos": { + "ingredients_count": + { + "bear": 15, + "milk": 15, + "pork": 15 + }, + "eating_time": 5, + "hobos_stealing_time": + { + "BB": 1, + "Larson": 1, + "Steve": 1, + "Ramzes": 1, + "Smurf": 2 + } + } +} diff --git a/lab-02/by/Dzenia/docks_and_hobos/lib/json-20230618.jar b/lab-02/by/Dzenia/docks_and_hobos/lib/json-20230618.jar new file mode 100644 index 0000000..c450ad4 Binary files /dev/null and b/lab-02/by/Dzenia/docks_and_hobos/lib/json-20230618.jar differ diff --git a/lab-02/by/Dzenia/docks_and_hobos/lib/log4j-1.2.17.jar b/lab-02/by/Dzenia/docks_and_hobos/lib/log4j-1.2.17.jar new file mode 100644 index 0000000..068867e Binary files /dev/null and b/lab-02/by/Dzenia/docks_and_hobos/lib/log4j-1.2.17.jar differ diff --git a/lab-02/by/Dzenia/docks_and_hobos/logs/log_2023-12-21_23-59-19.log.0 b/lab-02/by/Dzenia/docks_and_hobos/logs/log_2023-12-21_23-59-19.log.0 new file mode 100644 index 0000000..95d3864 --- /dev/null +++ b/lab-02/by/Dzenia/docks_and_hobos/logs/log_2023-12-21_23-59-19.log.0 @@ -0,0 +1,86 @@ +2023-12-21 23:59:19 CONFIG Path=lab-02/by/Dzenia/docks_and_hobos/config_long_stealing.json +2023-12-21 23:59:19 INFO Smurf start stealing milk +2023-12-21 23:59:19 INFO Ramzes start stealing bear +2023-12-21 23:59:19 INFO Larson start stealing pork +2023-12-21 23:59:19 INFO New ship with cargo=pork, weight=100 +2023-12-21 23:59:19 INFO Ship come to dock cargo=pork, weight=100 +2023-12-21 23:59:22 INFO New ship with cargo=pork, weight=100 +2023-12-21 23:59:22 INFO Ship come to dock cargo=pork, weight=100 +2023-12-21 23:59:25 INFO New ship with cargo=milk, weight=100 +2023-12-21 23:59:28 INFO New ship with cargo=bear, weight=100 +2023-12-21 23:59:29 INFO Ship come to dock cargo=milk, weight=100 +2023-12-21 23:59:31 INFO New ship with cargo=milk, weight=100 +2023-12-21 23:59:32 INFO Ship come to dock cargo=bear, weight=100 +2023-12-21 23:59:34 INFO New ship with cargo=pork, weight=100 +2023-12-21 23:59:37 INFO New ship with cargo=milk, weight=100 +2023-12-21 23:59:39 INFO Ship come to dock cargo=milk, weight=100 +2023-12-21 23:59:40 INFO New ship with cargo=pork, weight=100 +2023-12-21 23:59:42 INFO Ship come to dock cargo=pork, weight=100 +2023-12-21 23:59:43 INFO New ship with cargo=milk, weight=100 +2023-12-21 23:59:45 INFO Larson end stealing pork time=26s +2023-12-21 23:59:46 INFO New ship with cargo=pork, weight=100 +2023-12-21 23:59:47 INFO Smurf end stealing milk time=28s +2023-12-21 23:59:49 INFO New ship with cargo=pork, weight=100 +2023-12-21 23:59:49 INFO Ship go down with cargo=pork, weight=100 +2023-12-21 23:59:49 INFO Ship come to dock cargo=milk, weight=100 +2023-12-21 23:59:52 INFO New ship with cargo=pork, weight=100 +2023-12-21 23:59:52 INFO Ship come to dock cargo=pork, weight=100 +2023-12-21 23:59:55 INFO New ship with cargo=bear, weight=100 +2023-12-21 23:59:58 INFO New ship with cargo=pork, weight=100 +2023-12-21 23:59:58 INFO Ship go down with cargo=pork, weight=100 +2023-12-21 23:59:58 INFO Ramzes end stealing bear time=39s +2023-12-21 23:59:58 INFO Hobos start eating +2023-12-21 23:59:59 INFO Ship come to dock cargo=milk, weight=100 +2023-12-22 00:00:01 INFO New ship with cargo=pork, weight=100 +2023-12-22 00:00:02 INFO Ship come to dock cargo=pork, weight=100 +2023-12-22 00:00:03 INFO Steve start stealing bear +2023-12-22 00:00:03 INFO Larson start stealing milk +2023-12-22 00:00:03 INFO BB start stealing pork +2023-12-22 00:00:04 INFO New ship with cargo=milk, weight=100 +2023-12-22 00:00:07 INFO New ship with cargo=pork, weight=100 +2023-12-22 00:00:07 INFO Ship go down with cargo=pork, weight=100 +2023-12-22 00:00:09 INFO Ship come to dock cargo=pork, weight=100 +2023-12-22 00:00:10 INFO New ship with cargo=pork, weight=100 +2023-12-22 00:00:12 INFO Ship come to dock cargo=bear, weight=100 +2023-12-22 00:00:13 INFO New ship with cargo=bear, weight=100 +2023-12-22 00:00:16 INFO New ship with cargo=milk, weight=100 +2023-12-22 00:00:16 INFO Ship go down with cargo=milk, weight=100 +2023-12-22 00:00:19 INFO New ship with cargo=bear, weight=100 +2023-12-22 00:00:19 INFO Ship go down with cargo=bear, weight=100 +2023-12-22 00:00:19 INFO Ship come to dock cargo=pork, weight=100 +2023-12-22 00:00:19 INFO Larson end stealing milk time=16s +2023-12-22 00:00:19 INFO Steve end stealing bear time=16s +2023-12-22 00:00:19 INFO BB end stealing pork time=16s +2023-12-22 00:00:19 INFO Hobos start eating +2023-12-22 00:00:22 INFO New ship with cargo=milk, weight=100 +2023-12-22 00:00:22 INFO Ship come to dock cargo=milk, weight=100 +2023-12-22 00:00:24 INFO Smurf start stealing milk +2023-12-22 00:00:24 INFO Steve start stealing bear +2023-12-22 00:00:24 INFO Larson start stealing pork +2023-12-22 00:00:25 INFO New ship with cargo=milk, weight=100 +2023-12-22 00:00:28 INFO New ship with cargo=bear, weight=100 +2023-12-22 00:00:28 INFO Ship go down with cargo=bear, weight=100 +2023-12-22 00:00:29 INFO Ship come to dock cargo=pork, weight=100 +2023-12-22 00:00:31 INFO New ship with cargo=pork, weight=100 +2023-12-22 00:00:32 INFO Ship come to dock cargo=bear, weight=100 +2023-12-22 00:00:32 INFO Smurf end stealing milk time=8s +2023-12-22 00:00:34 INFO New ship with cargo=pork, weight=100 +2023-12-22 00:00:37 INFO New ship with cargo=milk, weight=100 +2023-12-22 00:00:37 INFO Ship go down with cargo=milk, weight=100 +2023-12-22 00:00:39 INFO Ship come to dock cargo=milk, weight=100 +2023-12-22 00:00:40 INFO New ship with cargo=pork, weight=100 +2023-12-22 00:00:40 INFO Larson end stealing pork time=16s +2023-12-22 00:00:40 INFO Steve end stealing bear time=16s +2023-12-22 00:00:40 INFO Hobos start eating +2023-12-22 00:00:42 INFO Ship come to dock cargo=milk, weight=100 +2023-12-22 00:00:43 INFO New ship with cargo=milk, weight=100 +2023-12-22 00:00:45 INFO Steve start stealing milk +2023-12-22 00:00:45 INFO Smurf start stealing bear +2023-12-22 00:00:45 INFO BB start stealing pork +2023-12-22 00:00:46 INFO New ship with cargo=milk, weight=100 +2023-12-22 00:00:46 INFO Ship go down with cargo=milk, weight=100 +2023-12-22 00:00:49 INFO New ship with cargo=bear, weight=100 +2023-12-22 00:00:49 INFO Ship go down with cargo=bear, weight=100 +2023-12-22 00:00:49 INFO Ship come to dock cargo=pork, weight=100 +2023-12-22 00:00:52 INFO New ship with cargo=bear, weight=100 +2023-12-22 00:00:52 INFO Ship come to dock cargo=pork, weight=100