use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class BufferedCollectionPartition method loadFromFS.
/**
* This method loads existing frames on disk
*/
private void loadFromFS() {
try {
FileStatus[] fileStatuses = this.fileSystem.listFiles(this.rootPath);
this.filesList = Arrays.stream(fileStatuses).map(FileStatus::getPath).filter(p -> p.getName().contains(EXTENSION)).sorted(Comparator.comparingLong(path -> Long.parseLong(path.getName().replace(EXTENSION, "")))).collect(Collectors.toList());
this.fileCounter = fileStatuses.length;
} catch (IOException e) {
throw new Twister2RuntimeException("Failed to load frames from file system", e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKMasterController method jobScaled.
@Override
public void jobScaled(int change, int numberOfWorkers1) {
if (change < 0) {
scaledDownWorkers = new LinkedList<>();
for (int i = numberOfWorkers1; i < numberOfWorkers; i++) {
scaledDownWorkers.add(i);
}
}
this.numberOfWorkers = numberOfWorkers1;
// generate en event and inform all other workers
JobMasterAPI.JobScaled jobScaled = JobMasterAPI.JobScaled.newBuilder().setNumberOfWorkers(numberOfWorkers1).setChange(change).build();
JobMasterAPI.JobEvent jobEvent = JobMasterAPI.JobEvent.newBuilder().setJobScaled(jobScaled).build();
try {
ZKEventsManager.publishEvent(client, rootPath, jobID, jobEvent);
} catch (Twister2Exception e) {
throw new Twister2RuntimeException(e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class ZKMasterController method allJoined.
@Override
public void allJoined() {
List<JobMasterAPI.WorkerInfo> workers = workerMonitor.getWorkerInfoList();
JobMasterAPI.AllJoined allWorkersJoined = JobMasterAPI.AllJoined.newBuilder().addAllWorkerInfo(workers).setNumberOfWorkers(workers.size()).build();
JobMasterAPI.JobEvent jobEvent = JobMasterAPI.JobEvent.newBuilder().setAllJoined(allWorkersJoined).build();
try {
ZKEventsManager.publishEvent(client, rootPath, jobID, jobEvent);
} catch (Twister2Exception e) {
throw new Twister2RuntimeException(e);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class MPIWorkerStarter method broadCastMasterInformation.
/**
* Broadcast the job master information to workers
*
* @param rank rank
*/
private void broadCastMasterInformation(int rank) {
byte[] workerBytes = wInfo.toByteArray();
int length = workerBytes.length;
IntBuffer countSend = MPI.newIntBuffer(1);
if (rank == 0) {
countSend.put(length);
}
try {
MPI.COMM_WORLD.bcast(countSend, 1, MPI.INT, 0);
length = countSend.get(0);
ByteBuffer sendBuffer = MPI.newByteBuffer(length);
if (rank == 0) {
sendBuffer.put(workerBytes);
}
MPI.COMM_WORLD.bcast(sendBuffer, length, MPI.BYTE, 0);
byte[] jmInfoBytes = new byte[length];
if (rank != 0) {
sendBuffer.get(jmInfoBytes);
JobMasterAPI.WorkerInfo masterInfo = JobMasterAPI.WorkerInfo.newBuilder().mergeFrom(jmInfoBytes).build();
config = Config.newBuilder().putAll(config).put(JobMasterContext.JOB_MASTER_PORT, masterInfo.getPort()).put(JobMasterContext.JOB_MASTER_IP, masterInfo.getNodeInfo().getNodeIP()).build();
} else {
config = Config.newBuilder().putAll(config).put(JobMasterContext.JOB_MASTER_PORT, wInfo.getPort()).put(JobMasterContext.JOB_MASTER_IP, wInfo.getNodeInfo().getNodeIP()).build();
}
} catch (MPIException mpie) {
throw new Twister2RuntimeException("Error when broadcasting Job Master information", mpie);
} catch (InvalidProtocolBufferException ipbe) {
throw new Twister2RuntimeException("Error when decoding Job Master information", ipbe);
}
}
use of edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException in project twister2 by DSC-SPIDAL.
the class NetworkUtils method findFreePorts.
/**
* Returns the list of free ports on localhost.
* A ServerSocket is started on each port
* These ports must be released after the JMWorkerAgent is started and
* before IWorker is started in MPIWorkerManager/WorkerManager
* using releaseWorkerPorts method
*
* @return a list of free ports
*/
public static Map<String, Integer> findFreePorts(List<String> portNames) {
List<ServerSocket> sockets = new ArrayList<>();
Map<String, Integer> freePorts = new HashMap<>();
try {
for (String portName : portNames) {
ServerSocket socket = new ServerSocket(0);
socket.setReuseAddress(true);
freePorts.put(portName, socket.getLocalPort());
sockets.add(socket);
}
WorkerEnvironment.putSharedValue("socketsForFreePorts", sockets);
return freePorts;
} catch (IOException e) {
throw new Twister2RuntimeException("Could not find free TCP/IP ports");
}
}
Aggregations