Java Code Examples for org.apache.kylin.cube.model.CubeDesc#getName()
The following examples show how to use
org.apache.kylin.cube.model.CubeDesc#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubeDescManager.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
/** * Create a new CubeDesc */ public CubeDesc createCubeDesc(CubeDesc cubeDesc) throws IOException { try (AutoLock lock = descMapLock.lockForWrite()) { if (cubeDesc.getUuid() == null || cubeDesc.getName() == null) throw new IllegalArgumentException(); if (cubeDescMap.containsKey(cubeDesc.getName())) throw new IllegalArgumentException("CubeDesc '" + cubeDesc.getName() + "' already exists"); if (cubeDesc.isDraft()) throw new IllegalArgumentException(String.format(Locale.ROOT, CUBE_SHOULD_NOT_BE_DRAFT_MSG, cubeDesc.getName())); try { cubeDesc.init(config); } catch (Exception e) { logger.warn("Broken cube desc " + cubeDesc, e); cubeDesc.addError(e.toString()); } postProcessCubeDesc(cubeDesc); // Check base validation if (cubeDesc.isBroken()) { return cubeDesc; } // Semantic validation CubeMetadataValidator validator = new CubeMetadataValidator(config); ValidateContext context = validator.validate(cubeDesc); if (!context.ifPass()) { return cubeDesc; } cubeDesc.setSignature(cubeDesc.calculateSignature()); // save resource crud.save(cubeDesc); return cubeDesc; } }
Example 2
Source File: CubeDescManager.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
/** * Update CubeDesc with the input. Broadcast the event into cluster */ public CubeDesc updateCubeDesc(CubeDesc desc) throws IOException { try (AutoLock lock = descMapLock.lockForWrite()) { // Validate CubeDesc if (desc.getUuid() == null || desc.getName() == null) throw new IllegalArgumentException(); String name = desc.getName(); if (!cubeDescMap.containsKey(name)) throw new IllegalArgumentException("CubeDesc '" + name + "' does not exist."); if (desc.isDraft()) throw new IllegalArgumentException(String.format(Locale.ROOT, CUBE_SHOULD_NOT_BE_DRAFT_MSG, desc.getName())); try { desc.init(config); } catch (Exception e) { logger.warn("Broken cube desc " + desc, e); desc.addError(e.toString()); return desc; } postProcessCubeDesc(desc); // Semantic validation CubeMetadataValidator validator = new CubeMetadataValidator(config); ValidateContext context = validator.validate(desc); if (!context.ifPass()) { return desc; } desc.setSignature(desc.calculateSignature()); // save resource crud.save(desc); return desc; } }
Example 3
Source File: CubeController.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
/** * save cubeDesc * * @return Table metadata array * @throws IOException */ @RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" }) @ResponseBody public CubeRequest saveCubeDesc(@RequestBody CubeRequest cubeRequest) { CubeDesc desc = deserializeCubeDesc(cubeRequest); if (desc == null) { cubeRequest.setMessage("CubeDesc is null."); return cubeRequest; } String name = desc.getName(); if (StringUtils.isEmpty(name)) { logger.info("Cube name should not be empty."); throw new BadRequestException("Cube name should not be empty."); } if (!ValidateUtil.isAlphanumericUnderscore(name)) { throw new BadRequestException("Invalid Cube name, only letters, numbers and underscore supported."); } validateColumnFamily(desc); try { desc.setUuid(RandomUtil.randomUUID().toString()); String projectName = (null == cubeRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME : cubeRequest.getProject(); ProjectInstance project = cubeService.getProjectManager().getProject(projectName); if (project == null) { throw new NotFoundException("Project " + projectName + " doesn't exist"); } cubeService.createCubeAndDesc(project, desc); } catch (Exception e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException(e.getLocalizedMessage(), e); } cubeRequest.setUuid(desc.getUuid()); cubeRequest.setSuccessful(true); return cubeRequest; }
Example 4
Source File: CubeService.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#project, 'ADMINISTRATION') or hasPermission(#project, 'MANAGEMENT')") public CubeInstance createCubeAndDesc(ProjectInstance project, CubeDesc desc) throws IOException { Message msg = MsgPicker.getMsg(); String cubeName = desc.getName(); if (getCubeManager().getCube(cubeName) != null) { throw new BadRequestException(String.format(Locale.ROOT, msg.getCUBE_ALREADY_EXIST(), cubeName)); } if (getCubeDescManager().getCubeDesc(desc.getName()) != null) { throw new BadRequestException(String.format(Locale.ROOT, msg.getCUBE_DESC_ALREADY_EXIST(), desc.getName())); } String owner = SecurityContextHolder.getContext().getAuthentication().getName(); CubeDesc createdDesc; CubeInstance createdCube; createdDesc = getCubeDescManager().createCubeDesc(desc); if (createdDesc.isBroken()) { throw new BadRequestException(createdDesc.getErrorsAsString()); } int cuboidCount = CuboidCLI.simulateCuboidGeneration(createdDesc, false); logger.info("New cube " + cubeName + " has " + cuboidCount + " cuboids"); createdCube = getCubeManager().createCube(cubeName, project.getName(), createdDesc, owner); return createdCube; }
Example 5
Source File: CubeService.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public void validateCubeDesc(CubeDesc desc, boolean isDraft) { Message msg = MsgPicker.getMsg(); if (desc == null) { throw new BadRequestException(msg.getINVALID_CUBE_DEFINITION()); } String cubeName = desc.getName(); if (StringUtils.isEmpty(cubeName)) { logger.info("Cube name should not be empty."); throw new BadRequestException(msg.getEMPTY_CUBE_NAME()); } if (!ValidateUtil.isAlphanumericUnderscore(cubeName)) { logger.info("Invalid Cube name {}, only letters, numbers and underscore supported.", cubeName); throw new BadRequestException(String.format(Locale.ROOT, msg.getINVALID_CUBE_NAME(), cubeName)); } if (!isDraft) { DataModelDesc modelDesc = modelService.getDataModelManager().getDataModelDesc(desc.getModelName()); if (modelDesc == null) { throw new BadRequestException( String.format(Locale.ROOT, msg.getMODEL_NOT_FOUND(), desc.getModelName())); } if (modelDesc.isDraft()) { logger.info("Cannot use draft model."); throw new BadRequestException( String.format(Locale.ROOT, msg.getUSE_DRAFT_MODEL(), desc.getModelName())); } } }
Example 6
Source File: CubeMigrationCrossClusterCLI.java From kylin with Apache License 2.0 | 5 votes |
private void checkGlobalDict(CubeDesc cubeDesc) { if (cubeDesc.getDictionaries() != null && !cubeDesc.getDictionaries().isEmpty()) { for (DictionaryDesc dictDesc : cubeDesc.getDictionaries()) { if (GlobalDictionaryBuilder.class.getName().equalsIgnoreCase(dictDesc.getBuilderClass())) { throw new RuntimeException("it's not supported to migrate global dictionaries " + dictDesc + " for cube " + cubeDesc.getName()); } } } }
Example 7
Source File: CubeDescManager.java From kylin with Apache License 2.0 | 5 votes |
/** * Create a new CubeDesc */ public CubeDesc createCubeDesc(CubeDesc cubeDesc) throws IOException { try (AutoLock lock = descMapLock.lockForWrite()) { if (cubeDesc.getUuid() == null || cubeDesc.getName() == null) throw new IllegalArgumentException(); if (cubeDescMap.containsKey(cubeDesc.getName())) throw new IllegalArgumentException("CubeDesc '" + cubeDesc.getName() + "' already exists"); if (cubeDesc.isDraft()) throw new IllegalArgumentException(String.format(Locale.ROOT, CUBE_SHOULD_NOT_BE_DRAFT_MSG, cubeDesc.getName())); try { cubeDesc.init(config); } catch (Exception e) { logger.warn("Broken cube desc " + cubeDesc, e); cubeDesc.addError(e.toString()); } postProcessCubeDesc(cubeDesc); // Check base validation if (cubeDesc.isBroken()) { return cubeDesc; } // Semantic validation CubeMetadataValidator validator = new CubeMetadataValidator(config); ValidateContext context = validator.validate(cubeDesc); if (!context.ifPass()) { return cubeDesc; } cubeDesc.setSignature(cubeDesc.calculateSignature()); // save resource crud.save(cubeDesc); return cubeDesc; } }
Example 8
Source File: CubeDescManager.java From kylin with Apache License 2.0 | 5 votes |
/** * Update CubeDesc with the input. Broadcast the event into cluster */ public CubeDesc updateCubeDesc(CubeDesc desc) throws IOException { try (AutoLock lock = descMapLock.lockForWrite()) { // Validate CubeDesc if (desc.getUuid() == null || desc.getName() == null) throw new IllegalArgumentException(); String name = desc.getName(); if (!cubeDescMap.containsKey(name)) throw new IllegalArgumentException("CubeDesc '" + name + "' does not exist."); if (desc.isDraft()) throw new IllegalArgumentException(String.format(Locale.ROOT, CUBE_SHOULD_NOT_BE_DRAFT_MSG, desc.getName())); try { desc.init(config); } catch (Exception e) { logger.warn("Broken cube desc " + desc, e); desc.addError(e.toString()); return desc; } postProcessCubeDesc(desc); // Semantic validation CubeMetadataValidator validator = new CubeMetadataValidator(config); ValidateContext context = validator.validate(desc); if (!context.ifPass()) { return desc; } desc.setSignature(desc.calculateSignature()); // save resource crud.save(desc); return desc; } }
Example 9
Source File: CubeController.java From kylin with Apache License 2.0 | 5 votes |
/** * save cubeDesc * * @return Table metadata array * @throws IOException */ @RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" }) @ResponseBody public CubeRequest saveCubeDesc(@RequestBody CubeRequest cubeRequest) { CubeDesc desc = deserializeCubeDesc(cubeRequest); if (desc == null) { cubeRequest.setMessage("CubeDesc is null."); return cubeRequest; } String name = desc.getName(); if (StringUtils.isEmpty(name)) { logger.info("Cube name should not be empty."); throw new BadRequestException("Cube name should not be empty."); } if (!ValidateUtil.isAlphanumericUnderscore(name)) { throw new BadRequestException("Invalid Cube name, only letters, numbers and underscore supported."); } validateColumnFamily(desc); try { desc.setUuid(RandomUtil.randomUUID().toString()); String projectName = (null == cubeRequest.getProject()) ? ProjectInstance.DEFAULT_PROJECT_NAME : cubeRequest.getProject(); ProjectInstance project = cubeService.getProjectManager().getProject(projectName); if (project == null) { throw new NotFoundException("Project " + projectName + " doesn't exist"); } cubeService.createCubeAndDesc(project, desc); } catch (Exception e) { logger.error("Failed to deal with the request.", e); throw new InternalErrorException(e.getLocalizedMessage(), e); } cubeRequest.setUuid(desc.getUuid()); cubeRequest.setSuccessful(true); return cubeRequest; }
Example 10
Source File: CubeService.java From kylin with Apache License 2.0 | 5 votes |
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#project, 'ADMINISTRATION') or hasPermission(#project, 'MANAGEMENT')") public CubeInstance createCubeAndDesc(ProjectInstance project, CubeDesc desc) throws IOException { Message msg = MsgPicker.getMsg(); String cubeName = desc.getName(); if (getCubeManager().getCube(cubeName) != null) { throw new BadRequestException(String.format(Locale.ROOT, msg.getCUBE_ALREADY_EXIST(), cubeName)); } if (getCubeDescManager().getCubeDesc(desc.getName()) != null) { throw new BadRequestException(String.format(Locale.ROOT, msg.getCUBE_DESC_ALREADY_EXIST(), desc.getName())); } String owner = SecurityContextHolder.getContext().getAuthentication().getName(); CubeDesc createdDesc; CubeInstance createdCube; createdDesc = getCubeDescManager().createCubeDesc(desc); if (createdDesc.isBroken()) { throw new BadRequestException(createdDesc.getErrorsAsString()); } int cuboidCount = CuboidCLI.simulateCuboidGeneration(createdDesc, false); logger.info("New cube " + cubeName + " has " + cuboidCount + " cuboids"); createdCube = getCubeManager().createCube(cubeName, project.getName(), createdDesc, owner); return createdCube; }
Example 11
Source File: CubeService.java From kylin with Apache License 2.0 | 5 votes |
public void validateCubeDesc(CubeDesc desc, boolean isDraft) { Message msg = MsgPicker.getMsg(); if (desc == null) { throw new BadRequestException(msg.getINVALID_CUBE_DEFINITION()); } String cubeName = desc.getName(); if (StringUtils.isEmpty(cubeName)) { logger.info("Cube name should not be empty."); throw new BadRequestException(msg.getEMPTY_CUBE_NAME()); } if (!ValidateUtil.isAlphanumericUnderscore(cubeName)) { logger.info("Invalid Cube name {}, only letters, numbers and underscore supported.", cubeName); throw new BadRequestException(String.format(Locale.ROOT, msg.getINVALID_CUBE_NAME(), cubeName)); } if (!isDraft) { DataModelDesc modelDesc = modelService.getDataModelManager().getDataModelDesc(desc.getModelName()); if (modelDesc == null) { throw new BadRequestException( String.format(Locale.ROOT, msg.getMODEL_NOT_FOUND(), desc.getModelName())); } if (modelDesc.isDraft()) { logger.info("Cannot use draft model."); throw new BadRequestException( String.format(Locale.ROOT, msg.getUSE_DRAFT_MODEL(), desc.getModelName())); } } }
Example 12
Source File: CubeDescManager.java From Kylin with Apache License 2.0 | 5 votes |
/** * Create a new CubeDesc * * @param cubeDesc * @return * @throws IOException */ public CubeDesc createCubeDesc(CubeDesc cubeDesc) throws IOException { if (cubeDesc.getUuid() == null || cubeDesc.getName() == null) throw new IllegalArgumentException(); if (cubeDescMap.containsKey(cubeDesc.getName())) throw new IllegalArgumentException("CubeDesc '" + cubeDesc.getName() + "' already exists"); try { cubeDesc.init(config, getMetadataManager().getAllTablesMap()); } catch (IllegalStateException e) { cubeDesc.addError(e.getMessage(), true); } // Check base validation if (!cubeDesc.getError().isEmpty()) { return cubeDesc; } // Semantic validation CubeMetadataValidator validator = new CubeMetadataValidator(); ValidateContext context = validator.validate(cubeDesc, true); if (!context.ifPass()) { return cubeDesc; } cubeDesc.setSignature(cubeDesc.calculateSignature()); String path = cubeDesc.getResourcePath(); getStore().putResource(path, cubeDesc, CUBE_DESC_SERIALIZER); cubeDescMap.put(cubeDesc.getName(), cubeDesc); return cubeDesc; }
Example 13
Source File: CubeControllerTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Test public void testBasics() throws IOException { CubeDesc[] cubes = cubeDescController.getCube("test_kylin_cube_with_slr_ready"); Assert.assertNotNull(cubes); Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000")); Assert.assertNotNull(cubeController.getCubes(null, null, null, 0, 5)); CubeDesc cube = cubes[0]; CubeDesc newCube = new CubeDesc(); String newCubeName = cube.getName() + "_test_save"; try { cubeController.deleteCube(newCubeName); } catch (Exception e) { // it may not exist, ignore the exception } newCube.setName(newCubeName); newCube.setModelName(cube.getModelName()); newCube.setModel(cube.getModel()); newCube.setDimensions(cube.getDimensions()); newCube.setHbaseMapping(cube.getHbaseMapping()); newCube.setMeasures(cube.getMeasures()); newCube.setRowkey(cube.getRowkey()); newCube.setAggregationGroups(cube.getAggregationGroups()); newCube.getModel().setLastModified(0); ObjectMapper cubeDescMapper = new ObjectMapper(); StringWriter cubeDescWriter = new StringWriter(); cubeDescMapper.writeValue(cubeDescWriter, newCube); ObjectMapper modelDescMapper = new ObjectMapper(); StringWriter modelDescWriter = new StringWriter(); modelDescMapper.writeValue(modelDescWriter, newCube.getModel()); CubeRequest cubeRequest = new CubeRequest(); cubeRequest.setCubeDescData(cubeDescWriter.toString()); cubeRequest.setCubeName(newCube.getName()); cubeRequest = cubeController.saveCubeDesc(cubeRequest); List<String> notifyList = Lists.newArrayList(); notifyList.add("[email protected]"); cubeController.updateNotifyList(newCubeName, notifyList); List<CubeInstanceResponse> cubeInstances = cubeController.getCubes(newCubeName, cube.getModelName(), "default", 1, 0); CubeInstance cubeInstance = cubeController.getCube(cubeInstances.get(0).getName()); Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]")); Assert.assertTrue(cubeInstance.getCost() == 495); cubeController.deleteCube(newCubeName); }
Example 14
Source File: CubeControllerTest.java From kylin with Apache License 2.0 | 4 votes |
@Test public void testBasics() throws IOException { CubeDesc[] cubes = cubeDescController.getCube("test_kylin_cube_with_slr_ready"); Assert.assertNotNull(cubes); Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000")); Assert.assertNotNull(cubeController.getCubes(null, null, null, 0, 5)); CubeDesc cube = cubes[0]; CubeDesc newCube = new CubeDesc(); String newCubeName = cube.getName() + "_test_save"; try { cubeController.deleteCube(newCubeName); } catch (Exception e) { // it may not exist, ignore the exception } newCube.setName(newCubeName); newCube.setModelName(cube.getModelName()); newCube.setModel(cube.getModel()); newCube.setDimensions(cube.getDimensions()); newCube.setHbaseMapping(cube.getHbaseMapping()); newCube.setMeasures(cube.getMeasures()); newCube.setRowkey(cube.getRowkey()); newCube.setAggregationGroups(cube.getAggregationGroups()); newCube.getModel().setLastModified(0); ObjectMapper cubeDescMapper = new ObjectMapper(); StringWriter cubeDescWriter = new StringWriter(); cubeDescMapper.writeValue(cubeDescWriter, newCube); ObjectMapper modelDescMapper = new ObjectMapper(); StringWriter modelDescWriter = new StringWriter(); modelDescMapper.writeValue(modelDescWriter, newCube.getModel()); CubeRequest cubeRequest = new CubeRequest(); cubeRequest.setCubeDescData(cubeDescWriter.toString()); cubeRequest.setCubeName(newCube.getName()); cubeRequest = cubeController.saveCubeDesc(cubeRequest); List<String> notifyList = Lists.newArrayList(); notifyList.add("[email protected]"); cubeController.updateNotifyList(newCubeName, notifyList); List<CubeInstanceResponse> cubeInstances = cubeController.getCubes(newCubeName, cube.getModelName(), "default", 1, 0); CubeInstance cubeInstance = cubeController.getCube(cubeInstances.get(0).getName()); Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]")); Assert.assertTrue(cubeInstance.getCost() == 495); cubeController.deleteCube(newCubeName); }
Example 15
Source File: CubeControllerTest.java From Kylin with Apache License 2.0 | 4 votes |
@Test public void testBasics() throws IOException { CubeDesc[] cubes = (CubeDesc[]) cubeDescController.getCube("test_kylin_cube_with_slr_ready"); Assert.assertNotNull(cubes); Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000")); Assert.assertNotNull(cubeController.getCubes(null, null, 0, 5)); CubeDesc cube = cubes[0]; CubeDesc newCube = new CubeDesc(); String newCubeName = cube.getName() + "_test_save"; try { cubeController.deleteCube(newCubeName); } catch (Exception e) { // it may not exist, ignore the exception } newCube.setName(newCubeName); newCube.setModelName(cube.getModelName()); newCube.setModel(cube.getModel()); newCube.setDimensions(cube.getDimensions()); newCube.setHBaseMapping(cube.getHBaseMapping()); newCube.setMeasures(cube.getMeasures()); newCube.setConfig(cube.getConfig()); newCube.setRowkey(cube.getRowkey()); String newModelName = newCubeName + "_model_desc"; newCube.getModel().setName(newModelName);//generate a random model newCube.getModel().setLastModified(0); ObjectMapper cubeDescMapper = new ObjectMapper(); StringWriter cubeDescWriter = new StringWriter(); cubeDescMapper.writeValue(cubeDescWriter, newCube); ObjectMapper modelDescMapper = new ObjectMapper(); StringWriter modelDescWriter = new StringWriter(); modelDescMapper.writeValue(modelDescWriter, newCube.getModel()); CubeRequest cubeRequest = new CubeRequest(); cubeRequest.setCubeDescData(cubeDescWriter.toString()); cubeRequest.setModelDescData(modelDescWriter.toString()); cubeRequest = cubeController.saveCubeDesc(cubeRequest); DataModelDesc model = modelController.getModel(newModelName); Assert.assertNotNull(model); List<String> notifyList = Lists.newArrayList(); notifyList.add("[email protected]"); cubeController.updateNotifyList(newCubeName, notifyList); cubeController.updateCubeCost(newCubeName, 80); List<CubeInstance> cubeInstances = cubeController.getCubes(newCubeName, "default", 1, 0); CubeInstance cubeInstance = cubeInstances.get(0); Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]")); Assert.assertTrue(cubeInstance.getCost() == 80); cubeController.deleteCube(newCubeName); }