/** * Checks if authorization is enabled. * * @return true if authorization is enabled, false otherwise */ public static boolean isAuthorizationEnabled() { return Configuration.getBoolean(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED); }
@Override protected boolean isZookeeperMode() { return Configuration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED); } }
@Override public boolean isEnabled() { return Configuration.getBoolean(PropertyKey.USER_LINEAGE_ENABLED); }
/** * Constructs a block integrity checker based on the given {@link FileSystemMaster}. * * @param fsm the master to check */ public BlockIntegrityChecker(FileSystemMaster fsm) { mFileSystemMaster = fsm; mRepair = Configuration.getBoolean(PropertyKey.MASTER_PERIODIC_BLOCK_INTEGRITY_CHECK_REPAIR); }
@Override public boolean isEnabled() { return Configuration.getBoolean(PropertyKey.KEY_VALUE_ENABLED); }
@Override public boolean isEnabled() { return Configuration.getBoolean(PropertyKey.KEY_VALUE_ENABLED); }
/** * Logs a fatal error and then exits the system. * * @param logger the logger to log to * @param t the throwable causing the fatal error * @param format the error message format string * @param args args for the format string */ public static void fatalError(Logger logger, Throwable t, String format, Object... args) { String message = String.format("Fatal error: " + format, args); if (t != null) { message += "\n" + ExceptionUtils.getStackTrace(t); } if (Configuration.getBoolean(PropertyKey.TEST_MODE)) { throw new RuntimeException(message); } logger.error(message); System.exit(-1); }
/** * @return the current lineage for Alluxio */ public static synchronized AlluxioLineage get() { if (sAlluxioLineage == null) { if (!ClientContext.getConf().getBoolean(Constants.USER_LINEAGE_ENABLED)) { throw new IllegalStateException("Lineage is not enabled in the configuration."); } sAlluxioLineage = new AlluxioLineage(); } return sAlluxioLineage; }
/** * Constructs a {@link PermissionChecker} instance for Alluxio file system. * * @param inodeTree inode tree of the file system master */ public DefaultPermissionChecker(InodeTree inodeTree) { mInodeTree = Preconditions.checkNotNull(inodeTree, "inodeTree"); mPermissionCheckEnabled = Configuration.getBoolean(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_ENABLED); mFileSystemSuperGroup = Configuration.get(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_SUPERGROUP); mInodePermissionChecker = InodePermissionChecker.create(); }
/** * Starts jvm monitor process, to monitor jvm. */ protected void startJvmMonitorProcess() { if (Configuration.getBoolean(PropertyKey.MASTER_JVM_MONITOR_ENABLED)) { mJvmPauseMonitor = new JvmPauseMonitor(); mJvmPauseMonitor.start(); } }
/** * @return whether the configuration describes how to find the master host, either through * explicit configuration or through zookeeper */ public static boolean masterHostConfigured() { boolean usingZk = Configuration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED) && Configuration.isSet(PropertyKey.ZOOKEEPER_ADDRESS); return Configuration.isSet(PropertyKey.MASTER_HOSTNAME) || usingZk; }
/** * Populates key, value pairs for UI display. * * @param request the {@link HttpServletRequest} object */ private void populateValues(HttpServletRequest request) throws IOException { request.setAttribute("debug", Configuration.getBoolean(PropertyKey.DEBUG)); List<WorkerInfo> workerInfos = mBlockMaster.getWorkerInfoList(); NodeInfo[] normalNodeInfos = generateOrderedNodeInfos(workerInfos); request.setAttribute("normalNodeInfos", normalNodeInfos); List<WorkerInfo> lostWorkerInfos = mBlockMaster.getLostWorkersInfoList(); NodeInfo[] failedNodeInfos = generateOrderedNodeInfos(lostWorkerInfos); request.setAttribute("failedNodeInfos", failedNodeInfos); } }
/** * Starts in a command like {@code java -cp ALLUXIO_JAR CLASS_NAME <key-value store URI>}. * * @param args one argument, specifying the URI of the store to be created */ public static void main(String[] args) throws Exception { if (args.length != 1) { System.out.println("Usage: java -cp " + RuntimeConstants.ALLUXIO_JAR + " " + KeyValueStoreOperations.class.getName() + " <key-value store URI>"); System.exit(-1); } if (!Configuration.getBoolean(PropertyKey.KEY_VALUE_ENABLED)) { System.out.println("Alluxio key value service is disabled. To run this test, please set " + PropertyKey.KEY_VALUE_ENABLED + " to be true and restart the cluster."); System.exit(-1); } // TODO(binfan): the "run and exit" pattern shows up repeatedly in the code base and it might // make sense to add a utility function for it to CliUtils boolean result = CliUtils.runExample(new KeyValueStoreOperations(new AlluxioURI(args[0]))); System.exit(result ? 0 : 1); } }
public static FileSystem get() { if (ClientContext.getConf().getBoolean(Constants.USER_LINEAGE_ENABLED)) { return LineageFileSystem.get(); } return BaseFileSystem.get(); } }
/** * @param workerNetAddress the worker address * @return true if the domain socket is enabled on this client */ public static boolean isDomainSocketSupported(WorkerNetAddress workerNetAddress) { if (workerNetAddress.getDomainSocketPath().isEmpty() || USER_CHANNEL_TYPE != ChannelType.EPOLL) { return false; } if (Configuration.getBoolean(PropertyKey.WORKER_DATA_SERVER_DOMAIN_SOCKET_AS_UUID)) { return FileUtils.exists(workerNetAddress.getDomainSocketPath()); } else { return workerNetAddress.getHost().equals(NetworkAddressUtils.getClientHostName()); } }
@Override public StartupConsistencyCheck getStartupConsistencyCheck() { if (!Configuration.getBoolean(PropertyKey.MASTER_STARTUP_CONSISTENCY_CHECK_ENABLED)) { return StartupConsistencyCheck.disabled(); } if (mStartupConsistencyCheck == null) { return StartupConsistencyCheck.notStarted(); } if (!mStartupConsistencyCheck.isDone()) { return StartupConsistencyCheck.running(); } try { List<AlluxioURI> inconsistentUris = mStartupConsistencyCheck.get(); return StartupConsistencyCheck.complete(inconsistentUris); } catch (Exception e) { LOG.warn("Failed to complete start up consistency check.", e); return StartupConsistencyCheck.failed(); } }
/** * @return the instance of under file system for Alluxio root directory */ public static UnderFileSystem createForRoot() { String ufsRoot = Configuration.get(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS); boolean readOnly = Configuration.getBoolean(PropertyKey.MASTER_MOUNT_TABLE_ROOT_READONLY); boolean shared = Configuration.getBoolean(PropertyKey.MASTER_MOUNT_TABLE_ROOT_SHARED); Map<String, String> ufsConf = Configuration.getNestedProperties(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION); return create(ufsRoot, UnderFileSystemConfiguration.defaults().setReadOnly(readOnly) .setShared(shared).setUserSpecifiedConf(ufsConf)); } }
@Override public UfsClient getRoot() { synchronized (this) { if (mRootUfsClient == null) { String rootUri = Configuration.get(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS); boolean rootReadOnly = Configuration.getBoolean(PropertyKey.MASTER_MOUNT_TABLE_ROOT_READONLY); boolean rootShared = Configuration.getBoolean(PropertyKey.MASTER_MOUNT_TABLE_ROOT_SHARED); Map<String, String> rootConf = Configuration.getNestedProperties(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION); addMount(IdUtils.ROOT_MOUNT_ID, new AlluxioURI(rootUri), UnderFileSystemConfiguration.defaults().setReadOnly(rootReadOnly).setShared(rootShared) .setUserSpecifiedConf(rootConf)); try { mRootUfsClient = get(IdUtils.ROOT_MOUNT_ID); } catch (NotFoundException | UnavailableException e) { throw new RuntimeException("We should never reach here", e); } } return mRootUfsClient; } }
/** * @return a new instance of {@link MasterProcess} */ public static MasterProcess create() { URI journalLocation = JournalUtils.getJournalLocation(); JournalSystem journalSystem = new JournalSystem.Builder().setLocation(journalLocation).build(); if (Configuration.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { PrimarySelector primarySelector = PrimarySelector.Factory.createZkPrimarySelector(); return new FaultTolerantAlluxioMasterProcess(journalSystem, primarySelector); } return new AlluxioMasterProcess(journalSystem); }
@Override public void resetState() { mInodeTree.reset(); String rootUfsUri = Configuration.get(PropertyKey.MASTER_MOUNT_TABLE_ROOT_UFS); Map<String, String> rootUfsConf = Configuration.getNestedProperties(PropertyKey.MASTER_MOUNT_TABLE_ROOT_OPTION); mMountTable.clear(); // Initialize the root mount if it doesn't exist yet. if (!mMountTable.isMountPoint(new AlluxioURI(MountTable.ROOT))) { try (CloseableResource<UnderFileSystem> ufsResource = mUfsManager.getRoot().acquireUfsResource()) { // The root mount is a part of the file system master's initial state. The mounting is not // journaled, so the root will be re-mounted based on configuration whenever the master // starts. long rootUfsMountId = IdUtils.ROOT_MOUNT_ID; mMountTable.add(new AlluxioURI(MountTable.ROOT), new AlluxioURI(rootUfsUri), rootUfsMountId, MountOptions.defaults() .setShared(ufsResource.get().isObjectStorage() && Configuration .getBoolean(PropertyKey.UNDERFS_OBJECT_STORE_MOUNT_SHARED_PUBLICLY)) .setProperties(rootUfsConf)); } catch (FileAlreadyExistsException | InvalidPathException e) { throw new IllegalStateException(e); } } }