From 50a9bd6fd1741585b7022350a425e9429fc87e4f Mon Sep 17 00:00:00 2001 From: Bin Fan Date: Wed, 2 Oct 2019 10:33:53 -0700 Subject: [PATCH] Implement BlackList (#4) --- .../main/java/alluxio/conf/PropertyKey.java | 7 +++++ .../master/file/DefaultFileSystemMaster.java | 31 ++++++++++++++----- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/core/common/src/main/java/alluxio/conf/PropertyKey.java b/core/common/src/main/java/alluxio/conf/PropertyKey.java index a79903cb5a68..3eba07ad8ea8 100644 --- a/core/common/src/main/java/alluxio/conf/PropertyKey.java +++ b/core/common/src/main/java/alluxio/conf/PropertyKey.java @@ -1639,6 +1639,11 @@ public String toString() { .setDescription("How often the master schedules persistence jobs " + "for files written using ASYNC_THROUGH") .build(); + public static final PropertyKey MASTER_PERSISTENCE_BLACKLIST = + new Builder(Name.MASTER_PERSISTENCE_BLACKLIST) + .setDefaultValue("") + .setDescription("Patterns to blacklist persist, comma separated, string match, no regex.") + .build(); public static final PropertyKey MASTER_REPLICATION_CHECK_INTERVAL_MS = new Builder(Name.MASTER_REPLICATION_CHECK_INTERVAL_MS) .setDefaultValue("1min") @@ -3922,6 +3927,8 @@ public static final class Name { "alluxio.master.persistence.max.interval"; public static final String MASTER_PERSISTENCE_SCHEDULER_INTERVAL_MS = "alluxio.master.persistence.scheduler.interval"; + public static final String MASTER_PERSISTENCE_BLACKLIST = + "alluxio.master.persistence.blacklist"; public static final String MASTER_LOG_CONFIG_REPORT_HEARTBEAT_INTERVAL = "alluxio.master.log.config.report.heartbeat.interval"; public static final String MASTER_PERIODIC_BLOCK_INTEGRITY_CHECK_REPAIR = diff --git a/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java b/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java index f89e6ade79e8..569290b9eda1 100644 --- a/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java +++ b/core/server/master/src/main/java/alluxio/master/file/DefaultFileSystemMaster.java @@ -2045,7 +2045,8 @@ private void renameInternal(RpcContext rpcContext, LockedInodePath srcInodePath, // Check options and determine if we should schedule async persist. This is helpful for compute // frameworks that use rename as a commit operation. - if (context.getPersist() && srcInode.isFile() && !srcInode.isPersisted()) { + if (context.getPersist() && srcInode.isFile() && !srcInode.isPersisted() + && shouldPersistPath(dstInodePath.toString())) { mInodeTree.updateInode(rpcContext, UpdateInodeEntry.newBuilder() .setId(srcInode.getId()) .setPersistenceState(PersistenceState.TO_BE_PERSISTED.name()) @@ -2061,6 +2062,20 @@ private void renameInternal(RpcContext rpcContext, LockedInodePath srcInodePath, } } + private static final List PERSISTENCE_BLACKLIST = + ServerConfiguration.getList(PropertyKey.MASTER_PERSISTENCE_BLACKLIST, ","); + + private boolean shouldPersistPath(String path) { + for (String pattern : PERSISTENCE_BLACKLIST) { + if (path.contains(pattern)) { + LOG.debug("Not persisting path {} because it is in PERSISTENC_BLACKLIST {}", + path, PERSISTENCE_BLACKLIST); + return false; + } + } + return true; + } + /** * Implements renaming. * @@ -3151,14 +3166,16 @@ private void scheduleAsyncPersistenceInternal(LockedInodePath inodePath, throw new InvalidPathException( "Cannot persist an incomplete Alluxio file: " + inodePath.getUri()); } - mInodeTree.updateInode(rpcContext, UpdateInodeEntry.newBuilder().setId(inode.getId()) + if (shouldPersistPath(inodePath.toString())) { + mInodeTree.updateInode(rpcContext, UpdateInodeEntry.newBuilder().setId(inode.getId()) .setPersistenceState(PersistenceState.TO_BE_PERSISTED.name()).build()); - mPersistRequests.put(inode.getId(), + mPersistRequests.put(inode.getId(), new alluxio.time.ExponentialTimer( - ServerConfiguration.getMs(PropertyKey.MASTER_PERSISTENCE_INITIAL_INTERVAL_MS), - ServerConfiguration.getMs(PropertyKey.MASTER_PERSISTENCE_MAX_INTERVAL_MS), - context.getPersistenceWaitTime(), - ServerConfiguration.getMs(PropertyKey.MASTER_PERSISTENCE_MAX_TOTAL_WAIT_TIME_MS))); + ServerConfiguration.getMs(PropertyKey.MASTER_PERSISTENCE_INITIAL_INTERVAL_MS), + ServerConfiguration.getMs(PropertyKey.MASTER_PERSISTENCE_MAX_INTERVAL_MS), + context.getPersistenceWaitTime(), + ServerConfiguration.getMs(PropertyKey.MASTER_PERSISTENCE_MAX_TOTAL_WAIT_TIME_MS))); + } } /**