private void doExecute(Tuple input) throws ParseException, UnsupportedEncodingException { // retrieve the input message byte[] data = input.getBinaryByField(VALUE.getFieldName()); if(data == null) { LOG.debug("Received null message. Nothing to do."); return; } // ensure there is a valid profiler configuration ProfilerConfig config = getProfilerConfig(); if(config == null || getProfilerConfig().getProfiles().size() == 0) { LOG.debug("No Profiler configuration found. Nothing to do."); return; } JSONObject message = (JSONObject) parser.parse(new String(data, "UTF8")); routeMessage(input, message, config); }
for (String cq : columnFamilies.get(cf)) { byte[] cqBytes = Bytes.toBytes(cq); byte[] val = tuple.getBinaryByField(cq);
@Override public byte[] format(Tuple tuple) { byte[] content = tuple.getBinaryByField("content"); String url = tuple.getStringByField("url"); Metadata metadata = (Metadata) tuple.getValueByField("metadata");
protected void parse(String url, byte[] content, Metadata metadata) throws IOException { Tuple tuple = mock(Tuple.class); when(tuple.getBinaryByField("content")).thenReturn(content); when(tuple.getStringByField("url")).thenReturn(url); when(tuple.getValueByField("metadata")).thenReturn(metadata); bolt.execute(tuple); }
protected void index(String url, String content, Metadata metadata) throws IOException { Tuple tuple = mock(Tuple.class); when(tuple.getBinaryByField("content")).thenReturn(content.getBytes()); when(tuple.getStringByField("url")).thenReturn(url); when(tuple.getValueByField("metadata")).thenReturn(metadata); bolt.execute(tuple); } }
public static Tuple getMockedTestTuple(String url, String content, Metadata metadata) { Tuple tuple = mock(Tuple.class); when(tuple.getStringByField("url")).thenReturn(url); when(tuple.getBinaryByField("content")).thenReturn( content.getBytes(Charset.defaultCharset())); if (metadata == null) { when(tuple.contains("metadata")).thenReturn(Boolean.FALSE); } else { when(tuple.contains("metadata")).thenReturn(Boolean.TRUE); when(tuple.getValueByField("metadata")).thenReturn(metadata); } return tuple; }
protected void parse(String url, String filename, Metadata metadata) throws IOException { byte[] content = readContent(filename); Tuple tuple = mock(Tuple.class); when(tuple.getBinaryByField("content")).thenReturn(content); when(tuple.getStringByField("url")).thenReturn(url); when(tuple.getValueByField("metadata")).thenReturn(metadata); bolt.execute(tuple); }
@Override public void execute(Tuple tuple) { String url = tuple.getStringByField("url"); byte[] content = tuple.getBinaryByField("content"); Metadata metadata = (Metadata) tuple.getValueByField("metadata"); String text = tuple.getStringByField("text"); Values v = new Values(url, content, metadata, text); // if there is a text - no need to parse it again if (StringUtils.isNotBlank(text)) { collector.emit(tuple, v); } else { collector.emit("tika", tuple, v); } collector.ack(tuple); }
@Override public void execute(Tuple tuple) { byte[] content = tuple.getBinaryByField("content"); String url = tuple.getStringByField("url"); Metadata metadata = (Metadata) tuple.getValueByField("metadata");
Metadata metadata = (Metadata) tuple.getValueByField("metadata"); byte[] content = tuple.getBinaryByField("content"); String url = tuple.getStringByField("url");
Metadata metadata = (Metadata) tuple.getValueByField("metadata"); byte[] content = tuple.getBinaryByField("content"); String url = tuple.getStringByField("url");
byte[] content = tuple.getBinaryByField("content"); String url = tuple.getStringByField("url"); final Metadata metadata = (Metadata) tuple.getValueByField("metadata");
@Override public void execute(Tuple tuple) { Metadata metadata = (Metadata) tuple.getValueByField("metadata"); byte[] content = tuple.getBinaryByField("content"); String url = tuple.getStringByField("url");
eventCounter.scope("tuple_in").incrBy(1); byte[] content = tuple.getBinaryByField("content");
@Override public void execute(Tuple tuple) { Metadata metadata = (Metadata) tuple.getValueByField("metadata"); byte[] content = tuple.getBinaryByField("content"); String url = tuple.getStringByField("url");
byte[] content = tuple.getBinaryByField("content"); String url = tuple.getStringByField("url");