-/* Copyright (c) 2006-2019. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
+import java.util.Random;
import org.simgrid.msg.Msg;
import org.simgrid.msg.Comm;
import org.simgrid.msg.Host;
import org.simgrid.msg.Task;
import org.simgrid.msg.Process;
-import org.simgrid.msg.RngStream;
import org.simgrid.msg.MsgException;
public class Peer extends Process {
+ Random rand = new Random();
protected int round = 0;
protected double beginReceiveTime;
protected double deadline;
- protected static RngStream stream = new RngStream();
protected int id;
protected String mailbox;
protected String mailboxTracker;
if (args.length != 3 && args.length != 2) {
Msg.info("Wrong number of arguments");
}
- if (args.length == 3) {
- init(Integer.parseInt(args[0]),true);
- } else {
- init(Integer.parseInt(args[0]),false);
- }
+ init(Integer.parseInt(args[0]), (args.length == 3));
+
//Retrieve the deadline
deadline = Double.parseDouble(args[1]);
if (deadline < 0) {
//TODO: trivial min algorithm when pieces >= 3
do {
- currentPiece = stream.randInt(0,Common.FILE_PIECES - 1);
+ currentPiece = rand.nextInt(Common.FILE_PIECES);
} while (!(bitfield[currentPiece] == '0' && !currentPieces.contains(currentPiece)));
currentPieces.add(currentPiece);
int j = 0;
do {
int i = 0;
- int idChosen = stream.randInt(0,peers.size() - 1);
+ int idChosen = rand.nextInt(peers.size());
for (Connection connection : peers.values()) {
if (i == idChosen) {
peerChoosed = connection;