Skip to content

Commit

Permalink
Mass rename to ensure we consistently use 'localcache'
Browse files Browse the repository at this point in the history
  • Loading branch information
bbockelm committed Mar 5, 2024
1 parent eb8d2e0 commit 459b7a6
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 82 deletions.
10 changes: 5 additions & 5 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ func InitServer(ctx context.Context, currentServers ServerType) error {
viper.SetDefault("Cache.RunLocation", filepath.Join("/run", "pelican", "xrootd", "cache"))
}
viper.SetDefault("Cache.DataLocation", "/run/pelican/xcache")
viper.SetDefault("FileCache.RunLocation", filepath.Join("/run", "pelican", "filecache"))
viper.SetDefault("LocalCache.RunLocation", filepath.Join("/run", "pelican", "localcache"))

viper.SetDefault("Origin.Multiuser", true)
viper.SetDefault("Director.GeoIPLocation", "/var/cache/pelican/maxmind/GeoLite2-City.mmdb")
Expand Down Expand Up @@ -864,12 +864,12 @@ func InitServer(ctx context.Context, currentServers ServerType) error {
cleanupDirOnShutdown(ctx, runtimeDir)
}
viper.SetDefault("Cache.DataLocation", filepath.Join(runtimeDir, "xcache"))
viper.SetDefault("FileCache.RunLocation", filepath.Join(runtimeDir, "cache"))
viper.SetDefault("LocalCache.RunLocation", filepath.Join(runtimeDir, "cache"))
viper.SetDefault("Origin.Multiuser", false)
}
fcRunLocation := viper.GetString("FileCache.RunLocation")
viper.SetDefault("FileCache.Socket", filepath.Join(fcRunLocation, "cache.sock"))
viper.SetDefault("FileCache.DataLocation", filepath.Join(fcRunLocation, "cache"))
fcRunLocation := viper.GetString("LocalCache.RunLocation")
viper.SetDefault("LocalCache.Socket", filepath.Join(fcRunLocation, "cache.sock"))
viper.SetDefault("LocalCache.DataLocation", filepath.Join(fcRunLocation, "cache"))

// Any platform-specific paths should go here
err := InitServerOSDefaults()
Expand Down
42 changes: 24 additions & 18 deletions docs/parameters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -618,49 +618,55 @@ default: path
components: ["origin"]
---
############################
# File-cache configs #
# Local cache configs #
############################
name: FileCache.RunLocation
name: LocalCache.RunLocation
description: >-
The directory for the runtime files of the file cache
type: string
root_default: /run/pelican/filecache
default: $XDG_RUNTIME_DIR/pelican/filecache
The directory for the runtime files of the local cache
type: filename
root_default: /run/pelican/localcache
default: $XDG_RUNTIME_DIR/pelican/localcache
components: ["localcache"]
---
name: FileCache.DataLocation
name: LocalCache.DataLocation
description: >-
The directory for the location of the cache data files - this is where the actual data in the cache is stored
for the file cache.
type: string
default: $PELICAN_FILECACHE_RUNLOCATION/cache
for the local cache.
type: filename
default: $PELICAN_LOCALCACHE_RUNLOCATION/cache
components: ["localcache"]
---
name: FileCache.Socket
name: LocalCache.Socket
description: >-
The location of the socket used for client communication for the file cache
type: string
default: $PELICAN_FILECACHE_RUNLOCATION/cache.sock
The location of the socket used for client communication for the local cache
type: filename
default: $PELICAN_LOCALCACHE_RUNLOCATION/cache.sock
components: ["localcache"]
---
name: FileCache.Size
name: LocalCache.Size
description: >-
The maximum size of the file cache. If not set, it is assumed the entire device can be used.
The maximum size of the local cache. If not set, it is assumed the entire device can be used.
type: string
default: 0
components: ["localcache"]
---
name: FileCache.HighWaterMarkPercentage
name: LocalCache.HighWaterMarkPercentage
description: >-
A percentage value where the cache cleanup routines will triggered. Once the cache usage
of completed files hits the high water mark, files will be deleted until the usage hits the
low water mark.
type: int
default: 95
components: ["localcache"]
---
name: FileCache.LowWaterMarkPercentage
name: LocalCache.LowWaterMarkPercentage
description: >-
A percentage value where the cache cleanup routines will complete. Once the cache usage
of completed files hits the high water mark, files will be deleted until the usage hits the
low water mark.
type: int
default: 85
components: ["localcache"]
---
############################
# Cache-level configs #
Expand Down
4 changes: 2 additions & 2 deletions launchers/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

