backtype.storm.tuple.Tuple.getBooleanByField()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中backtype.storm.tuple.Tuple.getBooleanByField()方法的一些代码示例,展示了Tuple.getBooleanByField()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple.getBooleanByField()方法的具体详情如下:
包路径:backtype.storm.tuple.Tuple
类名称:Tuple
方法名:getBooleanByField

Tuple.getBooleanByField介绍

暂无

代码示例

代码示例来源:origin: Symantec/hendrix

@Override
public void execute(Tuple tuple) {
  try {
    client = Utils.buildClient(this.uiEndpoint, 3000, 3000);
    HttpPut put = new HttpPut(this.uiEndpoint + "/" + tuple.getShortByField(Constants.FIELD_ALERT_TEMPLATE_ID)
        + "/" + tuple.getBooleanByField(Constants.SUPRESSION_STATE));
    client.execute(put);
    client.close();
  } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | IOException e) {
    collector.reportError(e);
  }
  collector.ack(tuple);
}

代码示例来源:origin: Symantec/hendrix

@Override
public void execute(Tuple tuple) {
  JsonObject obj = new JsonObject();
  obj.addProperty(Constants.FIELD_TIMESTAMP, tuple.getLongByField(Constants.FIELD_TIMESTAMP));
  obj.addProperty(Constants.FIELD_AGGREGATION_WINDOW,
      tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW));
  obj.addProperty(Constants.FIELD_RULE_ACTION_ID, tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID));
  obj.addProperty(Constants.FIELD_AGGREGATION_KEY, tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY));
  if (tuple.contains(Constants.FIELD_STATE_TRACK)) {
    obj.addProperty(Constants.FIELD_STATE_TRACK, tuple.getBooleanByField(Constants.FIELD_STATE_TRACK));
  } else if (tuple.contains(Constants.FIELD_AGGREGATION_VALUE)) {
    obj.addProperty(Constants.FIELD_AGGREGATION_VALUE,
        tuple.getValueByField(Constants.FIELD_AGGREGATION_VALUE).toString());
  } else {
    // invalid event
    collector.fail(tuple);
    return;
  }
  collector.emit(tuple, new Values(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID) + "_"
      + tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY), gson.toJson(obj)));
  collector.ack(tuple);
}

代码示例来源:origin: mayconbordin/storm-applications

@Override
  public void execute(Tuple input) {
    CallDetailRecord cdr = (CallDetailRecord) input.getValueByField(Field.RECORD);
    boolean newCallee = input.getBooleanByField(Field.NEW_CALLEE);
    
    if (cdr.isCallEstablished() && newCallee) {
      String caller = input.getStringByField(Field.CALLING_NUM);
      long timestamp = cdr.getAnswerTime().getMillis()/1000;

      filter.add(caller, cdr.getCallDuration(), timestamp);
      double calltime = filter.estimateCount(caller, timestamp);

      LOG.debug(String.format("CallTime: %f", calltime));
      collector.emit(new Values(caller, timestamp, calltime, cdr));
    }
  }
}

代码示例来源:origin: Symantec/hendrix

@Test
public void testBasicSerialization() {
  AggregationSerializerBolt bolt = new AggregationSerializerBolt();
  Map<String, String> conf = new HashMap<>();
  bolt.prepare(conf, null, collector);
  when(tuple.getLongByField(Constants.FIELD_TIMESTAMP)).thenReturn(143322L);
  when(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID)).thenReturn("34_22");
  when(tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY)).thenReturn("host1");
  when(tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW)).thenReturn(100);
  when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn(true);
  when(tuple.contains(Constants.FIELD_STATE_TRACK)).thenReturn(true);
  bolt.execute(tuple);
  verify(collector, times(1)).ack(tuple);
}

代码示例来源:origin: mayconbordin/storm-applications

boolean isSpam = input.getBooleanByField(Field.IS_SPAM);

代码示例来源:origin: mayconbordin/storm-applications

@Override
  public void execute(Tuple input) {
    CallDetailRecord cdr = (CallDetailRecord) input.getValueByField(Field.RECORD);
    boolean newCallee = input.getBooleanByField(Field.NEW_CALLEE);
    
    if (cdr.isCallEstablished() && newCallee) {
      String caller = input.getStringByField(Field.CALLING_NUM);
      long timestamp = cdr.getAnswerTime().getMillis()/1000;

      filter.add(caller, 1, timestamp);
      double rate = filter.estimateCount(caller, timestamp);

      collector.emit(new Values(caller, timestamp, rate, cdr));
    }
  }
}

代码示例来源:origin: Symantec/hendrix

