Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Commit 3f10e81

Browse files
Lubomir Litchevfacebook-github-bot
Lubomir Litchev
authored andcommitted
Rename LocalCache to LocalCacheStorage
Summary: Renamed LocalCache to LocalCacheStorage. Reviewed By: bobyangyf fbshipit-source-id: 677265dec0
1 parent 77c91ea commit 3f10e81

File tree

4 files changed

+36
-31
lines changed

4 files changed

+36
-31
lines changed

src/com/facebook/buck/parser/cache/ParserCacheException.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616

1717
package com.facebook.buck.parser.cache;
1818

19-
/** This exception is thrown when there are failures while doing {@link ParserCache} operations. */
19+
/**
20+
* This exception is thrown when there are failures while doing {@link ParserCacheStorage}
21+
* operations.
22+
*/
2023
public class ParserCacheException extends Exception {
2124

2225
/**

src/com/facebook/buck/parser/cache/ParserCache.java src/com/facebook/buck/parser/cache/ParserCacheStorage.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.google.common.hash.HashCode;
2121

2222
/** This is the main interface for interacting with the cache. */
23-
public interface ParserCache {
23+
public interface ParserCacheStorage {
2424

2525
/**
2626
* Stores a {@link BuildFileManifest} object to the cache.
@@ -43,7 +43,7 @@ void storeBuildFileManifest(
4343
* @return an {@link BuildFileManifest} object status operation if the operation is successful. In
4444
* case of failure an appropriate exception is thrown.
4545
* @throws ParserCacheException thrown when there is an error constructing the {@link
46-
* BuildFileManifest} from the {@link ParserCache}.
46+
* BuildFileManifest} from the {@link ParserCacheStorage}.
4747
*/
4848
BuildFileManifest getBuildFileManifest(HashCode weakFingerprint, HashCode strongFingerprint)
4949
throws ParserCacheException;

src/com/facebook/buck/parser/cache/impl/LocalCache.java src/com/facebook/buck/parser/cache/impl/LocalCacheStorage.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import com.facebook.buck.core.util.log.Logger;
2020
import com.facebook.buck.io.filesystem.ProjectFilesystem;
2121
import com.facebook.buck.parser.api.BuildFileManifest;
22-
import com.facebook.buck.parser.cache.ParserCache;
2322
import com.facebook.buck.parser.cache.ParserCacheException;
23+
import com.facebook.buck.parser.cache.ParserCacheStorage;
2424
import com.facebook.buck.parser.cache.json.BuildFileManifestSerializer;
2525
import com.google.common.base.Preconditions;
2626
import com.google.common.base.Stopwatch;
@@ -31,14 +31,14 @@
3131
import java.nio.file.Path;
3232
import java.util.concurrent.TimeUnit;
3333

34-
/** A local filesystem backed implementation for the {@link ParserCache} interface. */
35-
public class LocalCache implements ParserCache {
36-
private static final Logger LOG = Logger.get(LocalCache.class);
34+
/** An local filesystem backed implementation for the {@link ParserCacheStorage} interface. */
35+
public class LocalCacheStorage implements ParserCacheStorage {
36+
private static final Logger LOG = Logger.get(LocalCacheStorage.class);
3737

3838
private final Path localCachePath;
3939
private final ProjectFilesystem filesystem;
4040

41-
private LocalCache(Path localCachePath, ProjectFilesystem filesystem) {
41+
private LocalCacheStorage(Path localCachePath, ProjectFilesystem filesystem) {
4242
this.filesystem = filesystem;
4343
this.localCachePath = localCachePath;
4444
}
@@ -64,20 +64,20 @@ private static Path createLocalCachePathFromConfig(
6464
}
6565

6666
/**
67-
* Static factory for creating {@link LocalCache} objects.
67+
* Static factory for creating {@link LocalCacheStorage} objects.
6868
*
6969
* @param parserCacheConfig the {@code parserCacheConfig} object to be used for this parsing.
7070
* @return a new instance of fully instantiated local cache object.
71-
* @throws ParserCacheException when the {@link LocalCache} object cannot be constructed.
71+
* @throws ParserCacheException when the {@link LocalCacheStorage} object cannot be constructed.
7272
*/
73-
public static LocalCache newInstance(
73+
public static LocalCacheStorage newInstance(
7474
AbstractParserCacheConfig parserCacheConfig, ProjectFilesystem filesystem)
7575
throws ParserCacheException {
7676
Preconditions.checkState(
7777
parserCacheConfig.isDirParserCacheEnabled(),
78-
"Invalid state: LocalCache should not be instantiated if the cache is disabled.");
78+
"Invalid state: LocalCacheStorage should not be instantiated if the cache is disabled.");
7979
Path localCachePath = createLocalCachePathFromConfig(parserCacheConfig, filesystem);
80-
return new LocalCache(localCachePath, filesystem);
80+
return new LocalCacheStorage(localCachePath, filesystem);
8181
}
8282

8383
@Override

test/com/facebook/buck/parser/cache/impl/LocalCacheTest.java test/com/facebook/buck/parser/cache/impl/LocalCacheStorageTest.java

+20-18
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
import org.junit.Test;
5757
import org.junit.rules.ExpectedException;
5858

59-
public class LocalCacheTest {
59+
public class LocalCacheStorageTest {
6060
@Rule public ExpectedException expectedException = ExpectedException.none();
6161
@Rule public TemporaryPaths tempDir = new TemporaryPaths();
6262

@@ -113,7 +113,7 @@ public void setUp() {
113113
assumeThat(Platform.detect(), not(Platform.WINDOWS));
114114
filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem("/");
115115
localHandler = new LocalHandler();
116-
Logger.get(LocalCache.class).addHandler(localHandler);
116+
Logger.get(LocalCacheStorage.class).addHandler(localHandler);
117117
}
118118

119119
@Test
@@ -122,13 +122,14 @@ public void createLocalCacheWithAbsolutePathAndException()
122122
expectedException.expect(ParserCacheException.class);
123123
expectedException.expectMessage("Failed to create local cache directory - /foo/bar");
124124
filesystem.createNewFile(Paths.get("/foo"));
125-
LocalCache.newInstance(getParserCacheConfig(true, filesystem.getPath("/foo/bar")), filesystem);
125+
LocalCacheStorage.newInstance(
126+
getParserCacheConfig(true, filesystem.getPath("/foo/bar")), filesystem);
126127
}
127128

128129
@Test
129130
public void createLocalCacheWithAbsolutePath() throws ParserCacheException {
130131
Path absPath = filesystem.getBuckPaths().getBuckOut().resolve("/foo/bar").toAbsolutePath();
131-
LocalCache.newInstance(getParserCacheConfig(true, absPath), filesystem);
132+
LocalCacheStorage.newInstance(getParserCacheConfig(true, absPath), filesystem);
132133
List<LogRecord> events = localHandler.messages;
133134
assertEquals(1, events.size());
134135
LogRecord event = events.get(0);
@@ -139,7 +140,7 @@ public void createLocalCacheWithAbsolutePath() throws ParserCacheException {
139140
@Test
140141
public void createLocalCacheWithRelativePath() throws ParserCacheException {
141142
Path path = filesystem.getPath("foo/bar");
142-
LocalCache.newInstance(getParserCacheConfig(true, path), filesystem);
143+
LocalCacheStorage.newInstance(getParserCacheConfig(true, path), filesystem);
143144
List<LogRecord> events = localHandler.messages;
144145
assertEquals(1, events.size());
145146
LogRecord event = events.get(0);
@@ -153,15 +154,15 @@ public void createLocalCacheWithRelativePath() throws ParserCacheException {
153154
public void createLocalCacheWhenCachingDisabled() throws ParserCacheException {
154155
expectedException.expect(IllegalStateException.class);
155156
expectedException.expectMessage(
156-
"Invalid state: LocalCache should not be instantiated if the cache is disabled.");
157-
LocalCache.newInstance(
157+
"Invalid state: LocalCacheStorage should not be instantiated if the cache is disabled.");
158+
LocalCacheStorage.newInstance(
158159
getParserCacheConfig(false, filesystem.getPath(tempDir.getRoot().toString())), filesystem);
159160
}
160161

161162
@Test
162163
public void createLocalCacheWhenCacheDefaultDirectory() throws ParserCacheException {
163164
Path emptyPathForDefaultCacheLocation = filesystem.getPath("\"\"");
164-
LocalCache.newInstance(
165+
LocalCacheStorage.newInstance(
165166
getParserCacheConfig(true, emptyPathForDefaultCacheLocation), filesystem);
166167
List<LogRecord> events = localHandler.messages;
167168
assertEquals(1, events.size());
@@ -172,16 +173,16 @@ public void createLocalCacheWhenCacheDefaultDirectory() throws ParserCacheExcept
172173

173174
@Test
174175
public void createLocalCacheWFPDirectoryNonExisting() throws IOException, ParserCacheException {
175-
LocalCache localCache =
176-
LocalCache.newInstance(
176+
LocalCacheStorage localCacheStorage =
177+
LocalCacheStorage.newInstance(
177178
getParserCacheConfig(
178179
true,
179180
filesystem.getPath(tempDir.getRoot().toString() + File.separator + FOO_BAR_PATH)),
180181
filesystem);
181182
Path buildPath = filesystem.getPath(FOO_BAR_PATH);
182183
HashCode weakFingerprint = Fingerprinter.getWeakFingerprint(buildPath, getConfig().getConfig());
183184
HashCode strongFingerprint = Fingerprinter.getStrongFingerprint(filesystem, ImmutableList.of());
184-
localCache.storeBuildFileManifest(weakFingerprint, strongFingerprint, null);
185+
localCacheStorage.storeBuildFileManifest(weakFingerprint, strongFingerprint, null);
185186
Path localCachePath = tempDir.getRoot().resolve(FOO_BAR_PATH);
186187
assertNotNull(localCachePath);
187188
Path weakFingerprintPath =
@@ -193,8 +194,8 @@ public void createLocalCacheWFPDirectoryNonExisting() throws IOException, Parser
193194
@Test
194195
public void createLocalCacheWFPDirectoryExistingAndKeepIt()
195196
throws IOException, ParserCacheException {
196-
LocalCache localCache =
197-
LocalCache.newInstance(
197+
LocalCacheStorage localCacheStorage =
198+
LocalCacheStorage.newInstance(
198199
getParserCacheConfig(
199200
true,
200201
filesystem.getPath(tempDir.getRoot().toString() + File.separator + FOO_BAR_PATH)),
@@ -211,7 +212,7 @@ public void createLocalCacheWFPDirectoryExistingAndKeepIt()
211212
assertTrue(filesystem.exists(newFilePath));
212213
HashCode weakFingerprint = Fingerprinter.getWeakFingerprint(buildPath, getConfig().getConfig());
213214
HashCode strongFingerprint = Fingerprinter.getStrongFingerprint(filesystem, ImmutableList.of());
214-
localCache.storeBuildFileManifest(weakFingerprint, strongFingerprint, null);
215+
localCacheStorage.storeBuildFileManifest(weakFingerprint, strongFingerprint, null);
215216
assertNotNull(localCachePath);
216217
assertTrue(filesystem.exists(wfpPath));
217218
assertTrue(filesystem.exists(newFilePath));
@@ -220,8 +221,8 @@ public void createLocalCacheWFPDirectoryExistingAndKeepIt()
220221
@Test
221222
public void stroreInLocalCacheAndGetFromLocalCacheAndVerifyMatch()
222223
throws IOException, ParserCacheException {
223-
LocalCache localCache =
224-
LocalCache.newInstance(
224+
LocalCacheStorage localCacheStorage =
225+
LocalCacheStorage.newInstance(
225226
getParserCacheConfig(
226227
true,
227228
filesystem.getPath(tempDir.getRoot().toString() + File.separator + FOO_BAR_PATH)),
@@ -295,7 +296,8 @@ public void stroreInLocalCacheAndGetFromLocalCacheAndVerifyMatch()
295296
HashCode strongFingerprinter = Fingerprinter.getStrongFingerprint(filesystem, includes);
296297

297298
// Store in local cache
298-
localCache.storeBuildFileManifest(weakFingerprinter, strongFingerprinter, buildFileManifest);
299+
localCacheStorage.storeBuildFileManifest(
300+
weakFingerprinter, strongFingerprinter, buildFileManifest);
299301

300302
Path serializedDataFile =
301303
localCachePath
@@ -305,7 +307,7 @@ public void stroreInLocalCacheAndGetFromLocalCacheAndVerifyMatch()
305307

306308
// Get from local cache
307309
BuildFileManifest buildFileManifestResult =
308-
localCache.getBuildFileManifest(weakFingerprinter, strongFingerprinter);
310+
localCacheStorage.getBuildFileManifest(weakFingerprinter, strongFingerprinter);
309311
assertEquals(buildFileManifest, buildFileManifestResult);
310312
}
311313

0 commit comments

Comments
 (0)