@Test public void isMounted() { String s3Uri = "s3a: String hdfsUri = "hdfs: Map<String, MountPointInfo> mountTable = new HashMap<>(); mountTable.put("/s3", new MountPointInfo().setUfsUri(s3Uri)); FileSystemMaster mockMaster = mock(FileSystemMaster.class); when(mockMaster.getMountPointInfoSummary()).thenReturn(mountTable); AlluxioMasterProcess masterProcess = mock(AlluxioMasterProcess.class); when(masterProcess.getMaster(FileSystemMaster.class)).thenReturn(mockMaster); ServletContext context = mock(ServletContext.class); when(context.getAttribute(MasterWebServer.ALLUXIO_MASTER_SERVLET_RESOURCE_KEY)).thenReturn( masterProcess); AlluxioMasterRestServiceHandler handler = new AlluxioMasterRestServiceHandler(context); assertFalse(handler.isMounted(s3Uri)); assertTrue(handler.isMounted(MetricsSystem.escape(new AlluxioURI(s3Uri)))); assertTrue(handler.isMounted(MetricsSystem.escape(new AlluxioURI(s3Uri + "/")))); assertFalse(handler.isMounted(hdfsUri)); assertFalse(handler.isMounted(MetricsSystem.escape(new AlluxioURI(hdfsUri)))); }
@VisibleForTesting boolean isMounted(String ufs) { ufs = PathUtils.normalizePath(ufs, AlluxioURI.SEPARATOR); for (Map.Entry<String, MountPointInfo> entry : mFileSystemMaster.getMountPointInfoSummary().entrySet()) { String escaped = MetricsSystem.escape(new AlluxioURI(entry.getValue().getUfsUri())); escaped = PathUtils.normalizePath(escaped, AlluxioURI.SEPARATOR); if (escaped.equals(ufs)) { return true; } } return false; }
AlluxioMasterRestServiceHandler { @VisibleForTesting boolean isMounted(String ufs) { ufs = PathUtils.normalizePath(ufs, AlluxioURI.SEPARATOR); for (Map.Entry<String, MountPointInfo> entry : mFileSystemMaster.getMountPointInfoSummary().entrySet()) { String escaped = MetricsSystem.escape(new AlluxioURI(entry.getValue().getUfsUri())); escaped = PathUtils.normalizePath(escaped, AlluxioURI.SEPARATOR); if (escaped.equals(ufs)) { return true; } } return false; } }
AlluxioMasterRestServiceHandler { @VisibleForTesting boolean isMounted(String ufs) { ufs = PathUtils.normalizePath(ufs, AlluxioURI.SEPARATOR); for (Map.Entry<String, MountPointInfo> entry : mFileSystemMaster.getMountPointInfoSummary().entrySet()) { String escaped = MetricsSystem.escape(new AlluxioURI(entry.getValue().getUfsUri())); escaped = PathUtils.normalizePath(escaped, AlluxioURI.SEPARATOR); if (escaped.equals(ufs)) { return true; } } return false; } AlluxioMasterRestServiceHandler(@Context ServletContext context); }
AlluxioMasterRestServiceHandler { @VisibleForTesting boolean isMounted(String ufs) { ufs = PathUtils.normalizePath(ufs, AlluxioURI.SEPARATOR); for (Map.Entry<String, MountPointInfo> entry : mFileSystemMaster.getMountPointInfoSummary().entrySet()) { String escaped = MetricsSystem.escape(new AlluxioURI(entry.getValue().getUfsUri())); escaped = PathUtils.normalizePath(escaped, AlluxioURI.SEPARATOR); if (escaped.equals(ufs)) { return true; } } return false; } AlluxioMasterRestServiceHandler(@Context ServletContext context); @GET @Path(GET_INFO) @ApiOperation(value = "Get general Alluxio Master service information", response = alluxio.wire.AlluxioMasterInfo.class) Response getInfo(@QueryParam(QUERY_RAW_CONFIGURATION) final Boolean rawConfiguration); @GET @Path(WEBUI_INIT) Response getWebUIInit(); @GET @Path(WEBUI_OVERVIEW) Response getWebUIOverview(); @GET @Path(WEBUI_BROWSE) Response getWebUIBrowse(@DefaultValue("/") @QueryParam("path") String requestPath,
      @DefaultValue("0") @QueryParam("offset") String requestOffset,
      @DefaultValue("") @QueryParam("end") String requestEnd,
      @DefaultValue("20") @QueryParam("limit") String requestLimit); @GET @Path(WEBUI_DATA) Response getWebUIData(@DefaultValue("0") @QueryParam("offset") String requestOffset,
      @DefaultValue("20") @QueryParam("limit") String requestLimit); @GET @Path(WEBUI_LOGS) Response getWebUILogs(@DefaultValue("") @QueryParam("path") String requestPath,
      @DefaultValue("0") @QueryParam("offset") String requestOffset,
      @DefaultValue("") @QueryParam("end") String requestEnd,
      @DefaultValue("20") @QueryParam("limit") String requestLimit); @GET @Path(WEBUI_CONFIG) Response getWebUIConfiguration(); @GET @Path(WEBUI_WORKERS) Response getWebUIWorkers(); @GET @Path(WEBUI_METRICS) Response getWebUIMetrics(); @POST @Path(LOG_LEVEL) Response logLevel(@QueryParam(LOG_ARGUMENT_NAME) final String logName,
      @QueryParam(LOG_ARGUMENT_LEVEL) final String level); }
