public boolean equals(WorkerSummary that) { if (that == null) return false; boolean this_present_port = true; boolean that_present_port = true; if (this_present_port || that_present_port) { if (!(this_present_port && that_present_port)) return false; if (this.port != that.port) return false; } boolean this_present_uptime = true; boolean that_present_uptime = true; if (this_present_uptime || that_present_uptime) { if (!(this_present_uptime && that_present_uptime)) return false; if (this.uptime != that.uptime) return false; } boolean this_present_topology = true && this.is_set_topology(); boolean that_present_topology = true && that.is_set_topology(); if (this_present_topology || that_present_topology) { if (!(this_present_topology && that_present_topology)) return false; if (!this.topology.equals(that.topology)) return false; } boolean this_present_tasks = true && this.is_set_tasks(); boolean that_present_tasks = true && that.is_set_tasks(); if (this_present_tasks || that_present_tasks) { if (!(this_present_tasks && that_present_tasks)) return false; if (!this.tasks.equals(that.tasks)) return false; } return true; }
public WorkerSumm(WorkerSummary workerSummary) { this.port = String.valueOf(workerSummary.get_port()); this.topology = workerSummary.get_topology(); StringBuilder taskSB = new StringBuilder(); StringBuilder componentSB = new StringBuilder(); boolean isFirst = true; int minUptime = 0; taskSummList = workerSummary.get_tasks(); for (TaskSummary taskSummary : taskSummList) { if (isFirst == false) { taskSB.append(','); componentSB.append(','); } else { minUptime = taskSummary.get_uptime_secs(); } taskSB.append(taskSummary.get_task_id()); componentSB.append(taskSummary.get_component_id()); if (minUptime < taskSummary.get_uptime_secs()) { minUptime = taskSummary.get_uptime_secs(); } isFirst = false; } this.uptime = StatBuckets.prettyUptimeStr(minUptime); this.tasks = taskSB.toString(); this.components = componentSB.toString(); }
public void read(org.apache.thrift.protocol.TProtocol iprot, WorkerSummary struct) throws org.apache.thrift.TException { org.apache.thrift.protocol.TField schemeField; iprot.readStructBegin(); while (true) { schemeField = iprot.readFieldBegin(); if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { break; } switch (schemeField.id) { case 1: // PORT if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.port = iprot.readI32(); struct.set_port_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 2: // UPTIME if (schemeField.type == org.apache.thrift.protocol.TType.I32) { struct.uptime = iprot.readI32(); struct.set_uptime_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 3: // TOPOLOGY if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { struct.topology = iprot.readString(); struct.set_topology_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; case 4: // TASKS if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { { org.apache.thrift.protocol.TList _list98 = iprot.readListBegin(); struct.tasks = new ArrayList<TaskComponent>(_list98.size); TaskComponent _elem99; for (int _i100 = 0; _i100 < _list98.size; ++_i100) { _elem99 = new TaskComponent(); _elem99.read(iprot); struct.tasks.add(_elem99); } iprot.readListEnd(); } struct.set_tasks_isSet(true); } else { org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } break; default: org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); } iprot.readFieldEnd(); } iprot.readStructEnd(); struct.validate(); }
/** Performs a deep copy on <i>other</i>. */ public WorkerSummary(WorkerSummary other) { __isset_bitfield = other.__isset_bitfield; this.port = other.port; this.uptime = other.uptime; if (other.is_set_topology()) { this.topology = other.topology; } if (other.is_set_tasks()) { List<TaskComponent> __this__tasks = new ArrayList<TaskComponent>(other.tasks.size()); for (TaskComponent other_element : other.tasks) { __this__tasks.add(new TaskComponent(other_element)); } this.tasks = __this__tasks; } }
/** Performs a deep copy on <i>other</i>. */ public WorkerSummary(WorkerSummary other) { __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); this.port = other.port; if (other.is_set_topology()) { this.topology = other.topology; } if (other.is_set_tasks()) { List<TaskSummary> __this__tasks = new ArrayList<TaskSummary>(); for (TaskSummary other_element : other.tasks) { __this__tasks.add(new TaskSummary(other_element)); } this.tasks = __this__tasks; } }
public void write(org.apache.thrift.protocol.TProtocol oprot, WorkerSummary struct) throws org.apache.thrift.TException { struct.validate(); oprot.writeStructBegin(STRUCT_DESC); oprot.writeFieldBegin(PORT_FIELD_DESC); oprot.writeI32(struct.port); oprot.writeFieldEnd(); oprot.writeFieldBegin(UPTIME_FIELD_DESC); oprot.writeI32(struct.uptime); oprot.writeFieldEnd(); if (struct.topology != null) { oprot.writeFieldBegin(TOPOLOGY_FIELD_DESC); oprot.writeString(struct.topology); oprot.writeFieldEnd(); } if (struct.tasks != null) { oprot.writeFieldBegin(TASKS_FIELD_DESC); { oprot.writeListBegin( new org.apache.thrift.protocol.TList( org.apache.thrift.protocol.TType.STRUCT, struct.tasks.size())); for (TaskComponent _iter101 : struct.tasks) { _iter101.write(oprot); } oprot.writeListEnd(); } oprot.writeFieldEnd(); } oprot.writeFieldStop(); oprot.writeStructEnd(); }
@Override public int compareTo(WorkerSummary other) { if (!getClass().equals(other.getClass())) { return getClass().getName().compareTo(other.getClass().getName()); } int lastComparison = 0; lastComparison = Boolean.valueOf(is_set_port()).compareTo(other.is_set_port()); if (lastComparison != 0) { return lastComparison; } if (is_set_port()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.port, other.port); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_uptime()).compareTo(other.is_set_uptime()); if (lastComparison != 0) { return lastComparison; } if (is_set_uptime()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.uptime, other.uptime); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_topology()).compareTo(other.is_set_topology()); if (lastComparison != 0) { return lastComparison; } if (is_set_topology()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.topology, other.topology); if (lastComparison != 0) { return lastComparison; } } lastComparison = Boolean.valueOf(is_set_tasks()).compareTo(other.is_set_tasks()); if (lastComparison != 0) { return lastComparison; } if (is_set_tasks()) { lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.tasks, other.tasks); if (lastComparison != 0) { return lastComparison; } } return 0; }
@Override public void read(org.apache.thrift.protocol.TProtocol prot, WorkerSummary struct) throws org.apache.thrift.TException { TTupleProtocol iprot = (TTupleProtocol) prot; struct.port = iprot.readI32(); struct.set_port_isSet(true); struct.uptime = iprot.readI32(); struct.set_uptime_isSet(true); struct.topology = iprot.readString(); struct.set_topology_isSet(true); { org.apache.thrift.protocol.TList _list103 = new org.apache.thrift.protocol.TList( org.apache.thrift.protocol.TType.STRUCT, iprot.readI32()); struct.tasks = new ArrayList<TaskComponent>(_list103.size); TaskComponent _elem104; for (int _i105 = 0; _i105 < _list103.size; ++_i105) { _elem104 = new TaskComponent(); _elem104.read(iprot); struct.tasks.add(_elem104); } } struct.set_tasks_isSet(true); }
@Override public SupervisorWorkers getSupervisorWorkers(String host) throws NotAliveException, TException { try { StormClusterState stormClusterState = data.getStormClusterState(); String supervisorId = null; SupervisorInfo supervisorInfo = null; String ip = NetWorkUtils.host2Ip(host); String hostName = NetWorkUtils.ip2Host(host); // all supervisors Map<String, SupervisorInfo> supervisorInfos = Cluster.allSupervisorInfo(stormClusterState, null); for (Entry<String, SupervisorInfo> entry : supervisorInfos.entrySet()) { SupervisorInfo info = entry.getValue(); if (info.getHostName().equals(hostName) || info.getHostName().equals(ip)) { supervisorId = entry.getKey(); supervisorInfo = info; break; } } if (supervisorId == null) { throw new TException("No supervisor of " + host); } Map<String, Assignment> assignments = new HashMap<String, Assignment>(); // get all active topology's StormBase Map<String, StormBase> bases = Cluster.topology_bases(stormClusterState); for (Entry<String, StormBase> entry : bases.entrySet()) { String topologyId = entry.getKey(); StormBase base = entry.getValue(); Assignment assignment = stormClusterState.assignment_info(topologyId, null); if (assignment == null) { LOG.error("Failed to get assignment of " + topologyId); continue; } assignments.put(topologyId, assignment); } Map<Integer, WorkerSummary> portWorkerSummarys = new TreeMap<Integer, WorkerSummary>(); for (Entry<String, Assignment> entry : assignments.entrySet()) { String topologyId = entry.getKey(); Assignment assignment = entry.getValue(); Map<Integer, String> taskToComponent = Cluster.topology_task_info(stormClusterState, topologyId); Map<Integer, ResourceAssignment> taskToResource = assignment.getTaskToResource(); for (Entry<Integer, ResourceAssignment> resourceEntry : taskToResource.entrySet()) { Integer taskId = resourceEntry.getKey(); ResourceAssignment resourceAssignment = resourceEntry.getValue(); if (supervisorId.equals(resourceAssignment.getSupervisorId()) == false) { continue; } supervisorInfo.allocResource(resourceAssignment); Integer port = resourceAssignment.getPort(); WorkerSummary workerSummary = portWorkerSummarys.get(port); if (workerSummary == null) { workerSummary = new WorkerSummary(); workerSummary.set_port(port); workerSummary.set_topology(topologyId); workerSummary.set_tasks(new ArrayList<TaskSummary>()); portWorkerSummarys.put(port, workerSummary); } String componentName = taskToComponent.get(taskId); int uptime = TimeUtils.time_delta(assignment.getTaskStartTimeSecs().get(taskId)); List<TaskSummary> tasks = workerSummary.get_tasks(); TaskSummary taskSummary = NimbusUtils.mkSimpleTaskSummary( resourceAssignment, taskId, componentName, host, uptime); tasks.add(taskSummary); } } List<WorkerSummary> wokersList = new ArrayList<WorkerSummary>(); wokersList.addAll(portWorkerSummarys.values()); SupervisorSummary supervisorSummary = NimbusUtils.mkSupervisorSummary(supervisorInfo, supervisorId); return new SupervisorWorkers(supervisorSummary, wokersList); } catch (TException e) { LOG.info("Failed to get ClusterSummary ", e); throw e; } catch (Exception e) { LOG.info("Failed to get ClusterSummary ", e); throw new TException(e); } }