@Test public void testGetItemInfo() throws IOException { cache.putItem(ITEM_A_A); GoogleCloudStorageItemInfo result = gcs.getItemInfo(ITEM_A_A.getResourceId()); assertThat(result).isEqualTo(ITEM_A_A); assertThat(cache.getAllItemsRaw()).containsExactly(ITEM_A_A); }
@Override public GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException { GoogleCloudStorageItemInfo item = cache.getItem(resourceId); if (item == null && resourceId.isStorageObject()) { String bucketName = resourceId.getBucketName(); String objectName = resourceId.getObjectName(); int lastSlashIndex = objectName.lastIndexOf(PATH_DELIMITER); String directoryName = lastSlashIndex >= 0 ? objectName.substring(0, lastSlashIndex + 1) : null; listObjectInfoPage( bucketName, directoryName, ListObjectOptions.DEFAULT, null); item = cache.getItem(resourceId); } if (item == null) { item = super.getItemInfo(resourceId); cache.putItem(item); } return item; }
PerformanceCachingGoogleCloudStorage extends ForwardingGoogleCloudStorage { @Override public GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException { GoogleCloudStorageItemInfo item = cache.getItem(resourceId); if (item == null && resourceId.isStorageObject()) { String bucketName = resourceId.getBucketName(); String objectName = resourceId.getObjectName(); int lastSlashIndex = objectName.lastIndexOf(PATH_DELIMITER); String directoryName = lastSlashIndex >= 0 ? objectName.substring(0, lastSlashIndex + 1) : null; listObjectInfoPage( bucketName, directoryName, ListObjectOptions.DEFAULT, null); item = cache.getItem(resourceId); } if (item == null) { item = super.getItemInfo(resourceId); cache.putItem(item); } return item; } }
PerformanceCachingGoogleCloudStorage extends ForwardingGoogleCloudStorage { @Override public GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException { GoogleCloudStorageItemInfo item = cache.getItem(resourceId); if (item == null && resourceId.isStorageObject()) { String bucketName = resourceId.getBucketName(); String objectName = resourceId.getObjectName(); int lastSlashIndex = objectName.lastIndexOf(PATH_DELIMITER); String directoryName = lastSlashIndex >= 0 ? objectName.substring(0, lastSlashIndex + 1) : null; listObjectInfoPage( bucketName, directoryName, ListObjectOptions.DEFAULT, null); item = cache.getItem(resourceId); } if (item == null) { item = super.getItemInfo(resourceId); cache.putItem(item); } return item; } PerformanceCachingGoogleCloudStorage(
      GoogleCloudStorage delegate, PerformanceCachingGoogleCloudStorageOptions options); @VisibleForTesting  PerformanceCachingGoogleCloudStorage(
      GoogleCloudStorage delegate,
      PrefixMappedItemCache cache); }
PerformanceCachingGoogleCloudStorage extends ForwardingGoogleCloudStorage { @Override public GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException { GoogleCloudStorageItemInfo item = cache.getItem(resourceId); if (item == null && resourceId.isStorageObject()) { String bucketName = resourceId.getBucketName(); String objectName = resourceId.getObjectName(); int lastSlashIndex = objectName.lastIndexOf(PATH_DELIMITER); String directoryName = lastSlashIndex >= 0 ? objectName.substring(0, lastSlashIndex + 1) : null; listObjectInfoPage( bucketName, directoryName, ListObjectOptions.DEFAULT, null); item = cache.getItem(resourceId); } if (item == null) { item = super.getItemInfo(resourceId); cache.putItem(item); } return item; } PerformanceCachingGoogleCloudStorage(
      GoogleCloudStorage delegate, PerformanceCachingGoogleCloudStorageOptions options); @VisibleForTesting  PerformanceCachingGoogleCloudStorage(
      GoogleCloudStorage delegate,
      PrefixMappedItemCache cache); @Override WritableByteChannel create(StorageResourceId resourceId); @Override void deleteBuckets(List<String> bucketNames); @Override void deleteObjects(List<StorageResourceId> resourceIds); @Override List<GoogleCloudStorageItemInfo> listBucketInfo(); @Override List<String> listObjectNames(String bucketName, String objectNamePrefix); @Override List<String> listObjectNames(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions); @Override List<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix); @Override List<GoogleCloudStorageItemInfo> listObjectInfo(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions); @Override ListPage<GoogleCloudStorageItemInfo> listObjectInfoPage(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions, String pageToken); @Override GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId); @Override List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds); @Override List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList); @Override void close(); @Override GoogleCloudStorageItemInfo composeObjects(
      List<StorageResourceId> sources, StorageResourceId destination, CreateObjectOptions options); @VisibleForTesting void invalidateCache(); }
PerformanceCachingGoogleCloudStorage extends ForwardingGoogleCloudStorage { @Override public GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId) throws IOException { GoogleCloudStorageItemInfo item = cache.getItem(resourceId); if (item == null && resourceId.isStorageObject()) { String bucketName = resourceId.getBucketName(); String objectName = resourceId.getObjectName(); int lastSlashIndex = objectName.lastIndexOf(PATH_DELIMITER); String directoryName = lastSlashIndex >= 0 ? objectName.substring(0, lastSlashIndex + 1) : null; listObjectInfoPage( bucketName, directoryName, ListObjectOptions.DEFAULT, null); item = cache.getItem(resourceId); } if (item == null) { item = super.getItemInfo(resourceId); cache.putItem(item); } return item; } PerformanceCachingGoogleCloudStorage(
      GoogleCloudStorage delegate, PerformanceCachingGoogleCloudStorageOptions options); @VisibleForTesting  PerformanceCachingGoogleCloudStorage(
      GoogleCloudStorage delegate,
      PrefixMappedItemCache cache); @Override WritableByteChannel create(StorageResourceId resourceId); @Override void deleteBuckets(List<String> bucketNames); @Override void deleteObjects(List<StorageResourceId> resourceIds); @Override List<GoogleCloudStorageItemInfo> listBucketInfo(); @Override List<String> listObjectNames(String bucketName, String objectNamePrefix); @Override List<String> listObjectNames(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions); @Override List<GoogleCloudStorageItemInfo> listObjectInfo(String bucketName, String objectNamePrefix); @Override List<GoogleCloudStorageItemInfo> listObjectInfo(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions); @Override ListPage<GoogleCloudStorageItemInfo> listObjectInfoPage(
      String bucketName, String objectNamePrefix, ListObjectOptions listOptions, String pageToken); @Override GoogleCloudStorageItemInfo getItemInfo(StorageResourceId resourceId); @Override List<GoogleCloudStorageItemInfo> getItemInfos(List<StorageResourceId> resourceIds); @Override List<GoogleCloudStorageItemInfo> updateItems(List<UpdatableItemInfo> itemInfoList); @Override void close(); @Override GoogleCloudStorageItemInfo composeObjects(
      List<StorageResourceId> sources, StorageResourceId destination, CreateObjectOptions options); @VisibleForTesting void invalidateCache();  }