org.apache.kylin.common.persistence.ResourceStore.deleteResource()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(86)

本文整理了Java中org.apache.kylin.common.persistence.ResourceStore.deleteResource方法的一些代码示例,展示了ResourceStore.deleteResource的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceStore.deleteResource方法的具体详情如下:
包路径:org.apache.kylin.common.persistence.ResourceStore
类名称:ResourceStore
方法名:deleteResource

ResourceStore.deleteResource介绍

[英]delete a resource, does nothing on a folder
[中]删除资源,对文件夹不做任何操作

代码示例

代码示例来源:origin: apache/kylin

public void removeSnapshot(String resourcePath) throws IOException {
  ResourceStore store = getStore();
  store.deleteResource(resourcePath);
  snapshotCache.invalidate(resourcePath);
}

代码示例来源:origin: apache/kylin

public void removeDictionary(String resourcePath) throws IOException {
  logger.info("Remvoing dict: " + resourcePath);
  ResourceStore store = getStore();
  store.deleteResource(resourcePath);
  dictCache.invalidate(resourcePath);
}

代码示例来源:origin: apache/kylin

public void delete(String resName) throws IOException {
  Preconditions.checkArgument(resName != null);
  String path = resourcePath(resName);
  logger.debug("Deleting {} at {}", entityType.getSimpleName(), path);
  store.deleteResource(path);
  cache.remove(resName);
}

代码示例来源:origin: apache/kylin

public void delete(String uuid) throws IOException {
    ResourceStore store = getStore();
    store.deleteResource(Draft.concatResourcePath(uuid));
  }
}

代码示例来源:origin: apache/kylin

public void removeBadQueryHistory(String project) throws IOException {
  getStore().deleteResource(getResourcePathForProject(project));
}

代码示例来源:origin: apache/kylin

