当前位置: 首页>>代码示例>>Java>>正文


Java Tuple.getValueByField方法代码示例

本文整理汇总了Java中org.apache.storm.tuple.Tuple.getValueByField方法的典型用法代码示例。如果您正苦于以下问题:Java Tuple.getValueByField方法的具体用法?Java Tuple.getValueByField怎么用?Java Tuple.getValueByField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.storm.tuple.Tuple的用法示例。


在下文中一共展示了Tuple.getValueByField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reloadBolt

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void reloadBolt(Tuple tuple) {
    String msg = null;
    try {
        PropertiesHolder.reload();
        ThreadLocalCache.reload();
        Command.initialize();
        msg = "dispatcher bolt reload successful!";
        logger.info("Dispatcher bolt was reloaded at:{}", System.currentTimeMillis());
    } catch (Exception e) {
        msg = e.getMessage();
        throw new RuntimeException(e);
    } finally {
        if (tuple != null) {
            EmitData data = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
            ControlMessage message = data.get(EmitData.MESSAGE);
            CtlMessageResult result = new CtlMessageResult("dispatcher-bolt", msg);
            result.setOriginalMessage(message);
            CtlMessageResultSender sender = new CtlMessageResultSender(message.getType(), zkConnect);
            sender.send("dispatcher-bolt-" + context.getThisTaskId(), result, false, true);
        }
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:24,代码来源:DispatcherBolt.java

示例2: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void execute(Tuple input) {
    if (TupleUtils.isTick(input)) {
        collector.ack(input);
        return;
    }

    try {
        Command cmd = (Command) input.getValueByField(EmitFields.COMMAND);
        BoltCommandHandler handler = handlerManager.getHandler(cmd);
        handler.handle(input);
        this.collector.ack(input);
    } catch (Exception e) {
        logger.error("Process data error", e);
        this.collector.reportError(e);
        this.collector.fail(input);
    }

}
 
开发者ID:BriData,项目名称:DBus,代码行数:20,代码来源:WrapperBolt.java

示例3: handle

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void handle(Tuple tuple) {
    EmitData data = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
    List<PairWrapper<String, Object>> wrapperList = data.get(EmitData.MESSAGE);
    DataTable table = data.get(EmitData.DATA_TABLE);
    MetaVersion ver = data.get(EmitData.VERSION);
    for (PairWrapper<String, Object> wrapper : wrapperList) {
        Object packet = wrapper.getPairValue("PACKET");
        JSONObject json = JSON.parseObject(packet.toString());
        String dbSchema = wrapper.getPairValue("SCHEMA_NAME").toString();
        String tableName = wrapper.getPairValue("TABLE_NAME").toString();

        String pos = wrapper.getProperties(Constants.MessageBodyKey.POS).toString();

        // oracle 数据格式:2017-03-24 14:28:00.995660,mysql格式:2017-03-24 14:28:00.995
        // 暂时不要统一
        //String opts = wrapper.getProperties(Constants.MessageBodyKey.OP_TS).toString().substring(0, 23);
        String opts = wrapper.getProperties(Constants.MessageBodyKey.OP_TS).toString();
        long time = json.getLong("time");
        long txTime = json.getLong("txTime");

        String targetTopic = listener.getTargetTopic(dbSchema, tableName);
        // 发送Heartbeat
        listener.sendHeartbeat(message(table, ver, pos, opts), targetTopic, buildKey(time + "|" + txTime, table, ver));
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:27,代码来源:HeartbeatDefaultHandler.java

示例4: handle

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void handle(Tuple tuple) {
	try{
		EmitData emitData = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
		List<MessageEntry> datas = emitData.get(EmitData.MESSAGE);
		long offset = emitData.get(EmitData.OFFSET);

        logger.debug("[BEGIN] receive data,offset:{}", offset);
        
        for(MessageEntry msgEntry : datas){
        	long pos = Long.parseLong(msgEntry.getEntryHeader().getPos());
        	syncMeta(msgEntry, pos, offset, tuple);
        }
	} catch (Exception e){
		logger.error("Error when processing data", e);
        throw new RuntimeException(e);
	}
}
 
开发者ID:BriData,项目名称:DBus,代码行数:19,代码来源:MaMetaSyncEventHandler.java

示例5: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void execute(Tuple input) {
    StatsComponentType componentId = StatsComponentType.valueOf(input.getSourceComponent());
    InfoMessage message = (InfoMessage) input.getValueByField(MESSAGE_FIELD);

    if (!Destination.WFM_STATS.equals(message.getDestination())) {
        collector.ack(input);
        return;
    }

    LOGGER.debug("Flow stats message: {}={}, component={}, stream={}",
            CORRELATION_ID, message.getCorrelationId(), componentId, StatsStreamType.valueOf(input.getSourceStreamId()));
    FlowStatsData data = (FlowStatsData) message.getData();
    long timestamp = message.getTimestamp();
    String switchId = data.getSwitchId().replaceAll(":", "");

    try {
        for (FlowStatsReply reply : data.getStats()) {
            for (FlowStatsEntry entry : reply.getEntries()) {
                emit(entry, timestamp, switchId);
            }
        }
    } finally {
        collector.ack(input);
    }
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:27,代码来源:FlowMetricGenBolt.java

示例6: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void execute(Tuple input) {
    if (TupleUtils.isTick(input)) {
        collector.ack(input);
        return;
    }
    try {
        Command cmd = (Command) input.getValueByField(EmitFields.COMMAND);
        BoltCommandHandler handler = handlerManager.getHandler(cmd);
        handler.handle(input);
        this.collector.ack(input);
    } catch (Exception e) {
        this.collector.fail(input);
        this.collector.reportError(e);
        logger.error("Process Error!", e);
    }

}
 
开发者ID:BriData,项目名称:DBus,代码行数:19,代码来源:DispatcherBolt.java

示例7: reloadBolt

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void reloadBolt(Tuple tuple) {
    String msg = null;
    try {
        PropertiesHolder.reload();
        Command.initialize();
        ThreadLocalCache.reload();
        msg = "appender bolt reload successful!";
        logger.info("Appender bolt was reloaded at:{}", System.currentTimeMillis());
    } catch (Exception e) {
        msg = e.getMessage();
        throw new RuntimeException(e);
    } finally {
        if (tuple != null) {
            EmitData data = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
            ControlMessage message = data.get(EmitData.MESSAGE);
            CtlMessageResult result = new CtlMessageResult("appender-bolt", msg);
            result.setOriginalMessage(message);
            CtlMessageResultSender sender = new CtlMessageResultSender(message.getType(), zkConnect);
            sender.send("appender-bolt-" + context.getThisTaskId(), result, false, true);
        }
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:24,代码来源:DbusAppenderBolt.java

示例8: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
public void execute(Tuple input, BasicOutputCollector arg1) {
	PacketDetailDTO packetDetailDTO = (PacketDetailDTO) input.getValueByField("usagestream");
	session.execute("INSERT INTO packet_usage (phone_number, bin, bout, total_bytes) VALUES ("
			+ packetDetailDTO.getPhoneNumber()
			+ ", "
			+ packetDetailDTO.getBin()
			+ ", "
			+ packetDetailDTO.getBout()
			+ ", " + packetDetailDTO.getTotalBytes() + ")");
}
 
开发者ID:PacktPublishing,项目名称:Practical-Real-time-Processing-and-Analytics,代码行数:11,代码来源:UsageCassandraBolt.java

示例9: writeData

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void writeData(String dbSchema, String table, DbusMessage dbusMessage, Tuple input) {
    EmitData data = (EmitData) input.getValueByField(Constants.EmitFields.DATA);
    List<String> topics = topicProvider.provideTopics(dbSchema, table);
    if (topics == null || topics.isEmpty()) {
        logger.error("Can't find a topic to write the message!");
        this.collector.ack(input);
        return;
    }

    String message = dbusMessage.toString();
    ProducerRecord<String, String> record = new ProducerRecord<>(topics.get(0), buildKey(dbusMessage), message);
    reporter.report(message.getBytes().length, dbusMessage.getPayload().size());
    Object offsetObj = data.get(EmitData.OFFSET);
    String offset = offsetObj != null ? offsetObj.toString() : "0";
    producer.send(record, (metadata, exception) -> {
        if (exception != null) {
            synchronized (this.collector) {
                this.collector.fail(input);
            }
            logger.error("Write data to kafka error, original data:[schema:{}, table:{}, offset:{}]!", dbSchema, table, offset, exception);
        } else {
            synchronized (this.collector) {
                this.collector.ack(input);
            }
            logger.info("kafka-message,original-offset:{}, key:{}", offset, record.key());
        }
    });
}
 
开发者ID:BriData,项目名称:DBus,代码行数:30,代码来源:DbusKafkaWriterBolt.java

示例10: handle

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void handle(Tuple tuple) {
    EmitData data = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
    String groupId = tuple.getStringByField(Constants.EmitFields.GROUP_FIELD);
    this.emitHeartbeat(listener.getOutputCollector(), tuple, groupId, data, Command.HEART_BEAT);
    if(logger.isDebugEnabled()) {
        Object offset = data.get(EmitData.OFFSET);
        logger.debug("[heartbeat] {} {} offset:{}", listener.getClass().getSimpleName(), groupId, offset == null ? -1 : offset);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:11,代码来源:CommonHeartbeatHandler.java

示例11: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
   public void execute(Tuple tuple) {

       String url = tuple.getStringByField("url");
       Metadata metadata = (Metadata) tuple.getValueByField("metadata");

System.out.println("DummyIndexer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set to FETCHED url: " + url);

       _collector.emit(
               com.digitalpebble.stormcrawler.Constants.StatusStreamName,
               tuple, new Values(url, metadata, Status.FETCHED));
       _collector.ack(tuple);
   }
 
开发者ID:eorliac,项目名称:patent-crawler,代码行数:14,代码来源:DummyIndexer.java

示例12: handle

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void handle(Tuple tuple) {
    EmitData emitData = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);

    Command cmd = (Command)tuple.getValueByField(Constants.EmitFields.COMMAND);
    String dbschema = emitData.get(EmitData.DB_SCHEMA);
    String table = emitData.get(EmitData.DATA_TABLE);
    this.emit(listener.getOutputCollector(), tuple, groupField(dbschema, table), emitData, cmd);
    logger.info("Full pull request[{}]", groupField(dbschema, table));
}
 
开发者ID:BriData,项目名称:DBus,代码行数:11,代码来源:DispatcherInitialLoadHandler.java

示例13: reloadBolt

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void reloadBolt(Tuple tuple) {
    String msg = null;
    try {
        PropertiesHolder.reload();
        ThreadLocalCache.reload();
        if (producer != null) {
            producer.close();
        }

        producer = createProducer();
        msg = "kafka write bolt reload successful!";
        logger.info("Kafka writer bolt was reloaded at:{}", System.currentTimeMillis());
    } catch (Exception e) {
        msg = e.getMessage();
        throw new RuntimeException(e);
    } finally {
        if (tuple != null) {
            EmitData data = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
            ControlMessage message = data.get(EmitData.MESSAGE);
            CtlMessageResult result = new CtlMessageResult("kafka-write-bolt", msg);
            result.setOriginalMessage(message);
            CtlMessageResultSender sender = new CtlMessageResultSender(message.getType(), zkconnect);
            sender.send("kafka-write-bolt-" + context.getThisTaskId(), result, false, true);
        }
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:28,代码来源:DbusKafkaWriterBolt.java

示例14: execute

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
public void execute(Tuple input) {
    if (TupleUtils.isTick(input)) {
        collector.ack(input);
        return;
    }
    try {
        Command cmd = (Command) input.getValueByField(Constants.EmitFields.COMMAND);
        BoltCommandHandler handler = handlerManager.getHandler(cmd);
        handler.handle(input);
        this.collector.ack(input);
    } catch (Exception e) {
        this.collector.ack(input);
        logger.error("Heartbeat error, ignore this error", e);
    }
}
 
开发者ID:BriData,项目名称:DBus,代码行数:16,代码来源:DbusHeartBeatBolt.java

示例15: handle

import org.apache.storm.tuple.Tuple; //导入方法依赖的package包/类
@Override
public void handle(Tuple tuple) {
    EmitData emitData = (EmitData) tuple.getValueByField(Constants.EmitFields.DATA);
    Command cmd = (Command)tuple.getValueByField(Constants.EmitFields.COMMAND);

    listener.reloadBolt(tuple);
    this.emitToAll(listener.getOutputCollector(), tuple, emitData, cmd);
}
 
开发者ID:BriData,项目名称:DBus,代码行数:9,代码来源:CommonReloadHandler.java


注:本文中的org.apache.storm.tuple.Tuple.getValueByField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。