VladRodionov commented on code in PR #8739:
URL: https://github.com/apache/hbase/pull/8739#discussion_r4251551449


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/cache/persistence/HadoopFsCachePersistenceStorage.java:
##########
@@ -0,0 +1,419 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.io.hfile.cache.persistence;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.UUID;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.yetus.audience.InterfaceAudience;
+
+/**
+ * {@link CachePersistenceStorage} implementation backed by a Hadoop {@link 
FileSystem}.
+ * <p>
+ * This implementation works with filesystems available through Hadoop's 
filesystem abstraction,
+ * including HDFS and the local filesystem.
+ * </p>
+ * <p>
+ * Every persistence storage key is represented as a file below a configured 
root directory. Keys
+ * may contain relative path components separated by {@code /}, allowing 
higher-level persistence
+ * infrastructure to organize state by component role.
+ * </p>
+ * <p>
+ * Persistence writes are first written to a temporary file. The temporary 
file is promoted to the
+ * committed state path only after the caller explicitly commits the write. An 
abandoned write
+ * deletes its temporary file and leaves previously committed state unchanged.
+ * </p>
+ * <p>
+ * Publication uses filesystem rename operations. Rename atomicity and 
implementation details are
+ * determined by the underlying Hadoop filesystem. For filesystems where 
rename is implemented as
+ * copy-and-delete, publication has the corresponding filesystem semantics.
+ * </p>
+ * <p>
+ * This class does not own the supplied {@link FileSystem} and does not close 
it.
+ * </p>
+ */
[email protected]
+public class HadoopFsCachePersistenceStorage implements 
CachePersistenceStorage {

Review Comment:
   On your first comment. I don't intend this API to mean “backup/snapshot to 
non-local storage.” The distinction here is between the component persistence 
format and the storage used to hold it.
   PersistentCacheComponent only defines how a component saves/restores its own 
runtime state to streams. CachePersistenceStorage decides where those streams 
live. The provided HadoopFsCachePersistenceStorage supports the local Hadoop 
filesystem (file://) as well as HDFS and other Hadoop-compatible filesystems, 
so preserving state on the same local persistent disk is fully supported.
   BucketCachePersister is actually the natural first concrete use case once 
BucketCache is converted to a native BucketCacheEngine. Its current behavior 
already persists BucketCache metadata/backing-map state so that a persistent 
local IO engine can be reconstructed after restart. I expect that logic to 
become the PersistentCacheComponent.save()/restore() implementation of 
BucketCacheEngine, with local filesystem storage preserving the existing 
behavior.
   Remote storage is an additional possibility enabled by the abstraction, not 
the required semantics.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to