public void deleteJob(String uuid) throws PersistentException {
  try {
    store.deleteResource(pathOfJob(uuid));
    executableDigestMap.remove(uuid);
  } catch (IOException e) {
    logger.error("error delete job:" + uuid, e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: apache/kylin

public void removeSnapshot(String tableName, String snapshotID) throws IOException {
  String snapshotResPath = ExtTableSnapshotInfo.getResourcePath(tableName, snapshotID);
  snapshotCache.invalidate(snapshotResPath);
  ResourceStore store = TableMetadataManager.getInstance(this.config).getStore();
  store.deleteResource(snapshotResPath);
}

代码示例来源:origin: apache/kylin

private List<String> cleanupConclude(boolean delete, List<String> toDeleteResources) throws IOException {
  if (toDeleteResources.isEmpty()) {
    logger.info("No metadata resource to clean up");
    return toDeleteResources;
  }
  
  logger.info(toDeleteResources.size() + " metadata resource to clean up");
  if (delete) {
    ResourceStore store = ResourceStore.getStore(config);
    FileSystem fs = HadoopUtil.getWorkingFileSystem(HadoopUtil.getCurrentConfiguration());
    for (String res : toDeleteResources) {
      logger.info("Deleting metadata " + res);
      try {
        if (res.startsWith(KylinConfig.getInstanceFromEnv().getHdfsWorkingDirectory())) {
          fs.delete(new Path(res), true);
        } else {
          store.deleteResource(res);
        }
      } catch (IOException e) {
        logger.error("Failed to delete resource " + res, e);
      }
    }
  } else {
    for (String res : toDeleteResources) {
      logger.info("Dry run, pending delete metadata " + res);
    }
  }
  return toDeleteResources;
}

代码示例来源:origin: apache/kylin

public void resetR(ResourceStore store, String path) throws IOException {
  NavigableSet<String> children = store.listResources(path);
  if (children == null) { // path is a resource (not a folder)
    if (matchFilter(path, includes, excludes)) {
      store.deleteResource(path);
    }
  } else {
    for (String child : children)
      resetR(store, child);
  }
}

代码示例来源:origin: apache/kylin

public void deleteJobOutput(String uuid) throws PersistentException {
  try {
    store.deleteResource(pathOfJobOutput(uuid));
    if (!isTaskExecutableOutput(uuid))
      executableOutputDigestMap.remove(uuid);
  } catch (IOException e) {
    logger.error("error delete job:" + uuid, e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: apache/kylin

private static long testWritePerformance(ResourceStore store) throws IOException {
  store.deleteResource(PERFORMANCE_TEST_ROOT_PATH);
  StringEntity content = new StringEntity("something");
  long startTime = System.currentTimeMillis();
  for (int i = 0; i < TEST_RESOURCE_COUNT; i++) {
    String resourcePath = PERFORMANCE_TEST_ROOT_PATH + "/res_" + i;
    store.putResource(resourcePath, content, 0, StringEntity.serializer);
  }
  return System.currentTimeMillis() - startTime;
}

代码示例来源:origin: apache/kylin

private void delete(HybridInstance hybridInstance) throws IOException {
  ProjectManager.getInstance(kylinConfig).removeRealizationsFromProjects(RealizationType.HYBRID, hybridInstance.getName());
  store.deleteResource(hybridInstance.getResourcePath());
  hybridManager.reloadAllHybridInstance();
  logger.info("HybridInstance was deleted at: " + hybridInstance.getResourcePath());
}

代码示例来源:origin: apache/kylin

public static void appendFactTableData(String factTableContent, String factTableName) throws IOException {
  // Write to resource store
  ResourceStore store = ResourceStore.getStore(config());
  InputStream in = new ByteArrayInputStream(factTableContent.getBytes("UTF-8"));
  String factTablePath = "/data/" + factTableName + ".csv";
  File tmpFile = File.createTempFile(factTableName, "csv");
  FileOutputStream out = new FileOutputStream(tmpFile);
  InputStream tempIn = null;
  try {
    if (store.exists(factTablePath)) {
      InputStream oldContent = store.getResource(factTablePath).content();
      IOUtils.copy(oldContent, out);
    }
    IOUtils.copy(in, out);
    IOUtils.closeQuietly(in);
    IOUtils.closeQuietly(out);
    store.deleteResource(factTablePath);
    tempIn = new FileInputStream(tmpFile);
    store.putResource(factTablePath, tempIn, System.currentTimeMillis());
  } finally {
    IOUtils.closeQuietly(out);
    IOUtils.closeQuietly(in);
    IOUtils.closeQuietly(tempIn);
  }
}

代码示例来源:origin: apache/kylin

getStore().deleteResource(resource);
} catch (IOException ioe) {
  logger.error("Failed to delete resource {}", toRemoveResources);

代码示例来源:origin: apache/kylin

public void saveTableExt(TableExtDesc tableExt, String prj) throws IOException {
  try (AutoLock lock = srcExtMapLock.lockForWrite()) {
    if (tableExt.getUuid() == null || tableExt.getIdentity() == null) {
      throw new IllegalArgumentException();
    }
    // updating a legacy global table
    if (tableExt.getProject() == null) {
      if (getTableExt(tableExt.getIdentity(), prj).getProject() != null)
        throw new IllegalStateException(
            "Updating a legacy global TableExtDesc while a project level version exists: "
                + tableExt.getIdentity() + ", " + prj);
      prj = tableExt.getProject();
    }
    tableExt.init(prj);
    // what is this doing??
    String path = TableExtDesc.concatResourcePath(tableExt.getIdentity(), prj);
    ResourceStore store = getStore();
    TableExtDesc t = store.getResource(path, TABLE_EXT_SERIALIZER);
    if (t != null && t.getIdentity() == null)
      store.deleteResource(path);
    srcExtCrud.save(tableExt);
  }
}

代码示例来源:origin: apache/kylin

@Test
public void testExistingProject() throws Exception {
  ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig());
  CubeManager cubeMgr = CubeManager.getInstance(getTestConfig());
  CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig());
  int originalProjectCount = prjMgr.listAllProjects().size();
  int originalCubeCount = cubeMgr.listAllCubes().size();
  ResourceStore store = getStore();
  // clean legacy in case last run failed
  store.deleteResource("/cube/new_cube_in_default.json");
  CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc");
  CubeInstance createdCube = cubeMgr.createCube("new_cube_in_default", ProjectInstance.DEFAULT_PROJECT_NAME, desc, null);
  assertTrue(createdCube.equals(cubeMgr.getCube("new_cube_in_default")));
  //System.out.println(JsonUtil.writeValueAsIndentString(createdCube));
  assertTrue(prjMgr.listAllProjects().size() == originalProjectCount);
  assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1);
  CubeInstance droppedCube = cubeMgr.dropCube("new_cube_in_default", true);
  assertTrue(createdCube.equals(droppedCube));
  assertNull(cubeMgr.getCube("new_cube_in_default"));
  assertTrue(prjMgr.listAllProjects().size() == originalProjectCount);
  assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount);
}

代码示例来源:origin: apache/kylin

store.deleteResource("/cube/cube_in_alien_project.json");

代码示例来源:origin: apache/kylin

store.deleteResource("/res1");

代码示例来源:origin: apache/kylin

@Test
public void testCreateAndDrop() throws Exception {
  KylinConfig config = getTestConfig();
  CubeManager cubeMgr = CubeManager.getInstance(config);
  ProjectManager prjMgr = ProjectManager.getInstance(config);
  ResourceStore store = getStore();
  // clean legacy in case last run failed
  store.deleteResource("/cube/a_whole_new_cube.json");
  CubeDescManager cubeDescMgr = getCubeDescManager();
  CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc");
  CubeInstance createdCube = cubeMgr.createCube("a_whole_new_cube", ProjectInstance.DEFAULT_PROJECT_NAME, desc,
      null);
  assertTrue(createdCube.equals(cubeMgr.getCube("a_whole_new_cube")));
  assertTrue(prjMgr.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME).contains(createdCube));
  CubeInstance droppedCube = CubeManager.getInstance(getTestConfig()).dropCube("a_whole_new_cube", false);
  assertTrue(createdCube.equals(droppedCube));
  assertTrue(!prjMgr.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME).contains(droppedCube));
  assertNull(CubeManager.getInstance(getTestConfig()).getCube("a_whole_new_cube"));
}

代码示例来源:origin: apache/kylin

@Test
public void testReloadCache() throws Exception {
  ResourceStore store = getStore();
  // clean legacy in case last run failed
  store.deleteResource("/cube/a_whole_new_cube.json");
  CubeDescManager cubeDescMgr = getCubeDescManager();
  CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc");
  cubeManager.createCube("a_whole_new_cube", "default", desc, null);
  CubeInstance createdCube = cubeManager.getCube("a_whole_new_cube");
  assertEquals(0, createdCube.getSegments().size());
  assertEquals(RealizationStatusEnum.DISABLED, createdCube.getStatus());
  cubeManager.updateCubeStatus(createdCube, RealizationStatusEnum.READY);
  assertEquals(RealizationStatusEnum.READY, cubeManager.getCube("a_whole_new_cube").getStatus());
}

相关文章