AlluxioMasterRestServiceHandler { @VisibleForTesting boolean isMounted(String ufs) { ufs = PathUtils.normalizePath(ufs, AlluxioURI.SEPARATOR); for (Map.Entry<String, MountPointInfo> entry : mFileSystemMaster.getMountPointInfoSummary().entrySet()) { String escaped = MetricsSystem.escape(new AlluxioURI(entry.getValue().getUfsUri())); escaped = PathUtils.normalizePath(escaped, AlluxioURI.SEPARATOR); if (escaped.equals(ufs)) { return true; } } return false; } AlluxioMasterRestServiceHandler(@Context ServletContext context); @GET @Path(GET_INFO) @ApiOperation(value = "Get general Alluxio Master service information", response = alluxio.wire.AlluxioMasterInfo.class) Response getInfo(@QueryParam(QUERY_RAW_CONFIGURATION) final Boolean rawConfiguration); @GET @Path(WEBUI_INIT) Response getWebUIInit(); @GET @Path(WEBUI_OVERVIEW) Response getWebUIOverview(); @GET @Path(WEBUI_BROWSE) Response getWebUIBrowse(@DefaultValue("/") @QueryParam("path") String requestPath,
      @DefaultValue("0") @QueryParam("offset") String requestOffset,
      @DefaultValue("") @QueryParam("end") String requestEnd,
      @DefaultValue("20") @QueryParam("limit") String requestLimit); @GET @Path(WEBUI_DATA) Response getWebUIData(@DefaultValue("0") @QueryParam("offset") String requestOffset,
      @DefaultValue("20") @QueryParam("limit") String requestLimit); @GET @Path(WEBUI_LOGS) Response getWebUILogs(@DefaultValue("") @QueryParam("path") String requestPath,
      @DefaultValue("0") @QueryParam("offset") String requestOffset,
      @DefaultValue("") @QueryParam("end") String requestEnd,
      @DefaultValue("20") @QueryParam("limit") String requestLimit); @GET @Path(WEBUI_CONFIG) Response getWebUIConfiguration(); @GET @Path(WEBUI_WORKERS) Response getWebUIWorkers(); @GET @Path(WEBUI_METRICS) Response getWebUIMetrics(); @POST @Path(LOG_LEVEL) Response logLevel(@QueryParam(LOG_ARGUMENT_NAME) final String logName,
      @QueryParam(LOG_ARGUMENT_LEVEL) final String level); static final String SERVICE_PREFIX; static final String GET_INFO; static final String WEBUI_INIT; static final String WEBUI_OVERVIEW; static final String WEBUI_BROWSE; static final String WEBUI_DATA; static final String WEBUI_LOGS; static final String WEBUI_CONFIG; static final String WEBUI_WORKERS; static final String WEBUI_METRICS; static final String QUERY_RAW_CONFIGURATION; static final String LOG_LEVEL; static final String LOG_ARGUMENT_NAME; static final String LOG_ARGUMENT_LEVEL; }