本文整理了Java中org.apache.kylin.common.persistence.ResourceStore.exists
方法的一些代码示例,展示了ResourceStore.exists
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceStore.exists
方法的具体详情如下:
包路径:org.apache.kylin.common.persistence.ResourceStore
类名称:ResourceStore
方法名:exists
[英]return true if a resource exists, return false in case of folder or non-exist
[中]如果资源存在,则返回true;如果文件夹或不存在,则返回false
代码示例来源:origin: apache/kylin
private boolean isTableAlreadyMigrate(ResourceStore store, String tableName) throws IOException {
return store.exists(MIGRATE_OK_PREFIX + tableName);
}
代码示例来源:origin: apache/kylin
public boolean existsInStore(TableDesc table) throws IOException {
return outputStore.exists(path(table));
}
代码示例来源:origin: apache/kylin
protected void addCubeAndModelIntoProject(CubeInstance srcCube, String cubeName) throws IOException {
String projectResPath = ProjectInstance.concatResourcePath(dstProject);
if (!dstStore.exists(projectResPath))
throw new IllegalStateException("The target project " + dstProject + " does not exist");
operations.add(new Opt(OptType.ADD_INTO_PROJECT, new Object[] { srcCube, cubeName, dstProject }));
}
代码示例来源:origin: apache/kylin
private static void addCubeAndModelIntoProject(CubeInstance srcCube, String cubeName, String projectName) throws IOException {
String projectResPath = ProjectInstance.concatResourcePath(projectName);
if (!dstStore.exists(projectResPath))
throw new IllegalStateException("The target project " + projectName + "does not exist");
operations.add(new Opt(OptType.ADD_INTO_PROJECT, new Object[] { srcCube, cubeName, projectName }));
}
代码示例来源:origin: apache/kylin
private static void copyFilesInMetaStore(CubeInstance cube, String overwriteIfExists) throws IOException {
List<String> metaItems = new ArrayList<String>();
Set<String> dictAndSnapshot = new HashSet<String>();
listCubeRelatedResources(cube, metaItems, dictAndSnapshot);
if (dstStore.exists(cube.getResourcePath()) && !overwriteIfExists.equalsIgnoreCase("true"))
throw new IllegalStateException("The cube named " + cube.getName() + " already exists on target metadata store. Use overwriteIfExists to overwrite it");
for (String item : metaItems) {
operations.add(new Opt(OptType.COPY_FILE_IN_META, new Object[] { item }));
}
for (String item : dictAndSnapshot) {
operations.add(new Opt(OptType.COPY_DICT_OR_SNAPSHOT, new Object[] { item, cube.getName() }));
}
}
代码示例来源:origin: apache/kylin
private void attachSegmentsMetadataWithDict(List<CubeSegment> segments) throws IOException {
Set<String> dumpList = new LinkedHashSet<>();
dumpList.addAll(JobRelatedMetaUtil.collectCubeMetadata(segments.get(0).getCubeInstance()));
ResourceStore rs = ResourceStore.getStore(segments.get(0).getConfig());
for (CubeSegment segment : segments) {
dumpList.addAll(segment.getDictionaryPaths());
if (rs.exists(segment.getStatisticsResourcePath())) {
// cube statistics is not available for new segment
dumpList.add(segment.getStatisticsResourcePath());
}
}
JobRelatedMetaUtil.dumpAndUploadKylinPropsAndMetadata(dumpList, (KylinConfigExt) segments.get(0).getConfig(),
this.getParam(SparkCubingByLayer.OPTION_META_URL.getOpt()));
}
代码示例来源:origin: apache/kylin
protected void copyFilesInMetaStore(CubeInstance cube) throws IOException {
if (dstStore.exists(cube.getResourcePath()) && !doOverwrite)
throw new IllegalStateException("The cube named " + cube.getName()
+ " already exists on target metadata store. Use overwriteIfExists to overwrite it");
List<String> metaItems = new ArrayList<String>();
Set<String> dictAndSnapshot = new HashSet<String>();
listCubeRelatedResources(cube, metaItems, dictAndSnapshot);
for (String item : metaItems) {
operations.add(new Opt(OptType.COPY_FILE_IN_META, new Object[] { item }));
}
if (doMigrateSegment) {
for (String item : dictAndSnapshot) {
operations.add(new Opt(OptType.COPY_DICT_OR_SNAPSHOT, new Object[] { item, cube.getName() }));
}
}
}
代码示例来源:origin: apache/kylin
private static ResourceStore createResourceStore(KylinConfig kylinConfig) {
StorageURL metadataUrl = kylinConfig.getMetadataUrl();
logger.info("Using metadata url " + metadataUrl + " for resource store");
String clsName = kylinConfig.getResourceStoreImpls().get(metadataUrl.getScheme());
try {
Class<? extends ResourceStore> cls = ClassUtil.forName(clsName, ResourceStore.class);
ResourceStore store = cls.getConstructor(KylinConfig.class).newInstance(kylinConfig);
if (!store.exists(METASTORE_UUID_TAG)) {
store.checkAndPutResource(METASTORE_UUID_TAG, new StringEntity(store.createMetaStoreUUID()), 0,
StringEntity.serializer);
}
return store;
} catch (Throwable e) {
throw new IllegalArgumentException("Failed to find metadata store by url: " + metadataUrl, e);
}
}
代码示例来源:origin: apache/kylin
private void attachSegmentMetadataWithDict(CubeSegment segment) throws IOException {
Set<String> dumpList = new LinkedHashSet<>();
dumpList.addAll(JobRelatedMetaUtil.collectCubeMetadata(segment.getCubeInstance()));
dumpList.addAll(segment.getDictionaryPaths());
ResourceStore rs = ResourceStore.getStore(segment.getConfig());
if (rs.exists(segment.getStatisticsResourcePath())) {
// cube statistics is not available for new segment
dumpList.add(segment.getStatisticsResourcePath());
}
JobRelatedMetaUtil.dumpAndUploadKylinPropsAndMetadata(dumpList, (KylinConfigExt) segment.getConfig(),
this.getParam(SparkCubingByLayer.OPTION_META_URL.getOpt()));
}
代码示例来源:origin: apache/kylin
public String getMetaStoreUUID() throws IOException {
if (!exists(ResourceStore.METASTORE_UUID_TAG)) {
checkAndPutResource(ResourceStore.METASTORE_UUID_TAG, new StringEntity(createMetaStoreUUID()), 0,
StringEntity.serializer);
}
StringEntity entity = getResource(ResourceStore.METASTORE_UUID_TAG, StringEntity.serializer);
return entity.toString();
}
代码示例来源: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: KylinOLAP/Kylin
private static void addCubeIntoProject(String cubeName, String projectName) throws IOException {
String projectResPath = ProjectInstance.concatResourcePath(projectName);
if (!dstStore.exists(projectResPath))
throw new IllegalStateException("The target project " + projectName + "does not exist");
operations.add(new Opt(OptType.ADD_INTO_PROJECT, new Object[] { cubeName, projectName }));
}
代码示例来源:origin: KylinOLAP/Kylin
private static void copyFilesInMetaStore(CubeInstance cube, String overwriteIfExists) throws IOException {
List<String> metaItems = new ArrayList<String>();
List<String> dictAndSnapshot = new ArrayList<String>();
listCubeRelatedResources(cube, metaItems, dictAndSnapshot);
if (dstStore.exists(cube.getResourcePath()) && !overwriteIfExists.equalsIgnoreCase("true"))
throw new IllegalStateException("The cube named " + cube.getName() + " already exists on target metadata store. Use overwriteIfExists to overwrite it");
for (String item : metaItems) {
operations.add(new Opt(OptType.COPY_FILE_IN_META, new Object[] { item }));
}
for (String item : dictAndSnapshot) {
operations.add(new Opt(OptType.COPY_DICT_OR_SNAPSHOT, new Object[] { item, cube.getName() }));
}
}
代码示例来源:origin: apache/kylin
assertTrue(store.exists(path1));
t = store.getResource(path1, StringEntity.serializer);
assertEquals(content1, t);
assertTrue(store.exists(path2));
t = store.getResource(path2, StringEntity.serializer);
assertEquals(content2, t);
assertTrue(store.exists(path1) == false);
list = store.listResources(dir1);
assertTrue(list == null || list.contains(path1) == false);
assertTrue(store.exists(path2) == false);
list = store.listResources(dir2);
assertTrue(list == null || list.contains(path2) == false);
代码示例来源:origin: KylinOLAP/Kylin
public void scanRecursively(String path, Visitor visitor) throws IOException {
ArrayList<String> children = listResources(path);
if (children != null) {
for (String child : children)
scanRecursively(child, visitor);
return;
}
if (exists(path))
visitor.visit(path);
}
代码示例来源:origin: KylinOLAP/Kylin
@Test
public void testTableDescUpgrade() throws Exception {
MetadataManager metaMgr = MetadataManager.getInstance(KylinConfig.getInstanceFromEnv());
TableDesc fact = metaMgr.getTableDesc("default.test_kylin_fact");
@SuppressWarnings("deprecation")
String oldResLocation = fact.getResourcePathV1();
String newResLocation = fact.getResourcePath();
ResourceStore store = ResourceStore.getStore(KylinConfig.getInstanceFromEnv());
Assert.assertTrue(store.exists(newResLocation));
Assert.assertTrue(!store.exists(oldResLocation));
String oldExdResLocation = TableDesc.concatExdResourcePath("test_kylin_fact".toUpperCase());
String newExdResLocation = TableDesc.concatExdResourcePath("default.test_kylin_fact".toUpperCase());
Assert.assertTrue(store.exists(newExdResLocation));
Assert.assertTrue(!store.exists(oldExdResLocation));
}
代码示例来源:origin: KylinOLAP/Kylin
@Test
public void testHBaseStoreWithLargeCell() throws Exception {
String path = "/cube/_test_large_cell.json";
String largeContent = "THIS_IS_A_LARGE_CELL";
StringEntity content = new StringEntity(largeContent);
KylinConfig config = KylinConfig.getInstanceFromEnv();
int origSize = config.getHBaseKeyValueSize();
ResourceStore store = ResourceStore.getStore(KylinConfig.getInstanceFromEnv());
try {
config.setProperty("kylin.hbase.client.keyvalue.maxsize", String.valueOf(largeContent.length() - 1));
store.deleteResource(path);
store.putResource(path, content, StringEntity.serializer);
assertTrue(store.exists(path));
StringEntity t = store.getResource(path, StringEntity.class, StringEntity.serializer);
assertEquals(content, t);
Path redirectPath = ((HBaseResourceStore) store).bigCellHDFSPath(path);
Configuration hconf = HadoopUtil.getCurrentConfiguration();
FileSystem fileSystem = FileSystem.get(hconf);
assertTrue(fileSystem.exists(redirectPath));
FSDataInputStream in = fileSystem.open(redirectPath);
assertEquals(largeContent, in.readUTF());
in.close();
store.deleteResource(path);
} finally {
config.setProperty("kylin.hbase.client.keyvalue.maxsize", "" + origSize);
store.deleteResource(path);
}
}
代码示例来源:origin: KylinOLAP/Kylin
assertTrue(store.exists(path1));
t = store.getResource(path1, StringEntity.class, StringEntity.serializer);
assertEquals(content1, t);
assertTrue(store.exists(path2));
t = store.getResource(path2, StringEntity.class, StringEntity.serializer);
assertEquals(content2, t);
assertTrue(store.exists(path1) == false);
list = store.listResources(dir1);
assertTrue(list == null || list.contains(path1) == false);
assertTrue(store.exists(path2) == false);
list = store.listResources(dir2);
assertTrue(list == null || list.contains(path2) == false);
代码示例来源:origin: KylinOLAP/Kylin
assertTrue(store.exists(path1));
t = store.getResource(path1, StringEntity.class, StringEntity.serializer);
assertEquals(content1, t);
assertTrue(store.exists(path2));
t = store.getResource(path2, StringEntity.class, StringEntity.serializer);
assertEquals(content2, t);
assertTrue(store.exists(path1) == false);
list = store.listResources(dir1);
assertTrue(list == null || list.contains(path1) == false);
assertTrue(store.exists(path2) == false);
list = store.listResources(dir2);
assertTrue(list == null || list.contains(path2) == false);
代码示例来源:origin: org.apache.kylin/kylin-core-common
public String getMetaStoreUUID() throws IOException {
if (!exists(ResourceStore.METASTORE_UUID_TAG)) {
checkAndPutResource(ResourceStore.METASTORE_UUID_TAG, new StringEntity(createMetaStoreUUID()), 0,
StringEntity.serializer);
}
StringEntity entity = getResource(ResourceStore.METASTORE_UUID_TAG, StringEntity.serializer);
return entity.toString();
}
内容来源于网络,如有侵权,请联系作者删除!