-
Notifications
You must be signed in to change notification settings - Fork 275
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
Support dynamically removing store from storage manager #1232
Changes from all commits
626c1fd
f14a130
3f2b42c
5bb12c7
e167239
b1f2bd0
8ea2d7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,25 @@ void controlCompactionForBlobStore(BlobStore store, boolean enable) { | |
} | ||
} | ||
|
||
/** | ||
* Remove store from compaction manager. | ||
* @param store the {@link BlobStore} to remove | ||
* @return {@code true} if store is removed successfully. {@code false} if not. | ||
*/ | ||
boolean removeBlobStore(BlobStore store) { | ||
if (compactionExecutor == null) { | ||
stores.remove(store); | ||
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. Once #1226 is merged, |
||
return true; | ||
} else if (!compactionExecutor.getStoresDisabledCompaction().contains(store)) { | ||
logger.error("Fail to remove store ({}) from compaction manager because compaction is still enabled on it", | ||
store); | ||
return false; | ||
} | ||
// stores.remove(store) is invoked within compactionExecutor.removeBlobStore() because it requires lock | ||
compactionExecutor.removeBlobStore(store); | ||
return true; | ||
} | ||
|
||
/** | ||
* Get compaction details for a given {@link BlobStore} if any | ||
* @param blobStore the {@link BlobStore} for which compaction details are requested | ||
|
@@ -365,6 +384,31 @@ void controlCompactionForBlobStore(BlobStore store, boolean enable) { | |
storesDisabledCompaction.add(store); | ||
} | ||
} | ||
|
||
/** | ||
* Remove store from compaction executor. | ||
* @param store the {@link BlobStore} to remove | ||
*/ | ||
void removeBlobStore(BlobStore store) { | ||
lock.lock(); | ||
try { | ||
stores.remove(store); | ||
// It's ok to remove store from "storesDisabledCompaction" and "storesToSkip" list while executor thread is | ||
// going through each store to check compaction eligibility. Note that the executor will first check if store | ||
// is started, which is guaranteed to be false before removeBlobStore() is invoked. | ||
storesDisabledCompaction.remove(store); | ||
storesToSkip.remove(store); | ||
} finally { | ||
lock.unlock(); | ||
} | ||
} | ||
|
||
/** | ||
* @return a list of stores on which compaction is disabled. | ||
*/ | ||
Set<BlobStore> getStoresDisabledCompaction() { | ||
return storesDisabledCompaction; | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,7 +209,6 @@ public boolean controlCompactionForBlobStore(PartitionId id, boolean enabled) { | |
|
||
/** | ||
* Shutdown the {@link DiskManager}s for the disks on this node. | ||
* @throws StoreException | ||
* @throws InterruptedException | ||
*/ | ||
public void shutdown() throws InterruptedException { | ||
|
@@ -290,6 +289,26 @@ public boolean shutdownBlobStore(PartitionId id) { | |
return diskManager != null && diskManager.shutdownBlobStore(id); | ||
} | ||
|
||
/** | ||
* Remove store from storage manager. | ||
* @param id the {@link PartitionId} associated with store | ||
* @return {@code true} if removal succeeds. {@code false} otherwise. | ||
*/ | ||
public boolean removeBlobStore(PartitionId id) { | ||
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. Any reason for this method (and the ones in DiskManager and CompactionManager) to return success/failure booleans instead of throwing exceptions? With exceptions, you can log just once at the top level 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. I am slightly leaning towards current way to make it sort of consistent with |
||
DiskManager diskManager = partitionToDiskManager.get(id); | ||
if (diskManager == null) { | ||
logger.info("Store {} is not found in storage manager", id); | ||
return true; | ||
} | ||
if (!diskManager.removeBlobStore(id)) { | ||
logger.error("Fail to remove store {} from disk manager", id); | ||
return false; | ||
} | ||
partitionToDiskManager.remove(id); | ||
logger.info("Store {} is successfully removed from storage manager", id); | ||
return true; | ||
} | ||
|
||
/** | ||
* Set BlobStore Stopped state with given {@link PartitionId} {@code id}. | ||
* @param partitionIds a list {@link PartitionId} of the {@link Store} whose stopped state should be set. | ||
|
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 method already throws IOException, so you probably don't have to catch the exception, unless you want
dataDir
to be in the message.Also, I would recommend setting the cause exception to
e
if you keep the catchThere 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.
Thanks for reminding me of this. I prefer to keep this catch in case there is any non-IOException. Also, I would take your advice to set the exception
e