public abstract class BaseViewOperations extends java.lang.Object implements ViewOperations
Modifier | Constructor and Description |
---|---|
protected |
BaseViewOperations() |
Modifier and Type | Method and Description |
---|---|
void |
commit(ViewMetadata base,
ViewMetadata metadata)
Replace the base view metadata with a new version.
|
ViewMetadata |
current()
Return the currently loaded view metadata, without checking for updates.
|
protected java.lang.String |
currentMetadataLocation() |
protected int |
currentVersion() |
protected void |
disableRefresh() |
protected abstract void |
doCommit(ViewMetadata base,
ViewMetadata metadata) |
protected abstract void |
doRefresh() |
protected abstract FileIO |
io() |
ViewMetadata |
refresh()
Return the current view metadata after checking for updates.
|
protected void |
refreshFromMetadataLocation(java.lang.String newLocation) |
protected void |
refreshFromMetadataLocation(java.lang.String newLocation,
java.util.function.Predicate<java.lang.Exception> shouldRetry,
int numRetries) |
protected void |
refreshFromMetadataLocation(java.lang.String newLocation,
java.util.function.Predicate<java.lang.Exception> shouldRetry,
int numRetries,
java.util.function.Function<java.lang.String,ViewMetadata> metadataLoader) |
protected void |
requestRefresh() |
protected abstract java.lang.String |
viewName() |
protected java.lang.String |
writeNewMetadataIfRequired(ViewMetadata metadata) |
protected void requestRefresh()
protected void disableRefresh()
protected abstract void doRefresh()
protected abstract void doCommit(ViewMetadata base, ViewMetadata metadata)
protected abstract java.lang.String viewName()
protected abstract FileIO io()
protected java.lang.String currentMetadataLocation()
protected int currentVersion()
public ViewMetadata current()
ViewOperations
current
in interface ViewOperations
public ViewMetadata refresh()
ViewOperations
refresh
in interface ViewOperations
public void commit(ViewMetadata base, ViewMetadata metadata)
ViewOperations
This method should implement and document atomicity guarantees.
Implementations must check that the base metadata is current to avoid overwriting updates. Once the atomic commit operation succeeds, implementations must not perform any operations that may fail because failure in this method cannot be distinguished from commit failure.
Implementations should throw a CommitStateUnknownException
in cases where it cannot be
determined if the commit succeeded or failed. For example if a network partition causes the
confirmation of the commit to be lost, the implementation should throw a
CommitStateUnknownException. An unknown state indicates to downstream users of this API that it
is not safe to perform clean up and remove any files. In general, strict metadata cleanup will
only trigger cleanups when the commit fails with an exception implementing the marker interface
CleanableFailure
. All other exceptions will be treated as
if the commit has failed.
commit
in interface ViewOperations
base
- view metadata on which changes were basedmetadata
- new view metadata with updatesprotected java.lang.String writeNewMetadataIfRequired(ViewMetadata metadata)
protected void refreshFromMetadataLocation(java.lang.String newLocation)
protected void refreshFromMetadataLocation(java.lang.String newLocation, java.util.function.Predicate<java.lang.Exception> shouldRetry, int numRetries)
protected void refreshFromMetadataLocation(java.lang.String newLocation, java.util.function.Predicate<java.lang.Exception> shouldRetry, int numRetries, java.util.function.Function<java.lang.String,ViewMetadata> metadataLoader)