本文整理了Java中org.apache.kylin.common.persistence.ResourceStore.putResource
方法的一些代码示例,展示了ResourceStore.putResource
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceStore.putResource
方法的具体详情如下:
包路径:org.apache.kylin.common.persistence.ResourceStore
类名称:ResourceStore
方法名:putResource
[英]Overwrite a resource without write conflict check
[中]在不进行写冲突检查的情况下覆盖资源
代码示例来源:origin: apache/kylin
private void saveResource(byte[] content, String path) throws IOException {
System.out.println("Generated " + outputStore.getReadableResourcePath(path));
if (outprint) {
System.out.println(Bytes.toString(content));
}
outputStore.putResource(path, new ByteArrayInputStream(content), System.currentTimeMillis());
}
代码示例来源:origin: apache/kylin
public void refresh() throws IOException {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
List<String> all = Lists.newArrayList();
collectFiles(this.store, "/", all);
for (String path : all) {
if (path.endsWith(MetadataConstants.FILE_SURFIX) && !(path.startsWith(ResourceStore.DICT_RESOURCE_ROOT) || path.startsWith(ResourceStore.SNAPSHOT_RESOURCE_ROOT))) {
logger.info("Updating metadata version of path {}", path);
ObjectNode objectNode = (ObjectNode) mapper.readTree(this.store.getResource(path).content());
objectNode.put("version", version);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
mapper.writeValue(baos, objectNode);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
this.store.putResource(path, bais, System.currentTimeMillis());
}
}
}
代码示例来源:origin: apache/kylin
public void saveQuery(final String creator, final Query query) throws IOException {
List<Query> queries = getQueries(creator);
queries.add(query);
Query[] queryArray = new Query[queries.size()];
QueryRecord record = new QueryRecord(queries.toArray(queryArray));
queryStore.putResource(getQueryKeyById(creator), record, System.currentTimeMillis(),
QueryRecordSerializer.getInstance());
return;
}
代码示例来源:origin: apache/kylin
public void removeQuery(final String creator, final String id) throws IOException {
List<Query> queries = getQueries(creator);
Iterator<Query> queryIter = queries.iterator();
boolean changed = false;
while (queryIter.hasNext()) {
Query temp = queryIter.next();
if (temp.getId().equals(id)) {
queryIter.remove();
changed = true;
break;
}
}
if (!changed) {
return;
}
Query[] queryArray = new Query[queries.size()];
QueryRecord record = new QueryRecord(queries.toArray(queryArray));
queryStore.putResource(getQueryKeyById(creator), record, System.currentTimeMillis(),
QueryRecordSerializer.getInstance());
return;
}
代码示例来源:origin: apache/kylin
public static void dumpResources(KylinConfig kylinConfig, File metaDir, Set<String> dumpList) throws IOException {
long startTime = System.currentTimeMillis();
ResourceStore from = ResourceStore.getStore(kylinConfig);
KylinConfig localConfig = KylinConfig.createInstanceFromUri(metaDir.getAbsolutePath());
ResourceStore to = ResourceStore.getStore(localConfig);
for (String path : dumpList) {
RawResource res = from.getResource(path);
if (res == null)
throw new IllegalStateException("No resource found at -- " + path);
to.putResource(path, res.content(), res.lastModified());
res.content().close();
}
logger.debug("Dump resources to {} took {} ms", metaDir, System.currentTimeMillis() - startTime);
}
代码示例来源:origin: apache/kylin
@Override
public void convertResult(ResultScanner rs, ResourceStore store) throws IOException {
if (rs == null)
return;
Result result = rs.next();
while (result != null) {
ManagedUser user = hbaseRowToUser(result);
store.putResource(KylinUserService.getId(user.getUsername()), user,
System.currentTimeMillis(), KylinUserService.SERIALIZER);
result = rs.next();
}
}
});
代码示例来源:origin: apache/kylin
if (res == null)
throw new IllegalStateException("No resource found at -- " + path);
to.putResource(path, res.content(), res.lastModified());
res.close();
代码示例来源:origin: apache/kylin
private void mockUpOldTableExtJson(String tableId, Map<String, String> tableExdProperties) throws IOException {
String path = TableExtDesc.concatResourcePath(tableId, null);
ByteArrayOutputStream os = new ByteArrayOutputStream();
JsonUtil.writeValueIndent(os, tableExdProperties);
os.flush();
InputStream is = new ByteArrayInputStream(os.toByteArray());
getStore().putResource(path, is, System.currentTimeMillis());
os.close();
is.close();
}
}
代码示例来源: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
if (res != null) {
try {
dst.putResource(path, res.content(), res.lastModified());
} finally {
res.close();
代码示例来源:origin: apache/kylin
rs.putResource(statisticsFileName, fis, System.currentTimeMillis());
} finally {
IOUtils.closeStream(fis);
代码示例来源: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
rs.putResource(statisticsFileName, fis, System.currentTimeMillis());
} finally {
IOUtils.closeStream(fis);
代码示例来源:origin: apache/kylin
@Override
public void visit(RawResource resource) {
String path = resource.path();
try {
if (!ResourceTool.matchFilter(path, includes, excludes))
return;
count[0]++;
stats.onResourceStart(path);
long nBytes = dst.putResource(path, resource.content(), resource.lastModified());
stats.onResourceSuccess(path, nBytes);
} catch (Exception ex) {
stats.onResourceError(path, ex);
} finally {
closeQuietly(resource);
}
}
});
代码示例来源:origin: apache/kylin
@Override
public void convertResult(ResultScanner rs, ResourceStore store) throws IOException {
if (rs == null)
return;
Result result = rs.next();
while (result != null) {
AclRecord record = new AclRecord();
ObjectIdentityImpl object = getDomainObjectInfoFromRs(result);
record.setDomainObjectInfo(object);
record.setParentDomainObjectInfo(getParentDomainObjectInfoFromRs(result));
record.setOwnerInfo(getOwnerSidInfo(result));
record.setEntriesInheriting(getInheriting(result));
record.setAllAceInfo(getAllAceInfo(result));
store.putResource(AclService.resourceKey(object.getId()), record,
System.currentTimeMillis(), AclService.SERIALIZER);
result = rs.next();
}
}
});
代码示例来源:origin: apache/kylin
rs.putResource(statisticsFileName, is, System.currentTimeMillis());
} finally {
IOUtils.closeStream(is);
代码示例来源:origin: apache/kylin
rs.putResource(statisticsFileName, mergedStats, System.currentTimeMillis());
代码示例来源:origin: apache/kylin
hbaseRS.putResource(statisticsFileName, hdfsRS.getResource(newSegment.getStatisticsResourcePath()).content(), System.currentTimeMillis());
代码示例来源:origin: apache/kylin
rs.putResource(resPath, is, System.currentTimeMillis());
logger.info("{} stats saved to resource {}", newSegment, resPath);
代码示例来源:origin: apache/kylin
store.putResource("/res1", new StringEntity("data1"), 1000, StringEntity.serializer);
} finally {
cp.close();
try {
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
store.putResource("/res2", is, 2000);
is.close();
store.putResource("/res1", str, 2000, StringEntity.serializer);
store.deleteResource("/res1");
内容来源于网络,如有侵权,请联系作者删除!