You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "keith-turner (via GitHub)" <gi...@apache.org> on 2026/02/05 23:31:25 UTC
[PR] Refactor manager split code used by fate [accumulo]
keith-turner opened a new pull request, #6115:
URL: https://github.com/apache/accumulo/pull/6115
Separated out functionality in the manager Splitter class that was only used by the fate split operation. This avoids having to expose code used by TGW to Fate making it easier to execute fate operation outside the manager.
--
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: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Refactor manager split code used by fate [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #6115:
URL: https://github.com/apache/accumulo/pull/6115#discussion_r2771589354
##########
server/manager/src/main/java/org/apache/accumulo/manager/tableOps/FateEnv.java:
##########
@@ -55,7 +55,7 @@ public interface FateEnv {
ExecutorService getTabletRefreshThreadPool();
- Splitter getSplitter();
+ SplitFileCache getSplitFileCache();
Review Comment:
This change is the driver behind this entire PR. Needed to expose a more narrow type here for fate. Found this while experimenting with distributed fate.
--
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: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Refactor manager split code used by fate [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner merged PR #6115:
URL: https://github.com/apache/accumulo/pull/6115
--
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: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Refactor manager split code used by fate [accumulo]
Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #6115:
URL: https://github.com/apache/accumulo/pull/6115#discussion_r2806732477
##########
server/manager/src/main/java/org/apache/accumulo/manager/split/SplitFileCache.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.manager.split;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.file.FileOperations;
+import org.apache.accumulo.core.file.FileSKVIterator;
+import org.apache.accumulo.core.metadata.TabletFile;
+import org.apache.accumulo.core.util.cache.Caches;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.conf.TableConfiguration;
+import org.apache.hadoop.fs.FileSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.github.benmanes.caffeine.cache.CacheLoader;
+import com.github.benmanes.caffeine.cache.LoadingCache;
+import com.github.benmanes.caffeine.cache.Weigher;
+
+public class SplitFileCache {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SplitFileCache.class);
+
+ private static class CacheKey {
+
+ final TableId tableId;
+ final TabletFile tabletFile;
+
+ public CacheKey(TableId tableId, TabletFile tabletFile) {
+ this.tableId = tableId;
+ this.tabletFile = tabletFile;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ CacheKey cacheKey = (CacheKey) o;
+ return Objects.equals(tableId, cacheKey.tableId)
+ && Objects.equals(tabletFile, cacheKey.tabletFile);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tableId, tabletFile);
+ }
+
+ }
+
+ public static <T extends TabletFile> Map<T,FileSKVIterator.FileRange> tryToGetFirstAndLastRows(
+ ServerContext context, TableConfiguration tableConf, Set<T> dataFiles) {
+
+ HashMap<T,FileSKVIterator.FileRange> dataFilesInfo = new HashMap<>();
+
+ long t1 = System.currentTimeMillis();
+
+ for (T dataFile : dataFiles) {
+
+ FileSKVIterator reader = null;
+ FileSystem ns = context.getVolumeManager().getFileSystemByPath(dataFile.getPath());
+ try {
+ reader = FileOperations.getInstance().newReaderBuilder()
+ .forFile(dataFile, ns, ns.getConf(), tableConf.getCryptoService())
+ .withTableConfiguration(tableConf).build();
+
+ dataFilesInfo.put(dataFile, reader.getFileRange());
+ } catch (IOException ioe) {
+ LOG.warn("Failed to read data file to determine first and last key : " + dataFile, ioe);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ioe) {
+ LOG.warn("failed to close " + dataFile, ioe);
+ }
+ }
+ }
+
+ }
+
+ long t2 = System.currentTimeMillis();
+
+ String message = String.format("Found first and last keys for %d data files in %6.2f secs",
+ dataFiles.size(), (t2 - t1) / 1000.0);
+ if (t2 - t1 > 500) {
+ LOG.debug(message);
+ } else {
+ LOG.trace(message);
+ }
+
+ return dataFilesInfo;
+ }
+
+ final LoadingCache<CacheKey,FileSKVIterator.FileRange> splitFileCache;
+
+ public SplitFileCache(ServerContext context) {
Review Comment:
yeah that is not a good name... looked into what it is caching and its the first and last row of files, so renamed it to FileRangeCache
--
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: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Refactor manager split code used by fate [accumulo]
Posted by "dlmarion (via GitHub)" <gi...@apache.org>.
dlmarion commented on code in PR #6115:
URL: https://github.com/apache/accumulo/pull/6115#discussion_r2793222410
##########
server/manager/src/main/java/org/apache/accumulo/manager/split/SplitFileCache.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.manager.split;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.file.FileOperations;
+import org.apache.accumulo.core.file.FileSKVIterator;
+import org.apache.accumulo.core.metadata.TabletFile;
+import org.apache.accumulo.core.util.cache.Caches;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.conf.TableConfiguration;
+import org.apache.hadoop.fs.FileSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.github.benmanes.caffeine.cache.CacheLoader;
+import com.github.benmanes.caffeine.cache.LoadingCache;
+import com.github.benmanes.caffeine.cache.Weigher;
+
+public class SplitFileCache {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SplitFileCache.class);
+
+ private static class CacheKey {
Review Comment:
Can this be a Record?
##########
server/manager/src/main/java/org/apache/accumulo/manager/split/SplitFileCache.java:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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
+ *
+ * https://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.accumulo.manager.split;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.accumulo.core.data.TableId;
+import org.apache.accumulo.core.file.FileOperations;
+import org.apache.accumulo.core.file.FileSKVIterator;
+import org.apache.accumulo.core.metadata.TabletFile;
+import org.apache.accumulo.core.util.cache.Caches;
+import org.apache.accumulo.server.ServerContext;
+import org.apache.accumulo.server.conf.TableConfiguration;
+import org.apache.hadoop.fs.FileSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.github.benmanes.caffeine.cache.CacheLoader;
+import com.github.benmanes.caffeine.cache.LoadingCache;
+import com.github.benmanes.caffeine.cache.Weigher;
+
+public class SplitFileCache {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SplitFileCache.class);
+
+ private static class CacheKey {
+
+ final TableId tableId;
+ final TabletFile tabletFile;
+
+ public CacheKey(TableId tableId, TabletFile tabletFile) {
+ this.tableId = tableId;
+ this.tabletFile = tabletFile;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ CacheKey cacheKey = (CacheKey) o;
+ return Objects.equals(tableId, cacheKey.tableId)
+ && Objects.equals(tabletFile, cacheKey.tabletFile);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tableId, tabletFile);
+ }
+
+ }
+
+ public static <T extends TabletFile> Map<T,FileSKVIterator.FileRange> tryToGetFirstAndLastRows(
+ ServerContext context, TableConfiguration tableConf, Set<T> dataFiles) {
+
+ HashMap<T,FileSKVIterator.FileRange> dataFilesInfo = new HashMap<>();
+
+ long t1 = System.currentTimeMillis();
+
+ for (T dataFile : dataFiles) {
+
+ FileSKVIterator reader = null;
+ FileSystem ns = context.getVolumeManager().getFileSystemByPath(dataFile.getPath());
+ try {
+ reader = FileOperations.getInstance().newReaderBuilder()
+ .forFile(dataFile, ns, ns.getConf(), tableConf.getCryptoService())
+ .withTableConfiguration(tableConf).build();
+
+ dataFilesInfo.put(dataFile, reader.getFileRange());
+ } catch (IOException ioe) {
+ LOG.warn("Failed to read data file to determine first and last key : " + dataFile, ioe);
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ioe) {
+ LOG.warn("failed to close " + dataFile, ioe);
+ }
+ }
+ }
+
+ }
+
+ long t2 = System.currentTimeMillis();
+
+ String message = String.format("Found first and last keys for %d data files in %6.2f secs",
+ dataFiles.size(), (t2 - t1) / 1000.0);
+ if (t2 - t1 > 500) {
+ LOG.debug(message);
+ } else {
+ LOG.trace(message);
+ }
+
+ return dataFilesInfo;
+ }
+
+ final LoadingCache<CacheKey,FileSKVIterator.FileRange> splitFileCache;
+
+ public SplitFileCache(ServerContext context) {
Review Comment:
At first I was thinking this was a cache of split files, but it's a cache of file splits. I wonder if FileSplitsCache would be a better name?
--
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: notifications-unsubscribe@accumulo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org