protected char[][] bitfieldBlocks = new char[Common.FILE_PIECES][Common.PIECES_BLOCKS];
protected short[] piecesCount = new short[Common.FILE_PIECES];
protected int piecesRequested = 0;
- protected ArrayList<Integer> currentPieces = new ArrayList<Integer>();
+ protected ArrayList<Integer> currentPieces = new ArrayList<>();
protected int currentPiece = -1;
- protected HashMap<Integer, Connection> activePeers = new HashMap<Integer, Connection>();
- protected HashMap<Integer, Connection> peers = new HashMap<Integer, Connection>();
+ protected HashMap<Integer, Connection> activePeers = new HashMap<>();
+ protected HashMap<Integer, Connection> peers = new HashMap<>();
protected Comm commReceived = null;
public Peer(Host host, String name, String[]args) {
}
}
catch (MsgException e) {
+ e.printStackTrace();
commReceived = null;
}
}
}
private boolean getPeersData() {
- boolean success = false, sendSuccess = false;
+ boolean success = false;
+ boolean sendSuccess = false;
double timeout = Msg.getClock() + Common.GET_PEERS_TIMEOUT;
//Build the task to send to the tracker
TrackerTask taskSend = new TrackerTask(hostname, mailboxTracker, id);
sendSuccess = true;
}
catch (MsgException e) {
+ e.printStackTrace();
}
}
while (!success && Msg.getClock() < timeout) {
success = true;
}
}
- catch (MsgException e) {}
+ catch (MsgException e) {
+ e.printStackTrace();
+ }
commReceived = null;
}
commReceived = null;
if (currentPieces.size() >= (Common.FILE_PIECES - pieces)) {
return;
}
- if (true || pieces < 3) {
- int peerPiece;
+// if (pieces < 3) {
do {
currentPiece = stream.randInt(0,Common.FILE_PIECES - 1);
} while (!(bitfield[currentPiece] == '0' && !currentPieces.contains(currentPiece)));
- }
- else {
- //trivial min algorithm.
- //TODO
- }
+// }
+// else {
+ //TODO trivial min algorithm.
+// }
currentPieces.add(currentPiece);
Msg.debug("New interested piece: " + currentPiece);
assert currentPiece >= 0 && currentPiece < Common.FILE_PIECES;
}
i++;
} //TODO: Not really the best way ever
- if (!peerChoosed.interested) {
+ if (peerChoosed != null && !peerChoosed.interested) {
peerChoosed = null;
}
j++;
package cloud.migration;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Random;
import org.simgrid.msg.*;
// This test aims at validating that the migration process is robust in face of host turning off either on the SRC
// node or on the DST node.
-public class TestHostOnOff extends Process{
+public class TestHostOnOff extends Process{
public static Host host0 = null;
public static Host host1 = null;
public static Host host2 = null;
-
- TestHostOnOff(Host host, String name, String[] args) throws HostNotFoundException, NativeException {
+ TestHostOnOff(Host host, String name, String[] args) throws NativeException {
super(host, name, args);
}
+ @Override
public void main(String[] strings) throws MsgException {
- double startTime = 0;
- double endTime = 0;
-
/* get hosts 1 and 2*/
try {
host0 = Host.getByName("host0");
// Robustness on the SRC node
//for (int i =0 ; i < 55000 ; i++)
- // test_vm_migrate(host1, i);
+ // testVMMigrate(host1, i);
// Robustness on the DST node
//for (int i =0 ; i < 55000 ; i++)
- // test_vm_migrate(host2, i);
+ // testVMMigrate(host2, i);
/* End of Tests */
Msg.info("Nor more tests, Bye Bye !");
Main.setEndOfTest();
}
- public static void test_vm_migrate (Host hostToKill, long killAt) throws MsgException {
+ public static void testVMMigrate (Host hostToKill, long killAt) throws MsgException {
Msg.info("**** **** **** ***** ***** Test Migrate with host shutdown ***** ***** **** **** ****");
Msg.info("Turn on one host, assign a VM on this host, launch a process inside the VM, migrate the VM and "
+ "turn off either the SRC or DST");
Process.sleep(20000);
}
- public static void test_vm_shutdown_destroy () throws HostFailureException {
+ public static void testVMShutdownDestroy () throws HostFailureException {
Msg.info("**** **** **** ***** ***** Test shutdown a VM ***** ***** **** **** ****");
Msg.info("Turn on host1, assign a VM on host1, launch a process inside the VM, and turn off the vm, " +
"and check whether you can reallocate the same VM");
// Create VM0
int dpRate = 70;
- XVM vm0 = null;
- vm0 = new XVM(host1, "vm0",
+ XVM vm0 = new XVM(host1, "vm0",
1, // Nb of vcpu
2048, // Ramsize,
125, // Net Bandwidth
package energy.vm;
-import org.simgrid.msg.*;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.VM;
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Task;
import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.HostFailureException;
+import org.simgrid.msg.HostNotFoundException;
+import org.simgrid.msg.TaskCancelledException;
+import org.simgrid.msg.NativeException;
/* This class is a process in charge of running the test. It creates and starts the VMs, and fork processes within VMs */
public class EnergyVMRunner extends Process {
super(host, name);
}
- public void main(String[] args) {
+ @Override
+ public void main(String[] strings) {
Task task = new Task(this.getHost().getName()+"-task", 300E6 , 0);
try {
- task.execute();
- } catch (Exception e) {
+ task.execute();
+ } catch (HostFailureException | TaskCancelledException e) {
e.printStackTrace();
}
Msg.info("This worker is done.");
super(host, name, args);
}
+ @Override
public void main(String[] strings) throws MsgException, HostNotFoundException {
double startTime = 0;
double endTime = 0;