@Override public final void initialize(final ProcessorInitializationContext context) { identifier = context.getIdentifier(); logger = context.getLogger(); serviceLookup = context.getControllerServiceLookup(); nodeTypeProvider = context.getNodeTypeProvider(); init(context); description = getClass().getSimpleName() + "[id=" + identifier + "]"; }
@Override protected void init(final ProcessorInitializationContext context) { kerberosServicePrincipal = context.getKerberosServicePrincipal(); kerberosConfigFile = context.getKerberosConfigurationFile(); kerberosServiceKeytab = context.getKerberosServiceKeytab(); }
t.setName("Monitor ListFile Performance [UUID=" + context.getIdentifier() + "]"); t.setDaemon(true);
@Override protected void init(ProcessorInitializationContext context) { hdfsResources.set(new HdfsResources(null, null, null)); kerberosConfigFile = context.getKerberosConfigurationFile(); kerberosProperties = getKerberosProperties(kerberosConfigFile); List<PropertyDescriptor> props = new ArrayList<>(); props.add(HADOOP_CONFIGURATION_RESOURCES); props.add(KERBEROS_CREDENTIALS_SERVICE); props.add(kerberosProperties.getKerberosPrincipal()); props.add(kerberosProperties.getKerberosKeytab()); props.add(KERBEROS_RELOGIN_PERIOD); props.add(ADDITIONAL_CLASSPATH_RESOURCES); properties = Collections.unmodifiableList(props); }
/** * Test MapMessage to FlowFile conversion * * @throws java.lang.Exception ex */ @Test public void testMap2FlowFileMapMessage() throws Exception { TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class); MapMessage mapMessage = createMapMessage(); ProcessContext context = runner.getProcessContext(); ProcessSession session = runner.getProcessSessionFactory().createSession(); ProcessorInitializationContext pic = new MockProcessorInitializationContext(runner.getProcessor(), (MockProcessContext) runner.getProcessContext()); JmsProcessingSummary summary = JmsConsumer.map2FlowFile(context, session, mapMessage, true, pic.getLogger()); assertEquals("MapMessage should not create FlowFile content", 0, summary.getBytesReceived()); Map<String, String> attributes = summary.getLastFlowFile().getAttributes(); assertEquals("", "Arnold", attributes.get(JmsConsumer.MAP_MESSAGE_PREFIX + "name")); assertEquals("", "97", attributes.get(JmsConsumer.MAP_MESSAGE_PREFIX + "age")); assertEquals("", "89686.564", attributes.get(JmsConsumer.MAP_MESSAGE_PREFIX + "xyz")); assertEquals("", "true", attributes.get(JmsConsumer.MAP_MESSAGE_PREFIX + "good")); }
@Override public void initialize(ConfigurableComponent component) { Processor processor = (Processor) component; ProcessorInitializationContext initializationContext = new MockProcessorInitializationContext(); try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(extensionManager, component.getClass(), initializationContext.getIdentifier())) { processor.initialize(initializationContext); } }
@Override protected void init(ProcessorInitializationContext context) { List<PropertyDescriptor> props = new ArrayList<>(); props.add(METASTORE_URI); props.add(HIVE_CONFIGURATION_RESOURCES); props.add(DB_NAME); props.add(TABLE_NAME); props.add(PARTITION_COLUMNS); props.add(AUTOCREATE_PARTITIONS); props.add(MAX_OPEN_CONNECTIONS); props.add(HEARTBEAT_INTERVAL); props.add(TXNS_PER_BATCH); props.add(RECORDS_PER_TXN); props.add(CALL_TIMEOUT); props.add(ROLLBACK_ON_FAILURE); props.add(KERBEROS_CREDENTIALS_SERVICE); kerberosConfigFile = context.getKerberosConfigurationFile(); kerberosProperties = new KerberosProperties(kerberosConfigFile); props.add(kerberosProperties.getKerberosPrincipal()); props.add(kerberosProperties.getKerberosKeytab()); propertyDescriptors = Collections.unmodifiableList(props); Set<Relationship> _relationships = new HashSet<>(); _relationships.add(REL_SUCCESS); _relationships.add(REL_FAILURE); _relationships.add(REL_RETRY); relationships = Collections.unmodifiableSet(_relationships); }
@Test public void testMap2FlowFileTextMessage() throws Exception { TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class); TextMessage textMessage = new ActiveMQTextMessage(); String payload = "Hello world!"; textMessage.setText(payload); ProcessContext context = runner.getProcessContext(); ProcessSession session = runner.getProcessSessionFactory().createSession(); ProcessorInitializationContext pic = new MockProcessorInitializationContext(runner.getProcessor(), (MockProcessContext) runner.getProcessContext()); JmsProcessingSummary summary = JmsConsumer.map2FlowFile(context, session, textMessage, true, pic.getLogger()); assertEquals("TextMessage content length should equal to FlowFile content size", payload.length(), summary.getLastFlowFile().getSize()); final byte[] buffer = new byte[payload.length()]; runner.clearTransferState(); session.read(summary.getLastFlowFile(), new InputStreamCallback() { @Override public void process(InputStream in) throws IOException { StreamUtils.fillBuffer(in, buffer, false); } }); String contentString = new String(buffer, "UTF-8"); assertEquals("", payload, contentString); }
@Override public void initialize(ConfigurableComponent component) { Processor processor = (Processor) component; ProcessorInitializationContext initializationContext = new MockProcessorInitializationContext(); try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), initializationContext.getIdentifier())) { processor.initialize(initializationContext); } }
@Override protected void init(final ProcessorInitializationContext context) { kerberosServicePrincipal = context.getKerberosServicePrincipal(); kerberosConfigFile = context.getKerberosConfigurationFile(); kerberosServiceKeytab = context.getKerberosServiceKeytab(); }
@Override protected void init(ProcessorInitializationContext context) { hdfsResources.set(new HdfsResources(null, null, null)); kerberosConfigFile = context.getKerberosConfigurationFile(); kerberosProperties = getKerberosProperties(kerberosConfigFile); List<PropertyDescriptor> props = new ArrayList<>(); props.add(HADOOP_CONFIGURATION_RESOURCES); props.add(KERBEROS_CREDENTIALS_SERVICE); props.add(kerberosProperties.getKerberosPrincipal()); props.add(kerberosProperties.getKerberosKeytab()); props.add(KERBEROS_RELOGIN_PERIOD); props.add(ADDITIONAL_CLASSPATH_RESOURCES); properties = Collections.unmodifiableList(props); }
/** * Test BytesMessage to FlowFile conversion * * @throws java.lang.Exception ex */ @Test public void testMap2FlowFileBytesMessage() throws Exception { TestRunner runner = TestRunners.newTestRunner(GetJMSQueue.class); BytesMessage bytesMessage = new ActiveMQBytesMessage(); String sourceString = "Apache NiFi is an easy to use, powerful, and reliable system to process and distribute data.!"; byte[] payload = sourceString.getBytes("UTF-8"); bytesMessage.writeBytes(payload); bytesMessage.reset(); ProcessContext context = runner.getProcessContext(); ProcessSession session = runner.getProcessSessionFactory().createSession(); ProcessorInitializationContext pic = new MockProcessorInitializationContext(runner.getProcessor(), (MockProcessContext) runner.getProcessContext()); JmsProcessingSummary summary = JmsConsumer.map2FlowFile(context, session, bytesMessage, true, pic.getLogger()); assertEquals("BytesMessage content length should equal to FlowFile content size", payload.length, summary.getLastFlowFile().getSize()); final byte[] buffer = new byte[payload.length]; runner.clearTransferState(); session.read(summary.getLastFlowFile(), new InputStreamCallback() { @Override public void process(InputStream in) throws IOException { StreamUtils.fillBuffer(in, buffer, false); } }); String contentString = new String(buffer, "UTF-8"); assertEquals("", sourceString, contentString); }
@Override public void initialize(ConfigurableComponent component) { Processor processor = (Processor) component; ProcessorInitializationContext initializationContext = new MockProcessorInitializationContext(); try (NarCloseable narCloseable = NarCloseable.withComponentNarLoader(component.getClass(), initializationContext.getIdentifier())) { processor.initialize(initializationContext); } }
@Override protected void init(ProcessorInitializationContext context) { List<PropertyDescriptor> props = new ArrayList<>(); props.add(METASTORE_URI); props.add(HIVE_CONFIGURATION_RESOURCES); props.add(DB_NAME); props.add(TABLE_NAME); props.add(PARTITION_COLUMNS); props.add(AUTOCREATE_PARTITIONS); props.add(MAX_OPEN_CONNECTIONS); props.add(HEARTBEAT_INTERVAL); props.add(TXNS_PER_BATCH); props.add(RECORDS_PER_TXN); props.add(CALL_TIMEOUT); props.add(ROLLBACK_ON_FAILURE); props.add(KERBEROS_CREDENTIALS_SERVICE); kerberosConfigFile = context.getKerberosConfigurationFile(); kerberosProperties = new KerberosProperties(kerberosConfigFile); props.add(kerberosProperties.getKerberosPrincipal()); props.add(kerberosProperties.getKerberosKeytab()); propertyDescriptors = Collections.unmodifiableList(props); Set<Relationship> _relationships = new HashSet<>(); _relationships.add(REL_SUCCESS); _relationships.add(REL_FAILURE); _relationships.add(REL_RETRY); relationships = Collections.unmodifiableSet(_relationships); }