You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by ra...@apache.org on 2025/10/05 19:09:29 UTC
(storm) branch issue_7978_blob_download created (now 36c4b816c)
This is an automated email from the ASF dual-hosted git repository.
rabreu pushed a change to branch issue_7978_blob_download
in repository https://gitbox.apache.org/repos/asf/storm.git
at 36c4b816c KeyAlreadyExistsException does not cause downloadMissingBlob to return false
This branch includes the following new commits:
new 36c4b816c KeyAlreadyExistsException does not cause downloadMissingBlob to return false
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(storm) 01/01: KeyAlreadyExistsException does not cause downloadMissingBlob to return false
Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rabreu pushed a commit to branch issue_7978_blob_download
in repository https://gitbox.apache.org/repos/asf/storm.git
commit 36c4b816cf52453b47cb337a27be7438d3c971b0
Author: Rui Abreu <ru...@gmail.com>
AuthorDate: Sun Oct 5 20:08:52 2025 +0100
KeyAlreadyExistsException does not cause downloadMissingBlob to return false
---
.../org/apache/storm/blobstore/BlobStoreUtils.java | 1 +
.../apache/storm/blobstore/BlobStoreUtilsTest.java | 51 +++++++++++++++++++---
2 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/storm-server/src/main/java/org/apache/storm/blobstore/BlobStoreUtils.java b/storm-server/src/main/java/org/apache/storm/blobstore/BlobStoreUtils.java
index cc1d54550..f42b0c7e0 100644
--- a/storm-server/src/main/java/org/apache/storm/blobstore/BlobStoreUtils.java
+++ b/storm-server/src/main/java/org/apache/storm/blobstore/BlobStoreUtils.java
@@ -150,6 +150,7 @@ public class BlobStoreUtils {
throw new RuntimeException(exception);
} catch (KeyAlreadyExistsException kae) {
LOG.info("KeyAlreadyExistsException Key: {} {}", key, kae);
+ isSuccess = true;
} catch (KeyNotFoundException knf) {
// Catching and logging KeyNotFoundException because, if
// there is a subsequent update and delete, the non-leader
diff --git a/storm-server/src/test/java/org/apache/storm/blobstore/BlobStoreUtilsTest.java b/storm-server/src/test/java/org/apache/storm/blobstore/BlobStoreUtilsTest.java
index fa4352691..6079c8432 100644
--- a/storm-server/src/test/java/org/apache/storm/blobstore/BlobStoreUtilsTest.java
+++ b/storm-server/src/test/java/org/apache/storm/blobstore/BlobStoreUtilsTest.java
@@ -12,17 +12,27 @@
package org.apache.storm.blobstore;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
+
+import org.apache.storm.generated.*;
import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.thrift.TException;
+import org.apache.storm.thrift.transport.TTransportException;
+import org.apache.storm.utils.NimbusClient;
import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+
+import javax.security.auth.Subject;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.atLeastOnce;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
public class BlobStoreUtilsTest {
@@ -126,4 +136,33 @@ public class BlobStoreUtilsTest {
verify(nimbusDetails).getHost();
verify(conf, atLeastOnce()).get(anyString());
}
+
+ @Test
+ public void testDownloadMissingBlob_KeyAkreadyExists() throws TException, IOException {
+
+ NimbusClient.Builder builder1 = mock(NimbusClient.Builder.class);
+ NimbusClient.Builder builder2 = mock(NimbusClient.Builder.class);
+ NimbusClient client = mock(NimbusClient.class);
+ ReadableBlobMeta readableBlobMeta = mock(ReadableBlobMeta.class);
+ Nimbus.Iface iface = mock(Nimbus.Iface.class);
+
+
+ try (MockedStatic<NimbusClient.Builder> mockedNimbusClient = Mockito.mockStatic(NimbusClient.Builder.class)) {
+
+ mockedNimbusClient.when(() ->NimbusClient.Builder.withConf(anyMap())).thenReturn(builder1);
+ when(builder1.forDaemon()).thenReturn(builder2);
+ when(builder2.buildWithNimbusHostPort(anyString(),anyInt())).thenReturn(client);
+ when(client.getClient()).thenReturn(iface);
+ when(iface.getBlobMeta(anyString())).thenReturn(readableBlobMeta);
+ when(readableBlobMeta.get_settable()).thenReturn(new SettableBlobMeta());
+ when(iface.beginBlobDownload(anyString())).thenReturn(new BeginDownloadResult());
+ when(nimbusDetails.getHost()).thenReturn("localhost");
+ when(nimbusDetails.getPort()).thenReturn(1234);
+
+ doThrow(new KeyAlreadyExistsException()).when(blobStore).createBlob(anyString(),any(InputStream.class),any(SettableBlobMeta.class),any(Subject.class));
+
+ assertTrue((BlobStoreUtils.downloadMissingBlob(conf, blobStore, "testKey", Collections.singleton(nimbusDetails))));
+ }
+
+ }
}