[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user asfgit closed the pull request at: https://github.com/apache/nifi/pull/2294 ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167943515 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), +@WritesAttribute( attribute = "rowkey.end", description = "The last rowkey in the flowfile. Only written when a flowfile contains multiple deletes.") +} +) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final String RESTART_INDEX = "restart.index"; +static final String ROWKEY_START = "rowkey.start"; +static final String ROWKEY_END = "rowkey.end"; + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-batch-size") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167941736 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), +@WritesAttribute( attribute = "rowkey.end", description = "The last rowkey in the flowfile. Only written when a flowfile contains multiple deletes.") +} +) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167940501 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), +@WritesAttribute( attribute = "rowkey.end", description = "The last rowkey in the flowfile. Only written when a flowfile contains multiple deletes.") --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167940422 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), --- End diff -- Done. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167940095 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/TestDeleteHBaseRow.java --- @@ -0,0 +1,197 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.util.MockFlowFile; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class TestDeleteHBaseRow { +private TestRunner runner; +private MockHBaseClientService hBaseClient; + +@Before +public void setup() throws InitializationException { +runner = TestRunners.newTestRunner(new DeleteHBaseRow()); + +hBaseClient = new MockHBaseClientService(); +runner.addControllerService("hbaseClient", hBaseClient); +runner.enableControllerService(hBaseClient); + +runner.setProperty(DeleteHBaseRow.TABLE_NAME, "nifi"); +runner.setProperty(DeleteHBaseRow.HBASE_CLIENT_SERVICE, "hbaseClient"); +} + +List populateTable(int max) { +List ids = new ArrayList<>(); +for (int index = 0; index < max; index++) { +String uuid = UUID.randomUUID().toString(); +ids.add(uuid); +Mapcells = new HashMap<>(); +cells.put("test", UUID.randomUUID().toString()); +hBaseClient.addResult(uuid, cells, System.currentTimeMillis()); +} + +return ids; +} + +@Test +public void testSimpleDelete() { +List ids = populateTable(100); + +runner.setProperty(DeleteHBaseRow.BATCH_SIZE, "100"); +runner.setProperty(DeleteHBaseRow.FLOWFILE_FETCH_COUNT, "100"); +for (String id : ids) { +runner.enqueue(id); +} + +runner.run(1, true); +Assert.assertTrue("The mock client was not empty.", hBaseClient.isEmpty()); +} + +private String buildSeparatedString(List ids, String separator) { +StringBuilder sb = new StringBuilder(); +for (int index = 1; index <= ids.size(); index++) { +sb.append(ids.get(index - 1)).append(separator); +} + +return sb.toString(); +} + +private void testSeparatedDeletes(String separator) { +testSeparatedDeletes(separator, separator, new HashMap()); +} + +private void testSeparatedDeletes(String separator, String separatorProp, Map attrs) { +List ids = populateTable(1); +runner.setProperty(DeleteHBaseRow.KEY_SEPARATOR, separator); +runner.setProperty(DeleteHBaseRow.BATCH_SIZE, "100"); +runner.enqueue(buildSeparatedString(ids, separatorProp), attrs); +runner.run(1, true); + +Assert.assertTrue("The mock client was not empty.", hBaseClient.isEmpty()); +} + +@Test +public void testDeletesSeparatedByNewLines() { +testSeparatedDeletes("\n"); +} + +@Test +public void testDeletesSeparatedByCommas() { +testSeparatedDeletes(","); +} + +@Test +public void testDeleteWithELSeparator() { +runner.setValidateExpressionUsage(true); +Map attrs = new HashMap<>(); +attrs.put("test.separator", ""); +testSeparatedDeletes("${test.separator}", "", attrs); +} + +@Test +public void testDeleteWithExpressionLanguage() { +List ids = populateTable(1000);
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167939817 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), +@WritesAttribute( attribute = "rowkey.end", description = "The last rowkey in the flowfile. Only written when a flowfile contains multiple deletes.") +} +) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167854208 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), --- End diff -- It says "Only written when a flowfile contains multiple deletes." but the attribute is written when a FlowFile only contains single row id. It would be more accurate if we say "Only written when deleting Row IDs from flowfile content." ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167857406 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), +@WritesAttribute( attribute = "rowkey.end", description = "The last rowkey in the flowfile. Only written when a flowfile contains multiple deletes.") +} +) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final String RESTART_INDEX = "restart.index"; +static final String ROWKEY_START = "rowkey.start"; +static final String ROWKEY_END = "rowkey.end"; + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-batch-size") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167851490 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/TestDeleteHBaseRow.java --- @@ -0,0 +1,197 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.util.MockFlowFile; +import org.apache.nifi.util.TestRunner; +import org.apache.nifi.util.TestRunners; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +public class TestDeleteHBaseRow { +private TestRunner runner; +private MockHBaseClientService hBaseClient; + +@Before +public void setup() throws InitializationException { +runner = TestRunners.newTestRunner(new DeleteHBaseRow()); + +hBaseClient = new MockHBaseClientService(); +runner.addControllerService("hbaseClient", hBaseClient); +runner.enableControllerService(hBaseClient); + +runner.setProperty(DeleteHBaseRow.TABLE_NAME, "nifi"); +runner.setProperty(DeleteHBaseRow.HBASE_CLIENT_SERVICE, "hbaseClient"); +} + +List populateTable(int max) { +List ids = new ArrayList<>(); +for (int index = 0; index < max; index++) { +String uuid = UUID.randomUUID().toString(); +ids.add(uuid); +Mapcells = new HashMap<>(); +cells.put("test", UUID.randomUUID().toString()); +hBaseClient.addResult(uuid, cells, System.currentTimeMillis()); +} + +return ids; +} + +@Test +public void testSimpleDelete() { +List ids = populateTable(100); + +runner.setProperty(DeleteHBaseRow.BATCH_SIZE, "100"); +runner.setProperty(DeleteHBaseRow.FLOWFILE_FETCH_COUNT, "100"); +for (String id : ids) { +runner.enqueue(id); +} + +runner.run(1, true); +Assert.assertTrue("The mock client was not empty.", hBaseClient.isEmpty()); +} + +private String buildSeparatedString(List ids, String separator) { +StringBuilder sb = new StringBuilder(); +for (int index = 1; index <= ids.size(); index++) { +sb.append(ids.get(index - 1)).append(separator); +} + +return sb.toString(); +} + +private void testSeparatedDeletes(String separator) { +testSeparatedDeletes(separator, separator, new HashMap()); +} + +private void testSeparatedDeletes(String separator, String separatorProp, Map attrs) { +List ids = populateTable(1); +runner.setProperty(DeleteHBaseRow.KEY_SEPARATOR, separator); +runner.setProperty(DeleteHBaseRow.BATCH_SIZE, "100"); +runner.enqueue(buildSeparatedString(ids, separatorProp), attrs); +runner.run(1, true); + +Assert.assertTrue("The mock client was not empty.", hBaseClient.isEmpty()); +} + +@Test +public void testDeletesSeparatedByNewLines() { +testSeparatedDeletes("\n"); +} + +@Test +public void testDeletesSeparatedByCommas() { +testSeparatedDeletes(","); +} + +@Test +public void testDeleteWithELSeparator() { +runner.setValidateExpressionUsage(true); +Map attrs = new HashMap<>(); +attrs.put("test.separator", ""); +testSeparatedDeletes("${test.separator}", "", attrs); +} + +@Test +public void testDeleteWithExpressionLanguage() { +List ids =
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167858912 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), +@WritesAttribute( attribute = "rowkey.end", description = "The last rowkey in the flowfile. Only written when a flowfile contains multiple deletes.") +} +) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); --- End diff -- I'd suggest keep the naming consistent. Both of `body` and `content` are used, but it would be cleaner if we use just one of them. If so, I'd prefer `content`. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167854611 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), +@WritesAttribute( attribute = "rowkey.end", description = "The last rowkey in the flowfile. Only written when a flowfile contains multiple deletes.") --- End diff -- Same comment as "rowkey.start" on the description applied here. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167851239 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.behavior.WritesAttributes; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttributes( +value = { +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' " + +"relationship, so that this processor can retry from there when the same FlowFile is routed again." ), +@WritesAttribute( attribute = "rowkey.start", description = "The first rowkey in the flowfile. Only written when a flowfile contains multiple deletes."), +@WritesAttribute( attribute = "rowkey.end", description = "The last rowkey in the flowfile. Only written when a flowfile contains multiple deletes.") +} +) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { --- End diff -- `@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)` should be added. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167319088 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/MockHBaseClientService.java --- @@ -71,6 +73,43 @@ public void delete(String tableName, byte[] rowId) throws IOException { throw new UnsupportedOperationException(); } +@Override +public void delete(String tableName, ListrowIds) throws IOException { +if (throwException) { +throw new RuntimeException("Simulated connectivity error"); +} + +Random random = new Random(); +int location = 0; +if (rowIds.size() > 1) { +while (location == 0) { +location = random.nextInt(rowIds.size()); --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167319106 --- Diff: nifi-nar-bundles/nifi-standard-services/nifi-hbase-client-service-api/src/main/java/org/apache/nifi/hbase/HBaseClientService.java --- @@ -116,6 +117,13 @@ */ void delete(String tableName, byte[] rowId) throws IOException; +/** + * Deletes a list of rows in HBase. All cells are deleted. + * + */ + --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167210043 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/AbstractDeleteHBase.java --- @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractDeleteHBase extends AbstractProcessor { +protected static final PropertyDescriptor HBASE_CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("HBase Client Service") +.description("Specifies the Controller Service to use for accessing HBase.") +.required(true) +.identifiesControllerService(HBaseClientService.class) +.build(); +protected static final PropertyDescriptor TABLE_NAME = new PropertyDescriptor.Builder() +.name("Table Name") +.description("The name of the HBase Table to put data into") --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167209979 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, it will restart from restart.index" ) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor KEY_SEPARATOR = new PropertyDescriptor.Builder() +.name("delete-hb-separator") +.displayName("Delete Row Key Separator") +.description("The separator character(s) that separate multiple row keys " + +"when multiple row keys are provided in the flowfile body") +.required(true) +.defaultValue(",") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.expressionLanguageSupported(true) +.build(); +static final PropertyDescriptor CHARSET = new
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167210016 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/AbstractDeleteHBase.java --- @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractDeleteHBase extends AbstractProcessor { +protected static final PropertyDescriptor HBASE_CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("HBase Client Service") +.description("Specifies the Controller Service to use for accessing HBase.") +.required(true) +.identifiesControllerService(HBaseClientService.class) +.build(); +protected static final PropertyDescriptor TABLE_NAME = new PropertyDescriptor.Builder() +.name("Table Name") +.description("The name of the HBase Table to put data into") +.required(true) +.expressionLanguageSupported(true) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); +protected static final PropertyDescriptor ROW_ID = new PropertyDescriptor.Builder() +.name("Row Identifier") +.description("Specifies the Row ID to use when inserting data into HBase") --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167209940 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, it will restart from restart.index" ) --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167209961 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, it will restart from restart.index" ) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") --- End diff -- Done ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167195155 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/AbstractDeleteHBase.java --- @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractDeleteHBase extends AbstractProcessor { --- End diff -- I was planning to do a DeleteHBaseRecords processor later. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167150445 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, it will restart from restart.index" ) --- End diff -- This description can be improved. It's possible that user might expect restart happens automatically. How about something like: "If a delete batch fails, 'restart.index' attribute is added to the FlowFile and sent to 'failure' relationship, so that this processor can retry from there when the same FlowFile is routed again." ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167148328 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, it will restart from restart.index" ) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") --- End diff -- What does this "ff" stand for? I wonder if "delete-hb-batch-size" sounds better. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167152061 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/MockHBaseClientService.java --- @@ -71,6 +73,43 @@ public void delete(String tableName, byte[] rowId) throws IOException { throw new UnsupportedOperationException(); } +@Override +public void delete(String tableName, ListrowIds) throws IOException { +if (throwException) { +throw new RuntimeException("Simulated connectivity error"); +} + +Random random = new Random(); +int location = 0; +if (rowIds.size() > 1) { +while (location == 0) { +location = random.nextInt(rowIds.size()); --- End diff -- Using random to simulate exception situation looks cool, but it should be avoided in unit testing where we want consistent behavior at every time. I prefer making it a parameter passed from the test method. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167147850 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/AbstractDeleteHBase.java --- @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractDeleteHBase extends AbstractProcessor { +protected static final PropertyDescriptor HBASE_CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("HBase Client Service") +.description("Specifies the Controller Service to use for accessing HBase.") +.required(true) +.identifiesControllerService(HBaseClientService.class) +.build(); +protected static final PropertyDescriptor TABLE_NAME = new PropertyDescriptor.Builder() +.name("Table Name") +.description("The name of the HBase Table to put data into") +.required(true) +.expressionLanguageSupported(true) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); +protected static final PropertyDescriptor ROW_ID = new PropertyDescriptor.Builder() +.name("Row Identifier") +.description("Specifies the Row ID to use when inserting data into HBase") +.required(false) // not all sub-classes will require this +.expressionLanguageSupported(true) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) --- End diff -- It would be more user friendly if we add custom validate to suggest setting this property when `Row Id Location` is `FlowFIle attributes` ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167148081 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, it will restart from restart.index" ) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor KEY_SEPARATOR = new PropertyDescriptor.Builder() +.name("delete-hb-separator") +.displayName("Delete Row Key Separator") +.description("The separator character(s) that separate multiple row keys " + +"when multiple row keys are provided in the flowfile body") +.required(true) +.defaultValue(",") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.expressionLanguageSupported(true) +.build(); +static final PropertyDescriptor CHARSET = new
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167149587 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, it will restart from restart.index" ) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor KEY_SEPARATOR = new PropertyDescriptor.Builder() +.name("delete-hb-separator") +.displayName("Delete Row Key Separator") +.description("The separator character(s) that separate multiple row keys " + +"when multiple row keys are provided in the flowfile body") +.required(true) +.defaultValue(",") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.expressionLanguageSupported(true) +.build(); +static final PropertyDescriptor CHARSET = new
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167144332 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/AbstractDeleteHBase.java --- @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractDeleteHBase extends AbstractProcessor { +protected static final PropertyDescriptor HBASE_CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("HBase Client Service") +.description("Specifies the Controller Service to use for accessing HBase.") +.required(true) +.identifiesControllerService(HBaseClientService.class) +.build(); +protected static final PropertyDescriptor TABLE_NAME = new PropertyDescriptor.Builder() +.name("Table Name") +.description("The name of the HBase Table to put data into") --- End diff -- This should be 'to delete'. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167150836 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,183 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.behavior.WritesAttribute; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +@WritesAttribute( attribute = "restart.index", description = "If a delete batch fails, it will restart from restart.index" ) +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor KEY_SEPARATOR = new PropertyDescriptor.Builder() +.name("delete-hb-separator") +.displayName("Delete Row Key Separator") +.description("The separator character(s) that separate multiple row keys " + +"when multiple row keys are provided in the flowfile body") +.required(true) +.defaultValue(",") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.expressionLanguageSupported(true) +.build(); +static final PropertyDescriptor CHARSET = new
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user ijokarumawak commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r167144686 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/AbstractDeleteHBase.java --- @@ -0,0 +1,103 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.nifi.annotation.lifecycle.OnScheduled; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.processor.AbstractProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public abstract class AbstractDeleteHBase extends AbstractProcessor { +protected static final PropertyDescriptor HBASE_CLIENT_SERVICE = new PropertyDescriptor.Builder() +.name("HBase Client Service") +.description("Specifies the Controller Service to use for accessing HBase.") +.required(true) +.identifiesControllerService(HBaseClientService.class) +.build(); +protected static final PropertyDescriptor TABLE_NAME = new PropertyDescriptor.Builder() +.name("Table Name") +.description("The name of the HBase Table to put data into") +.required(true) +.expressionLanguageSupported(true) +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.build(); +protected static final PropertyDescriptor ROW_ID = new PropertyDescriptor.Builder() +.name("Row Identifier") +.description("Specifies the Row ID to use when inserting data into HBase") --- End diff -- Should be "deleting data from HBase". ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r160178312 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.List; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor KEY_SEPARATOR = new PropertyDescriptor.Builder() +.name("delete-hb-separator") +.displayName("Delete Row Key Separator") +.description("The separator character(s) that separate multiple row keys " + +"when multiple row keys are provided in the flowfile body") +.required(true) +.defaultValue(",") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.expressionLanguageSupported(true) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); +
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r160140592 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,154 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.List; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor KEY_SEPARATOR = new PropertyDescriptor.Builder() +.name("delete-hb-separator") +.displayName("Delete Row Key Separator") +.description("The separator character(s) that separate multiple row keys " + +"when multiple row keys are provided in the flowfile body") +.required(true) +.defaultValue(",") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.expressionLanguageSupported(true) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); +
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r159047973 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor KEY_SEPARATOR = new PropertyDescriptor.Builder() +.name("delete-hb-separator") +.displayName("Delete Row Key Separator") +.description("The separator character(s) that separate multiple row keys " + +"when multiple row keys are provided in the flowfile body") +.required(true) +.defaultValue(",") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r159047906 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,158 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue(ROW_ID_BODY.getValue()) +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor KEY_SEPARATOR = new PropertyDescriptor.Builder() +.name("delete-hb-separator") +.displayName("Delete Row Key Separator") +.description("The separator character(s) that separate multiple row keys " + +"when multiple row keys are provided in the flowfile body") +.required(true) +.defaultValue(",") +.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157414765 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null &&
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157383920 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157383902 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157377689 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null &&
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157368968 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157368931 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157368648 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user MikeThomsen commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157368551 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); --- End diff -- It might be, but I've never been told to change it before. If someone wants to make a real issue of it, I'll change it. Otherwise, I think it helps with readability in cases like this. ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157258216 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null &&
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157257248 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null &&
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157256777 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null &&
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157256636 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); +final String location = context.getProperty(ROW_ID_LOCATION).getValue(); +final int flowFileCount = context.getProperty(FLOWFILE_FETCH_COUNT).asInteger(); +List flowFiles = session.get(flowFileCount); + +if (flowFiles != null &&
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157256381 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") +.allowableValues(ROW_ID_BODY, ROW_ID_ATTR) +.addValidator(Validator.VALID) +.build(); + +static final PropertyDescriptor FLOWFILE_FETCH_COUNT = new PropertyDescriptor.Builder() +.name("delete-hb-flowfile-fetch-count") +.displayName("Flowfile Fetch Count") +.description("The number of flowfiles to fetch per run.") +.required(true) +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.defaultValue("5") +.expressionLanguageSupported(false) +.build(); + +static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor.Builder() +.name("delete-hb-row-ff-count") +.displayName("Batch Size") +.description("The number of deletes to send per batch.") +.required(true) +.defaultValue("50") +.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR) +.expressionLanguageSupported(false) +.build(); + +@Override +protected List getSupportedPropertyDescriptors() { +final List properties = super.getSupportedPropertyDescriptors(); +properties.add(ROW_ID_LOCATION); +properties.add(FLOWFILE_FETCH_COUNT); +properties.add(BATCH_SIZE); + +return properties; +} + +@Override +protected void doDelete(ProcessContext context, ProcessSession session) throws Exception { +final int batchSize = context.getProperty(BATCH_SIZE).asInteger(); --- End diff -- I think that the preferred syntax in the project is to have only one space before and after the `=` sign ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
Github user mgaido91 commented on a diff in the pull request: https://github.com/apache/nifi/pull/2294#discussion_r157255826 --- Diff: nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/main/java/org/apache/nifi/hbase/DeleteHBaseRow.java --- @@ -0,0 +1,178 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.nifi.hbase; + +import org.apache.commons.io.IOUtils; +import org.apache.nifi.annotation.documentation.CapabilityDescription; +import org.apache.nifi.annotation.documentation.Tags; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.Validator; +import org.apache.nifi.flowfile.FlowFile; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.util.StandardValidators; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Tags({ "delete", "hbase" }) +@CapabilityDescription( +"Delete HBase records individually or in batches. The input can be a single row ID in the body, one ID per line, " + +"row IDs separated by commas or a combination of the two. ") +public class DeleteHBaseRow extends AbstractDeleteHBase { +static final AllowableValue ROW_ID_BODY = new AllowableValue("body", "FlowFile content", "Get the row key(s) from the flowfile content."); +static final AllowableValue ROW_ID_ATTR = new AllowableValue("attr", "FlowFile attributes", "Get the row key from an expression language statement."); + +static final PropertyDescriptor ROW_ID_LOCATION = new PropertyDescriptor.Builder() +.name("delete-hb-row-id-location") +.displayName("Row ID Location") +.description("The location of the row ID to use for building the delete. Can be from the content or an expression language statement.") +.required(true) +.defaultValue("body") --- End diff -- what about using `defaultValue(ROW_ID_BODY.getValue())`? ---
[GitHub] nifi pull request #2294: NIFI-3538 Added DeleteHBaseRow
GitHub user MikeThomsen opened a pull request: https://github.com/apache/nifi/pull/2294 NIFI-3538 Added DeleteHBaseRow Thank you for submitting a contribution to Apache NiFi. In order to streamline the review of the contribution we ask you to ensure the following steps have been taken: ### For all changes: - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in the commit message? - [ ] Does your PR title start with NIFI- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [ ] Has your PR been rebased against the latest commit within the target branch (typically master)? - [ ] Is your initial contribution a single, squashed commit? ### For code changes: - [ ] Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder? - [ ] Have you written or updated unit tests to verify your changes? - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)? - [ ] If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly? - [ ] If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly? - [ ] If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties? ### For documentation related changes: - [ ] Have you ensured that format looks appropriate for the output in which it is rendered? ### Note: Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible. You can merge this pull request into a Git repository by running: $ git pull https://github.com/MikeThomsen/nifi NIFI-3538 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/nifi/pull/2294.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #2294 commit 6df9cc009be3ea681d3029e5bc40118a9dd26dd7 Author: Mike ThomsenDate: 2017-11-24T11:06:41Z NIFI-3538 Added DeleteHBaseRow ---