*/
Map<Integer, String> newWorkerIds = new HashMap<Integer, String>();
for (Entry<Integer, LocalAssignment> entry : newWorkers.entrySet()) {
Integer port = entry.getKey();
LocalAssignment assignment = entry.getValue();
String workerId = UUID.randomUUID().toString();
newWorkerIds.put(port, workerId);
// create new worker Id directory
// LOCALDIR/workers/newworkid/pids
try {
StormConfig.worker_pids_root(conf, workerId);
} catch (IOException e1) {
LOG.error("Failed to create " + workerId + " localdir", e1);
throw e1;
}
StringBuilder sb = new StringBuilder();
sb.append("Launching worker with assiangment ");
sb.append(assignment.toString());
sb.append(" for the supervisor ");
sb.append(supervisorId);
sb.append(" on port ");
sb.append(port);
sb.append(" with id ");
sb.append(workerId);
LOG.info(sb);
try {
String clusterMode = StormConfig.cluster_mode(conf);
if (clusterMode.equals("distributed")) {
launchWorker(conf, sharedContext,
assignment.getTopologyId(), supervisorId, port,
workerId, assignment);
} else if (clusterMode.equals("local")) {
launchWorker(conf, sharedContext,
assignment.getTopologyId(), supervisorId, port,
workerId, workerThreadPids);
}
} catch (Exception e) {
String errorMsg = "Failed to launchWorker workerId:" + workerId
+ ":" + port;