-
Notifications
You must be signed in to change notification settings - Fork 25.2k
lazy snapshot repository initialization #31606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
vladimirdolzhenko
merged 21 commits into
elastic:master
from
vladimirdolzhenko:lazy_repo_init
Jul 13, 2018
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3dd9d22
lazy snapshot repository initialization
16d9b40
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
848f346
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
79ab701
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
2eaed57
drop unused import
3b03345
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
4b4b837
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
c89a103
move checks to ctor; rename methods for consistency
89e2310
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
3529a7e
fix URLRepositoryTests
608f644
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
bc60b22
changes due to Yannick's review - test code clean up; blob store para…
3a322aa
extend comment for r/o repo verification
f84ec61
added missed start
da5c07f
added missed start
d25b248
fix test; close blobStore if a concurrent blobStore initialization is…
b2ac9d8
fix thread check for unit test
c6b836a
fix thread check for unit test
d8c9593
Merge remote-tracking branch 'remotes/origin/master' into lazy_repo_init
8dfa60d
enforcing access to blobStore / blobContainer only to snapshot and ge…
ae3ee24
verifyBlobInnersAccess renamed to assertSnapshotOrGenericThread; adde…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,6 @@ | |
import org.elasticsearch.snapshots.SnapshotCreationException; | ||
import org.elasticsearch.snapshots.SnapshotId; | ||
|
||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.util.List; | ||
import java.util.Locale; | ||
|
@@ -78,25 +77,21 @@ public static final class Repository { | |
public static final Setting<Boolean> READONLY_SETTING = Setting.boolSetting("readonly", false, Property.NodeScope); | ||
} | ||
|
||
private final AzureBlobStore blobStore; | ||
private final BlobPath basePath; | ||
private final ByteSizeValue chunkSize; | ||
private final boolean compress; | ||
private final Environment environment; | ||
private final AzureStorageService storageService; | ||
private final boolean readonly; | ||
|
||
public AzureRepository(RepositoryMetaData metadata, Environment environment, NamedXContentRegistry namedXContentRegistry, | ||
AzureStorageService storageService) throws IOException, URISyntaxException, StorageException { | ||
AzureStorageService storageService) { | ||
super(metadata, environment.settings(), namedXContentRegistry); | ||
this.blobStore = new AzureBlobStore(metadata, environment.settings(), storageService); | ||
this.chunkSize = Repository.CHUNK_SIZE_SETTING.get(metadata.settings()); | ||
this.compress = Repository.COMPRESS_SETTING.get(metadata.settings()); | ||
// If the user explicitly did not define a readonly value, we set it by ourselves depending on the location mode setting. | ||
// For secondary_only setting, the repository should be read only | ||
if (Repository.READONLY_SETTING.exists(metadata.settings())) { | ||
this.readonly = Repository.READONLY_SETTING.get(metadata.settings()); | ||
} else { | ||
this.readonly = this.blobStore.getLocationMode() == LocationMode.SECONDARY_ONLY; | ||
} | ||
this.environment = environment; | ||
this.storageService = storageService; | ||
|
||
final String basePath = Strings.trimLeadingCharacter(Repository.BASE_PATH_SETTING.get(metadata.settings()), '/'); | ||
if (Strings.hasLength(basePath)) { | ||
// Remove starting / if any | ||
|
@@ -108,15 +103,33 @@ public AzureRepository(RepositoryMetaData metadata, Environment environment, Nam | |
} else { | ||
this.basePath = BlobPath.cleanPath(); | ||
} | ||
logger.debug((org.apache.logging.log4j.util.Supplier<?>) () -> new ParameterizedMessage( | ||
"using container [{}], chunk_size [{}], compress [{}], base_path [{}]", blobStore, chunkSize, compress, basePath)); | ||
|
||
// If the user explicitly did not define a readonly value, we set it by ourselves depending on the location mode setting. | ||
// For secondary_only setting, the repository should be read only | ||
final LocationMode locationMode = Repository.LOCATION_MODE_SETTING.get(metadata.settings()); | ||
if (Repository.READONLY_SETTING.exists(metadata.settings())) { | ||
this.readonly = Repository.READONLY_SETTING.get(metadata.settings()); | ||
} else { | ||
this.readonly = locationMode == LocationMode.SECONDARY_ONLY; | ||
} | ||
} | ||
|
||
// only use for testing | ||
@Override | ||
protected BlobStore getBlobStore() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this be removed now? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope, it is in use in |
||
return super.getBlobStore(); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
protected BlobStore blobStore() { | ||
protected AzureBlobStore createBlobStore() throws URISyntaxException, StorageException { | ||
final AzureBlobStore blobStore = new AzureBlobStore(metadata, environment.settings(), storageService); | ||
|
||
logger.debug((org.apache.logging.log4j.util.Supplier<?>) () -> new ParameterizedMessage( | ||
"using container [{}], chunk_size [{}], compress [{}], base_path [{}]", | ||
blobStore, chunkSize, compress, basePath)); | ||
return blobStore; | ||
} | ||
|
||
|
@@ -144,6 +157,7 @@ protected ByteSizeValue chunkSize() { | |
@Override | ||
public void initializeSnapshot(SnapshotId snapshotId, List<IndexId> indices, MetaData clusterMetadata) { | ||
try { | ||
final AzureBlobStore blobStore = (AzureBlobStore) blobStore(); | ||
if (blobStore.containerExist() == false) { | ||
throw new IllegalArgumentException("The bucket [" + blobStore + "] does not exist. Please create it before " | ||
+ " creating an azure snapshot repository backed by it."); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to be testing the lazy initialization of BlobStoreRepository, not URLRepository? Do we need to expose the methods in URLRepository and test this at this level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URLRepositoryTests
doesn't extendESBlobStoreRepositoryIntegTestCase
(asFsBlobStoreRepositoryIT
,S3BlobStoreRepositoryTests
andGoogleCloudStorageBlobStoreRepositoryTests
) - it looks like more due to read-only nature of url repo - therefore such kind of check is done on this level