"github.com/pelicanplatform/pelican/broker"
"github.com/pelicanplatform/pelican/config"
simple_cache "github.com/pelicanplatform/pelican/file_cache"
"github.com/pelicanplatform/pelican/local_cache"
"github.com/pelicanplatform/pelican/origin_ui"
"github.com/pelicanplatform/pelican/param"
"github.com/pelicanplatform/pelican/server_ui"
Expand Down Expand Up @@ -251,7 +251,7 @@ func LaunchModules(ctx context.Context, modules config.ServerType) (context.Canc

if modules.IsEnabled(config.LocalCacheType) {
log.Debugln("Starting local cache listener")
if err := simple_cache.LaunchListener(ctx, egrp); err != nil {
if err := local_cache.LaunchListener(ctx, egrp); err != nil {
log.Errorln("Failure when starting the local cache listener:", err)
return shutdownCancel, err
}
Expand Down
6 changes: 3 additions & 3 deletions file_cache/cache_api.go → local_cache/cache_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
***************************************************************/

package simple_cache
package local_cache

import (
"context"
Expand All @@ -39,7 +39,7 @@ import (

// Launch the unix socket listener as a separate goroutine
func LaunchListener(ctx context.Context, egrp *errgroup.Group) error {
socketName := param.FileCache_Socket.GetString()
socketName := param.LocalCache_Socket.GetString()
if err := os.MkdirAll(filepath.Dir(socketName), fs.FileMode(0755)); err != nil {
return errors.Wrap(err, "failed to create socket directory")
}
Expand All @@ -48,7 +48,7 @@ func LaunchListener(ctx context.Context, egrp *errgroup.Group) error {
if err != nil {
return err
}
sc, err := NewSimpleCache(ctx, egrp)
sc, err := NewLocalCache(ctx, egrp)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion file_cache/cache_authz.go → local_cache/cache_authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
***************************************************************/

package simple_cache
package local_cache

import (
"context"
Expand Down
20 changes: 10 additions & 10 deletions file_cache/cache_test.go → local_cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
***************************************************************/

package simple_cache_test
package local_cache_test

import (
"context"
Expand All @@ -33,8 +33,8 @@ import (

"github.com/pelicanplatform/pelican/client"
"github.com/pelicanplatform/pelican/config"
simple_cache "github.com/pelicanplatform/pelican/file_cache"
"github.com/pelicanplatform/pelican/launchers"
local_cache "github.com/pelicanplatform/pelican/local_cache"
"github.com/pelicanplatform/pelican/param"
"github.com/pelicanplatform/pelican/test_utils"
"github.com/pelicanplatform/pelican/token_scopes"
Expand Down Expand Up @@ -154,18 +154,18 @@ func TestFedPublicGet(t *testing.T) {
ft := fedTest{}
ft.spinup(t, ctx, egrp)

sc, err := simple_cache.NewSimpleCache(ctx, egrp)
lc, err := local_cache.NewLocalCache(ctx, egrp)
require.NoError(t, err)

reader, err := sc.Get("/test/hello_world.txt", "")
reader, err := lc.Get("/test/hello_world.txt", "")
require.NoError(t, err)

byteBuff, err := io.ReadAll(reader)
assert.NoError(t, err)
assert.Equal(t, "Hello, World!", string(byteBuff))

// Query again -- cache hit case
reader, err = sc.Get("/test/hello_world.txt", "")
reader, err = lc.Get("/test/hello_world.txt", "")
require.NoError(t, err)

assert.Equal(t, "*os.File", fmt.Sprintf("%T", reader))
Expand All @@ -183,7 +183,7 @@ func TestFedAuthGet(t *testing.T) {
ft := fedTest{}
ft.spinup(t, ctx, egrp)

lc, err := simple_cache.NewSimpleCache(ctx, egrp)
lc, err := local_cache.NewLocalCache(ctx, egrp)
require.NoError(t, err)

reader, err := lc.Get("/test/hello_world.txt", ft.token)
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestHttpReq(t *testing.T) {

transport := config.GetTransport().Clone()
transport.DialContext = func(_ context.Context, _, _ string) (net.Conn, error) {
return net.Dial("unix", param.FileCache_Socket.GetString())
return net.Dial("unix", param.LocalCache_Socket.GetString())
}

client := &http.Client{Transport: transport}
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestClient(t *testing.T) {

cacheUrl := &url.URL{
Scheme: "unix",
Path: param.FileCache_Socket.GetString(),
Path: param.LocalCache_Socket.GetString(),
}

discoveryHost := param.Federation_DiscoveryUrl.GetString()
Expand All @@ -278,7 +278,7 @@ func TestStat(t *testing.T) {
ft := fedTest{}
ft.spinup(t, ctx, egrp)

lc, err := simple_cache.NewSimpleCache(ctx, egrp)
lc, err := local_cache.NewLocalCache(ctx, egrp)
require.NoError(t, err)

size, err := lc.Stat("/test/hello_world.txt", "")
Expand Down Expand Up @@ -309,7 +309,7 @@ func TestLargeFile(t *testing.T) {

cacheUrl := &url.URL{
Scheme: "unix",
Path: param.FileCache_Socket.GetString(),
Path: param.LocalCache_Socket.GetString(),
}

fp, err := os.OpenFile(filepath.Join(ft.originDir, "hello_world.txt"), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600)
Expand Down
Loading

0 comments on commit 459b7a6

Please sign in to comment.