Commit fa8c0497 authored by Nick Karsky's avatar Nick Karsky
Browse files

dropped async cache stuff

parent cbb3131f
Pipeline #34568 failed with stage
in 55 seconds
......@@ -40,36 +40,10 @@ import java.util.concurrent.atomic.AtomicInteger;
* @Autowired
* private AsyncBlobStore asyncBlobStore;
*
* String readFromStorageContainerExample()
* {
* String content = asyncBlobStorage.readFromStorageContainer("dataPartitionId", "filePath", "containerName");
* if (content != null)
* return content;
* }
*
* void writeToStorageContainerAsyncExample()
* {
* asnycBlobStorage.writeToStorageContainer("dataPartitionId", "filePath", "content", "containerName");
* }
*
* void deleteFromStorageContainerExample()
* {
* Boolean success = asyncBlobStorage.deleteFromStorageContainer("dataPartitionId", "filePath", "containerName");
* }
*
* void getSasTokenExample()
* {
* int expiryDays = 7;
* OffsetDateTime expiryTime = OffsetDateTime.now().plusDays(expiryDays);
* BlobSasPermission permissions = (new BlobSasPermission()).setReadPermission(true).setCreatePermission(true);
* String sasToken = asyncBlobStorage.getSasToken("dataPartitionId", "filePath", "containerName", expiryTime, permissions);
* }
*
* void copyFileExample()
* {
* BlobCopyInfo copyInfo = asyncBlobStore.copyFile("dataPartitionId", "filePath", "containerName", "sourceFilePath");
* System.out.println("copy info " + copyInfo.getCopyStatus());
* }
* }
* </pre>
*/
......
......@@ -17,7 +17,6 @@ package org.opengroup.osdu.azure.blobstorage;
import com.azure.identity.DefaultAzureCredential;
import com.azure.storage.blob.BlobServiceAsyncClient;
import com.azure.storage.blob.BlobServiceClientBuilder;
import org.opengroup.osdu.azure.cache.BlobServiceAsyncClientCache;
import org.opengroup.osdu.azure.partition.PartitionInfoAzure;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.common.Validators;
......@@ -28,20 +27,16 @@ import org.opengroup.osdu.common.Validators;
public class BlobServiceAsyncClientFactoryImpl implements IBlobServiceAsyncClientFactory {
private DefaultAzureCredential defaultAzureCredential;
private PartitionServiceClient partitionService;
private BlobServiceAsyncClientCache clientCache;
/**
* Constructor to initialize instance of {@link BlobServiceAsyncClientFactoryImpl}.
* @param credentials Azure Credentials to use
* @param partitionServiceClient Partition service client to use
* @param blobServiceAsyncClientCache Blob service client cache to use
*/
public BlobServiceAsyncClientFactoryImpl(final DefaultAzureCredential credentials,
final PartitionServiceClient partitionServiceClient,
final BlobServiceAsyncClientCache blobServiceAsyncClientCache) {
final PartitionServiceClient partitionServiceClient) {
this.defaultAzureCredential = credentials;
this.partitionService = partitionServiceClient;
this.clientCache = blobServiceAsyncClientCache;
}
/**
......@@ -53,11 +48,6 @@ public class BlobServiceAsyncClientFactoryImpl implements IBlobServiceAsyncClien
Validators.checkNotNull(defaultAzureCredential, "Credential");
Validators.checkNotNullAndNotEmpty(dataPartitionId, "dataPartitionId");
String cacheKey = String.format("%s-blobServiceAsyncClient", dataPartitionId);
if (this.clientCache.containsKey(cacheKey)) {
return this.clientCache.get(cacheKey);
}
PartitionInfoAzure pi = this.partitionService.getPartition(dataPartitionId);
String endpoint = String.format("https://%s.blob.core.windows.net", pi.getStorageAccountName());
......@@ -66,8 +56,6 @@ public class BlobServiceAsyncClientFactoryImpl implements IBlobServiceAsyncClien
.credential(defaultAzureCredential)
.buildAsyncClient();
this.clientCache.put(cacheKey, blobServiceAsyncClient);
return blobServiceAsyncClient;
}
}
......@@ -2,7 +2,6 @@ package org.opengroup.osdu.azure.blobstorage;
import com.azure.identity.DefaultAzureCredential;
import org.opengroup.osdu.azure.cache.BlobServiceClientCache;
import org.opengroup.osdu.azure.cache.BlobServiceAsyncClientCache;
import org.opengroup.osdu.azure.partition.PartitionServiceClient;
import org.opengroup.osdu.core.common.logging.ILogger;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
......@@ -33,15 +32,13 @@ public class BlobStoreProvider {
* Creates instance of {@link IBlobServiceAsyncClientFactory}.
* @param defaultAzureCredential Azure credentials to use.
* @param partitionServiceClient Partition service client to use.
* @param blobServiceAsyncClientCache Blob service async client cache to use.
* @return instance of {@link BlobServiceClientFactoryImpl}
*/
@Bean
public IBlobServiceAsyncClientFactory buildBlobAsyncClientFactory(
final DefaultAzureCredential defaultAzureCredential,
final PartitionServiceClient partitionServiceClient,
final BlobServiceAsyncClientCache blobServiceAsyncClientCache) {
return new BlobServiceAsyncClientFactoryImpl(defaultAzureCredential, partitionServiceClient, blobServiceAsyncClientCache);
final PartitionServiceClient partitionServiceClient) {
return new BlobServiceAsyncClientFactoryImpl(defaultAzureCredential, partitionServiceClient);
}
/**
......
package org.opengroup.osdu.azure.cache;
import com.azure.storage.blob.BlobContainerAsyncClient;
import org.opengroup.osdu.core.common.cache.VmCache;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
/**
* Implementation of ICache for BlobContainerClient.
*/
@Component
@Lazy
public class BlobContainerAsyncClientCache extends VmCache<String, BlobContainerAsyncClient> {
/**
* Default cache constructor.
*/
public BlobContainerAsyncClientCache() {
super(60 * 60, 1000);
}
/**
* @param key cache key
* @return true if found in cache
*/
public boolean containsKey(final String key) {
return this.get(key) != null;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment