Search in sources :

Example 6 with KerberosProperties

use of org.apache.nifi.hadoop.KerberosProperties in project nifi by apache.

the class PutHDFSTest method testPutFileWithException.

@Test
public void testPutFileWithException() throws IOException {
    // Refer to comment in the BeforeClass method for an explanation
    assumeTrue(isNotWindows());
    String dirName = "target/testPutFileWrongPermissions";
    File file = new File(dirName);
    file.mkdirs();
    Configuration config = new Configuration();
    FileSystem fs = FileSystem.get(config);
    Path p = new Path(dirName).makeQualified(fs.getUri(), fs.getWorkingDirectory());
    final KerberosProperties testKerberosProperties = kerberosProperties;
    TestRunner runner = TestRunners.newTestRunner(new PutHDFS() {

        @Override
        protected void changeOwner(ProcessContext context, FileSystem hdfs, Path name, FlowFile flowFile) {
            throw new ProcessException("Forcing Exception to get thrown in order to verify proper handling");
        }

        @Override
        protected KerberosProperties getKerberosProperties(File kerberosConfigFile) {
            return testKerberosProperties;
        }
    });
    runner.setProperty(PutHDFS.DIRECTORY, dirName);
    runner.setProperty(PutHDFS.CONFLICT_RESOLUTION, "replace");
    try (FileInputStream fis = new FileInputStream("src/test/resources/testdata/randombytes-1")) {
        Map<String, String> attributes = new HashMap<String, String>();
        attributes.put(CoreAttributes.FILENAME.key(), "randombytes-1");
        runner.enqueue(fis, attributes);
        runner.run();
    }
    List<MockFlowFile> failedFlowFiles = runner.getFlowFilesForRelationship(new Relationship.Builder().name("failure").build());
    assertFalse(failedFlowFiles.isEmpty());
    assertTrue(failedFlowFiles.get(0).isPenalized());
    fs.delete(p, true);
}
Also used : Path(org.apache.hadoop.fs.Path) FlowFile(org.apache.nifi.flowfile.FlowFile) MockFlowFile(org.apache.nifi.util.MockFlowFile) Configuration(org.apache.hadoop.conf.Configuration) HashMap(java.util.HashMap) TestRunner(org.apache.nifi.util.TestRunner) MockProcessContext(org.apache.nifi.util.MockProcessContext) ProcessContext(org.apache.nifi.processor.ProcessContext) FileInputStream(java.io.FileInputStream) MockFlowFile(org.apache.nifi.util.MockFlowFile) ProcessException(org.apache.nifi.processor.exception.ProcessException) FileSystem(org.apache.hadoop.fs.FileSystem) Relationship(org.apache.nifi.processor.Relationship) FlowFile(org.apache.nifi.flowfile.FlowFile) File(java.io.File) MockFlowFile(org.apache.nifi.util.MockFlowFile) KerberosProperties(org.apache.nifi.hadoop.KerberosProperties) Test(org.junit.Test)

Example 7 with KerberosProperties

use of org.apache.nifi.hadoop.KerberosProperties in project nifi by apache.

the class PutHDFSTest method setup.

@Before
public void setup() {
    mockNiFiProperties = mock(NiFiProperties.class);
    when(mockNiFiProperties.getKerberosConfigurationFile()).thenReturn(null);
    kerberosProperties = new KerberosProperties(null);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) KerberosProperties(org.apache.nifi.hadoop.KerberosProperties) Before(org.junit.Before)

Example 8 with KerberosProperties

use of org.apache.nifi.hadoop.KerberosProperties in project nifi by apache.

the class TestDeleteHDFS method setup.

@Before
public void setup() throws Exception {
    mockNiFiProperties = mock(NiFiProperties.class);
    when(mockNiFiProperties.getKerberosConfigurationFile()).thenReturn(null);
    kerberosProperties = new KerberosProperties(null);
    mockFileSystem = mock(FileSystem.class);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) FileSystem(org.apache.hadoop.fs.FileSystem) KerberosProperties(org.apache.nifi.hadoop.KerberosProperties) Before(org.junit.Before)

Example 9 with KerberosProperties

use of org.apache.nifi.hadoop.KerberosProperties in project nifi by apache.

the class TestFetchHDFS method setup.

@Before
public void setup() {
    mockNiFiProperties = mock(NiFiProperties.class);
    when(mockNiFiProperties.getKerberosConfigurationFile()).thenReturn(null);
    kerberosProperties = new KerberosProperties(null);
    proc = new TestableFetchHDFS(kerberosProperties);
    runner = TestRunners.newTestRunner(proc);
}
Also used : NiFiProperties(org.apache.nifi.util.NiFiProperties) KerberosProperties(org.apache.nifi.hadoop.KerberosProperties) Before(org.junit.Before)

Example 10 with KerberosProperties

use of org.apache.nifi.hadoop.KerberosProperties in project nifi by apache.

the class PutHiveStreaming method init.

@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);
}
Also used : PropertyDescriptor(org.apache.nifi.components.PropertyDescriptor) Relationship(org.apache.nifi.processor.Relationship) ArrayList(java.util.ArrayList) KerberosProperties(org.apache.nifi.hadoop.KerberosProperties) HashSet(java.util.HashSet)

Aggregations

KerberosProperties (org.apache.nifi.hadoop.KerberosProperties)17 Before (org.junit.Before)13 NiFiProperties (org.apache.nifi.util.NiFiProperties)9 File (java.io.File)6 ArrayList (java.util.ArrayList)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 PropertyDescriptor (org.apache.nifi.components.PropertyDescriptor)2 Relationship (org.apache.nifi.processor.Relationship)2 MockFlowFile (org.apache.nifi.util.MockFlowFile)2 TestRunner (org.apache.nifi.util.TestRunner)2 Test (org.junit.Test)2 FileInputStream (java.io.FileInputStream)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 Table (org.apache.hadoop.hbase.client.Table)1 DFSInotifyEventInputStream (org.apache.hadoop.hdfs.DFSInotifyEventInputStream)1 HdfsAdmin (org.apache.hadoop.hdfs.client.HdfsAdmin)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1