@ThreadSafe public final class CloudStorageFileSystem extends FileSystem
FileSystem
implementation.Modifier and Type | Field and Description |
---|---|
static String |
BASIC_VIEW |
static int |
BLOCK_SIZE_DEFAULT |
static FileTime |
FILE_TIME_UNKNOWN |
static String |
GCS_VIEW |
static Set<String> |
SUPPORTED_VIEWS |
static String |
URI_SCHEME |
Modifier and Type | Method and Description |
---|---|
String |
bucket()
Returns Cloud Storage bucket name being served by this file system.
|
void |
close()
Does nothing currently.
|
CloudStorageConfiguration |
config()
Returns configuration object for this file system instance.
|
boolean |
equals(Object other) |
static CloudStorageFileSystem |
forBucket(String bucket)
Returns Google Cloud Storage
FileSystem object for bucket . |
static CloudStorageFileSystem |
forBucket(String bucket,
CloudStorageConfiguration config)
Creates new file system instance for
bucket , with customizable settings. |
static CloudStorageFileSystem |
forBucket(String bucket,
CloudStorageConfiguration config,
StorageOptions storageOptions)
Returns Google Cloud Storage
FileSystem object for bucket . |
Iterable<FileStore> |
getFileStores()
Returns nothing because Google Cloud Storage doesn't have disk partitions of limited size, or
anything similar.
|
CloudStoragePath |
getPath(String first,
String... more)
Converts Cloud Storage object name to a
Path object. |
PathMatcher |
getPathMatcher(String syntaxAndPattern) |
Iterable<Path> |
getRootDirectories() |
String |
getSeparator()
Returns .
|
UserPrincipalLookupService |
getUserPrincipalLookupService()
Throws
UnsupportedOperationException because this feature hasn't been implemented yet. |
int |
hashCode() |
boolean |
isOpen()
Returns
true , even if you previously called the close() method. |
boolean |
isReadOnly()
Returns
false . |
static com.google.api.gax.paging.Page<Bucket> |
listBuckets(String project,
Storage.BucketListOption... options)
Lists the project's buckets.
|
WatchService |
newWatchService()
Throws
UnsupportedOperationException because this feature hasn't been implemented yet. |
CloudStorageFileSystemProvider |
provider() |
Set<String> |
supportedFileAttributeViews() |
String |
toString() |
public static final String URI_SCHEME
public static final String GCS_VIEW
public static final String BASIC_VIEW
public static final int BLOCK_SIZE_DEFAULT
public static final FileTime FILE_TIME_UNKNOWN
public static com.google.api.gax.paging.Page<Bucket> listBuckets(@Nullable String project, Storage.BucketListOption... options)
Example of listing buckets, specifying the page size and a name prefix.
String prefix = "bucket_";
Page<Bucket> buckets = CloudStorageFileSystem.listBuckets("my-project", BucketListOption.prefix(prefix));
Iterator<Bucket> bucketIterator = buckets.iterateAll();
while (bucketIterator.hasNext()) {
Bucket bucket = bucketIterator.next();
// do something with the bucket
}
StorageException
- upon failure@CheckReturnValue public static CloudStorageFileSystem forBucket(String bucket)
FileSystem
object for bucket
.
NOTE: You may prefer to use Java's standard API instead:
FileSystem fs = FileSystems.getFileSystem(URI.create("gs://bucket"));
However some systems and build environments might be flaky when it comes to Java SPI. This is because services are generally runtime dependencies and depend on a META-INF file being present in your jar (generated by Google Auto at compile-time). In such cases, this method provides a simpler alternative.
@CheckReturnValue public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config)
bucket
, with customizable settings.forBucket(String)
@CheckReturnValue public static CloudStorageFileSystem forBucket(String bucket, CloudStorageConfiguration config, @Nullable StorageOptions storageOptions)
FileSystem
object for bucket
.
Google Cloud Storage file system objects are basically free. You can create as many as you
want, even if you have multiple instances for the same bucket. There's no actual system
resources associated with this object. Therefore calling close()
on the returned value
is optional.
Note: It is also possible to instantiate this class via Java's FileSystems.getFileSystem(URI.create("gs://bucket"))
. We discourage you from using that if
possible, for the reasons documented in CloudStorageFileSystemProvider.newFileSystem(URI, java.util.Map)
FileSystems.getFileSystem(URI)
public CloudStorageFileSystemProvider provider()
provider
in class FileSystem
public String bucket()
public CloudStorageConfiguration config()
public CloudStoragePath getPath(String first, String... more)
Path
object.getPath
in class FileSystem
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FileSystem
IOException
public boolean isOpen()
true
, even if you previously called the close()
method.isOpen
in class FileSystem
public boolean isReadOnly()
false
.isReadOnly
in class FileSystem
public String getSeparator()
getSeparator
in class FileSystem
public Iterable<Path> getRootDirectories()
getRootDirectories
in class FileSystem
public Iterable<FileStore> getFileStores()
getFileStores
in class FileSystem
public Set<String> supportedFileAttributeViews()
supportedFileAttributeViews
in class FileSystem
public PathMatcher getPathMatcher(String syntaxAndPattern)
getPathMatcher
in class FileSystem
public UserPrincipalLookupService getUserPrincipalLookupService()
UnsupportedOperationException
because this feature hasn't been implemented yet.getUserPrincipalLookupService
in class FileSystem
public WatchService newWatchService() throws IOException
UnsupportedOperationException
because this feature hasn't been implemented yet.newWatchService
in class FileSystem
IOException
Copyright © 2019 Google LLC. All rights reserved.