本文整理汇总了Java中org.apache.kylin.metadata.project.ProjectInstance类的典型用法代码示例。如果您正苦于以下问题:Java ProjectInstance类的具体用法?Java ProjectInstance怎么用?Java ProjectInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProjectInstance类属于org.apache.kylin.metadata.project包,在下文中一共展示了ProjectInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listJobInstances
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
private List<JobInstance> listJobInstances(String project, String cube, long startTime, long endTime) {
final List<JobInstance> result = Lists.newArrayList();
final List<AbstractExecutable> executables = executableManager.getAllExecutables(startTime, endTime);
final Map<String, Output> allOutputs = executableManager.getAllOutputs();
for (AbstractExecutable executable : executables) {
if (executable instanceof CubingJob) {
String cubeName = CubingExecutableUtil.getCubeName(executable.getParams());
boolean shouldExtract = false;
if (cube == null || cube.equalsIgnoreCase(cubeName)) {
if (project == null) {
shouldExtract = true;
} else {
ProjectInstance projectInstance = projectManager.getProject(project);
if (projectInstance != null && projectInstance.containsRealization(RealizationType.CUBE, cubeName)) {
shouldExtract = true;
}
}
}
if (shouldExtract) {
result.add(parseToJobInstance((CubingJob) executable, allOutputs));
}
}
}
return result;
}
示例2: getModels
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
public List<DataModelDesc> getModels(String projectName) {
try (AutoLock lock = modelMapLock.lockForRead()) {
ProjectInstance projectInstance = ProjectManager.getInstance(config).getProject(projectName);
ArrayList<DataModelDesc> ret = new ArrayList<>();
if (projectInstance != null && projectInstance.getModels() != null) {
for (String modelName : projectInstance.getModels()) {
DataModelDesc model = getDataModelDesc(modelName);
if (null != model) {
ret.add(model);
} else {
logger.info("Model " + modelName + " is missing or unloaded yet");
}
}
}
return ret;
}
}
示例3: onEntityChange
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@Override
public void onEntityChange(Broadcaster broadcaster, String entity, Event event, String cacheKey)
throws IOException {
try (AutoLock lock = srcTableMapLock.lockForWrite()) {
if (event == Event.DROP)
srcTableMap.removeLocal(cacheKey);
else
srcTableCrud.reloadQuietly(cacheKey);
}
Pair<String, String> pair = TableDesc.parseResourcePath(cacheKey);
String table = pair.getFirst();
String prj = pair.getSecond();
if (prj == null) {
for (ProjectInstance p : ProjectManager.getInstance(config).findProjectsByTable(table)) {
broadcaster.notifyProjectSchemaUpdate(p.getName());
}
} else {
broadcaster.notifyProjectSchemaUpdate(prj);
}
}
示例4: getAllTablesMap
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
public Map<String, TableDesc> getAllTablesMap(String prj) {
// avoid cyclic locks
ProjectInstance project = (prj == null) ? null : ProjectManager.getInstance(config).getProject(prj);
try (AutoLock lock = srcTableMapLock.lockForWrite()) {
//TODO prj == null case is now only used by test case and CubeMetaIngester
//should refactor these test case and tool ASAP and stop supporting null case
if (prj == null) {
Map<String, TableDesc> globalTables = new LinkedHashMap<>();
for (TableDesc t : srcTableMap.values()) {
globalTables.put(t.getIdentity(), t);
}
return globalTables;
}
Set<String> prjTableNames = project.getTables();
Map<String, TableDesc> ret = new LinkedHashMap<>();
for (String tableName : prjTableNames) {
String tableIdentity = getTableIdentity(tableName);
ret.put(tableIdentity, getProjectSpecificTableDesc(tableIdentity, prj));
}
return ret;
}
}
示例5: resetProjectSpecificTableDesc
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
/**
* the project-specific table desc will be expand by computed columns from the projects' models
* when the projects' model list changed, project-specific table should be reset and get expanded
* again
*/
public void resetProjectSpecificTableDesc(String prj) throws IOException {
// avoid cyclic locks
ProjectInstance project = ProjectManager.getInstance(config).getProject(prj);
try (AutoLock lock = srcTableMapLock.lockForWrite()) {
for (String tableName : project.getTables()) {
String tableIdentity = getTableIdentity(tableName);
String key = mapKey(tableIdentity, prj);
TableDesc originTableDesc = srcTableMap.get(key);
if (originTableDesc == null) {
continue;
}
if (originTableDesc.isBorrowedFromGlobal()) {
srcTableMap.removeLocal(key);//delete it so that getProjectSpecificTableDesc will create again
} else {
srcTableCrud.reload(key);
}
}
}
}
示例6: setupAll
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
protected static void setupAll() throws Exception {
//setup env
HBaseMetadataTestCase.staticCreateTestMetadata();
config = KylinConfig.getInstanceFromEnv();
//setup cube conn
String project = ProjectInstance.DEFAULT_PROJECT_NAME;
cubeConnection = QueryConnection.getConnection(project);
//setup h2
h2Connection = DriverManager.getConnection("jdbc:h2:mem:db" + (h2InstanceCount++) + ";CACHE_SIZE=32072", "sa",
"");
// Load H2 Tables (inner join)
H2Database h2DB = new H2Database(h2Connection, config, project);
h2DB.loadAllTables();
}
示例7: onEntityChange
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@Override
public void onEntityChange(Broadcaster broadcaster, String entity, Event event, String cacheKey)
throws IOException {
if ("hybrid".equals(entity)) {
String hybridName = cacheKey;
try (AutoLock l = lock.lockForWrite()) {
if (event == Event.DROP)
hybridMap.removeLocal(hybridName);
else
crud.reloadQuietly(hybridName);
}
for (ProjectInstance prj : ProjectManager.getInstance(config).findProjects(RealizationType.HYBRID,
hybridName)) {
broadcaster.notifyProjectSchemaUpdate(prj.getName());
}
} else if ("cube".equals(entity)) {
String cubeName = cacheKey;
try (AutoLock l = lock.lockForWrite()) {
for (HybridInstance hybrid : getHybridInstancesByChild(RealizationType.CUBE, cubeName)) {
crud.reloadQuietly(hybrid.getName());
}
}
}
}
示例8: testAddUpdateProject
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@Test
public void testAddUpdateProject() throws IOException {
int originalProjectCount = projectController.getProjects(null, null).size();
//test add project
ProjectInstance project = new ProjectInstance();
project.setName("new_project");
ProjectInstance ret = projectController.saveProject(getProjectRequest(project, null));
Assert.assertEquals(ret.getOwner(), "ADMIN");
Assert.assertEquals(ProjectManager.getInstance(getTestConfig()).listAllProjects().size(), originalProjectCount + 1);
//test update project description only
ProjectInstance newProject2 = new ProjectInstance();
newProject2.setName("new_project");
newProject2.setDescription("hello world");
projectController.updateProject(getProjectRequest(newProject2, "new_project"));
Assert.assertEquals(ProjectManager.getInstance(getTestConfig()).listAllProjects().size(), originalProjectCount + 1);
Assert.assertNotEquals(ProjectManager.getInstance(getTestConfig()).getProject("new_project"), null);
Assert.assertEquals(ProjectManager.getInstance(getTestConfig()).getProject("new_project").getDescription(), "hello world");
}
示例9: testGetUserPermissionInPrj
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@Test
public void testGetUserPermissionInPrj() {
List<ProjectInstance> projects = projectController.getProjects(10000, 0);
assertTrue(projects.size() > 0);
ProjectInstance project = projects.get(0);
ManagedUser user = new ManagedUser("u", "kylin", false, "all_users");
userService.createUser(user);
grantPermission("g1", READ, project.getUuid());
grantPermission("g2", READ, project.getUuid());
swichUser("u", "g1", "g2");
Assert.assertEquals(READ, accessController.getUserPermissionInPrj(project.getName()));
grantPermission("g1", MANAGEMENT, project.getUuid());
grantPermission("g2", ADMINISTRATION, project.getUuid());
grantPermission("g3", OPERATION, project.getUuid());
grantPermission("g4", READ, project.getUuid());
swichUser("u", "g1", "g2", "g3", "g4");
Assert.assertEquals(ADMINISTRATION, accessController.getUserPermissionInPrj(project.getName()));
}
示例10: testAuthInProjectLevel
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@Test
public void testAuthInProjectLevel() throws Exception {
List<AccessEntryResponse> aes = null;
swichToAdmin();
List<ProjectInstance> projects = projectController.getProjects(10000, 0);
assertTrue(projects.size() > 0);
ProjectInstance project = projects.get(0);
swichToAnalyst();
projects = projectController.getProjects(10000, 0);
assertEquals(0, projects.size());
//grant auth in project level
swichToAdmin();
aes = accessController.grant(PROJECT_INSTANCE, project.getUuid(), getAccessRequest(ANALYST, READ, true));
swichToAnalyst();
projects = projectController.getProjects(10000, 0);
assertEquals(1, projects.size());
//revoke auth
swichToAdmin();
AccessRequest request = getAccessRequest(ANALYST, READ, true);
request.setAccessEntryId((Long) aes.get(0).getId());
accessController.revoke(PROJECT_INSTANCE, project.getUuid(), request);
swichToAnalyst();
projects = projectController.getProjects(10000, 0);
assertEquals(0, projects.size());
}
示例11: testBasics
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@Test
public void testBasics() throws JobException, IOException, SQLException {
Assert.assertNotNull(queryService.getConfig());
Assert.assertNotNull(queryService.getConfig());
Assert.assertNotNull(queryService.getDataModelManager());
Assert.assertNotNull(QueryConnection.getConnection(ProjectInstance.DEFAULT_PROJECT_NAME));
// Assert.assertTrue(queryService.getQueries("ADMIN").size() == 0);
//
// queryService.saveQuery("test", "test", "select * from test_table", "test");
// Assert.assertTrue(queryService.getQueries("ADMIN").size() == 1);
//
// queryService.removeQuery(queryService.getQueries("ADMIN").get(0).getProperty("id"));
// Assert.assertTrue(queryService.getQueries("ADMIN").size() == 0);
SQLRequest request = new SQLRequest();
request.setSql("select * from test_table");
request.setAcceptPartial(true);
SQLResponse response = new SQLResponse();
response.setHitExceptionCache(true);
queryService.logQuery(request, response);
}
示例12: filterByProjects
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
private static List<String> filterByProjects(List<String> allTableNames, List<String> projectNames) {
ProjectManager projectManager = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv());
CubeManager cubeManager = CubeManager.getInstance(KylinConfig.getInstanceFromEnv());
List<String> result = Lists.newArrayList();
for (String p : projectNames) {
p = p.trim();
if (p.endsWith(",")) {
p = p.substring(0, p.length() - 1);
}
ProjectInstance projectInstance = projectManager.getProject(p);
List<RealizationEntry> cubeList = projectInstance.getRealizationEntries(RealizationType.CUBE);
for (RealizationEntry cube : cubeList) {
CubeInstance cubeInstance = cubeManager.getCube(cube.getRealization());
for (CubeSegment segment : cubeInstance.getSegments()) {
String tableName = segment.getStorageLocationIdentifier();
if (allTableNames.contains(tableName)) {
result.add(tableName);
}
}
}
}
return result;
}
示例13: onEntityChange
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@Override
public void onEntityChange(Broadcaster broadcaster, String entity, Event event, String cacheKey)
throws IOException {
String cubeDescName = cacheKey;
CubeDesc cubeDesc = getCubeDesc(cubeDescName);
String modelName = cubeDesc == null ? null : cubeDesc.getModelName();
if (event == Event.DROP)
removeLocalCubeDesc(cubeDescName);
else
reloadCubeDescQuietly(cubeDescName);
for (ProjectInstance prj : ProjectManager.getInstance(config).findProjectsByModel(modelName)) {
broadcaster.notifyProjectSchemaUpdate(prj.getName());
}
}
示例14: testCreateAndDrop
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@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"));
}
示例15: saveProject
import org.apache.kylin.metadata.project.ProjectInstance; //导入依赖的package包/类
@RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" })
@ResponseBody
public ProjectInstance saveProject(@RequestBody ProjectRequest projectRequest) {
ProjectInstance projectDesc = deserializeProjectDesc(projectRequest);
if (StringUtils.isEmpty(projectDesc.getName())) {
throw new InternalErrorException("A project name must be given to create a project");
}
if (!StringUtils.containsOnly(projectDesc.getName(), VALID_PROJECTNAME)) {
logger.info("Invalid Project name {}, only letters, numbers and underline supported.", projectDesc.getName());
throw new BadRequestException("Invalid Project name, only letters, numbers and underline supported.");
}
ProjectInstance createdProj = null;
try {
createdProj = projectService.createProject(projectDesc);
} catch (Exception e) {
logger.error("Failed to deal with the request.", e);
throw new InternalErrorException(e.getLocalizedMessage());
}
return createdProj;
}