@@ -89,8 +89,8 @@ type ObjectMetadata struct {
8989 DiskFileNum base.DiskFileNum
9090 FileType base.FileType
9191
92- // The fields below are only set if the object is on shared storage.
93- Shared struct {
92+ // The fields below are only set if the object is on remote storage.
93+ Remote struct {
9494 // CreatorID identifies the DB instance that originally created the object.
9595 //
9696 // Only used when CustomObjectName is not set.
@@ -113,31 +113,44 @@ type ObjectMetadata struct {
113113 }
114114}
115115
116- // IsShared returns true if the object is on shared storage.
116+ // IsRemote returns true if the object is on remote storage.
117+ func (meta * ObjectMetadata ) IsRemote () bool {
118+ return meta .IsShared () || meta .IsExternal ()
119+ }
120+
121+ // IsExternal returns true if the object is on remote storage but is not owned
122+ // by any Pebble instances in the cluster.
123+ func (meta * ObjectMetadata ) IsExternal () bool {
124+ return meta .Remote .CustomObjectName != ""
125+ }
126+
127+ // IsShared returns true if the object is on remote storage and is owned by a
128+ // Pebble instance in the cluster (potentially shared between multiple
129+ // instances).
117130func (meta * ObjectMetadata ) IsShared () bool {
118- return meta .Shared .CreatorID .IsSet () || meta . Shared . CustomObjectName != ""
131+ return meta .Remote .CreatorID .IsSet ()
119132}
120133
121134// AssertValid checks that the metadata is sane.
122135func (meta * ObjectMetadata ) AssertValid () {
123- if ! meta .IsShared () {
124- // Verify all Shared fields are empty.
125- if meta .Shared != (ObjectMetadata {}).Shared {
126- panic (errors .AssertionFailedf ("meta.Shared not empty: %#v" , meta .Shared ))
136+ if ! meta .IsRemote () {
137+ // Verify all Remote fields are empty.
138+ if meta .Remote != (ObjectMetadata {}).Remote {
139+ panic (errors .AssertionFailedf ("meta.Remote not empty: %#v" , meta .Remote ))
127140 }
128141 } else {
129- if meta .Shared .CustomObjectName != "" {
130- if meta .Shared .CreatorID == 0 {
142+ if meta .Remote .CustomObjectName != "" {
143+ if meta .Remote .CreatorID == 0 {
131144 panic (errors .AssertionFailedf ("CreatorID not set" ))
132145 }
133- if meta .Shared .CreatorFileNum == base .FileNum (0 ).DiskFileNum () {
146+ if meta .Remote .CreatorFileNum == base .FileNum (0 ).DiskFileNum () {
134147 panic (errors .AssertionFailedf ("CreatorFileNum not set" ))
135148 }
136149 }
137- if meta .Shared .CleanupMethod != SharedNoCleanup && meta .Shared .CleanupMethod != SharedRefTracking {
138- panic (errors .AssertionFailedf ("invalid CleanupMethod %d" , meta .Shared .CleanupMethod ))
150+ if meta .Remote .CleanupMethod != SharedNoCleanup && meta .Remote .CleanupMethod != SharedRefTracking {
151+ panic (errors .AssertionFailedf ("invalid CleanupMethod %d" , meta .Remote .CleanupMethod ))
139152 }
140- if meta .Shared .Storage == nil {
153+ if meta .Remote .Storage == nil {
141154 panic (errors .AssertionFailedf ("Storage not set" ))
142155 }
143156 }
@@ -161,7 +174,7 @@ const (
161174 // keep track of references via reference marker objects.
162175 SharedRefTracking SharedCleanupMethod = iota
163176
164- // SharedNoCleanup is used for shared objects that are managed externally; the
177+ // SharedNoCleanup is used for remote objects that are managed externally; the
165178 // objstorage provider never deletes such objects.
166179 SharedNoCleanup
167180)
@@ -249,7 +262,7 @@ type Provider interface {
249262 List () []ObjectMetadata
250263
251264 // SetCreatorID sets the CreatorID which is needed in order to use shared
252- // objects. Shared object usage is disabled until this method is called the
265+ // objects. Remote object usage is disabled until this method is called the
253266 // first time. Once set, the Creator ID is persisted and cannot change.
254267 //
255268 // Cannot be called if shared storage is not configured for the provider.
@@ -260,16 +273,16 @@ type Provider interface {
260273 // exist in this provider.
261274 IsForeign (meta ObjectMetadata ) bool
262275
263- // SharedObjectBacking encodes the shared object metadata for the given object.
264- SharedObjectBacking (meta * ObjectMetadata ) (SharedObjectBackingHandle , error )
276+ // RemoteObjectBacking encodes the remote object metadata for the given object.
277+ RemoteObjectBacking (meta * ObjectMetadata ) (RemoteObjectBackingHandle , error )
265278
266- // CreateSharedObjectBacking creates a backing for an existing object with a
279+ // CreateExternalObjectBacking creates a backing for an existing object with a
267280 // custom object name. The object is considered to be managed outside of
268281 // Pebble and will never be removed by Pebble.
269- CreateSharedObjectBacking (locator shared.Locator , objName string ) (SharedObjectBacking , error )
282+ CreateExternalObjectBacking (locator shared.Locator , objName string ) (RemoteObjectBacking , error )
270283
271- // AttachSharedObjects registers existing shared objects with this provider.
272- AttachSharedObjects (objs []SharedObjectToAttach ) ([]ObjectMetadata , error )
284+ // AttachRemoteObjects registers existing remote objects with this provider.
285+ AttachRemoteObjects (objs []RemoteObjectToAttach ) ([]ObjectMetadata , error )
273286
274287 Close () error
275288
@@ -278,31 +291,31 @@ type Provider interface {
278291 IsNotExistError (err error ) bool
279292}
280293
281- // SharedObjectBacking encodes the metadata necessary to incorporate a shared
294+ // RemoteObjectBacking encodes the metadata necessary to incorporate a shared
282295// object into a different Pebble instance. The encoding is specific to a given
283296// Provider implementation.
284- type SharedObjectBacking []byte
297+ type RemoteObjectBacking []byte
285298
286- // SharedObjectBackingHandle is a container for a SharedObjectBacking which
299+ // RemoteObjectBackingHandle is a container for a RemoteObjectBacking which
287300// ensures that the backing stays valid. A backing can otherwise become invalid
288- // if this provider unrefs the shared object. The SharedObjectBackingHandle
301+ // if this provider unrefs the shared object. The RemoteObjectBackingHandle
289302// delays any unref until Close.
290- type SharedObjectBackingHandle interface {
303+ type RemoteObjectBackingHandle interface {
291304 // Get returns the backing. The backing is only guaranteed to be valid until
292305 // Close is called (or until the Provider is closed). If Close was already
293306 // called, returns an error.
294- Get () (SharedObjectBacking , error )
307+ Get () (RemoteObjectBacking , error )
295308 Close ()
296309}
297310
298- // SharedObjectToAttach contains the arguments needed to attach an existing shared object.
299- type SharedObjectToAttach struct {
311+ // RemoteObjectToAttach contains the arguments needed to attach an existing remote object.
312+ type RemoteObjectToAttach struct {
300313 // FileNum is the file number that will be used to refer to this object (in
301314 // the context of this instance).
302315 FileNum base.DiskFileNum
303316 FileType base.FileType
304- // Backing contains the metadata for the shared object backing (normally
317+ // Backing contains the metadata for the remote object backing (normally
305318 // generated from a different instance, but using the same Provider
306319 // implementation).
307- Backing SharedObjectBacking
320+ Backing RemoteObjectBacking
308321}
0 commit comments