@Test
public void testJSONSerialization() {
  AggregationSerializerBolt bolt = new AggregationSerializerBolt();
  Map<String, String> conf = new HashMap<>();
  final AtomicReference<Values> outputTuple = new AtomicReference<Values>(null);
  OutputCollector mockCollector = MockTupleHelpers.mockCollector(new Answer<Object>() {
    @Override
    public Object answer(InvocationOnMock invocation) throws Throwable {
      Object newEvent = invocation.getArguments()[1];
      outputTuple.set((Values) newEvent);
      return new ArrayList<>();
    }
  });
  bolt.prepare(conf, null, mockCollector);
  when(tuple.getLongByField(Constants.FIELD_TIMESTAMP)).thenReturn(143322L);
  when(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID)).thenReturn("34_22");
  when(tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY)).thenReturn("host1");
  when(tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW)).thenReturn(100);
  when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn(true);
  when(tuple.contains(Constants.FIELD_STATE_TRACK)).thenReturn(true);
  bolt.execute(tuple);
  verify(mockCollector, times(1)).ack(tuple);
  assertEquals("34_22_host1", outputTuple.get().get(0));
  JsonObject obj = new Gson().fromJson(outputTuple.get().get(1).toString(), JsonObject.class);
  assertEquals(143322L, obj.get(Constants.FIELD_TIMESTAMP).getAsLong());
  assertEquals("34_22", obj.get(Constants.FIELD_RULE_ACTION_ID).getAsString());
  assertEquals("host1", obj.get(Constants.FIELD_AGGREGATION_KEY).getAsString());
  assertEquals(100, obj.get(Constants.FIELD_AGGREGATION_WINDOW).getAsInt());
  assertEquals(true, obj.get(Constants.FIELD_STATE_TRACK).getAsBoolean());
}

代码示例来源:origin: Symantec/hendrix

when(tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW)).thenReturn(10);
when(tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY)).thenReturn("series1");
when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn(true);
when(tuple.getLongByField(Constants.FIELD_TIMESTAMP)).thenReturn(1464038054645L);
bolt.execute(tuple);

代码示例来源:origin: com.srotya.tau/tau-dengine

stateHit.scope(Utils.separateRuleActionId(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID))
    .getKey().toString()).incr();
if (tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)) {
  logger.fine("State tracking true:" + tuple);
  stateTrackingEngine.track(tuple.getLongByField(Constants.FIELD_TIMESTAMP),

代码示例来源:origin: Symantec/hendrix

when(tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW)).thenReturn(10);
when(tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY)).thenReturn("series1");
when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn(true);
when(tuple.getLongByField(Constants.FIELD_TIMESTAMP)).thenReturn(1464038054645L);
bolt.execute(tuple);

代码示例来源:origin: Symantec/hendrix

stateHit.scope(Utils.separateRuleActionId(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID))
    .getKey().toString()).incr();
if (tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)) {
  logger.fine("State tracking true:" + tuple);
  stateTrackingEngine.track(tuple.getLongByField(Constants.FIELD_TIMESTAMP),

代码示例来源:origin: Symantec/hendrix

when(tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW)).thenReturn(10);
when(tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY)).thenReturn("series1");
when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn(true);
when(tuple.getLongByField(Constants.FIELD_TIMESTAMP)).thenReturn(1464038054645L);
bolt.execute(tuple);

代码示例来源:origin: Symantec/hendrix

when(tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW)).thenReturn(10);
when(tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY)).thenReturn("series1");
when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn(true);
when(tuple.getLongByField(Constants.FIELD_TIMESTAMP)).thenReturn(1464038054645L);
bolt.execute(tuple);

代码示例来源:origin: Symantec/hendrix

when(tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW)).thenReturn(10);
when(tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY)).thenReturn("series1");
when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn(true);
when(tuple.getLongByField(Constants.FIELD_TIMESTAMP)).thenReturn(1464038054645L);
when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn(false);

代码示例来源:origin: Symantec/hendrix

when(tuple.getIntegerByField(Constants.FIELD_AGGREGATION_WINDOW)).thenReturn((Integer) values.get(2));
when(tuple.getStringByField(Constants.FIELD_RULE_ACTION_ID)).thenReturn((String) values.get(3));
when(tuple.getBooleanByField(Constants.FIELD_STATE_TRACK)).thenReturn((Boolean) values.get(0));
when(tuple.getStringByField(Constants.FIELD_AGGREGATION_KEY)).thenReturn((String) values.get(4));

代码示例来源:origin: mayconbordin/storm-applications

String word = input.getStringByField(Field.WORD);
int count = input.getIntegerByField(Field.COUNT);
boolean isSpam = input.getBooleanByField(Field.IS_SPAM);

相关文章