示例#1
0
  public int compareTo(Bolt other) {
    if (!getClass().equals(other.getClass())) {
      return getClass().getName().compareTo(other.getClass().getName());
    }

    int lastComparison = 0;
    Bolt typedOther = (Bolt) other;

    lastComparison =
        Boolean.valueOf(is_set_bolt_object()).compareTo(typedOther.is_set_bolt_object());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_bolt_object()) {
      lastComparison =
          org.apache.thrift.TBaseHelper.compareTo(this.bolt_object, typedOther.bolt_object);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    lastComparison = Boolean.valueOf(is_set_common()).compareTo(typedOther.is_set_common());
    if (lastComparison != 0) {
      return lastComparison;
    }
    if (is_set_common()) {
      lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.common, typedOther.common);
      if (lastComparison != 0) {
        return lastComparison;
      }
    }
    return 0;
  }
示例#2
0
 /** Performs a deep copy on <i>other</i>. */
 public Bolt(Bolt other) {
   if (other.is_set_bolt_object()) {
     this.bolt_object = new ComponentObject(other.bolt_object);
   }
   if (other.is_set_common()) {
     this.common = new ComponentCommon(other.common);
   }
 }
示例#3
0
 @Override
 public void read(org.apache.thrift.protocol.TProtocol prot, Bolt struct)
     throws org.apache.thrift.TException {
   TTupleProtocol iprot = (TTupleProtocol) prot;
   struct.bolt_object = new ComponentObject();
   struct.bolt_object.read(iprot);
   struct.set_bolt_object_isSet(true);
   struct.common = new ComponentCommon();
   struct.common.read(iprot);
   struct.set_common_isSet(true);
 }
示例#4
0
  public boolean equals(Bolt that) {
    if (that == null) return false;

    boolean this_present_bolt_object = true && this.is_set_bolt_object();
    boolean that_present_bolt_object = true && that.is_set_bolt_object();
    if (this_present_bolt_object || that_present_bolt_object) {
      if (!(this_present_bolt_object && that_present_bolt_object)) return false;
      if (!this.bolt_object.equals(that.bolt_object)) return false;
    }

    boolean this_present_common = true && this.is_set_common();
    boolean that_present_common = true && that.is_set_common();
    if (this_present_common || that_present_common) {
      if (!(this_present_common && that_present_common)) return false;
      if (!this.common.equals(that.common)) return false;
    }

    return true;
  }
  private int setBoltInfo(
      StormTopology oldTopology, StormTopology newTopology, int cnt, StormClusterState clusterState)
      throws Exception {
    Map<String, Bolt> oldBolts = oldTopology.get_bolts();
    Map<String, Bolt> bolts = newTopology.get_bolts();
    for (Entry<String, Bolt> entry : oldBolts.entrySet()) {
      String boltName = entry.getKey();
      Bolt oldBolt = entry.getValue();
      Bolt bolt = bolts.get(boltName);
      if (oldBolt.get_common().get_parallelism_hint() > bolt.get_common().get_parallelism_hint()) {
        int removedTaskNum =
            oldBolt.get_common().get_parallelism_hint() - bolt.get_common().get_parallelism_hint();
        TreeSet<Integer> taskIds =
            new TreeSet<Integer>(clusterState.task_ids_by_componentId(topologyid, boltName));
        Iterator<Integer> descendIterator = taskIds.descendingIterator();
        while (--removedTaskNum >= 0) {
          int taskId = descendIterator.next();
          removeTask(topologyid, taskId, clusterState);
          LOG.info("Remove bolt task, taskId=" + taskId + " for " + boltName);
        }
      } else if (oldBolt.get_common().get_parallelism_hint()
          == bolt.get_common().get_parallelism_hint()) {
        continue;
      } else {
        int delta =
            bolt.get_common().get_parallelism_hint() - oldBolt.get_common().get_parallelism_hint();
        Map<Integer, TaskInfo> taskInfoMap = new HashMap<Integer, TaskInfo>();

        for (int i = 1; i <= delta; i++) {
          cnt++;
          TaskInfo taskInfo = new TaskInfo((String) entry.getKey(), "bolt");
          taskInfoMap.put(cnt, taskInfo);
          newTasks.add(cnt);
          LOG.info("Setup new bolt task, taskId=" + cnt + " for " + boltName);
        }
        clusterState.add_task(topologyid, taskInfoMap);
      }
    }

    return cnt;
  }
示例#6
0
 public void read(org.apache.thrift.protocol.TProtocol iprot, Bolt 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: // BOLT_OBJECT
         if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
           struct.bolt_object = new ComponentObject();
           struct.bolt_object.read(iprot);
           struct.set_bolt_object_isSet(true);
         } else {
           org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
         }
         break;
       case 2: // COMMON
         if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
           struct.common = new ComponentCommon();
           struct.common.read(iprot);
           struct.set_common_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();
 }
示例#7
0
    public void write(org.apache.thrift.protocol.TProtocol oprot, Bolt struct)
        throws org.apache.thrift.TException {
      struct.validate();

      oprot.writeStructBegin(STRUCT_DESC);
      if (struct.bolt_object != null) {
        oprot.writeFieldBegin(BOLT_OBJECT_FIELD_DESC);
        struct.bolt_object.write(oprot);
        oprot.writeFieldEnd();
      }
      if (struct.common != null) {
        oprot.writeFieldBegin(COMMON_FIELD_DESC);
        struct.common.write(oprot);
        oprot.writeFieldEnd();
      }
      oprot.writeFieldStop();
      oprot.writeStructEnd();
    }