Remove the process to check if the target key exists or not

This commit is contained in:
Yu ISHIKAWA 2015-09-07 23:32:48 +09:00
parent c492a1aaae
commit d32a32a92d
2 changed files with 2 additions and 27 deletions

View File

@ -64,11 +64,6 @@ public class DeleteS3Object extends AbstractS3Processor {
public static final Set<Relationship> relationships = Collections.unmodifiableSet( public static final Set<Relationship> relationships = Collections.unmodifiableSet(
new HashSet<>(Arrays.asList(REL_SUCCESS, REL_FAILURE, REL_NOT_FOUND))); new HashSet<>(Arrays.asList(REL_SUCCESS, REL_FAILURE, REL_NOT_FOUND)));
@Override
public Set<Relationship> getRelationships() {
return relationships;
}
@Override @Override
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() { protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
return properties; return properties;
@ -89,16 +84,6 @@ public class DeleteS3Object extends AbstractS3Processor {
final AmazonS3 s3 = getClient(); final AmazonS3 s3 = getClient();
// Checks if the key exists or not
// If there is no such a key, then throws a exception
try {
s3.getObjectMetadata(bucket, key);
} catch (final AmazonServiceException ase) {
getLogger().error("Not found such a S3 object for {}; routing to not found", new Object[]{flowFile, ase});
session.transfer(flowFile, REL_NOT_FOUND);
return;
}
// Deletes a key on Amazon S3 // Deletes a key on Amazon S3
try { try {
if (versionId == null) { if (versionId == null) {

View File

@ -22,12 +22,9 @@ import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import com.amazonaws.auth.PropertiesCredentials; import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.AmazonS3Client;
@ -36,7 +33,7 @@ import com.amazonaws.services.s3.model.CreateBucketRequest;
import com.amazonaws.services.s3.model.DeleteBucketRequest; import com.amazonaws.services.s3.model.DeleteBucketRequest;
import com.amazonaws.services.s3.model.PutObjectRequest; import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.PutObjectResult; import com.amazonaws.services.s3.model.PutObjectResult;
import org.apache.nifi.processor.Relationship;
import org.apache.nifi.util.TestRunner; import org.apache.nifi.util.TestRunner;
import org.apache.nifi.util.TestRunners; import org.apache.nifi.util.TestRunners;
@ -128,14 +125,7 @@ public class TestDeleteS3Object {
runner.enqueue(new byte[0], attrs); runner.enqueue(new byte[0], attrs);
runner.run(1); runner.run(1);
runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_NOT_FOUND, 1); runner.assertAllFlowFilesTransferred(DeleteS3Object.REL_FAILURE, 1);
}
@Test
public void testGetRelationships() {
DeleteS3Object deleter = new DeleteS3Object();
Set<Relationship> relationships = deleter.getRelationships();
assertEquals(relationships.size(), 3);
} }
// Uploads a test file // Uploads a test file