olá, tenho uma duvida no código abaixo. Não irei postar o código por inteiro pois é muito extenso. Então vou direto ao ponto da minha duvida.
public class JobManager extends Thread implements IJobManager {
.
.
.
.
.
public void run() {
try {
while (this.running) {
this.request = this.requestList.take();
this.workerId = this.request.getWorkerId();
this.requestSizeMin = this.request.getMin();
this.requestSizeMax = this.request.getMax();
.
.
.
.
.
if (!this.jobsList.isEmpty()) {
this.tempJobsList = this.jobsSelect(this.requestSizeMin, this.requestSizeMax);
long actualTime = this.executionTime.resumeS();
long lastTime = this.statusWorkerManager.getWorker(this.workerId).getLastStatusMsg();
int countWorkload = 0;
.
.
.
.
this.statusWorkerManager.getWorker(this.workerId).setCountWorkload(countWorkload);
} else {
.
.
.
.
.
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public class StatusWorkerManager extends Thread implements IStatusManager, IWorkerManager {
.
.
.
.
.
private Map<String, IWorker> workersList;
.
.
.
.
.
public StatusWorkerManager(String managerId, ManagerProxy managerProxy, JobManager jobManager) {
try {
this.workersList = new LinkedHashMap<String, IWorker>();
.
.
.
.
.
} catch (Exception e) {
e.printStackTrace();
}
}
public void newWorker(String workerId, String channelDescription) {
// TODO Auto-generated method stub
try {
int sizeWorkTemp = 0;
int sizeWorkMin = 0;
/*if (workerId.equals(Config.MANAGER_LSC1.trim())){
channelDescription = (Config.DEFAULT_IP+":"+ 4450).trim();
}*/
// //////////////////////////////////////////////////////////////////////
//System.out.println("StatusWorkerManager (" + this.getID() + ") =>");
//System.out.println("\t Recebi NEW_WORKER");
//System.out.println("\t\t WorkerId: " + workerId);
//System.out.println("\t\t ChannelDesc: " + channelDescription + "\n");
// //////////////////////////////////////////////////////////////////////
Worker worker = new Worker();
worker.setID(workerId);
worker.setChannelDesc(channelDescription);
worker.setCapacity(this.initialWorkerCapacity);
worker.setWorkload(this.initialWorkerWorkload);
worker.setLastStatusMsg(this.executionTime.resumeS());
.
.
.
.
this.setWorker(workerId, worker);
.
.
.
.
} catch (Exception e) {
e.printStackTrace();
}
}
public void setWorker(String workerId, IWorker worker) {
// TODO Auto-generated method stub
try {
this.workersList.put(workerId, worker);
} catch (Exception e) {
e.printStackTrace();
}
}
public IWorker getWorker(String workerId) {
// TODO Auto-generated method stub
try {
return this.workersList.get(workerId);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public void statusUpdate() {
float capacityTotal = 0;
int workloadTotal = 0;
Iterator<String> i = this.workersList.keySet().iterator();
while (i.hasNext()) {
String key = (String) i.next();
capacityTotal += this.workersList.get(key).getCapacity();
workloadTotal += this.workersList.get(key).getWorkload();
}
this.setCapacity(capacityTotal);
this.setWorkload(workloadTotal + this.jobManager.getWorkload());
}
.
.
.
.
.
}
Minha duvida esta no acesso aos metodos getWorker e setWorker. Estão corretos? está faltando algo?